List of usage examples for org.eclipse.jdt.core IType getFullyQualifiedParameterizedName
String getFullyQualifiedParameterizedName() throws JavaModelException;
From source file:ca.mt.wb.devtools.tx.IVLabelProvider.java
License:unlicense.org
public IFigure getTooltip(Object entity) { if (entity instanceof IType) { IType type = (IType) entity; try {/*from ww w . j a v a 2s.co m*/ StringBuilder sb = new StringBuilder(); sb.append(type.getFullyQualifiedParameterizedName()); // IJavaProject jp = type.getJavaProject(); // jp.getProject() // PDE return new TextFlow(); } catch (JavaModelException e) { e.printStackTrace(); } } return null; }
From source file:edu.brown.cs.bubbles.bedrock.BedrockUtil.java
License:Open Source License
private static void outputNameDetails(IType typ, IvyXmlWriter xw) throws JavaModelException { String tnm = "Class"; if (typ.isInterface()) tnm = "Interface"; else if (typ.isEnum()) tnm = "Enum"; else {//from ww w. ja v a2s . co m try { ITypeHierarchy ith = typ.newSupertypeHierarchy(null); for (IType xtyp = typ; xtyp != null; xtyp = ith.getSuperclass(xtyp)) { if (xtyp.getFullyQualifiedName().equals("java.lang.Throwable")) { tnm = "Throwable"; break; } } } catch (JavaModelException ex) { } } outputSymbol(typ, tnm, typ.getFullyQualifiedParameterizedName(), typ.getKey(), xw); }
From source file:edu.brown.cs.bubbles.bedrock.BedrockUtil.java
License:Open Source License
/********************************************************************************/ static void outputTypeHierarchy(ITypeHierarchy th, IvyXmlWriter xw) { xw.begin("HIERARCHY"); IType[] typs = th.getAllTypes();/*from www . j a va2 s . c o m*/ for (IType typ : typs) { xw.begin("TYPE"); try { xw.field("NAME", typ.getFullyQualifiedName()); xw.field("QNAME", typ.getTypeQualifiedName()); xw.field("PNAME", typ.getFullyQualifiedParameterizedName()); if (typ.isClass()) xw.field("KIND", "CLASS"); else if (typ.isEnum()) xw.field("KIND", "ENUM"); else if (typ.isInterface()) xw.field("KIND", "INTERFACE"); xw.field("LOCAL", typ.isLocal()); xw.field("MEMBER", typ.isMember()); xw.field("KEY", typ.getKey()); IType[] subs = th.getAllSubtypes(typ); for (IType styp : subs) { xw.begin("SUBTYPE"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("SUBTYPE"); } IType[] sups = th.getAllSuperclasses(typ); for (IType styp : sups) { xw.begin("SUPERCLASS"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("SUPERCLASS"); } sups = th.getAllSuperInterfaces(typ); for (IType styp : sups) { xw.begin("SUPERIFACE"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("SUPERIFACE"); } sups = th.getAllSupertypes(typ); for (IType styp : sups) { xw.begin("SUPERTYPE"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("SUPERTYPE"); } sups = th.getExtendingInterfaces(typ); for (IType styp : sups) { xw.begin("EXTENDIFACE"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("EXTENDIFACE"); } sups = th.getImplementingClasses(typ); for (IType styp : sups) { xw.begin("IMPLEMENTOR"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("IMPLEMENTOR"); } } catch (JavaModelException e) { } xw.end("TYPE"); } xw.end("HIERARCHY"); }
From source file:fr.obeo.ariadne.ide.connector.java.internal.explorer.JavaExplorer.java
License:Open Source License
/** * Explores the Java type representing an annotation and create the matching Ariadne annotation in the * given Ariadne types container./*from ww w. j a v a2 s . c om*/ * * @param iType * The Java annotation * @param typesContainer * The Ariadne types container * @param monitor * The progress monitor * @return The Ariadne annotation created */ private Annotation exploreAnnotation(IType iType, TypesContainer typesContainer, IProgressMonitor monitor) { Annotation annotation = null; try { List<Type> types = typesContainer.getTypes(); for (Type aType : types) { if (aType instanceof Annotation && aType.getQualifiedName().equals(iType.getFullyQualifiedParameterizedName())) { annotation = (Annotation) aType; } } if (annotation == null) { annotation = CodeFactory.eINSTANCE.createAnnotation(); annotation.setQualifiedName(iType.getFullyQualifiedParameterizedName()); } if (annotation != null) { typesContainer.getTypes().add(annotation); String javadoc = this.getJavadoc(iType, monitor); annotation.setDescription(javadoc); annotation.setVersion(this.getVersionFromJavadoc(javadoc)); int flags = iType.getFlags(); if (Flags.isDeprecated(flags)) { // Add the property "Deprecated" this.addDeprecatedProperty(annotation); } annotation.setVisibility(this.getVisibility(iType, false)); // Explore the fields IField[] fields = iType.getFields(); for (IField iField : fields) { this.exploreField(iField, annotation, monitor); } // Set up the annotations dependencies IAnnotation[] annotations = iType.getAnnotations(); for (IAnnotation iAnnotation : annotations) { Annotation ariadneAnnotation = this.getOrCreateAnnotation(iAnnotation); if (ariadneAnnotation != null) { annotation.getAnnotations().add(ariadneAnnotation); } } // Set up the reference dependencies (import) ICompilationUnit compilationUnit = iType.getCompilationUnit(); if (compilationUnit != null) { IImportDeclaration[] imports = compilationUnit.getImports(); for (IImportDeclaration iImportDeclaration : imports) { if (!iImportDeclaration.getElementName().endsWith("*")) { //$NON-NLS-1$ Classifier classifier = this.getOrCreateClassifier(iImportDeclaration.getElementName()); if (classifier != null) { VersionedDependency versionedDependency = CoreFactory.eINSTANCE .createVersionedDependency(); versionedDependency.setVersionedElement(classifier); annotation.getVersionedDependencies().add(versionedDependency); } } else { // TODO Support "*" import } } } } } catch (JavaModelException e) { e.printStackTrace(); } return annotation; }
From source file:fr.obeo.ariadne.ide.connector.java.internal.explorer.JavaExplorer.java
License:Open Source License
/** * Explores the Java type representing a classifier (enumeration, interface, class) and create the * matching Ariadne classifier in the given types container. * /* www .j av a 2 s . c o m*/ * @param iType * The Java class, enumeration or interface * @param typesContainer * The Ariadne types container * @param monitor * The progress monitor * @return The Ariadne classifier created */ private Classifier exploreClassifier(IType iType, TypesContainer typesContainer, IProgressMonitor monitor) { Classifier classifier = null; try { List<Type> types = typesContainer.getTypes(); for (Type aType : types) { if (aType instanceof Classifier && aType.getQualifiedName().equals(iType.getFullyQualifiedParameterizedName())) { classifier = (Classifier) aType; } } if (classifier == null) { classifier = CodeFactory.eINSTANCE.createClassifier(); classifier.setName(iType.getElementName()); classifier.setQualifiedName(iType.getFullyQualifiedParameterizedName()); } if (classifier != null) { typesContainer.getTypes().add(classifier); String javadoc = this.getJavadoc(iType, monitor); classifier.setDescription(javadoc); classifier.setVersion(this.getVersionFromJavadoc(javadoc)); int flags = iType.getFlags(); if (Flags.isInterface(flags)) { classifier.setKind(ClassifierKind.INTERFACE); } else if (Flags.isEnum(flags)) { classifier.setKind(ClassifierKind.ENUMERATION); } else { classifier.setKind(ClassifierKind.CLASS); } if (Flags.isDeprecated(flags)) { // Add the property "Deprecated" this.addDeprecatedProperty(classifier); } classifier.setFinal(Flags.isFinal(flags)); classifier.setStatic(Flags.isStatic(flags)); classifier.setVisibility(this.getVisibility(iType, false)); // Explore the methods IMethod[] methods = iType.getMethods(); for (IMethod iMethod : methods) { if (iMethod.isConstructor()) { this.exploreConstructor(iMethod, classifier, Flags.isInterface(flags), monitor); } else { this.exploreOperation(iMethod, classifier, Flags.isInterface(flags), monitor); } } // Explore the fields IField[] fields = iType.getFields(); for (IField iField : fields) { this.exploreField(iField, classifier, Flags.isInterface(flags), monitor); } // Set up the annotations dependencies IAnnotation[] annotations = iType.getAnnotations(); for (IAnnotation iAnnotation : annotations) { Annotation ariadneAnnotation = this.getOrCreateAnnotation(iAnnotation); if (ariadneAnnotation != null) { classifier.getAnnotations().add(ariadneAnnotation); } } // Set up the reference dependencies (import) ICompilationUnit compilationUnit = iType.getCompilationUnit(); if (compilationUnit != null) { IImportDeclaration[] imports = compilationUnit.getImports(); for (IImportDeclaration iImportDeclaration : imports) { if (!iImportDeclaration.getElementName().endsWith("*")) { //$NON-NLS-1$ Classifier ariadneClassifier = this .getOrCreateClassifier(iImportDeclaration.getElementName()); if (ariadneClassifier != null) { VersionedDependency versionedDependency = CoreFactory.eINSTANCE .createVersionedDependency(); versionedDependency.setVersionedElement(ariadneClassifier); classifier.getVersionedDependencies().add(versionedDependency); } } else { // TODO Support "*" import } } } // Set up the inhenritance dependencies String superclassName = iType.getSuperclassName(); Classifier ariadneClassifier = this.getOrCreateClassifier(superclassName); if (ariadneClassifier != null) { classifier.getSuperTypes().add(ariadneClassifier); } String[] superInterfaceNames = iType.getSuperInterfaceNames(); for (String superInterfaceName : superInterfaceNames) { ariadneClassifier = this.getOrCreateClassifier(superInterfaceName); if (ariadneClassifier != null) { classifier.getSuperTypes().add(ariadneClassifier); } } } } catch (JavaModelException e) { e.printStackTrace(); } return classifier; }
From source file:org.eclipse.jpt.common.core.tests.internal.utility.jdt.MiscTests.java
License:Open Source License
public void testITypeParameterizedName() throws Exception { IType mapType = this.getJavaProject().getJavaProject().findType("java.util.Map"); assertEquals(mapType.getFullyQualifiedParameterizedName(), "java.util.Map<K extends java.lang.Object, V extends java.lang.Object>"); }
From source file:org.jboss.tools.cdi.ui.wizard.NewAnnotationLiteralWizardPage.java
License:Open Source License
public void init(IStructuredSelection selection) { super.init(selection); defaultTypeName = null;/*from w ww . j a va 2 s .co m*/ if (!selection.isEmpty()) { Object o = selection.iterator().next(); IType type = null; if (o instanceof IType) { type = (IType) o; } else if (o instanceof ICompilationUnit) { ICompilationUnit cu = (ICompilationUnit) o; try { IType[] ts = cu.getTypes(); if (ts != null && ts.length > 0) type = ts[0]; } catch (JavaModelException e) { CDICorePlugin.getDefault().logError(e); } } boolean isInterface = false; try { isInterface = type != null && type.isInterface(); } catch (JavaModelException e) { CDICorePlugin.getDefault().logError(e); } if (isInterface) { String name = ""; try { name = type.getFullyQualifiedParameterizedName(); } catch (JavaModelException e) { name = type.getFullyQualifiedName(); } IPackageFragmentRoot r = getPackageFragmentRoot(); if (r != null) { ICDIProject cdi = NewCDIAnnotationWizardPage.getCDIProject(r.getJavaProject()); IQualifier q = cdi != null ? cdi.getQualifier(name) : null; if (q != null) { selected = q; ArrayList<String> interfacesNames = new ArrayList<String>(); interfacesNames.add(name); setSuperInterfaces(interfacesNames, true); superInterfacesChanged(); setSuperClass(CDIConstants.ANNOTATION_LITERAL_TYPE_NAME + "<" + type.getElementName() + ">", false); setDefaultTypeName(name); } } } } doStatusUpdate(); }
From source file:org.jboss.tools.cdi.ui.wizard.NewBeanWizardPage.java
License:Open Source License
public void init(IStructuredSelection selection) { super.init(selection); if (selection != null && !selection.isEmpty()) { Object o = selection.iterator().next(); IType type = null; if (o instanceof IType) { type = (IType) o;/*from w w w .j a va 2 s . c o m*/ } else if (o instanceof ICompilationUnit) { ICompilationUnit cu = (ICompilationUnit) o; try { IType[] ts = cu.getTypes(); if (ts != null && ts.length > 0) type = ts[0]; } catch (JavaModelException e) { CDICorePlugin.getDefault().logError(e); } } boolean isInterface = false; try { isInterface = type != null && type.isInterface(); } catch (JavaModelException e) { CDICorePlugin.getDefault().logError(e); } ArrayList<String> interfacesNames = new ArrayList<String>(); if (isInterface) { String name = ""; try { name = type.getFullyQualifiedParameterizedName(); } catch (JavaModelException e) { name = type.getFullyQualifiedName(); } interfacesNames.add(name); setDefaultTypeName(name); } // interfacesNames.add("java.io.Serializable"); setSuperInterfaces(interfacesNames, true); superInterfacesChanged(); } doStatusUpdate(); }
From source file:org.jboss.tools.cdi.ui.wizard.NewDecoratorWizardPage.java
License:Open Source License
public void init(IStructuredSelection selection) { super.init(selection); defaultTypeName = null;/*from w ww. j a va 2s. c om*/ defaultFieldName = null; if (selection != null && !selection.isEmpty()) { Object o = selection.iterator().next(); IType type = null; if (o instanceof IType) { type = (IType) o; } else if (o instanceof ICompilationUnit) { ICompilationUnit cu = (ICompilationUnit) o; try { IType[] ts = cu.getTypes(); if (ts != null && ts.length > 0) type = ts[0]; } catch (JavaModelException e) { CDICorePlugin.getDefault().logError(e); } } boolean isInterface = false; try { isInterface = type != null && type.isInterface(); } catch (JavaModelException e) { CDICorePlugin.getDefault().logError(e); } if (isInterface) { ArrayList<String> interfacesNames = new ArrayList<String>(); String name = ""; try { name = type.getFullyQualifiedParameterizedName(); } catch (JavaModelException e) { name = type.getFullyQualifiedName(); } interfacesNames.add(name); setSuperInterfaces(interfacesNames, true); superInterfacesChanged(); setDefaultTypeName(name); } } setModifiers(getModifiers() | Flags.AccAbstract, true); doStatusUpdate(); }
From source file:org.jboss.tools.common.ui.wizard.service.NewServiceWizardPage.java
License:Open Source License
public void init(IStructuredSelection selection) { super.init(selection); defaultTypeName = null;/* ww w . j a v a 2s . c o m*/ if (selection != null && !selection.isEmpty()) { Object o = selection.iterator().next(); IType type = null; if (o instanceof IType) { type = (IType) o; } else if (o instanceof ICompilationUnit) { ICompilationUnit cu = (ICompilationUnit) o; try { IType[] ts = cu.getTypes(); if (ts != null && ts.length > 0) type = ts[0]; } catch (JavaModelException e) { CommonUIPlugin.getDefault().logError(e); } } boolean isInterface = false; try { isInterface = type != null && type.isInterface(); } catch (JavaModelException e) { CommonUIPlugin.getDefault().logError(e); } if (isInterface) { ArrayList<String> interfacesNames = new ArrayList<String>(); String name = ""; try { name = type.getFullyQualifiedParameterizedName(); } catch (JavaModelException e) { name = type.getFullyQualifiedName(); } interfacesNames.add(name); setSuperInterfaces(interfacesNames, true); superInterfacesChanged(); setDefaultTypeName(name); } } setModifiers(getModifiers(), true); try { Field f = NewTypeWizardPage.class.getDeclaredField("fOtherMdfButtons"); if (f != null) { f.setAccessible(true); SelectionButtonDialogFieldGroup g = (SelectionButtonDialogFieldGroup) f.get(this); g.enableSelectionButton(0, false); } } catch (Exception e) { CommonUIPlugin.getDefault().logError(e); } doStatusUpdate(); }