本文整理匯總了Java中org.eclipse.jdt.core.dom.SingleVariableDeclaration.getInitializer方法的典型用法代碼示例。如果您正苦於以下問題:Java SingleVariableDeclaration.getInitializer方法的具體用法?Java SingleVariableDeclaration.getInitializer怎麽用?Java SingleVariableDeclaration.getInitializer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.SingleVariableDeclaration
的用法示例。
在下文中一共展示了SingleVariableDeclaration.getInitializer方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
@Override
public ITypeConstraint[] create(SingleVariableDeclaration svd) {
ITypeConstraint[] defines =
fTypeConstraintFactory.createDefinesConstraint(
fConstraintVariableFactory.makeExpressionOrTypeVariable(svd.getName(), getContext()),
fConstraintVariableFactory.makeTypeVariable(svd.getType()));
if (svd.getInitializer() == null) return defines;
ITypeConstraint[] constraints =
fTypeConstraintFactory.createSubtypeConstraint(
fConstraintVariableFactory.makeExpressionOrTypeVariable(
svd.getInitializer(), getContext()),
fConstraintVariableFactory.makeExpressionOrTypeVariable(svd.getName(), getContext()));
if (defines.length == 0 && constraints.length == 0) {
return new ITypeConstraint[0];
} else if (defines.length == 0) {
return constraints;
} else if (constraints.length == 0) {
return defines;
} else {
List<ITypeConstraint> all = new ArrayList<ITypeConstraint>();
all.addAll(Arrays.asList(defines));
all.addAll(Arrays.asList(constraints));
return (ITypeConstraint[]) all.toArray();
}
}
示例2: hasSideEffect
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的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;
}
示例3: endVisit
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
@Override
public void endVisit(SingleVariableDeclaration node) {
if (skipNode(node)) {
return;
}
IVariableBinding binding = node.resolveBinding();
LocalFlowInfo nameInfo = null;
Expression initializer = node.getInitializer();
if (binding != null && !binding.isField() && initializer != null) {
nameInfo = new LocalFlowInfo(binding, FlowInfo.WRITE, fFlowContext);
}
GenericSequentialFlowInfo info = processSequential(node, node.getType(), initializer);
info.merge(nameInfo, fFlowContext);
}
示例4: hasSideEffect
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的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<Expression>();
node.accept(new SideEffectFinder(sideEffects));
return sideEffects.size() > 0;
}
示例5: endVisit
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
@Override
public void endVisit(SingleVariableDeclaration node) {
// used for formal method parameters and catch clauses
// TODO: extra dimensions?
// ConstraintVariable2 typeCv= getConstraintVariable(node.getType()); //TODO: who needs this?
// ConstraintVariable2 nameCv;
// switch (node.getParent().getNodeType()) {
// case ASTNode.METHOD_DECLARATION :
// MethodDeclaration parent= (MethodDeclaration) node.getParent();
// int index= parent.parameters().indexOf(node);
// nameCv= fTCFactory.makeParameterTypeVariable(parent.resolveBinding(), index,
// node.getType());
// //store source range even if variable not used in constraint here. TODO: move to
// visit(MethodDeclaration)?
// break;
// case ASTNode.CATCH_CLAUSE :
// nameCv= fTCFactory.makeVariableVariable(node.resolveBinding());
//
// break;
// default:
// unexpectedNode(node.getParent());
// }
// setConstraintVariable(node, nameCv);
// TODO: Move this into visit(SimpleName) or leave it here?
// ExpressionVariable2 name= fTCFactory.makeExpressionVariable(node.getName());
// TypeVariable2 type= fTCFactory.makeTypeVariable(node.getType());
// ITypeConstraint2[] nameEqualsType= fTCFactory.createEqualsConstraint(name, type);
// addConstraints(nameEqualsType);
// TODO: When can a SingleVariableDeclaration have an initializer? Never up to Java 1.5?
Expression initializer = node.getInitializer();
if (initializer == null) return;
// ConstraintVariable2 initializerCv= getConstraintVariable(initializer);
// ConstraintVariable2 nameCv= getConstraintVariable(node);
// TODO: check: property has been set in visit(CatchClause), visit(MethodDeclaration),
// visit(EnhancedForStatament)
// fTCFactory.createSubtypeConstraint(initializerCv, nameCv); //TODO: not for augment raw
// container clients
}