本文整理匯總了Java中org.eclipse.jdt.core.IJavaElement.TYPE屬性的典型用法代碼示例。如果您正苦於以下問題:Java IJavaElement.TYPE屬性的具體用法?Java IJavaElement.TYPE怎麽用?Java IJavaElement.TYPE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.eclipse.jdt.core.IJavaElement
的用法示例。
在下文中一共展示了IJavaElement.TYPE屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processType
private void processType(ITypeVisitor visitor, BinaryTypeName btn,
IType type, IProgressMonitor monitor) throws JavaModelException {
final String binaryname = btn.toString();
monitor.subTask(binaryname);
visitor.visit(type, binaryname);
for (final IJavaElement child : type.getChildren()) {
if (monitor.isCanceled()) {
break;
}
switch (child.getElementType()) {
case IJavaElement.TYPE:
IType nestedtype = (IType) child;
processType(visitor, btn.nest(nestedtype), nestedtype, monitor);
break;
case IJavaElement.METHOD:
case IJavaElement.INITIALIZER:
case IJavaElement.FIELD:
processAnonymousInnerTypes(visitor, btn, (IMember) child, monitor);
break;
}
}
}
示例2: collectCodeLenses
private void collectCodeLenses(ITypeRoot unit, IJavaElement[] elements, List<ICodeLens> lenses,
IProgressMonitor monitor) throws JavaModelException {
for (IJavaElement element : elements) {
if (monitor.isCanceled()) {
return;
}
if (element.getElementType() == IJavaElement.TYPE) {
collectCodeLenses(unit, ((IType) element).getChildren(), lenses, monitor);
} else if (element.getElementType() != IJavaElement.METHOD || JDTUtils.isHiddenGeneratedElement(element)) {
continue;
}
// if (preferenceManager.getPreferences().isReferencesCodeLensEnabled()) {
ICodeLens lens = getCodeLens(REFERENCES_TYPE, element, unit);
lenses.add(lens);
// }
// if (preferenceManager.getPreferences().isImplementationsCodeLensEnabled() &&
// element instanceof IType) {
if (element instanceof IType) {
IType type = (IType) element;
if (type.isInterface() || Flags.isAbstract(type.getFlags())) {
lens = getCodeLens(IMPLEMENTATION_TYPE, element, unit);
lenses.add(lens);
}
}
}
}
示例3: processAnonymousInnerTypes
private void processAnonymousInnerTypes(ITypeVisitor visitor,
BinaryTypeName btn, IMember member, IProgressMonitor monitor)
throws JavaModelException {
for (final IJavaElement element : member.getChildren()) {
if (monitor.isCanceled()) {
break;
}
if (element.getElementType() == IJavaElement.TYPE) {
final IType type = (IType) element;
processType(visitor, btn.nest(type), type, monitor);
}
}
}
示例4: collectCompilationUnits
private void collectCompilationUnits(Object element, Collection<IJavaElement> result, String packagePrefix) {
try {
if (element instanceof IJavaElement) {
IJavaElement elem = (IJavaElement) element;
if (elem.exists()) {
switch (elem.getElementType()) {
case IJavaElement.TYPE:
if (elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) {
result.add(elem.getParent());
}
break;
case IJavaElement.COMPILATION_UNIT:
result.add(elem);
break;
case IJavaElement.IMPORT_CONTAINER:
result.add(elem.getParent());
break;
case IJavaElement.PACKAGE_FRAGMENT:
collectCompilationUnits((IPackageFragment) elem, result);
break;
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
collectCompilationUnits((IPackageFragmentRoot) elem, result, packagePrefix);
break;
case IJavaElement.JAVA_PROJECT:
IPackageFragmentRoot[] roots = ((IJavaProject) elem).getPackageFragmentRoots();
for (int k = 0; k < roots.length; k++) {
collectCompilationUnits(roots[k], result, null);
}
break;
}
}
}
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Problem collection compilation unit ", e);
}
}
示例5: collectChildren
private void collectChildren(ITypeRoot unit, IJavaElement[] elements, ArrayList<SymbolInformation> symbols,
IProgressMonitor monitor)
throws JavaModelException {
for(IJavaElement element : elements ){
if (monitor.isCanceled()) {
return;
}
if(element instanceof IParent){
collectChildren(unit, filter(((IParent) element).getChildren()), symbols, monitor);
}
int type = element.getElementType();
if (type != IJavaElement.TYPE && type != IJavaElement.FIELD && type != IJavaElement.METHOD) {
continue;
}
Location location = JDTUtils.toLocation(element);
if (location != null) {
SymbolInformation si = new SymbolInformation();
String name = JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT);
si.setName(name == null ? element.getElementName() : name);
si.setKind(mapKind(element));
if (element.getParent() != null) {
si.setContainerName(element.getParent().getElementName());
}
location.setUri(ResourceUtils.toClientUri(location.getUri()));
si.setLocation(location);
if (!symbols.contains(si)) {
symbols.add(si);
}
}
}
}
示例6: 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;
}
示例7: getKind
private String getKind(IMember member) {
switch (member.getElementType()) {
case IJavaElement.METHOD:
return KIND_METHOD;
case IJavaElement.INITIALIZER:
return KIND_INITIALIZER;
case IJavaElement.FIELD:
return KIND_FIELD;
case IJavaElement.TYPE:
IType type = (IType) member;
try {
if (type.isAnnotation()) {
return KIND_ANNOTATION;
}
if (type.isInterface()) {
return KIND_INTERFACE;
}
if (type.isEnum()) {
return KIND_ENUM;
}
if (type.isClass()) {
return KIND_CLASS;
}
} catch (JavaModelException e) {
return KIND_TYPE;
}
return KIND_TYPE;
default:
return null;
}
}
示例8: 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);
}
}