コード例 #1
0
 public void infer(
     EObject xtendFile, IAcceptor<JvmDeclaredType> acceptor, boolean prelinkingPhase) {
   if (!(xtendFile instanceof XtendFile)) return;
   final XtendFile xtendFile2 = (XtendFile) xtendFile;
   XtendClass xtendClass = xtendFile2.getXtendClass();
   if (xtendClass == null) return;
   JvmGenericType inferredJvmType = transform(xtendClass, prelinkingPhase);
   acceptor.accept(inferredJvmType);
 }
コード例 #2
0
 protected String compileToJavaCode(String xtendCode) {
   try {
     final String text =
         "package foo class Test { def Object foo() throws Exception {" + xtendCode + "} }";
     final XtendFile file = parseHelper.parse(text);
     validationHelper.assertNoErrors(file);
     JvmGenericType inferredType = associations.getInferredType(file.getXtendClass());
     CharSequence javaCode = generator.generateType(inferredType);
     return javaCode.toString();
   } catch (Exception e) {
     throw new RuntimeException("Xtend compilation failed for: " + xtendCode, e);
   }
 }
コード例 #3
0
 protected void _createChildren(DocumentRootNode parentNode, XtendFile xtendFile) {
   if (xtendFile.getPackage() != null)
     createEStructuralFeatureNode(
         parentNode,
         xtendFile,
         Xtend2Package.Literals.XTEND_FILE__PACKAGE,
         images.forPackage(),
         xtendFile.getPackage(),
         true);
   if (!xtendFile.getImports().isEmpty())
     createEStructuralFeatureNode(
         parentNode,
         xtendFile,
         Xtend2Package.Literals.XTEND_FILE__IMPORTS,
         images.forImportContainer(),
         "import declarations",
         false);
   if (xtendFile.getXtendClass() != null) createEObjectNode(parentNode, xtendFile.getXtendClass());
 }