Search in sources :

Example 1 with PartialParsingPointers

use of org.eclipse.xtext.parser.impl.PartialParsingPointers in project xtext-core by eclipse.

the class PartialParsingPointerLookaheadTest method testLookahead_9_14.

@Test
public void testLookahead_9_14() throws Exception {
    String model = "bar a foo bar c b d foo bar b c";
    for (int i = 9; i < 15; ++i) {
        PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
        // actual expecation would lead to yet more complexity in partial
        // parser
        // checkParseRegionPointers(parsingPointers, " foo bar c b d", "RuleCall", "Alts");
        checkParseRegionPointers(parsingPointers, model, "ParserRule", "Entry");
    }
}
Also used : PartialParsingPointers(org.eclipse.xtext.parser.impl.PartialParsingPointers) Test(org.junit.Test)

Example 2 with PartialParsingPointers

use of org.eclipse.xtext.parser.impl.PartialParsingPointers in project xtext-core by eclipse.

the class PartialParsingPointerLookaheadTest method testLookahead_19_22.

@Test
public void testLookahead_19_22() throws Exception {
    String model = "bar a foo bar c b d foo bar b c";
    for (int i = 19; i < 22; ++i) {
        PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
        checkParseRegionPointers(parsingPointers, model, "ParserRule", "Entry");
    }
}
Also used : PartialParsingPointers(org.eclipse.xtext.parser.impl.PartialParsingPointers) Test(org.junit.Test)

Example 3 with PartialParsingPointers

use of org.eclipse.xtext.parser.impl.PartialParsingPointers in project xtext-core by eclipse.

the class PartialParsingPointerLookaheadTest method testLookahead_0_2.

@Test
public void testLookahead_0_2() throws Exception {
    String model = "bar a foo bar c b d foo bar b c";
    for (int i = 0; i < 3; ++i) {
        PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
        checkParseRegionPointers(parsingPointers, model, "ParserRule", "Entry");
    }
}
Also used : PartialParsingPointers(org.eclipse.xtext.parser.impl.PartialParsingPointers) Test(org.junit.Test)

Example 4 with PartialParsingPointers

use of org.eclipse.xtext.parser.impl.PartialParsingPointers in project xtext-core by eclipse.

the class PartialParsingPointerLookaheadTest method testLookahead_23_28.

@Test
public void testLookahead_23_28() throws Exception {
    String model = "bar a foo bar c b d foo bar b c";
    for (int i = 23; i < 29; ++i) {
        PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
        checkParseRegionPointers(parsingPointers, model, "ParserRule", "Entry");
    }
}
Also used : PartialParsingPointers(org.eclipse.xtext.parser.impl.PartialParsingPointers) Test(org.junit.Test)

Example 5 with PartialParsingPointers

use of org.eclipse.xtext.parser.impl.PartialParsingPointers in project xtext-core by eclipse.

the class AbstractPartialParserReplaceTest method replaceAndReparse.

protected void replaceAndReparse(String model, int offset, int length, String change, String expectedReparseRegion) throws Exception {
    IParseResult parseResult = getParseResult(model);
    PartialParsingPointers parsingPointers = getPartialParser().calculatePartialParsingPointers(parseResult, offset, length);
    String reparseRegion = getPartialParser().insertChangeIntoReplaceRegion(parsingPointers.getDefaultReplaceRootNode(), new ReplaceRegion(offset, length, change));
    assertEquals(expectedReparseRegion, reparseRegion);
    final Wrapper<Boolean> unloaded = Wrapper.wrap(Boolean.FALSE);
    getPartialParser().setUnloader(new IReferableElementsUnloader() {

        @Override
        public void unloadRoot(EObject root) {
            unloaded.set(Boolean.TRUE);
        }
    });
    IParseResult partiallyReparse = reparse(parseResult, offset, length, change);
    assertTrue("unloaded", unloaded.get());
    assertFalse(partiallyReparse.getRootNode().getText(), partiallyReparse.hasSyntaxErrors());
    String expectedReparseModel = model.substring(0, offset) + change + model.substring(offset + length);
    assertEquals(expectedReparseModel, partiallyReparse.getRootNode().getText());
}
Also used : IReferableElementsUnloader(org.eclipse.xtext.parser.antlr.IReferableElementsUnloader) ReplaceRegion(org.eclipse.xtext.util.ReplaceRegion) EObject(org.eclipse.emf.ecore.EObject) PartialParsingPointers(org.eclipse.xtext.parser.impl.PartialParsingPointers)

Aggregations

PartialParsingPointers (org.eclipse.xtext.parser.impl.PartialParsingPointers)22 Test (org.junit.Test)17 EObject (org.eclipse.emf.ecore.EObject)3 ReplaceRegion (org.eclipse.xtext.util.ReplaceRegion)3 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)2 IParseResult (org.eclipse.xtext.parser.IParseResult)2 IReferableElementsUnloader (org.eclipse.xtext.parser.antlr.IReferableElementsUnloader)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1 ParserRule (org.eclipse.xtext.ParserRule)1 RuleCall (org.eclipse.xtext.RuleCall)1 SyntheticCompositeNode (org.eclipse.xtext.nodemodel.impl.SyntheticCompositeNode)1 ParseException (org.eclipse.xtext.parser.ParseException)1 ParseResult (org.eclipse.xtext.parser.ParseResult)1 Range (org.eclipse.xtext.parser.impl.Range)1