Skip to content

Commit

Permalink
Some Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Saranga Athukorale <sarangaa@millenniumit.com>
  • Loading branch information
sathukorale committed Nov 21, 2018
1 parent 4170ef5 commit 9334bb1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions PlantUMLCodeGeneratorGUI/Class.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace PlantUMLCodeGeneratorGUI
static class RegExs
{
public static Regex namespaceMatch = new Regex(@"(namespace)([ \t]+)([a-zA-Z0-9_:]+)([ \t\r\n]*{)");
public static Regex classMatch = new Regex(@"([ \t]*)((class|struct)[ \t]+)([A-Z_0-9]+[ \t]+)?([a-zA-Z0-9_]+)(([ \t\r\n]*{)|([ \t]+:[ \t]*[a-zA-Z0-9_,<>: ]+([ \t\r\n]*{)))");
public static Regex classMatch = new Regex(@"([ \t]*)((class|struct)[ \t]+)([A-Z_0-9]+[ \t]+)?([a-zA-Z0-9_]+)(([ \t\r\n]*{)|(([ \t]+:)([ \t]*[a-zA-Z0-9_,<>: ]+([ \t\r\n]*))*{))");
public static Regex methodMatch = new Regex(@"(([ \t]+)([a-zA-Z0-9_:,<>\*]+))+([ \t]*\()((([ \t]*)(([a-zA-Z0-9_:]+[&*]?[ \t]+[a-zA-Z0-9_]+)(,[ \t]*[a-zA-Z0-9_:]+[&*]?[ \t]+[a-zA-Z0-9_]+))|)(\)[ \t\r\n]*([{;=]|override|const)))");
public static Regex multiSpaces = new Regex("[ ]{2,}", RegexOptions.None);
public static Regex templateTypes = new Regex(@"(<)([a-zA-Z0-9_: ,]+)(>)");
Expand Down Expand Up @@ -92,7 +92,7 @@ public void Set(string namespaceContent)
if (Namespaces.ContainsKey(namespaceObj.Name) == false) Namespaces.Add(namespaceObj.Name, namespaceObj);
}

remainingContent = namespaceContent.Substring(lastMatchOffset, namespaceContent.Length - lastMatchOffset);
remainingContent += namespaceContent.Substring(lastMatchOffset, namespaceContent.Length - lastMatchOffset);

remainingContent = ProcessFullContent(remainingContent);
}
Expand Down Expand Up @@ -146,13 +146,16 @@ private string ProcessFullContent(string fullContent)

private string[] GetParents(string parentString)
{
var regexMultipleSpaces = new Regex("[ \t]+");
parentString = regexMultipleSpaces.Replace(parentString.Trim().Replace("\r", "").Replace("\n", ""), " ");

var modifiedParentString = "";
var lastVisitedIndex = 0;
var matches = RegExs.templateTypes.Matches(parentString).OfType<Match>().ToArray();

foreach (var match in matches)
{
modifiedParentString += parentString.Substring(lastVisitedIndex, match.Index);
modifiedParentString += parentString.Substring(lastVisitedIndex, match.Index - lastVisitedIndex);
modifiedParentString += match.Value.Replace(",", "[COMMA]");
lastVisitedIndex = (match.Index + match.Length);
}
Expand Down

0 comments on commit 9334bb1

Please sign in to comment.