List of usage examples for org.eclipse.jdt.core IType getSuperclassName
String getSuperclassName() throws JavaModelException;
null
for source types that do not specify a superclass. From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.contentassist.FXGraphProposalProvider.java
License:Open Source License
private void collectStaticFields(List<IField> fields, IType type) throws JavaModelException { //FIXME Don't we have to check if the field is assignable??? for (IField f : type.getFields()) { if (Flags.isStatic(f.getFlags())) { fields.add(f);/*from w w w.j a va2 s. c o m*/ } } String s = type.getSuperclassName(); if (s != null) { String fqn = at.bestsolution.efxclipse.tooling.model.internal.utils.Util.getFQNType(type, Signature.getTypeErasure(s)); collectStaticFields(fields, type.getJavaProject().findType(fqn)); } }
From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.util.JDTHelper.java
License:Open Source License
public TypeData getTypeData(IJavaProject jproject, IType jdtType) { if (jdtType == null) { return null; }/* w w w . ja v a 2 s . c om*/ TypeData data = typeCache.get(jdtType.getFullyQualifiedName()); if (data == null) { try { List<IMethod> allMethods = new ArrayList<IMethod>(); allMethods.addAll(Arrays.asList(jdtType.getMethods())); IType parentType = jdtType; while (parentType != null && parentType.getSuperclassName() != null) { if (parentType instanceof SourceType) { String[][] typeDefs = parentType.resolveType(parentType.getSuperclassName()); if (typeDefs != null) { for (String[] type : typeDefs) { parentType = jproject.findType(type[0] + "." + type[1]); } } } else { parentType = jproject.findType(parentType.getSuperclassName()); } if (parentType != null) { allMethods.addAll(Arrays.asList(parentType.getMethods())); } } data = createData(allMethods, jproject); if (!(jdtType instanceof SourceType)) { typeCache.put(jdtType.getFullyQualifiedName(), data); } } catch (JavaModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return data; }
From source file:at.bestsolution.efxclipse.tooling.model.internal.FXClass.java
License:Open Source License
public FXClass(IJavaProject jp, IType type) { this.type = type; this.javaProject = jp; try {//from w w w .ja va 2s . com String s = type.getSuperclassName(); if (s != null) { s = getFQNType(type, Signature.getTypeErasure(s)); superClass = FXPlugin.getClassmodel().findClass(jp, jp.findType(s)); } } catch (JavaModelException e) { FXPlugin.getLogger().log(LogService.LOG_ERROR, "Unable to retrieve superclass name of '" + type.getFullyQualifiedName() + "'", e); } }
From source file:at.bestsolution.efxclipse.tooling.model.internal.FXCollectionProperty.java
License:Open Source License
public static boolean isList(IJavaProject jp, String erasedFQNType) throws JavaModelException { String checkType = erasedFQNType; do {// w w w . j a va 2 s . co m if ("javafx.collections.ObservableList".equals(checkType) || "javafx.collections.ObservableSet".equals(checkType) || "java.util.Collection".equals(checkType)) { return true; } IType t = jp.findType(checkType); checkType = t.getSuperclassName(); if (checkType != null) { checkType = Util.getFQNType(t, checkType); } } while (checkType != null); return false; }
From source file:at.bestsolution.efxclipse.tooling.model.internal.FXCtrlClass.java
License:Open Source License
public FXCtrlClass(IJavaProject jp, IType type) { this.javaProject = jp; this.type = type; try {/*from w ww. j a v a 2s . c om*/ String s = type.getSuperclassName(); if (s != null) { s = getFQNType(type, s); superClass = FXPlugin.getClassmodel().findCtrlClass(jp, jp.findType(s)); } } catch (JavaModelException e) { FXPlugin.getLogger().log(LogService.LOG_ERROR, "Unable to retrieve superclass name of '" + type.getFullyQualifiedName() + "'", e); } }
From source file:at.bestsolution.efxclipse.tooling.model.internal.FXCtrlEventMethod.java
License:Open Source License
public static boolean isEventMethod(IJavaProject jp, String erasedFQNType) throws JavaModelException { String checkType = erasedFQNType; do {/*w w w . j a v a 2s . c om*/ if ("javafx.event.Event".equals(checkType)) { return true; } IType t = jp.findType(checkType); checkType = t.getSuperclassName(); if (checkType != null) { checkType = Util.getFQNType(t, checkType); } } while (checkType != null); return false; }
From source file:at.bestsolution.efxclipse.tooling.model.internal.FXEventHandlerProperty.java
License:Open Source License
public static boolean isEventHandler(IJavaProject jp, String erasedFQNType) throws JavaModelException { String checkType = erasedFQNType; do {/*w w w . jav a 2 s . c o m*/ if ("javafx.event.EventHandler".equals(checkType)) { return true; } IType t = jp.findType(checkType); checkType = t.getSuperclassName(); if (checkType != null) { checkType = Util.getFQNType(t, checkType); } } while (checkType != null); return false; }
From source file:at.bestsolution.efxclipse.tooling.model.internal.FXMapProperty.java
License:Open Source License
public static boolean isMap(IJavaProject jp, String erasedFQNType) throws JavaModelException { String checkType = erasedFQNType; do {/*from www. j a va 2s .c o m*/ if ("javafx.collections.ObservableMap".equals(checkType)) { return true; } IType t = jp.findType(checkType); checkType = t.getSuperclassName(); if (checkType != null) { checkType = Util.getFQNType(t, checkType); } } while (checkType != null); return false; }
From source file:com.aliyun.odps.eclipse.launch.shortcut.udf.UDFLaunchShortcuts2.java
License:Apache License
/** * Returns the smallest enclosing <code>IType</code> if the specified object is a main method, or * <code>null</code>//from w ww.ja v a 2s .co m * * @param o the object to inspect * @return the smallest enclosing <code>IType</code> of the specified object if it is a main * method or <code>null</code> if it is not */ private IType isUDF(Object o) { if (o instanceof IAdaptable) { IAdaptable adapt = (IAdaptable) o; IJavaElement element = (IJavaElement) adapt.getAdapter(IJavaElement.class); if (element instanceof CompilationUnit) { CompilationUnit unit = (CompilationUnit) element; IClassFile i; try { IType[] types = unit.getTypes(); for (IType iType : types) { String superClassName = iType.getSuperclassName(); if (superClassName.equals("UDF") || superClassName.equals("UDTF") || superClassName.equals("Aggregator")) { return iType; } } } catch (JavaModelException e) { } } } return null; }
From source file:com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo.java
License:Open Source License
/** * Returns the activities associated with the given layout file. Makes an educated guess * by peeking at the usages of the R.layout.name field corresponding to the layout and * if it finds a usage./*from ww w . j ava 2s. co m*/ * * @param project the project containing the layout * @param layoutName the layout whose activity we want to look up * @param pkg the package containing activities * @return the activity name */ @NonNull public static List<String> guessActivities(IProject project, String layoutName, String pkg) { final LinkedList<String> activities = new LinkedList<String>(); SearchRequestor requestor = new SearchRequestor() { @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { Object element = match.getElement(); if (element instanceof IMethod) { IMethod method = (IMethod) element; IType declaringType = method.getDeclaringType(); String fqcn = declaringType.getFullyQualifiedName(); if ((declaringType.getSuperclassName() != null && declaringType.getSuperclassName().endsWith("Activity")) //$NON-NLS-1$ || method.getElementName().equals("onCreate")) { //$NON-NLS-1$ activities.addFirst(fqcn); } else { activities.addLast(fqcn); } } } }; try { IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); if (javaProject == null) { return Collections.emptyList(); } // TODO - look around a bit more and see if we can figure out whether the // call if from within a setContentView call! // Search for which java classes call setContentView(R.layout.layoutname); String typeFqcn = "R.layout"; //$NON-NLS-1$ if (pkg != null) { typeFqcn = pkg + '.' + typeFqcn; } IType type = javaProject.findType(typeFqcn); if (type != null) { IField field = type.getField(layoutName); if (field.exists()) { SearchPattern pattern = SearchPattern.createPattern(field, REFERENCES); try { search(requestor, javaProject, pattern); } catch (OperationCanceledException canceled) { // pass } } } } catch (CoreException e) { AdtPlugin.log(e, null); } return activities; }