1
0
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:
chylex 2015-09-09 12:02:04 +02:00
parent 676c861f61
commit b929fb6c9e
5 changed files with 62 additions and 1 deletions

View File

@ -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" />

View File

@ -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{
}
}
}

View 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()); // ^
}
}
}

View File

@ -0,0 +1,7 @@
using System.Collections.Generic;
namespace CodeStatistics.Handlers.Objects.Java{
class JavaStatistics{
public HashSet<string> Packages = new HashSet<string>();
}
}

View 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){
}
}
}
}