Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit89420df

Browse files
committed
refactor: use file scoped namespaces
1 parent56f4baa commit89420df

36 files changed

+1698
-1734
lines changed

‎src/Glob/AST/CharacterSet.cs‎

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,71 @@
22
usingSystem.Linq;
33
usingSystem.Text;
44

5-
namespaceGlobExpressions.AST
5+
namespaceGlobExpressions.AST;
6+
7+
internalsealedclassCharacterSet:SubSegment
68
{
7-
internalsealedclassCharacterSet:SubSegment
8-
{
9-
publicboolInverted{get;}
10-
publicstringCharacters{get;}
11-
publicstringExpandedCharacters{get;}
9+
publicboolInverted{get;}
10+
publicstringCharacters{get;}
11+
publicstringExpandedCharacters{get;}
1212

13-
publicCharacterSet(stringcharacters,boolinverted)
14-
:base(GlobNodeType.CharacterSet)
15-
{
13+
publicCharacterSet(stringcharacters,boolinverted)
14+
:base(GlobNodeType.CharacterSet)
15+
{
1616
Characters=characters;
1717
Inverted=inverted;
1818
this.ExpandedCharacters=CalculateExpandedForm(characters);
1919
}
2020

21-
publicboolMatches(charc,boolcaseSensitive)=>Contains(c,caseSensitive)!=this.Inverted;
21+
publicboolMatches(charc,boolcaseSensitive)=>Contains(c,caseSensitive)!=this.Inverted;
2222

23-
privateboolContains(charc,boolcaseSensitive)=>ExpandedCharacters.IndexOf(c.ToString(),caseSensitive?StringComparison.Ordinal:StringComparison.OrdinalIgnoreCase)>=0;
23+
privateboolContains(charc,boolcaseSensitive)=>ExpandedCharacters.IndexOf(c.ToString(),caseSensitive?StringComparison.Ordinal:StringComparison.OrdinalIgnoreCase)>=0;
2424

25-
privatestringCalculateExpandedForm(stringchars)
25+
privatestringCalculateExpandedForm(stringchars)
26+
{
27+
varsb=newStringBuilder();
28+
vari=0;
29+
varlen=chars.Length;
30+
31+
// if first character is special, add it
32+
if(chars.StartsWith("-")||chars.StartsWith("[")||chars.StartsWith("]"))
2633
{
27-
varsb=newStringBuilder();
28-
vari=0;
29-
varlen=chars.Length;
34+
sb.Append(chars[0]);
35+
i++;
36+
}
3037

31-
// if first character is special, add it
32-
if(chars.StartsWith("-")||chars.StartsWith("[")||chars.StartsWith("]"))
33-
{
34-
sb.Append(chars[0]);
35-
i++;
36-
}
38+
while(true)
39+
{
40+
if(i>=len)
41+
break;
3742

38-
while(true)
43+
if(chars[i]=='-')
3944
{
40-
if(i>=len)
41-
break;
42-
43-
if(chars[i]=='-')
45+
if(i==len-1)
4446
{
45-
if(i==len-1)
46-
{
47-
// - is last character so just add it
48-
sb.Append('-');
49-
}
50-
else
51-
{
52-
for(varc=chars[i-1]+1;c<=chars[i+1];c++)
53-
{
54-
sb.Append((char)c);
55-
}
56-
i++;// skip trailing range
57-
}
58-
}
59-
elseif(chars[i]=='/')
60-
{
61-
i++;// skip
47+
// - is last character so just add it
48+
sb.Append('-');
6249
}
6350
else
6451
{
65-
sb.Append(chars[i]);
52+
for(varc=chars[i-1]+1;c<=chars[i+1];c++)
53+
{
54+
sb.Append((char)c);
55+
}
56+
i++;// skip trailing range
6657
}
67-
i++;
6858
}
69-
70-
returnsb.ToString();
59+
elseif(chars[i]=='/')
60+
{
61+
i++;// skip
62+
}
63+
else
64+
{
65+
sb.Append(chars[i]);
66+
}
67+
i++;
7168
}
69+
70+
returnsb.ToString();
7271
}
73-
}
72+
}

‎src/Glob/AST/CharacterWildcard.cs‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
namespaceGlobExpressions.AST
1+
namespaceGlobExpressions.AST;
2+
3+
internalsealedclassCharacterWildcard:SubSegment
24
{
3-
internalsealedclassCharacterWildcard:SubSegment
4-
{
5-
publicstaticreadonlyCharacterWildcardDefault=newCharacterWildcard();
5+
publicstaticreadonlyCharacterWildcardDefault=newCharacterWildcard();
66

7-
privateCharacterWildcard()
8-
:base(GlobNodeType.CharacterWildcard)
9-
{
7+
privateCharacterWildcard()
8+
:base(GlobNodeType.CharacterWildcard)
9+
{
1010
}
1111

12-
publicoverridestringToString()=>"?";
13-
}
14-
}
12+
publicoverridestringToString()=>"?";
13+
}

‎src/Glob/AST/DirectorySegment.cs‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
usingSystem.Collections.Generic;
22
usingSystem.Linq;
33

4-
namespaceGlobExpressions.AST
4+
namespaceGlobExpressions.AST;
5+
6+
internalsealedclassDirectorySegment:Segment
57
{
6-
internalsealedclassDirectorySegment:Segment
7-
{
8-
publicSubSegment[]SubSegments{get;}
8+
publicSubSegment[]SubSegments{get;}
99

10-
publicDirectorySegment(IEnumerable<SubSegment>subSegments)
11-
:base(GlobNodeType.DirectorySegment)
12-
{
10+
publicDirectorySegment(IEnumerable<SubSegment>subSegments)
11+
:base(GlobNodeType.DirectorySegment)
12+
{
1313
SubSegments=subSegments.ToArray();
1414
}
1515

16-
publicoverridestringToString()
17-
{
16+
publicoverridestringToString()
17+
{
1818
returnstring.Join("",SubSegments.Select(x=>x.ToString()));
1919
}
20-
}
21-
}
20+
}

‎src/Glob/AST/DirectoryWildcard.cs‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
namespaceGlobExpressions.AST
1+
namespaceGlobExpressions.AST;
2+
3+
internalsealedclassDirectoryWildcard:Segment
24
{
3-
internalsealedclassDirectoryWildcard:Segment
4-
{
5-
publicstaticreadonlyDirectoryWildcardDefault=newDirectoryWildcard();
5+
publicstaticreadonlyDirectoryWildcardDefault=newDirectoryWildcard();
66

7-
privateDirectoryWildcard()
8-
:base(GlobNodeType.DirectoryWildcard)
9-
{
7+
privateDirectoryWildcard()
8+
:base(GlobNodeType.DirectoryWildcard)
9+
{
1010
}
1111

12-
publicoverridestringToString()
13-
{
12+
publicoverridestringToString()
13+
{
1414
return"**";
1515
}
16-
}
17-
}
16+
}

‎src/Glob/AST/GlobNode.cs‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
namespaceGlobExpressions.AST
1+
namespaceGlobExpressions.AST;
2+
3+
internalabstractclassGlobNode
24
{
3-
internalabstractclassGlobNode
5+
protectedGlobNode(GlobNodeTypetype)
46
{
5-
protectedGlobNode(GlobNodeTypetype)
6-
{
77
this.Type=type;
88
}
99

10-
publicGlobNodeTypeType{get;}
11-
}
12-
}
10+
publicGlobNodeTypeType{get;}
11+
}

‎src/Glob/AST/GlobNodeType.cs‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
namespaceGlobExpressions.AST
1+
namespaceGlobExpressions.AST;
2+
3+
internalenumGlobNodeType
24
{
3-
internalenumGlobNodeType
4-
{
5-
Tree,
5+
Tree,
66

7-
// Segments
8-
Root,
7+
// Segments
8+
Root,
99

10-
DirectoryWildcard,
11-
DirectorySegment,
10+
DirectoryWildcard,
11+
DirectorySegment,
1212

13-
// SubSegments
14-
CharacterSet,
13+
// SubSegments
14+
CharacterSet,
1515

16-
Identifier,
17-
LiteralSet,
18-
StringWildcard,
19-
CharacterWildcard
20-
}
16+
Identifier,
17+
LiteralSet,
18+
StringWildcard,
19+
CharacterWildcard
2120
}

‎src/Glob/AST/Identifier.cs‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
namespaceGlobExpressions.AST
1+
namespaceGlobExpressions.AST;
2+
3+
internalsealedclassIdentifier:SubSegment
24
{
3-
internalsealedclassIdentifier:SubSegment
4-
{
5-
publicstringValue{get;}
5+
publicstringValue{get;}
66

7-
publicIdentifier(stringvalue)
8-
:base(GlobNodeType.Identifier)
9-
{
10-
Value=value;
11-
}
7+
publicIdentifier(stringvalue)
8+
:base(GlobNodeType.Identifier)
9+
{
10+
Value=value;
11+
}
1212

13-
publicoverridestringToString()=>Value;
13+
publicoverridestringToString()=>Value;
1414

15-
publicstaticimplicitoperatorIdentifier(stringvalue)
16-
{
17-
returnnewIdentifier(value);
18-
}
15+
publicstaticimplicitoperatorIdentifier(stringvalue)
16+
{
17+
returnnewIdentifier(value);
1918
}
20-
}
19+
}

‎src/Glob/AST/LiteralSet.cs‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
usingSystem.Collections.Generic;
22
usingSystem.Linq;
33

4-
namespaceGlobExpressions.AST
4+
namespaceGlobExpressions.AST;
5+
6+
internalsealedclassLiteralSet:SubSegment
57
{
6-
internalsealedclassLiteralSet:SubSegment
7-
{
8-
publicIdentifier[]Literals{get;}
8+
publicIdentifier[]Literals{get;}
99

10-
publicLiteralSet(paramsIdentifier[]literals)
11-
:base(GlobNodeType.LiteralSet)
12-
{
10+
publicLiteralSet(paramsIdentifier[]literals)
11+
:base(GlobNodeType.LiteralSet)
12+
{
1313
Literals=literals.ToArray();
1414
}
1515

16-
publicLiteralSet(IEnumerable<Identifier>literals)
17-
:base(GlobNodeType.LiteralSet)
18-
{
16+
publicLiteralSet(IEnumerable<Identifier>literals)
17+
:base(GlobNodeType.LiteralSet)
18+
{
1919
Literals=literals.ToArray();
2020
}
2121

22-
publicoverridestringToString()=>$"{{{string.Join(",", Literals.Select(lit => lit.ToString()))}}}";
23-
}
24-
}
22+
publicoverridestringToString()=>$"{{{string.Join(",", Literals.Select(lit => lit.ToString()))}}}";
23+
}

‎src/Glob/AST/Root.cs‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
namespaceGlobExpressions.AST
1+
namespaceGlobExpressions.AST;
2+
3+
internalsealedclassRoot:Segment
24
{
3-
internalsealedclassRoot:Segment
4-
{
5-
publicstringText{get;}
5+
publicstringText{get;}
66

7-
publicRoot(stringtext="")
8-
:base(GlobNodeType.Root)
9-
{
7+
publicRoot(stringtext="")
8+
:base(GlobNodeType.Root)
9+
{
1010
Text=text;
1111
}
1212

13-
publicoverridestringToString()=>Text;
14-
}
15-
}
13+
publicoverridestringToString()=>Text;
14+
}

‎src/Glob/AST/Segment.cs‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
namespaceGlobExpressions.AST
1+
namespaceGlobExpressions.AST;
2+
3+
internalabstractclassSegment:GlobNode
24
{
3-
internalabstractclassSegment:GlobNode
5+
protectedSegment(GlobNodeTypetype)
6+
:base(type)
47
{
5-
protectedSegment(GlobNodeTypetype)
6-
:base(type)
7-
{
88
}
9-
}
10-
}
9+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp