示例#1
0
 static ReferenceType getReferenceTypeFromToken(String idToken) {
   ReferenceType cls = null;
   if (Character.isDigit(idToken.charAt(0))) {
     cls = null;
   } else if (idToken.startsWith("*.")) {
     // This notation saves typing by letting the user omit leading
     // package names. The first
     // loaded class whose name matches this limited regular
     // expression is selected.
     idToken = idToken.substring(1);
     List classes = Env.vm().allClasses();
     Iterator iter = classes.iterator();
     while (iter.hasNext()) {
       ReferenceType type = ((ReferenceType) iter.next());
       if (type.name().endsWith(idToken)) {
         cls = type;
         break;
       }
     }
   } else {
     // It's a class name
     List classes = Env.vm().classesByName(idToken);
     if (classes.size() > 0) {
       // TO DO: handle multiples
       cls = (ReferenceType) classes.get(0);
     }
   }
   return cls;
 }
示例#2
0
  static synchronized String sourceLine(Location location, int lineNumber) throws IOException {
    if (lineNumber == -1) {
      throw new IllegalArgumentException();
    }

    try {
      String fileName = location.sourceName();

      Iterator iter = sourceCache.iterator();
      SourceCode code = null;
      while (iter.hasNext()) {
        SourceCode candidate = (SourceCode) iter.next();
        if (candidate.fileName().equals(fileName)) {
          code = candidate;
          iter.remove();
          break;
        }
      }
      if (code == null) {
        BufferedReader reader = sourceReader(location);
        if (reader == null) {
          throw new FileNotFoundException(fileName);
        }
        code = new SourceCode(fileName, reader);
        if (sourceCache.size() == SOURCE_CACHE_SIZE) {
          sourceCache.remove(sourceCache.size() - 1);
        }
      }
      sourceCache.add(0, code);
      return code.sourceLine(lineNumber);
    } catch (AbsentInformationException e) {
      throw new IllegalArgumentException();
    }
  }
示例#3
0
 String sourceLine(int number) {
   int index = number - 1; // list is 0-indexed
   if (index >= sourceLines.size()) {
     return null;
   } else {
     return (String) sourceLines.get(index);
   }
 }
示例#4
0
 static void setExcludes(String excludeString) {
   StringTokenizer t = new StringTokenizer(excludeString, " ,;");
   List list = new ArrayList();
   while (t.hasMoreTokens()) {
     list.add(t.nextToken());
   }
   excludes = list;
 }
示例#5
0
 SourceCode(String fileName, BufferedReader reader) throws IOException {
   this.fileName = fileName;
   try {
     String line = reader.readLine();
     while (line != null) {
       sourceLines.add(line);
       line = reader.readLine();
     }
   } finally {
     reader.close();
   }
 }
示例#6
0
 static void setSourcePath(List srcList) {
   sourceMapper = new SourceMapper(srcList);
   sourceCache.clear();
 }
示例#7
0
 static void setSourcePath(String srcPath) {
   sourceMapper = new SourceMapper(srcPath);
   sourceCache.clear();
 }