本文整理匯總了Java中javax.lang.model.element.ElementKind.isField方法的典型用法代碼示例。如果您正苦於以下問題:Java ElementKind.isField方法的具體用法?Java ElementKind.isField怎麽用?Java ElementKind.isField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.lang.model.element.ElementKind
的用法示例。
在下文中一共展示了ElementKind.isField方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isInaccessibleOutsideOuterClass
import javax.lang.model.element.ElementKind; //導入方法依賴的package包/類
/**
* computes accessibility of members of nested classes
* @param e member
* @return {@code true} if the member cannot be accessed outside the outer class
* @see <a href="http://www.netbeans.org/issues/show_bug.cgi?id=169377">169377</a>
*/
private static boolean isInaccessibleOutsideOuterClass(Element e, ElementUtilities eu) {
Element enclosing = e.getEnclosingElement();
boolean isStatic = e.getModifiers().contains(Modifier.STATIC);
ElementKind kind = e.getKind();
if (isStatic || kind.isClass() || kind.isInterface() || kind.isField()) {
// static declaration of nested class, interface, enum, ann type, method, field
// or inner class
return isAnyEncloserPrivate(e);
} else if (enclosing != null && kind == ElementKind.METHOD) {
// final is enum, ann type and some classes
ElementKind enclosingKind = enclosing.getKind();
boolean isEnclosingFinal = enclosing.getModifiers().contains(Modifier.FINAL)
// ann type is not final even if it cannot be subclassed
|| enclosingKind == ElementKind.ANNOTATION_TYPE;
return isAnyEncloserPrivate(e) && !eu.overridesMethod((ExecutableElement) e) && !eu.implementsMethod((ExecutableElement)e) &&
(isEnclosingFinal || !isOverriddenInsideOutermostEnclosingClass((ExecutableElement)e, eu));
}
return false;
}
示例2: getHelpCtx
import javax.lang.model.element.ElementKind; //導入方法依賴的package包/類
@Override
public HelpCtx getHelpCtx() {
String postfix;
if (handle==null) {
postfix = ".JavaPackage";//NOI18N
} else {
ElementHandle elHandle = handle.getElementHandle();
if (elHandle == null) {
postfix = "";
} else {
ElementKind k = elHandle.getKind();
if (k == null) {
postfix = "";
} else if (k.isClass() || k.isInterface()) {
postfix = ".JavaClass";//NOI18N
} else if (k == ElementKind.METHOD) {
postfix = ".Method";//NOI18N
} else if (k.isField()) {
postfix = ".Field";//NOI18N
} else {
postfix = "";
}
}
}
return new HelpCtx(RenameRefactoringUI.class.getName() + postfix);
}
示例3: findTargetPosition
import javax.lang.model.element.ElementKind; //導入方法依賴的package包/類
/**
* Finds the target position within the source class element.
* In the current implementation, the target position is just below
* the last static field of the class; if there is no static field
* in the class, the target position is the top of the class.
*
* @param classMembers list of all members of the class
* @param fields list of the fields in the class
* @return target position ({@code 0}-based) of the field,
* or {@code -1} if the field should be added to the end
* of the class
*/
private int findTargetPosition(
List<? extends javax.lang.model.element.Element> classMembers,
List<? extends VariableElement> fields) {
if (fields.isEmpty()) {
return 0;
}
int target = 0;
boolean skippingStaticFields = false;
Iterator<? extends javax.lang.model.element.Element> membersIt
= classMembers.iterator();
for (int index = 0; membersIt.hasNext(); index++) {
javax.lang.model.element.Element member = membersIt.next();
ElementKind kind = member.getKind();
if (kind.isField()
&& (kind != ElementKind.ENUM_CONSTANT)
&& member.getModifiers().contains(Modifier.STATIC)) {
/* it is a static field - skip it! */
skippingStaticFields = true;
} else if (skippingStaticFields) {
/* we were skipping all static fields - until now */
skippingStaticFields = false;
target = index;
}
}
return !skippingStaticFields ? target : -1;
}