Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Various fixes after udpate to stc v6" #307

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("}");
Expand Down
38 changes: 19 additions & 19 deletions src/AXSharp.compiler/src/ixr/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,35 @@ void Generate(Options o)

void IterateSyntaxTreeForStringLiterals(ISyntaxNode root, LocalizedStringWrapper lw, string fileName)
{
//foreach (var literalSyntax in GetChildNodesRecursive(root).OfType<ILiteralSyntax>())
//{
// var token = literalSyntax.Tokens.First();
// //literalSyntax.Location
// AddToDictionaryIfLocalizedString(token,lw,fileName);
//}
foreach (var literalSyntax in GetChildNodesRecursive(root).OfType<ILiteralSyntax>())
{
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<PragmaSyntax>())
{
var token = pragmaSyntax;
if (lw.IsAttributeNamePragmaToken(token.PragmaContent))
{
AddToDictionaryIfLocalizedString(token, lw, fileName);
}
}
//foreach (var pragmaSyntax in GetChildNodesRecursive(root).OfType<PragmaSyntax>())
//{
// 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)
{
Expand All @@ -139,15 +139,15 @@ 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);
}
}
}
}
bool IsPragmaToken(PragmaSyntax token)
bool IsPragmaToken(ISyntaxToken token)
{
//if(token.SyntaxKind == SyntaxKind.PragmaToken)
//{
Expand All @@ -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 ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using Pocos.Simatic.Ax.Stateframework;
using Pocos.Simatic.Ax.StatePattern;

namespace Pocos
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Pocos.FileWithUsingsSimpleFirstLevelNamespace;
using Pocos.FileWithUsingsSimpleQualifiedNamespace.Qualified;
using Pocos.FileWithUsingsHelloLevelOne.FileWithUsingsHelloLevelTwo;

namespace Pocos
{
Expand Down
Loading