This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-473
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-473 by this push:
     new 3d698dc  WIP.
3d698dc is described below

commit 3d698dc251fd73defe76525cd88eb31a93af218e
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Jan 27 17:43:51 2022 +0300

    WIP.
---
 .../nlpcraft/internal/impl/NCModelScanner.scala    | 51 ++++++++++++----------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
index 5462d3c..299d46e 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
@@ -307,7 +307,7 @@ object NCModelScanner extends LazyLogging:
 
     /**
       *
-      * @param anns
+      * @param спус
       * @param origin
       * @tparam T
       */
@@ -359,16 +359,17 @@ class NCModelScanner(mdl: NCModel) extends LazyLogging:
         val h = ObjectsHolder()
 
         def processImports(anns: scala.Array[NCIntentImport], orig: => 
String): Unit =
-            checkMultiple(anns, (a: NCIntentImport) => a.value, orig)
-
-            for (
-                ann <- anns;
-                res <- ann.value;
-                intent <- 
NCIDLCompiler.compile(NCUtils.readResource(res.strip).mkString("\n"), cfg, res)
-            )
-                if h.intentDecls.exists(_.id == intent.id) then
-                    E(s"Duplicate intent ID [mdlId=$mdlId, origin=$origin, 
resource=$res, id=${intent.id}]")
-                h.intentDecls += intent
+            if anns.nonEmpty then
+                checkMultiple(anns, (a: NCIntentImport) => a.value, orig)
+
+                for (
+                    ann <- anns;
+                    res <- ann.value;
+                    intent <- 
NCIDLCompiler.compile(NCUtils.readResource(res.strip).mkString("\n"), cfg, res)
+                )
+                    if h.intentDecls.exists(_.id == intent.id) then
+                        E(s"Duplicate intent ID [mdlId=$mdlId, origin=$origin, 
resource=$res, id=${intent.id}]")
+                    h.intentDecls += intent
 
         def scanObject(obj: Object): Unit =
             val claxx = obj.getClass
@@ -513,24 +514,28 @@ class NCModelScanner(mdl: NCModel) extends LazyLogging:
 
         // 1. Process inline intent declarations by @NCIntent annotation.
         val annsIntents = mtd.getAnnotationsByType(CLS_INTENT)
-        checkSingle(annsIntents, (a:NCIntent) => a.value, mtdStr)
 
-        for (ann <- annsIntents; intent <- NCIDLCompiler.compile(ann.value, 
cfg, mtdStr))
-            if intentDecls.exists(_.id == intent.id && 
existsForOtherMethod(intent.id)) then
-                E(s"Duplicate intent ID [mdlId=$mdlId, origin=$origin, 
callback=$mtdStr, id=${intent.id}]")
-            else
-                bindIntent(intent, prepareCallback(mtd, obj, intent))
+        if annsIntents.nonEmpty then
+            checkSingle(annsIntents, (a:NCIntent) => a.value, mtdStr)
+
+            for (ann <- annsIntents; intent <- 
NCIDLCompiler.compile(ann.value, cfg, mtdStr))
+                if intentDecls.exists(_.id == intent.id && 
existsForOtherMethod(intent.id)) then
+                    E(s"Duplicate intent ID [mdlId=$mdlId, origin=$origin, 
callback=$mtdStr, id=${intent.id}]")
+                else
+                    bindIntent(intent, prepareCallback(mtd, obj, intent))
 
         // 2. Process intent references from @NCIntentRef annotation.
         val annRefs = mtd.getAnnotationsByType(CLS_INTENT_REF)
-        checkSingle(annRefs, (a:NCIntentRef) => a.value, mtdStr)
 
-        for (ann <- annRefs)
-            val refId = ann.value.trim
+        if annRefs.nonEmpty then
+            checkSingle(annRefs, (a:NCIntentRef) => a.value, mtdStr)
+
+            for (ann <- annRefs)
+                val refId = ann.value.trim
 
-            intentDecls.find(_.id == refId) match
-                case Some(intent) => bindIntent(intent, prepareCallback(mtd, 
obj, intent))
-                case None => E(s"@NCIntentRef(\"$refId\") references unknown 
intent ID [mdlId=$mdlId, origin=$origin, refId=$refId, callback=$mtdStr]")
+                intentDecls.find(_.id == refId) match
+                    case Some(intent) => bindIntent(intent, 
prepareCallback(mtd, obj, intent))
+                    case None => E(s"@NCIntentRef(\"$refId\") references 
unknown intent ID [mdlId=$mdlId, origin=$origin, refId=$refId, 
callback=$mtdStr]")
 
     /**
       *

Reply via email to