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

The following examples show how to use org.eclipse.jdt.core.dom.ASTNode#BOOLEAN_LITERAL . 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: ExtractTempRefactoring.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private boolean isLiteralNodeSelected() throws JavaModelException {
	IExpressionFragment fragment = getSelectedExpression();
	if (fragment == null) {
		return false;
	}
	Expression expression = fragment.getAssociatedExpression();
	if (expression == null) {
		return false;
	}
	switch (expression.getNodeType()) {
		case ASTNode.BOOLEAN_LITERAL:
		case ASTNode.CHARACTER_LITERAL:
		case ASTNode.NULL_LITERAL:
		case ASTNode.NUMBER_LITERAL:
			return true;

		default:
			return false;
	}
}
 
Example 2
Source File: ExtractMethodAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
public boolean isLiteralNodeSelected() {
	ASTNode[] nodes = getSelectedNodes();
	if (nodes.length != 1) {
		return false;
	}
	ASTNode node = nodes[0];
	switch (node.getNodeType()) {
		case ASTNode.BOOLEAN_LITERAL:
		case ASTNode.CHARACTER_LITERAL:
		case ASTNode.NULL_LITERAL:
		case ASTNode.NUMBER_LITERAL:
			return true;

		default:
			return false;
	}
}
 
Example 3
Source File: ExtractConstantRefactoring.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private boolean isLiteralNodeSelected() throws JavaModelException {
	IExpressionFragment fragment = getSelectedExpression();
	if (fragment == null) {
		return false;
	}
	Expression expression = fragment.getAssociatedExpression();
	if (expression == null) {
		return false;
	}
	switch (expression.getNodeType()) {
		case ASTNode.BOOLEAN_LITERAL:
		case ASTNode.CHARACTER_LITERAL:
		case ASTNode.NULL_LITERAL:
		case ASTNode.NUMBER_LITERAL:
			return true;

		default:
			return false;
	}
}
 
Example 4
Source File: ExtractTempRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private boolean isLiteralNodeSelected() throws JavaModelException {
	IExpressionFragment fragment= getSelectedExpression();
	if (fragment == null)
		return false;
	Expression expression= fragment.getAssociatedExpression();
	if (expression == null)
		return false;
	switch (expression.getNodeType()) {
		case ASTNode.BOOLEAN_LITERAL:
		case ASTNode.CHARACTER_LITERAL:
		case ASTNode.NULL_LITERAL:
		case ASTNode.NUMBER_LITERAL:
			return true;

		default:
			return false;
	}
}
 
Example 5
Source File: ExtractMethodAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public boolean isLiteralNodeSelected() {
	ASTNode[] nodes= getSelectedNodes();
	if (nodes.length != 1)
		return false;
	ASTNode node= nodes[0];
	switch (node.getNodeType()) {
		case ASTNode.BOOLEAN_LITERAL :
		case ASTNode.CHARACTER_LITERAL :
		case ASTNode.NULL_LITERAL :
		case ASTNode.NUMBER_LITERAL :
			return true;

		default :
			return false;
	}
}
 
Example 6
Source File: ExtractConstantRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private boolean isLiteralNodeSelected() throws JavaModelException {
	IExpressionFragment fragment= getSelectedExpression();
	if (fragment == null)
		return false;
	Expression expression= fragment.getAssociatedExpression();
	if (expression == null)
		return false;
	switch (expression.getNodeType()) {
		case ASTNode.BOOLEAN_LITERAL :
		case ASTNode.CHARACTER_LITERAL :
		case ASTNode.NULL_LITERAL :
		case ASTNode.NUMBER_LITERAL :
			return true;

		default :
			return false;
	}
}
 
Example 7
Source File: JavaCodeMiningASTVisitor.java    From jdt-codemining with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean isLiteral(Expression expression) {
	switch (expression.getNodeType()) {
	case ASTNode.BOOLEAN_LITERAL:
	case ASTNode.CHARACTER_LITERAL:
	case ASTNode.NULL_LITERAL:
	case ASTNode.NUMBER_LITERAL:
	case ASTNode.STRING_LITERAL:
		return true;

	default:
		return false;
	}
}
 
Example 8
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());
  }
}
 
Example 9
Source File: ASTNodes.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isLiteral(Expression expression) {
	int type= expression.getNodeType();
	return type == ASTNode.BOOLEAN_LITERAL || type == ASTNode.CHARACTER_LITERAL || type == ASTNode.NULL_LITERAL ||
		type == ASTNode.NUMBER_LITERAL || type == ASTNode.STRING_LITERAL || type == ASTNode.TYPE_LITERAL;
}