Exemplo n.º 1
0
 public T find(String moduleId, String symbolId) throws IllegalArgumentException {
   if (moduleId != null) {
     SmiModule module = moduleMap.get(moduleId);
     if (module == null) {
       throw new IllegalArgumentException("Module " + moduleId + " could not be found.");
     }
     SmiSymbol symbol = module.findSymbol(symbolId);
     if (symbol == null) {
       return null;
     }
     if (symbolClass.isAssignableFrom(symbol.getClass())) {
       return symbolClass.cast(symbol);
     } else {
       // throw new
       // IllegalArgumentException(symbol.getClass().getSimpleName() +
       // " with id " + symbolId + " is not an instance of " +
       // m_symbolClass);
       return null; // when the lookup is through the global map, we
       // also return null for an object that is of the
       // wrong type.
     }
   } else {
     return getOne(symbolId);
   }
 }
Exemplo n.º 2
0
 public <T extends SmiSymbol> T resolveReference(
     IdToken idToken, Class<T> expectedClass, XRefProblemReporter reporter) {
   SmiSymbol result = resolveReference(idToken, reporter);
   if (result != null) {
     if (expectedClass.isInstance(result)) {
       return expectedClass.cast(result);
     } else {
       reporter.reportFoundSymbolButWrongType(idToken, expectedClass, result.getClass());
     }
   }
   return null;
 }