本文整理汇总了Java中org.eclipse.xtend.lib.macro.declaration.CompilationStrategy类的典型用法代码示例。如果您正苦于以下问题:Java CompilationStrategy类的具体用法?Java CompilationStrategy怎么用?Java CompilationStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompilationStrategy类属于org.eclipse.xtend.lib.macro.declaration包,在下文中一共展示了CompilationStrategy类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doTransform
点赞 3
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
@Override
public void doTransform(final MutableClassDeclaration clazz, @Extension final TransformationContext ctx) {
final Iterable<? extends MutableFieldDeclaration> fields = clazz.getDeclaredFields();
final Consumer<MutableFieldDeclaration> _function = (MutableFieldDeclaration field) -> {
MutableTypeDeclaration _declaringType = field.getDeclaringType();
String _simpleName = field.getSimpleName();
String _firstUpper = StringExtensions.toFirstUpper(_simpleName);
String _plus = ("get" + _firstUpper);
final Procedure1<MutableMethodDeclaration> _function_1 = (MutableMethodDeclaration it) -> {
TypeReference _type = field.getType();
it.setReturnType(_type);
final CompilationStrategy _function_2 = (CompilationStrategy.CompilationContext it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return this.");
String _simpleName_1 = field.getSimpleName();
_builder.append(_simpleName_1, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
return _builder;
};
it.setBody(_function_2);
};
_declaringType.addMethod(_plus, _function_1);
};
fields.forEach(_function);
}
开发者ID:East196,
项目名称:maker,
代码行数:27,
代码来源:GettersCompilationParticipant.java
示例2: doTransform
点赞 3
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
@Override
public void doTransform(final MutableFieldDeclaration field, @Extension final TransformationContext ctx) {
MutableTypeDeclaration _declaringType = field.getDeclaringType();
String _simpleName = field.getSimpleName();
String _firstUpper = StringExtensions.toFirstUpper(_simpleName);
String _plus = ("get" + _firstUpper);
final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> {
TypeReference _type = field.getType();
it.setReturnType(_type);
final CompilationStrategy _function_1 = (CompilationStrategy.CompilationContext it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return this.");
String _simpleName_1 = field.getSimpleName();
_builder.append(_simpleName_1, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
return _builder;
};
it.setBody(_function_1);
};
_declaringType.addMethod(_plus, _function);
}
开发者ID:East196,
项目名称:maker,
代码行数:23,
代码来源:GetterCompilationParticipant.java
示例3: doTransform
点赞 3
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
@Override
public void doTransform(final MutableClassDeclaration clazz, @Extension final TransformationContext ctx) {
final TypeReference logger = ctx.newTypeReference(Logger.class);
final TypeReference loggerFactory = ctx.newTypeReference(LoggerFactory.class);
final Procedure1<MutableFieldDeclaration> _function = (MutableFieldDeclaration it) -> {
it.setType(logger);
it.setStatic(true);
it.setFinal(true);
final CompilationStrategy _function_1 = (CompilationStrategy.CompilationContext it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _javaCode = it_1.toJavaCode(loggerFactory);
_builder.append(_javaCode, "");
_builder.append(".getLogger(");
String _simpleName = clazz.getSimpleName();
_builder.append(_simpleName, "");
_builder.append(".class)");
return _builder;
};
it.setInitializer(_function_1);
};
clazz.addField("log", _function);
}
开发者ID:East196,
项目名称:maker,
代码行数:23,
代码来源:Slf4jCompilationParticipant.java
示例4: doTransform
点赞 3
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
@Override
public void doTransform(final MutableClassDeclaration clazz, @Extension final TransformationContext ctx) {
final TypeReference toStringBuilder = ctx.newTypeReference(ToStringBuilder.class);
final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> {
AnnotationReference _newAnnotationReference = ctx.newAnnotationReference(Override.class);
it.addAnnotation(_newAnnotationReference);
TypeReference _string = ctx.getString();
it.setReturnType(_string);
final CompilationStrategy _function_1 = (CompilationStrategy.CompilationContext it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("String result = new ");
String _javaCode = it_1.toJavaCode(toStringBuilder);
_builder.append(_javaCode, "");
_builder.append("(this).addAllFields().toString();");
_builder.newLineIfNotEmpty();
_builder.append("return result;");
_builder.newLine();
return _builder;
};
it.setBody(_function_1);
};
clazz.addMethod("toString", _function);
}
开发者ID:East196,
项目名称:maker,
代码行数:24,
代码来源:ToStringCompilationParticipant.java
示例5: doTransform
点赞 3
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
@Override
public void doTransform(final MutableClassDeclaration clazz, @Extension final TransformationContext ctx) {
final TypeReference logger = ctx.newTypeReference(Logger.class);
final Procedure1<MutableFieldDeclaration> _function = (MutableFieldDeclaration it) -> {
it.setType(logger);
it.setStatic(true);
it.setFinal(true);
final CompilationStrategy _function_1 = (CompilationStrategy.CompilationContext it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _javaCode = it_1.toJavaCode(logger);
_builder.append(_javaCode, "");
_builder.append(".getLogger(");
String _simpleName = clazz.getSimpleName();
_builder.append(_simpleName, "");
_builder.append(".class.getName())");
return _builder;
};
it.setInitializer(_function_1);
};
clazz.addField("log", _function);
}
开发者ID:East196,
项目名称:maker,
代码行数:22,
代码来源:LogCompilationParticipant.java
示例6: addEitherSetter
点赞 2
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
protected void addEitherSetter(final MutableFieldDeclaration field, final String setterName, final EitherTypeArgument argument, @Extension final JsonRpcDataTransformationContext context) {
final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration method) -> {
context.setPrimarySourceElement(method, context.getPrimarySourceElement(field));
method.addParameter(field.getSimpleName(), argument.getType());
method.setStatic(field.isStatic());
method.setVisibility(Visibility.PUBLIC);
method.setReturnType(context.getPrimitiveVoid());
final CompilationStrategy _function_1 = (CompilationStrategy.CompilationContext ctx) -> {
return this.compileEitherSetterBody(field, argument, field.getSimpleName(), ctx, context);
};
method.setBody(_function_1);
};
field.getDeclaringType().addMethod(setterName, _function);
}
开发者ID:eclipse,
项目名称:lsp4j,
代码行数:15,
代码来源:JsonRpcDataProcessor.java
示例7: addImplementationFor
点赞 2
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
/**
* Copies the header of the given base method so that you only have to add a body in most cases.
* You are free to modify the default settings, of course, e.g. widening the visibility of the
* implementing method.
*/
public MutableMethodDeclaration addImplementationFor(final MutableClassDeclaration cls, final MethodDeclaration baseMethod, final CompilationStrategy implementation) {
MutableMethodDeclaration _xblockexpression = null;
{
final MutableMethodDeclaration method = this.createImplementation(cls, baseMethod);
method.setBody(implementation);
_xblockexpression = method;
}
return _xblockexpression;
}
开发者ID:East196,
项目名称:maker,
代码行数:15,
代码来源:CommonTransformations.java
示例8: addIndirection
点赞 2
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
/**
* Moves the body of this method to a new private method with the given name.
* The original method then gets the newly specified body which can delegate to the inner method.
* @return the inner method.
*/
public MutableMethodDeclaration addIndirection(final MutableMethodDeclaration wrapper, final String innerMethodName, final CompilationStrategy indirection) {
MutableMethodDeclaration _xblockexpression = null;
{
final MutableMethodDeclaration inner = this.createInnerMethod(wrapper, innerMethodName);
wrapper.setBody(indirection);
_xblockexpression = inner;
}
return _xblockexpression;
}
开发者ID:East196,
项目名称:maker,
代码行数:15,
代码来源:CommonTransformations.java
示例9: doTransform
点赞 2
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
@Override
public void doTransform(final MutableFieldDeclaration field, @Extension final TransformationContext ctx) {
final TypeReference preconditions = ctx.newTypeReference(Preconditions.class);
MutableTypeDeclaration _declaringType = field.getDeclaringType();
String _simpleName = field.getSimpleName();
String _firstUpper = StringExtensions.toFirstUpper(_simpleName);
String _plus = ("set" + _firstUpper);
final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> {
TypeReference _primitiveVoid = ctx.getPrimitiveVoid();
it.setReturnType(_primitiveVoid);
String _simpleName_1 = field.getSimpleName();
TypeReference _type = field.getType();
it.addParameter(_simpleName_1, _type);
final CompilationStrategy _function_1 = (CompilationStrategy.CompilationContext it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _javaCode = it_1.toJavaCode(preconditions);
_builder.append(_javaCode, "");
_builder.append(".checkNotNull(");
String _simpleName_2 = field.getSimpleName();
_builder.append(_simpleName_2, "");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("this.");
String _simpleName_3 = field.getSimpleName();
_builder.append(_simpleName_3, "");
_builder.append(" = ");
String _simpleName_4 = field.getSimpleName();
_builder.append(_simpleName_4, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
return _builder;
};
it.setBody(_function_1);
};
_declaringType.addMethod(_plus, _function);
}
开发者ID:East196,
项目名称:maker,
代码行数:37,
代码来源:SetterCompilationParticipant.java
示例10: doTransform
点赞 2
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
@Override
public void doTransform(final MutableClassDeclaration clazz, @Extension final TransformationContext ctx) {
final Iterable<? extends MutableFieldDeclaration> fields = clazz.getDeclaredFields();
final TypeReference preconditions = ctx.newTypeReference(Preconditions.class);
final Consumer<MutableFieldDeclaration> _function = (MutableFieldDeclaration field) -> {
MutableTypeDeclaration _declaringType = field.getDeclaringType();
String _simpleName = field.getSimpleName();
String _firstUpper = StringExtensions.toFirstUpper(_simpleName);
String _plus = ("set" + _firstUpper);
final Procedure1<MutableMethodDeclaration> _function_1 = (MutableMethodDeclaration it) -> {
TypeReference _primitiveVoid = ctx.getPrimitiveVoid();
it.setReturnType(_primitiveVoid);
String _simpleName_1 = field.getSimpleName();
TypeReference _type = field.getType();
it.addParameter(_simpleName_1, _type);
final CompilationStrategy _function_2 = (CompilationStrategy.CompilationContext it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _javaCode = it_1.toJavaCode(preconditions);
_builder.append(_javaCode, "");
_builder.append(".checkNotNull(");
String _simpleName_2 = field.getSimpleName();
_builder.append(_simpleName_2, "");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("this.");
String _simpleName_3 = field.getSimpleName();
_builder.append(_simpleName_3, "");
_builder.append(" = ");
String _simpleName_4 = field.getSimpleName();
_builder.append(_simpleName_4, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
return _builder;
};
it.setBody(_function_2);
};
_declaringType.addMethod(_plus, _function_1);
};
fields.forEach(_function);
}
开发者ID:East196,
项目名称:maker,
代码行数:41,
代码来源:SettersCompilationParticipant.java
示例11: doTransform
点赞 2
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
@Override
public void doTransform(final MutableClassDeclaration clazz, @Extension final TransformationContext ctx) {
final Procedure1<MutableConstructorDeclaration> _function = (MutableConstructorDeclaration it) -> {
final CompilationStrategy _function_1 = (CompilationStrategy.CompilationContext it_1) -> {
StringConcatenation _builder = new StringConcatenation();
return _builder;
};
it.setBody(_function_1);
};
clazz.addConstructor(_function);
}
开发者ID:East196,
项目名称:maker,
代码行数:12,
代码来源:NoArgsConstructorCompilationParticipant.java
示例12: compileEitherSetterBody
点赞 2
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
protected CharSequence compileEitherSetterBody(final MutableFieldDeclaration field, final EitherTypeArgument argument, final String variableName, @Extension final CompilationStrategy.CompilationContext compilaitonContext, @Extension final JsonRpcDataTransformationContext context) {
CharSequence _xblockexpression = null;
{
final String newVariableName = ("_" + variableName);
StringConcatenation _builder = new StringConcatenation();
String _javaCode = compilaitonContext.toJavaCode(context.getEitherType());
_builder.append(_javaCode);
_builder.append(".for");
{
boolean _isRight = argument.isRight();
if (_isRight) {
_builder.append("Right");
} else {
_builder.append("Left");
}
}
_builder.append("(");
_builder.append(variableName);
_builder.append(")");
final String compileNewEither = _builder.toString();
StringConcatenation _builder_1 = new StringConcatenation();
{
EitherTypeArgument _parent = argument.getParent();
boolean _tripleNotEquals = (_parent != null);
if (_tripleNotEquals) {
_builder_1.append("final ");
String _javaCode_1 = compilaitonContext.toJavaCode(argument.getParent().getType());
_builder_1.append(_javaCode_1);
_builder_1.append(" ");
_builder_1.append(newVariableName);
_builder_1.append(" = ");
_builder_1.append(compileNewEither);
_builder_1.append(";");
_builder_1.newLineIfNotEmpty();
CharSequence _compileEitherSetterBody = this.compileEitherSetterBody(field, argument.getParent(), newVariableName, compilaitonContext, context);
_builder_1.append(_compileEitherSetterBody);
_builder_1.newLineIfNotEmpty();
} else {
_builder_1.append("this.");
String _simpleName = field.getSimpleName();
_builder_1.append(_simpleName);
_builder_1.append(" = ");
_builder_1.append(compileNewEither);
_builder_1.append(";");
_builder_1.newLineIfNotEmpty();
}
}
_xblockexpression = _builder_1;
}
return _xblockexpression;
}
开发者ID:eclipse,
项目名称:lsp4j,
代码行数:52,
代码来源:JsonRpcDataProcessor.java
示例13: doTransform
点赞 2
import org.eclipse.xtend.lib.macro.declaration.CompilationStrategy; //导入依赖的package包/类
@Override
public void doTransform(final MutableClassDeclaration clazz, @Extension final TransformationContext ctx) {
final Iterable<? extends MutableFieldDeclaration> fields = clazz.getDeclaredFields();
final TypeReference preconditions = ctx.newTypeReference(Preconditions.class);
final Consumer<MutableFieldDeclaration> _function = (MutableFieldDeclaration field) -> {
MutableTypeDeclaration _declaringType = field.getDeclaringType();
String _simpleName = field.getSimpleName();
String _firstUpper = StringExtensions.toFirstUpper(_simpleName);
String _plus = ("set" + _firstUpper);
final Procedure1<MutableMethodDeclaration> _function_1 = (MutableMethodDeclaration it) -> {
TypeReference _newTypeReference = ctx.newTypeReference(clazz);
it.setReturnType(_newTypeReference);
String _simpleName_1 = field.getSimpleName();
TypeReference _type = field.getType();
it.addParameter(_simpleName_1, _type);
final CompilationStrategy _function_2 = (CompilationStrategy.CompilationContext it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _javaCode = it_1.toJavaCode(preconditions);
_builder.append(_javaCode, "");
_builder.append(".checkNotNull(");
String _simpleName_2 = field.getSimpleName();
_builder.append(_simpleName_2, "");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("this.");
String _simpleName_3 = field.getSimpleName();
_builder.append(_simpleName_3, "");
_builder.append(" = ");
String _simpleName_4 = field.getSimpleName();
_builder.append(_simpleName_4, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("return this ;");
_builder.newLine();
return _builder;
};
it.setBody(_function_2);
};
_declaringType.addMethod(_plus, _function_1);
};
fields.forEach(_function);
}
开发者ID:East196,
项目名称:maker,
代码行数:43,
代码来源:FluentSettersCompilationParticipant.java