本文整理汇总了Java中org.eclipse.jdt.core.dom.ExpressionStatement.getExpression方法的典型用法代码示例。如果您正苦于以下问题:Java ExpressionStatement.getExpression方法的具体用法?Java ExpressionStatement.getExpression怎么用?Java ExpressionStatement.getExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.ExpressionStatement
的用法示例。
在下文中一共展示了ExpressionStatement.getExpression方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.eclipse.jdt.core.dom.ExpressionStatement; //导入方法依赖的package包/类
public boolean visit(final ExpressionStatement node) {
if (node.getExpression() instanceof MethodInvocation) {
final MethodInvocation method = (MethodInvocation)node.getExpression();
Expression expression;
for (expression = method.getExpression(); expression instanceof MethodInvocation; expression = ((MethodInvocation)expression).getExpression()) {}
final IVariableBinding field = this.getLocalField(expression);
if (field != null) {
MethodAnalyzer.this.setFields.add(field);
}
int index = this.getVariableIndex(method.getExpression());
if (index != -1) {
MethodAnalyzer.this.variables.get(index).setModified(true);
} else {
index = this.getParameterIndex(method.getExpression());
if (index != -1) {
MethodAnalyzer.this.parameters.get(index).setModified(true);
}
}
if (this.isLocalMethod(method)) {
MethodAnalyzer.this.invokedLocalMethods.add(method.resolveMethodBinding());
}
}
return super.visit(node);
}
示例2: isAssigned
import org.eclipse.jdt.core.dom.ExpressionStatement; //导入方法依赖的package包/类
private boolean isAssigned(Statement statement, SimpleName name) {
if (statement instanceof ExpressionStatement) {
ExpressionStatement exstat= (ExpressionStatement) statement;
if (exstat.getExpression() instanceof Assignment) {
Assignment assignment= (Assignment) exstat.getExpression();
return assignment.getLeftHandSide() == name;
}
}
return false;
}
示例3: isAssigned
import org.eclipse.jdt.core.dom.ExpressionStatement; //导入方法依赖的package包/类
private boolean isAssigned(Statement statement, SimpleName name) {
if (statement instanceof ExpressionStatement) {
ExpressionStatement exstat = (ExpressionStatement) statement;
if (exstat.getExpression() instanceof Assignment) {
Assignment assignment = (Assignment) exstat.getExpression();
return assignment.getLeftHandSide() == name;
}
}
return false;
}
示例4: getAssignToVariableProposals
import org.eclipse.jdt.core.dom.ExpressionStatement; //导入方法依赖的package包/类
public static boolean getAssignToVariableProposals(IInvocationContext context, ASTNode node, IProblemLocation[] locations, Collection<ICommandAccess> resultingCollections) {
Statement statement= ASTResolving.findParentStatement(node);
if (!(statement instanceof ExpressionStatement)) {
return false;
}
ExpressionStatement expressionStatement= (ExpressionStatement) statement;
Expression expression= expressionStatement.getExpression();
if (expression.getNodeType() == ASTNode.ASSIGNMENT) {
return false; // too confusing and not helpful
}
ITypeBinding typeBinding= expression.resolveTypeBinding();
typeBinding= Bindings.normalizeTypeBinding(typeBinding);
if (typeBinding == null) {
return false;
}
if (resultingCollections == null) {
return true;
}
// don't add if already added as quick fix
if (containsMatchingProblem(locations, IProblem.UnusedObjectAllocation))
return false;
ICompilationUnit cu= context.getCompilationUnit();
AssignToVariableAssistProposal localProposal= new AssignToVariableAssistProposal(cu, AssignToVariableAssistProposal.LOCAL, expressionStatement, typeBinding, IProposalRelevance.ASSIGN_TO_LOCAL);
localProposal.setCommandId(ASSIGN_TO_LOCAL_ID);
resultingCollections.add(localProposal);
ASTNode type= ASTResolving.findParentType(expression);
if (type != null) {
AssignToVariableAssistProposal fieldProposal= new AssignToVariableAssistProposal(cu, AssignToVariableAssistProposal.FIELD, expressionStatement, typeBinding, IProposalRelevance.ASSIGN_TO_FIELD);
fieldProposal.setCommandId(ASSIGN_TO_FIELD_ID);
resultingCollections.add(fieldProposal);
}
return true;
}
示例5: extractExpressionType
import org.eclipse.jdt.core.dom.ExpressionStatement; //导入方法依赖的package包/类
private static ITypeBinding extractExpressionType(ExpressionStatement statement) {
Expression expression= statement.getExpression();
if (expression.getNodeType() == ASTNode.METHOD_INVOCATION
|| expression.getNodeType() == ASTNode.FIELD_ACCESS) {
return expression.resolveTypeBinding();
}
return null;
}
示例6: getAssignToVariableProposals
import org.eclipse.jdt.core.dom.ExpressionStatement; //导入方法依赖的package包/类
public static boolean getAssignToVariableProposals(IInvocationContext context, ASTNode node, IProblemLocation[] locations, Collection<ICommandAccess> resultingCollections) {
Statement statement= ASTResolving.findParentStatement(node);
if (!(statement instanceof ExpressionStatement)) {
return false;
}
ExpressionStatement expressionStatement= (ExpressionStatement) statement;
Expression expression= expressionStatement.getExpression();
if (expression.getNodeType() == ASTNode.ASSIGNMENT) {
return false; // too confusing and not helpful
}
ITypeBinding typeBinding= expression.resolveTypeBinding();
typeBinding= Bindings.normalizeTypeBinding(typeBinding);
if (typeBinding == null) {
return false;
}
if (resultingCollections == null) {
return true;
}
// don't add if already added as quick fix
if (containsMatchingProblem(locations, IProblem.UnusedObjectAllocation))
return false;
ICompilationUnit cu= context.getCompilationUnit();
AssignToVariableAssistProposal localProposal= new AssignToVariableAssistProposal(cu, AssignToVariableAssistProposal.LOCAL, expressionStatement, typeBinding, 3);
localProposal.setCommandId(ASSIGN_TO_LOCAL_ID);
resultingCollections.add(localProposal);
ASTNode type= ASTResolving.findParentType(expression);
if (type != null) {
AssignToVariableAssistProposal fieldProposal= new AssignToVariableAssistProposal(cu, AssignToVariableAssistProposal.FIELD, expressionStatement, typeBinding, 2);
fieldProposal.setCommandId(ASSIGN_TO_FIELD_ID);
resultingCollections.add(fieldProposal);
}
return true;
}
示例7: splitStatementAndInitializer
import org.eclipse.jdt.core.dom.ExpressionStatement; //导入方法依赖的package包/类
private boolean splitStatementAndInitializer(ExpressionStatement storeStatement) {
Expression storeExpression = storeStatement.getExpression();
if (storeExpression instanceof Assignment) {
Assignment assignment = (Assignment) storeExpression;
this.unnecessaryStoreStatement = storeStatement;
this.storedVariable = assignment.getLeftHandSide();
this.unnecessaryStoreOperator = assignment.getOperator();
this.unnecessaryStoreExpression = assignment.getRightHandSide();
return true;
}
return false;
}
示例8: findClassInstanceCreationInAssignment
import org.eclipse.jdt.core.dom.ExpressionStatement; //导入方法依赖的package包/类
private ClassInstanceCreation findClassInstanceCreationInAssignment(SimpleName collectionName,
ExpressionStatement statement) throws EnumParsingException {
// this ExpressionStatement is expected to be a wrapped assignment
Expression expression = statement.getExpression();
if (expression instanceof Assignment) {
Assignment assignment = (Assignment) expression;
if (areNamesEqual(collectionName, findNameOfCollection(assignment.getLeftHandSide()))) {
if (assignment.getRightHandSide() instanceof ClassInstanceCreation) {
return (ClassInstanceCreation) assignment.getRightHandSide();
}
}
}
throw new EnumParsingException();
}
示例9: visit
import org.eclipse.jdt.core.dom.ExpressionStatement; //导入方法依赖的package包/类
/**
* The only expressions explicitly processed here are those used as statements. They are not
* processed via the normal visitation path, but rather explicitly as part of an expression
* statement.
*
* StatementExpression
*
* TODO: reduce the cyclomatic complexity.
*/
@Override
public boolean visit(final ExpressionStatement node)
{
if (node.getExpression() instanceof Assignment)
{
if (((Assignment) node.getExpression()).getLeftHandSide() instanceof ArrayAccess)
{
visitAssignArrayCell((Assignment) node.getExpression());
}
else
{
visitAssign((Assignment) node.getExpression());
}
}
else if (node.getExpression() instanceof ClassInstanceCreation)
{
visitExpression((ClassInstanceCreation) node.getExpression());
}
else if (node.getExpression() instanceof ConditionalExpression)
{
visitExpression((ConditionalExpression) node.getExpression());
}
else if (node.getExpression() instanceof MethodInvocation)
{
visitExpression((MethodInvocation) node.getExpression());
}
else if (node.getExpression() instanceof PostfixExpression)
{
if (((PostfixExpression) node.getExpression()).getOperand() instanceof ArrayAccess)
{
visitPostfixArrayCell((PostfixExpression) node.getExpression());
}
else
{
visitPostfix((PostfixExpression) node.getExpression());
}
}
else if (node.getExpression() instanceof PrefixExpression)
{
if (((PrefixExpression) node.getExpression()).getOperand() instanceof ArrayAccess)
{
visitPrefixArrayCell((PrefixExpression) node.getExpression());
}
else
{
visitPrefix((PrefixExpression) node.getExpression());
}
}
else if (node.getExpression() instanceof SuperMethodInvocation)
{
// uses an expression visitor for the arguments
visitExpression((SuperMethodInvocation) node.getExpression());
}
else if (node.getExpression() instanceof VariableDeclarationExpression)
{
// uses an expression visitor for the initializer
visitExpression((VariableDeclarationExpression) node.getExpression());
}
// do not visit children
return false;
}