org.eclipse.jdt.core.dom.NumberLiteral Java Examples

The following examples show how to use org.eclipse.jdt.core.dom.NumberLiteral. 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: BaseTranslator.java    From junion with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public Expression getLongAddress(MethodInvocation mi) {
	Expression indexExpr = getLongAddressBase(mi);
	
	NumberLiteral lit = (NumberLiteral)mi.arguments().get(2);
	if(offset != Integer.parseInt(lit.getToken()))
		throw new IllegalArgumentException("offset != " + lit);
	
	Expression args;
	if(offset == 0) args = indexExpr;
	else {
		InfixExpression add = ast.newInfixExpression();
		add.setOperator(InfixExpression.Operator.PLUS);
		add.setLeftOperand(indexExpr);
		add.setRightOperand(returnInt(offset));
		args = add;
	}
	return args;
}
 
Example #2
Source File: UpperEllQuickfix.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ASTVisitor handleGetCorrectingASTVisitor(final IRegion lineInfo,
        final int markerStartOffset) {
  return new ASTVisitor() {

    @Override
    public boolean visit(NumberLiteral node) {
      if (containsPosition(node, markerStartOffset)) {

        String token = node.getToken();
        if (token.endsWith("l")) { //$NON-NLS-1$
          token = token.replace('l', 'L');
          node.setToken(token);
        }
      }
      return true;
    }
  };
}
 
Example #3
Source File: UpperEllQuickFix.java    From vscode-checkstyle with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ASTVisitor getCorrectingASTVisitor(IRegion lineInfo, int markerStartOffset) {
    return new ASTVisitor() {

        @Override
        public boolean visit(NumberLiteral node) {
            if (containsPosition(node, markerStartOffset)) {

                String token = node.getToken();
                if (token.endsWith("l")) { //$NON-NLS-1$
                    token = token.replace('l', 'L');
                    node.setToken(token);
                }
            }
            return true;
        }
    };
}
 
Example #4
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean visit(final ArrayAccess node) {
  Expression _index = node.getIndex();
  if ((_index instanceof NumberLiteral)) {
    node.getArray().accept(this);
    this.appendToBuffer(".get(");
    node.getIndex().accept(this);
    this.appendToBuffer(")");
  } else {
    final String arrayname = this.computeArrayName(node);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{val _rdIndx_");
    _builder.append(arrayname);
    _builder.append("=");
    this.appendToBuffer(_builder.toString());
    node.getIndex().accept(this);
    this.appendSpaceToBuffer();
    node.getArray().accept(this);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append(".get(_rdIndx_");
    _builder_1.append(arrayname);
    _builder_1.append(")}");
    this.appendToBuffer(_builder_1.toString());
  }
  return false;
}
 
Example #5
Source File: ImplementationSmellDetector.java    From DesigniteJava with Apache License 2.0 6 votes vote down vote up
private boolean isNotZeroOrOne(NumberLiteral singleNumberLiteral) {
	String numberToString = singleNumberLiteral.toString().toLowerCase().replaceAll("_", "");
	double literalValue = 0.0;
	try {
		// hex case
		if(numberToString.startsWith("0x")) {
			literalValue = (double)(Long.parseLong(numberToString.replaceAll("0x", "").replaceAll("l", ""),16));
		// long case
		} else if(numberToString.endsWith("l")) {
			literalValue = (double)(Long.parseLong(numberToString.replaceAll("l", "")));
		// float case
		} else if(numberToString.endsWith("f")) {
			literalValue = Float.parseFloat(numberToString.replaceAll("f", ""));
		}
		// double case
		else {
			literalValue = Double.parseDouble(numberToString);
		}
	} catch (NumberFormatException ex) {
		String logMessage = "Exception while parsing literal number (during Magic Number detection). " + ex.getMessage();
		Logger.log(logMessage);
		literalValue = 0.0;
	}
	return literalValue != 0.0 && literalValue != 1.0;
}
 
Example #6
Source File: ASTNodeMatcher.java    From JDeodorant with MIT License 6 votes vote down vote up
protected boolean isTypeHolder(Object o) {
	if(o.getClass().equals(MethodInvocation.class) || o.getClass().equals(SuperMethodInvocation.class)			
			|| o.getClass().equals(NumberLiteral.class) || o.getClass().equals(StringLiteral.class)
			|| o.getClass().equals(CharacterLiteral.class) || o.getClass().equals(BooleanLiteral.class)
			|| o.getClass().equals(TypeLiteral.class) || o.getClass().equals(NullLiteral.class)
			|| o.getClass().equals(ArrayCreation.class)
			|| o.getClass().equals(ClassInstanceCreation.class)
			|| o.getClass().equals(ArrayAccess.class) || o.getClass().equals(FieldAccess.class)
			|| o.getClass().equals(SuperFieldAccess.class) || o.getClass().equals(ParenthesizedExpression.class)
			|| o.getClass().equals(SimpleName.class) || o.getClass().equals(QualifiedName.class)
			|| o.getClass().equals(CastExpression.class) || o.getClass().equals(InfixExpression.class)
			|| o.getClass().equals(PrefixExpression.class) || o.getClass().equals(InstanceofExpression.class)
			|| o.getClass().equals(ThisExpression.class) || o.getClass().equals(ConditionalExpression.class))
		return true;
	return false;
}
 
Example #7
Source File: SwitchControlCase.java    From JDeodorant with MIT License 6 votes vote down vote up
private String getLiteralValue(Expression expression)
{
	if (expression instanceof NumberLiteral)
	{
		return ((NumberLiteral)expression).getToken();
	}
	else if (expression instanceof CharacterLiteral)
	{
		return String.valueOf(((CharacterLiteral)expression).charValue());
	}
	else if (expression instanceof StringLiteral)
	{
		return ((StringLiteral)expression).getLiteralValue();
	}
	else
	{
		return null;
	}
}
 
Example #8
Source File: GenerateForLoopAssistProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Generates a {@link VariableDeclarationExpression}, which initializes the loop variable to
 * iterate over an array.
 * 
 * @param ast the current {@link AST} instance
 * @param loopVariableName the name of the variable which should be initialized
 * @return a filled {@link VariableDeclarationExpression}, declaring a int variable, which is
 *         initializes with 0
 */
private VariableDeclarationExpression getForInitializer(AST ast, SimpleName loopVariableName) {
	// initializing fragment
	VariableDeclarationFragment firstDeclarationFragment= ast.newVariableDeclarationFragment();
	firstDeclarationFragment.setName(loopVariableName);
	NumberLiteral startIndex= ast.newNumberLiteral();
	firstDeclarationFragment.setInitializer(startIndex);

	// declaration
	VariableDeclarationExpression variableDeclaration= ast.newVariableDeclarationExpression(firstDeclarationFragment);
	PrimitiveType variableType= ast.newPrimitiveType(PrimitiveType.INT);
	variableDeclaration.setType(variableType);

	return variableDeclaration;
}
 
Example #9
Source File: Visitor.java    From RefactoringMiner with MIT License 5 votes vote down vote up
public boolean visit(NumberLiteral node) {
	numberLiterals.add(node.toString());
	if(current.getUserObject() != null) {
		AnonymousClassDeclarationObject anonymous = (AnonymousClassDeclarationObject)current.getUserObject();
		anonymous.getNumberLiterals().add(node.toString());
	}
	return super.visit(node);
}
 
Example #10
Source File: ConvertForLoopOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isOneLiteral(Expression expression) {
	if (!(expression instanceof NumberLiteral))
		return false;

	NumberLiteral literal= (NumberLiteral)expression;
	return LITERAL_1.equals(literal.getToken());
}
 
Example #11
Source File: InstanceOfLiteral.java    From JDeodorant with MIT License 5 votes vote down vote up
public boolean instanceOf(Expression expression) {
	if(expression instanceof BooleanLiteral || expression instanceof CharacterLiteral || expression instanceof StringLiteral ||
			expression instanceof NullLiteral || expression instanceof NumberLiteral || expression instanceof TypeLiteral)
		return true;
	else
		return false;
}
 
Example #12
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(final NumberLiteral node) {
  String value = node.getToken();
  if ((value.startsWith("0x") || value.startsWith("0X"))) {
    int _length = value.length();
    int _minus = (_length - 1);
    final char lastChar = value.charAt(_minus);
    String _lowerCase = Character.valueOf(lastChar).toString().toLowerCase();
    boolean _equals = Objects.equal("l", _lowerCase);
    if (_equals) {
      int _length_1 = value.length();
      int _minus_1 = (_length_1 - 1);
      String _substring = value.substring(0, _minus_1);
      String _plus = (_substring + "#");
      String _plus_1 = (_plus + Character.valueOf(lastChar));
      value = _plus_1;
    }
    final int binExponent = value.indexOf("p");
    if ((binExponent >= 2)) {
      boolean _endsWith = value.endsWith("f");
      if (_endsWith) {
        String _string = Float.valueOf(value).toString();
        String _plus_2 = (_string + "f");
        value = _plus_2;
      } else {
        value = Double.valueOf(value).toString();
      }
    }
  }
  this.appendToBuffer(value);
  return false;
}
 
Example #13
Source File: ConvertForLoopOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IVariableBinding getIndexBindingFromFragment(VariableDeclarationFragment fragment) {
	Expression initializer= fragment.getInitializer();
	if (!(initializer instanceof NumberLiteral))
		return null;

	NumberLiteral number= (NumberLiteral)initializer;
	if (!LITERAL_0.equals(number.getToken()))
		return null;

	return (IVariableBinding)fragment.getName().resolveBinding();
}
 
Example #14
Source File: GetterSetterUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static Expression createInfixInvocationFromPostPrefixExpression(InfixExpression.Operator operator, Expression getterExpression, AST ast, ITypeBinding variableType, boolean is50OrHigher) {
	InfixExpression infix= ast.newInfixExpression();
	infix.setLeftOperand(getterExpression);
	infix.setOperator(operator);
	NumberLiteral number= ast.newNumberLiteral();
	number.setToken("1"); //$NON-NLS-1$
	infix.setRightOperand(number);
	ITypeBinding infixType= infix.resolveTypeBinding();
	return createNarrowCastIfNessecary(infix, infixType, ast, variableType, is50OrHigher);
}
 
Example #15
Source File: ImplementationSmellDetector.java    From DesigniteJava with Apache License 2.0 5 votes vote down vote up
private void hasMagicNumbers() {
	NumberLiteralVisitor visitor = new NumberLiteralVisitor();
	methodMetrics.getMethod().getMethodDeclaration().accept(visitor);
	List<NumberLiteral> literals = visitor.getNumberLiteralsExpressions();
	
	if( literals.size() < 1 ) {
		return;
	}
	
	for(NumberLiteral singleNumberLiteral : literals) {
		if( isLiteralValid(singleNumberLiteral) ) {
			addToSmells(initializeCodeSmell(MAGIC_NUMBER));
		}
	}
}
 
Example #16
Source File: StyledStringVisitor.java    From JDeodorant with MIT License 5 votes vote down vote up
public boolean visit(NumberLiteral expr) {
	/*
	 * Number literal nodes.
	 */
	styledString.append(expr.getToken(),  determineDiffStyle(expr, new StyledStringStyler(ordinaryStyle)));
	return false;
}
 
Example #17
Source File: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static String getBaseNameFromExpression(IJavaProject project, Expression assignedExpression, int variableKind) {
	String name= null;
	if (assignedExpression instanceof CastExpression) {
		assignedExpression= ((CastExpression)assignedExpression).getExpression();
	}
	if (assignedExpression instanceof Name) {
		Name simpleNode= (Name)assignedExpression;
		IBinding binding= simpleNode.resolveBinding();
		if (binding instanceof IVariableBinding)
			return getBaseName((IVariableBinding)binding, project);

		return ASTNodes.getSimpleNameIdentifier(simpleNode);
	} else if (assignedExpression instanceof MethodInvocation) {
		name= ((MethodInvocation)assignedExpression).getName().getIdentifier();
	} else if (assignedExpression instanceof SuperMethodInvocation) {
		name= ((SuperMethodInvocation)assignedExpression).getName().getIdentifier();
	} else if (assignedExpression instanceof FieldAccess) {
		return ((FieldAccess)assignedExpression).getName().getIdentifier();
	} else if (variableKind == NamingConventions.VK_STATIC_FINAL_FIELD && (assignedExpression instanceof StringLiteral || assignedExpression instanceof NumberLiteral)) {
		String string= assignedExpression instanceof StringLiteral ? ((StringLiteral)assignedExpression).getLiteralValue() : ((NumberLiteral)assignedExpression).getToken();
		StringBuffer res= new StringBuffer();
		boolean needsUnderscore= false;
		for (int i= 0; i < string.length(); i++) {
			char ch= string.charAt(i);
			if (Character.isJavaIdentifierPart(ch)) {
				if (res.length() == 0 && !Character.isJavaIdentifierStart(ch) || needsUnderscore) {
					res.append('_');
				}
				res.append(ch);
				needsUnderscore= false;
			} else {
				needsUnderscore= res.length() > 0;
			}
		}
		if (res.length() > 0) {
			return res.toString();
		}
	}
	if (name != null) {
		for (int i= 0; i < KNOWN_METHOD_NAME_PREFIXES.length; i++) {
			String curr= KNOWN_METHOD_NAME_PREFIXES[i];
			if (name.startsWith(curr)) {
				if (name.equals(curr)) {
					return null; // don't suggest 'get' as variable name
				} else if (Character.isUpperCase(name.charAt(curr.length()))) {
					return name.substring(curr.length());
				}
			}
		}
	}
	return name;
}
 
Example #18
Source File: FlowAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void endVisit(NumberLiteral node) {
	// Leaf node.
}
 
Example #19
Source File: GenericVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean visit(NumberLiteral node) {
	return visitNode(node);
}
 
Example #20
Source File: SemanticHighlightingReconciler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean visit(NumberLiteral node) {
	return visitLiteral(node);
}
 
Example #21
Source File: LiteralObject.java    From JDeodorant with MIT License 4 votes vote down vote up
public LiteralObject(Expression expression) {
	if(expression instanceof StringLiteral) {
		StringLiteral stringLiteral = (StringLiteral)expression;
		literalType = LiteralType.STRING;
		value = stringLiteral.getLiteralValue();
		type = TypeObject.extractTypeObject(stringLiteral.resolveTypeBinding().getQualifiedName());
	}
	else if(expression instanceof NullLiteral) {
		NullLiteral nullLiteral = (NullLiteral)expression;
		literalType = LiteralType.NULL;
		value = "null";
		if(nullLiteral.resolveTypeBinding() != null) {
			type = TypeObject.extractTypeObject(nullLiteral.resolveTypeBinding().getQualifiedName());
		}
	}
	else if(expression instanceof NumberLiteral) {
		NumberLiteral numberLiteral = (NumberLiteral)expression;
		literalType = LiteralType.NUMBER;
		value = numberLiteral.getToken();
		type = TypeObject.extractTypeObject(numberLiteral.resolveTypeBinding().getQualifiedName());
	}
	else if(expression instanceof BooleanLiteral) {
		BooleanLiteral booleanLiteral = (BooleanLiteral)expression;
		literalType = LiteralType.BOOLEAN;
		value = Boolean.toString(booleanLiteral.booleanValue());
		type = TypeObject.extractTypeObject(booleanLiteral.resolveTypeBinding().getQualifiedName());
	}
	else if(expression instanceof CharacterLiteral) {
		CharacterLiteral characterLiteral = (CharacterLiteral)expression;
		literalType = LiteralType.CHARACTER;
		value = Character.toString(characterLiteral.charValue());
		type = TypeObject.extractTypeObject(characterLiteral.resolveTypeBinding().getQualifiedName());
	}
	else if(expression instanceof TypeLiteral) {
		TypeLiteral typeLiteral = (TypeLiteral)expression;
		literalType = LiteralType.TYPE;
		value = typeLiteral.getType().toString();
		type = TypeObject.extractTypeObject(typeLiteral.resolveTypeBinding().getQualifiedName());
	}
	this.literal = ASTInformationGenerator.generateASTInformation(expression);
}
 
Example #22
Source File: BindingSignatureVisitor.java    From JDeodorant with MIT License 4 votes vote down vote up
public boolean visit(NumberLiteral expr) {
	bindingKeys.add(expr.getToken());
	return false;
}
 
Example #23
Source File: BindingSignatureVisitor.java    From JDeodorant with MIT License 4 votes vote down vote up
private void handleExpression(Expression expression) {
	if (expression instanceof ArrayAccess) {
		visit((ArrayAccess) expression);
	} else if (expression instanceof ArrayCreation) {
		visit((ArrayCreation) expression);
	} else if (expression instanceof ArrayInitializer) {
		visit((ArrayInitializer) expression);
	} else if (expression instanceof Assignment) {
		visit((Assignment) expression);
	} else if (expression instanceof BooleanLiteral) {
		visit((BooleanLiteral) expression);
	} else if (expression instanceof CastExpression) {
		visit((CastExpression) expression);
	} else if (expression instanceof CharacterLiteral) {
		visit((CharacterLiteral) expression);
	} else if (expression instanceof ClassInstanceCreation) {
		visit((ClassInstanceCreation) expression);
	} else if (expression instanceof ConditionalExpression) {
		visit((ConditionalExpression) expression);
	} else if (expression instanceof FieldAccess) {
		visit((FieldAccess) expression);
	} else if (expression instanceof InfixExpression) {
		visit((InfixExpression) expression);
	} else if (expression instanceof InstanceofExpression) {
		visit((InstanceofExpression) expression);
	} else if (expression instanceof MethodInvocation) {
		visit((MethodInvocation) expression);
	} else if (expression instanceof NullLiteral) {
		visit((NullLiteral) expression);
	} else if (expression instanceof NumberLiteral) {
		visit((NumberLiteral) expression);
	} else if (expression instanceof ParenthesizedExpression) {
		visit((ParenthesizedExpression) expression);
	} else if (expression instanceof PostfixExpression) {
		visit((PostfixExpression) expression);
	} else if (expression instanceof PrefixExpression) {
		visit((PrefixExpression) expression);
	} else if ((expression instanceof QualifiedName)) {
		visit((QualifiedName) expression);
	} else if (expression instanceof SimpleName) {
		visit((SimpleName) expression);
	} else if (expression instanceof StringLiteral) {
		visit((StringLiteral) expression);
	} else if (expression instanceof SuperFieldAccess) {
		visit((SuperFieldAccess) expression);
	} else if (expression instanceof SuperMethodInvocation) {
		visit((SuperMethodInvocation) expression);
	} else if (expression instanceof ThisExpression) {
		visit((ThisExpression) expression);
	} else if (expression instanceof TypeLiteral) {
		visit((TypeLiteral) expression);
	} else if (expression instanceof VariableDeclarationExpression) {
		visit((VariableDeclarationExpression) expression);
	}
}
 
Example #24
Source File: StyledStringVisitor.java    From JDeodorant with MIT License 4 votes vote down vote up
private void handleExpression(Expression expression) {
	if (expression instanceof ArrayAccess) {
		visit((ArrayAccess) expression);
	} else if (expression instanceof ArrayCreation) {
		visit((ArrayCreation) expression);
	} else if (expression instanceof ArrayInitializer) {
		visit((ArrayInitializer) expression);
	} else if (expression instanceof Assignment) {
		visit((Assignment) expression);
	} else if (expression instanceof BooleanLiteral) {
		visit((BooleanLiteral) expression);
	} else if (expression instanceof CastExpression) {
		visit((CastExpression) expression);
	} else if (expression instanceof CharacterLiteral) {
		visit((CharacterLiteral) expression);
	} else if (expression instanceof ClassInstanceCreation) {
		visit((ClassInstanceCreation) expression);
	} else if (expression instanceof ConditionalExpression) {
		visit((ConditionalExpression) expression);
	} else if (expression instanceof FieldAccess) {
		visit((FieldAccess) expression);
	} else if (expression instanceof InfixExpression) {
		visit((InfixExpression) expression);
	} else if (expression instanceof InstanceofExpression) {
		visit((InstanceofExpression) expression);
	} else if (expression instanceof MethodInvocation) {
		visit((MethodInvocation) expression);
	} else if (expression instanceof NullLiteral) {
		visit((NullLiteral) expression);
	} else if (expression instanceof NumberLiteral) {
		visit((NumberLiteral) expression);
	} else if (expression instanceof ParenthesizedExpression) {
		visit((ParenthesizedExpression) expression);
	} else if (expression instanceof PostfixExpression) {
		visit((PostfixExpression) expression);
	} else if (expression instanceof PrefixExpression) {
		visit((PrefixExpression) expression);
	} else if ((expression instanceof QualifiedName)) {
		visit((QualifiedName) expression);
	} else if (expression instanceof SimpleName) {
		visit((SimpleName) expression);
	} else if (expression instanceof StringLiteral) {
		visit((StringLiteral) expression);
	} else if (expression instanceof SuperFieldAccess) {
		visit((SuperFieldAccess) expression);
	} else if (expression instanceof SuperMethodInvocation) {
		visit((SuperMethodInvocation) expression);
	} else if (expression instanceof ThisExpression) {
		visit((ThisExpression) expression);
	} else if (expression instanceof TypeLiteral) {
		visit((TypeLiteral) expression);
	} else if (expression instanceof VariableDeclarationExpression) {
		visit((VariableDeclarationExpression) expression);
	}
}
 
Example #25
Source File: NumberLiteralWriter.java    From juniversal with MIT License 4 votes vote down vote up
@Override
public void write(NumberLiteral numberLiteral) {
    String rawToken = numberLiteral.getToken();

    // Strip out any _ separators in the number, as those aren't supported in C# (at least not until the
    // new C# 6 comes out)
    String token = rawToken.replace("_", "");

    boolean isHex = token.startsWith("0x") || token.startsWith("0X");
    char lastChar = token.charAt(token.length() - 1);

    boolean isFloatingPoint = !isHex && (token.contains(".") || token.contains("e") || token.contains("E") ||
                                         lastChar == 'f' || lastChar == 'F' || lastChar == 'd' || lastChar == 'D');

    // First see if it's a floating point (with a decimal point or in scientific notation) or an integer
    if (isFloatingPoint)
        write(token);
    else {
        // TODO: Support binary (and octal) literals by converting to hex
        if (token.length() >= 2 && token.startsWith("0")) {
            char secondChar = token.charAt(1);
            if (secondChar >= '0' && secondChar <= '7') {
                throw sourceNotSupported("Octal literals aren't currently supported; change the source to use hex instead");
            } else if ((secondChar == 'b') || (secondChar == 'B')) {
                throw sourceNotSupported("Binary literals aren't currently supported; change the source to use hex instead");
            }
        }

        if (token.length() < 8)
            write(token);
        else {
            // If the literal exceeds the max size of an int/long, then C# will automatically treat its type as an
            // unsigned int/long instead of signed.   In that case, add an explicit cast, with the unchecked modifier,
            // to convert the type back to signed

            BigInteger tokenValue = ASTUtil.getIntegerLiteralValue(numberLiteral);

            // TODO: ADD TEST CASES HERE
            if (lastChar == 'L' || lastChar == 'l') {
                if (tokenValue.longValue() < 0)
                    write("unchecked((long) " + token + ")");
                else write(token);
            } else {
                if (tokenValue.intValue() < 0)
                    write("unchecked((int) " + token + ")");
                else write(token);
            }
        }
    }

    match(rawToken);
}
 
Example #26
Source File: GenericVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void endVisit(NumberLiteral node) {
	endVisitNode(node);
}
 
Example #27
Source File: ConstraintCollector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean visit(NumberLiteral node) {
	add(fCreator.create(node));
	return true;
}
 
Example #28
Source File: AstMatchingNodeFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean visit(NumberLiteral node) {
	if (node.subtreeMatch(fMatcher, fNodeToMatch))
		return matches(node);
	return super.visit(node);
}
 
Example #29
Source File: BaseTranslator.java    From junion with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public Expression returnLong(long val) {
	NumberLiteral num = ast.newNumberLiteral(""+val);
	num.setProperty(TYPEBIND_PROP, StructCache.FieldType.LONG);
	return num;
}
 
Example #30
Source File: InferTypeArgumentsConstraintCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void endVisit(NumberLiteral node) {
	ITypeBinding typeBinding= node.resolveTypeBinding();
	ImmutableTypeVariable2 cv= fTCModel.makeImmutableTypeVariable(typeBinding, node);
	setConstraintVariable(node, cv);
}