本文整理汇总了Java中javax.lang.model.element.ElementKind.OTHER属性的典型用法代码示例。如果您正苦于以下问题:Java ElementKind.OTHER属性的具体用法?Java ElementKind.OTHER怎么用?Java ElementKind.OTHER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.lang.model.element.ElementKind
的用法示例。
在下文中一共展示了ElementKind.OTHER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeReferenceCount
/**
* Returns an estimate of a number of classes on given source path (source root) which are
* using given type.
* @param type the type type to find the usage frequency for.
* @return number of classes using the type.
*/
public int getTypeReferenceCount(@NonNull final ElementHandle<? extends TypeElement> type) {
Parameters.notNull("binaryName", type); //NOI18N
if (!type.getKind().isClass() &&
!type.getKind().isInterface() &&
type.getKind() != ElementKind.OTHER) {
throw new IllegalArgumentException(type.toString());
}
try {
init();
final Integer count = typeFreqs.get(SourceUtils.getJVMSignature(type)[0]);
return count == null ? 0 : count;
} catch (InterruptedException ie) {
return 0;
}
}
示例2: createElementHandle
@CheckForNull
public static <T extends Element> ElementHandle<T> createElementHandle(@NonNull final T element) {
//ElementKind OTHER represents errors <any>, <none>.
//These are special errors which cannot be resolved
if (element.getKind() == ElementKind.OTHER) {
return null;
}
try {
return ElementHandle.create(element);
} catch (IllegalArgumentException e) {
LOG.log(
Level.INFO,
"Unresolvable element: {0}, reason: {1}", //NOI18N
new Object[]{
element,
e.getMessage()
});
return null;
}
}
示例3: signatureEquals
public static boolean signatureEquals(
@NonNull final ElementHandle<Element> handle,
@NonNull final Element element) {
if (handle == null) {
return false;
}
//ElementKind OTHER represents errors <any>, <none>.
//These are special errors which cannot be resolved
if (element.getKind() == ElementKind.OTHER) {
return false;
}
try {
return handle.signatureEquals(element);
} catch (IllegalArgumentException e) {
LOG.log(
Level.INFO,
"Unresolvable element: {0}, reason: {1}", //NOI18N
new Object[]{
element,
e.getMessage()
});
return false;
}
}
示例4: directive
@NonNull
static Description directive(
@NonNull final ClassMemberPanelUI ui,
@NonNull final String name,
@NonNull final TreePathHandle treePathHandle,
@NonNull final ModuleElement.DirectiveKind kind,
@NonNull final ClasspathInfo cpInfo,
final long pos,
@NonNull final Openable openable) {
return new Description(
ui,
name,
Union2.<ElementHandle<?>,TreePathHandle>createSecond(treePathHandle),
ElementKind.OTHER,
directivePosInKind(kind),
cpInfo,
EnumSet.of(Modifier.PUBLIC),
pos,
false,
false,
()->ElementIcons.getModuleDirectiveIcon(kind),
openable);
}
示例5: findNode
@CheckForNull
@Override
public Node findNode(@NonNull final Point loc) {
final TreePath path = tree.getPathForLocation( loc.x, loc.y );
if( null == path ) {
return null;
}
final Node node = Visualizer.findNode( path.getLastPathComponent());
if (!(node instanceof ElementNode)) {
return null;
}
final ElementNode enode = (ElementNode) node;
final ElementNode.Description desc = enode.getDescritption();
//Other and module do not have javadoc
return desc.kind != ElementKind.OTHER
&& desc.kind != ElementKind.MODULE ?
node :
null;
}
示例6: isSameKind
private static boolean isSameKind (ElementKind k1, ElementKind k2) {
if ((k1 == k2) ||
(k1 == ElementKind.OTHER && (k2.isClass() || k2.isInterface())) ||
(k2 == ElementKind.OTHER && (k1.isClass() || k1.isInterface()))) {
return true;
}
return false;
}
示例7: getBinaryName
/**
* Returns a binary name of the {@link TypeElement} represented by this
* {@link ElementHandle}. When the {@link ElementHandle} doesn't represent
* a {@link TypeElement} it throws a {@link IllegalStateException}
* @return the qualified name
* @throws an {@link IllegalStateException} when this {@link ElementHandle}
* isn't created for the {@link TypeElement}.
*/
public @NonNull String getBinaryName () throws IllegalStateException {
if ((this.kind.isClass() && !isArray(signatures[0])) ||
this.kind.isInterface() ||
this.kind == ElementKind.MODULE ||
this.kind == ElementKind.OTHER) {
return this.signatures[0];
}
else {
throw new IllegalStateException ();
}
}
示例8: getQualifiedName
/**
* Returns a qualified name of the {@link TypeElement} represented by this
* {@link ElementHandle}. When the {@link ElementHandle} doesn't represent
* a {@link TypeElement} it throws a {@link IllegalStateException}
* @return the qualified name
* @throws an {@link IllegalStateException} when this {@link ElementHandle}
* isn't creatred for the {@link TypeElement}.
*/
public @NonNull String getQualifiedName () throws IllegalStateException {
if ((this.kind.isClass() && !isArray(signatures[0])) ||
this.kind.isInterface() ||
this.kind == ElementKind.MODULE ||
this.kind == ElementKind.OTHER) {
return this.signatures[0].replace (Target.DEFAULT.syntheticNameChar(),'.'); //NOI18N
}
else {
throw new IllegalStateException ();
}
}
示例9: signatureEquals
/**
* Tests if the handle has this same signature as the parameter.
* The handles has the same signatures if it is resolved into the same
* element in the same {@link javax.tools.JavaCompiler} task, but may be resolved into
* the different {@link Element} in the different {@link javax.tools.JavaCompiler} task.
* @param element to be checked
* @return true if this handle resolves into the same {@link Element}
* in the same {@link javax.tools.JavaCompiler} task.
*/
public boolean signatureEquals (@NonNull final T element) {
final ElementKind ek = element.getKind();
final ElementKind thisKind = getKind();
if ((ek != thisKind) && !(thisKind == ElementKind.OTHER && (ek.isClass() || ek.isInterface()))) {
return false;
}
final ElementHandle<T> handle = create (element);
return signatureEquals (handle);
}
示例10: getGroupId
/**
* Returns the group number of the class member. Elements with the same
* number form a group. Groups with lower numbers should be positioned
* higher in the class member list.
* @param tree the member tree
* @return the group number
* @since 0.96
*/
public int getGroupId(Tree tree) {
ElementKind kind = ElementKind.OTHER;
Set<Modifier> modifiers = null;
switch (tree.getKind()) {
case ANNOTATION_TYPE:
case CLASS:
case ENUM:
case INTERFACE:
kind = ElementKind.CLASS;
modifiers = ((ClassTree)tree).getModifiers().getFlags();
break;
case METHOD:
MethodTree mt = (MethodTree)tree;
if (mt.getName().contentEquals("<init>")) { //NOI18N
kind = ElementKind.CONSTRUCTOR;
} else {
kind = ElementKind.METHOD;
}
modifiers = mt.getModifiers().getFlags();
break;
case VARIABLE:
kind = ElementKind.FIELD;
modifiers = ((VariableTree)tree).getModifiers().getFlags();
break;
case BLOCK:
kind = ((BlockTree)tree).isStatic() ? ElementKind.STATIC_INIT : ElementKind.INSTANCE_INIT;
break;
}
for (Info info : infos) {
if (info.check(kind, modifiers))
return info.groupId;
}
return infos.length;
}
示例11: getActions
@Override
public Action[] getActions( boolean context ) {
if ( context || description.name == null ) {
return description.ui.getActions();
} else {
final Action panelActions[] = description.ui.getActions();
final List<? extends Action> standardActions;
final List<? extends Action> additionalActions;
if (description.kind == ElementKind.OTHER) {
standardActions = Collections.singletonList(getOpenAction());
additionalActions = Collections.<Action>emptyList();
} else {
standardActions = Arrays.asList(new Action[] {
getOpenAction(),
RefactoringActionsFactory.whereUsedAction(),
RefactoringActionsFactory.popupSubmenuAction()
});
additionalActions = Utilities.actionsForPath(ACTION_FOLDER);
}
final int standardActionsSize = standardActions.isEmpty() ? 0 : standardActions.size() + 1;
final int additionalActionSize = additionalActions.isEmpty() ? 0 : additionalActions.size() + 1;
final List<Action> actions = new ArrayList<>(standardActionsSize + additionalActionSize + panelActions.length);
if (standardActionsSize > 0) {
actions.addAll(standardActions);
actions.add(null);
}
if (additionalActionSize > 0) {
actions.addAll(additionalActions);
actions.add(null);
}
actions.addAll(Arrays.asList(panelActions));
return actions.toArray(new Action[actions.size()]);
}
}
示例12: updateNavigatorSelection
private void updateNavigatorSelection(CompilationInfo ci, TreePath tp) throws Exception {
final ClassMemberPanel cmp = ClassMemberPanel.getInstance();
if (cmp == null) {
return;
}
final ClassMemberPanelUI cmpUi = cmp.getClassMemberPanelUI();
if (!cmpUi.isAutomaticRefresh()) {
cmpUi.getTask().runImpl(ci, false);
lastEhForNavigator = null;
}
// Try to find the declaration we are in
final Pair<Element,TreePath> p = outerElement(ci, tp);
if (p != null) {
final Element e = p.first();
Runnable action = null;
if (e == null) {
//Directive
lastEhForNavigator = null;
action = () -> {
cmp.selectTreePath(TreePathHandle.create(p.second(), ci));
};
} else if (e.getKind() != ElementKind.OTHER) {
final ElementHandle<Element> eh = ElementHandle.create(e);
if (lastEhForNavigator != null && eh.signatureEquals(lastEhForNavigator)) {
return;
}
lastEhForNavigator = eh;
action = () -> {
cmp.selectElement(eh);
};
}
if (action != null) {
SwingUtilities.invokeLater(action);
}
}
}
示例13: testOriginatingElementComments
public void testOriginatingElementComments() throws Exception {
b = new LayerBuilder(doc, new Element() {
public @Override ElementKind getKind() {
return ElementKind.OTHER;
}
public @Override String toString() {
return "originating.Type";
}
public @Override TypeMirror asType() {return null;}
public @Override List<? extends AnnotationMirror> getAnnotationMirrors() {return null;}
public @Override <A extends Annotation> A getAnnotation(Class<A> annotationType) {return null;}
public @Override Set<Modifier> getModifiers() {return null;}
public @Override Name getSimpleName() {return null;}
public @Override Element getEnclosingElement() {return null;}
public @Override List<? extends Element> getEnclosedElements() {return null;}
public @Override <R, P> R accept(ElementVisitor<R, P> v, P p) {return null;}
@Override
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) {
return (A[]) Array.newInstance(annotationType, 0);
}
}, null);
b.folder("f").write();
assertEquals("<filesystem><folder name='f'><!--originating.Type--></folder></filesystem>", dump());
// #180154: do not repeat after an incremental build
b.folder("f").write();
assertEquals("<filesystem><folder name='f'><!--originating.Type--></folder></filesystem>", dump());
}
示例14: getDocCommentTuple
private DocCommentDuo getDocCommentTuple(Element element) {
// prevent nasty things downstream with overview element
if (element.getKind() != ElementKind.OTHER) {
TreePath path = getTreePath(element);
if (path != null) {
DocCommentTree docCommentTree = docTrees.getDocCommentTree(path);
return new DocCommentDuo(path, docCommentTree);
}
}
return null;
}
示例15: search
@Override
public <T> void search (
@NonNull final ElementHandle<?> element,
@NonNull final Set<? extends UsageType> usageType,
@NonNull final Set<? extends ClassIndex.SearchScopeType> scope,
@NonNull final Convertor<? super Document, T> convertor,
@NonNull final Set<? super T> result) throws InterruptedException, IOException {
Parameters.notNull("element", element); //NOI18N
Parameters.notNull("usageType", usageType); //NOI18N
Parameters.notNull("scope", scope); //NOI18N
Parameters.notNull("convertor", convertor); //NOI18N
Parameters.notNull("result", result); //NOI18N
final Pair<Convertor<? super Document, T>,Index> ctu = indexPath.getPatch(convertor);
try {
final String binaryName = SourceUtils.getJVMSignature(element)[0];
final ElementKind kind = element.getKind();
if (kind == ElementKind.PACKAGE) {
IndexManager.priorityAccess(() -> {
final Query q = QueryUtil.scopeFilter(
QueryUtil.createPackageUsagesQuery(binaryName,usageType,Occur.SHOULD),
scope);
if (q != null) {
index.query(result, ctu.first(), DocumentUtil.declaredTypesFieldSelector(false, false), cancel.get(), q);
if (ctu.second() != null) {
ctu.second().query(result, convertor, DocumentUtil.declaredTypesFieldSelector(false, false), cancel.get(), q);
}
}
return null;
});
} else if (kind.isClass() ||
kind.isInterface() ||
kind == ElementKind.OTHER) {
if (BinaryAnalyser.OBJECT.equals(binaryName)) {
getDeclaredElements(
"", //NOI18N
ClassIndex.NameKind.PREFIX,
scope,
DocumentUtil.declaredTypesFieldSelector(false, false),
convertor,
result);
} else {
IndexManager.priorityAccess(() -> {
final Query usagesQuery = QueryUtil.scopeFilter(
QueryUtil.createUsagesQuery(binaryName, usageType, Occur.SHOULD),
scope);
if (usagesQuery != null) {
index.query(result, ctu.first(), DocumentUtil.declaredTypesFieldSelector(false, false), cancel.get(), usagesQuery);
if (ctu.second() != null) {
ctu.second().query(result, convertor, DocumentUtil.declaredTypesFieldSelector(false, false), cancel.get(), usagesQuery);
}
}
return null;
});
}
} else {
throw new IllegalArgumentException(element.toString());
}
} catch (IOException ioe) {
this.<Void,IOException>handleException(null, ioe, root);
}
}