use of org.eclipse.jdt.core.ICodeAssist in project che by eclipse.
the class JavaNavigation method findDeclaration.
public OpenDeclarationDescriptor findDeclaration(IJavaProject project, String fqn, int offset) throws JavaModelException {
IJavaElement originalElement = null;
IType type = project.findType(fqn);
ICodeAssist codeAssist;
if (type.isBinary()) {
codeAssist = type.getClassFile();
} else {
codeAssist = type.getCompilationUnit();
}
IJavaElement[] elements = null;
if (codeAssist != null) {
elements = codeAssist.codeSelect(offset, 0);
}
if (elements != null && elements.length > 0) {
originalElement = elements[0];
}
IJavaElement element = originalElement;
while (element != null) {
if (element instanceof ICompilationUnit) {
ICompilationUnit unit = ((ICompilationUnit) element).getPrimary();
return compilationUnitNavigation(unit, originalElement);
}
if (element instanceof IClassFile) {
return classFileNavigation((IClassFile) element, originalElement);
}
element = element.getParent();
}
return null;
}
use of org.eclipse.jdt.core.ICodeAssist in project che by eclipse.
the class JavaTypeHierarchy method getJavaElement.
private IJavaElement getJavaElement(IJavaProject project, String fqn, int offset) throws JavaModelException {
IJavaElement originalElement = null;
IType type = project.findType(fqn);
ICodeAssist codeAssist;
if (type.isBinary()) {
codeAssist = type.getClassFile();
} else {
codeAssist = type.getCompilationUnit();
}
IJavaElement[] elements = null;
if (codeAssist != null) {
elements = codeAssist.codeSelect(offset, 0);
}
if (elements != null && elements.length > 0) {
originalElement = elements[0];
}
return originalElement;
}
use of org.eclipse.jdt.core.ICodeAssist in project che by eclipse.
the class JavadocFinder method findJavadoc.
public String findJavadoc(IJavaProject project, String fqn, int offset) throws JavaModelException {
IMember member = null;
IType type = project.findType(fqn);
ICodeAssist codeAssist;
if (type.isBinary()) {
codeAssist = type.getClassFile();
} else {
codeAssist = type.getCompilationUnit();
}
IJavaElement[] elements = null;
if (codeAssist != null) {
elements = codeAssist.codeSelect(/*region.getOffset(), region.getLength()*/
offset, 0);
}
IJavaElement element = null;
if (elements != null && elements.length > 0) {
element = elements[0];
}
if (element != null && element instanceof IMember) {
member = ((IMember) element);
}
if (member == null) {
return null;
}
return getJavadoc(member);
}
Aggregations