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

项目:incubator-netbeans    文件:CasualDiff.java   
protected int diffExports(JCExports oldT, JCExports newT, int[] bounds) {
    int localPointer = bounds[0];
    // package name
    int[] expNameBounds = getBounds(oldT.qualid);
    copyTo(localPointer, expNameBounds[0]);
    localPointer = diffTree(oldT.qualid, newT.qualid, expNameBounds);
    // modules
    int posHint;
    if (oldT.moduleNames == null || oldT.moduleNames.isEmpty()) {
        posHint = endPos(oldT) - 1;
    } else {
        posHint = oldT.moduleNames.iterator().next().getStartPosition();
    }
    if (newT.moduleNames != null && !newT.moduleNames.isEmpty()) //do not copy the "to" keyword:
        copyTo(localPointer, localPointer = posHint);
    PositionEstimator est = EstimatorFactory.exportsOpensTo(oldT.moduleNames, newT.moduleNames, diffContext);
    localPointer = diffList2(oldT.moduleNames, newT.moduleNames, posHint, est);
    copyTo(localPointer, bounds[1]);
    return bounds[1];        
}
项目:openjdk-jdk10    文件:Modules.java   
@Override
public void visitExports(JCExports tree) {
    Iterable<Symbol> packageContent = tree.directive.packge.members().getSymbols();
    List<JavaFileObject> filesToCheck = List.nil();
    boolean packageNotEmpty = false;
    for (Symbol sym : packageContent) {
        if (sym.kind != Kinds.Kind.TYP)
            continue;
        ClassSymbol csym = (ClassSymbol) sym;
        if (sym.completer.isTerminal() ||
            csym.classfile.getKind() == Kind.CLASS) {
            packageNotEmpty = true;
            filesToCheck = List.nil();
            break;
        }
        if (csym.classfile.getKind() == Kind.SOURCE) {
            filesToCheck = filesToCheck.prepend(csym.classfile);
        }
    }
    for (JavaFileObject jfo : filesToCheck) {
        if (findPackageInFile.findPackageNameOf(jfo) == tree.directive.packge.fullname) {
            packageNotEmpty = true;
            break;
        }
    }
    if (!packageNotEmpty) {
        log.error(tree.qualid.pos(), Errors.PackageEmptyOrNotFound(tree.directive.packge));
    }
    msym.directives = msym.directives.prepend(tree.directive);
}
项目:openjdk9    文件:Modules.java   
@Override
public void visitExports(JCExports tree) {
    Name name = TreeInfo.fullName(tree.qualid);
    PackageSymbol packge = syms.enterPackage(sym, name);
    attr.setPackageSymbols(tree.qualid, packge);
    if (!allExports.add(packge)) {
        log.error(tree.qualid.pos(), Errors.DuplicateExports(packge));
    }

    List<ModuleSymbol> toModules = null;
    if (tree.moduleNames != null) {
        Set<ModuleSymbol> to = new HashSet<>();
        for (JCExpression n: tree.moduleNames) {
            ModuleSymbol msym = lookupModule(n);
            if (msym.kind != MDL) {
                log.error(n.pos(), Errors.ModuleNotFound(msym));
            } else if (!to.add(msym)) {
                log.error(n.pos(), Errors.DuplicateExports(msym));
            }
        }
        toModules = List.from(to);
    }

    if (toModules == null || !toModules.isEmpty()) {
        ExportsDirective d = new ExportsDirective(packge, toModules);
        tree.directive = d;
        sym.exports = sym.exports.prepend(d);
    }
}
项目:openjdk9    文件:Modules.java   
@Override
public void visitExports(JCExports tree) {
    if (tree.directive.packge.members().isEmpty()) {
        log.error(tree.qualid.pos(), Errors.PackageEmptyOrNotFound(tree.directive.packge));
    }
    msym.directives = msym.directives.prepend(tree.directive);
}
项目:openjdk-jdk10    文件:Modules.java   
private void reportExportsConflict(JCExports tree, PackageSymbol packge) {
    log.error(tree.qualid.pos(), Errors.ConflictingExports(packge));
}