List of usage examples for org.eclipse.jdt.core ILocalVariable getHandleIdentifier
String getHandleIdentifier();
From source file:edu.brown.cs.bubbles.bedrock.BedrockJava.java
License:Open Source License
/********************************************************************************/ void getFullyQualifiedName(String proj, String file, int start, int end, IvyXmlWriter xw) throws BedrockException { String name = null;/*from ww w .ja v a 2s . c om*/ String key = null; String sgn = null; String hdl = null; ICompilationUnit icu = our_plugin.getProjectManager().getCompilationUnit(proj, file); if (icu == null) throw new BedrockException("Compilation unit not found for " + file); icu = getCompilationElement(icu); try { IJavaElement[] elts = icu.codeSelect(start, end - start); for (int i = 0; i < elts.length && name == null; ++i) { switch (elts[i].getElementType()) { case IJavaElement.JAVA_PROJECT: case IJavaElement.JAVA_MODEL: case IJavaElement.PACKAGE_FRAGMENT_ROOT: case IJavaElement.CLASS_FILE: case IJavaElement.PACKAGE_FRAGMENT: case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: case IJavaElement.TYPE_PARAMETER: case IJavaElement.COMPILATION_UNIT: default: break; case IJavaElement.TYPE: IType typ = (IType) elts[i]; name = typ.getFullyQualifiedName(); key = typ.getKey(); break; case IJavaElement.FIELD: IField fld = ((IField) elts[i]); name = fld.getDeclaringType().getFullyQualifiedName() + "." + fld.getElementName(); key = fld.getKey(); sgn = fld.getTypeSignature(); break; case IJavaElement.METHOD: IMethod mthd = ((IMethod) elts[i]); name = mthd.getDeclaringType().getFullyQualifiedName() + "." + mthd.getElementName(); key = mthd.getKey(); sgn = mthd.getSignature(); // TODO: might want to add signture here as well break; case IJavaElement.INITIALIZER: IInitializer init = ((IInitializer) elts[i]); name = init.getDeclaringType().getFullyQualifiedName() + ".<clinit>"; break; case IJavaElement.PACKAGE_DECLARATION: name = ((IPackageDeclaration) elts[i]).getElementName(); break; case IJavaElement.LOCAL_VARIABLE: ILocalVariable lcl = (ILocalVariable) elts[i]; name = lcl.getHandleIdentifier(); sgn = lcl.getTypeSignature(); break; } hdl = elts[i].getHandleIdentifier(); } } catch (CoreException e) { throw new BedrockException("Problem getting name", e); } if (name == null) { return; // throw new BedrockException("No identifier at location"); } xw.begin("FULLYQUALIFIEDNAME"); xw.field("NAME", name); if (key != null) xw.field("KEY", key); if (sgn != null) xw.field("TYPE", sgn); if (hdl != null) xw.field("HANDLE", hdl); xw.end(); }