Beispiel #1
0
  /**
   * Resolves a reference from within this module to a symbol in the same module, an imported module
   * or in the whole mib
   *
   * @param idToken Token of the identifier that has to be resolved.
   * @param reporter If not null, the reporter will be used to reporter the not found error message.
   * @return The symbol that was found, or null.
   */
  public SmiSymbol resolveReference(IdToken idToken, XRefProblemReporter reporter) {
    // doesn't work anymore with hardcoded missing symbols
    //        if (!idToken.getLocation().getSource().equals(getIdToken().getLocation().getSource()))
    // {
    //            // note this check is not entirely fool-proof in case multiple modules are located
    // in one file
    //            throw new IllegalArgumentException("Resolving references is only allowed from
    // inside the same module");
    //        }

    SmiSymbol result = findSymbol(idToken.getId());
    if (result == null) {
      result = findImportedSymbol(idToken.getId());
    }
    if (result == null) {
      List<SmiSymbol> symbols = getMib().getSymbols().findAll(idToken.getId());
      if (symbols.size() == 1) {
        result = symbols.get(0);
      } else if (symbols.size() > 0) {
        result = determineBestMatch(idToken, symbols);
      }
    }
    if (result == null && reporter != null) {
      reporter.reportCannotFindSymbol(idToken);
    }

    return result;
  }
Beispiel #2
0
 public SmiModule(SmiMib mib, IdToken idToken) {
   m_mib = mib;
   if (idToken == null) {
     throw new IllegalArgumentException();
   }
   setIdToken(idToken);
   m_isSmiDefinitionModule = SmiConstants.SMI_DEFINITION_MODULE_NAMES.contains(idToken.getId());
 }
Beispiel #3
0
 public String toString() {
   return m_idToken.toString();
 }
Beispiel #4
0
 public SmiRow createRow(IdToken idToken) {
   SmiRow row = new SmiRow(idToken, this);
   m_rowMap.put(idToken.getId(), row);
   return row;
 }
Beispiel #5
0
 public SmiTable createTable(IdToken idToken) {
   SmiTable table = new SmiTable(idToken, this);
   m_tableMap.put(idToken.getId(), table);
   return table;
 }
Beispiel #6
0
 public SmiType createType(IdToken idToken) {
   SmiType type = new SmiType(idToken, this);
   m_typeMap.put(idToken.getId(), type);
   return type;
 }
Beispiel #7
0
 public String getId() {
   return m_idToken.getId();
 }
Beispiel #8
0
 public void setIdToken(IdToken id) {
   assert (m_idToken == null);
   m_idToken = id;
   m_mib.addModule(id.getId(), this);
 }