From 31df1645b384a10fb8edd9f533c4025d56762275 Mon Sep 17 00:00:00 2001
From: Dominique Marcadet <Dominique.Marcadet@centralesupelec.fr>
Date: Thu, 14 Feb 2019 10:55:22 +0100
Subject: [PATCH] check for presence of depending NS in findXXX()

---
 .../riseclipse/iec61850/nsd/impl/NSImpl.java  | 20 ++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/fr.centralesupelec.edf.riseclipse.iec61850.nsd/src/fr/centralesupelec/edf/riseclipse/iec61850/nsd/impl/NSImpl.java b/fr.centralesupelec.edf.riseclipse.iec61850.nsd/src/fr/centralesupelec/edf/riseclipse/iec61850/nsd/impl/NSImpl.java
index b263548..e093996 100644
--- a/fr.centralesupelec.edf.riseclipse.iec61850.nsd/src/fr/centralesupelec/edf/riseclipse/iec61850/nsd/impl/NSImpl.java
+++ b/fr.centralesupelec.edf.riseclipse.iec61850.nsd/src/fr/centralesupelec/edf/riseclipse/iec61850/nsd/impl/NSImpl.java
@@ -1675,7 +1675,9 @@ public class NSImpl extends CopyrightedImpl implements NS {
             if( found != null ) return found;
         }
 
-        if( isSetDependsOn() ) {
+        // Look for in NS referred by DependsOn
+        // Warning: NS referred by DependsOn may not be loaded
+        if( isSetDependsOn() && ( getDependsOn().isSetRefersToNS() )) {
             getDependsOn().buildExplicitLinks( console );
             return getDependsOn().getRefersToNS().findCDC( cDCName, console );
         }
@@ -1696,7 +1698,9 @@ public class NSImpl extends CopyrightedImpl implements NS {
             if( found != null ) return found;
         }
 
-        if( isSetDependsOn() ) {
+        // Look for in NS referred by DependsOn
+        // Warning: NS referred by DependsOn may not be loaded
+        if( isSetDependsOn() && ( getDependsOn().isSetRefersToNS() )) {
             getDependsOn().buildExplicitLinks( console );
             return getDependsOn().getRefersToNS().findPresenceCondition( presenceConditionName, console );
         }
@@ -1719,7 +1723,9 @@ public class NSImpl extends CopyrightedImpl implements NS {
             if( found != null ) return found;
         }
 
-        if( isSetDependsOn() ) {
+        // Look for in NS referred by DependsOn
+        // Warning: NS referred by DependsOn may not be loaded
+        if( isSetDependsOn() && ( getDependsOn().isSetRefersToNS() )) {
             getDependsOn().buildExplicitLinks( console );
             return getDependsOn().getRefersToNS().findFunctionalConstraint( functionalConstraintAbbreviation, console );
         }
@@ -1740,7 +1746,9 @@ public class NSImpl extends CopyrightedImpl implements NS {
             if( found != null ) return found;
         }
 
-        if( isSetDependsOn() ) {
+        // Look for in NS referred by DependsOn
+        // Warning: NS referred by DependsOn may not be loaded
+        if( isSetDependsOn() && ( getDependsOn().isSetRefersToNS() )) {
             getDependsOn().buildExplicitLinks( console );
             return getDependsOn().getRefersToNS().findEnumeration( enumerationName, console );
         }
@@ -1761,7 +1769,9 @@ public class NSImpl extends CopyrightedImpl implements NS {
             if( found != null ) return found;
         }
 
-        if( isSetDependsOn() ) {
+        // Look for in NS referred by DependsOn
+        // Warning: NS referred by DependsOn may not be loaded
+        if( isSetDependsOn() && ( getDependsOn().isSetRefersToNS() )) {
             getDependsOn().buildExplicitLinks( console );
             return getDependsOn().getRefersToNS().findBasicType( basicTypeName, console );
         }
-- 
GitLab