private IMember getEnclosingInitialSelectionMember() throws JavaModelException { return (IMember) fSelectionCompilationUnit.getElementAt(fSelectionStart); }
private IMember getEnclosingInitialSelectionMember() throws JavaModelException { return (IMember) fSelectionCompilationUnit.getElementAt(fSelectionStart); }
private IMember getEnclosingInitialSelectionMember() throws JavaModelException { return (IMember) fSelectionCompilationUnit.getElementAt(fSelectionStart); }
public static void startIntroduceParameterObject(ICompilationUnit unit, int offset, int length, Shell shell) throws CoreException { IJavaElement javaElement= unit.getElementAt(offset); if (javaElement instanceof IMethod) { IMethod method= (IMethod) javaElement; startIntroduceParameterObject(method, shell); } }
public static void startIntroduceParameterObject(ICompilationUnit unit, int offset, Shell shell) throws CoreException { IJavaElement javaElement= unit.getElementAt(offset); if (javaElement instanceof IMethod) { IMethod method= (IMethod) javaElement; startIntroduceParameterObject(method, shell); } }
public static void startIntroduceParameterObject(ICompilationUnit unit, int offset, Shell shell) throws CoreException { IJavaElement javaElement= unit.getElementAt(offset); if (javaElement instanceof IMethod) { IMethod method= (IMethod) javaElement; startIntroduceParameterObject(method, shell); } }
private String getEnclosingTypeName(int codeAssistOffset, ICompilationUnit compilationUnit) throws JavaModelException { IJavaElement element= compilationUnit.getElementAt(codeAssistOffset); if (element == null) return null; element= element.getAncestor(IJavaElement.TYPE); if (element == null) return null; return element.getElementName(); }
public IJavaElement getEnclosingElement() { try { if (!this.hasComputedEnclosingJavaElements) { computeEnclosingJavaElements(); } if (this.compilationUnit == null) return null; IJavaElement enclosingElement = this.compilationUnit.getElementAt(this.completionContext.offset); return enclosingElement == null ? this.compilationUnit : enclosingElement; } catch (JavaModelException e) { Util.log(e, "Cannot compute enclosing element"); //$NON-NLS-1$ return null; } }
public IJavaElement getEnclosingElement() { try { if (!this.hasComputedEnclosingJavaElements) { computeEnclosingJavaElements(); } if (this.compilationUnit == null) return null; IJavaElement enclosingElement = this.compilationUnit.getElementAt(this.completionContext.offset); return enclosingElement == null ? this.compilationUnit : enclosingElement; } catch (JavaModelException e) { Util.log(e, "Cannot compute enclosing element"); //$NON-NLS-1$ return null; } }
public IJavaElement getEnclosingElement() { try { if (!this.hasComputedEnclosingJavaElements) { computeEnclosingJavaElements(); } if (this.compilationUnit == null) return null; IJavaElement enclosingElement = this.compilationUnit.getElementAt(this.completionContext.offset); return enclosingElement == null ? this.compilationUnit : enclosingElement; } catch (JavaModelException e) { Util.log(e, "Cannot compute enclosing element"); //$NON-NLS-1$ return null; } }
public IJavaElement getEnclosingElement() { try { if (!this.hasComputedEnclosingJavaElements) { computeEnclosingJavaElements(); } if (this.compilationUnit == null) return null; IJavaElement enclosingElement = this.compilationUnit.getElementAt(this.completionContext.offset); return enclosingElement == null ? this.compilationUnit : enclosingElement; } catch (JavaModelException e) { Util.log(e, "Cannot compute enclosing element"); //$NON-NLS-1$ return null; } }
private static IType findContextType(ICompilationUnit icu, int offset) throws JavaModelException { IJavaElement element = icu.getElementAt(offset); if (element == null) { return null; } if (element.getElementType() == IJavaElement.TYPE) { return (IType) element; } return (IType) element.getAncestor(IJavaElement.TYPE); } }
public IJavaElement getEnclosingElement() { try { if (!this.hasComputedEnclosingJavaElements) { computeEnclosingJavaElements(); } if (this.compilationUnit == null) return null; IJavaElement enclosingElement = this.compilationUnit.getElementAt(this.completionContext.offset); return enclosingElement == null ? this.compilationUnit : enclosingElement; } catch (JavaModelException e) { Util.log(e, "Cannot compute enclosing element"); //$NON-NLS-1$ return null; } }
public IJavaElement getEnclosingElement() { try { if (!this.hasComputedEnclosingJavaElements) { computeEnclosingJavaElements(); } if (this.compilationUnit == null) return null; IJavaElement enclosingElement = this.compilationUnit.getElementAt(this.completionContext.offset); return enclosingElement == null ? this.compilationUnit : enclosingElement; } catch (JavaModelException e) { Util.log(e, "Cannot compute enclosing element"); //$NON-NLS-1$ return null; } }
private String createJavaDocTags(IDocument document, int offset, String indentation, String lineDelimiter, ICompilationUnit unit) throws CoreException, BadLocationException { IJavaElement element = unit.getElementAt(offset); if (element == null) { return null; } switch (element.getElementType()) { case IJavaElement.TYPE: return createTypeTags(document, offset, indentation, lineDelimiter, (IType) element); case IJavaElement.METHOD: return createMethodTags(document, offset, indentation, lineDelimiter, (IMethod) element); default: return null; } }
private IMethod getSingleSelectedMethod(ITextSelection selection) throws JavaModelException { // - when caret/selection on method name (call or declaration) -> that method // - otherwise: caret position's enclosing method declaration // - when caret inside argument list of method declaration -> enclosing method declaration // - when caret inside argument list of method call -> enclosing method declaration (and NOT method call) IJavaElement[] elements= SelectionConverter.codeResolve(fEditor); if (elements.length > 1) return null; if (elements.length == 1 && elements[0] instanceof IMethod) { return (IMethod) elements[0]; } else { IJavaElement elementAt= SelectionConverter.getInputAsCompilationUnit(fEditor).getElementAt(selection.getOffset()); if (!(elementAt instanceof IMethod)) return null; return (IMethod) elementAt; } } }
private IMethod getSingleSelectedMethod(ITextSelection selection) throws JavaModelException{ //- when caret/selection on method name (call or declaration) -> that method //- otherwise: caret position's enclosing method declaration // - when caret inside argument list of method declaration -> enclosing method declaration // - when caret inside argument list of method call -> enclosing method declaration (and NOT method call) IJavaElement[] elements= SelectionConverter.codeResolve(fEditor); if (elements.length > 1) return null; if (elements.length == 1 && elements[0] instanceof IMethod) return (IMethod)elements[0]; IJavaElement elementAt= SelectionConverter.getInputAsCompilationUnit(fEditor).getElementAt(selection.getOffset()); if (elementAt instanceof IMethod) return (IMethod)elementAt; return null; } }
private IMethod getSingleSelectedMethod(ITextSelection selection) throws JavaModelException{ //- when caret/selection on method name (call or declaration) -> that method //- otherwise: caret position's enclosing method declaration // - when caret inside argument list of method declaration -> enclosing method declaration // - when caret inside argument list of method call -> enclosing method declaration (and NOT method call) IJavaElement[] elements= SelectionConverter.codeResolve(fEditor); if (elements.length > 1) return null; if (elements.length == 1 && elements[0] instanceof IMethod) return (IMethod)elements[0]; IJavaElement elementAt= SelectionConverter.getInputAsCompilationUnit(fEditor).getElementAt(selection.getOffset()); if (elementAt instanceof IMethod) return (IMethod)elementAt; return null; } }
private IMethod getSingleSelectedMethod(ITextSelection selection) throws JavaModelException{ //- when caret/selection on method name (call or declaration) -> that method //- otherwise: caret position's enclosing method declaration // - when caret inside argument list of method declaration -> enclosing method declaration // - when caret inside argument list of method call -> enclosing method declaration (and NOT method call) IJavaElement[] elements= SelectionConverter.codeResolve(fEditor); if (elements.length > 1) return null; if (elements.length == 1 && elements[0] instanceof IMethod) return (IMethod)elements[0]; IJavaElement elementAt= SelectionConverter.getInputAsCompilationUnit(fEditor).getElementAt(selection.getOffset()); if (elementAt instanceof IMethod) return (IMethod)elementAt; return null; } }
/** * Returns the element at the given position in the given type */ protected static IJavaElement getElementAt(IType type, int pos) throws JavaModelException { if (type.isBinary()) { return type.getClassFile().getElementAt(pos); } return type.getCompilationUnit().getElementAt(pos); }