當前位置: 首頁>>代碼示例>>Java>>正文


Java ElementKind.PARAMETER屬性代碼示例

本文整理匯總了Java中javax.lang.model.element.ElementKind.PARAMETER屬性的典型用法代碼示例。如果您正苦於以下問題:Java ElementKind.PARAMETER屬性的具體用法?Java ElementKind.PARAMETER怎麽用?Java ElementKind.PARAMETER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.lang.model.element.ElementKind的用法示例。


在下文中一共展示了ElementKind.PARAMETER屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visitCompilationUnit

@Override
public Void visitCompilationUnit(CompilationUnitTree node, Void p) {
    if (!searchComment) {
        return super.visitCompilationUnit(node, p);
    }

    if (toFind.getKind() == ElementKind.PARAMETER) {
        renameParameterInMethodComments(toFind);
    } else {
        String originalName = toFind.getSimpleName().toString();
        if (originalName!=null) {
            TokenSequence<JavaTokenId> ts = info.getTokenHierarchy().tokenSequence(JavaTokenId.language());

            while (ts.moveNext()) {
                Token<JavaTokenId> t = ts.token();
                
                if (isComment(t)) {
                    findAllInComment(t.text().toString(), ts.offset(), originalName);
                }
            }
        }
    }
    return super.visitCompilationUnit(node, p);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:FindLocalUsagesQuery.java

示例2: checkConstantExpression

static boolean checkConstantExpression(final CompilationInfo info, TreePath path) {
    InstanceRefFinder finder = new InstanceRefFinder(info, path) {
        @Override
        public Object visitIdentifier(IdentifierTree node, Object p) {
            Element el = info.getTrees().getElement(getCurrentPath());
            if (el == null || el.asType() == null || el.asType().getKind() == TypeKind.ERROR) {
                return null;
            }
            if (el.getKind() == ElementKind.LOCAL_VARIABLE || el.getKind() == ElementKind.PARAMETER) {
                throw new StopProcessing();
            } else if (el.getKind() == ElementKind.FIELD) {
                if (!el.getModifiers().contains(Modifier.FINAL)) {
                    throw new StopProcessing();
                }
            }
            return super.visitIdentifier(node, p);
        }
    };
    try {
        finder.process();
        return  !(finder.containsInstanceReferences() || finder.containsLocalReferences() || finder.containsReferencesToSuper());
    } catch (StopProcessing e) {
        return false;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:IntroduceConstantFix.java

示例3: findMethodsWithSpyglassAnnotations

private Set<ExecutableElement> findMethodsWithSpyglassAnnotations(final RoundEnvironment roundEnvironment) {
	final Set<ExecutableElement> methods = new HashSet<>();

	for (final Class<? extends Annotation> annoType : SUPPORTED_ANNOTATIONS) {
		for (final Element foundElement : roundEnvironment.getElementsAnnotatedWith(annoType)) {
			if (foundElement.getKind() == ElementKind.METHOD) {
				methods.add((ExecutableElement) foundElement);
			} else if (foundElement.getKind() == ElementKind.PARAMETER) {
				methods.add((ExecutableElement) foundElement.getEnclosingElement());
			} else {
				throw new RuntimeException("A Spyglass annotation was somehow applied to an illegal element type.");
			}
		}
	}

	return methods;
}
 
開發者ID:MatthewTamlin,項目名稱:Spyglass,代碼行數:17,代碼來源:MainProcessor.java

示例4: getKind

@DefinedBy(Api.LANGUAGE_MODEL)
public ElementKind getKind() {
    long flags = flags();
    if ((flags & PARAMETER) != 0) {
        if (isExceptionParameter())
            return ElementKind.EXCEPTION_PARAMETER;
        else
            return ElementKind.PARAMETER;
    } else if ((flags & ENUM) != 0) {
        return ElementKind.ENUM_CONSTANT;
    } else if (owner.kind == TYP || owner.kind == ERR) {
        return ElementKind.FIELD;
    } else if (isResourceVariable()) {
        return ElementKind.RESOURCE_VARIABLE;
    } else {
        return ElementKind.LOCAL_VARIABLE;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:Symbol.java

示例5: getPanel

@Override
public CustomRefactoringPanel getPanel(ChangeListener parent) {
    if (panel == null) {
        String suffix = "";
        if(handle != null && handle.getKind() == Tree.Kind.LABELED_STATEMENT) {
            suffix = getString("LBL_Label");
        } else if (handle != null && handle.getElementHandle() !=null) {
            ElementKind kind = handle.getElementHandle().getKind();
            if (kind!=null && (kind.isClass() || kind.isInterface())) {
                suffix  = kind.isInterface() ? getString("LBL_Interface") : getString("LBL_Class");
            } else if (kind == ElementKind.METHOD) {
                suffix = getString("LBL_Method");
            } else if (kind == ElementKind.FIELD) {
                suffix = getString("LBL_Field");
            } else if (kind == ElementKind.LOCAL_VARIABLE) {
                suffix = getString("LBL_LocalVar");
            } else if (kind == ElementKind.PACKAGE || (handle == null && fromListener)) {
                suffix = pkgRename ? getString("LBL_Package") : getString("LBL_Folder");
            } else if (kind == ElementKind.PARAMETER) {
                suffix = getString("LBL_Parameter");
            }
        }
        suffix = suffix + " " + this.oldName; // NOI18N
        panel = new RenamePanel(handle, newName, parent, NbBundle.getMessage(RenamePanel.class, "LBL_Rename") + " " + suffix, !fromListener, fromListener && !byPassPakageRename);
    }
    return panel;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:RenameRefactoringUI.java

示例6: visitText

@Override
public DocTree visitText(TextTree node, Element p) {
    if(searchComment) {
        DocTrees trees = info.getDocTrees();
        DocSourcePositions sourcePositions = trees.getSourcePositions();
        DocTreePath currentDocPath = getCurrentPath();
        if(toFind.getKind() == ElementKind.PARAMETER) {
            VariableElement var = (VariableElement) toFind;
            Element method = trees.getElement(currentDocPath);
            if(!var.getEnclosingElement().equals(method)) {
                return super.visitText(node, p);
            }
        }
        String text = node.getBody();
        String name = toFind.getSimpleName().toString();
        if(text.contains(name)) {
            int start = (int) sourcePositions.getStartPosition(info.getCompilationUnit(), currentDocPath.getDocComment(), node);
            int length = name.length();
            int offset = -1;
            do {
                offset = text.indexOf(name, ++offset);
                if(offset != -1) {
                    try {
                        MutablePositionRegion region = createRegion(doc, start + offset, start + offset + length);
                        comments.add(region);
                    } catch(BadLocationException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }
            } while (offset != -1);
        }
    }
    return super.visitText(node, p);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:FindLocalUsagesQuery.java

示例7: isLocalVariable

private boolean isLocalVariable(IdentifierTree id, Trees trees) {
    Element el = trees.getElement(TreePath.getPath(treePath, id));
    if (el != null) {
        return el.getKind() == ElementKind.LOCAL_VARIABLE || el.getKind() == ElementKind.PARAMETER;
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:PreconditionsChecker.java

示例8: visitIdentifier

@Override
public Object visitIdentifier(IdentifierTree node, Object p) {
    Element el = ci.getTrees().getElement(getCurrentPath());
    if (el != null && el.getKind() == ElementKind.PARAMETER) {
        unusedVars.remove(el);
        if (unusedVars.isEmpty()) {
            throw new StopProcessing();
        }
    }
    return super.visitIdentifier(node, p);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:ComparatorParameterNotUsed.java

示例9: assignmentToMethodParam

@Hint(displayName = "#DN_org.netbeans.modules.java.hints.AssignmentIssues.assignmentToMethodParam", description = "#DESC_org.netbeans.modules.java.hints.AssignmentIssues.assignmentToMethodParam", category = "assignment_issues", enabled = false, suppressWarnings = "AssignmentToMethodParameter", options=Options.QUERY) //NOI18N
@TriggerTreeKind({Kind.ASSIGNMENT, Kind.AND_ASSIGNMENT, Kind.DIVIDE_ASSIGNMENT,
    Kind.LEFT_SHIFT_ASSIGNMENT, Kind.MINUS_ASSIGNMENT, Kind.MULTIPLY_ASSIGNMENT,
    Kind.OR_ASSIGNMENT, Kind.PLUS_ASSIGNMENT, Kind.REMAINDER_ASSIGNMENT, Kind.RIGHT_SHIFT_ASSIGNMENT,
    Kind.UNSIGNED_RIGHT_SHIFT_ASSIGNMENT, Kind.XOR_ASSIGNMENT, Kind.PREFIX_INCREMENT,
    Kind.PREFIX_DECREMENT, Kind.POSTFIX_INCREMENT, Kind.POSTFIX_DECREMENT})
public static ErrorDescription assignmentToMethodParam(HintContext context) {
    final TreePath path = context.getPath();
    Element element = null;
    switch (path.getLeaf().getKind()) {
        case ASSIGNMENT:
            element = context.getInfo().getTrees().getElement(TreePath.getPath(path, ((AssignmentTree) path.getLeaf()).getVariable()));
            break;
        case PREFIX_INCREMENT:
        case PREFIX_DECREMENT:
        case POSTFIX_INCREMENT:
        case POSTFIX_DECREMENT:
            element = context.getInfo().getTrees().getElement(TreePath.getPath(path, ((UnaryTree) path.getLeaf()).getExpression()));
            break;
        default:
            element = context.getInfo().getTrees().getElement(TreePath.getPath(path, ((CompoundAssignmentTree) path.getLeaf()).getVariable()));
    }
    if (element != null && element.getKind() == ElementKind.PARAMETER) {
        return ErrorDescriptionFactory.forTree(context, path, NbBundle.getMessage(AssignmentIssues.class, "MSG_AssignmentToMethodParam", element.getSimpleName())); //NOI18N
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:AssignmentIssues.java

示例10: visitVariable

@Override
public Void visitVariable(VariableElement e, Boolean highlightName) {
    modifier(e.getModifiers());
    
    result.append(getTypeName(info, e.asType(), true));
    
    result.append(' ');
    
    boldStartCheck(highlightName);

    result.append(e.getSimpleName());
    
    boldStopCheck(highlightName);
    
    if (highlightName) {
        if (e.getConstantValue() != null) {
            result.append(" = ");
            result.append(StringEscapeUtils.escapeHtml(e.getConstantValue().toString()));
        }
        
        Element enclosing = e.getEnclosingElement();
        
        if (e.getKind() != ElementKind.PARAMETER && e.getKind() != ElementKind.LOCAL_VARIABLE
                && e.getKind() != ElementKind.RESOURCE_VARIABLE && e.getKind() != ElementKind.EXCEPTION_PARAMETER) {
            result.append(" in ");

            //short typename:
            result.append(getTypeName(info, enclosing.asType(), true));
        }
    }
    
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:GoToSupport.java

示例11: isLocalVariableClosure

private static boolean isLocalVariableClosure(Element el) {
    return el.getKind() == ElementKind.PARAMETER || el.getKind() == ElementKind.LOCAL_VARIABLE
            || el.getKind() == ElementKind.RESOURCE_VARIABLE || el.getKind() == ElementKind.EXCEPTION_PARAMETER;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:SemanticHighlighterBase.java


注:本文中的javax.lang.model.element.ElementKind.PARAMETER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。