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


Java JavaSource类代码示例

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


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


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