mirror of
https://github.com/chylex/Code-Statistics.git
synced 2025-04-09 19:15:41 +02:00
Add a WIP Java handler
This commit is contained in:
parent
676c861f61
commit
b929fb6c9e
CodeStatistics
@ -57,6 +57,9 @@
|
||||
<Compile Include="Handlers\FileHandler.cs" />
|
||||
<Compile Include="Handlers\IHandlerTab.cs" />
|
||||
<Compile Include="Handlers\Objects\AssetHandler.cs" />
|
||||
<Compile Include="Handlers\Objects\JavaHandler.cs" />
|
||||
<Compile Include="Handlers\Objects\Java\JavaParser.cs" />
|
||||
<Compile Include="Handlers\Objects\Java\JavaStatistics.cs" />
|
||||
<Compile Include="Handlers\ProjectAnalyzer.cs" />
|
||||
<Compile Include="Input\File.cs" />
|
||||
<Compile Include="Input\FileSearch.cs" />
|
||||
|
@ -6,6 +6,8 @@ namespace CodeStatistics.Handlers{
|
||||
private static readonly Dictionary<string,FileHandler> handlers = new Dictionary<string,FileHandler>();
|
||||
|
||||
static FileHandlers(){
|
||||
handlers.Add("java",new JavaHandler());
|
||||
|
||||
AssetHandler assetHandler = new AssetHandler(10);
|
||||
|
||||
foreach(string ext in new string[]{
|
||||
@ -39,4 +41,3 @@ namespace CodeStatistics.Handlers{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
19
CodeStatistics/Handlers/Objects/Java/JavaParser.cs
Normal file
19
CodeStatistics/Handlers/Objects/Java/JavaParser.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using CodeStatistics.Input;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace CodeStatistics.Handlers.Objects.Java{
|
||||
static class JavaParser{
|
||||
private static readonly Regex commentOneLine = new Regex(@"//.*",RegexOptions.Compiled);
|
||||
private static readonly Regex commentMultiLine = new Regex(@"/\*(?:.|[\n\r])*?\*/",RegexOptions.Compiled);
|
||||
|
||||
public static void Parse(File file, JavaStatistics stats){
|
||||
string filePlain = file.Read();
|
||||
string fileParsed = commentMultiLine.Replace(commentOneLine.Replace(filePlain,""),"");
|
||||
|
||||
string[] linesPlain = filePlain.Split("\\n".ToCharArray()); // lines are always \n
|
||||
string[] linesParsed = fileParsed.Split("\\n".ToCharArray()); // ^
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
7
CodeStatistics/Handlers/Objects/Java/JavaStatistics.cs
Normal file
7
CodeStatistics/Handlers/Objects/Java/JavaStatistics.cs
Normal file
@ -0,0 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CodeStatistics.Handlers.Objects.Java{
|
||||
class JavaStatistics{
|
||||
public HashSet<string> Packages = new HashSet<string>();
|
||||
}
|
||||
}
|
31
CodeStatistics/Handlers/Objects/JavaHandler.cs
Normal file
31
CodeStatistics/Handlers/Objects/JavaHandler.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using CodeStatistics.ConsoleUtil;
|
||||
using CodeStatistics.Handlers.Objects.Java;
|
||||
using CodeStatistics.Input;
|
||||
|
||||
namespace CodeStatistics.Handlers.Objects{
|
||||
class JavaHandler : FileHandler.Major{
|
||||
private JavaStatistics stats = new JavaStatistics();
|
||||
|
||||
public override string GetName(){
|
||||
return "Java";
|
||||
}
|
||||
|
||||
public override void Handle(File file){
|
||||
JavaParser.Parse(file,stats);
|
||||
}
|
||||
|
||||
public override IHandlerTab[] GenerateTabs(){
|
||||
return new IHandlerTab[]{ new GeneralTab() };
|
||||
}
|
||||
|
||||
class GeneralTab : IHandlerTab{
|
||||
public string GetName(){
|
||||
return "General";
|
||||
}
|
||||
|
||||
public void RenderInfo(ConsoleWrapper c, int y){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user