org.eclipse.jdt.internal.compiler.ast.FalseLiteral Java Examples

The following examples show how to use org.eclipse.jdt.internal.compiler.ast.FalseLiteral. 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: HandleBuilder.java    From EasyMPermission with MIT License 6 votes vote down vote up
private MethodDeclaration generateCleanMethod(List<BuilderFieldData> builderFields, EclipseNode builderType, ASTNode source) {
	List<Statement> statements = new ArrayList<Statement>();
	
	for (BuilderFieldData bfd : builderFields) {
		if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
			bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, builderType, statements);
		}
	}
	
	FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0);
	thisUnclean.receiver = new ThisReference(0, 0);
	statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0));
	MethodDeclaration decl = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
	decl.selector = CLEAN_METHOD_NAME;
	decl.modifiers = ClassFileConstants.AccPrivate;
	decl.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
	decl.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
	decl.statements = statements.toArray(new Statement[0]);
	decl.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
	return decl;
}
 
Example #2
Source File: HandleEqualsAndHashCode.java    From EasyMPermission with MIT License 6 votes vote down vote up
public IfStatement generateCompareFloatOrDouble(Expression thisRef, Expression otherRef, char[] floatOrDouble, ASTNode source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	/* if (Float.compare(fieldName, other.fieldName) != 0) return false */
	MessageSend floatCompare = new MessageSend();
	floatCompare.sourceStart = pS; floatCompare.sourceEnd = pE;
	setGeneratedBy(floatCompare, source);
	floatCompare.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.LANG, floatOrDouble);
	floatCompare.selector = "compare".toCharArray();
	floatCompare.arguments = new Expression[] {thisRef, otherRef};
	IntLiteral int0 = makeIntLiteral("0".toCharArray(), source);
	EqualExpression ifFloatCompareIsNot0 = new EqualExpression(floatCompare, int0, OperatorIds.NOT_EQUAL);
	ifFloatCompareIsNot0.sourceStart = pS; ifFloatCompareIsNot0.sourceEnd = pE;
	setGeneratedBy(ifFloatCompareIsNot0, source);
	FalseLiteral falseLiteral = new FalseLiteral(pS, pE);
	setGeneratedBy(falseLiteral, source);
	ReturnStatement returnFalse = new ReturnStatement(falseLiteral, pS, pE);
	setGeneratedBy(returnFalse, source);
	IfStatement ifStatement = new IfStatement(ifFloatCompareIsNot0, returnFalse, pS, pE);
	setGeneratedBy(ifStatement, source);
	return ifStatement;
}
 
Example #3
Source File: HandleBuilder.java    From EasyMPermission with MIT License 4 votes vote down vote up
private static final boolean toBoolean(Object expr, boolean defaultValue) {
	if (expr == null) return defaultValue;
	if (expr instanceof FalseLiteral) return false;
	if (expr instanceof TrueLiteral) return true;
	return ((Boolean) expr).booleanValue();
}
 
Example #4
Source File: SetGeneratedByVisitor.java    From EasyMPermission with MIT License 4 votes vote down vote up
@Override public boolean visit(FalseLiteral node, BlockScope scope) {
	fixPositions(setGeneratedBy(node, source));
	return super.visit(node, scope);
}
 
Example #5
Source File: BinaryExpressionFragmentBuilder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public boolean visit(FalseLiteral falseLiteral, BlockScope scope) {
	addSmallFragment(falseLiteral);
	return false;
}