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


Java JavaFileObject.getKind方法代码示例

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


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

示例1: fillIn

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
private void fillIn(PackageSymbol p,
                    Location location,
                    Iterable<JavaFileObject> files) {
    currentLoc = location;
    for (JavaFileObject fo : files) {
        switch (fo.getKind()) {
            case CLASS:
            case SOURCE: {
                // TODO pass binaryName to includeClassFile
                String binaryName = fileManager.inferBinaryName(currentLoc, fo);
                String simpleName = binaryName.substring(binaryName.lastIndexOf(".") + 1);
                if (SourceVersion.isIdentifier(simpleName) ||
                        simpleName.equals("package-info"))
                    includeClassFile(p, fo);
                break;
            }
            default:
                extraFileActions(p, fo);
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:22,代码来源:ClassReader.java

示例2: enterClassFiles

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/** Enter a set of generated class files. */
private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
    ClassReader reader = ClassReader.instance(context);
    Names names = Names.instance(context);
    List<ClassSymbol> list = List.nil();

    for (Map.Entry<String,JavaFileObject> entry : classFiles.entrySet()) {
        Name name = names.fromString(entry.getKey());
        JavaFileObject file = entry.getValue();
        if (file.getKind() != JavaFileObject.Kind.CLASS)
            throw new AssertionError(file);
        ClassSymbol cs;
        if (isPkgInfo(file, JavaFileObject.Kind.CLASS)) {
            Name packageName = Convert.packagePart(name);
            PackageSymbol p = reader.enterPackage(packageName);
            if (p.package_info == null)
                p.package_info = reader.enterClass(Convert.shortName(name), p);
            cs = p.package_info;
            if (cs.classfile == null)
                cs.classfile = file;
        } else
            cs = reader.enterClass(name, file);
        list = list.prepend(cs);
    }
    return list.reverse();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:27,代码来源:JavacProcessingEnvironment.java

示例3: fillIn

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
private void fillIn(PackageSymbol p,
                    Location location,
                    Iterable<JavaFileObject> files)
{
    currentLoc = location;
    for (JavaFileObject fo : files) {
        switch (fo.getKind()) {
        case CLASS:
        case SOURCE: {
            // TODO pass binaryName to includeClassFile
            String binaryName = fileManager.inferBinaryName(currentLoc, fo);
            String simpleName = binaryName.substring(binaryName.lastIndexOf(".") + 1);
            if (SourceVersion.isIdentifier(simpleName) ||
                simpleName.equals("package-info"))
                includeClassFile(p, fo);
            break;
        }
        default:
            extraFileActions(p, fo);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:ClassReader.java

示例4: get

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public Collection<JavaFileObject> get(JavaFileObject.Kind kind) {
    List<JavaFileObject> result = new ArrayList<JavaFileObject>();
    for (JavaFileObject candidate : javaFileObjects.values()) {
        if (candidate.getKind() == kind) {
            result.add(candidate);
        }
    }

    return result;
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:12,代码来源:JavaFileObjectRegistryImpl.java

示例5: preferredFileObject

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
 * Implement policy to choose to derive information from a source
 * file or a class file when both are present.  May be overridden
 * by subclasses.
 */
protected JavaFileObject preferredFileObject(JavaFileObject a,
                                             JavaFileObject b) {

    if (preferSource)
        return (a.getKind() == JavaFileObject.Kind.SOURCE) ? a : b;
    else {
        long adate = a.getLastModified();
        long bdate = b.getLastModified();
        // 6449326: policy for bad lastModifiedTime in ClassReader
        //assert adate >= 0 && bdate >= 0;
        return (adate > bdate) ? a : b;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:19,代码来源:ClassReader.java

示例6: closeFileObject

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
 * Upon close, register files opened by create{Source, Class}File
 * for annotation processing.
 */
private void closeFileObject(String typeName, FileObject fileObject) {
    /*
     * If typeName is non-null, the file object was opened as a
     * source or class file by the user.  If a file was opened as
     * a resource, typeName will be null and the file is *not*
     * subject to annotation processing.
     */
    if ((typeName != null)) {
        if (!(fileObject instanceof JavaFileObject))
            throw new AssertionError("JavaFileOject not found for " + fileObject);
        JavaFileObject javaFileObject = (JavaFileObject)fileObject;
        switch(javaFileObject.getKind()) {
        case SOURCE:
            generatedSourceNames.add(typeName);
            generatedSourceFileObjects.add(javaFileObject);
            openTypeNames.remove(typeName);
            break;

        case CLASS:
            generatedClasses.put(typeName, javaFileObject);
            openTypeNames.remove(typeName);
            break;

        default:
            break;
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:33,代码来源:JavacFiler.java

示例7: preferredFileObject

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/** Implement policy to choose to derive information from a source
 *  file or a class file when both are present.  May be overridden
 *  by subclasses.
 */
protected JavaFileObject preferredFileObject(JavaFileObject a,
                                       JavaFileObject b) {

    if (preferSource)
        return (a.getKind() == JavaFileObject.Kind.SOURCE) ? a : b;
    else {
        long adate = a.getLastModified();
        long bdate = b.getLastModified();
        // 6449326: policy for bad lastModifiedTime in ClassReader
        //assert adate >= 0 && bdate >= 0;
        return (adate > bdate) ? a : b;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ClassReader.java

示例8: fillIn

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@SuppressWarnings("fallthrough")
private void fillIn(PackageSymbol p,
                    Location location,
                    Iterable<JavaFileObject> files)
{
    currentLoc = location;
    for (JavaFileObject fo : files) {
        switch (fo.getKind()) {
        case OTHER:
            if (!isSigFile(location, fo)) {
                extraFileActions(p, fo);
                break;
            }
            //intentional fall-through:
        case CLASS:
        case SOURCE: {
            // TODO pass binaryName to includeClassFile
            String binaryName = fileManager.inferBinaryName(currentLoc, fo);
            String simpleName = binaryName.substring(binaryName.lastIndexOf(".") + 1);
            if (SourceVersion.isIdentifier(simpleName) ||
                simpleName.equals("package-info"))
                includeClassFile(p, fo);
            break;
        }
        default:
            extraFileActions(p, fo);
            break;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:ClassFinder.java

示例9: createBadClassFileDiagnostic

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
private JCDiagnostic createBadClassFileDiagnostic(JavaFileObject file, JCDiagnostic diag) {
    String key = (file.getKind() == JavaFileObject.Kind.SOURCE
            ? "bad.source.file.header" : "bad.class.file.header");
    return diagFactory.fragment(key, file, diag);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:6,代码来源:ClassReader.java

示例10: getTask

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
public DocumentationTask getTask(
        Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Class<?> docletClass,
        Iterable<String> options,
        Iterable<? extends JavaFileObject> compilationUnits,
        Context context) {
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null) {
            for (String option : options)
                Objects.requireNonNull(option);
        }

        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    final String kindMsg = "All compilation units must be of SOURCE kind";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.errKey, new PrintWriter(System.err, true));
        else if (out instanceof PrintWriter)
            context.put(Log.errKey, ((PrintWriter) out));
        else
            context.put(Log.errKey, new PrintWriter(out, true));

        if (fileManager == null) {
            fileManager = getStandardFileManager(diagnosticListener, null, null);
            if (fileManager instanceof BaseFileManager) {
                ((BaseFileManager) fileManager).autoClose = true;
            }
        }
        fileManager = ccw.wrap(fileManager);
        context.put(JavaFileManager.class, fileManager);

        return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:JavadocTool.java

示例11: createBadClassFileDiagnostic

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
private JCDiagnostic createBadClassFileDiagnostic(JavaFileObject file, JCDiagnostic diag) {
    String key = (file.getKind() == JavaFileObject.Kind.SOURCE
                ? "bad.source.file.header" : "bad.class.file.header");
    return diagFactory.fragment(key, file, diag);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:ClassReader.java

示例12: getFileKind

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
public Kind getFileKind(TypeElement te) {
    JavaFileObject jfo = ((ClassSymbol)te).outermostClass().classfile;
    return jfo == null ? Kind.SOURCE : jfo.getKind();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:ToolEnvironment.java

示例13: readModule

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
private ModuleSymbol readModule(JavaFileObject fo) throws IOException {
    Name name;
    switch (fo.getKind()) {
        case SOURCE:
            name = moduleNameFromSourceReader.readModuleName(fo);
            if (name == null) {
                JCDiagnostic diag =
                    diags.fragment(Fragments.FileDoesNotContainModule);
                ClassSymbol errModuleInfo = syms.defineClass(names.module_info, syms.errModule);
                throw new ClassFinder.BadClassFile(errModuleInfo, fo, diag, diags);
            }
            break;
        case CLASS:
            try {
                name = names.fromString(readModuleName(fo));
            } catch (BadClassFile | IOException ex) {
                //fillIn will report proper errors:
                name = names.error;
            }
            break;
        default:
            Assert.error();
            name = names.error;
            break;
    }

    ModuleSymbol msym = syms.enterModule(name);
    msym.module_info.classfile = fo;
    if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) && name != names.error) {
        msym.patchLocation = fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH, name.toString());

        if (msym.patchLocation != null) {
            JavaFileObject patchFO = getModuleInfoFromLocation(StandardLocation.CLASS_OUTPUT, Kind.CLASS);
            patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.CLASS), patchFO);
            patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.SOURCE), patchFO);

            if (patchFO != null) {
                msym.module_info.classfile = patchFO;
            }
        }
    }

    msym.completer = Completer.NULL_COMPLETER;
    classFinder.fillIn(msym.module_info);

    return msym;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:48,代码来源:ModuleFinder.java

示例14: list

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
Iterable<JavaFileObject> list(Location location,
                              PackageSymbol p,
                              String packageName,
                              Set<Kind> kinds) throws IOException {
    Iterable<JavaFileObject> listed = fileManager.list(location,
                                                       packageName,
                                                       EnumSet.allOf(Kind.class),
                                                       false);
    return () -> new Iterator<JavaFileObject>() {
        private final Iterator<JavaFileObject> original = listed.iterator();
        private JavaFileObject next;
        @Override
        public boolean hasNext() {
            if (next == null) {
                while (original.hasNext()) {
                    JavaFileObject fo = original.next();

                    if (fo.getKind() != Kind.CLASS &&
                        fo.getKind() != Kind.SOURCE &&
                        !isSigFile(currentLoc, fo)) {
                        p.flags_field |= Flags.HAS_RESOURCE;
                    }

                    if (kinds.contains(fo.getKind())) {
                        next = fo;
                        break;
                    }
                }
            }
            return next != null;
        }

        @Override
        public JavaFileObject next() {
            if (!hasNext())
                throw new NoSuchElementException();
            JavaFileObject result = next;
            next = null;
            return result;
        }

    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:ClassFinder.java

示例15: createBadClassFileDiagnostic

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
private static JCDiagnostic createBadClassFileDiagnostic(
        JavaFileObject file, JCDiagnostic diag, JCDiagnostic.Factory diagFactory) {
    String key = (file.getKind() == JavaFileObject.Kind.SOURCE
                ? "bad.source.file.header" : "bad.class.file.header");
    return diagFactory.fragment(key, file, diag);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:ClassFinder.java


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