Java Code Examples for org.eclipse.jdt.core.IType#getFullyQualifiedName()
The following examples show how to use
org.eclipse.jdt.core.IType#getFullyQualifiedName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuperInterfaceSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static String getNameWithTypeParameters(IType type) { String superName= type.getFullyQualifiedName('.'); if (!JavaModelUtil.is50OrHigher(type.getJavaProject())) { return superName; } try { ITypeParameter[] typeParameters= type.getTypeParameters(); if (typeParameters.length > 0) { StringBuffer buf= new StringBuffer(superName); buf.append('<'); for (int k= 0; k < typeParameters.length; k++) { if (k != 0) { buf.append(',').append(' '); } buf.append(typeParameters[k].getElementName()); } buf.append('>'); return buf.toString(); } } catch (JavaModelException e) { // ignore } return superName; }
Example 2
Source File: JavaProjectPipelineOptionsHierarchy.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * Retrieve the {@link PipelineOptionsType} for the provided {@code optionsType} using the * {@code * typeHierarchy}. If the {@code PipelineOptionsType} has already been created, reuse the same * instance (by fully qualified name). * * <p>If the {@code PipelineOptionsType} does not exist, create all of its supertypes that extend * {@code PipelineOptions} recursively, and create the requested type, place it in the {@code * pipelinOptionsTypes} map, and return it. If the {@code PipelineOptionsType} has already been * created, return it. */ private PipelineOptionsType getOrCreatePipelineOptionsType(IType optionsType) throws JavaModelException { if (knownTypes.containsKey(optionsType.getFullyQualifiedName())) { // Already found this type on a different interface. return knownTypes.get(optionsType.getFullyQualifiedName()); } // Construct the Superinterfaces of this type recursively. ImmutableSet.Builder<PipelineOptionsType> parentTypes = ImmutableSet.builder(); for (IType superInterface : hierarchy.getSuperInterfaces(optionsType)) { PipelineOptionsType superInterfaceType = getOrCreatePipelineOptionsType(superInterface); parentTypes.add(superInterfaceType); } PipelineOptionsType myType = new PipelineOptionsType( optionsType.getFullyQualifiedName(), parentTypes.build(), getProperties(optionsType)); knownTypes.put(optionsType.getFullyQualifiedName(), myType); return myType; }
Example 3
Source File: DeltaConverter.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.8 */ private void convertChangedTypeAndChildren(List<IResourceDescription.Delta> result, TypeNames previousTypeNames, IType type, URI topLevelUri) { String typeName = type.getFullyQualifiedName(); if (previousTypeNames.remove(typeName)) { convertChangedType(topLevelUri, type, result); } else { convertNewType(topLevelUri, type, result); } try { for(IType child : type.getTypes()){ convertChangedTypeAndChildren(result, previousTypeNames, child, topLevelUri); } } catch (JavaModelException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(e, e); } } }
Example 4
Source File: SystemObject.java From JDeodorant with MIT License | 6 votes |
public Set<ClassObject> getClassObjects(IType type) { Set<ClassObject> classObjectSet = new LinkedHashSet<ClassObject>(); String typeQualifiedName = type.getFullyQualifiedName('.'); ClassObject classObject = getClassObject(typeQualifiedName); if(classObject != null) classObjectSet.add(classObject); try { IType[] nestedTypes = type.getTypes(); for(IType nestedType : nestedTypes) { classObjectSet.addAll(getClassObjects(nestedType)); } } catch (JavaModelException e) { e.printStackTrace(); } return classObjectSet; }
Example 5
Source File: ContentAssistHistory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Remembers the selection of a right hand side type (proposal type) for a certain left hand side (expected * type) in content assist. * * @param lhs the left hand side / expected type * @param rhs the selected right hand side */ public void remember(IType lhs, IType rhs) { Assert.isLegal(lhs != null); Assert.isLegal(rhs != null); try { if (!isCacheableRHS(rhs)) return; ITypeHierarchy hierarchy= rhs.newSupertypeHierarchy(getProgressMonitor()); if (hierarchy.contains(lhs)) { // TODO remember for every member of the LHS hierarchy or not? Yes for now. IType[] allLHSides= hierarchy.getAllSupertypes(lhs); String rhsQualifiedName= rhs.getFullyQualifiedName(); for (int i= 0; i < allLHSides.length; i++) rememberInternal(allLHSides[i], rhsQualifiedName); rememberInternal(lhs, rhsQualifiedName); } } catch (JavaModelException x) { JavaPlugin.log(x); } }
Example 6
Source File: LazyGenericTypeProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Finds and returns the super type signature in the * <code>extends</code> or <code>implements</code> clause of * <code>subType</code> that corresponds to <code>superType</code>. * * @param subType a direct and true sub type of <code>superType</code> * @param superType a direct super type (super class or interface) of * <code>subType</code> * @return the super type signature of <code>subType</code> referring * to <code>superType</code> * @throws JavaModelException if extracting the super type signatures * fails, or if <code>subType</code> contains no super type * signature to <code>superType</code> */ private String findMatchingSuperTypeSignature(IType subType, IType superType) throws JavaModelException { String[] signatures= getSuperTypeSignatures(subType, superType); for (int i= 0; i < signatures.length; i++) { String signature= signatures[i]; String qualified= SignatureUtil.qualifySignature(signature, subType); String subFQN= SignatureUtil.stripSignatureToFQN(qualified); String superFQN= superType.getFullyQualifiedName(); if (subFQN.equals(superFQN)) { return signature; } // TODO handle local types } throw new JavaModelException(new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "Illegal hierarchy", null))); //$NON-NLS-1$ }
Example 7
Source File: Resource.java From EasyShell with Eclipse Public License 2.0 | 6 votes |
public String getFullQualifiedName() { if (resource != null) { Bundle bundle = Platform.getBundle("org.eclipse.jdt.core"); if (bundle != null) { IJavaElement element = JavaCore.create(resource); if (element instanceof IPackageFragment) { return ((IPackageFragment)element).getElementName(); } else if (element instanceof ICompilationUnit) { IType type = ((ICompilationUnit)element).findPrimaryType(); if (type != null) { return type.getFullyQualifiedName(); } } } } return getFullQualifiedPathName(); }
Example 8
Source File: MoveMethodRefactoring.java From JDeodorant with MIT License | 6 votes |
private Map<IMethodBinding, TypeDeclaration> findSubclassesOverridingMethod(TypeDeclaration typeDeclaration, IMethodBinding methodBinding) { Map<IMethodBinding, TypeDeclaration> subclassTypeDeclarationMap = new LinkedHashMap<IMethodBinding, TypeDeclaration>(); CompilationUnitCache cache = CompilationUnitCache.getInstance(); Set<IType> subTypes = cache.getSubTypes((IType)typeDeclaration.resolveBinding().getJavaElement()); for(IType iType : subTypes) { String fullyQualifiedTypeName = iType.getFullyQualifiedName(); ClassObject classObject = ASTReader.getSystemObject().getClassObject(fullyQualifiedTypeName); if(classObject != null) { AbstractTypeDeclaration abstractTypeDeclaration = classObject.getAbstractTypeDeclaration(); if(abstractTypeDeclaration instanceof TypeDeclaration) { TypeDeclaration subclassTypeDeclaration = (TypeDeclaration)abstractTypeDeclaration; for(MethodDeclaration subclassMethodDeclaration : subclassTypeDeclaration.getMethods()) { if(MethodCallAnalyzer.equalSignature(subclassMethodDeclaration.resolveBinding(), methodBinding)) { subclassTypeDeclarationMap.put(subclassMethodDeclaration.resolveBinding(), subclassTypeDeclaration); } } } } } return subclassTypeDeclarationMap; }
Example 9
Source File: CompilationUnitCompletion.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Finds and returns the super type signature in the * <code>extends</code> or <code>implements</code> clause of * <code>subType</code> that corresponds to <code>superType</code>. * * @param subType a direct and true sub type of <code>superType</code> * @param superType a direct super type (super class or interface) of * <code>subType</code> * @return the super type signature of <code>subType</code> referring * to <code>superType</code> * @throws JavaModelException if extracting the super type signatures * fails, or if <code>subType</code> contains no super type * signature to <code>superType</code> */ private String findMatchingSuperTypeSignature(IType subType, IType superType) throws JavaModelException { String[] signatures= getSuperTypeSignatures(subType, superType); for (int i= 0; i < signatures.length; i++) { String signature= signatures[i]; String qualified= SignatureUtil.qualifySignature(signature, subType); String subFQN= SignatureUtil.stripSignatureToFQN(qualified); String superFQN= superType.getFullyQualifiedName(); if (subFQN.equals(superFQN)) { return signature; } // handle local types if (fLocalTypes.containsValue(subFQN)) { return signature; } } throw new JavaModelException(new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "Illegal hierarchy", null))); //$NON-NLS-1$ }
Example 10
Source File: MatchLocator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected char[][][] computeSuperTypeNames(IType focusType) { String fullyQualifiedName = focusType.getFullyQualifiedName(); int lastDot = fullyQualifiedName.lastIndexOf('.'); char[] qualification = lastDot == -1 ? CharOperation.NO_CHAR : fullyQualifiedName.substring(0, lastDot).toCharArray(); char[] simpleName = focusType.getElementName().toCharArray(); SuperTypeNamesCollector superTypeNamesCollector = new SuperTypeNamesCollector( this.pattern, simpleName, qualification, new MatchLocator(this.pattern, this.requestor, this.scope, this.progressMonitor), // clone MatchLocator so that it has no side effect focusType, this.progressMonitor); try { this.allSuperTypeNames = superTypeNamesCollector.collect(); } catch (JavaModelException e) { // problem collecting super type names: leave it null } return this.allSuperTypeNames; }
Example 11
Source File: AbstractConversionTable.java From sarl with Apache License 2.0 | 5 votes |
/** Create a cell editor that enables to select a class. * * @return the cell editor. */ protected CellEditor createClassCellEditor() { return new DialogCellEditor(getControl()) { @Override protected Object openDialogBox(Control cellEditorWindow) { final OpenTypeSelectionDialog dialog = new OpenTypeSelectionDialog( getControl().getShell(), false, PlatformUI.getWorkbench().getProgressService(), null, IJavaSearchConstants.TYPE); dialog.setTitle(JavaUIMessages.OpenTypeAction_dialogTitle); dialog.setMessage(JavaUIMessages.OpenTypeAction_dialogMessage); final int result = dialog.open(); if (result != IDialogConstants.OK_ID) { return null; } final Object[] types = dialog.getResult(); if (types == null || types.length != 1 || !(types[0] instanceof IType)) { return null; } final IType type = (IType) types[0]; final String name = type.getFullyQualifiedName(); return Strings.emptyIfNull(name); } }; }
Example 12
Source File: JUnitStatusRegistry.java From jdt-codemining with Eclipse Public License 1.0 | 5 votes |
public ITestSuiteElement findTestSuite(IType element) { IJavaProject project = element.getJavaProject(); String className = element.getFullyQualifiedName(); Map<String, Map<String, ITestCaseElement>> testClasses = projects.get(project); if (testClasses == null) { return null; } Map<String, ITestCaseElement> tests = testClasses.get(className); if (tests == null) { return null; } return (ITestSuiteElement) ((ITestCaseElement) tests.values().toArray()[0]).getParentContainer(); }
Example 13
Source File: NLSSourceModifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String createImportForAccessor(MultiTextEdit parent, String accessorClassName, IPackageFragment accessorPackage, ICompilationUnit cu) throws CoreException { IType type= accessorPackage.getCompilationUnit(accessorClassName + JavaModelUtil.DEFAULT_CU_SUFFIX).getType(accessorClassName); String fullyQualifiedName= type.getFullyQualifiedName(); ImportRewrite importRewrite= StubUtility.createImportRewrite(cu, true); String nameToUse= importRewrite.addImport(fullyQualifiedName); TextEdit edit= importRewrite.rewriteImports(null); parent.addChild(edit); return nameToUse; }
Example 14
Source File: HierarchyBuilder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public HierarchyBuilder(TypeHierarchy hierarchy) throws JavaModelException { this.hierarchy = hierarchy; JavaProject project = (JavaProject) hierarchy.javaProject(); IType focusType = hierarchy.getType(); org.eclipse.jdt.core.ICompilationUnit unitToLookInside = focusType == null ? null : focusType.getCompilationUnit(); org.eclipse.jdt.core.ICompilationUnit[] workingCopies = this.hierarchy.workingCopies; org.eclipse.jdt.core.ICompilationUnit[] unitsToLookInside; if (unitToLookInside != null) { int wcLength = workingCopies == null ? 0 : workingCopies.length; if (wcLength == 0) { unitsToLookInside = new org.eclipse.jdt.core.ICompilationUnit[] {unitToLookInside}; } else { unitsToLookInside = new org.eclipse.jdt.core.ICompilationUnit[wcLength+1]; unitsToLookInside[0] = unitToLookInside; System.arraycopy(workingCopies, 0, unitsToLookInside, 1, wcLength); } } else { unitsToLookInside = workingCopies; } if (project != null) { SearchableEnvironment searchableEnvironment = project.newSearchableNameEnvironment(unitsToLookInside); this.nameLookup = searchableEnvironment.nameLookup; this.hierarchyResolver = new HierarchyResolver( searchableEnvironment, project.getOptions(true), this, new DefaultProblemFactory()); } this.infoToHandle = new HashMap(5); this.focusQualifiedName = focusType == null ? null : focusType.getFullyQualifiedName(); }
Example 15
Source File: TypeOccurrenceCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public TypeOccurrenceCollector(IType type, ReferencesInBinaryContext binaryRefs) { super(binaryRefs); fOldName= type.getElementName(); fOldQualifiedName= type.getFullyQualifiedName('.'); }
Example 16
Source File: CallHierarchyContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Checks if the method or its declaring type matches the pre-defined array of methods and types * for default expand with constructors. * * @param method the wrapped method * @return <code>true</code> if method or type matches the pre-defined list, <code>false</code> * otherwise * * @since 3.5 */ static boolean isInTheDefaultExpandWithConstructorList(IMethod method) { String serializedMembers= PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS_MEMBERS); if (serializedMembers.length() == 0) return false; String[] defaultMemberPatterns= serializedMembers.split(";"); //$NON-NLS-1$ String methodName= method.getElementName(); IType declaringType= method.getDeclaringType(); String declaringTypeName= declaringType.getFullyQualifiedName('.'); String superClassName; String[] superInterfaceNames; try { superClassName= declaringType.getSuperclassName(); if (superClassName != null) { superClassName= stripTypeArguments(superClassName); } superInterfaceNames= declaringType.getSuperInterfaceNames(); for (int i= 0; i < superInterfaceNames.length; i++) { superInterfaceNames[i]= stripTypeArguments(superInterfaceNames[i]); } } catch (JavaModelException e) { return false; } for (int i= 0; i < defaultMemberPatterns.length; i++) { String defaultMemberPattern= defaultMemberPatterns[i]; int pos= defaultMemberPattern.lastIndexOf('.'); String defaultTypeName= defaultMemberPattern.substring(0, pos); String defaultMethodName= defaultMemberPattern.substring(pos + 1); if ("*".equals(defaultMethodName)) { //$NON-NLS-1$ if (declaringTypeName.equals(defaultTypeName)) { return true; } } else { if (!methodName.equals(defaultMethodName)) { continue; } if (declaringTypeName.equals(defaultTypeName)) { return true; } } if (superClassName != null && JavaModelUtil.isMatchingName(superClassName, defaultTypeName)) { return true; } for (int j= 0; j < superInterfaceNames.length; j++) { String superInterfaceName= superInterfaceNames[j]; if (JavaModelUtil.isMatchingName(superInterfaceName, defaultTypeName)) { return true; } } } return false; }
Example 17
Source File: ClientBundleUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
public static String suggestResourceTypeName(IJavaProject javaProject, IFile file) { String ext = file.getFileExtension(); if (ext == null) { return DATA_RESOURCE_TYPE_NAME; } // The @DefaultExtensions include the leading dot, so we need to as well ext = "." + ext; try { List<String> matchingResourceTypes = new ArrayList<String>(); // Look for @DefaultExtensions on all ResourcePrototype subtypes IType[] resourceTypes = findResourcePrototypeSubtypes(javaProject); for (IType resourceType : resourceTypes) { String[] defaultExtensions = ResourceTypeDefaultExtensions.getDefaultExtensions(resourceType); for (String defaultExtension : defaultExtensions) { if (ResourceUtils.areFilenamesEqual(ext, defaultExtension)) { String resourceTypeName = resourceType.getFullyQualifiedName('.'); matchingResourceTypes.add(resourceTypeName); } } } // Now see what we found if (matchingResourceTypes.size() > 0) { /* * If TextResource was a match, prefer it. This is necessary since it * and ExternalTextResource both declare .txt as their default * extension. Since TextResource (which inlines its content into the * compiled output) is the more commonly used variant, we want to use it * by default. If we're wrong, the user can always change it manually. */ if (matchingResourceTypes.contains(TEXT_RESOURCE_TYPE_NAME)) { return TEXT_RESOURCE_TYPE_NAME; } /* * If we don't have TextResource in the mix, return the first matching * ResourcePrototype subtype we found. In the case of multiple resource * types that declare the same default file extensions, the order in * which they are found is undefined, so which one we return is * undefined as well. In general, multiple resource types will not have * the same default extensions, so this is probably good enough (that * is, it's not worth creating new UI/settings for this edge case). */ return matchingResourceTypes.get(0); } } catch (JavaModelException e) { GWTPluginLog.logError(e, "Unable to suggest resource type for file " + file.getName()); } return DATA_RESOURCE_TYPE_NAME; }
Example 18
Source File: TypeOccurrenceCollector.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public TypeOccurrenceCollector(IType type, ReferencesInBinaryContext binaryRefs) { super(binaryRefs); fOldName= type.getElementName(); fOldQualifiedName= type.getFullyQualifiedName('.'); }
Example 19
Source File: NewTypeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * Sets the enclosing type. The method updates the underlying model * and the text of the control. * * @param type the enclosing type * @param canBeModified if <code>true</code> the enclosing type field is * editable; otherwise it is read-only. */ public void setEnclosingType(IType type, boolean canBeModified) { fCurrEnclosingType= type; fCanModifyEnclosingType= canBeModified; String str= (type == null) ? "" : type.getFullyQualifiedName('.'); //$NON-NLS-1$ fEnclosingTypeDialogField.setText(str); updateEnableState(); }
Example 20
Source File: Binding2JavaModel.java From lapse-plus with GNU General Public License v3.0 | 2 votes |
/** * Returns the fully qualified name of the given type using '.' as separators. * This is a replace for IType.getFullyQualifiedTypeName * which uses '$' as separators. As '$' is also a valid character in an id * this is ambiguous. JavaCore PR: 1GCFUNT */ public static String getFullyQualifiedName(IType type) { return type.getFullyQualifiedName('.'); }