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


Java JavaParser.parseUiContainer方法代码示例

本文整理汇总了Java中com.github.javaparser.JavaParser.parseUiContainer方法的典型用法代码示例。如果您正苦于以下问题:Java JavaParser.parseUiContainer方法的具体用法?Java JavaParser.parseUiContainer怎么用?Java JavaParser.parseUiContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.javaparser.JavaParser的用法示例。


在下文中一共展示了JavaParser.parseUiContainer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeAppName

import com.github.javaparser.JavaParser; //导入方法依赖的package包/类
protected String computeAppName() {
    final Ui uiAnno = getClass().getAnnotation(Ui.class);
    if (uiAnno == null) {
        throw new IllegalStateException(getClass() + " must have a @Ui annotation!");
    }
    String source = X_String.join("", uiAnno.value());
    try {
        final UiContainerExpr xapi = JavaParser.parseUiContainer(getClass().getCanonicalName(), source);
        if (xapi.getName().startsWith("import")) {
            return xapi.getAttributeNotNull("file")
                .getStringExpression(false)
                .replace(".xapi", "");
        }
    } catch (ParseException e) {
        X_Log.error(DevApp.class, "Error checking app name");
    }
    return getClass().getCanonicalName();
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:19,代码来源:DevApp.java

示例2: generateTemplate

import com.github.javaparser.JavaParser; //导入方法依赖的package包/类
@Override
public boolean generateTemplate(
    JavacService service,
    CompilationUnitTree cup,
    MethodInvocationTree source,
    IsType type,
    String value,
    InjectionResolver resolver
) {
  if (value.trim().startsWith("<")) {
    try {
      final UiContainerExpr expr = JavaParser.parseUiContainer(value);
      final Transformer transformer = getTransformer();
      String src = expr.toSource(transformer);
      resolver.replace(source, src);
    } catch (ParseException e) {
      throw rethrow(e);
    }

  }
  return false;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:23,代码来源:ElementalTemplateGenerator.java

示例3: toHtmlNative

import com.github.javaparser.JavaParser; //导入方法依赖的package包/类
protected String toHtmlNative(String html, Mutable<ShadowDomControllerBuilder> slotController) {
  // optionally adds selector-matching support for V1 slotted elements
  if (html.contains("<slot")) {
    // if a html has slots, check if they use selectors.
    try {
      UiContainerExpr parsed = JavaParser.parseUiContainer(html);
      if (hasSelectorSlot(parsed)) {
        // Only if our source uses a selector slot do we perform slotting.
        // Note, what we should do in this case is not tear off inserted elements;
        // rather, we should just set the correct slot names (as this method assumes native slot support)
        final ShadowDomControllerBuilder builder = ShadowDomControllerBuilder.forSource(parsed, true);
        slotController.in(builder);
      }
      if (parsed.getName().equals("virtual")) {
        return parsed.getBody().toSource();
      }
    } catch (ParseException e) {
      throw new IllegalArgumentException("Bad xapi element", e);
    }
  }
  return html;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:23,代码来源:WebComponentBuilder.java

示例4: loadSettings

import com.github.javaparser.JavaParser; //导入方法依赖的package包/类
private void loadSettings(Ctx ctx, StringTo<GeneratedUiDefinition> map, URL settingsFile) throws IOException,
                                                                                        ParseException {
    // TODO have a settings service to do this once globally per classloader
    String source = X_IO.toStringUtf8(settingsFile.openStream());
    final UiContainerExpr container = JavaParser.parseUiContainer(source);
    for (UiAttrExpr component : container.getAttributesMatching(attr -> attr.getNameString().equals("components"))) {
        if (!(component.getExpression() instanceof JsonContainerExpr)) {
            throw new IllegalArgumentException("Components tag must be a [json, array]; you sent " + component);
        }
        JsonContainerExpr items = (JsonContainerExpr) component.getExpression();
        if (!items.isArray()) {
            throw new IllegalArgumentException("Components tag must be a [json, array]; you sent " + component);
        }
        items.getValues()
             .forAll(e->{
                 final GeneratedUiDefinition definition = GeneratedUiDefinition.fromSettings(
                     tools(),
                     ctx,
                     (UiContainerExpr) e
                 );
                 map.put(definition.getTagName(), definition);
                 map.put(definition.getTypeName(), definition);
                 map.put(definition.getQualifiedName(), definition);
             });
    }
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:27,代码来源:AbstractUiGeneratorService.java

示例5: onTemplateStart

import com.github.javaparser.JavaParser; //导入方法依赖的package包/类
@Override
public String onTemplateStart(
    Printable printer, TemplateLiteralExpr template
) {
  if (shouldConvertToString(template)) {
    if (delegate == null) {
      normalizeToString(printer, template.getValueWithoutTicks());
    } else {
      delegate.normalizeToString(printer, template.getValueWithoutTicks());
    }
    return DO_NOT_PRINT;
  }
  if (plugin == null) {
    if (delegate != null) {
      return delegate.onTemplateStart(printer, template);
    }
    return super.onTemplateStart(printer, template);
  }
  final UiContainerExpr ui;
  try {
    // For now, only supporting "html" roots
    ui = JavaParser.parseUiContainer("<content>"+template.getValueWithoutTicks()+"</content>");
  } catch (ParseException e) {
    throw new RuntimeException(e);
  }
  return plugin.transformUi(printer, ui.getBody());
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:28,代码来源:UiTransformer.java

示例6: testSerialization

import com.github.javaparser.JavaParser; //导入方法依赖的package包/类
@Test
public void testSerialization() throws IOException, ParseException {
    manager.getSettings()
        .addAttribute("hello", StringLiteralExpr.stringLiteral("world"));
    manager.saveSettings();
    final String location = manager.getFileLocation();
    final File file = new File(location, "settings.xapi");
    String in = X_IO.toStringUtf8(new FileInputStream(file));
    final UiContainerExpr parsed = JavaParser.parseUiContainer(location, in);
    assertEquals("Imperfect deserialization:", in, parsed.toSource());
    assertTrue(parsed.getAttribute("hello").isPresent());
    assertEquals("\"world\"", parsed.getAttributeNotNull("hello").getExpression().toSource());
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:14,代码来源:SettingsManagerTest.java

示例7: named

import com.github.javaparser.JavaParser; //导入方法依赖的package包/类
@Given("^Generate web app named (.+):$")
public void generateWebApp(String name, List<String> source) throws ParseException, ClassNotFoundException {
    String src = X_String.join("\n", source);
    final UiContainerExpr app = JavaParser.parseUiContainer(src);
    createWebApp(name, app);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:7,代码来源:ServerGenSteps.java

示例8: name

import com.github.javaparser.JavaParser; //导入方法依赖的package包/类
@Given("^compile ui with name (\\S)+:$")
public void compileTemplate(String name, List<String> lines) throws Throwable {
  String src = join("\n", lines);
  final UiContainerExpr ui = JavaParser.parseUiContainer(src);
  compiledByName.put(name, ui);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:7,代码来源:TemplateGeneratorSteps.java


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