Search in sources :

Example 16 with PartialParsingPointers

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

the class PartialParsingPointerLookaheadTest method testLookahead_15_18.

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

Example 17 with PartialParsingPointers

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

the class PartialParsingPointerLookaheadTest method testLookahead_3_4.

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

Example 18 with PartialParsingPointers

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

the class PartialParsingPointerLookaheadTest method testLookahead_6_8.

@Test
public void testLookahead_6_8() throws Exception {
    String model = "bar a foo bar c b d foo bar b c";
    for (int i = 6; i < 9; ++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 19 with PartialParsingPointers

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

the class Bug419429Test method replaceAndReparse.

protected void replaceAndReparse(String model, int offset, int length, String change, String expectedReparseRegion) throws Exception {
    IParseResult parseResult = getParseResultAndExpect(model, UNKNOWN_EXPECTATION);
    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());
    String expectedReparseModel = model.substring(0, offset) + change + model.substring(offset + length);
    assertEquals(expectedReparseModel, partiallyReparse.getRootNode().getText());
    compareWithFullParse(model, offset, length, change);
}
Also used : IReferableElementsUnloader(org.eclipse.xtext.parser.antlr.IReferableElementsUnloader) ReplaceRegion(org.eclipse.xtext.util.ReplaceRegion) EObject(org.eclipse.emf.ecore.EObject) IParseResult(org.eclipse.xtext.parser.IParseResult) PartialParsingPointers(org.eclipse.xtext.parser.impl.PartialParsingPointers)

Aggregations

PartialParsingPointers (org.eclipse.xtext.parser.impl.PartialParsingPointers)19 Test (org.junit.Test)16 EObject (org.eclipse.emf.ecore.EObject)2 IReferableElementsUnloader (org.eclipse.xtext.parser.antlr.IReferableElementsUnloader)2 ReplaceRegion (org.eclipse.xtext.util.ReplaceRegion)2 IParseResult (org.eclipse.xtext.parser.IParseResult)1