• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JavaSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: readYStatementFromFile

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
public static YStatementJustificationWrapper readYStatementFromFile(Path path) throws IOException {
    AnnotationSource annotation;
    try (InputStream stream = Files.newInputStream(path)) {
        final JavaSource javaSource = (JavaSource) Roaster.parse(stream);
        LOG.debug("Read YStatementJustification from {}", path);
        annotation = javaSource.getAnnotation(YStatementJustification.class);
    }
    if (annotation == null) {
        return null;
    }

    YStatementJustificationWrapper decision = createYStatementJustificationFromAnnotationSource
            (annotation);
    LOG.info("Found YStatementJustification {}", decision);
    DecisionSourceMapping.putLocalSource(decision.getId(), path.toString());
    return decision;
}
 
开发者ID:adr,项目名称:eadlsync,代码行数:18,代码来源:JavaDecisionParser.java


示例2: addYStatementToClassSource

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
private static void addYStatementToClassSource(YStatementJustificationWrapper yStatement,
                                               JavaSource javaSource) {
    LOG.debug("YStatementJustification values {}", yStatement);
    AnnotationSource newAnnotation = javaSource.addAnnotation(YStatementJustification.class);
    newAnnotation.setStringValue(YStatementConstants.ID, yStatement.getId());
    if (!yStatement.getContext().isEmpty())
        newAnnotation.setStringValue(YStatementConstants.CONTEXT, yStatement.getContext());
    if (!yStatement.getFacing().isEmpty())
        newAnnotation.setStringValue(YStatementConstants.FACING, yStatement.getFacing());
    if (!yStatement.getChosen().isEmpty())
        newAnnotation.setStringValue(YStatementConstants.CHOSEN, yStatement.getChosen());
    if (!yStatement.getNeglected().isEmpty())
        newAnnotation.setStringValue(YStatementConstants.NEGLECTED, yStatement.getNeglected());
    if (!yStatement.getAchieving().isEmpty())
        newAnnotation.setStringValue(YStatementConstants.ACHIEVING, yStatement.getAchieving());
    if (!yStatement.getAccepting().isEmpty())
        newAnnotation.setStringValue(YStatementConstants.ACCEPTING, yStatement.getAccepting());
}
 
开发者ID:adr,项目名称:eadlsync,代码行数:19,代码来源:JavaDecisionParser.java


示例3: visit

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
@Override
public void visit(VisitContext context, JavaResource javaResource)
{
   if (!found)
   {
      try
      {
         JavaSource<?> javaSource = javaResource.getJavaType();
         if (javaSource instanceof JavaClass)
         {
            JavaClass<?> javaClass = (JavaClass<?>) javaSource;
            if (javaClass.getName().equals(entityName + "Endpoint") && javaClass.hasAnnotation(Path.class))
            {
               this.path = javaClass.getAnnotation(Path.class).getStringValue();
               found = true;
            }
         }
      }
      catch (FileNotFoundException e)
      {
         throw new RuntimeException(e);
      }
   }
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:25,代码来源:ResourcePathVisitor.java


示例4: visit

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
@Override
public void visit(VisitContext context, JavaResource javaResource)
{
   if (!found)
   {
      try
      {
         JavaSource<?> javaType = javaResource.getJavaType();
         if (javaType.getAnnotation("javax.ws.rs.Path") != null)
         {
            String path = javaType.getAnnotation("javax.ws.rs.Path")
                     .getStringValue();
            String absolutePath = path.endsWith("/") ? path.substring(0, path.lastIndexOf('/')) : path;
            if (absolutePath.equals(proposedPath))
            {
               javaSource = javaType;
               found = true;
            }
         }
      }
      catch (FileNotFoundException e)
      {
         throw new RuntimeException(e);
      }
   }
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:27,代码来源:RestResourceTypeVisitor.java


示例5: visit

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
public void visit(JavaSource javaSource) {

        // Imports
        List<Import> imports = javaSource.getImports();
        for (Import javaImport : imports) {
            visit(javaImport);
        }

        if (javaSource instanceof Body) {
            visit((Body) javaSource);
        } else if (javaSource instanceof JavaAnnotationSource) {
            visit((JavaAnnotationSource) javaSource);
        } else if (javaSource instanceof JavaClassSource) {
            visit((JavaClassSource) javaSource);
        } else if (javaSource instanceof JavaEnumSource) {
            visit((JavaEnumSource) javaSource);
        } else if (javaSource instanceof JavaInterfaceSource) {
            visit((JavaInterfaceSource) javaSource);
        }
    }
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:21,代码来源:JavaSourceVisitor.java


示例6: visit

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
public void visit(FieldSource<? extends JavaSource> fieldSource) {
    Type fieldType = fieldSource.getType();
    String fieldClassName;

    // the javadoc for Named.getName() is misleading:
    // the FieldSource.getName() (which is implemented by FieldImpl.getName())
    // returns the (fully-qualified!) name of the field
    String fieldName = fieldSource.getName();
    resParts.addPart(fieldName,
                     PartType.FIELD);

    if (fieldType.isPrimitive()) {
        fieldClassName = fieldType.getName();
    } else {
        fieldClassName = fieldType.getQualifiedName();
    }
    addJavaResourceReference(fieldClassName);

    // Field annotations
    for (AnnotationSource annoSource : fieldSource.getAnnotations()) {
        visit(annoSource);
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:24,代码来源:TestJavaSourceVisitor.java


示例7: writeModifiedYStatementToFile

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
public static void writeModifiedYStatementToFile(YStatementJustificationWrapper yStatement) throws
        IOException {
    Path path = Paths.get(DecisionSourceMapping.getLocalSource(yStatement.getId()));
    LOG.debug("Modify YStatementJustification {} from {}", yStatement.getId(), path);
    try (InputStream stream = Files.newInputStream(path)) {
        final JavaSource javaSource = (JavaSource) Roaster.parse(stream);
        AnnotationSource annotation = javaSource.getAnnotation(YStatementJustification.class);
        if (YStatementJustificationComparator.isSameButNotEqual(yStatement,
                createYStatementJustificationFromAnnotationSource(annotation))) {
            javaSource.removeAnnotation(annotation);
            addYStatementToClassSource(yStatement, javaSource);
            Files.write(path, javaSource.toString().getBytes(Charset.defaultCharset()));
        }
    }
}
 
开发者ID:adr,项目名称:eadlsync,代码行数:16,代码来源:JavaDecisionParser.java


示例8: removeYStatementFromFile

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
public static void removeYStatementFromFile(YStatementJustificationWrapper yStatement) throws
        IOException {
    Path path = Paths.get(DecisionSourceMapping.getLocalSource(yStatement.getId()));
    LOG.debug("Remove YStatementJustification {} from {}", yStatement.getId(), path);
    try (InputStream stream = Files.newInputStream(path)) {
        final JavaSource javaSource = (JavaSource) Roaster.parse(stream);
        AnnotationSource annotation = javaSource.getAnnotation(YStatementJustification.class);
        if (YStatementJustificationComparator.isSame(yStatement,
                createYStatementJustificationFromAnnotationSource(annotation))) {
            javaSource.removeAnnotation(annotation);
            Files.write(path, javaSource.toString().getBytes(Charset.defaultCharset()));
        }
    }
}
 
开发者ID:adr,项目名称:eadlsync,代码行数:15,代码来源:JavaDecisionParser.java


示例9: addYStatementToFile

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
public static void addYStatementToFile(YStatementJustificationWrapper yStatement) throws
        IOException {
    Path path = Paths.get(DecisionSourceMapping.getLocalSource(yStatement.getId()));
    LOG.debug("Add YStatementJustification {} to {}", yStatement.getId(), path);
    try (InputStream stream = Files.newInputStream(path)) {
        final JavaSource javaSource = (JavaSource) Roaster.parse(stream);
        addYStatementToClassSource(yStatement, javaSource);
        Files.write(path, javaSource.toString().getBytes(Charset.defaultCharset()));
    }
}
 
开发者ID:adr,项目名称:eadlsync,代码行数:11,代码来源:JavaDecisionParser.java


示例10: cache

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
private void cache(JavaType<?> type) {
    if(type instanceof TypeHolderSource<?>) {
        List<JavaSource<?>> nested = ((TypeHolderSource<?>) type).getNestedTypes();
        for (JavaSource<?> child : nested) {
            cache(child);
        }
    }

    String name = type.getName();
    if(javaTypes.containsKey(name)) {
        throw new IllegalStateException("Two java javaTypes defined with the same name: " + name);
    }
    javaTypes.put(name, type);
}
 
开发者ID:sdadas,项目名称:spring2ts,代码行数:15,代码来源:JavaTypeContainer.java


示例11: fillIndexBuilder

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
@Override
protected DefaultIndexBuilder fillIndexBuilder(Path path) throws Exception {
    final DefaultIndexBuilder builder = getIndexBuilder(path);
    if (builder == null) {
        return null;
    }

    String javaSource = ioService.readAllString(path);
    org.jboss.forge.roaster.model.JavaType<?> javaType = Roaster.parse(javaSource);

    if (javaType.getSyntaxErrors() == null || javaType.getSyntaxErrors().isEmpty()) {
        String pkgName = javaType.getPackage();
        if (pkgName == null) {
            pkgName = "";
        }
        // use Java class package name, not Package name
        builder.setPackageName(pkgName);

        String javaTypeName = javaType.getQualifiedName();
        Resource resParts = new Resource(javaTypeName,
                                         ResourceType.JAVA);

        if (javaType instanceof JavaSource) {
            TestJavaSourceVisitor visitor = new TestJavaSourceVisitor((JavaSource) javaType,
                                                                      resParts);
            visitor.visit((JavaSource) javaType);
            addReferencedResourcesToIndexBuilder(builder,
                                                 visitor);
        }

        builder.addGenerator(resParts);
    }

    return builder;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:36,代码来源:TestJavaIndexer.java


示例12: createClassTypeResolver

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
public static ClassTypeResolver createClassTypeResolver(JavaSource javaSource, ClassLoader classLoader) {
    String packageName;
    Set<String> classImports = new HashSet<String>();

    // Importer.getImports() returns both normal and static imports
    // You can see if an Import is static by calling hte
    // Import.isStatic() method
    List<Import> imports = javaSource.getImports();
    if (imports != null) {
        for (Import currentImport : imports) {
            String importName = currentImport.getQualifiedName();
            if (currentImport.isWildcard()) {
                importName = importName + ".*";
            }
            classImports.add(importName);
        }
    }

    packageName = javaSource.getPackage();
    //add current package too, if not added, the class type resolver don't resolve current package classes.
    if (packageName != null && !"".equals(packageName)) {
        classImports.add(packageName + ".*");
    }

    if (javaSource instanceof JavaClassSource) {
        JavaClassSource javaClassSource = (JavaClassSource) javaSource;

        //add current file inner types as import clauses to help the ClassTypeResolver to find variables of inner types
        //It was detected that current ClassTypeResolver don't resolve inner classes well.
        //workaround for BZ https://bugzilla.redhat.com/show_bug.cgi?id=1172711
        List<JavaSource<?>> innerTypes = javaClassSource.getNestedTypes();
        if (innerTypes != null) {
            for (JavaSource<?> type : innerTypes) {
                classImports.add(packageName + "." + javaClassSource.getName() + "." + type.getName());
            }
        }
    }

    return new ClassTypeResolver(classImports, classLoader);
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:41,代码来源:DriverUtils.java


示例13: fillIndexBuilder

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
    // create indexbuilder
    final KieModule module = getModule(path);

    if (module == null) {
        logger.error("Unable to index " + path.toUri().toString() + ": module could not be resolved.");
        return null;
    }

    final Package pkg = getPackage(path);
    if (pkg == null) {
        logger.error("Unable to index " + path.toUri().toString() + ": package could not be resolved.");
        return null;
    }

    // responsible for basic index info: module name, branch, etc
    final DefaultIndexBuilder builder = new DefaultIndexBuilder(Paths.convert(path).getFileName(),
                                                                module,
                                                                pkg);

    // visit/index java source
    final String javaSource = ioService.readAllString(path);
    org.jboss.forge.roaster.model.JavaType<?> javaType = Roaster.parse(javaSource);
    if (javaType.getSyntaxErrors() == null || javaType.getSyntaxErrors().isEmpty()) {

        if (javaFileIndexerExtensions != null) {
            for (JavaFileIndexerExtension javaFileIndexerExtension : javaFileIndexerExtensions) {
                javaFileIndexerExtension.process(builder,
                                                 javaType);
            }
        }

        String pkgName = pkg.getPackageName();
        pkgName = javaType.getPackage();
        if (pkgName == null) {
            pkgName = "";
        }
        // use Java class package name, not Package name
        builder.setPackageName(pkgName);

        String javaTypeName = javaType.getQualifiedName();
        Resource resParts = new Resource(javaTypeName,
                                         ResourceType.JAVA);

        if (javaType instanceof JavaSource) {
            ClassLoader moduleClassLoader = getModuleClassLoader(module);
            JavaSourceVisitor visitor = new JavaSourceVisitor((JavaSource) javaType,
                                                              moduleClassLoader,
                                                              resParts);
            visitor.visit((JavaSource) javaType);
            addReferencedResourcesToIndexBuilder(builder,
                                                 visitor);
        }

        builder.addGenerator(resParts);
    }

    return builder;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:61,代码来源:JavaFileIndexer.java


示例14: JavaSourceVisitor

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
public JavaSourceVisitor(JavaSource javaSource, ClassLoader classLoader, Resource resParts) {
    this.javaSource = javaSource;
    this.classTypeResolver = DriverUtils.createClassTypeResolver(javaSource, classLoader);
    this.resParts = resParts;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:6,代码来源:JavaSourceVisitor.java


示例15: TestJavaSourceVisitor

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
public TestJavaSourceVisitor(JavaSource javaSource,
                             Resource resParts) {
    this.javaSource = javaSource;
    this.resParts = resParts;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:6,代码来源:TestJavaSourceVisitor.java


示例16: addParsedClassToFile

import org.jboss.forge.roaster.model.source.JavaSource; //导入依赖的package包/类
private void addParsedClassToFile(GraphRewrite event, EvaluationContext context, JavaSourceFileModel sourceFileModel, FileInputStream fis)
{
    JavaSource<?> javaSource;
    try
    {
        javaSource = Roaster.parse(JavaSource.class, fis);
    }
    catch (ParserException e)
    {
        ClassificationService classificationService = new ClassificationService(event.getGraphContext());
        classificationService.attachClassification(event, context, sourceFileModel, UNPARSEABLE_JAVA_CLASSIFICATION, UNPARSEABLE_JAVA_DESCRIPTION);
        sourceFileModel.setParseError(UNPARSEABLE_JAVA_CLASSIFICATION + ": " + e.getMessage());
        return;
    }

    String packageName = javaSource.getPackage();
    // set the package name to the parsed value
    sourceFileModel.setPackageName(packageName);

    // Set the root path of this source file (if possible). As this could be coming from user-provided source, it
    // is possible that the path will not match the package name. In this case, we will likely end up with a null
    // root path.
    Path rootSourcePath = PathUtil.getRootFolderForSource(sourceFileModel.asFile().toPath(), packageName);
    if (rootSourcePath != null)
    {
        FileModel rootSourceFileModel = new FileService(event.getGraphContext()).createByFilePath(rootSourcePath.toString());
        sourceFileModel.setRootSourceFolder(rootSourceFileModel);
    }

    String qualifiedName = javaSource.getQualifiedName();

    String simpleName = qualifiedName;
    if (packageName != null && !packageName.isEmpty() && simpleName != null)
    {
        simpleName = simpleName.substring(packageName.length() + 1);
    }

    JavaClassService javaClassService = new JavaClassService(event.getGraphContext());
    JavaClassModel javaClassModel = javaClassService.create(qualifiedName);
    javaClassModel.setOriginalSource(sourceFileModel);
    javaClassModel.setSimpleName(simpleName);
    javaClassModel.setPackageName(packageName);
    javaClassModel.setQualifiedName(qualifiedName);
    javaClassModel.setClassFile(sourceFileModel);
    javaClassModel.setPublic(javaSource.isPublic());
    javaClassModel.setInterface(javaSource.isInterface());

    if (javaSource instanceof InterfaceCapable)
    {
        InterfaceCapable interfaceCapable = (InterfaceCapable) javaSource;
        List<String> interfaceNames = interfaceCapable.getInterfaces();
        if (interfaceNames != null)
        {
            for (String iface : interfaceNames)
            {
                JavaClassModel interfaceModel = javaClassService.getOrCreatePhantom(iface);
                javaClassService.addInterface(javaClassModel, interfaceModel);
            }
        }
    }

    if (!javaSource.isInterface() && javaSource instanceof Extendable)
    {
        Extendable<?> extendable = (Extendable<?>) javaSource;
        String superclassName = extendable.getSuperType();
        if (Strings.isNullOrEmpty(superclassName))
            javaClassModel.setExtends(javaClassService.getOrCreatePhantom(superclassName));
    }

    sourceFileModel.addJavaClass(javaClassModel);
}
 
开发者ID:windup,项目名称:windup,代码行数:72,代码来源:IndexJavaSourceFilesRuleProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FontRes类代码示例发布时间:2022-05-22
下一篇:
Java ThreadSafeClientConnManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap