本文整理汇总了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;
}