List of usage examples for org.eclipse.jdt.core IType getTypeRoot
ITypeRoot getTypeRoot();
From source file:at.bestsolution.fxide.jdt.text.viewersupport.JavaElementLabelComposer.java
License:Open Source License
/** * Appends the label for a type. Considers the T_* flags. * * @param type the element to render/*from w w w . j a v a 2 s . c om*/ * @param flags the rendering flags. Flags with names starting with 'T_' are considered. */ public void appendTypeLabel(IType type, long flags) { if (getFlag(flags, JavaElementLabels.T_FULLY_QUALIFIED)) { IPackageFragment pack = type.getPackageFragment(); if (!pack.isDefaultPackage()) { appendPackageFragmentLabel(pack, (flags & QUALIFIER_FLAGS)); fBuffer.append('.'); } } IJavaElement parent = type.getParent(); if (getFlag(flags, JavaElementLabels.T_FULLY_QUALIFIED | JavaElementLabels.T_CONTAINER_QUALIFIED)) { IType declaringType = type.getDeclaringType(); if (declaringType != null) { appendTypeLabel(declaringType, JavaElementLabels.T_CONTAINER_QUALIFIED | (flags & QUALIFIER_FLAGS)); fBuffer.append('.'); } int parentType = parent.getElementType(); if (parentType == IJavaElement.METHOD || parentType == IJavaElement.FIELD || parentType == IJavaElement.INITIALIZER) { // anonymous or local appendElementLabel(parent, 0); fBuffer.append('.'); } } String typeName; boolean isAnonymous = false; if (type.isLambda()) { typeName = "() -> {...}"; //$NON-NLS-1$ try { String[] superInterfaceSignatures = type.getSuperInterfaceTypeSignatures(); if (superInterfaceSignatures.length > 0) { typeName = typeName + ' ' + getSimpleTypeName(type, superInterfaceSignatures[0]); } } catch (JavaModelException e) { //ignore } } else { typeName = getElementName(type); try { isAnonymous = type.isAnonymous(); } catch (JavaModelException e1) { // should not happen, but let's play safe: isAnonymous = typeName.length() == 0; } if (isAnonymous) { try { if (parent instanceof IField && type.isEnum()) { typeName = '{' + JavaElementLabels.ELLIPSIS_STRING + '}'; } else { String supertypeName = null; String[] superInterfaceSignatures = type.getSuperInterfaceTypeSignatures(); if (superInterfaceSignatures.length > 0) { supertypeName = getSimpleTypeName(type, superInterfaceSignatures[0]); } else { String supertypeSignature = type.getSuperclassTypeSignature(); if (supertypeSignature != null) { supertypeName = getSimpleTypeName(type, supertypeSignature); } } if (supertypeName == null) { typeName = JavaUIMessages.JavaElementLabels_anonym; } else { typeName = Messages.format(JavaUIMessages.JavaElementLabels_anonym_type, supertypeName); } } } catch (JavaModelException e) { //ignore typeName = JavaUIMessages.JavaElementLabels_anonym; } } } fBuffer.append(typeName); if (getFlag(flags, JavaElementLabels.T_TYPE_PARAMETERS)) { if (getFlag(flags, JavaElementLabels.USE_RESOLVED) && type.isResolved()) { BindingKey key = new BindingKey(type.getKey()); if (key.isParameterizedType()) { String[] typeArguments = key.getTypeArguments(); appendTypeArgumentSignaturesLabel(type, typeArguments, flags); } else { String[] typeParameters = Signature.getTypeParameters(key.toSignature()); appendTypeParameterSignaturesLabel(typeParameters, flags); } } else if (type.exists()) { try { appendTypeParametersLabels(type.getTypeParameters(), flags); } catch (JavaModelException e) { // ignore } } } // category if (getFlag(flags, JavaElementLabels.T_CATEGORY) && type.exists()) { try { appendCategoryLabel(type, flags); } catch (JavaModelException e) { // ignore } } // post qualification if (getFlag(flags, JavaElementLabels.T_POST_QUALIFIED)) { int offset = fBuffer.length(); fBuffer.append(JavaElementLabels.CONCAT_STRING); IType declaringType = type.getDeclaringType(); if (declaringType == null && type.isBinary() && isAnonymous) { // workaround for Bug 87165: [model] IType#getDeclaringType() does not work for anonymous binary type String tqn = type.getTypeQualifiedName(); int lastDollar = tqn.lastIndexOf('$'); if (lastDollar != 1) { String declaringTypeCF = tqn.substring(0, lastDollar) + ".class"; //$NON-NLS-1$ declaringType = type.getPackageFragment().getClassFile(declaringTypeCF).getType(); try { ISourceRange typeSourceRange = type.getSourceRange(); if (declaringType.exists() && SourceRange.isAvailable(typeSourceRange)) { IJavaElement realParent = declaringType.getTypeRoot() .getElementAt(typeSourceRange.getOffset() - 1); if (realParent != null) { parent = realParent; } } } catch (JavaModelException e) { // ignore } } } if (declaringType != null) { appendTypeLabel(declaringType, JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS)); int parentType = parent.getElementType(); if (parentType == IJavaElement.METHOD || parentType == IJavaElement.FIELD || parentType == IJavaElement.INITIALIZER) { // anonymous or local fBuffer.append('.'); appendElementLabel(parent, 0); } } else { appendPackageFragmentLabel(type.getPackageFragment(), flags & QUALIFIER_FLAGS); } // if (getFlag(flags, JavaElementLabels.COLORIZE)) { // fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); // } } }
From source file:ca.uvic.chisel.javasketch.internal.JavaSearchUtils.java
License:Open Source License
private static IJavaElement searchForType(String classSignature, IJavaSearchScope scope, IProgressMonitor monitor) throws CoreException, InterruptedException { try {/* w ww . j a va 2s . c om*/ synchronized (cachedTypes) { IType found = cachedTypes.get(classSignature); if (found != null) { return found; } SearchEngine engine = new SearchEngine(); SearchPattern pattern = null; SearchParticipant participant = SearchEngine.getDefaultSearchParticipant(); LocalSearchRequestor requestor = new LocalSearchRequestor(); pattern = SearchPattern.createPattern(classSignature.replace('$', '.'), IJavaSearchConstants.CLASS, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH); engine.search(pattern, new SearchParticipant[] { participant }, scope, requestor, monitor); if (requestor.matches.size() > 0) { found = (IType) requestor.matches.get(0).getElement(); if (found.getFullyQualifiedName().equals(classSignature)) { cachedTypes.put(classSignature, found); return found; } } String[] className = classSignature.split("\\$"); found = cachedTypes.get(className[0]); if (found == null) { //find the class pattern = SearchPattern.createPattern(className[0], IJavaSearchConstants.CLASS, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH); engine.search(pattern, new SearchParticipant[] { participant }, scope, requestor, monitor); if (monitor.isCanceled()) { throw new InterruptedException(); } if (requestor.matches.size() > 0) { found = (IType) requestor.matches.get(0).getElement(); if (found.getFullyQualifiedName().equals(classSignature)) { for (SearchMatch match : requestor.matches) { IType temp = (IType) match.getElement(); if (temp.getTypeRoot() instanceof ICompilationUnit) { //prefer source types. found = temp; break; } } if (cachedTypes.size() > 100) { cachedTypes.clear(); } cachedTypes.put(className[0], found); } else { found = null; } } } if (found == null) return null; StringBuilder childTypeName = new StringBuilder(); childTypeName.append(className[0]); //check each of the indexes for the sub-types for (int i = 1; i < className.length; i++) { childTypeName.append('$'); childTypeName.append(className[i]); IType parent = found; found = cachedTypes.get(childTypeName.toString()); if (found == null) { boolean isAnonymous = false; Integer occurrenceCount = -1; try { occurrenceCount = Integer.parseInt(className[i]); isAnonymous = true; } catch (NumberFormatException e) { isAnonymous = false; } if (isAnonymous) { if (!parent.isBinary()) { found = parent.getType("", occurrenceCount); if (found != null) { if (found.exists()) { cachedTypes.put(childTypeName.toString(), found); continue; } else { found = null; } } } else { //if it is a binary type, there is no hope for //finding an anonymous inner class. Use the number //as the type name, and cache the handle. found = parent.getType(className[i]); cachedTypes.put(childTypeName.toString(), found); continue; } } ArrayList<IType> childTypes = new ArrayList<IType>(); LinkedList<IJavaElement> children = new LinkedList<IJavaElement>(); children.addAll(Arrays.asList(parent.getChildren())); while (children.size() > 0) { IJavaElement child = children.removeFirst(); if (child instanceof IType) { childTypes.add((IType) child); } else if (child instanceof IMember) { children.addAll(Arrays.asList(((IMember) child).getChildren())); } } int numIndex = 0; while (numIndex < className[i].length() && Character.isDigit(className[i].charAt(numIndex))) { numIndex++; } String name = className[i]; try { //get a number at the beginning to find out if //there is an occurrence count if (numIndex <= name.length()) { occurrenceCount = parseInt(name.substring(0, numIndex)); if (occurrenceCount == null) { occurrenceCount = 1; } if (numIndex < name.length() - 1) { name = name.substring(numIndex); } else { name = ""; } } for (IType childType : childTypes) { if ("".equals(name)) { if (childType.getOccurrenceCount() == occurrenceCount) { found = childType; break; } } else { if (name.equals(childType.getElementName()) && childType.getOccurrenceCount() == occurrenceCount) { found = childType; break; } } } if (found == null) { if ("".equals(name)) { found = parent.getTypeRoot().getJavaProject().findType(classSignature); //found = parent.getType("" + occurrenceCount); } else { found = parent.getType(name, occurrenceCount); } } cachedTypes.put(childTypeName.toString(), found); } catch (Exception e) { e.printStackTrace(); } } } return found; } } catch (Exception e) { SketchPlugin.getDefault().log(e); return null; } }
From source file:com.codenvy.ide.ext.java.server.javadoc.JavaElementLabelComposer.java
License:Open Source License
/** * Appends the label for a type. Considers the T_* flags. * * @param type the element to render/*from ww w .j ava 2 s .com*/ * @param flags the rendering flags. Flags with names starting with 'T_' are considered. */ public void appendTypeLabel(IType type, long flags) { if (getFlag(flags, JavaElementLabels.T_FULLY_QUALIFIED)) { IPackageFragment pack = type.getPackageFragment(); if (!pack.isDefaultPackage()) { appendPackageFragmentLabel(pack, (flags & QUALIFIER_FLAGS)); fBuffer.append('.'); } } IJavaElement parent = type.getParent(); if (getFlag(flags, JavaElementLabels.T_FULLY_QUALIFIED | JavaElementLabels.T_CONTAINER_QUALIFIED)) { IType declaringType = type.getDeclaringType(); if (declaringType != null) { appendTypeLabel(declaringType, JavaElementLabels.T_CONTAINER_QUALIFIED | (flags & QUALIFIER_FLAGS)); fBuffer.append('.'); } int parentType = parent.getElementType(); if (parentType == IJavaElement.METHOD || parentType == IJavaElement.FIELD || parentType == IJavaElement.INITIALIZER) { // anonymous or local appendElementLabel(parent, 0); fBuffer.append('.'); } } String typeName; boolean isAnonymous = false; if (type.isLambda()) { typeName = "() -> {...}"; //$NON-NLS-1$ try { String[] superInterfaceSignatures = type.getSuperInterfaceTypeSignatures(); if (superInterfaceSignatures.length > 0) { typeName = typeName + ' ' + getSimpleTypeName(type, superInterfaceSignatures[0]); } } catch (JavaModelException e) { //ignore } } else { typeName = getElementName(type); try { isAnonymous = type.isAnonymous(); } catch (JavaModelException e1) { // should not happen, but let's play safe: isAnonymous = typeName.length() == 0; } if (isAnonymous) { try { if (parent instanceof IField && type.isEnum()) { typeName = '{' + JavaElementLabels.ELLIPSIS_STRING + '}'; } else { String supertypeName; String[] superInterfaceSignatures = type.getSuperInterfaceTypeSignatures(); if (superInterfaceSignatures.length > 0) { supertypeName = getSimpleTypeName(type, superInterfaceSignatures[0]); } else { supertypeName = getSimpleTypeName(type, type.getSuperclassTypeSignature()); } typeName = MessageFormat.format("new {0}() '{'...}", supertypeName); } } catch (JavaModelException e) { //ignore typeName = "new Anonymous"; } } } fBuffer.append(typeName); if (getFlag(flags, JavaElementLabels.T_TYPE_PARAMETERS)) { if (getFlag(flags, JavaElementLabels.USE_RESOLVED) && type.isResolved()) { BindingKey key = new BindingKey(type.getKey()); if (key.isParameterizedType()) { String[] typeArguments = key.getTypeArguments(); appendTypeArgumentSignaturesLabel(type, typeArguments, flags); } else { String[] typeParameters = Signature.getTypeParameters(key.toSignature()); appendTypeParameterSignaturesLabel(typeParameters, flags); } } else if (type.exists()) { try { appendTypeParametersLabels(type.getTypeParameters(), flags); } catch (JavaModelException e) { // ignore } } } // category if (getFlag(flags, JavaElementLabels.T_CATEGORY) && type.exists()) { try { appendCategoryLabel(type, flags); } catch (JavaModelException e) { // ignore } } // post qualification if (getFlag(flags, JavaElementLabels.T_POST_QUALIFIED)) { int offset = fBuffer.length(); fBuffer.append(JavaElementLabels.CONCAT_STRING); IType declaringType = type.getDeclaringType(); if (declaringType == null && type.isBinary() && isAnonymous) { // workaround for Bug 87165: [model] IType#getDeclaringType() does not work for anonymous binary type String tqn = type.getTypeQualifiedName(); int lastDollar = tqn.lastIndexOf('$'); if (lastDollar != 1) { String declaringTypeCF = tqn.substring(0, lastDollar) + ".class"; //$NON-NLS-1$ declaringType = type.getPackageFragment().getClassFile(declaringTypeCF).getType(); try { ISourceRange typeSourceRange = type.getSourceRange(); if (declaringType.exists() && SourceRange.isAvailable(typeSourceRange)) { IJavaElement realParent = declaringType.getTypeRoot() .getElementAt(typeSourceRange.getOffset() - 1); if (realParent != null) { parent = realParent; } } } catch (JavaModelException e) { // ignore } } } if (declaringType != null) { appendTypeLabel(declaringType, JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS)); int parentType = parent.getElementType(); if (parentType == IJavaElement.METHOD || parentType == IJavaElement.FIELD || parentType == IJavaElement.INITIALIZER) { // anonymous or local fBuffer.append('.'); appendElementLabel(parent, 0); } } else { appendPackageFragmentLabel(type.getPackageFragment(), flags & QUALIFIER_FLAGS); } // if (getFlag(flags, JavaElementLabels.COLORIZE)) { // fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); // } } }
From source file:com.microsoft.javapkgsrv.JavaElementLabelComposer.java
License:Open Source License
/** * Appends the label for a type. Considers the T_* flags. * * @param type the element to render/*from w w w .j a v a2 s.c o m*/ * @param flags the rendering flags. Flags with names starting with 'T_' are considered. */ public void appendTypeLabel(IType type, long flags) { if (getFlag(flags, T_FULLY_QUALIFIED)) { IPackageFragment pack = type.getPackageFragment(); if (!pack.isDefaultPackage()) { appendPackageFragmentLabel(pack, (flags & QUALIFIER_FLAGS)); fBuffer.append('.'); } } IJavaElement parent = type.getParent(); if (getFlag(flags, T_FULLY_QUALIFIED | T_CONTAINER_QUALIFIED)) { IType declaringType = type.getDeclaringType(); if (declaringType != null) { appendTypeLabel(declaringType, T_CONTAINER_QUALIFIED | (flags & QUALIFIER_FLAGS)); fBuffer.append('.'); } int parentType = parent.getElementType(); if (parentType == IJavaElement.METHOD || parentType == IJavaElement.FIELD || parentType == IJavaElement.INITIALIZER) { // anonymous or local appendElementLabel(parent, 0); fBuffer.append('.'); } } String typeName; boolean isAnonymous = false; if (type.isLambda()) { typeName = "() -> {...}"; //$NON-NLS-1$ try { String[] superInterfaceSignatures = type.getSuperInterfaceTypeSignatures(); if (superInterfaceSignatures.length > 0) { typeName = typeName + ' ' + getSimpleTypeName(type, superInterfaceSignatures[0]); } } catch (JavaModelException e) { //ignore } } else { typeName = getElementName(type); try { isAnonymous = type.isAnonymous(); } catch (JavaModelException e1) { // should not happen, but let's play safe: isAnonymous = typeName.length() == 0; } if (isAnonymous) { try { if (parent instanceof IField && type.isEnum()) { typeName = '{' + ELLIPSIS_STRING + '}'; } else { String supertypeName; String[] superInterfaceSignatures = type.getSuperInterfaceTypeSignatures(); if (superInterfaceSignatures.length > 0) { supertypeName = getSimpleTypeName(type, superInterfaceSignatures[0]); } else { supertypeName = getSimpleTypeName(type, type.getSuperclassTypeSignature()); } typeName = "new " + supertypeName + "() {...}"; } } catch (JavaModelException e) { //ignore typeName = "new Anonymous"; } } } fBuffer.append(typeName); if (getFlag(flags, T_TYPE_PARAMETERS)) { if (getFlag(flags, USE_RESOLVED) && type.isResolved()) { BindingKey key = new BindingKey(type.getKey()); if (key.isParameterizedType()) { String[] typeArguments = key.getTypeArguments(); appendTypeArgumentSignaturesLabel(type, typeArguments, flags); } else { String[] typeParameters = Signature.getTypeParameters(key.toSignature()); appendTypeParameterSignaturesLabel(typeParameters, flags); } } else if (type.exists()) { try { appendTypeParametersLabels(type.getTypeParameters(), flags); } catch (JavaModelException e) { // ignore } } } // category if (getFlag(flags, T_CATEGORY) && type.exists()) { try { appendCategoryLabel(type, flags); } catch (JavaModelException e) { // ignore } } // post qualification if (getFlag(flags, T_POST_QUALIFIED)) { int offset = fBuffer.length(); fBuffer.append(CONCAT_STRING); IType declaringType = type.getDeclaringType(); if (declaringType == null && type.isBinary() && isAnonymous) { // workaround for Bug 87165: [model] IType#getDeclaringType() does not work for anonymous binary type String tqn = type.getTypeQualifiedName(); int lastDollar = tqn.lastIndexOf('$'); if (lastDollar != 1) { String declaringTypeCF = tqn.substring(0, lastDollar) + ".class"; //$NON-NLS-1$ declaringType = type.getPackageFragment().getClassFile(declaringTypeCF).getType(); try { ISourceRange typeSourceRange = type.getSourceRange(); if (declaringType.exists() && SourceRange.isAvailable(typeSourceRange)) { IJavaElement realParent = declaringType.getTypeRoot() .getElementAt(typeSourceRange.getOffset() - 1); if (realParent != null) { parent = realParent; } } } catch (JavaModelException e) { // ignore } } } if (declaringType != null) { appendTypeLabel(declaringType, T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS)); int parentType = parent.getElementType(); if (parentType == IJavaElement.METHOD || parentType == IJavaElement.FIELD || parentType == IJavaElement.INITIALIZER) { // anonymous or local fBuffer.append('.'); appendElementLabel(parent, 0); } } else { appendPackageFragmentLabel(type.getPackageFragment(), flags & QUALIFIER_FLAGS); } } }
From source file:com.redhat.ceylon.eclipse.core.model.JDTModelLoader.java
License:Open Source License
public static void doOnResolvedGeneratedType(IType typeModel, ActionOnResolvedGeneratedType action) { if (typeModel == null || !typeModel.exists()) { throw new ModelResolutionException("Resolving action requested on a missing declaration"); }/*from www.ja va 2 s. co m*/ JDTModelLoader modelLoader = getModelLoader(typeModel); if (modelLoader == null) { throw new ModelResolutionException("The Model Loader is not available to resolve type '" + typeModel.getFullyQualifiedName() + "'"); } char[][] compoundName = CharOperation.splitOn('.', typeModel.getFullyQualifiedName().toCharArray()); LookupEnvironment lookupEnvironment = modelLoader.createLookupEnvironmentForGeneratedCode(); ReferenceBinding binding = null; IBinaryType binaryType = null; try { ITypeRoot typeRoot = typeModel.getTypeRoot(); if (typeRoot instanceof IClassFile) { ClassFile classFile = (ClassFile) typeRoot; IFile classFileRsrc = (IFile) classFile.getCorrespondingResource(); if (classFileRsrc != null && !classFileRsrc.exists()) { //the .class file has been deleted return; } BinaryTypeBinding binaryTypeBinding = null; try { binaryType = classFile.getBinaryTypeInfo(classFileRsrc, true); binaryTypeBinding = lookupEnvironment.cacheBinaryType(binaryType, null); } catch (JavaModelException e) { if (!e.isDoesNotExist()) { throw e; } } if (binaryTypeBinding == null) { ReferenceBinding existingType = lookupEnvironment.getCachedType(compoundName); if (existingType == null || !(existingType instanceof BinaryTypeBinding)) { return; } binaryTypeBinding = (BinaryTypeBinding) existingType; } binding = binaryTypeBinding; } } catch (JavaModelException e) { throw new ModelResolutionException(e); } if (binaryType != null && binding != null) { action.doWithBinding(typeModel, binding, binaryType); } }
From source file:com.redhat.ceylon.eclipse.core.model.JDTModelLoader.java
License:Open Source License
private static ReferenceBinding toBinding(IType type, LookupEnvironment theLookupEnvironment, char[][] compoundName) throws JavaModelException { ITypeRoot typeRoot = type.getTypeRoot(); if (typeRoot instanceof IClassFile) { ClassFile classFile = (ClassFile) typeRoot; IFile classFileRsrc = (IFile) classFile.getCorrespondingResource(); if (classFileRsrc != null && !classFileRsrc.exists()) { //the .class file has been deleted return null; }// w w w . j a v a 2 s . c om BinaryTypeBinding binaryTypeBinding = null; try { IBinaryType binaryType = classFile.getBinaryTypeInfo(classFileRsrc, true); binaryTypeBinding = theLookupEnvironment.cacheBinaryType(binaryType, null); } catch (JavaModelException e) { if (!e.isDoesNotExist()) { throw e; } } if (binaryTypeBinding == null) { ReferenceBinding existingType = theLookupEnvironment.getCachedType(compoundName); if (existingType == null || !(existingType instanceof BinaryTypeBinding)) { return null; } binaryTypeBinding = (BinaryTypeBinding) existingType; } return binaryTypeBinding; } else { ReferenceBinding referenceBinding = theLookupEnvironment.getType(compoundName); if (referenceBinding != null && !(referenceBinding instanceof BinaryTypeBinding)) { if (referenceBinding instanceof ProblemReferenceBinding) { ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) referenceBinding; if (problemReferenceBinding.problemId() == ProblemReasons.InternalNameProvided) { referenceBinding = problemReferenceBinding.closestReferenceMatch(); } else { System.out.println( ProblemReferenceBinding.problemReasonString(problemReferenceBinding.problemId())); return null; } } return referenceBinding; } return null; } }
From source file:com.redhat.ceylon.eclipse.core.model.JDTModelLoader.java
License:Open Source License
private Unit newCompiledUnit(LazyPackage pkg, ClassMirror classMirror) { Unit unit;//from w w w. j av a2 s . co m JDTClass jdtClass = (JDTClass) classMirror; IType type = jdtClass.getType(); if (type == null) { return null; } ITypeRoot typeRoot = type.getTypeRoot(); StringBuilder sb = new StringBuilder(); List<String> parts = pkg.getName(); for (int i = 0; i < parts.size(); i++) { String part = parts.get(i); if (!part.isEmpty()) { sb.append(part); sb.append('/'); } } sb.append(jdtClass.getFileName()); String relativePath = sb.toString(); String fileName = jdtClass.getFileName(); String fullPath = jdtClass.getFullPath(); if (!jdtClass.isBinary()) { unit = new JavaCompilationUnit((org.eclipse.jdt.core.ICompilationUnit) typeRoot, fileName, relativePath, fullPath, pkg); } else { if (jdtClass.isCeylon()) { if (pkg.getModule() instanceof JDTModule) { JDTModule module = (JDTModule) pkg.getModule(); IProject originalProject = module.getOriginalProject(); if (originalProject != null) { unit = new CrossProjectBinaryUnit((IClassFile) typeRoot, fileName, relativePath, fullPath, pkg); } else { unit = new CeylonBinaryUnit((IClassFile) typeRoot, fileName, relativePath, fullPath, pkg); } } else { unit = new CeylonBinaryUnit((IClassFile) typeRoot, fileName, relativePath, fullPath, pkg); } } else { unit = new JavaClassFile((IClassFile) typeRoot, fileName, relativePath, fullPath, pkg); } } return unit; }
From source file:navclus.userinterface.classdiagram.utils.JavaEditorUtil.java
License:Open Source License
public static boolean IsExistInTab(IType type) { if (type == null) return false; return IsExistInTab(type.getTypeRoot()); }
From source file:navclus.userinterface.classdiagram.utils.JavaEditorUtil.java
License:Open Source License
public static IJavaElement getJavaElement(IType type) { return type.getTypeRoot(); }
From source file:navclus.userinterface.classdiagram.utils.JavaEditorUtil.java
License:Open Source License
public static boolean isTop(IType type) { IJavaElement topElement = EditorUtility.getActiveEditorJavaInput(); if (topElement == null) return false; if (type.getTypeRoot().getHandleIdentifier().equals(topElement.getHandleIdentifier())) return true; else//from w w w . j av a2s . c o m return false; }