use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-core by eclipse.
the class SemanticRegionFinderTest method regionForKeywordString.
@Test
public void regionForKeywordString() throws Exception {
Mixed mixed = parseAs("6 (foo)", Mixed.class);
ISemanticRegionsFinder finder = toAccess(mixed).regionForEObject(mixed).getRegionFor();
ISemanticRegion actual = finder.keyword("(");
List<ISemanticRegion> actuals = finder.keywords("(");
assertEquals("(", actual, actuals);
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-core by eclipse.
the class SemanticRegionFinderTest method regionForRuleCallUnassignedDataType.
@Test
public void regionForRuleCallUnassignedDataType() throws Exception {
Mixed mixed = parseAs("6 (unassigned datatype foo)", Mixed.class);
ISemanticRegionsFinder finder = toAccess(mixed).regionForEObject(mixed).getRegionFor();
ISemanticRegion actual = finder.ruleCall(grammarAccess.getMixedAccess().getDatatypeParserRuleCall_1_1_1());
List<ISemanticRegion> actuals = finder.ruleCalls(grammarAccess.getMixedAccess().getDatatypeParserRuleCall_1_1_1());
assertEquals("datatype foo", actual, actuals);
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-core by eclipse.
the class SemanticRegionFinderTest method regionForRuleCallCrossReference.
@Test
public void regionForRuleCallCrossReference() throws Exception {
AssignedAction mixed = parseAs("6 (ref foo) action (foo) end", AssignedAction.class);
ISemanticRegionsFinder finder = toAccess(mixed).regionForEObject(mixed.getChild()).getRegionFor();
ISemanticRegion actual = finder.ruleCall(grammarAccess.getMixedAccess().getRefMixedIDTerminalRuleCall_2_2_3_1_0_1());
List<ISemanticRegion> actuals = finder.ruleCalls(grammarAccess.getMixedAccess().getRefMixedIDTerminalRuleCall_2_2_3_1_0_1());
assertEquals("foo", actual, actuals);
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-core by eclipse.
the class SemanticRegionFinderTest method regionForRuleCallToAssignedDataType.
@Test
public void regionForRuleCallToAssignedDataType() throws Exception {
Mixed mixed = parseAs("6 (datatype foo)", Mixed.class);
ISemanticRegionsFinder finder = toAccess(mixed).regionForEObject(mixed).getRegionFor();
ISemanticRegion actual = finder.ruleCallTo(grammarAccess.getDatatypeRule());
ISemanticRegion actuals = finder.ruleCallTo(grammarAccess.getDatatypeRule());
Assert.assertEquals("datatype foo", actual, actuals);
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-core by eclipse.
the class RegionAccessCommentsTest method testDeleteFirstRegion1.
@Test
public void testDeleteFirstRegion1() throws Exception {
String model = "/*h*/\n" + "\n" + "/*8*/\n" + "8 //8\n" + "/*a*/\n" + "a\n";
ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
ISemanticRegion foo = access.regionForRootEObject().getAllRegionsFor().keyword("8");
it.remove(foo);
});
String expectation = " 0 1 H \"/*h*/\" Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + " \"\\n" + "\\n" + "\" Whitespace:TerminalRule'WS'\n" + " \"/*a*/\" Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + " 13 \"\\n" + "\" Whitespace:TerminalRule'WS'\n" + " B ValueList'[a]' Root\n" + "13 1 S \"a\" ValueList:name+=ID\n" + " E ValueList'[a]' Root\n" + "14 0 H\n" + "------------ diff 1 ------------\n" + " 0 H \"/*h*/\" Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + " \"\\n" + "\\n" + "\" Whitespace:TerminalRule'WS'\n" + " \"/*8*/\" Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + " 13 \"\\n" + "\" Whitespace:TerminalRule'WS'\n" + "13 1 S \"8\" Root:'8'\n" + "14 H \" \" Whitespace:TerminalRule'WS'\n" + " \"//8\\n" + "\" Comment:TerminalRule'SL_COMMENT' Association:PREVIOUS\n" + " \"/*a*/\" Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + " 11 \"\\n" + "\" Whitespace:TerminalRule'WS'\n";
regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
Aggregations