Java Code Examples for org.eclipse.jdt.core.dom.ASTNode#SIMPLE_NAME

The following examples show how to use org.eclipse.jdt.core.dom.ASTNode#SIMPLE_NAME . 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: UnimplementedCodeFix.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static ASTNode getSelectedTypeNode(CompilationUnit root, IProblemLocation problem) {
	ASTNode selectedNode= problem.getCoveringNode(root);
	if (selectedNode == null)
		return null;

	if (selectedNode.getNodeType() == ASTNode.ANONYMOUS_CLASS_DECLARATION) { // bug 200016
		selectedNode= selectedNode.getParent();
	}

	if (selectedNode.getLocationInParent() == EnumConstantDeclaration.NAME_PROPERTY) {
		selectedNode= selectedNode.getParent();
	}
	if (selectedNode.getNodeType() == ASTNode.SIMPLE_NAME && selectedNode.getParent() instanceof AbstractTypeDeclaration) {
		return selectedNode.getParent();
	} else if (selectedNode.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
		return ((ClassInstanceCreation) selectedNode).getAnonymousClassDeclaration();
	} else if (selectedNode.getNodeType() == ASTNode.ENUM_CONSTANT_DECLARATION) {
		EnumConstantDeclaration enumConst= (EnumConstantDeclaration) selectedNode;
		if (enumConst.getAnonymousClassDeclaration() != null)
			return enumConst.getAnonymousClassDeclaration();
		return enumConst;
	} else {
		return null;
	}
}
 
Example 2
Source File: SnippetFinder.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
static boolean isLeftHandSideOfAssignment(ASTNode node) {
	Assignment assignment = (Assignment) ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
	if (assignment != null) {
		Expression leftHandSide = assignment.getLeftHandSide();
		if (leftHandSide == node) {
			return true;
		}
		if (ASTNodes.isParent(node, leftHandSide)) {
			switch (leftHandSide.getNodeType()) {
				case ASTNode.SIMPLE_NAME:
					return true;
				case ASTNode.FIELD_ACCESS:
					return node == ((FieldAccess) leftHandSide).getName();
				case ASTNode.QUALIFIED_NAME:
					return node == ((QualifiedName) leftHandSide).getName();
				case ASTNode.SUPER_FIELD_ACCESS:
					return node == ((SuperFieldAccess) leftHandSide).getName();
				default:
					return false;
			}
		}
	}
	return false;
}
 
Example 3
Source File: Bindings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the binding of the variable written in an Assignment.
 * @param assignment The assignment
 * @return The binding or <code>null</code> if no bindings are available.
 */
public static IVariableBinding getAssignedVariable(Assignment assignment) {
	Expression leftHand = assignment.getLeftHandSide();
	switch (leftHand.getNodeType()) {
		case ASTNode.SIMPLE_NAME:
			return (IVariableBinding) ((SimpleName) leftHand).resolveBinding();
		case ASTNode.QUALIFIED_NAME:
			return (IVariableBinding) ((QualifiedName) leftHand).getName().resolveBinding();
		case ASTNode.FIELD_ACCESS:
			return ((FieldAccess) leftHand).resolveFieldBinding();
		case ASTNode.SUPER_FIELD_ACCESS:
			return ((SuperFieldAccess) leftHand).resolveFieldBinding();
		default:
			return null;
	}
}
 
Example 4
Source File: IntroduceIndirectionRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static ASTNode checkNode(ASTNode node) {
	if (node == null)
		return null;
	if (node.getNodeType() == ASTNode.SIMPLE_NAME) {
		node= node.getParent();
	} else if (node.getNodeType() == ASTNode.EXPRESSION_STATEMENT) {
		node= ((ExpressionStatement) node).getExpression();
	}
	switch (node.getNodeType()) {
		case ASTNode.METHOD_INVOCATION:
		case ASTNode.METHOD_DECLARATION:
		case ASTNode.SUPER_METHOD_INVOCATION:
			return node;
	}
	return null;
}
 
Example 5
Source File: ExtractClassRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private Expression handleSimpleNameAssignment(ASTNode replaceNode, ParameterObjectFactory pof, String parameterName, AST ast, IJavaProject javaProject, boolean useSuper) {
	if (replaceNode instanceof Assignment) {
		Assignment assignment= (Assignment) replaceNode;
		Expression rightHandSide= assignment.getRightHandSide();
		if (rightHandSide.getNodeType() == ASTNode.SIMPLE_NAME) {
			SimpleName sn= (SimpleName) rightHandSide;
			IVariableBinding binding= ASTNodes.getVariableBinding(sn);
			if (binding != null && binding.isField()) {
				if (fDescriptor.getType().getFullyQualifiedName().equals(binding.getDeclaringClass().getQualifiedName())) {
					FieldInfo fieldInfo= getFieldInfo(binding.getName());
					if (fieldInfo != null && binding == fieldInfo.pi.getOldBinding()) {
						return pof.createFieldReadAccess(fieldInfo.pi, parameterName, ast, javaProject, useSuper, null);
					}
				}
			}
		}
	}
	return null;
}
 
Example 6
Source File: ReplaceInvocationsRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static ASTNode checkNode(ASTNode node) {
		if (node == null)
			return null;
		if (node.getNodeType() == ASTNode.SIMPLE_NAME) {
			node= node.getParent();
		} else if (node.getNodeType() == ASTNode.EXPRESSION_STATEMENT) {
			node= ((ExpressionStatement)node).getExpression();
		}
		switch(node.getNodeType()) {
			case ASTNode.METHOD_DECLARATION:
			case ASTNode.METHOD_INVOCATION:
// not yet...
//			case ASTNode.SUPER_METHOD_INVOCATION:
//			case ASTNode.CONSTRUCTOR_INVOCATION:
				return node;
		}
		return null;
	}
 
Example 7
Source File: RefactoringAvailabilityTester.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static ASTNode getInlineableMethodNode(ASTNode node, IJavaElement unit) {
	if (node == null)
		return null;
	switch (node.getNodeType()) {
		case ASTNode.SIMPLE_NAME:
			StructuralPropertyDescriptor locationInParent= node.getLocationInParent();
			if (locationInParent == MethodDeclaration.NAME_PROPERTY) {
				return node.getParent();
			} else if (locationInParent == MethodInvocation.NAME_PROPERTY
					|| locationInParent == SuperMethodInvocation.NAME_PROPERTY) {
				return unit instanceof ICompilationUnit ? node.getParent() : null; // don't start on invocations in binary
			}
			return null;
		case ASTNode.EXPRESSION_STATEMENT:
			node= ((ExpressionStatement)node).getExpression();
	}
	switch (node.getNodeType()) {
		case ASTNode.METHOD_DECLARATION:
			return node;
		case ASTNode.METHOD_INVOCATION:
		case ASTNode.SUPER_METHOD_INVOCATION:
		case ASTNode.CONSTRUCTOR_INVOCATION:
			return unit instanceof ICompilationUnit ? node : null; // don't start on invocations in binary
	}
	return null;
}
 
Example 8
Source File: SnippetFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean isLeftHandSideOfAssignment(ASTNode node) {
	Assignment assignment= (Assignment)ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
	if (assignment != null) {
		Expression leftHandSide= assignment.getLeftHandSide();
		if (leftHandSide == node) {
			return true;
		}
		if (ASTNodes.isParent(node, leftHandSide)) {
			switch (leftHandSide.getNodeType()) {
				case ASTNode.SIMPLE_NAME:
					return true;
				case ASTNode.FIELD_ACCESS:
					return node == ((FieldAccess)leftHandSide).getName();
				case ASTNode.QUALIFIED_NAME:
					return node == ((QualifiedName)leftHandSide).getName();
				case ASTNode.SUPER_FIELD_ACCESS:
					return node == ((SuperFieldAccess)leftHandSide).getName();
				default:
					return false;
			}
		}
	}
	return false;
}
 
Example 9
Source File: JavadocHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static Object getVariableBindingConstValue(ASTNode node, IField field) {
	if (node != null && node.getNodeType() == ASTNode.SIMPLE_NAME) {
		IBinding binding= ((SimpleName) node).resolveBinding();
		if (binding != null && binding.getKind() == IBinding.VARIABLE) {
			IVariableBinding variableBinding= (IVariableBinding) binding;
			if (field.equals(variableBinding.getJavaElement())) {
				return variableBinding.getConstantValue();
			}
		}
	}
	return null;
}
 
Example 10
Source File: NullAnnotationsRewriteOperations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static String findAffectedParameterName(ASTNode selectedNode) {
	VariableDeclaration argDecl= (selectedNode instanceof VariableDeclaration) ? (VariableDeclaration) selectedNode : (VariableDeclaration) ASTNodes.getParent(selectedNode,
			VariableDeclaration.class);
	if (argDecl != null)
		return argDecl.getName().getIdentifier();
	if (selectedNode.getNodeType() == ASTNode.SIMPLE_NAME) {
		IBinding binding= ((SimpleName) selectedNode).resolveBinding();
		if (binding.getKind() == IBinding.VARIABLE && ((IVariableBinding) binding).isParameter())
			return ((SimpleName) selectedNode).getIdentifier();
	}
	return null;
}
 
Example 11
Source File: AccessAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Expression getReceiver(Expression expression) {
	int type= expression.getNodeType();
	switch(type) {
		case ASTNode.SIMPLE_NAME:
			return null;
		case ASTNode.QUALIFIED_NAME:
			return ((QualifiedName)expression).getQualifier();
		case ASTNode.FIELD_ACCESS:
			return ((FieldAccess)expression).getExpression();
		case ASTNode.PARENTHESIZED_EXPRESSION:
			return getReceiver(((ParenthesizedExpression)expression).getExpression());
	}
	return null;
}
 
Example 12
Source File: TreedUtils.java    From compiler with Apache License 2.0 5 votes vote down vote up
public static String buildASTLabel(ASTNode node) {
	String label = node.getClass().getSimpleName();
	if (node instanceof Expression) {
		if (node.getClass().getSimpleName().endsWith("Literal")) {
			return label + "(" + node.toString() + ")";
		}
		int type = node.getNodeType();
		switch (type) {
		case ASTNode.INFIX_EXPRESSION:
			return label + "(" + ((InfixExpression) node).getOperator().toString() + ")";
		case ASTNode.SIMPLE_NAME:
			return label + "(" + node.toString() + ")";
		case ASTNode.POSTFIX_EXPRESSION:
			return label + "(" + ((PostfixExpression) node).getOperator().toString() + ")";
		case ASTNode.PREFIX_EXPRESSION:
			return label + "(" + ((PrefixExpression) node).getOperator().toString() + ")";
		default:
			break;
		}
	} else if (node instanceof Modifier) {
		return label + "(" + node.toString() + ")";
	} else if (node instanceof Type) {
		if (node instanceof PrimitiveType)
			return label + "(" + node.toString() + ")";
	} else if (node instanceof TextElement) {
		return label + "(" + node.toString() + ")";
	} else if (node instanceof TagElement) {
		String tag = ((TagElement) node).getTagName();
		if (tag == null)
			return label;
		return label + "(" + tag + ")";
	}
	return label;
}
 
Example 13
Source File: TreedUtils.java    From compiler with Apache License 2.0 5 votes vote down vote up
public static char buildLabelForVector(ASTNode node) {
	char label = (char) node.getNodeType();
	if (node instanceof Expression) {
		if (node.getClass().getSimpleName().endsWith("Literal")) {
			return (char) (label | (node.toString().hashCode() << 7));
		}
		int type = node.getNodeType();
		switch (type) {
		case ASTNode.INFIX_EXPRESSION:
			return (char) (label | (((InfixExpression) node).getOperator().toString().hashCode() << 7));
		case ASTNode.SIMPLE_NAME:
			return (char) (label | (node.toString().hashCode() << 7));
		case ASTNode.POSTFIX_EXPRESSION:
			return (char) (label | (((PostfixExpression) node).getOperator().toString().hashCode() << 7));
		case ASTNode.PREFIX_EXPRESSION:
			return (char) (label | (((PrefixExpression) node).getOperator().toString().hashCode() << 7));
		default:
			break;
		}
	} else if (node instanceof Modifier) {
		return (char) (label | (node.toString().hashCode() << 7));
	} else if (node instanceof Type) {
		if (node instanceof PrimitiveType)
			return (char) (label | (node.toString().hashCode() << 7));
	} else if (node instanceof TextElement) {
		return (char) (label | (node.toString().hashCode() << 7));
	} else if (node instanceof TagElement) {
		String tag = ((TagElement) node).getTagName();
		if (tag != null)
			return (char) (label | (((TagElement) node).getTagName().hashCode() << 7));
	}
	return label;
}
 
Example 14
Source File: AccessAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private Expression getReceiver(Expression expression) {
	int type = expression.getNodeType();
	switch (type) {
		case ASTNode.SIMPLE_NAME:
			return null;
		case ASTNode.QUALIFIED_NAME:
			return ((QualifiedName) expression).getQualifier();
		case ASTNode.FIELD_ACCESS:
			return ((FieldAccess) expression).getExpression();
		case ASTNode.PARENTHESIZED_EXPRESSION:
			return getReceiver(((ParenthesizedExpression) expression).getExpression());
	}
	return null;
}
 
Example 15
Source File: RefactoringAvailabilityTester.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static ASTNode getInlineableMethodNode(ASTNode node, IJavaElement unit) {
	if (node == null) {
		return null;
	}
	switch (node.getNodeType()) {
		case ASTNode.SIMPLE_NAME:
			StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
			if (locationInParent == MethodDeclaration.NAME_PROPERTY) {
				return node.getParent();
			} else if (locationInParent == MethodInvocation.NAME_PROPERTY || locationInParent == SuperMethodInvocation.NAME_PROPERTY) {
				return unit instanceof ICompilationUnit ? node.getParent() : null; // don't start on invocations in binary
			}
			return null;
		case ASTNode.EXPRESSION_STATEMENT:
			node = ((ExpressionStatement) node).getExpression();
	}
	switch (node.getNodeType()) {
		case ASTNode.METHOD_DECLARATION:
			return node;
		case ASTNode.METHOD_INVOCATION:
		case ASTNode.SUPER_METHOD_INVOCATION:
		case ASTNode.CONSTRUCTOR_INVOCATION:
			return unit instanceof ICompilationUnit ? node : null; // don't start on invocations in binary
	}
	return null;
}
 
Example 16
Source File: JDTUtils.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static Object getVariableBindingConstValue(ASTNode node, IField field) {
	if (node != null && node.getNodeType() == ASTNode.SIMPLE_NAME) {
		IBinding binding = ((SimpleName) node).resolveBinding();
		if (binding != null && binding.getKind() == IBinding.VARIABLE) {
			IVariableBinding variableBinding = (IVariableBinding) binding;
			if (field.equals(variableBinding.getJavaElement())) {
				return variableBinding.getConstantValue();
			}
		}
	}
	return null;
}
 
Example 17
Source File: ChangeTypeRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Determines what kind of ASTNode has been selected.
 * @param node the node
 * @return  A non-null String containing an error message
 * is returned if the ChangeTypeRefactoring refactoring cannot be applied to the selected ASTNode.
 * A return value of null indicates a valid selection.
 */
private String determineSelection(ASTNode node) {
	if (node == null) {
		return RefactoringCoreMessages.ChangeTypeRefactoring_invalidSelection;
	} else {

		if (DEBUG) System.out.println("node nodeType= " + node.getClass().getName()); //$NON-NLS-1$
		if (DEBUG) System.out.println("parent nodeType= " + node.getParent().getClass().getName()); //$NON-NLS-1$
		if (DEBUG) System.out.println("GrandParent nodeType= " + node.getParent().getParent().getClass().getName()); //$NON-NLS-1$

		ASTNode parent= node.getParent();
		ASTNode grandParent= parent.getParent();
		if (grandParent == null)
			return nodeTypeNotSupported();

		// adjustment needed if part of a parameterized type is selected
		if (grandParent.getNodeType() == ASTNode.PARAMETERIZED_TYPE){
			node= grandParent;
		}

		// adjustment needed if part of a qualified name is selected
		ASTNode current= null;
		if (node.getNodeType() == ASTNode.QUALIFIED_NAME){
			current= node;
			while (current.getNodeType() == ASTNode.QUALIFIED_NAME){
				current= current.getParent();
			}
			if (current.getNodeType() != ASTNode.SIMPLE_TYPE){
				return nodeTypeNotSupported();
			}
			node= current.getParent();
		} else if (parent.getNodeType() == ASTNode.QUALIFIED_NAME){
			current= parent;
			while (current.getNodeType() == ASTNode.QUALIFIED_NAME){
				current= current.getParent();
			}
			if (current.getNodeType() != ASTNode.SIMPLE_TYPE){
				return nodeTypeNotSupported();
			}
			node= current.getParent();
		}

		fObject= node.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
		switch (node.getNodeType()) {
			case ASTNode.SIMPLE_NAME :
				return simpleNameSelected((SimpleName)node);
			case ASTNode.VARIABLE_DECLARATION_STATEMENT :
				return variableDeclarationStatementSelected((VariableDeclarationStatement) node);
			case ASTNode.FIELD_DECLARATION :
				return fieldDeclarationSelected((FieldDeclaration) node);
			case ASTNode.SINGLE_VARIABLE_DECLARATION :
				return singleVariableDeclarationSelected((SingleVariableDeclaration) node);
			case ASTNode.PARAMETERIZED_TYPE:
				return parameterizedTypeSelected((ParameterizedType) node);
			default :
				return nodeTypeNotSupported();
		}
	}
}
 
Example 18
Source File: Bindings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Resolve the binding (<em>not</em> the type binding) for the expression or a nested expression
 * (e.g. nested in parentheses, cast, ...).
 * 
 * @param expression an expression node
 * @param goIntoCast iff <code>true</code>, go into a CastExpression's expression to resolve
 * @return the expression binding, or <code>null</code> if the expression has no binding or the
 *         binding could not be resolved
 * 
 * @see StubUtility#getVariableNameSuggestions(int, IJavaProject, ITypeBinding, Expression, java.util.Collection)
 * @since 3.5
 */
public static IBinding resolveExpressionBinding(Expression expression, boolean goIntoCast) {
	//TODO: search for callers of resolve*Binding() methods and replace with call to this method
	
	// similar to StubUtility#getVariableNameSuggestions(int, IJavaProject, ITypeBinding, Expression, Collection)
	switch (expression.getNodeType()) {
		case ASTNode.SIMPLE_NAME:
		case ASTNode.QUALIFIED_NAME:
			return ((Name) expression).resolveBinding();
			
		case ASTNode.FIELD_ACCESS:
			return ((FieldAccess) expression).resolveFieldBinding();
		case ASTNode.SUPER_FIELD_ACCESS:
			return ((SuperFieldAccess) expression).resolveFieldBinding();
			
		case ASTNode.METHOD_INVOCATION:
			return ((MethodInvocation) expression).resolveMethodBinding();
		case ASTNode.SUPER_METHOD_INVOCATION:
			return ((SuperMethodInvocation) expression).resolveMethodBinding();
		case ASTNode.CLASS_INSTANCE_CREATION:
			return ((ClassInstanceCreation) expression).resolveConstructorBinding();
			
		case ASTNode.MARKER_ANNOTATION:
		case ASTNode.SINGLE_MEMBER_ANNOTATION:
		case ASTNode.NORMAL_ANNOTATION:
			return ((Annotation) expression).resolveAnnotationBinding();
			
		case ASTNode.ARRAY_ACCESS:
			return resolveExpressionBinding(((ArrayAccess) expression).getArray(), goIntoCast);
		case ASTNode.CAST_EXPRESSION:
			if (goIntoCast) {
				return resolveExpressionBinding(((CastExpression) expression).getExpression(), true);
			} else {
				return null;
			}
		case ASTNode.PARENTHESIZED_EXPRESSION:
			return resolveExpressionBinding(((ParenthesizedExpression) expression).getExpression(), goIntoCast);
		case ASTNode.PREFIX_EXPRESSION:
			return resolveExpressionBinding(((PrefixExpression) expression).getOperand(), goIntoCast);
		case ASTNode.POSTFIX_EXPRESSION:
			return resolveExpressionBinding(((PostfixExpression) expression).getOperand(), goIntoCast);
		default:
			return null;
	}
}
 
Example 19
Source File: CompilationUnitBuilder.java    From j2cl with Apache License 2.0 4 votes vote down vote up
private Expression convert(org.eclipse.jdt.core.dom.Expression expression) {
  switch (expression.getNodeType()) {
    case ASTNode.ARRAY_ACCESS:
      return convert((org.eclipse.jdt.core.dom.ArrayAccess) expression);
    case ASTNode.ARRAY_CREATION:
      return convert((org.eclipse.jdt.core.dom.ArrayCreation) expression);
    case ASTNode.ARRAY_INITIALIZER:
      return convert((org.eclipse.jdt.core.dom.ArrayInitializer) expression);
    case ASTNode.ASSIGNMENT:
      return convert((org.eclipse.jdt.core.dom.Assignment) expression);
    case ASTNode.BOOLEAN_LITERAL:
      return convert((org.eclipse.jdt.core.dom.BooleanLiteral) expression);
    case ASTNode.CAST_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.CastExpression) expression);
    case ASTNode.CHARACTER_LITERAL:
      return convert((org.eclipse.jdt.core.dom.CharacterLiteral) expression);
    case ASTNode.CLASS_INSTANCE_CREATION:
      return convert((org.eclipse.jdt.core.dom.ClassInstanceCreation) expression);
    case ASTNode.CONDITIONAL_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.ConditionalExpression) expression);
    case ASTNode.EXPRESSION_METHOD_REFERENCE:
      return convert((org.eclipse.jdt.core.dom.ExpressionMethodReference) expression);
    case ASTNode.CREATION_REFERENCE:
      return convert((org.eclipse.jdt.core.dom.CreationReference) expression);
    case ASTNode.TYPE_METHOD_REFERENCE:
      return convert((org.eclipse.jdt.core.dom.TypeMethodReference) expression);
    case ASTNode.SUPER_METHOD_REFERENCE:
      return convert((org.eclipse.jdt.core.dom.SuperMethodReference) expression);
    case ASTNode.FIELD_ACCESS:
      return convert((org.eclipse.jdt.core.dom.FieldAccess) expression);
    case ASTNode.INFIX_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.InfixExpression) expression);
    case ASTNode.INSTANCEOF_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.InstanceofExpression) expression);
    case ASTNode.LAMBDA_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.LambdaExpression) expression);
    case ASTNode.METHOD_INVOCATION:
      return convert((org.eclipse.jdt.core.dom.MethodInvocation) expression);
    case ASTNode.NULL_LITERAL:
      return NullLiteral.get();
    case ASTNode.NUMBER_LITERAL:
      return convert((org.eclipse.jdt.core.dom.NumberLiteral) expression);
    case ASTNode.PARENTHESIZED_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.ParenthesizedExpression) expression);
    case ASTNode.POSTFIX_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.PostfixExpression) expression);
    case ASTNode.PREFIX_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.PrefixExpression) expression);
    case ASTNode.QUALIFIED_NAME:
      return convert((org.eclipse.jdt.core.dom.QualifiedName) expression);
    case ASTNode.SIMPLE_NAME:
      return convert((org.eclipse.jdt.core.dom.SimpleName) expression);
    case ASTNode.STRING_LITERAL:
      return convert((org.eclipse.jdt.core.dom.StringLiteral) expression);
    case ASTNode.SUPER_FIELD_ACCESS:
      return convert((org.eclipse.jdt.core.dom.SuperFieldAccess) expression);
    case ASTNode.SUPER_METHOD_INVOCATION:
      return convert((org.eclipse.jdt.core.dom.SuperMethodInvocation) expression);
    case ASTNode.THIS_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.ThisExpression) expression);
    case ASTNode.TYPE_LITERAL:
      return convert((org.eclipse.jdt.core.dom.TypeLiteral) expression);
    case ASTNode.VARIABLE_DECLARATION_EXPRESSION:
      return convert((org.eclipse.jdt.core.dom.VariableDeclarationExpression) expression);
    default:
      throw internalCompilerError(
          "Unexpected type for Expression: %s", expression.getClass().getName());
  }
}