本文整理汇总了Java中org.eclipse.jdt.core.ITypeHierarchy.contains方法的典型用法代码示例。如果您正苦于以下问题:Java ITypeHierarchy.contains方法的具体用法?Java ITypeHierarchy.contains怎么用?Java ITypeHierarchy.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.ITypeHierarchy
的用法示例。
在下文中一共展示了ITypeHierarchy.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isGraphWalkerExecutionContextClass
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
* @param testInterface
* @return
* @throws JavaModelException
*/
public static boolean isGraphWalkerExecutionContextClass(ICompilationUnit unit) throws JavaModelException {
IType[] types = unit.getAllTypes();
if (types == null || types.length == 0) {
ResourceManager.logInfo(unit.getJavaProject().getProject().getName(),
"getAllTypes return null" + unit.getPath());
return false;
}
IType execContextType = unit.getJavaProject().findType(ExecutionContext.class.getName());
for (int i = 0; i < types.length; i++) {
IType type = types[i];
String typeNname = type.getFullyQualifiedName();
String compilationUnitName = JDTManager.getJavaFullyQualifiedName(unit);
if (typeNname.equals(compilationUnitName)) {
try {
ITypeHierarchy th = types[0].newTypeHierarchy(new NullProgressMonitor());
return th.contains(execContextType);
} catch (Exception e) {
ResourceManager.logException(e);
}
}
}
return false;
}
示例2: computeInheritancePath
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
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()]);
}
示例3: getCachedHierarchy
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
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;
}
示例4: findTypeHierarchyInCache
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
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;
}
示例5: getCachedHierarchy
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
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;
}
示例6: computeInheritancePath
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
* Computes one inheritance path from <code>superType</code> to <code>subType</code> or <code>null
* </code> if <code>subType</code> does not inherit from <code>superType</code>. Note that there
* may be more than one inheritance path - this method simply returns one.
*
* <p>The returned array contains <code>superType</code> at its first index, and <code>subType
* </code> at its last index. If <code>subType</code> equals <code>superType</code> , an array of
* length 1 is returned containing that type.
*
* @param subType the sub type
* @param superType the super type
* @return an inheritance path from <code>superType</code> to <code>subType</code>, or <code>null
* </code> if <code>subType</code> does not inherit from <code>superType</code>
* @throws org.eclipse.jdt.core.JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
private 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(getProgressMonitor());
if (!hierarchy.contains(superType)) return null; // no path
List<IType> path = new LinkedList<IType>();
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()]);
}
示例7: remember
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
* 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);
}
}
示例8: getCachedHierarchy
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
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;
}
示例9: findTypeHierarchyInCache
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
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;
}
示例10: computeInheritancePath
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
* Computes one inheritance path from <code>superType</code> to <code>subType</code> or
* <code>null</code> if <code>subType</code> does not inherit from <code>superType</code>. Note
* that there may be more than one inheritance path - this method simply returns one.
* <p>
* The returned array contains <code>superType</code> at its first index, and
* <code>subType</code> at its last index. If <code>subType</code> equals <code>superType</code>
* , an array of length 1 is returned containing that type.
* </p>
*
* @param subType the sub type
* @param superType the super type
* @return an inheritance path from <code>superType</code> to <code>subType</code>, or
* <code>null</code> if <code>subType</code> does not inherit from
* <code>superType</code>
* @throws JavaModelException if this element does not exist or if an exception occurs while
* accessing its corresponding resource
*/
private 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(getProgressMonitor());
if (!hierarchy.contains(superType))
return null; // no path
List<IType> path= new LinkedList<IType>();
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()]);
}
示例11: remember
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
* 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);
}
}
示例12: isSubtype
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
public boolean isSubtype(IType type, IType supertype)
{
if (supertype == null)
return false;
try
{
ITypeHierarchy supertypes = getSupertypes(type);
return supertypes.contains(supertype);
}
catch (JavaModelException e)
{
Activator.log(Status.ERROR, "Error while checking type hierarchy of "
+ type.getFullyQualifiedName() + " and " + supertype.getFullyQualifiedName());
}
return false;
}
示例13: addTypeHierarchyToCache
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static void addTypeHierarchyToCache(ITypeHierarchy hierarchy) {
synchronized (fgHierarchyCache) {
int nEntries = fgHierarchyCache.size();
if (nEntries >= CACHE_SIZE) {
// find obsolete entries or remove entry that was least recently accessed
HierarchyCacheEntry oldest = null;
ArrayList<HierarchyCacheEntry> obsoleteHierarchies =
new ArrayList<HierarchyCacheEntry>(CACHE_SIZE);
for (int i = 0; i < nEntries; i++) {
HierarchyCacheEntry entry = fgHierarchyCache.get(i);
ITypeHierarchy curr = entry.getTypeHierarchy();
if (!curr.exists() || hierarchy.contains(curr.getType())) {
obsoleteHierarchies.add(entry);
} else {
if (oldest == null || entry.getLastAccess() < oldest.getLastAccess()) {
oldest = entry;
}
}
}
if (!obsoleteHierarchies.isEmpty()) {
for (int i = 0; i < obsoleteHierarchies.size(); i++) {
removeHierarchyEntryFromCache(obsoleteHierarchies.get(i));
}
} else if (oldest != null) {
removeHierarchyEntryFromCache(oldest);
}
}
HierarchyCacheEntry newEntry = new HierarchyCacheEntry(hierarchy);
fgHierarchyCache.add(newEntry);
}
}
示例14: isSubtype
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
* Returns whether a type is the super of another type.
*
* @param superType the possible super type. If <code>null</code>, this method
* always returns <code>false<code>.
* @param type the type
*/
public static boolean isSubtype(IType superType, IType type)
throws JavaModelException {
if (superType == null) {
return false;
}
ITypeHierarchy superTypes = type.newSupertypeHierarchy(null);
return superTypes.contains(superType);
}
示例15: isSyncInterface
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
* Returns <code>true</code> if the type is or extends the RemoteService
* interface.
*/
public static boolean isSyncInterface(IType type) throws JavaModelException {
IJavaProject javaProject = type.getJavaProject();
if (!GWTNature.isGWTProject(javaProject.getProject())) {
return false;
}
ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
IType remoteServiceInterface = javaProject.findType(REMOTE_SERVICE_QUALIFIED_NAME);
return remoteServiceInterface != null
&& hierarchy.contains(remoteServiceInterface);
}