Java Code Examples for org.eclipse.xtext.nodemodel.impl.InvariantChecker#checkInvariant()
The following examples show how to use
org.eclipse.xtext.nodemodel.impl.InvariantChecker#checkInvariant() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bug480686Test.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testBrokenInput_01() throws Exception { ContentAssistFragmentTestLanguageRoot result = parseHelper.parse("}"); XtextResource res = (XtextResource) result.eResource(); InvariantChecker invariantChecker = new InvariantChecker(); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); res.update(0, 0, "newArrayList()"); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); EObject first = Iterables.getFirst(res.getContents(), null); Assert.assertTrue(first.eClass().getName(), first instanceof ContentAssistFragmentTestLanguageRoot); res.update("newArrayList(".length(), 0, "1"); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); EObject second = Iterables.getFirst(res.getContents(), null); Assert.assertTrue(second.eClass().getName(), second instanceof ContentAssistFragmentTestLanguageRoot); }
Example 2
Source File: Bug480686Test.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testBrokenInput_02() throws Exception { ContentAssistFragmentTestLanguageRoot result = parseHelper.parse("}} abc"); XtextResource res = (XtextResource) result.eResource(); InvariantChecker invariantChecker = new InvariantChecker(); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); res.update(0, 0, "newArrayList()"); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); EObject first = Iterables.getFirst(res.getContents(), null); Assert.assertTrue(first.eClass().getName(), first instanceof ContentAssistFragmentTestLanguageRoot); res.update("newArrayList(".length(), 0, "1"); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); EObject second = Iterables.getFirst(res.getContents(), null); Assert.assertTrue(second.eClass().getName(), second instanceof ContentAssistFragmentTestLanguageRoot); }
Example 3
Source File: PartialParsingProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void assertEqual(String data, String newData, ICompositeNode fromScratch, ICompositeNode reparsed) { InvariantChecker checker = new InvariantChecker(); checker.checkInvariant(reparsed); Iterator<INode> scratchIterator = fromScratch.getAsTreeIterable().iterator(); Iterator<INode> reparsedIterator = reparsed.getAsTreeIterable().iterator(); while(scratchIterator.hasNext()) { Assert.assertTrue(reparsedIterator.hasNext()); assertEqualNodes(data, newData, scratchIterator.next(), reparsedIterator.next()); } Assert.assertFalse(scratchIterator.hasNext()); Assert.assertFalse(reparsedIterator.hasNext()); }
Example 4
Source File: PartialParsingProcessor.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private void assertEqual(String data, String newData, ICompositeNode fromScratch, ICompositeNode reparsed) { InvariantChecker checker = new InvariantChecker(); checker.checkInvariant(reparsed); Iterator<INode> scratchIterator = fromScratch.getAsTreeIterable().iterator(); Iterator<INode> reparsedIterator = reparsed.getAsTreeIterable().iterator(); while(scratchIterator.hasNext()) { Assert.assertTrue(reparsedIterator.hasNext()); assertEqualNodes(data, newData, scratchIterator.next(), reparsedIterator.next()); } Assert.assertFalse(scratchIterator.hasNext()); Assert.assertFalse(reparsedIterator.hasNext()); }