static String fullPath(int offset, String prefix, Tree.ImportPath path) {
   StringBuilder fullPath = new StringBuilder();
   if (path != null) {
     String pathString = formatPath(path.getIdentifiers());
     fullPath.append(pathString).append('.');
     int len = offset - path.getStartIndex() - prefix.length();
     fullPath.setLength(len);
   }
   return fullPath.toString();
 }
示例#2
0
 @Override
 public void visit(Tree.CompilationUnit that) {
   unit = that.getUnit();
   super.visit(that);
   HashSet<String> set = new HashSet<String>();
   for (Tree.Import im : that.getImportList().getImports()) {
     Tree.ImportPath ip = im.getImportPath();
     if (ip != null) {
       String mp = formatPath(ip.getIdentifiers());
       if (!set.add(mp)) {
         ip.addError("duplicate import: '" + mp + "'");
       }
     }
   }
 }