当前位置: 首页>>代码示例>>Java>>正文


Java TransformationContext类代码示例

本文整理汇总了Java中org.eclipse.xtend.lib.macro.TransformationContext的典型用法代码示例。如果您正苦于以下问题:Java TransformationContext类的具体用法?Java TransformationContext怎么用?Java TransformationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransformationContext类属于org.eclipse.xtend.lib.macro包,在下文中一共展示了TransformationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doTransform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
@Override
public void doTransform(final MutableFieldDeclaration it, @Extension final TransformationContext context) {
  @Extension
  final AccessorsProcessor.Util util = new AccessorsProcessor.Util(context);
  boolean _hasGetter = util.hasGetter(it);
  boolean _not = (!_hasGetter);
  if (_not) {
    util.addGetter(it, Visibility.PUBLIC);
  }
  if (((!it.isFinal()) && (!util.hasSetter(it)))) {
    util.addSetter(it, Visibility.PUBLIC);
  }
  String _firstLower = StringExtensions.toFirstLower(it.getSimpleName());
  String _plus = ("_" + _firstLower);
  it.setSimpleName(_plus);
}
 
开发者ID:eclipse,项目名称:xtext-lib,代码行数:17,代码来源:PropertyProcessor.java

示例2: doTransform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
@Override
public void doTransform(final MutableClassDeclaration cls, @Extension final TransformationContext context) {
  final Procedure1<MutableFieldDeclaration> _function = (MutableFieldDeclaration it) -> {
    it.setStatic(true);
    it.setFinal(true);
    it.setType(context.newTypeReference(Logger.class));
    StringConcatenationClient _client = new StringConcatenationClient() {
      @Override
      protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
        _builder.append(Logger.class);
        _builder.append(".getLogger(");
        String _simpleName = cls.getSimpleName();
        _builder.append(_simpleName);
        _builder.append(".class)");
        _builder.newLineIfNotEmpty();
      }
    };
    it.setInitializer(_client);
    context.setPrimarySourceElement(it, cls);
  };
  cls.addField("LOG", _function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:LogProcessor.java

示例3: doTransform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
@Override
public void doTransform(final List<? extends MutableMethodDeclaration> methods, @Extension final TransformationContext context) {
  final Consumer<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> {
    Iterable<? extends MutableParameterDeclaration> _parameters = it.getParameters();
    int _size = IterableExtensions.size(_parameters);
    switch (_size) {
      case 0:
        ParamterlessMethodMemoizer _paramterlessMethodMemoizer = new ParamterlessMethodMemoizer(it, context);
        _paramterlessMethodMemoizer.generate();
        break;
      case 1:
        SingleParameterMethodMemoizer _singleParameterMethodMemoizer = new SingleParameterMethodMemoizer(it, context);
        _singleParameterMethodMemoizer.generate();
        break;
      default:
        MultipleParameterMethodMemoizer _multipleParameterMethodMemoizer = new MultipleParameterMethodMemoizer(it, context);
        _multipleParameterMethodMemoizer.generate();
        break;
    }
  };
  methods.forEach(_function);
}
 
开发者ID:East196,项目名称:maker,代码行数:23,代码来源:CachedProcessor.java

示例4: doTransform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的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

示例5: doTransform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的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

示例6: doTransform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的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

示例7: doTransform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的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

示例8: doTransform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的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

示例9: _transform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
protected void _transform(final MutableFieldDeclaration it, @Extension final TransformationContext context) {
	@Extension
	final DirtyAccessorsProcessor.Util util = new DirtyAccessorsProcessor.Util(context);
	final boolean _shouldAddGetter = util.shouldAddGetter(it);
	if (_shouldAddGetter) {
		final AccessorType _getterType = util.getGetterType(it);
		final Visibility _visibility = util.toVisibility(_getterType);
		util.addGetter(it, _visibility);
	}
	final boolean _shouldAddSetter = util.shouldAddSetter(it);
	if (_shouldAddSetter) {
		final AccessorType _setterType = util.getSetterType(it);
		final Visibility _visibility_1 = util.toVisibility(_setterType);
		util.addSetter(it, _visibility_1);
	}
}
 
开发者ID:CymricNPG,项目名称:abattle,代码行数:17,代码来源:DirtyAccessorsProcessor.java

示例10: init_superclass

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
/**
 * For each annoted class store his super classes hierarchy.
 * An annoted class which is a parent of an other annoted
 * class is not in the final result.
 * 
 * @annotedClasses All aspects
 * @superclass Mapping computed between class and list of his super classes
 * @context
 */
public void init_superclass(final List<? extends MutableClassDeclaration> annotedClasses, final TransformationContext context, final Map<MutableClassDeclaration,List<MutableClassDeclaration>> superclass) {
  for (final MutableClassDeclaration clazz : annotedClasses) {
    {
      ArrayList<MutableClassDeclaration> _arrayList = new ArrayList<MutableClassDeclaration>();
      final ArrayList<MutableClassDeclaration> ext = _arrayList;
      this.getSuperClass(ext, clazz, context);
      int _size = ext.size();
      boolean _greaterThan = (_size > 0);
      if (_greaterThan) {
        superclass.put(clazz, ext);
      }
    }
  }
  LinkedHashSet<MutableClassDeclaration> _linkedHashSet = new LinkedHashSet<MutableClassDeclaration>();
  final LinkedHashSet<MutableClassDeclaration> allparent = _linkedHashSet;
  Set<MutableClassDeclaration> _keySet = superclass.keySet();
  for (final MutableClassDeclaration child : _keySet) {
    List<MutableClassDeclaration> _get = superclass.get(child);
    allparent.addAll(_get);
  }
  for (final MutableClassDeclaration p : allparent) {
    superclass.remove(p);
  }
}
 
开发者ID:damien-cremilleux,项目名称:TP4INFO,代码行数:34,代码来源:AspectProcessor.java

示例11: getAllPre

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
private void getAllPre(final MutableClassDeclaration cl, final List<MutableMethodDeclaration> pres, final String MsimpleName, @Extension final TransformationContext context) {
  Iterable<? extends MutableMethodDeclaration> _declaredMethods = cl.getDeclaredMethods();
  final Function1<MutableMethodDeclaration,Boolean> _function = new Function1<MutableMethodDeclaration,Boolean>() {
    public Boolean apply(final MutableMethodDeclaration m1) {
      String _simpleName = m1.getSimpleName();
      String _plus = ("pre" + MsimpleName);
      boolean _equals = Objects.equal(_simpleName, _plus);
      return Boolean.valueOf(_equals);
    }
  };
  Iterable<? extends MutableMethodDeclaration> _filter = IterableExtensions.filter(_declaredMethods, _function);
  Iterables.<MutableMethodDeclaration>addAll(pres, _filter);
  TypeReference _extendedClass = cl.getExtendedClass();
  boolean _notEquals = (!Objects.equal(_extendedClass, null));
  if (_notEquals) {
    TypeReference _extendedClass_1 = cl.getExtendedClass();
    String _name = _extendedClass_1.getName();
    final MutableClassDeclaration parent = context.findClass(_name);
    boolean _notEquals_1 = (!Objects.equal(parent, null));
    if (_notEquals_1) {
      this.getAllPre(parent, pres, MsimpleName, context);
    }
  }
}
 
开发者ID:damien-cremilleux,项目名称:TP4INFO,代码行数:25,代码来源:ContractedProcessor.java

示例12: getAllPost

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
private void getAllPost(final MutableClassDeclaration cl, final List<MutableMethodDeclaration> posts, final String simpleName, @Extension final TransformationContext context) {
  Iterable<? extends MutableMethodDeclaration> _declaredMethods = cl.getDeclaredMethods();
  final Function1<MutableMethodDeclaration,Boolean> _function = new Function1<MutableMethodDeclaration,Boolean>() {
    public Boolean apply(final MutableMethodDeclaration m1) {
      String _simpleName = m1.getSimpleName();
      String _plus = ("post" + simpleName);
      boolean _equals = Objects.equal(_simpleName, _plus);
      return Boolean.valueOf(_equals);
    }
  };
  Iterable<? extends MutableMethodDeclaration> _filter = IterableExtensions.filter(_declaredMethods, _function);
  Iterables.<MutableMethodDeclaration>addAll(posts, _filter);
  TypeReference _extendedClass = cl.getExtendedClass();
  boolean _notEquals = (!Objects.equal(_extendedClass, null));
  if (_notEquals) {
    TypeReference _extendedClass_1 = cl.getExtendedClass();
    String _name = _extendedClass_1.getName();
    final MutableClassDeclaration parent = context.findClass(_name);
    boolean _notEquals_1 = (!Objects.equal(parent, null));
    if (_notEquals_1) {
      this.getAllPost(parent, posts, simpleName, context);
    }
  }
}
 
开发者ID:damien-cremilleux,项目名称:TP4INFO,代码行数:25,代码来源:ContractedProcessor.java

示例13: doTransform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
@Override
public void doTransform(final List<? extends MutableTypeParameterDeclarator> elements, @Extension final TransformationContext context) {
  final Procedure1<MutableTypeParameterDeclarator> _function = new Procedure1<MutableTypeParameterDeclarator>() {
    @Override
    public void apply(final MutableTypeParameterDeclarator it) {
      FinalFieldsConstructorProcessor.this.transform(it, context);
    }
  };
  IterableExtensions.forEach(elements, _function);
}
 
开发者ID:eclipse,项目名称:xtext-lib,代码行数:11,代码来源:FinalFieldsConstructorProcessor.java

示例14: _transform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
protected void _transform(final MutableClassDeclaration it, @Extension final TransformationContext context) {
  AnnotationReference _findAnnotation = it.findAnnotation(context.findTypeGlobally(Data.class));
  boolean _tripleNotEquals = (_findAnnotation != null);
  if (_tripleNotEquals) {
    return;
  }
  AnnotationReference _findAnnotation_1 = it.findAnnotation(context.findTypeGlobally(Accessors.class));
  boolean _tripleNotEquals_1 = (_findAnnotation_1 != null);
  if (_tripleNotEquals_1) {
    return;
  }
  @Extension
  final FinalFieldsConstructorProcessor.Util util = new FinalFieldsConstructorProcessor.Util(context);
  util.addFinalFieldsConstructor(it);
}
 
开发者ID:eclipse,项目名称:xtext-lib,代码行数:16,代码来源:FinalFieldsConstructorProcessor.java

示例15: transform

import org.eclipse.xtend.lib.macro.TransformationContext; //导入依赖的package包/类
public void transform(final MutableTypeParameterDeclarator it, final TransformationContext context) {
  if (it instanceof MutableConstructorDeclaration) {
    _transform((MutableConstructorDeclaration)it, context);
    return;
  } else if (it instanceof MutableClassDeclaration) {
    _transform((MutableClassDeclaration)it, context);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, context).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-lib,代码行数:13,代码来源:FinalFieldsConstructorProcessor.java


注:本文中的org.eclipse.xtend.lib.macro.TransformationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。