private void processTypeDelta(IType type, ArrayList<IType> changedTypes) { if (getHierarchy().contains(type)) { changedTypes.add(type); } }
private void processTypeDelta(IType type, ArrayList<IType> changedTypes) { if (getHierarchy().contains(type)) { changedTypes.add(type); } }
private void processTypeDelta(IType type, ArrayList changedTypes) { if (getHierarchy().contains(type)) { changedTypes.add(type); } }
static IType[] computeInheritancePath(IType subType, IType superType) throws JavaModelException { if (superType == null) { return null; } // optimization: avoid building the type hierarchy for the identity case if (superType.equals(subType)) { return new IType[] { subType }; } ITypeHierarchy hierarchy= subType.newSupertypeHierarchy(new NullProgressMonitor()); if (!hierarchy.contains(superType)) { return null; // no path } List<IType> path= new LinkedList<>(); path.add(superType); do { // any sub type must be on a hierarchy chain from superType to subType superType= hierarchy.getSubtypes(superType)[0]; path.add(superType); } while (!superType.equals(subType)); // since the equality case is handled above, we can spare one check return path.toArray(new IType[path.size()]); }
public boolean visit(FieldAccess node) { final ITypeBinding declaring= MoveInnerToTopRefactoring.getDeclaringTypeBinding(node); if (declaring != null) { final IType type= (IType) declaring.getJavaElement(); if (type != null && fHierarchy.contains(type)) fFieldAccesses.add(node); } return super.visit(node); }
public boolean visit(MethodInvocation node) { final ITypeBinding declaring= MoveInnerToTopRefactoring.getDeclaringTypeBinding(node); if (declaring != null) { final IType type= (IType) declaring.getJavaElement(); if (type != null && fHierarchy.contains(type)) fMethodAccesses.add(node); } return super.visit(node); }
private static IType findMostSpecific(Collection<IType> candidates) throws JavaModelException { ITypeHierarchy superHierarchy = null; for (IType t : candidates) { if (superHierarchy == null || !superHierarchy.contains(t)) { superHierarchy = t.newSupertypeHierarchy(null); } } if (superHierarchy == null) { return null; } return superHierarchy.getType(); }
private ITypeHierarchy getCachedHierarchy(IType type, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { IType rep = fUnionFind.find(type); if (rep != null) { Collection<IType> collection = fRootReps.get(rep); for (Iterator<IType> iter = collection.iterator(); iter.hasNext();) { IType root = iter.next(); ITypeHierarchy hierarchy = fRootHierarchies.get(root); if (hierarchy == null) { hierarchy = root.newTypeHierarchy(owner, new SubProgressMonitor(monitor, 1)); fRootHierarchies.put(root, hierarchy); } if (hierarchy.contains(type)) { return hierarchy; } } } return null; }
private ITypeHierarchy getCachedHierarchy(IType type, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { IType rep= fUnionFind.find(type); if (rep != null) { Collection<IType> collection= fRootReps.get(rep); for (Iterator<IType> iter= collection.iterator(); iter.hasNext();) { IType root= iter.next(); ITypeHierarchy hierarchy= fRootHierarchies.get(root); if (hierarchy == null) { hierarchy= root.newTypeHierarchy(owner, new SubProgressMonitor(monitor, 1)); fRootHierarchies.put(root, hierarchy); } if (hierarchy.contains(type)) return hierarchy; } } return null; }
private ITypeHierarchy getCachedHierarchy(IType type, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { IType rep= fUnionFind.find(type); if (rep != null) { Collection<IType> collection= fRootReps.get(rep); for (Iterator<IType> iter= collection.iterator(); iter.hasNext();) { IType root= iter.next(); ITypeHierarchy hierarchy= fRootHierarchies.get(root); if (hierarchy == null) { hierarchy= root.newTypeHierarchy(owner, new SubProgressMonitor(monitor, 1)); fRootHierarchies.put(root, hierarchy); } if (hierarchy.contains(type)) return hierarchy; } } return null; }
private ITypeHierarchy getCachedHierarchy(IType type, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { IType rep= fUnionFind.find(type); if (rep != null) { Collection collection= fRootReps.get(rep); for (Iterator iter= collection.iterator(); iter.hasNext();) { IType root= (IType) iter.next(); ITypeHierarchy hierarchy= (ITypeHierarchy) fRootHierarchies.get(root); if (hierarchy == null) { hierarchy= root.newTypeHierarchy(owner, new SubProgressMonitor(monitor, 1)); fRootHierarchies.put(root, hierarchy); } if (hierarchy.contains(type)) return hierarchy; } } return null; }
private ITypeHierarchy getCachedHierarchy(IType type, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { IType rep= fUnionFind.find(type); if (rep != null) { Collection<IType> collection= fRootReps.get(rep); for (Iterator<IType> iter= collection.iterator(); iter.hasNext();) { IType root= iter.next(); ITypeHierarchy hierarchy= fRootHierarchies.get(root); if (hierarchy == null) { hierarchy= root.newTypeHierarchy(owner, new SubProgressMonitor(monitor, 1)); fRootHierarchies.put(root, hierarchy); } if (hierarchy.contains(type)) { return hierarchy; } } } return null; }
private static ITypeHierarchy findTypeHierarchyInCache(IType type) { synchronized (fgHierarchyCache) { for (int i= fgHierarchyCache.size() - 1; i>= 0; i--) { HierarchyCacheEntry curr= (HierarchyCacheEntry) fgHierarchyCache.get(i); ITypeHierarchy hierarchy= curr.getTypeHierarchy(); if (!hierarchy.exists()) { removeHierarchyEntryFromCache(curr); } else { if (hierarchy.contains(type)) { curr.markAsAccessed(); return hierarchy; } } } } return null; }
private static ITypeHierarchy findTypeHierarchyInCache(IType type) { synchronized (fgHierarchyCache) { for (int i= fgHierarchyCache.size() - 1; i>= 0; i--) { HierarchyCacheEntry curr= fgHierarchyCache.get(i); ITypeHierarchy hierarchy= curr.getTypeHierarchy(); if (!hierarchy.exists()) { removeHierarchyEntryFromCache(curr); } else { if (hierarchy.contains(type)) { curr.markAsAccessed(); return hierarchy; } } } } return null; }
private static ITypeHierarchy findTypeHierarchyInCache(IType type) { synchronized (fgHierarchyCache) { for (int i= fgHierarchyCache.size() - 1; i>= 0; i--) { HierarchyCacheEntry curr= fgHierarchyCache.get(i); ITypeHierarchy hierarchy= curr.getTypeHierarchy(); if (!hierarchy.exists()) { removeHierarchyEntryFromCache(curr); } else { if (hierarchy.contains(type)) { curr.markAsAccessed(); return hierarchy; } } } } return null; }
public boolean visit(ThisExpression node) { final Name qualifier= node.getQualifier(); if (qualifier != null) { final ITypeBinding binding= qualifier.resolveTypeBinding(); if (binding != null) { final IType type= (IType) binding.getJavaElement(); if (type != null && fHierarchy.contains(type)) { fSimpleNames.add(qualifier); return false; } } } return super.visit(node); } }
private static boolean isEclipseNLSUsed(IType accessor) { IJavaProject javaProject= accessor.getJavaProject(); if (javaProject == null || !javaProject.exists()) return false; try { IType nls= javaProject.findType("org.eclipse.osgi.util.NLS"); //$NON-NLS-1$ if(nls==null) return false; ITypeHierarchy supertypeHierarchy= accessor.newSupertypeHierarchy(null); return supertypeHierarchy.contains(nls); } catch (JavaModelException e) { return false; } }
private static boolean isEclipseNLSUsed(IType accessor) { IJavaProject javaProject= accessor.getJavaProject(); if (javaProject == null || !javaProject.exists()) return false; try { IType nls= javaProject.findType("org.eclipse.osgi.util.NLS"); //$NON-NLS-1$ if(nls==null) return false; ITypeHierarchy supertypeHierarchy= accessor.newSupertypeHierarchy(null); return supertypeHierarchy.contains(nls); } catch (JavaModelException e) { return false; } }
@SuppressWarnings("synthetic-access") @Override public void run(IProgressMonitor pm) throws InvocationTargetException { try { final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); final IJavaProject javaProject = JavaCore.create(project); final IType agentType = javaProject.findType("io.sarl.lang.core.Agent"); //$NON-NLS-1$ if (agentType != null) { final IType type = javaProject.findType(agentName); if (type != null) { res[0] = type.newSupertypeHierarchy(pm).contains(agentType); } } } catch (JavaModelException e) { setErrorMessage(e.getLocalizedMessage()); JDIDebugUIPlugin.log(e); } } });
public boolean visit(SimpleName node) { if (node.getParent() instanceof QualifiedName) return super.visit(node); IBinding binding= node.resolveBinding(); if (binding instanceof IVariableBinding) { IVariableBinding variable= (IVariableBinding) binding; ITypeBinding declaring= variable.getDeclaringClass(); if (variable.isField() && declaring != null) { final IType type= (IType) declaring.getJavaElement(); if (type != null && fHierarchy.contains(type)) { fSimpleNames.add(node); return false; } } } return super.visit(node); }