public static IJavaElement getElementAtOffset(ITypeRoot input, ITextSelection selection) throws JavaModelException { if (input instanceof ICompilationUnit) { JavaModelUtil.reconcile((ICompilationUnit) input); } IJavaElement ref= input.getElementAt(selection.getOffset()); if (ref == null) return input; return ref; }
private IJavaElement getEnclosingMethod(ITypeRoot input, ITextSelection selection) { try { IJavaElement enclosingElement= input.getElementAt(selection.getOffset()); if (enclosingElement instanceof IMethod || enclosingElement instanceof IInitializer || enclosingElement instanceof IField) { // opening on the enclosing type would be too confusing (since the type resolves to the constructors) return enclosingElement; } } catch (JavaModelException e) { JavaPlugin.log(e); } return null; }
private IJavaElement getEnclosingMethod(ITypeRoot input, ITextSelection selection) { try { IJavaElement enclosingElement= input.getElementAt(selection.getOffset()); if (enclosingElement instanceof IMethod || enclosingElement instanceof IInitializer || enclosingElement instanceof IField) { // opening on the enclosing type would be too confusing (since the type resolves to the constructors) return enclosingElement; } } catch (JavaModelException e) { JavaPlugin.log(e); } return null; }
public static IJavaElement getElementAtOffset(ITypeRoot input, ITextSelection selection) throws JavaModelException { if (input instanceof ICompilationUnit) { JavaModelUtil.reconcile((ICompilationUnit) input); } IJavaElement ref= input.getElementAt(selection.getOffset()); if (ref == null) return input; return ref; }
public void consumeLocalType(char[] uniqueKey) { if (this.element == null) return; if (this.element instanceof BinaryType) { int lastSlash = CharOperation.lastIndexOf('/', uniqueKey); int end = CharOperation.indexOf(';', uniqueKey, lastSlash+1); char[] localName = CharOperation.subarray(uniqueKey, lastSlash+1, end); IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_class); } else { int firstDollar = CharOperation.indexOf('$', uniqueKey); int end = CharOperation.indexOf('$', uniqueKey, firstDollar+1); if (end == -1) end = CharOperation.indexOf(';', uniqueKey, firstDollar+1); char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar+1, end); int position = Integer.parseInt(new String(sourceStart)); try { this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position); } catch (JavaModelException e) { this.exception = e; } } }
@Override public void consumeLocalType(char[] uniqueKey) { if (this.element == null) return; if (this.element instanceof BinaryType) { int lastSlash = CharOperation.lastIndexOf('/', uniqueKey); int end = CharOperation.indexOf(';', uniqueKey, lastSlash+1); char[] localName = CharOperation.subarray(uniqueKey, lastSlash+1, end); IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_class); } else { int firstDollar = CharOperation.indexOf('$', uniqueKey); int end = CharOperation.indexOf('$', uniqueKey, firstDollar+1); if (end == -1) end = CharOperation.indexOf(';', uniqueKey, firstDollar+1); char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar+1, end); int position = Integer.parseInt(new String(sourceStart)); try { this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position); } catch (JavaModelException e) { this.exception = e; } } }
public void consumeLocalType(char[] uniqueKey) { if (this.element == null) return; if (this.element instanceof BinaryType) { int lastSlash = CharOperation.lastIndexOf('/', uniqueKey); int end = CharOperation.indexOf(';', uniqueKey, lastSlash+1); char[] localName = CharOperation.subarray(uniqueKey, lastSlash+1, end); IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_class); } else { int firstDollar = CharOperation.indexOf('$', uniqueKey); int end = CharOperation.indexOf('$', uniqueKey, firstDollar+1); if (end == -1) end = CharOperation.indexOf(';', uniqueKey, firstDollar+1); char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar+1, end); int position = Integer.parseInt(new String(sourceStart)); try { this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position); } catch (JavaModelException e) { this.exception = e; } } }
public void consumeLocalType(char[] uniqueKey) { if (this.element == null) return; if (this.element instanceof BinaryType) { int lastSlash = CharOperation.lastIndexOf('/', uniqueKey); int end = CharOperation.indexOf(';', uniqueKey, lastSlash+1); char[] localName = CharOperation.subarray(uniqueKey, lastSlash+1, end); IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_class); } else { int firstDollar = CharOperation.indexOf('$', uniqueKey); int end = CharOperation.indexOf('$', uniqueKey, firstDollar+1); if (end == -1) end = CharOperation.indexOf(';', uniqueKey, firstDollar+1); char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar+1, end); int position = Integer.parseInt(new String(sourceStart)); try { this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position); } catch (JavaModelException e) { this.exception = e; } } }
public void consumeLocalType(char[] uniqueKey) { if (this.element == null) return; if (this.element instanceof BinaryType) { int lastSlash = CharOperation.lastIndexOf('/', uniqueKey); int end = CharOperation.indexOf(';', uniqueKey, lastSlash+1); char[] localName = CharOperation.subarray(uniqueKey, lastSlash+1, end); IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_class); } else { int firstDollar = CharOperation.indexOf('$', uniqueKey); int end = CharOperation.indexOf('$', uniqueKey, firstDollar+1); if (end == -1) end = CharOperation.indexOf(';', uniqueKey, firstDollar+1); char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar+1, end); int position = Integer.parseInt(new String(sourceStart)); try { this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position); } catch (JavaModelException e) { this.exception = e; } } }
public void consumeLocalType(char[] uniqueKey) { if (this.element == null) return; if (this.element instanceof BinaryType) { int lastSlash = CharOperation.lastIndexOf('/', uniqueKey); int end = CharOperation.indexOf(';', uniqueKey, lastSlash+1); char[] localName = CharOperation.subarray(uniqueKey, lastSlash+1, end); IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_class); } else { int firstDollar = CharOperation.indexOf('$', uniqueKey); int end = CharOperation.indexOf('$', uniqueKey, firstDollar+1); if (end == -1) end = CharOperation.indexOf(';', uniqueKey, firstDollar+1); char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar+1, end); int position = Integer.parseInt(new String(sourceStart)); try { this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position); } catch (JavaModelException e) { this.exception = e; } } }
public void consumeLocalType(char[] uniqueKey) { if (this.element == null) return; if (this.element instanceof BinaryType) { int lastSlash = CharOperation.lastIndexOf('/', uniqueKey); int end = CharOperation.indexOf(';', uniqueKey, lastSlash+1); char[] localName = CharOperation.subarray(uniqueKey, lastSlash+1, end); IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_class); } else { int firstDollar = CharOperation.indexOf('$', uniqueKey); int end = CharOperation.indexOf('$', uniqueKey, firstDollar+1); if (end == -1) end = CharOperation.indexOf(';', uniqueKey, firstDollar+1); char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar+1, end); int position = Integer.parseInt(new String(sourceStart)); try { this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position); } catch (JavaModelException e) { this.exception = e; } } }
ISourceRange typeSourceRange= type.getSourceRange(); if (declaringType.exists() && SourceRange.isAvailable(typeSourceRange)) { IJavaElement realParent= declaringType.getTypeRoot().getElementAt(typeSourceRange.getOffset() - 1); if (realParent != null) { parent= realParent;
ISourceRange typeSourceRange= type.getSourceRange(); if (declaringType.exists() && SourceRange.isAvailable(typeSourceRange)) { IJavaElement realParent= declaringType.getTypeRoot().getElementAt(typeSourceRange.getOffset() - 1); if (realParent != null) { parent= realParent;
ISourceRange typeSourceRange= type.getSourceRange(); if (declaringType.exists() && SourceRange.isAvailable(typeSourceRange)) { IJavaElement realParent= declaringType.getTypeRoot().getElementAt(typeSourceRange.getOffset() - 1); if (realParent != null) { parent= realParent;