private boolean isDeprecated(IJavaElement element) throws JavaModelException { if (element instanceof ITypeRoot) { return Flags.isDeprecated(((ITypeRoot) element).findPrimaryType().getFlags()); } return false; }
@JavaSelectionSubscriber public void onTypeRootSelection(final ITypeRoot root, final JavaSelectionEvent event, final Composite parent) throws ExecutionException { final IType type = root.findPrimaryType(); if (type != null) { onTypeSelection(type, event, parent); } }
@JavaSelectionSubscriber public void onTypeRootSelection(final ITypeRoot root, final JavaSelectionEvent event, final Composite parent) throws ExecutionException { final IType type = root.findPrimaryType(); if (type != null) { onTypeSelection(type, event, parent); } }
@JavaSelectionSubscriber public void onCompilationUnitSelection(final ITypeRoot root, final JavaSelectionEvent selection, final Composite parent) throws JavaModelException { final IType type = root.findPrimaryType(); if (type != null) { render(type, parent); } }
public IType type() { return this.compilationUnit().getTypeRoot().findPrimaryType(); }
protected String getTraceSimpleFileName(final ITypeRoot derivedResource) { IType type = derivedResource.findPrimaryType(); if (type == null) return null; String sourceName = ((BinaryType) type).getSourceFileName(null); if (sourceName == null) return null; // the primary source in the .class file is .java (JSR-45 aka SMAP scenario) if (sourceName.endsWith(".java")) { return traceFileNameProvider.getTraceFromJava(sourceName); } // xtend-as-primary-source-scenario. if (sourceName.endsWith(".xtend")) { String name = type.getElementName(); int index = name.indexOf("$"); if (index > 0) name = name.substring(0, index); return traceFileNameProvider.getTraceFromJava(name + ".java"); } return null; }
protected void findReferences(ITypeRoot[] roots, Set<String> pkgs, IProgressMonitor monitor, boolean binary) throws JavaModelException { SubMonitor subMonitor = SubMonitor.convert(monitor, roots.length); for (ITypeRoot root : roots) { findReferences(root.findPrimaryType(), pkgs, binary, subMonitor.split(1)); } }
public Object[] getElements(Object parent) { if (fTopLevelTypeOnly) { if (parent instanceof ITypeRoot) { try { IType type= ((ITypeRoot) parent).findPrimaryType(); return type != null ? type.getChildren() : NO_CLASS; } catch (JavaModelException e) { JavaPlugin.log(e); } } } return getChildren(parent); }
@Override public boolean select(final Viewer viewer, final Object parentElement, final Object element) { if (parentElement instanceof IType) { if (JAVA_LANG_OBJECT_CLASS_NAME.equals(((IType) parentElement).getFullyQualifiedName())) { return true; // java.lang.Object itself is shown; don't filter it out } } if (parentElement instanceof ITypeRoot) { IType primaryType= ((ITypeRoot) parentElement).findPrimaryType(); if (primaryType != null && JAVA_LANG_OBJECT_CLASS_NAME.equals(primaryType.getFullyQualifiedName())) { return true; // top-level type is java.lang.Object itself; don't filter it out } } if (element instanceof IMember) { IType declaringType= ((IMember) element).getDeclaringType(); if (declaringType != null) { String fullyQualifiedName= declaringType.getFullyQualifiedName(); if (JAVA_LANG_OBJECT_CLASS_NAME.equals(fullyQualifiedName)) { return false; } } } return true; }
@Override public Object[] getElements(Object parent) { if (fTopLevelTypeOnly) { if (parent instanceof ITypeRoot) { try { IType type= ((ITypeRoot) parent).findPrimaryType(); return type != null ? type.getChildren() : NO_CLASS; } catch (JavaModelException e) { JavaPlugin.log(e); } } } return getChildren(parent); }
@Override public Object[] getElements(Object parent) { if (fTopLevelTypeOnly) { if (parent instanceof ITypeRoot) { try { IType type= ((ITypeRoot) parent).findPrimaryType(); return type != null ? type.getChildren() : NO_CLASS; } catch (JavaModelException e) { JavaPlugin.log(e); } } } return getChildren(parent); }
private IJavaElement[] getInputForCategories() { if (fInput == null) return new IJavaElement[0]; if (fOutlineContentProvider.isShowingInheritedMembers()) { IJavaElement p= fInput; if (p instanceof ITypeRoot) { p= ((ITypeRoot)p).findPrimaryType(); } while (p != null && !(p instanceof IType)) { p= p.getParent(); } if (!(p instanceof IType)) return new IJavaElement[] {fInput}; ITypeHierarchy hierarchy= getSuperTypeHierarchy((IType)p); if (hierarchy == null) return new IJavaElement[] {fInput}; IType[] supertypes= hierarchy.getAllSupertypes((IType)p); IJavaElement[] result= new IJavaElement[supertypes.length + 1]; result[0]= fInput; System.arraycopy(supertypes, 0, result, 1, supertypes.length); return result; } else { return new IJavaElement[] {fInput}; } }
private char[][][] getQualifiedNames(ObjectVector types) { final int size = types.size; char[][][] focusQualifiedNames = null; IJavaElement javaElement = this.pattern.focus; while (javaElement != null && !(javaElement instanceof ITypeRoot)) { javaElement = javaElement.getParent(); } if (javaElement != null) { IType primaryType = ((ITypeRoot) javaElement).findPrimaryType(); if (primaryType != null) { focusQualifiedNames = new char[size+1][][]; focusQualifiedNames[0] = CharOperation.splitOn('.', primaryType.getFullyQualifiedName().toCharArray()); } } for (int i = 0; i < size; i++) { focusQualifiedNames[i+1] = CharOperation.splitOn('.', ((IType)(types.elementAt(i))).getFullyQualifiedName().toCharArray()); } return focusQualifiedNames == null ? null : ReferenceCollection.internQualifiedNames(focusQualifiedNames, true); } }
private char[][][] getQualifiedNames(ObjectVector types) { final int size = types.size; char[][][] focusQualifiedNames = null; IJavaElement javaElement = this.pattern.focus; int index = 0; while (javaElement != null && !(javaElement instanceof ITypeRoot)) { javaElement = javaElement.getParent(); } if (javaElement != null) { IType primaryType = ((ITypeRoot) javaElement).findPrimaryType(); if (primaryType != null) { focusQualifiedNames = new char[size+1][][]; focusQualifiedNames[index++] = CharOperation.splitOn('.', primaryType.getFullyQualifiedName().toCharArray()); } } if (focusQualifiedNames == null) { focusQualifiedNames = new char[size][][]; } for (int i = 0; i < size; i++) { focusQualifiedNames[index++] = CharOperation.splitOn('.', ((IType)(types.elementAt(i))).getFullyQualifiedName().toCharArray()); } return focusQualifiedNames.length == 0 ? null : ReferenceCollection.internQualifiedNames(focusQualifiedNames, true); } }
private char[][][] getQualifiedNames(ObjectVector types) { final int size = types.size; char[][][] focusQualifiedNames = null; IJavaElement javaElement = this.pattern.focus; int index = 0; while (javaElement != null && !(javaElement instanceof ITypeRoot)) { javaElement = javaElement.getParent(); } if (javaElement != null) { IType primaryType = ((ITypeRoot) javaElement).findPrimaryType(); if (primaryType != null) { focusQualifiedNames = new char[size+1][][]; focusQualifiedNames[index++] = CharOperation.splitOn('.', primaryType.getFullyQualifiedName().toCharArray()); } } if (focusQualifiedNames == null) { focusQualifiedNames = new char[size][][]; } for (int i = 0; i < size; i++) { focusQualifiedNames[index++] = CharOperation.splitOn('.', ((IType)(types.elementAt(i))).getFullyQualifiedName().toCharArray()); } return focusQualifiedNames.length == 0 ? null : ReferenceCollection.internQualifiedNames(focusQualifiedNames, true); } }
private char[][][] getQualifiedNames(ObjectVector types) { final int size = types.size; char[][][] focusQualifiedNames = null; IJavaElement javaElement = this.pattern.focus; int index = 0; while (javaElement != null && !(javaElement instanceof ITypeRoot)) { javaElement = javaElement.getParent(); } if (javaElement != null) { IType primaryType = ((ITypeRoot) javaElement).findPrimaryType(); if (primaryType != null) { focusQualifiedNames = new char[size+1][][]; focusQualifiedNames[index++] = CharOperation.splitOn('.', primaryType.getFullyQualifiedName().toCharArray()); } } if (focusQualifiedNames == null) { focusQualifiedNames = new char[size][][]; } for (int i = 0; i < size; i++) { focusQualifiedNames[index++] = CharOperation.splitOn('.', ((IType)(types.elementAt(i))).getFullyQualifiedName().toCharArray()); } return focusQualifiedNames.length == 0 ? null : ReferenceCollection.internQualifiedNames(focusQualifiedNames, true); } }
private void findStaticHooks(final TreeMultimap<IType, IMethod> index, final ITypeRoot root) throws JavaModelException { final IType type = root.findPrimaryType(); if (type == null) { return; } if (!type.isClass()) { return; } for (final IMethod m : type.getMethods()) { if (JdtFlags.isStatic(m) && JdtFlags.isPublic(m) && !JdtUtils.isInitializer(m)) { index.put(type, m); } } } }
public List<? extends Location> findImplementations(TextDocumentPositionParams param, IProgressMonitor monitor) { List<Location> locations = null; IJavaElement elementToSearch = null; try { ITypeRoot typeRoot = JDTUtils.resolveTypeRoot(param.getTextDocument().getUri()); if (typeRoot != null) { elementToSearch = JDTUtils.findElementAtSelection(typeRoot, param.getPosition().getLine(), param.getPosition().getCharacter(), this.preferenceManager, monitor); } if (elementToSearch == null) { return Collections.emptyList(); } int offset = getOffset(param, typeRoot); IRegion region = new Region(offset, 0); IType primaryType = typeRoot.findPrimaryType(); //java.lang.Object is a special case. We need to minimize heavy cost of I/O, // by avoiding opening all files from the Object hierarchy boolean useDefaultLocation = primaryType == null ? false : "java.lang.Object".equals(primaryType.getFullyQualifiedName()); ImplementationToLocationMapper mapper = new ImplementationToLocationMapper(preferenceManager.isClientSupportsClassFileContent(), useDefaultLocation); ImplementationCollector<Location> collector = new ImplementationCollector<>(region, elementToSearch, mapper); locations = collector.findImplementations(monitor); } catch (CoreException e) { JavaLanguageServerPlugin.logException("Find implementations failure ", e); } return locations; }
/** * Link selection to active editor. * @param editor The activated editor */ protected void editorActivated(IEditorPart editor) { if (!isLinkingEnabled()) { return; } if (fInputElements == null) { // no type hierarchy shown return; } IJavaElement elem= editor.getEditorInput().getAdapter(IJavaElement.class); if (elem instanceof ITypeRoot) { IType type= ((ITypeRoot) elem).findPrimaryType(); if (type != null) { internalSelectType(type, true); if (getCurrentViewer().getSelection().isEmpty()) { updateMethodViewer(null); } else { updateMethodViewer(type); } } } }
/** * Link selection to active editor. * @param editor The activated editor */ protected void editorActivated(IEditorPart editor) { if (!isLinkingEnabled()) { return; } if (fInputElement == null) { // no type hierarchy shown return; } IJavaElement elem= (IJavaElement)editor.getEditorInput().getAdapter(IJavaElement.class); if (elem instanceof ITypeRoot) { IType type= ((ITypeRoot) elem).findPrimaryType(); if (type != null) { internalSelectType(type, true); if (getCurrentViewer().getSelection().isEmpty()) { updateMethodViewer(null); } else { updateMethodViewer(type); } } } }