Skip to content

Commit

Permalink
[Fix] Issue#1 Parser finds errors that aren't errors
Browse files Browse the repository at this point in the history
  • Loading branch information
megaboich committed Sep 16, 2015
1 parent 840e123 commit a56ea18
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 45 deletions.
3 changes: 2 additions & 1 deletion source/JsParser.Core/Infrastructure/JsParserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ private bool CheckExt(string fileName)
{
if (_settings.Extensions.Count > 0)
{
var currentExt = Path.GetExtension(fileName).SafeTrimStart('.');
foreach (var ext in _settings.Extensions)
{
if (fileName.ToLower().EndsWith(ext, StringComparison.InvariantCultureIgnoreCase))
if (string.Compare(currentExt, ext, StringComparison.InvariantCultureIgnoreCase) == 0)
{
return true;
}
Expand Down
98 changes: 54 additions & 44 deletions source/JsParser.Core/Parsers/JSParserExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,58 @@

namespace JsParser.Core.Parsers
{
public static class JSParserExtensions
{
public static string Shortenize(this String s, int targetLength)
{
if (targetLength <= 0)
{
return string.Empty;
}

if (s.Length > targetLength)
{
var si = (int)2 * (targetLength / 3);
s = s.Substring(0, si) + '\x2026' + s.Substring(s.Length + 1 - targetLength + si);
}

return s;
}

/// <summary>
/// Transform input string by adding spaces where words should be separeated.
/// Example: "ThisStringShouldBeSeparated" => "This String Shoud Be Separated"
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string SplitWordsByCamelCase(this String s)
{
if (string.IsNullOrEmpty(s))
{
return s;
}

var chars = s.ToList();
for (int charIndex = 0; charIndex < chars.Count; charIndex++)
{
if (char.IsUpper(chars[charIndex]))
{
chars.Insert(charIndex, ' ');
charIndex++;
}
}

return new string(chars.ToArray()).Trim();
}
}
public static class JsParserExtensions
{
public static string SafeTrimStart(this string s, char symbol)
{
if (string.IsNullOrEmpty(s))
{
return string.Empty;
}

return s.TrimStart(symbol);
}

public static string Shortenize(this String s, int targetLength)
{
if (targetLength <= 0)
{
return string.Empty;
}

if (s.Length > targetLength)
{
var si = (int) 2*(targetLength/3);
s = s.Substring(0, si) + '\x2026' + s.Substring(s.Length + 1 - targetLength + si);
}

return s;
}

/// <summary>
/// Transform input string by adding spaces where words should be separeated.
/// Example: "ThisStringShouldBeSeparated" => "This String Shoud Be Separated"
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string SplitWordsByCamelCase(this String s)
{
if (string.IsNullOrEmpty(s))
{
return s;
}

var chars = s.ToList();
for (int charIndex = 0; charIndex < chars.Count; charIndex++)
{
if (char.IsUpper(chars[charIndex]))
{
chars.Insert(charIndex, ' ');
charIndex++;
}
}

return new string(chars.ToArray()).Trim();
}
}
}

0 comments on commit a56ea18

Please sign in to comment.