use of org.eclipse.xtext.common.types.JvmFeature in project xtext-eclipse by eclipse.
the class XtypeProposalProvider method completeXImportDeclaration_MemberName.
@Override
public void completeXImportDeclaration_MemberName(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
if (model instanceof XImportDeclaration) {
XImportDeclaration importDeclaration = (XImportDeclaration) model;
for (JvmFeature feature : staticallyImportedMemberProvider.findAllFeatures(importDeclaration)) {
Image image = getImage(feature);
LightweightTypeReferenceFactory typeConverter = getTypeConverter(context.getResource());
StyledString displayString = getStyledDisplayString(feature, false, 0, feature.getQualifiedName(), feature.getSimpleName(), typeConverter);
acceptor.accept(createCompletionProposal(feature.getSimpleName(), displayString, image, context));
}
}
}
use of org.eclipse.xtext.common.types.JvmFeature in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testBug470767.
@Test
public void testBug470767() {
String typeName = Bug470767.class.getName();
JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
assertNotNull(type);
diagnose(type);
diagnose(type);
Resource resource = type.eResource();
getAndResolveAllFragments(resource);
recomputeAndCheckIdentifiers(resource);
Iterable<JvmFeature> methods = type.findAllFeaturesByName("paramIsAnnotated");
JvmOperation method = (JvmOperation) Iterables.getOnlyElement(methods);
JvmTypeReference paramType = method.getParameters().get(0).getParameterType();
assertEquals("int", paramType.getSimpleName());
}
use of org.eclipse.xtext.common.types.JvmFeature in project xtext-eclipse by eclipse.
the class XbaseReferenceUpdater method createReferenceUpdate.
@Override
protected void createReferenceUpdate(EObject referringElement, URI referringResourceURI, EReference reference, int indexInList, EObject newTargetElement, IRefactoringUpdateAcceptor updateAcceptor) {
if (referringElement instanceof XImportDeclaration) {
XImportDeclaration importDeclaration = (XImportDeclaration) referringElement;
JvmDeclaredType importedType = importDeclaration.getImportedType();
boolean isStatic = importDeclaration.isStatic();
boolean isExtension = importDeclaration.isExtension();
String memberName = importDeclaration.getMemberName();
if (newTargetElement instanceof JvmDeclaredType) {
JvmDeclaredType type = (JvmDeclaredType) newTargetElement;
ImportAwareUpdateAcceptor importAwareUpdateAcceptor = (ImportAwareUpdateAcceptor) updateAcceptor;
importAwareUpdateAcceptor.removeImport(type, isStatic, isExtension, memberName);
importAwareUpdateAcceptor.acceptImport(type, isStatic, isExtension, memberName);
return;
}
if (newTargetElement instanceof JvmFeature) {
JvmFeature feature = (JvmFeature) newTargetElement;
String featureName = feature.getSimpleName();
if (featureName.equals(memberName)) {
// type rename is handled separately
return;
}
ImportAwareUpdateAcceptor importAwareUpdateAcceptor = (ImportAwareUpdateAcceptor) updateAcceptor;
if (!importAwareUpdateAcceptor.isUsed(importedType, isStatic, isExtension, memberName)) {
importAwareUpdateAcceptor.removeImport(importedType, isStatic, isExtension, memberName);
}
if (importAwareUpdateAcceptor.isConflicted(importedType, isStatic, isExtension, featureName)) {
JvmDeclaredType parentType = importedType;
while (parentType != null && !importAwareUpdateAcceptor.getImportSection().hasImportedType(parentType) && !importAwareUpdateAcceptor.acceptImport(parentType, false, false, null)) {
parentType = parentType.getDeclaringType();
}
} else {
importAwareUpdateAcceptor.acceptImport(importedType, isStatic, isExtension, featureName);
}
return;
}
}
if (referringElement instanceof XAbstractFeatureCall) {
if (newTargetElement instanceof JvmDeclaredType) {
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) referringElement;
JvmIdentifiableElement feature = featureCall.getFeature();
if (isStaticExtensionFeatureCall(referringElement, reference, feature)) {
return;
}
if (isStaticFeatureCall(referringElement, reference, feature)) {
return;
}
}
}
if (!(referringElement instanceof XFeatureCall && newTargetElement instanceof JvmConstructor)) {
// skip constructor calls like this() or super()
super.createReferenceUpdate(referringElement, referringResourceURI, reference, indexInList, newTargetElement, updateAcceptor);
}
}
use of org.eclipse.xtext.common.types.JvmFeature in project xtext-xtend by eclipse.
the class AbstractMultiModeOutlineTreeProvider method createQualifier.
private String createQualifier(JvmMember jvmMember) {
String qualifier = null;
if (jvmMember instanceof JvmFeature) {
JvmDeclaredType declaringType = jvmMember.getDeclaringType();
qualifier = getPackageFreeNameForType(declaringType);
} else if (jvmMember instanceof JvmDeclaredType) {
if (jvmMember.eContainer() instanceof JvmDeclaredType) {
qualifier = getPackageFreeNameForType((JvmDeclaredType) jvmMember.eContainer());
} else {
JvmDeclaredType jvmDeclaredType = (JvmDeclaredType) jvmMember;
if (StringUtils.isEmpty(jvmDeclaredType.getPackageName())) {
qualifier = "(default package)";
} else {
qualifier = jvmDeclaredType.getPackageName();
}
}
}
return qualifier;
}
use of org.eclipse.xtext.common.types.JvmFeature in project xtext-xtend by eclipse.
the class AbstractMultiModeOutlineTreeProvider method createNodeForFeature.
protected XtendFeatureNode createNodeForFeature(IOutlineNode parentNode, final JvmDeclaredType inferredType, EObject featureElement, int inheritanceDepth) {
boolean synthetic = false;
if (featureElement instanceof JvmFeature) {
synthetic = typeExtensions.isSynthetic((JvmIdentifiableElement) featureElement);
}
Object text = computeDecoratedText(featureElement, inheritanceDepth);
ImageDescriptor image = getImageDescriptor(featureElement);
if (isShowInherited()) {
return getOutlineNodeFactory().createXtendFeatureNode(parentNode, featureElement, image, text, true, synthetic, inheritanceDepth);
}
return getOutlineNodeFactory().createXtendFeatureNode(parentNode, featureElement, image, text, true, synthetic, inheritanceDepth);
}
Aggregations