Skip to content

Commit e58a40b

Browse files
authored
Merge pull request #392 from Inxton/missing-types-in-smodel
Enhance logging and update launch settings
2 parents ffd6bd5 + 9976c01 commit e58a40b

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Helpers/SemanticsHelpers.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using AXSharp.Compiler.Cs.Helpers;
1515
using AXSharp.Connector;
1616

17+
1718
namespace AXSharp.Compiler.Cs;
1819

1920
/// <summary>
@@ -76,15 +77,26 @@ public static ITypeDeclaration FindTypeDeclaration(this Compilation compilation,
7677
return candidates.First();
7778
}
7879

79-
if (candidates.Count() == 0)
80+
try
8081
{
81-
Log.Logger.Warning($"Type '{typeAccess?.ToString()}' not found in the semantic tree.");
82-
}
82+
var span = typeAccess?.Location?.GetLineSpan();
83+
var line = span.Value.StartLinePosition.Line;
84+
var character = span.Value.StartLinePosition.Character;
85+
if (candidates.Count() == 0)
86+
{
87+
Log.Logger.Warning($"{span?.Filename}({line}:{character}) : Type '{typeAccess.TypeSymbol.Name}' not found the type may not be eligible for transpile or meta information is not available because this type is not defined in AX# compliant project. ");
88+
}
8389

84-
if (candidates.Count() > 1)
90+
if (candidates.Count() > 1)
91+
{
92+
Log.Logger.Warning($"{span?.Filename}({line}:{character}) : Multiple types found for '{typeAccess.TypeSymbol.Name}' the declaration appears ambiguous. You may need to fully qualify the declaration.");
93+
}
94+
}
95+
catch
8596
{
86-
Log.Logger.Warning($"Multiple types found for '{typeAccess?.ToString()}' in the semantic tree. You may need to fully qualify the declaration.");
97+
Log.Logger.Warning($"Failed to determine the location of the type declaration for `{typeAccess?.TypeSymbol?.Name}`.");
8798
}
99+
88100

89101
return null;
90102
}
@@ -113,7 +125,7 @@ public static ITypeDeclaration FindTypeDeclaration(this Compilation compilation,
113125

114126
if (candidates.Count() == 0)
115127
{
116-
Log.Logger.Warning($"Type '{typeAccess?.ToString()}' not found in the semantic tree.");
128+
Log.Logger.Warning($"Type '{typeAccess?.ToString()}' not found in the semantic tree. {typeAccess?.Location}");
117129
}
118130

119131
if (candidates.Count() > 1)

src/AXSharp.compiler/src/ixc/Properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
"workingDirectory": "c:\\W\\Develop\\gh\\inxton\\axopen\\src\\integrations\\ctrl\\"
1010
},
1111
"ixc-simple-template": {
12-
"commandName": "Project",
13-
"commandLineArgs": "--skip-deps",
12+
"commandName": "Project",
1413
"workingDirectory": "C:\\W\\Develop\\gh\\inxton\\simatic-ax\\axopen.templates\\axopen.template.simple\\ax"
1514
},
1615
"ixc-template-ref": {
1716
"commandName": "Project",
17+
"commandLineArgs": "--skip-deps",
1818
"workingDirectory": "C:\\W\\Develop\\gh\\inxton\\axopen\\src\\templates.simple\\ctrl"
1919
},
2020
"ax-connectors-test-project": {

0 commit comments

Comments
 (0)