use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder in project xtext-xtend by eclipse.
the class RichStringToLineModel method announceNextLiteral.
@Override
public void announceNextLiteral(final RichStringLiteral object) {
super.announceNextLiteral(object);
if (((this.lastLiteralEndOffset > 0) && (this.contentStartOffset < 0))) {
this.contentStartOffset = this.lastLiteralEndOffset;
}
IEObjectRegion _regionForEObject = this.nodeModelAccess.regionForEObject(object);
ISemanticRegionsFinder _regionFor = null;
if (_regionForEObject != null) {
_regionFor = _regionForEObject.getRegionFor();
}
ISemanticRegion _feature = null;
if (_regionFor != null) {
_feature = _regionFor.feature(XbasePackage.Literals.XSTRING_LITERAL__VALUE);
}
final ISemanticRegion node = _feature;
if ((node != null)) {
int _offset = node.getOffset();
int _literalPrefixLenght = this.literalPrefixLenght(node);
int _plus = (_offset + _literalPrefixLenght);
this.offset = _plus;
int _endOffset = node.getEndOffset();
int _literalPostfixLenght = this.literalPostfixLenght(node);
int _minus = (_endOffset - _literalPostfixLenght);
this.lastLiteralEndOffset = _minus;
}
this.content = true;
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder in project xtext-core by eclipse.
the class ReferenceUpdater method getRegion.
protected ISemanticRegion getRegion(ITextRegionAccess access, IReferenceSnapshot ref) {
XtextResource resource = access.getResource();
URI objectUri = ref.getSourceEObjectUri();
if (!resource.getURI().equals(objectUri.trimFragment())) {
return null;
}
EObject object = resource.getEObject(objectUri.fragment());
if (object == null) {
return null;
}
ISemanticRegionsFinder finder = access.getExtensions().regionFor(object);
int index = ref.getIndexInList();
if (index < 0) {
return finder.feature(ref.getEReference());
} else {
List<ISemanticRegion> list = finder.features(ref.getEReference());
if (list != null && index < list.size()) {
return list.get(index);
}
}
return null;
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder in project xtext-core by eclipse.
the class SemanticRegionFinderTest method regionForRuleCallCrossReference.
@Test
public void regionForRuleCallCrossReference() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("6 (ref foo) action (foo) end");
final AssignedAction mixed = this.<AssignedAction>parseAs(_builder, AssignedAction.class);
final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed.getChild()).getRegionFor();
final ISemanticRegion actual = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getRefMixedIDTerminalRuleCall_2_2_3_1_0_1());
final List<ISemanticRegion> actuals = finder.ruleCalls(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getRefMixedIDTerminalRuleCall_2_2_3_1_0_1());
this.assertEquals("foo", actual, actuals);
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder in project xtext-core by eclipse.
the class SemanticRegionFinderTest method regionForRuleCallAssignedTerminal.
@Test
public void regionForRuleCallAssignedTerminal() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("6 (foo)");
final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
final ISemanticRegion actual = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getNameIDTerminalRuleCall_2_2_0_0());
final ISemanticRegion actuals = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getNameIDTerminalRuleCall_2_2_0_0());
Assert.assertEquals("foo", actual, actuals);
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder in project xtext-core by eclipse.
the class SemanticRegionFinderTest method regionForRuleCallAssignedDataType.
@Test
public void regionForRuleCallAssignedDataType() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("6 (datatype foo)");
final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
final ISemanticRegion actual = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getDatatypeDatatypeParserRuleCall_2_2_2_0());
final ISemanticRegion actuals = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getDatatypeDatatypeParserRuleCall_2_2_2_0());
Assert.assertEquals("datatype foo", actual, actuals);
}
Aggregations