本文整理汇总了Java中org.eclipse.jdt.core.IJavaElement.CLASS_FILE属性的典型用法代码示例。如果您正苦于以下问题:Java IJavaElement.CLASS_FILE属性的具体用法?Java IJavaElement.CLASS_FILE怎么用?Java IJavaElement.CLASS_FILE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.IJavaElement
的用法示例。
在下文中一共展示了IJavaElement.CLASS_FILE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findElementAtCursor
/**
* Try to identify a nested java element of the given element from a textual
* selection in its source code. This might be possible if the given element
* is a compilation unit or class file.
*
* @param unit
* unit to search
* @param selection
* selection within this unit
* @return nested element or the unit itself
*/
private IJavaElement findElementAtCursor(IJavaElement unit,
ISelection selection) {
int pos = -1;
if (selection instanceof ITextSelection) {
pos = ((ITextSelection) selection).getOffset();
}
if (selection instanceof IMarkSelection) {
pos = ((IMarkSelection) selection).getOffset();
}
if (pos == -1)
return unit;
IJavaElement element = null;
try {
switch (unit.getElementType()) {
case IJavaElement.COMPILATION_UNIT:
element = ((ICompilationUnit) unit).getElementAt(pos);
break;
case IJavaElement.CLASS_FILE:
element = ((IClassFile) unit).getElementAt(pos);
break;
}
} catch (JavaModelException e) {
// we ignore this
}
return element == null ? unit : element;
}
示例2: mapKind
public static SymbolKind mapKind(IJavaElement element) {
switch (element.getElementType()) {
case IJavaElement.ANNOTATION:
return SymbolKind.Property; // TODO: find a better mapping
case IJavaElement.CLASS_FILE:
case IJavaElement.COMPILATION_UNIT:
return SymbolKind.File;
case IJavaElement.FIELD:
return SymbolKind.Field;
case IJavaElement.IMPORT_CONTAINER:
case IJavaElement.IMPORT_DECLARATION:
return SymbolKind.Module;
case IJavaElement.INITIALIZER:
return SymbolKind.Constructor;
case IJavaElement.LOCAL_VARIABLE:
case IJavaElement.TYPE_PARAMETER:
return SymbolKind.Variable;
case IJavaElement.METHOD:
return SymbolKind.Method;
case IJavaElement.PACKAGE_DECLARATION:
return SymbolKind.Package;
case IJavaElement.TYPE:
try {
return ( ((IType)element).isInterface() ? SymbolKind.Interface : SymbolKind.Class);
} catch (JavaModelException e) {
return SymbolKind.Class;
}
}
return SymbolKind.String;
}
示例3: appendElementLabel
/**
* Appends the label for a Java element with the flags as defined by this class.
*
* @param element the element to render
* @param flags the rendering flags.
*/
public void appendElementLabel(IJavaElement element, long flags) {
int type= element.getElementType();
IPackageFragmentRoot root= null;
if (type != IJavaElement.JAVA_MODEL && type != IJavaElement.JAVA_PROJECT && type != IJavaElement.PACKAGE_FRAGMENT_ROOT) {
root= JavaModelUtil.getPackageFragmentRoot(element);
}
if (root != null && getFlag(flags, JavaElementLabels.PREPEND_ROOT_PATH)) {
appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED);
fBuilder.append(JavaElementLabels.CONCAT_STRING);
}
switch (type) {
case IJavaElement.METHOD:
appendMethodLabel((IMethod) element, flags);
break;
case IJavaElement.FIELD:
appendFieldLabel((IField) element, flags);
break;
case IJavaElement.LOCAL_VARIABLE:
appendLocalVariableLabel((ILocalVariable) element, flags);
break;
case IJavaElement.TYPE_PARAMETER:
appendTypeParameterLabel((ITypeParameter) element, flags);
break;
case IJavaElement.INITIALIZER:
appendInitializerLabel((IInitializer) element, flags);
break;
case IJavaElement.TYPE:
appendTypeLabel((IType) element, flags);
break;
case IJavaElement.CLASS_FILE:
appendClassFileLabel((IClassFile) element, flags);
break;
case IJavaElement.COMPILATION_UNIT:
appendCompilationUnitLabel((ICompilationUnit) element, flags);
break;
case IJavaElement.PACKAGE_FRAGMENT:
appendPackageFragmentLabel((IPackageFragment) element, flags);
break;
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
appendPackageFragmentRootLabel((IPackageFragmentRoot) element, flags);
break;
case IJavaElement.IMPORT_CONTAINER:
case IJavaElement.IMPORT_DECLARATION:
case IJavaElement.PACKAGE_DECLARATION:
appendDeclarationLabel(element, flags);
break;
case IJavaElement.JAVA_PROJECT:
case IJavaElement.JAVA_MODEL:
fBuilder.append(element.getElementName());
break;
default:
fBuilder.append(element.getElementName());
}
if (root != null && getFlag(flags, JavaElementLabels.APPEND_ROOT_PATH)) {
fBuilder.append(JavaElementLabels.CONCAT_STRING);
appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED);
}
}