diff --git a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Onliner/CsOnlinerSourceBuilder.cs b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Onliner/CsOnlinerSourceBuilder.cs index 964e6ce3..2e571f30 100644 --- a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Onliner/CsOnlinerSourceBuilder.cs +++ b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Onliner/CsOnlinerSourceBuilder.cs @@ -55,11 +55,6 @@ public void CreateFile(IFileSyntax fileSyntax, IxNodeVisitor visitor) AddToSource("using System.Collections.Generic;"); AddToSource("using AXSharp.Connector.Localizations;"); - foreach (var fileSyntaxUsingDirective in fileSyntax.UsingDirectives) - { - AddToSource($"using {fileSyntaxUsingDirective.QualifiedIdentifierList.GetText()};"); - } - fileSyntax.Declarations.ToList().ForEach(p => p.Visit(visitor, this)); } diff --git a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Plain/CsPlainSourceBuilder.cs b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Plain/CsPlainSourceBuilder.cs index 0ed3172a..fb532a3c 100644 --- a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Plain/CsPlainSourceBuilder.cs +++ b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/Plain/CsPlainSourceBuilder.cs @@ -179,12 +179,6 @@ public virtual void CreateNamedValueTypeDeclaration(INamedValueTypeDeclaration n public void CreateFile(IFileSyntax fileSyntax, IxNodeVisitor visitor) { AddToSource("using System;"); - - foreach (var fileSyntaxUsingDirective in fileSyntax.UsingDirectives) - { - AddToSource($"using Pocos.{fileSyntaxUsingDirective.QualifiedIdentifierList.GetText()};"); - } - AddToSource("namespace Pocos {"); fileSyntax.Declarations.ToList().ForEach(p => p.Visit(visitor, this)); AddToSource("}"); diff --git a/src/AXSharp.compiler/src/ixr/Program.cs b/src/AXSharp.compiler/src/ixr/Program.cs index a0129977..c9cc0794 100644 --- a/src/AXSharp.compiler/src/ixr/Program.cs +++ b/src/AXSharp.compiler/src/ixr/Program.cs @@ -93,35 +93,35 @@ void Generate(Options o) void IterateSyntaxTreeForStringLiterals(ISyntaxNode root, LocalizedStringWrapper lw, string fileName) { - //foreach (var literalSyntax in GetChildNodesRecursive(root).OfType()) - //{ - // var token = literalSyntax.Tokens.First(); - // //literalSyntax.Location - // AddToDictionaryIfLocalizedString(token,lw,fileName); - //} + foreach (var literalSyntax in GetChildNodesRecursive(root).OfType()) + { + var token = literalSyntax.Tokens.First(); + //literalSyntax.Location + AddToDictionaryIfLocalizedString(token,lw,fileName); + } } void IterateSyntaxTreeForPragmas(ISyntaxNode root, LocalizedStringWrapper lw, string fileName) { - foreach (var pragmaSyntax in GetChildNodesRecursive(root).OfType()) - { - var token = pragmaSyntax; - if (lw.IsAttributeNamePragmaToken(token.PragmaContent)) - { - AddToDictionaryIfLocalizedString(token, lw, fileName); - } - } + //foreach (var pragmaSyntax in GetChildNodesRecursive(root).OfType()) + //{ + // var token = pragmaSyntax.PragmaToken; + // if(lw.IsAttributeNamePragmaToken(token.Text)) + // { + // AddToDictionaryIfLocalizedString(token,lw,fileName); + // } + //} } -void AddToDictionaryIfLocalizedString(PragmaSyntax token, LocalizedStringWrapper lw, string fileName) +void AddToDictionaryIfLocalizedString(ISyntaxToken token, LocalizedStringWrapper lw, string fileName) { // if is valid token if(IsStringToken(token) || IsPragmaToken(token)) { // try to acquire localized string - var localizedStringList = lw.TryToGetLocalizedStrings(token.PragmaContent); + var localizedStringList = lw.TryToGetLocalizedStrings(token.Text); if(localizedStringList == null) { @@ -139,7 +139,7 @@ void AddToDictionaryIfLocalizedString(PragmaSyntax token, LocalizedStringWrapper //check if identifier is valid if(lw.IsValidId(id)) { - var pos = token.SourceText.GetLineSpan(token.Span).StartLinePosition; + var pos = token.Location.GetLineSpan().StartLinePosition; var wrapper = new StringValueWrapper(rawText, fileName, pos.Line); // add id and wrapper to dictionary lw.LocalizedStringsDictionary.TryAdd(id, wrapper); @@ -147,7 +147,7 @@ void AddToDictionaryIfLocalizedString(PragmaSyntax token, LocalizedStringWrapper } } } -bool IsPragmaToken(PragmaSyntax token) +bool IsPragmaToken(ISyntaxToken token) { //if(token.SyntaxKind == SyntaxKind.PragmaToken) //{ @@ -156,7 +156,7 @@ bool IsPragmaToken(PragmaSyntax token) return false; } -bool IsStringToken(PragmaSyntax token) +bool IsStringToken(ISyntaxToken token) { if(token.SyntaxKind == SyntaxKind.TypedStringDToken || token.SyntaxKind == SyntaxKind.TypedStringSToken || diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extended_by_known_type.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extended_by_known_type.g.cs index da3314b6..e296c211 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extended_by_known_type.g.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/class_extended_by_known_type.g.cs @@ -3,8 +3,6 @@ using AXSharp.Connector.ValueTypes; using System.Collections.Generic; using AXSharp.Connector.Localizations; -using Simatic.Ax.Stateframework; -using Simatic.Ax.StatePattern; namespace Simatic.Ax.StateFramework { diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/file_with_usings.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/file_with_usings.g.cs index 7960acb2..1f3ba8e0 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/file_with_usings.g.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/Onliners/file_with_usings.g.cs @@ -3,9 +3,6 @@ using AXSharp.Connector.ValueTypes; using System.Collections.Generic; using AXSharp.Connector.Localizations; -using FileWithUsingsSimpleFirstLevelNamespace; -using FileWithUsingsSimpleQualifiedNamespace.Qualified; -using FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo; namespace FileWithUsingsSimpleFirstLevelNamespace { diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extended_by_known_type.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extended_by_known_type.g.cs index c2efaa77..d0264b84 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extended_by_known_type.g.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/class_extended_by_known_type.g.cs @@ -1,6 +1,4 @@ using System; -using Pocos.Simatic.Ax.Stateframework; -using Pocos.Simatic.Ax.StatePattern; namespace Pocos { diff --git a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/file_with_usings.g.cs b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/file_with_usings.g.cs index 0d64ca0c..cd26fc5e 100644 --- a/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/file_with_usings.g.cs +++ b/src/AXSharp.compiler/tests/AXSharp.Compiler.CsTests/samples/units/expected/.g/POCO/file_with_usings.g.cs @@ -1,7 +1,4 @@ using System; -using Pocos.FileWithUsingsSimpleFirstLevelNamespace; -using Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified; -using Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo; namespace Pocos {