Java Code Examples for org.eclipse.jdt.core.IType#getSuperclassName()
The following examples show how to use
org.eclipse.jdt.core.IType#getSuperclassName() .
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: Bug403554Test.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); IJavaProject project = getJavaProject(null); IType type = project.findType(ArrayList.class.getName()); IMethod method = type.getMethod("subList", new String[] { "I", "I" }); while (!method.exists()) { String superclassName = type.getSuperclassName(); int idx = superclassName.indexOf("<"); if (idx != -1) { superclassName = superclassName.substring(0, idx); } type = project.findType(superclassName); method = type.getMethod("subList", new String[] { "I", "I" }); } declarator = type.getElementName(); }
Example 2
Source File: SetterAttributeProposalComputer.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public void computeProposals(List<ICompletionProposal> completions) { Map<String, ICompletionProposal> proposals = new HashMap<String, ICompletionProposal>(); IType type; try { // walk the inheritance chain for (String name = widgetTypeName; name != null; name = type.getSuperclassName()) { type = getJavaProject().findType(name); if (type == null) { break; } addProposalsFromType(proposals, type); } } catch (JavaModelException e) { GWTPluginLog.logError(e, "Could not generate setter-based attribute proposal."); } completions.addAll(proposals.values()); }
Example 3
Source File: NLSRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Computes whether the Eclipse NLSing mechanism is used. * * @return <code>true</code> if NLSing is done the Eclipse way * and <code>false</code> if the standard resource bundle mechanism is used * @since 3.1 */ public boolean detectIsEclipseNLS() { ICompilationUnit accessorCU= getAccessorClassPackage().getCompilationUnit(getAccessorCUName()); IType type= accessorCU.getType(getAccessorClassName()); if (type.exists()) { try { String superclassName= type.getSuperclassName(); if (!"NLS".equals(superclassName) && !NLS.class.getName().equals(superclassName)) //$NON-NLS-1$ return false; IType superclass= type.newSupertypeHierarchy(null).getSuperclass(type); return superclass != null && NLS.class.getName().equals(superclass.getFullyQualifiedName()); } catch (JavaModelException e) { // use default } } // Bug 271375: Make the default be to use Eclipse's NLS mechanism if it's available. return isEclipseNLSAvailable(); }
Example 4
Source File: ChangeCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private boolean hasSuperTypeChange(IType type) throws JavaModelException { // check super class IType superclass = this.hierarchy.getSuperclass(type); String existingSuperclassName = superclass == null ? null : superclass.getElementName(); String newSuperclassName = type.getSuperclassName(); if (existingSuperclassName != null && !existingSuperclassName.equals(newSuperclassName)) { return true; } // check super interfaces IType[] existingSuperInterfaces = this.hierarchy.getSuperInterfaces(type); String[] newSuperInterfaces = type.getSuperInterfaceNames(); if (existingSuperInterfaces.length != newSuperInterfaces.length) { return true; } for (int i = 0, length = newSuperInterfaces.length; i < length; i++) { String superInterfaceName = newSuperInterfaces[i]; if (!superInterfaceName.equals(newSuperInterfaces[i])) { return true; } } return false; }
Example 5
Source File: JavaUtils.java From developer-studio with Apache License 2.0 | 6 votes |
public static boolean isClassExtendedFrom(IProject project, String fullyQualifiedClassName,String classNameToCheck) throws JavaModelException{ if (fullyQualifiedClassName.equals(classNameToCheck)){ return true; } else { if (fullyQualifiedClassName.equals(TOP_LEVEL_SUPER_CLASS)){ return false; }else{ IJavaProject jp = JavaCore.create(project); IType findType = getJavaITypeForClass(jp, fullyQualifiedClassName); if (findType!=null && findType.getSuperclassName()!=null){ String[][] resolveType = findType.resolveType(findType.getSuperclassName()); if (resolveType!=null){ String fullyQualifiedSuperClassName=(resolveType[0][0]).toString()+"."+(resolveType[0][1]).toString(); boolean result = isClassExtendedFrom(project, fullyQualifiedSuperClassName,classNameToCheck); if (result){ return true; } } } } return false; } }
Example 6
Source File: EqualsHashCodeDialogFactory.java From jenerate with Eclipse Public License 1.0 | 5 votes |
private boolean isDirectSubclassOfObject(final IType objectClass) throws JavaModelException { String superclass = objectClass.getSuperclassName(); if (superclass == null) { return true; } if (superclass.equals("Object") || superclass.equals("java.lang.Object")) { return true; } return false; }
Example 7
Source File: Jdt2Ecore.java From sarl with Apache License 2.0 | 5 votes |
/** Replies if the target feature is visible from the type. * * <p>The type finder could be obtained with {@link #toTypeFinder(IJavaProject)}. * * @param typeFinder the type finder to be used for finding the type definitions. * @param fromType the type from which the feature visibility is tested. * @param target the feature to test for the visibility. * @return <code>true</code> if the given type can see the target feature. * @throws JavaModelException if the Java model is invalid. * @see #toTypeFinder(IJavaProject) */ public boolean isVisible(TypeFinder typeFinder, IType fromType, IMember target) throws JavaModelException { final int flags = target.getFlags(); if (Flags.isPublic(flags)) { return true; } final String fromTypeName = fromType.getFullyQualifiedName(); final String memberType = target.getDeclaringType().getFullyQualifiedName(); if (Flags.isPrivate(flags)) { return target.getDeclaringType().getFullyQualifiedName().equals(fromTypeName); } if (Flags.isProtected(flags)) { IType t = fromType; while (t != null) { if (memberType.equals(t.getFullyQualifiedName())) { return true; } final String typeName = t.getSuperclassName(); if (Strings.isNullOrEmpty(typeName)) { t = null; } else { t = typeFinder.findType(typeName); } } } final IPackageFragment f1 = target.getDeclaringType().getPackageFragment(); final IPackageFragment f2 = fromType.getPackageFragment(); if (f1.isDefaultPackage()) { return f2.isDefaultPackage(); } return f1.getElementName().equals(f2.getElementName()); }
Example 8
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; }