use of org.eclipse.jdt.core.JavaModelException in project che by eclipse.
the class JavaElementImageProvider method getPackageFragmentIcon.
private ImageDescriptor getPackageFragmentIcon(IJavaElement element) throws JavaModelException {
IPackageFragment fragment = (IPackageFragment) element;
boolean containsJavaElements = false;
try {
containsJavaElements = fragment.hasChildren();
} catch (JavaModelException e) {
// assuming no children;
}
if (!containsJavaElements && (fragment.getNonJavaResources().length > 0))
return JavaPluginImages.DESC_OBJS_EMPTY_PACKAGE_RESOURCES;
else if (!containsJavaElements)
return JavaPluginImages.DESC_OBJS_EMPTY_PACKAGE;
return JavaPluginImages.DESC_OBJS_PACKAGE;
}
use of org.eclipse.jdt.core.JavaModelException in project che by eclipse.
the class JavaElementLabelComposer method appendInternalArchiveLabel.
private void appendInternalArchiveLabel(IPackageFragmentRoot root, long flags) {
IResource resource = root.getResource();
boolean rootQualified = getFlag(flags, JavaElementLabels.ROOT_QUALIFIED);
if (rootQualified) {
fBuffer.append(root.getPath().makeRelative().toString());
} else {
fBuffer.append(root.getElementName());
int offset = fBuffer.length();
boolean referencedPostQualified = getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED);
if (referencedPostQualified && isReferenced(root)) {
fBuffer.append(JavaElementLabels.CONCAT_STRING);
fBuffer.append(resource.getParent().getFullPath().makeRelative().toString());
} else if (getFlag(flags, JavaElementLabels.ROOT_POST_QUALIFIED)) {
fBuffer.append(JavaElementLabels.CONCAT_STRING);
fBuffer.append(root.getParent().getPath().makeRelative().toString());
}
if (referencedPostQualified) {
try {
IClasspathEntry referencingEntry = JavaModelUtil.getClasspathEntry(root).getReferencingEntry();
if (referencingEntry != null) {
fBuffer.append(Messages.format(JavaUIMessages.JavaElementLabels_onClassPathOf, new Object[] { Name.CLASS_PATH.toString(), referencingEntry.getPath().lastSegment() }));
}
} catch (JavaModelException e) {
// ignore
}
}
if (getFlag(flags, JavaElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
}
}
}
use of org.eclipse.jdt.core.JavaModelException in project che by eclipse.
the class JavaElementLabelComposer method appendTypeParameterLabel.
/**
* Appends the styled label for a type parameter.
*
* @param typeParameter the element to render
* @param flags the rendering flags. Flags with names starting with 'T_' are considered.
*/
public void appendTypeParameterLabel(ITypeParameter typeParameter, long flags) {
try {
appendTypeParameterWithBounds(typeParameter, flags);
// post qualification
if (getFlag(flags, JavaElementLabels.TP_POST_QUALIFIED)) {
fBuffer.append(JavaElementLabels.CONCAT_STRING);
IMember declaringMember = typeParameter.getDeclaringMember();
appendElementLabel(declaringMember, JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_FULLY_QUALIFIED | JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
}
} catch (JavaModelException e) {
// NotExistsException will not reach this point
JavaPlugin.log(e);
}
}
use of org.eclipse.jdt.core.JavaModelException in project che by eclipse.
the class CompletionProposalCollector method createAnonymousTypeProposal.
private IJavaCompletionProposal createAnonymousTypeProposal(CompletionProposal proposal, JavaContentAssistInvocationContext invocationContext) {
if (fCompilationUnit == null || fJavaProject == null)
return null;
char[] declarationKey = proposal.getDeclarationKey();
if (declarationKey == null)
return null;
try {
IJavaElement element = fJavaProject.findElement(new String(declarationKey), null);
if (!(element instanceof IType))
return null;
IType type = (IType) element;
String completion = String.valueOf(proposal.getCompletion());
int start = proposal.getReplaceStart();
int length = getLength(proposal);
int relevance = computeRelevance(proposal);
StyledString label = fLabelProvider.createAnonymousTypeLabel(proposal);
JavaCompletionProposal javaProposal = new AnonymousTypeCompletionProposal(fJavaProject, fCompilationUnit, invocationContext, start, length, completion, label, String.valueOf(proposal.getDeclarationSignature()), type, relevance);
javaProposal.setProposalInfo(new AnonymousTypeProposalInfo(fJavaProject, proposal));
return javaProposal;
} catch (JavaModelException e) {
return null;
}
}
use of org.eclipse.jdt.core.JavaModelException in project che by eclipse.
the class JavaElementLabelComposer method appendExternalArchiveLabel.
private void appendExternalArchiveLabel(IPackageFragmentRoot root, long flags) {
IPath path;
IClasspathEntry classpathEntry = null;
try {
classpathEntry = JavaModelUtil.getClasspathEntry(root);
IPath rawPath = classpathEntry.getPath();
if (classpathEntry.getEntryKind() != IClasspathEntry.CPE_CONTAINER && !rawPath.isAbsolute())
path = rawPath;
else
path = root.getPath();
} catch (JavaModelException e) {
path = root.getPath();
}
if (getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED)) {
int segements = path.segmentCount();
if (segements > 0) {
fBuffer.append(path.segment(segements - 1));
int offset = fBuffer.length();
if (segements > 1 || path.getDevice() != null) {
fBuffer.append(JavaElementLabels.CONCAT_STRING);
fBuffer.append(path.removeLastSegments(1).toOSString());
}
if (classpathEntry != null) {
IClasspathEntry referencingEntry = classpathEntry.getReferencingEntry();
if (referencingEntry != null) {
fBuffer.append(Messages.format(JavaUIMessages.JavaElementLabels_onClassPathOf, new Object[] { Name.CLASS_PATH.toString(), referencingEntry.getPath().lastSegment() }));
}
}
if (getFlag(flags, JavaElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
}
} else {
fBuffer.append(path.toOSString());
}
} else {
fBuffer.append(path.toOSString());
}
}
Aggregations