Java 类com.sun.tools.javac.tree.JCTree.JCRequires 实例源码

项目:openjdk-jdk10    文件:Modules.java   
@Override
public void visitRequires(JCRequires tree) {
    ModuleSymbol msym = lookupModule(tree.moduleName);
    if (msym.kind != MDL) {
        log.error(tree.moduleName.pos(), Errors.ModuleNotFound(msym));
        warnedMissing.add(msym);
    } else if (allRequires.contains(msym)) {
        log.error(tree.moduleName.pos(), Errors.DuplicateRequires(msym));
    } else {
        allRequires.add(msym);
        Set<RequiresFlag> flags = EnumSet.noneOf(RequiresFlag.class);
        if (tree.isTransitive)
            flags.add(RequiresFlag.TRANSITIVE);
        if (tree.isStaticPhase)
            flags.add(RequiresFlag.STATIC_PHASE);
        RequiresDirective d = new RequiresDirective(msym, flags);
        tree.directive = d;
        sym.requires = sym.requires.prepend(d);
    }
}
项目:openjdk9    文件:Modules.java   
@Override
public void visitRequires(JCRequires tree) {
    ModuleSymbol msym = lookupModule(tree.moduleName);
    if (msym.kind != MDL) {
        log.error(tree.moduleName.pos(), Errors.ModuleNotFound(msym));
    } else if (allRequires.contains(msym)) {
        log.error(tree.moduleName.pos(), Errors.DuplicateRequires(msym));
    } else {
        allRequires.add(msym);
        Set<RequiresFlag> flags = EnumSet.noneOf(RequiresFlag.class);
        if (tree.isPublic)
            flags.add(RequiresFlag.PUBLIC);
        RequiresDirective d = new RequiresDirective(msym, flags);
        tree.directive = d;
        sym.requires = sym.requires.prepend(d);
    }
}
项目:openjdk-jdk10    文件:Modules.java   
@Override
public void visitRequires(JCRequires tree) {
    if (tree.directive != null && allModules().contains(tree.directive.module)) {
        chk.checkDeprecated(tree.moduleName.pos(), msym, tree.directive.module);
        chk.checkModuleRequires(tree.moduleName.pos(), tree.directive);
        msym.directives = msym.directives.prepend(tree.directive);
    }
}
项目:openjdk-jdk10    文件:Modules.java   
private void checkCyclicDependencies(JCModuleDecl mod) {
    for (JCDirective d : mod.directives) {
        JCRequires rd;
        if (!d.hasTag(Tag.REQUIRES) || (rd = (JCRequires) d).directive == null)
            continue;
        Set<ModuleSymbol> nonSyntheticDeps = new HashSet<>();
        List<ModuleSymbol> queue = List.of(rd.directive.module);
        while (queue.nonEmpty()) {
            ModuleSymbol current = queue.head;
            queue = queue.tail;
            if (!nonSyntheticDeps.add(current))
                continue;
            current.complete();
            if ((current.flags() & Flags.ACYCLIC) != 0)
                continue;
            Assert.checkNonNull(current.requires, current::toString);
            for (RequiresDirective dep : current.requires) {
                if (!dep.flags.contains(RequiresFlag.EXTRA))
                    queue = queue.prepend(dep.module);
            }
        }
        if (nonSyntheticDeps.contains(mod.sym)) {
            log.error(rd.moduleName.pos(), Errors.CyclicRequires(rd.directive.module));
        }
        mod.sym.flags_field |= Flags.ACYCLIC;
    }
}
项目:openjdk9    文件:Modules.java   
private void checkCyclicDependencies(JCModuleDecl mod) {
    for (JCDirective d : mod.directives) {
        if (!d.hasTag(Tag.REQUIRES))
            continue;
        JCRequires rd = (JCRequires) d;
        Set<ModuleSymbol> nonSyntheticDeps = new HashSet<>();
        List<ModuleSymbol> queue = List.of(rd.directive.module);
        while (queue.nonEmpty()) {
            ModuleSymbol current = queue.head;
            queue = queue.tail;
            if (!nonSyntheticDeps.add(current))
                continue;
            if ((current.flags() & Flags.ACYCLIC) != 0)
                continue;
            current.complete();
            Assert.checkNonNull(current.requires, () -> current.toString());
            for (RequiresDirective dep : current.requires) {
                if (!dep.flags.contains(RequiresFlag.EXTRA))
                    queue = queue.prepend(dep.module);
            }
        }
        if (nonSyntheticDeps.contains(mod.sym)) {
            log.error(rd.moduleName.pos(), Errors.CyclicRequires(rd.directive.module));
        }
        mod.sym.flags_field |= Flags.ACYCLIC;
    }
}
项目:incubator-netbeans    文件:CasualDiff.java   
protected int diffRequires(JCRequires oldT, JCRequires newT, int[] bounds) {
    int localPointer = bounds[0];
    // module name
    int[] nameBounds = getBounds(oldT.moduleName);
    if (oldT.isStaticPhase || oldT.isTransitive) {
        JavaTokenId id = moveFwdToOneOfTokens(tokenSequence, localPointer, EnumSet.of(JavaTokenId.STATIC, JavaTokenId.TRANSITIVE));
        switch (id) {
            case STATIC:
                if (!newT.isStaticPhase) {
                    //removing "static":
                    copyTo(localPointer, tokenSequence.offset());
                    tokenSequence.moveNext();
                    localPointer = tokenSequence.offset() + tokenSequence.token().length();
                }
                if (oldT.isTransitive == newT.isTransitive) {
                    copyTo(localPointer, nameBounds[0]);
                } else {
                    if (oldT.isTransitive) {
                        //removing "transitive":
                        moveFwdToToken(tokenSequence, localPointer, JavaTokenId.TRANSITIVE);
                        copyTo(localPointer, tokenSequence.offset());
                    } else {
                        copyTo(localPointer, nameBounds[0]);
                        printer.print("transitive "); //NOI18N
                    }
                }
                break;
            case TRANSITIVE:
                if (!newT.isTransitive) {
                    //removing "transitive":
                    copyTo(localPointer, tokenSequence.offset());
                    tokenSequence.moveNext();
                    localPointer = tokenSequence.offset() + tokenSequence.token().length();
                }
                if (oldT.isStaticPhase == newT.isStaticPhase) {
                    copyTo(localPointer, nameBounds[0]);
                } else {
                    if (oldT.isStaticPhase) {
                        //removing "static":
                        moveFwdToToken(tokenSequence, localPointer, JavaTokenId.STATIC);
                        copyTo(localPointer, tokenSequence.offset());
                    } else {
                        copyTo(localPointer, nameBounds[0]);
                        printer.print("static "); //NOI18N
                    }
                }
                break;
        }
    } else {
        copyTo(localPointer, nameBounds[0]);
        if (newT.isStaticPhase) {
            printer.print("static "); //NOI18N
        }
        if (newT.isTransitive) {
            printer.print("transitive "); //NOI18N
        }
    }
    localPointer = diffTree(oldT.moduleName, newT.moduleName, nameBounds);
    copyTo(localPointer, bounds[1]);

    return bounds[1];        
}
项目:openjdk9    文件:Modules.java   
@Override
public void visitRequires(JCRequires tree) {
    msym.directives = msym.directives.prepend(tree.directive);
}