Skip to content

Commit d3a0701

Browse files
committed
Fixes to PR comments
1 parent f2ac4ae commit d3a0701

10 files changed

Lines changed: 259 additions & 169 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ nbproject/
1212
## Build folders
1313
build/
1414
build_*/
15+
Build/
16+
Build_*/
1517
install/
1618
install_*/

plugins/csharp/csharp.sln

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.5.2.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "db_model", "db_model", "{2E2F0E00-502D-A052-0019-82CFB9270E3D}"
6+
EndProject
7+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "migrations", "migrations", "{D4C4D1C2-DE9C-AF20-17FD-0A3EB2BFD436}"
8+
EndProject
9+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "service", "service", "{226567F5-DD15-7888-5BF1-C4407778305A}"
10+
EndProject
11+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "parser", "parser", "{BC34E35A-B109-A120-90EC-15530B70B9CB}"
12+
EndProject
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbModel", "db_model\DbModel.csproj", "{BADE2559-4F0F-21F6-067B-8EDF7DE9DFC1}"
14+
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqliteMigrations", "migrations\sqliteMigrations\SqliteMigrations.csproj", "{2C9A9B86-A50E-C025-B4E0-195D2ACD4B54}"
16+
EndProject
17+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PgsqlMigrations", "migrations\pgsqlMigrations\PgsqlMigrations.csproj", "{20C587AF-64DB-68B4-1F92-61681232D74B}"
18+
EndProject
19+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src_csharp", "src_csharp", "{9BD6E17B-7A65-7B8B-5096-A508D0BE5AAA}"
20+
EndProject
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharpservice", "service\src_csharp\csharpservice.csproj", "{1AF03105-21A5-3508-A40F-365ADA9DFF92}"
22+
EndProject
23+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src_csharp", "src_csharp", "{37C60329-C8F7-3ACB-DE03-F714C9EE58C5}"
24+
EndProject
25+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpParser", "parser\src_csharp\CSharpParser.csproj", "{568E5C5A-2A3E-AEA2-1355-EC26E382DA2B}"
26+
EndProject
27+
Global
28+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
29+
Debug|Any CPU = Debug|Any CPU
30+
Release|Any CPU = Release|Any CPU
31+
EndGlobalSection
32+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
33+
{BADE2559-4F0F-21F6-067B-8EDF7DE9DFC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{BADE2559-4F0F-21F6-067B-8EDF7DE9DFC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{BADE2559-4F0F-21F6-067B-8EDF7DE9DFC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{BADE2559-4F0F-21F6-067B-8EDF7DE9DFC1}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{2C9A9B86-A50E-C025-B4E0-195D2ACD4B54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{2C9A9B86-A50E-C025-B4E0-195D2ACD4B54}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{2C9A9B86-A50E-C025-B4E0-195D2ACD4B54}.Release|Any CPU.ActiveCfg = Release|Any CPU
40+
{2C9A9B86-A50E-C025-B4E0-195D2ACD4B54}.Release|Any CPU.Build.0 = Release|Any CPU
41+
{20C587AF-64DB-68B4-1F92-61681232D74B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42+
{20C587AF-64DB-68B4-1F92-61681232D74B}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{20C587AF-64DB-68B4-1F92-61681232D74B}.Release|Any CPU.ActiveCfg = Release|Any CPU
44+
{20C587AF-64DB-68B4-1F92-61681232D74B}.Release|Any CPU.Build.0 = Release|Any CPU
45+
{1AF03105-21A5-3508-A40F-365ADA9DFF92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46+
{1AF03105-21A5-3508-A40F-365ADA9DFF92}.Debug|Any CPU.Build.0 = Debug|Any CPU
47+
{1AF03105-21A5-3508-A40F-365ADA9DFF92}.Release|Any CPU.ActiveCfg = Release|Any CPU
48+
{1AF03105-21A5-3508-A40F-365ADA9DFF92}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{568E5C5A-2A3E-AEA2-1355-EC26E382DA2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{568E5C5A-2A3E-AEA2-1355-EC26E382DA2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{568E5C5A-2A3E-AEA2-1355-EC26E382DA2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
52+
{568E5C5A-2A3E-AEA2-1355-EC26E382DA2B}.Release|Any CPU.Build.0 = Release|Any CPU
53+
EndGlobalSection
54+
GlobalSection(SolutionProperties) = preSolution
55+
HideSolutionNode = FALSE
56+
EndGlobalSection
57+
GlobalSection(NestedProjects) = preSolution
58+
{BADE2559-4F0F-21F6-067B-8EDF7DE9DFC1} = {2E2F0E00-502D-A052-0019-82CFB9270E3D}
59+
{2C9A9B86-A50E-C025-B4E0-195D2ACD4B54} = {D4C4D1C2-DE9C-AF20-17FD-0A3EB2BFD436}
60+
{20C587AF-64DB-68B4-1F92-61681232D74B} = {D4C4D1C2-DE9C-AF20-17FD-0A3EB2BFD436}
61+
{9BD6E17B-7A65-7B8B-5096-A508D0BE5AAA} = {226567F5-DD15-7888-5BF1-C4407778305A}
62+
{1AF03105-21A5-3508-A40F-365ADA9DFF92} = {9BD6E17B-7A65-7B8B-5096-A508D0BE5AAA}
63+
{37C60329-C8F7-3ACB-DE03-F714C9EE58C5} = {BC34E35A-B109-A120-90EC-15530B70B9CB}
64+
{568E5C5A-2A3E-AEA2-1355-EC26E382DA2B} = {37C60329-C8F7-3ACB-DE03-F714C9EE58C5}
65+
EndGlobalSection
66+
GlobalSection(ExtensibilityGlobals) = postSolution
67+
SolutionGuid = {17FCE6F1-24FA-4D94-8799-D869033FFB44}
68+
EndGlobalSection
69+
EndGlobal

plugins/csharp/parser/src/csharpparser.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ bool CsharpParser::parse()
4646

4747
if (acceptProjectBuildPath(buildPath))
4848
{
49-
LOG(debug) << "C# parser parse path: " << paths[0];
50-
LOG(debug) << "Parsed csharp project build path: " << buildPath;
5149
success = success && parseProjectBuildPath(paths, buildPath);
5250
}
5351
else
@@ -108,7 +106,6 @@ bool CsharpParser::parseProjectBuildPath(
108106

109107
std::string line;
110108
std::stringstream log_str(log.get());
111-
//LOG(warning) << log_str.str();
112109
int countFull = 0, countPart = 0;
113110

114111
while(std::getline(log_str, line, '\n'))

plugins/csharp/parser/src_csharp/AstVisitor.cs

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,18 @@ partial class AstVisitor : CSharpSyntaxWalker
1414
private readonly CsharpDbContext DbContext;
1515
private readonly SemanticModel Model;
1616
private readonly SyntaxTree Tree;
17+
private readonly AstVisitorHelper Helper;
1718

1819
public bool FullyParsed = true;
1920

2021
public AstVisitor(CsharpDbContext context, SemanticModel model, SyntaxTree tree)
2122
{
2223
this.DbContext = context;
2324
this.Model = model;
24-
this.Tree = tree;
25-
}
26-
27-
private ulong createIdentifier(CsharpAstNode astNode){
28-
string[] properties =
29-
{
30-
astNode.AstValue,":",
31-
astNode.AstType.ToString(),":",
32-
astNode.EntityHash.ToString(),":",
33-
astNode.RawKind.ToString(),":",
34-
astNode.Path,":",
35-
astNode.Location_range_start_line.ToString(),":",
36-
astNode.Location_range_start_column.ToString(),":",
37-
astNode.Location_range_end_line.ToString(),":",
38-
astNode.Location_range_end_column.ToString()
39-
};
40-
41-
string res = string.Concat(properties);
42-
43-
//WriteLine(res);
44-
return fnvHash(res);
25+
this.Tree = tree;
26+
this.Helper = new AstVisitorHelper();
4527
}
4628

47-
private ulong fnvHash(string data_)
48-
{
49-
ulong hash = 14695981039346656037;
50-
51-
int len = data_.Length;
52-
for (int i = 0; i < len; ++i)
53-
{
54-
hash ^= data_[i];
55-
hash *= 1099511628211;
56-
}
57-
58-
return hash;
59-
}
60-
61-
private ulong getAstNodeId(SyntaxNode node){
62-
CsharpAstNode astNode = new CsharpAstNode
63-
{
64-
AstValue = node.ToString(),
65-
RawKind = node.Kind(),
66-
EntityHash = node.GetHashCode(),
67-
AstType = AstTypeEnum.Declaration
68-
};
69-
astNode.SetLocation(node.SyntaxTree.GetLineSpan(node.Span));
70-
var ret = createIdentifier(astNode);
71-
return ret;
72-
}
73-
7429
private CsharpAstNode AstNode(SyntaxNode node, AstSymbolTypeEnum type, AstTypeEnum astType)
7530
{
7631
Accessibility acc = Accessibility.NotApplicable;
@@ -92,7 +47,7 @@ private CsharpAstNode AstNode(SyntaxNode node, AstSymbolTypeEnum type, AstTypeEn
9247
Accessibility = acc
9348
};
9449
astNode.SetLocation(Tree.GetLineSpan(node.Span));
95-
astNode.Id = createIdentifier(astNode);
50+
astNode.Id = Helper.createIdentifier(astNode);
9651

9752
if (DbContext.CsharpAstNodes.Find(astNode.Id) == null)
9853
{
@@ -933,7 +888,7 @@ public override void VisitInvocationExpression(InvocationExpressionSyntax node)
933888
FullyParsed = false;
934889
}
935890
var info = Model.GetTypeInfo(node).ConvertedType;
936-
var declaratorNodeId = getAstNodeId(declaration.GetSyntax());
891+
var declaratorNodeId = Helper.getAstNodeId(declaration.GetSyntax());
937892
var astNode = AstNode(node, AstSymbolTypeEnum.EtcEntity, AstTypeEnum.Usage);
938893
CsharpEtcEntity invoc = new CsharpEtcEntity
939894
{
@@ -981,7 +936,7 @@ public override void VisitIdentifierName(IdentifierNameSyntax node)
981936
EtcEntityTypeEnum.ForeachExpr : EtcEntityTypeEnum.Invocation;
982937
if (node.Parent.Parent.Kind() != SyntaxKind.InvocationExpression)
983938
{
984-
var declaratorNodeId = getAstNodeId(declaration.GetSyntax());
939+
var declaratorNodeId = Helper.getAstNodeId(declaration.GetSyntax());
985940
var astNode = AstNode(node, AstSymbolTypeEnum.EtcEntity, AstTypeEnum.Usage);
986941
CsharpEtcEntity expr = new CsharpEtcEntity
987942
{
@@ -1004,4 +959,54 @@ public override void VisitIdentifierName(IdentifierNameSyntax node)
1004959

1005960
}
1006961
}
962+
963+
class AstVisitorHelper
964+
{
965+
public ulong createIdentifier(CsharpAstNode astNode){
966+
string[] properties =
967+
{
968+
astNode.AstValue,":",
969+
astNode.AstType.ToString(),":",
970+
astNode.EntityHash.ToString(),":",
971+
astNode.RawKind.ToString(),":",
972+
astNode.Path,":",
973+
astNode.Location_range_start_line.ToString(),":",
974+
astNode.Location_range_start_column.ToString(),":",
975+
astNode.Location_range_end_line.ToString(),":",
976+
astNode.Location_range_end_column.ToString()
977+
};
978+
979+
string res = string.Concat(properties);
980+
981+
//WriteLine(res);
982+
return fnvHash(res);
983+
}
984+
985+
private ulong fnvHash(string data_)
986+
{
987+
ulong hash = 14695981039346656037;
988+
989+
int len = data_.Length;
990+
for (int i = 0; i < len; ++i)
991+
{
992+
hash ^= data_[i];
993+
hash *= 1099511628211;
994+
}
995+
996+
return hash;
997+
}
998+
999+
public ulong getAstNodeId(SyntaxNode node){
1000+
CsharpAstNode astNode = new CsharpAstNode
1001+
{
1002+
AstValue = node.ToString(),
1003+
RawKind = node.Kind(),
1004+
EntityHash = node.GetHashCode(),
1005+
AstType = AstTypeEnum.Declaration
1006+
};
1007+
astNode.SetLocation(node.SyntaxTree.GetLineSpan(node.Span));
1008+
var ret = createIdentifier(astNode);
1009+
return ret;
1010+
}
1011+
}
10071012
}

plugins/csharp/parser/src_csharp/Program.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int Main(string[] args)
8282
}*/
8383

8484
//Converting the connectionstring into entiy framwork style connectionstring
85-
string csharpConnectionString = transformConnectionString();
85+
string csharpConnectionString = ProgramHelper.transformConnectionString(_connectionString);
8686

8787
var options = new DbContextOptionsBuilder<CsharpDbContext>()
8888
.UseNpgsql(csharpConnectionString)
@@ -95,17 +95,17 @@ static int Main(string[] args)
9595
foreach (var p in _rootDir)
9696
{
9797
Console.WriteLine(p);
98-
allFiles.AddRange(GetSourceFilesFromDir(p, ".cs"));
98+
allFiles.AddRange(ProgramHelper.GetSourceFilesFromDir(p, ".cs"));
9999
}
100100

101101
foreach (var f in allFiles)
102102
{
103103
WriteLine(f);
104104
}
105-
IEnumerable<string> assemblies = GetSourceFilesFromDir(_buildDir, ".dll");
105+
IEnumerable<string> assemblies = ProgramHelper.GetSourceFilesFromDir(_buildDir, ".dll");
106106
IEnumerable<string> assemblies_base = assemblies;
107107
if (args.Length == 5)
108-
assemblies_base = GetSourceFilesFromDir(_buildDirBase, ".dll");
108+
assemblies_base = ProgramHelper.GetSourceFilesFromDir(_buildDirBase, ".dll");
109109

110110
List<SyntaxTree> trees = new List<SyntaxTree>();
111111
foreach (string file in allFiles)
@@ -197,6 +197,11 @@ private static async Task<int> ParseTree(CsharpDbContext context,
197197
return await ParsingTask;
198198
}
199199

200+
201+
}
202+
203+
class ProgramHelper
204+
{
200205
public static IEnumerable<string> GetSourceFilesFromDir(string root, string extension)
201206
{
202207
IEnumerable<string> allFiles = new string[]{};
@@ -268,7 +273,7 @@ public static IEnumerable<string> GetSourceFilesFromDir(string root, string exte
268273
return allFiles;
269274
}
270275

271-
private static string transformConnectionString()
276+
public static string transformConnectionString(string _connectionString)
272277
{
273278
_connectionString = _connectionString.Substring(_connectionString.IndexOf(':')+1);
274279
_connectionString = _connectionString.Replace("user", "username");

plugins/csharp/service/include/service/csharpservice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class CSharpQueryHandler : public CsharpServiceIf
8181

8282
if (elapsed_time > timeoutInMs_)
8383
{
84-
LOG(debug) << "Connection timeout, could not reach CSharp server on"
84+
LOG(error) << "Connection timeout, could not reach CSharp server on"
8585
<< host << ":" << _thriftServerPort;
8686
apache::thrift::GlobalOutput.setOutputFunction(
8787
apache::thrift::TOutput::errorTimeWrapper);
@@ -332,6 +332,7 @@ class CsharpServiceHandler : virtual public LanguageServiceIf
332332

333333
cc::service::csharp::CSharpQueryHandler _csharpQueryHandler;
334334
static int _thriftServerPort;
335+
static int getThriftServerPort();
335336
};
336337

337338
} // language

0 commit comments

Comments
 (0)