Двери учитывают все ссылки

Я хочу подсчитать все входящие ссылки всех объектов во всех модулях в проекте IBM Doors. (с DXL)

Вот как я это сделал (в основном я вызываю функцию goThroughFolders(current Folder)):

  1. Пройдитесь по каждой папке в проекте и проверьте, есть ли модули если есть модули вызовите функцию "checkLinks(Module m)"

        void goThroughFolders(Folder f)
        {
            Item itm
            if (null f) return
    
            for itm in f do{
    
                    print("\nScanning folder...")
                    if (null itm) continue
                    if (isDeleted(itm)) continue
    
                    else if ((type (itm) == "Project") || (type (itm) == "Folder"))
                        {
                      goThroughFolders(folder(itm))
                        }
                    else if (type (itm) == "Formal") {
                        print("\nFound Module")
                        checkLinks(module(itm))
                        }
    
            }
    } 
    
    1. Проверить модули на наличие ссылок

      void checkLinks(Module m)
      {
          string objType = ""
          Object o = null
          Link anyLink
          for o in m do {
      
      objType = o."Object Type" ""
      
      // Check if the type is right
      if ( ( objType == "Req" ) || ( objType == "Obj" ) ) {
          // Check for any outlinks at all
          for anyLink in o <- "*" do{
      
      
      
         LinkCount++
      
         }
      

      } } }

Итак, моя проблема заключается в том, что вызов функции checkLinks(module(itm)) в goThroughFolders(Folder f), похоже, передает объект null.

Error:

    -R-E- DXL: <Line:11> null Module do loop parameter was passed
    Backtrace:
        <Line:69> 
        <Line:78> 
    -I- DXL: execution halted

Но я не знаю, почему? Можете вы помочь мне?


person Loois95    schedule 25.09.2018    source источник
comment
Нашел свою ошибку в checkLinks(), это должно быть m = read (fullName(itm), false, true) // открыть модуль checkLinks(m)   -  person Loois95    schedule 25.09.2018


Ответы (1)


Хорошая работа, обнаружение пропущенного шага. Еще одна вещь, которую вы, возможно, захотите сделать, это закрыть модули после завершения анализа, в противном случае вы, вероятно, забудете и оставите их открытыми, жертвуя памятью, пока не выйдете из DOORS.

Я сделал несколько изменений и дополнений ниже, чтобы добиться этого - если что-то неясно, пожалуйста, не стесняйтесь спрашивать.

Ричард

Module m
Skip skLinkSourceMods = create() // Create a skip list to hold references to all modules opened for link analysis

int linkCount = 0

void checkLinks(Item itm, Skip skOpenMods) // Function signature changed to pass in the skip list - not strictly necessary, but clean
{
    m = read (fullName(itm), false, true)
    put(skOpenMods, m, m) // Add the opened module to the skip list, so we can easily close it later
    string objType = ""
    Object o = null
    Link anyLink

    for o in m do {
        objType = o."Object Type" ""

        // Check if the type is right
        if ( ( objType == "Req" ) || ( objType == "Obj" ) ) {

        // Check for any outlinks at all
            for anyLink in o <- "*" do {
               linkCount++
           }
       }
    }
}

void goThroughFolders(Folder f)
{
    Item itm
    if (null f) return

    for itm in f do {
        print("\nScanning folder...")
        if (null itm) continue
        if (isDeleted(itm)) continue

        else if ((type (itm) == "Project") || (type (itm) == "Folder"))
        {
          goThroughFolders(folder(itm))
        }
        else if (type (itm) == "Formal") {
            print("\nFound Module")

            checkLinks(itm, skLinkSourceMods) // Function signature changed (see above) to pass in the skip list - not strictly necessary, but clean
        }
    }
}

void closeModules(Skip skOpenMods)
{
    for m in skOpenMods do // Loop through each module in the skip list
    {
        close(m, false) // Close the module without saving changes (we shouldn't have any - they were opened read-only anyway!)
    }
}

goThroughFolders(current Folder)
print "\n" linkCount " links."
closeModules(skLinkSourceMods)
delete(skLinkSourceMods)
person Richard Hesketh    schedule 21.12.2018