Java Code Examples for org.eclipse.jdt.core.dom.Expression#toString()

The following examples show how to use org.eclipse.jdt.core.dom.Expression#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractExpression.java    From RefactoringMiner with MIT License 6 votes vote down vote up
public AbstractExpression(CompilationUnit cu, String filePath, Expression expression, CodeElementType codeElementType) {
  	this.locationInfo = new LocationInfo(cu, filePath, expression, codeElementType);
  	Visitor visitor = new Visitor(cu, filePath);
  	expression.accept(visitor);
this.variables = visitor.getVariables();
this.types = visitor.getTypes();
this.variableDeclarations = visitor.getVariableDeclarations();
this.methodInvocationMap = visitor.getMethodInvocationMap();
this.anonymousClassDeclarations = visitor.getAnonymousClassDeclarations();
this.stringLiterals = visitor.getStringLiterals();
this.numberLiterals = visitor.getNumberLiterals();
this.nullLiterals = visitor.getNullLiterals();
this.booleanLiterals = visitor.getBooleanLiterals();
this.typeLiterals = visitor.getTypeLiterals();
this.creationMap = visitor.getCreationMap();
this.infixOperators = visitor.getInfixOperators();
this.arrayAccesses = visitor.getArrayAccesses();
this.prefixExpressions = visitor.getPrefixExpressions();
this.postfixExpressions = visitor.getPostfixExpressions();
this.arguments = visitor.getArguments();
this.ternaryOperatorExpressions = visitor.getTernaryOperatorExpressions();
this.lambdas = visitor.getLambdas();
  	this.expression = expression.toString();
  	this.owner = null;
  }
 
Example 2
Source File: SequenceExporter.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean preNext(MethodInvocation curElement) {
	// Sequence.fromActor call
	if (curElement.arguments().size() == 2) {
		return true;
	}

	// Sequence.assertSend call
	Expression sender = (Expression) curElement.arguments().get(0);
	String senderName = sender.toString();

	Expression target = (Expression) curElement.arguments().get(2);
	String targetName = target.toString();

	Expression signal = (Expression) curElement.arguments().get(1);
	String signalExpr = signal.resolveTypeBinding().getQualifiedName();

	List<String> lifelineNames = compiler.getLifelineNames();
	if (lifelineNames.contains(senderName) || lifelineNames.contains(targetName)) {
		compiler.println(senderName + "->" + targetName + " : " + signalExpr);
	}
	return true;
}
 
Example 3
Source File: Invocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static ITypeBinding[] getInferredTypeArguments(Expression invocation) {
	IMethodBinding methodBinding;
	switch (invocation.getNodeType()) {
		case ASTNode.METHOD_INVOCATION:
			methodBinding= ((MethodInvocation) invocation).resolveMethodBinding();
			return methodBinding == null ? null : methodBinding.getTypeArguments();
		case ASTNode.SUPER_METHOD_INVOCATION:
			methodBinding= ((SuperMethodInvocation) invocation).resolveMethodBinding();
			return methodBinding == null ? null : methodBinding.getTypeArguments();
		case ASTNode.CLASS_INSTANCE_CREATION:
			Type type= ((ClassInstanceCreation) invocation).getType();
			ITypeBinding typeBinding= type.resolveBinding();
			return typeBinding == null ? null : typeBinding.getTypeArguments();
			
		default:
			throw new IllegalArgumentException(invocation.toString());
	}
}
 
Example 4
Source File: Invocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static ListRewrite getInferredTypeArgumentsRewrite(ASTRewrite rewrite, Expression invocation) {
	switch (invocation.getNodeType()) {
		case ASTNode.METHOD_INVOCATION:
			return rewrite.getListRewrite(invocation, MethodInvocation.TYPE_ARGUMENTS_PROPERTY);
		case ASTNode.SUPER_METHOD_INVOCATION:
			return rewrite.getListRewrite(invocation, SuperMethodInvocation.TYPE_ARGUMENTS_PROPERTY);
		case ASTNode.CLASS_INSTANCE_CREATION:
			Type type= ((ClassInstanceCreation) invocation).getType();
			return rewrite.getListRewrite(type, ParameterizedType.TYPE_ARGUMENTS_PROPERTY);
			
		default:
			throw new IllegalArgumentException(invocation.toString());
	}
}
 
Example 5
Source File: ExpressionVariable.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public ExpressionVariable(Expression expression){
	super(expression.resolveTypeBinding());
	fSource= expression.toString();
	ICompilationUnit cu= ASTCreator.getCu(expression);
	Assert.isNotNull(cu);
	fRange= new CompilationUnitRange(cu, expression);
	fExpressionBinding= resolveBinding(expression);
	fExpressionType= expression.getNodeType();
}
 
Example 6
Source File: LoopFragmentExporter.java    From txtUML with Eclipse Public License 1.0 4 votes vote down vote up
protected String updaterConverter(Expression updater) {
	if (updater.toString().equals("++i") || updater.toString().equals("i++")) {
		return "i+1";
	}
	return updater.toString();
}