本文整理汇总了Java中org.codehaus.groovy.syntax.Token类的典型用法代码示例。如果您正苦于以下问题:Java Token类的具体用法?Java Token怎么用?Java Token使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Token类属于org.codehaus.groovy.syntax包,在下文中一共展示了Token类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visitBinaryExpression
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
public void visitBinaryExpression(BinaryExpression expression) {
Expression left = expression.getLeftExpression();
Expression right = expression.getRightExpression();
boolean leaf = (right instanceof ConstantExpression || left instanceof ConstantExpression);
if (!leaf) buffer.append("(");
left.visit(this);
buffer.append(" ");
Token token = expression.getOperation();
buffer.append(tokenAsSql(token));
buffer.append(" ");
right.visit(this);
if (!leaf) buffer.append(")");
}
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:SqlWhereVisitor.java
示例2: visitField
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
@Override
public void visitField(final FieldNode node) {
final boolean osc = typeCheckingContext.isInStaticContext;
try {
typeCheckingContext.isInStaticContext = node.isInStaticContext();
currentField = node;
super.visitField(node);
Expression init = node.getInitialExpression();
if (init != null) {
FieldExpression left = new FieldExpression(node);
BinaryExpression bexp = binX(
left,
Token.newSymbol("=", node.getLineNumber(), node.getColumnNumber()),
init
);
bexp.setSourcePosition(init);
typeCheckAssignment(bexp, left, node.getOriginType(), init, getType(init));
if (init instanceof ConstructorCallExpression) {
inferDiamondType((ConstructorCallExpression) init, node.getOriginType());
}
}
} finally {
currentField = null;
typeCheckingContext.isInStaticContext = osc;
}
}
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:StaticTypeCheckingVisitor.java
示例3: convertInOperatorToTernary
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
private Expression convertInOperatorToTernary(final BinaryExpression bin, final Expression rightExpression, final Expression leftExpression) {
MethodCallExpression call = new MethodCallExpression(
rightExpression,
"isCase",
leftExpression
);
call.setMethodTarget((MethodNode) bin.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET));
call.setSourcePosition(bin);
call.copyNodeMetaData(bin);
TernaryExpression tExp = new TernaryExpression(
new BooleanExpression(
new BinaryExpression(rightExpression, Token.newSymbol("==", -1, -1), new ConstantExpression(null))
),
new BinaryExpression(leftExpression, Token.newSymbol("==", -1, -1), new ConstantExpression(null)),
call
);
return staticCompilationTransformer.transform(tExp);
}
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:BinaryExpressionTransformer.java
示例4: optimizeConstantInitialization
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
private static DeclarationExpression optimizeConstantInitialization(
final BinaryExpression originalDeclaration,
final Token operation,
final ConstantExpression constant,
final Expression leftExpression,
final ClassNode declarationType) {
ConstantExpression cexp = new ConstantExpression(
convertConstant((Number) constant.getValue(), ClassHelper.getWrapper(declarationType)), true);
cexp.setType(declarationType);
cexp.setSourcePosition(constant);
DeclarationExpression result = new DeclarationExpression(
leftExpression,
operation,
cexp
);
result.setSourcePosition(originalDeclaration);
result.copyNodeMetaData(originalDeclaration);
return result;
}
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:BinaryExpressionTransformer.java
示例5: transformBinaryExpression
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
private Expression transformBinaryExpression(final BinaryExpression exp) {
final int op = exp.getOperation().getType();
int token = TokenUtil.removeAssignment(op);
if (token == op) {
// no transform needed
return super.transform(exp);
}
BinaryExpression operation = new BinaryExpression(
exp.getLeftExpression(),
Token.newSymbol(token, -1, -1),
exp.getRightExpression()
);
operation.setSourcePosition(exp);
BinaryExpression result = new BinaryExpression(
exp.getLeftExpression(),
Token.newSymbol(EQUAL, -1, -1),
operation
);
result.setSourcePosition(exp);
return result;
}
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:NAryOperationRewriter.java
示例6: setPropertySetterDispatcher
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
protected static void setPropertySetterDispatcher(BlockStatement block, Expression thiz, Parameter[] parameters) {
List<ConstantExpression> gStringStrings = new ArrayList<ConstantExpression>();
gStringStrings.add(new ConstantExpression(""));
gStringStrings.add(new ConstantExpression(""));
List<Expression> gStringValues = new ArrayList<Expression>();
gStringValues.add(new VariableExpression(parameters[0]));
block.addStatement(
new ExpressionStatement(
new BinaryExpression(
new PropertyExpression(
thiz,
new GStringExpression("$name", gStringStrings, gStringValues)
),
Token.newSymbol(Types.ASSIGN, -1, -1),
new VariableExpression(parameters[1])
)
)
);
}
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:InnerClassVisitorHelper.java
示例7: visitClosureExpression
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
@Override
public void visitClosureExpression(ClosureExpression expression) {
if (inputs == null) {
inputs = ImmutableListMultimap.builder();
try {
accessVariable = new VariableExpression(ACCESS_HOLDER_FIELD, ACCESS_API_TYPE);
super.visitClosureExpression(expression);
BlockStatement code = (BlockStatement) expression.getCode();
code.setNodeMetaData(AST_NODE_METADATA_INPUTS_KEY, inputs.build());
accessVariable.setClosureSharedVariable(true);
StaticMethodCallExpression getAccessCall = new StaticMethodCallExpression(CONTEXTUAL_INPUT_TYPE, GET_ACCESS, ArgumentListExpression.EMPTY_ARGUMENTS);
DeclarationExpression variableDeclaration = new DeclarationExpression(accessVariable, new Token(Types.ASSIGN, "=", -1, -1), getAccessCall);
code.getStatements().add(0, new ExpressionStatement(variableDeclaration));
code.getVariableScope().putDeclaredVariable(accessVariable);
} finally {
inputs = null;
}
} else {
expression.getVariableScope().putReferencedLocalVariable(accessVariable);
super.visitClosureExpression(expression);
}
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:25,代码来源:RuleVisitor.java
示例8: visitBinaryExpression
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
@Override
public void visitBinaryExpression(BinaryExpression expression) {
Token operation = expression.getOperation();
if (operation.isA(Types.LEFT_SHIFT) && expression.getLeftExpression() instanceof VariableExpression && expression.getRightExpression() instanceof ClosureExpression) {
addCreator(scope, (VariableExpression) expression.getLeftExpression(), (ClosureExpression) expression.getRightExpression());
} else if (operation.isA(Types.ASSIGN)) {
if (expression.getLeftExpression() instanceof VariableExpression) {
addCreator(scope, (VariableExpression) expression.getLeftExpression(), expression.getRightExpression());
} else if (expression.getLeftExpression() instanceof PropertyExpression) {
addCreator(scope, (PropertyExpression) expression.getLeftExpression(), expression.getRightExpression());
} else {
super.visitBinaryExpression(expression);
}
} else {
super.visitBinaryExpression(expression);
}
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:18,代码来源:ScopeVisitor.java
示例9: tokenAsSql
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
protected String tokenAsSql(Token token) {
switch (token.getType()) {
case Types.COMPARE_EQUAL:
return "=";
case Types.LOGICAL_AND:
return "and";
case Types.LOGICAL_OR:
return "or";
default:
return token.getText();
}
}
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:SqlWhereVisitor.java
示例10: assertTokenAuthorized
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
/**
* Checks that a given token is either in the whitelist or not in the blacklist.
*
* @param token the token to be checked
* @throws SecurityException if usage of this token is forbidden
*/
private void assertTokenAuthorized(final Token token) throws SecurityException {
final int value = token.getType();
if (tokensBlacklist != null && tokensBlacklist.contains(value)) {
throw new SecurityException("Token " + token + " is not allowed");
} else if (tokensWhitelist != null && !tokensWhitelist.contains(value)) {
throw new SecurityException("Token " + token + " is not allowed");
}
}
开发者ID:apache,项目名称:groovy,代码行数:15,代码来源:SecureASTCustomizer.java
示例11: transformPrefixExpression
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
private Expression transformPrefixExpression(final PrefixExpression exp) {
if (isInternalFieldAccess(exp.getExpression())) {
Token operation = exp.getOperation();
sourceUnit.addError(new SyntaxException("Prefix expressions on trait fields/properties are not supported in traits.", operation.getStartLine(), operation.getStartColumn()));
return exp;
} else {
return super.transform(exp);
}
}
开发者ID:apache,项目名称:groovy,代码行数:10,代码来源:NAryOperationRewriter.java
示例12: transformPostfixExpression
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
private Expression transformPostfixExpression(final PostfixExpression exp) {
if (isInternalFieldAccess(exp.getExpression())) {
Token operation = exp.getOperation();
sourceUnit.addError(new SyntaxException("Postfix expressions on trait fields/properties are not supported in traits.", operation.getStartLine(), operation.getStartColumn()));
return exp;
} else {
return super.transform(exp);
}
}
开发者ID:apache,项目名称:groovy,代码行数:10,代码来源:NAryOperationRewriter.java
示例13: createSuperFallback
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
private static Statement createSuperFallback(MethodNode forwarderMethod, ClassNode returnType) {
ArgumentListExpression args = new ArgumentListExpression();
Parameter[] forwarderMethodParameters = forwarderMethod.getParameters();
for (final Parameter forwarderMethodParameter : forwarderMethodParameters) {
args.addExpression(new VariableExpression(forwarderMethodParameter));
}
BinaryExpression instanceOfExpr = new BinaryExpression(new VariableExpression("this"), Token.newSymbol(Types.KEYWORD_INSTANCEOF, -1, -1), new ClassExpression(Traits.GENERATED_PROXY_CLASSNODE));
MethodCallExpression superCall = new MethodCallExpression(
new VariableExpression("super"),
forwarderMethod.getName(),
args
);
superCall.setImplicitThis(false);
CastExpression proxyReceiver = new CastExpression(Traits.GENERATED_PROXY_CLASSNODE, new VariableExpression("this"));
MethodCallExpression getProxy = new MethodCallExpression(proxyReceiver, "getProxyTarget", ArgumentListExpression.EMPTY_ARGUMENTS);
getProxy.setImplicitThis(true);
StaticMethodCallExpression proxyCall = new StaticMethodCallExpression(
ClassHelper.make(InvokerHelper.class),
"invokeMethod",
new ArgumentListExpression(getProxy, new ConstantExpression(forwarderMethod.getName()), new ArrayExpression(ClassHelper.OBJECT_TYPE, args.getExpressions()))
);
IfStatement stmt = new IfStatement(
new BooleanExpression(instanceOfExpr),
new ExpressionStatement(new CastExpression(returnType,proxyCall)),
new ExpressionStatement(superCall)
);
return stmt;
}
开发者ID:apache,项目名称:groovy,代码行数:29,代码来源:TraitComposer.java
示例14: createStaticReceiver
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
private TernaryExpression createStaticReceiver(final Expression receiver) {
return new TernaryExpression(
new BooleanExpression(new BinaryExpression(
receiver,
Token.newSymbol(Types.KEYWORD_INSTANCEOF, -1, -1),
new ClassExpression(ClassHelper.CLASS_Type)
)),
receiver,
new MethodCallExpression(createFieldHelperReceiver(), "getClass", ArgumentListExpression.EMPTY_ARGUMENTS)
);
}
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:TraitReceiverTransformer.java
示例15: createAssignmentToField
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
private BinaryExpression createAssignmentToField(final Expression rightExpression,
final Token operation, final String fieldName) {
return new BinaryExpression(
new PropertyExpression(
new VariableExpression(weaved),
fieldName
),
operation,
transform(rightExpression));
}
开发者ID:apache,项目名称:groovy,代码行数:11,代码来源:TraitReceiverTransformer.java
示例16: BinaryExpression
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
public BinaryExpression(Expression leftExpression,
Token operation,
Expression rightExpression) {
this.leftExpression = leftExpression;
this.operation = operation;
this.rightExpression = rightExpression;
}
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:BinaryExpression.java
示例17: newAssignmentExpression
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
/**
* Creates an assignment expression in which the specified expression
* is written into the specified variable name.
*/
public static BinaryExpression newAssignmentExpression(Variable variable, Expression rhs) {
VariableExpression lhs = new VariableExpression(variable);
Token operator = Token.newPlaceholder(Types.ASSIGN);
return new BinaryExpression(lhs, operator, rhs);
}
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:BinaryExpression.java
示例18: addFieldInit
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
protected static void addFieldInit(Parameter p, FieldNode fn, BlockStatement block) {
VariableExpression ve = new VariableExpression(p);
FieldExpression fe = new FieldExpression(fn);
block.addStatement(new ExpressionStatement(
new BinaryExpression(fe, Token.newSymbol(Types.ASSIGN, -1, -1), ve)
));
}
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:InnerClassVisitorHelper.java
示例19: evaluateElvisEqual
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
public void evaluateElvisEqual(BinaryExpression expression) {
Token operation = expression.getOperation();
BinaryExpression elvisAssignmentExpression =
new BinaryExpression(
expression.getLeftExpression(),
Token.newSymbol(Types.EQUAL, operation.getStartLine(), operation.getStartColumn()),
new ElvisOperatorExpression(expression.getLeftExpression(), expression.getRightExpression())
);
this.evaluateEqual(elvisAssignmentExpression, false);
}
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:BinaryExpressionHelper.java
示例20: evaluateNotInstanceof
import org.codehaus.groovy.syntax.Token; //导入依赖的package包/类
private void evaluateNotInstanceof(BinaryExpression expression) {
unaryExpressionHelper.writeNotExpression(
new NotExpression(
new BinaryExpression(
expression.getLeftExpression(),
Token.newSymbol(KEYWORD_INSTANCEOF, -1, -1),
expression.getRightExpression()
)
)
);
}
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:BinaryExpressionHelper.java
注:本文中的org.codehaus.groovy.syntax.Token类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论