/** Does the specified ReferenceType match this spec. */
 public boolean matches(ReferenceType refType) {
   try {
     if (refType.sourceName().equals(sourceName)) {
       try {
         refType.locationsOfLine(linenumber);
         // if we don't throw an exception then it was found
         return true;
       } catch (AbsentInformationException exc) {
       } catch (ObjectCollectedException exc) {
       } catch (InvalidLineNumberException exc) {
         //          } catch(ClassNotPreparedException  exc) {
         //               -- should not happen, so don't catch this ---
       }
     }
   } catch (AbsentInformationException exc) {
     // for sourceName(), fall through
   }
   return false;
 }
Ejemplo n.º 2
0
 /** Get source object associated with a class or interface. Returns null if not available. */
 public SourceModel sourceForClass(ReferenceType refType) {
   SourceModel sm = classToSource.get(refType);
   if (sm != null) {
     return sm;
   }
   try {
     String filename = refType.sourceName();
     String refName = refType.name();
     int iDot = refName.lastIndexOf('.');
     String pkgName = (iDot >= 0) ? refName.substring(0, iDot + 1) : "";
     String full = pkgName.replace('.', File.separatorChar) + filename;
     File path = sourcePath.resolve(full);
     if (path != null) {
       sm = sourceForFile(path);
       classToSource.put(refType, sm);
       return sm;
     }
     return null;
   } catch (AbsentInformationException e) {
     return null;
   }
 }