use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class XtendHighlightingCalculator method highlightDeprecatedXtendAnnotationTarget.
protected void highlightDeprecatedXtendAnnotationTarget(IHighlightedPositionAcceptor acceptor, XtendAnnotationTarget target, XAnnotation annotation) {
JvmType annotationType = annotation.getAnnotationType();
if (annotationType instanceof JvmAnnotationType && DeprecationUtil.isDeprecatedAnnotation((JvmAnnotationType) annotationType)) {
if (target instanceof XtendConstructor) {
ICompositeNode compositeNode = NodeModelUtils.getNode(target);
for (ILeafNode leaf : compositeNode.getLeafNodes()) {
if (leaf.getGrammarElement() == xtendGrammarAccess.getMemberAccess().getNewKeyword_2_2_2()) {
highlightNode(acceptor, leaf, XbaseHighlightingStyles.DEPRECATED_MEMBERS);
highlightNode(acceptor, leaf, HighlightingStyles.KEYWORD_ID);
return;
}
}
} else {
EStructuralFeature nameFeature = target.eClass().getEStructuralFeature("name");
if (nameFeature != null) {
highlightFeature(acceptor, target, nameFeature, XbaseHighlightingStyles.DEPRECATED_MEMBERS);
}
}
}
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class JavaLinkingTest method testGetXtendClassAsArray.
@Test
public void testGetXtendClassAsArray() throws Exception {
IFile xtendFile = testHelper.createFile("test/XtendClass", "package test\nclass XtendClass {}");
waitForBuild();
assertNumberOfMarkers(xtendFile, 0);
ResourceSet resourceSet = resourceSetProvider.get(testHelper.getProject());
IJvmTypeProvider jvmTypeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
JvmType xtendArrayType = jvmTypeProvider.findTypeByName("test.XtendClass[][]");
assertNotNull(xtendArrayType);
assertTrue(xtendArrayType instanceof JvmArrayType);
assertEquals("test.XtendClass[][]", xtendArrayType.getQualifiedName());
Resource xtendResource = xtendArrayType.eResource();
assertEquals("platform:/resource" + xtendFile.getFullPath(), xtendResource.getURI().toString());
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class JavaLinkingTest method testNavigateToXtendClassArray.
@Test
public void testNavigateToXtendClassArray() throws Exception {
IFile xtendFile = testHelper.createFile("test/XtendClass", "package test\nclass XtendClass {}");
IFile javaFile = testHelper.createFileImpl(WorkbenchTestHelper.TESTPROJECT_NAME + "/src/test/JavaClass.java", "package test;\npublic class JavaClass extends java.util.ArrayList<XtendClass[]> {}");
waitForBuild();
assertNumberOfMarkers(xtendFile, 0);
assertNumberOfMarkers(javaFile, 0);
ResourceSet resourceSet = resourceSetProvider.get(testHelper.getProject());
IJvmTypeProvider jvmTypeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
JvmType javaType = jvmTypeProvider.findTypeByName("test.JavaClass");
assertNotNull(javaType);
assertTrue(javaType instanceof JvmDeclaredType);
JvmDeclaredType declaredJavaType = (JvmDeclaredType) javaType;
JvmParameterizedTypeReference arrayList = (JvmParameterizedTypeReference) declaredJavaType.getSuperTypes().get(0);
JvmTypeReference arrayReference = arrayList.getArguments().get(0);
assertTrue(arrayReference instanceof JvmGenericArrayTypeReference);
JvmType arrayType = arrayReference.getType();
assertTrue(arrayType instanceof JvmArrayType);
JvmType xtendType = ((JvmArrayType) arrayType).getComponentType();
assertNotNull(xtendType);
assertEquals("test.XtendClass", xtendType.getQualifiedName());
Resource xtendResource = xtendType.eResource();
assertEquals("platform:/resource" + xtendFile.getFullPath(), xtendResource.getURI().toString());
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class XtendCompiler method needSyntheticSelfVariable.
@Override
protected boolean needSyntheticSelfVariable(XClosure closure, LightweightTypeReference typeRef) {
JvmType jvmType = typeRef.getType();
TreeIterator<EObject> closureIterator = closure.eAllContents();
while (closureIterator.hasNext()) {
EObject obj1 = closureIterator.next();
if (obj1 instanceof XClosure) {
closureIterator.prune();
} else if (obj1 instanceof XtendTypeDeclaration) {
TreeIterator<EObject> typeIterator = obj1.eAllContents();
while (typeIterator.hasNext()) {
EObject obj2 = typeIterator.next();
if (obj2 instanceof XClosure) {
typeIterator.prune();
} else if (obj2 instanceof XFeatureCall && isReferenceToSelf((XFeatureCall) obj2, jvmType)) {
return true;
}
}
closureIterator.prune();
}
}
return false;
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class XtendCompiler method appendExtensionAnnotation.
protected void appendExtensionAnnotation(EObject context, ITreeAppendable appendable, boolean newLine) {
JvmType extension = findKnownTopLevelType(Extension.class, context);
if (extension != null) {
appendable.append("@");
appendable.append(extension);
if (!newLine)
appendable.append(" ");
else
appendable.newLine();
}
}
Aggregations