本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.MessageSend类的典型用法代码示例。如果您正苦于以下问题:Java MessageSend类的具体用法?Java MessageSend怎么用?Java MessageSend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageSend类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了MessageSend类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createFactoryParameter
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
@Override public Expression createFactoryParameter(ClassLiteralAccess type, Annotation source) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long)pS << 32 | pE;
MessageSend factoryParameterCall = new MessageSend();
setGeneratedBy(factoryParameterCall, source);
factoryParameterCall.receiver = super.createFactoryParameter(type, source);
factoryParameterCall.selector = "getName".toCharArray();
factoryParameterCall.nameSourcePosition = p;
factoryParameterCall.sourceStart = pS;
factoryParameterCall.sourceEnd = factoryParameterCall.statementEnd = pE;
return factoryParameterCall;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:HandleLog.java
示例2: generateCompareFloatOrDouble
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
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;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:22,代码来源:HandleEqualsAndHashCode.java
示例3: getSize
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
/** Generates 'this.<em>name</em>.size()' as an expression; if nullGuard is true, it's this.name == null ? 0 : this.name.size(). */
protected Expression getSize(EclipseNode builderType, char[] name, boolean nullGuard) {
MessageSend invoke = new MessageSend();
ThisReference thisRef = new ThisReference(0, 0);
FieldReference thisDotName = new FieldReference(name, 0L);
thisDotName.receiver = thisRef;
invoke.receiver = thisDotName;
invoke.selector = SIZE_TEXT;
if (!nullGuard) return invoke;
ThisReference cdnThisRef = new ThisReference(0, 0);
FieldReference cdnThisDotName = new FieldReference(name, 0L);
cdnThisDotName.receiver = cdnThisRef;
NullLiteral nullLiteral = new NullLiteral(0, 0);
EqualExpression isNull = new EqualExpression(cdnThisDotName, nullLiteral, OperatorIds.EQUAL_EQUAL);
IntLiteral zeroLiteral = makeIntLiteral(new char[] {'0'}, null);
ConditionalExpression conditional = new ConditionalExpression(isNull, zeroLiteral, invoke);
return conditional;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:20,代码来源:EclipseSingularsRecipes.java
示例4: generateClearMethod
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
private void generateClearMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = ClassFileConstants.AccPublic;
FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
thisDotField.receiver = new ThisReference(0, 0);
FieldReference thisDotField2 = new FieldReference(data.getPluralName(), 0L);
thisDotField2.receiver = new ThisReference(0, 0);
md.selector = HandlerUtil.buildAccessorName("clear", new String(data.getPluralName())).toCharArray();
MessageSend clearMsg = new MessageSend();
clearMsg.receiver = thisDotField2;
clearMsg.selector = "clear".toCharArray();
Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsg, 0, 0);
md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
md.returnType = returnType;
injectMethod(builderType, md);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:EclipseJavaUtilListSetSingularizer.java
示例5: newMessageSendWithTypeArguments
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
protected MessageSend newMessageSendWithTypeArguments() {
char[] selector = this.identifierStack[this.identifierPtr];
if (selector != assistIdentifier()){
return super.newMessageSendWithTypeArguments();
}
MessageSend messageSend = new SelectionOnMessageSend();
int length;
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
this.expressionPtr -= length;
System.arraycopy(
this.expressionStack,
this.expressionPtr + 1,
messageSend.arguments = new Expression[length],
0,
length);
}
this.assistNode = messageSend;
if (!this.diet){
this.restartRecovery = true; // force to restart in recovery mode
this.lastIgnoredToken = -1;
}
this.isOrphanCompletionNode = true;
return messageSend;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:SelectionParser.java
示例6: consumeMethodInvocationNameWithTypeArguments
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
protected void consumeMethodInvocationNameWithTypeArguments() {
// MethodInvocation ::= Name '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
// when the name is only an identifier...we have a message send to "this" (implicit)
MessageSend m = newMessageSendWithTypeArguments();
m.sourceEnd = this.rParenPos;
m.sourceStart =
(int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
m.selector = this.identifierStack[this.identifierPtr--];
this.identifierLengthPtr--;
// handle type arguments
int length = this.genericsLengthStack[this.genericsLengthPtr--];
this.genericsPtr -= length;
System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
this.intPtr--; // consume position of '<'
m.receiver = getUnspecifiedReference();
m.sourceStart = m.receiver.sourceStart;
pushOnExpressionStack(m);
consumeInvocationExpression();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:Parser.java
示例7: consumeMethodInvocationPrimaryWithTypeArguments
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
protected void consumeMethodInvocationPrimaryWithTypeArguments() {
//optimize the push/pop
//MethodInvocation ::= Primary '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
MessageSend m = newMessageSendWithTypeArguments();
m.sourceStart =
(int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
m.selector = this.identifierStack[this.identifierPtr--];
this.identifierLengthPtr--;
// handle type arguments
int length = this.genericsLengthStack[this.genericsLengthPtr--];
this.genericsPtr -= length;
System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
this.intPtr--; // consume position of '<'
m.receiver = this.expressionStack[this.expressionPtr];
m.sourceStart = m.receiver.sourceStart;
m.sourceEnd = this.rParenPos;
this.expressionStack[this.expressionPtr] = m;
consumeInvocationExpression();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:Parser.java
示例8: consumeMethodInvocationSuperWithTypeArguments
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
protected void consumeMethodInvocationSuperWithTypeArguments() {
// MethodInvocation ::= 'super' '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
MessageSend m = newMessageSendWithTypeArguments();
this.intPtr--; // start position of the typeArguments
m.sourceEnd = this.rParenPos;
m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr];
m.selector = this.identifierStack[this.identifierPtr--];
this.identifierLengthPtr--;
// handle type arguments
int length = this.genericsLengthStack[this.genericsLengthPtr--];
this.genericsPtr -= length;
System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
m.sourceStart = this.intStack[this.intPtr--]; // start position of the super keyword
m.receiver = new SuperReference(m.sourceStart, this.endPosition);
pushOnExpressionStack(m);
consumeInvocationExpression();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:Parser.java
示例9: newMessageSend
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
protected MessageSend newMessageSend() {
// '(' ArgumentListopt ')'
// the arguments are on the expression stack
MessageSend m = new MessageSend();
int length;
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
this.expressionPtr -= length;
System.arraycopy(
this.expressionStack,
this.expressionPtr + 1,
m.arguments = new Expression[length],
0,
length);
}
return m;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:Parser.java
示例10: errorNoMethodFor
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
StringBuffer buffer = new StringBuffer();
StringBuffer shortBuffer = new StringBuffer();
for (int i = 0, length = params.length; i < length; i++) {
if (i != 0){
buffer.append(", "); //$NON-NLS-1$
shortBuffer.append(", "); //$NON-NLS-1$
}
buffer.append(new String(params[i].readableName()));
shortBuffer.append(new String(params[i].shortReadableName()));
}
int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
this.handle(
id,
new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
messageSend.sourceStart,
messageSend.sourceEnd);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:ProblemReporter.java
示例11: javadocErrorNoMethodFor
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) {
int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType;
int severity = computeSeverity(id);
if (severity == ProblemSeverities.Ignore) return;
StringBuffer buffer = new StringBuffer();
StringBuffer shortBuffer = new StringBuffer();
for (int i = 0, length = params.length; i < length; i++) {
if (i != 0){
buffer.append(", "); //$NON-NLS-1$
shortBuffer.append(", "); //$NON-NLS-1$
}
buffer.append(new String(params[i].readableName()));
shortBuffer.append(new String(params[i].shortReadableName()));
}
if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
this.handle(
id,
new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
severity,
messageSend.sourceStart,
messageSend.sourceEnd);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:ProblemReporter.java
示例12: missingTypeInMethod
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
public void missingTypeInMethod(MessageSend messageSend, MethodBinding method) {
List missingTypes = method.collectMissingTypes(null);
if (missingTypes == null) {
System.err.println("The method " + method + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
TypeBinding missingType = (TypeBinding) missingTypes.get(0);
this.handle(
IProblem.MissingTypeInMethod,
new String[] {
new String(method.declaringClass.readableName()),
new String(method.selector),
typesAsString(method, false),
new String(missingType.readableName()),
},
new String[] {
new String(method.declaringClass.shortReadableName()),
new String(method.selector),
typesAsString(method, true),
new String(missingType.shortReadableName()),
},
(int) (messageSend.nameSourcePosition >>> 32),
(int) messageSend.nameSourcePosition);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:25,代码来源:ProblemReporter.java
示例13: generateCompareFloatOrDouble
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
private 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;
}
开发者ID:redundent,项目名称:lombok,代码行数:22,代码来源:HandleEqualsAndHashCode.java
示例14: get
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
public Expression get(final ASTNode source, char[] name) {
MessageSend call = new MessageSend();
call.sourceStart = source.sourceStart; call.sourceEnd = source.sourceEnd;
call.nameSourcePosition = pos(source);
setGeneratedBy(call, source);
call.selector = name;
call.receiver = new ThisReference(source.sourceStart, source.sourceEnd);
setGeneratedBy(call.receiver, source);
return call;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:11,代码来源:PatchDelegate.java
示例15: createFieldAccessor
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
static Expression createFieldAccessor(EclipseNode field, FieldAccess fieldAccess, ASTNode source) {
int pS = source == null ? 0 : source.sourceStart, pE = source == null ? 0 : source.sourceEnd;
long p = (long)pS << 32 | pE;
boolean lookForGetter = lookForGetter(field, fieldAccess);
GetterMethod getter = lookForGetter ? findGetter(field) : null;
if (getter == null) {
FieldDeclaration fieldDecl = (FieldDeclaration)field.get();
FieldReference ref = new FieldReference(fieldDecl.name, p);
if ((fieldDecl.modifiers & ClassFileConstants.AccStatic) != 0) {
EclipseNode containerNode = field.up();
if (containerNode != null && containerNode.get() instanceof TypeDeclaration) {
ref.receiver = new SingleNameReference(((TypeDeclaration)containerNode.get()).name, p);
} else {
Expression smallRef = new FieldReference(field.getName().toCharArray(), p);
if (source != null) setGeneratedBy(smallRef, source);
return smallRef;
}
} else {
ref.receiver = new ThisReference(pS, pE);
}
if (source != null) {
setGeneratedBy(ref, source);
setGeneratedBy(ref.receiver, source);
}
return ref;
}
MessageSend call = new MessageSend();
setGeneratedBy(call, source);
call.sourceStart = pS; call.statementEnd = call.sourceEnd = pE;
call.receiver = new ThisReference(pS, pE);
setGeneratedBy(call.receiver, source);
call.selector = getter.name;
return call;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:40,代码来源:EclipseHandlerUtil.java
示例16: generateSingularMethod
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
void generateSingularMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
LombokImmutableList<String> suffixes = getArgumentSuffixes();
char[][] names = new char[suffixes.size()][];
for (int i = 0; i < suffixes.size(); i++) {
String s = suffixes.get(i);
char[] n = data.getSingularName();
names[i] = s.isEmpty() ? n : s.toCharArray();
}
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = ClassFileConstants.AccPublic;
List<Statement> statements = new ArrayList<Statement>();
statements.add(createConstructBuilderVarIfNeeded(data, builderType));
FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
thisDotField.receiver = new ThisReference(0, 0);
MessageSend thisDotFieldDotAdd = new MessageSend();
thisDotFieldDotAdd.arguments = new Expression[suffixes.size()];
for (int i = 0; i < suffixes.size(); i++) {
thisDotFieldDotAdd.arguments[i] = new SingleNameReference(names[i], 0L);
}
thisDotFieldDotAdd.receiver = thisDotField;
thisDotFieldDotAdd.selector = getAddMethodName().toCharArray();
statements.add(thisDotFieldDotAdd);
if (returnStatement != null) statements.add(returnStatement);
md.statements = statements.toArray(new Statement[statements.size()]);
md.arguments = new Argument[suffixes.size()];
for (int i = 0; i < suffixes.size(); i++) {
TypeReference tr = cloneParamType(i, data.getTypeArgs(), builderType);
md.arguments[i] = new Argument(names[i], 0, tr, 0);
}
md.returnType = returnType;
md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName(getAddMethodName(), new String(data.getSingularName())).toCharArray();
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:40,代码来源:EclipseGuavaSingularizer.java
示例17: createConstructBuilderVarIfNeeded
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
protected Statement createConstructBuilderVarIfNeeded(SingularData data, EclipseNode builderType) {
FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
thisDotField.receiver = new ThisReference(0, 0);
FieldReference thisDotField2 = new FieldReference(data.getPluralName(), 0L);
thisDotField2.receiver = new ThisReference(0, 0);
Expression cond = new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.EQUAL_EQUAL);
MessageSend createBuilderInvoke = new MessageSend();
char[][] tokenizedName = makeGuavaTypeName(getSimpleTargetTypeName(data), false);
createBuilderInvoke.receiver = new QualifiedNameReference(tokenizedName, NULL_POSS, 0, 0);
createBuilderInvoke.selector = getBuilderMethodName(data);
return new IfStatement(cond, new Assignment(thisDotField2, createBuilderInvoke, 0), 0, 0);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:14,代码来源:EclipseGuavaSingularizer.java
示例18: generateSingularMethod
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
void generateSingularMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = ClassFileConstants.AccPublic;
List<Statement> statements = new ArrayList<Statement>();
statements.add(createConstructBuilderVarIfNeeded(data, builderType, false));
FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
thisDotField.receiver = new ThisReference(0, 0);
MessageSend thisDotFieldDotAdd = new MessageSend();
thisDotFieldDotAdd.arguments = new Expression[] {new SingleNameReference(data.getSingularName(), 0L)};
thisDotFieldDotAdd.receiver = thisDotField;
thisDotFieldDotAdd.selector = "add".toCharArray();
statements.add(thisDotFieldDotAdd);
if (returnStatement != null) statements.add(returnStatement);
md.statements = statements.toArray(new Statement[statements.size()]);
TypeReference paramType = cloneParamType(0, data.getTypeArgs(), builderType);
Argument param = new Argument(data.getSingularName(), 0, paramType, 0);
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:28,代码来源:EclipseJavaUtilListSetSingularizer.java
示例19: generatePluralMethod
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
void generatePluralMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = ClassFileConstants.AccPublic;
List<Statement> statements = new ArrayList<Statement>();
statements.add(createConstructBuilderVarIfNeeded(data, builderType, false));
FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
thisDotField.receiver = new ThisReference(0, 0);
MessageSend thisDotFieldDotAddAll = new MessageSend();
thisDotFieldDotAddAll.arguments = new Expression[] {new SingleNameReference(data.getPluralName(), 0L)};
thisDotFieldDotAddAll.receiver = thisDotField;
thisDotFieldDotAddAll.selector = "addAll".toCharArray();
statements.add(thisDotFieldDotAddAll);
if (returnStatement != null) statements.add(returnStatement);
md.statements = statements.toArray(new Statement[statements.size()]);
TypeReference paramType = new QualifiedTypeReference(TypeConstants.JAVA_UTIL_COLLECTION, NULL_POSS);
paramType = addTypeArgs(1, true, builderType, paramType, data.getTypeArgs());
Argument param = new Argument(data.getPluralName(), 0, paramType, 0);
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:30,代码来源:EclipseJavaUtilListSetSingularizer.java
示例20: generateClearMethod
import org.eclipse.jdt.internal.compiler.ast.MessageSend; //导入依赖的package包/类
private void generateClearMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = ClassFileConstants.AccPublic;
String pN = new String(data.getPluralName());
char[] keyFieldName = (pN + "$key").toCharArray();
char[] valueFieldName = (pN + "$value").toCharArray();
FieldReference thisDotField = new FieldReference(keyFieldName, 0L);
thisDotField.receiver = new ThisReference(0, 0);
FieldReference thisDotField2 = new FieldReference(keyFieldName, 0L);
thisDotField2.receiver = new ThisReference(0, 0);
FieldReference thisDotField3 = new FieldReference(valueFieldName, 0L);
thisDotField3.receiver = new ThisReference(0, 0);
md.selector = HandlerUtil.buildAccessorName("clear", new String(data.getPluralName())).toCharArray();
MessageSend clearMsg1 = new MessageSend();
clearMsg1.receiver = thisDotField2;
clearMsg1.selector = "clear".toCharArray();
MessageSend clearMsg2 = new MessageSend();
clearMsg2.receiver = thisDotField3;
clearMsg2.selector = "clear".toCharArray();
Block clearMsgs = new Block(2);
clearMsgs.statements = new Statement[] {clearMsg1, clearMsg2};
Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsgs, 0, 0);
md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
md.returnType = returnType;
injectMethod(builderType, md);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:30,代码来源:EclipseJavaUtilMapSingularizer.java
注:本文中的org.eclipse.jdt.internal.compiler.ast.MessageSend类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论