use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-xtend by eclipse.
the class JavaDocTypeReferenceProviderTest method testComputation_7.
@Test
public void testComputation_7() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("/**");
_builder.newLine();
_builder.append("* {@link String}");
_builder.newLine();
_builder.append("*/");
_builder.newLine();
_builder.append("class Foo{}");
_builder.newLine();
final String input = _builder.toString();
Resource _eResource = this.clazz(input).eResource();
final XtextResource resource = ((XtextResource) _eResource);
final ICompositeNode rootNode = resource.getParseResult().getRootNode();
final List<ReplaceRegion> regions = this.javaDocTypeReferenceProvider.computeTypeRefRegions(rootNode);
Assert.assertEquals(1, regions.size());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-xtend by eclipse.
the class ParserTest method testAllGrammarElementsUniqueAfterReparse.
@Test
public void testAllGrammarElementsUniqueAfterReparse() throws Exception {
String text = "class Foo { def m() { newArrayList() } }";
XtendClass clazz = clazz(text);
XtextResource resource = (XtextResource) clazz.eResource();
resource.update(text.indexOf('m'), 0, "m");
ICompositeNode root = resource.getParseResult().getRootNode();
assertSame(root, root.getRootNode());
Set<EObject> grammarElements = Sets.newHashSet();
for (INode node : root.getAsTreeIterable()) {
if (node instanceof ICompositeNode) {
if (node.getGrammarElement() == null) {
fail("node without grammar element");
}
if (!grammarElements.add(node.getGrammarElement())) {
fail(node.getGrammarElement().toString());
}
}
}
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-xtend by eclipse.
the class ParserTest method testAllGrammarElementsUnique.
@Test
public void testAllGrammarElementsUnique() throws Exception {
XtendClass clazz = clazz("class Foo { def m() { newArrayList() } }");
XtextResource resource = (XtextResource) clazz.eResource();
ICompositeNode root = resource.getParseResult().getRootNode();
new InvariantChecker().checkInvariant(root);
assertSame(root, root.getRootNode());
Set<EObject> grammarElements = Sets.newHashSet();
for (INode node : root.getAsTreeIterable()) {
if (node instanceof ICompositeNode) {
if (node.getGrammarElement() == null) {
fail("node without grammar element");
}
if (!grammarElements.add(node.getGrammarElement())) {
fail(node.getGrammarElement().toString());
}
}
}
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-xtend by eclipse.
the class XtendHoverSerializer method computeArguments.
public String computeArguments(XAbstractFeatureCall featureCall) {
StringBuilder stringBuilder = new StringBuilder("(");
if (featureCall != null) {
XExpression implicitFirstArgument = featureCall.getImplicitFirstArgument();
List<XExpression> arguments = featureCall.getActualArguments();
if (implicitFirstArgument != null) {
XbaseSwitch<String> xbaseSwitch = new XtendHoverXbaseSwitch();
String doSwitch = xbaseSwitch.doSwitch(implicitFirstArgument).trim();
if (doSwitch != null)
stringBuilder.append(doSwitch);
}
int start = implicitFirstArgument != null ? 1 : 0;
for (int i = start; i < arguments.size(); i++) {
if (i != 0) {
stringBuilder.append(SEPARATOR);
}
XExpression expression = arguments.get(i);
ICompositeNode node = NodeModelUtils.findActualNodeFor(expression);
if (node != null)
stringBuilder.append(node.getText().trim());
}
}
stringBuilder.append(")");
return stringBuilder.toString();
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-xtend by eclipse.
the class XtendOutlineNodeFactory method configureNode.
private void configureNode(IOutlineNode parentNode, EObject modelElement, int inheritanceDepth, XtendEObjectNode featureNode) {
EObject primarySourceElement = associations.getPrimarySourceElement(modelElement);
ICompositeNode parserNode = NodeModelUtils.getNode(primarySourceElement == null ? modelElement : primarySourceElement);
if (parserNode != null)
featureNode.setTextRegion(parserNode.getTextRegion());
if (isLocalElement(parentNode, modelElement))
featureNode.setShortTextRegion(getLocationInFileProvider().getSignificantTextRegion(primarySourceElement == null ? modelElement : primarySourceElement));
featureNode.setStatic(isStatic(modelElement));
featureNode.setInheritanceDepth(inheritanceDepth);
}
Aggregations