本文整理匯總了Java中org.eclipse.jdt.core.dom.SimpleName.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleName.getParent方法的具體用法?Java SimpleName.getParent怎麽用?Java SimpleName.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.SimpleName
的用法示例。
在下文中一共展示了SimpleName.getParent方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDeclarationNode
import org.eclipse.jdt.core.dom.SimpleName; //導入方法依賴的package包/類
/**
* Returns the declaration node for the originally selected node.
*
* @param name
* the name of the node
*
* @return the declaration node
*/
private static ASTNode getDeclarationNode(SimpleName name) {
ASTNode parent = name.getParent();
if (!(parent instanceof AbstractTypeDeclaration)) {
parent = parent.getParent();
if (parent instanceof ParameterizedType || parent instanceof Type) {
parent = parent.getParent();
}
if (parent instanceof ClassInstanceCreation) {
final ClassInstanceCreation creation = (ClassInstanceCreation) parent;
parent = creation.getAnonymousClassDeclaration();
}
}
return parent;
}
示例2: needsImport
import org.eclipse.jdt.core.dom.SimpleName; //導入方法依賴的package包/類
private boolean needsImport(ITypeBinding typeBinding, SimpleName ref) {
if (!typeBinding.isTopLevel() && !typeBinding.isMember() || typeBinding.isRecovered()) {
return false; // no imports for anonymous, local, primitive types or parameters types
}
int modifiers= typeBinding.getModifiers();
if (Modifier.isPrivate(modifiers)) {
return false; // imports for privates are not required
}
ITypeBinding currTypeBinding= Bindings.getBindingOfParentType(ref);
if (currTypeBinding == null) {
if (ASTNodes.getParent(ref, ASTNode.PACKAGE_DECLARATION) != null) {
return true; // reference in package-info.java
}
return false; // not in a type
}
if (!Modifier.isPublic(modifiers)) {
if (!currTypeBinding.getPackage().getName().equals(typeBinding.getPackage().getName())) {
return false; // not visible
}
}
ASTNode parent= ref.getParent();
while (parent instanceof Type) {
parent= parent.getParent();
}
if (parent instanceof AbstractTypeDeclaration && parent.getParent() instanceof CompilationUnit) {
return true;
}
if (typeBinding.isMember()) {
if (fAnalyzer.isDeclaredInScope(typeBinding, ref, ScopeAnalyzer.TYPES | ScopeAnalyzer.CHECK_VISIBILITY)) {
return false;
}
}
return true;
}
示例3: hasSideEffect
import org.eclipse.jdt.core.dom.SimpleName; //導入方法依賴的package包/類
private static boolean hasSideEffect(SimpleName reference) {
ASTNode parent= reference.getParent();
while (parent instanceof QualifiedName) {
parent= parent.getParent();
}
if (parent instanceof FieldAccess) {
parent= parent.getParent();
}
ASTNode node= null;
int nameParentType= parent.getNodeType();
if (nameParentType == ASTNode.ASSIGNMENT) {
Assignment assignment= (Assignment) parent;
node= assignment.getRightHandSide();
} else if (nameParentType == ASTNode.SINGLE_VARIABLE_DECLARATION) {
SingleVariableDeclaration decl= (SingleVariableDeclaration)parent;
node= decl.getInitializer();
if (node == null) {
return false;
}
} else if (nameParentType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
node= parent;
} else {
return false;
}
ArrayList<Expression> sideEffects= new ArrayList<>();
node.accept(new SideEffectFinder(sideEffects));
return sideEffects.size() > 0;
}
示例4: isEnhancedForStatementVariable
import org.eclipse.jdt.core.dom.SimpleName; //導入方法依賴的package包/類
private boolean isEnhancedForStatementVariable(Statement statement, SimpleName name) {
if (statement instanceof EnhancedForStatement) {
EnhancedForStatement forStatement= (EnhancedForStatement) statement;
SingleVariableDeclaration param= forStatement.getParameter();
return param.getType() == name.getParent(); // strange recovery, see https://bugs.eclipse.org/180456
}
return false;
}
示例5: visit
import org.eclipse.jdt.core.dom.SimpleName; //導入方法依賴的package包/類
@Override
public boolean visit(SimpleName node) {
if(!(node.getParent() instanceof QualifiedName))
vars.add(node.getIdentifier());
return true;
}
示例6: isFormalParameterInEnhancedForStatement
import org.eclipse.jdt.core.dom.SimpleName; //導入方法依賴的package包/類
private static boolean isFormalParameterInEnhancedForStatement(SimpleName name) {
return name.getParent() instanceof SingleVariableDeclaration && name.getParent().getLocationInParent() == EnhancedForStatement.PARAMETER_PROPERTY;
}