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
This repository was archived by the owner on Aug 26, 2022. It is now read-only.
/PSharpPublic archive

Commit87dd7f6

Browse files
lovettchrispdeligia
authored andcommitted
fix bug in brace matching and colors (#466)
1 parentc9c2de6 commit87dd7f6

File tree

3 files changed

+52
-50
lines changed

3 files changed

+52
-50
lines changed

‎Tests/TestingServices.Tests/Runtime/MustHandleEventTest.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void TestMustHandleFail1()
121121
varm=r.CreateMachine(typeof(M1));
122122
r.SendEvent(m,newE(),options:newSendOptions(mustHandle:true));
123123
},
124-
configuration:Configuration.Create().WithNumberOfIterations(100),
124+
configuration:Configuration.Create().WithNumberOfIterations(500),
125125
expectedErrors:newstring[]
126126
{
127127
"A must-handle event 'E' was sent to the halted machine 'M1()'.",
@@ -139,7 +139,7 @@ public void TestMustHandleFail2()
139139
r.SendEvent(m,newE());
140140
r.SendEvent(m,newE(),options:newSendOptions(mustHandle:true));
141141
},
142-
configuration:Configuration.Create().WithNumberOfIterations(100),
142+
configuration:Configuration.Create().WithNumberOfIterations(500),
143143
expectedErrors:newstring[]
144144
{
145145
"A must-handle event 'E' was sent to the halted machine 'M2()'.",
@@ -172,7 +172,7 @@ public void TestMustHandleSuccess()
172172
r.SendEvent(m,newE(),options:newSendOptions(mustHandle:true));
173173
r.SendEvent(m,newHalt());
174174
},
175-
configuration:Configuration.Create().WithNumberOfIterations(100));
175+
configuration:Configuration.Create().WithNumberOfIterations(500));
176176
}
177177

178178
[Fact(Timeout=5000)]

‎Tools/VisualStudio/VisualStudio/BraceMatching/BraceMatchingTagger.cs‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
usingSystem;
77
usingSystem.Linq;
88
usingSystem.Collections.Generic;
9+
usingSystem.ComponentModel.Composition;
910
usingMicrosoft.VisualStudio.Text;
11+
usingMicrosoft.VisualStudio.Text.Classification;
1012
usingMicrosoft.VisualStudio.Text.Editor;
1113
usingMicrosoft.VisualStudio.Text.Tagging;
14+
usingMicrosoft.VisualStudio.Utilities;
1215
usingMicrosoft.PSharp.VisualStudio.Outlining;
1316

1417
namespaceMicrosoft.PSharp.VisualStudio
@@ -60,8 +63,8 @@ void UpdateAtCaretPosition(CaretPosition caretPosition)
6063

6164
publicIEnumerable<ITagSpan<TextMarkerTag>>GetTags(NormalizedSnapshotSpanCollectionspans)
6265
{
63-
// Do nothing if there is no content in the buffer, the current SnapshotPoint is not initialized, or we're at the end of the buffer.
64-
if(spans.Count==0||!CurrentChar.HasValue||CurrentChar.Value.Position>=CurrentChar.Value.Snapshot.Length)
66+
// Do nothing if there is no content in the buffer, the current SnapshotPoint is not initialized
67+
if(spans.Count==0||!CurrentChar.HasValue)
6568
{
6669
yieldbreak;
6770
}
@@ -72,7 +75,11 @@ public IEnumerable<ITagSpan<TextMarkerTag>> GetTags(NormalizedSnapshotSpanCollec
7275
:CurrentChar.Value.TranslateTo(spans[0].Snapshot,PointTrackingMode.Positive);
7376

7477
// If the current char is an opening char, stay on it. Otherwise, back up one to see if the previous char is the close char.
75-
charcurrentChar=currentCharPoint.GetChar();
78+
charcurrentChar='\0';
79+
if(CurrentChar.Value.Position<CurrentChar.Value.Snapshot.Length)
80+
{
81+
currentChar=currentCharPoint.GetChar();
82+
}
7683
varcurrentLine=currentCharPoint.GetContainingLine();
7784

7885
boolisBoundaryChar(outboolisOpen)
@@ -129,12 +136,15 @@ bool getRegion(out Region region)
129136
TagSpan<TextMarkerTag>getTag(intlineNumber,intoffset)
130137
{
131138
varline=currentCharPoint.Snapshot.GetLineFromLineNumber(lineNumber);
132-
returnnewTagSpan<TextMarkerTag>(newSnapshotSpan(line.Start+offset,1),newTextMarkerTag("blue"));
139+
returnnewTagSpan<TextMarkerTag>(newSnapshotSpan(line.Start+offset,1),BraceHighlightTag);
133140
}
134141

135142
yieldreturngetTag(foundRegion.StartLineNumber,foundRegion.StartOffset);
136143
yieldreturngetTag(foundRegion.EndLineNumber,foundRegion.EndOffset-1);// -1 here because EndOffset is after the close char
137144
}
138145
}
146+
147+
publicstaticreadonlyTextMarkerTagBraceHighlightTag=newTextMarkerTag(ClassificationTypeDefinitions.BraceMatchingName);
139148
}
149+
140150
}

‎Tools/VisualStudio/VisualStudio/Classification/ClassificationFormats.cs‎

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,49 @@
55

66
usingSystem.ComponentModel.Composition;
77
usingSystem.Windows.Media;
8-
8+
usingMicrosoft.CodeAnalysis.Classification;
9+
usingMicrosoft.VisualStudio.Language.StandardClassification;
910
usingMicrosoft.VisualStudio.Text.Classification;
1011
usingMicrosoft.VisualStudio.Utilities;
1112

1213
namespaceMicrosoft.PSharp.VisualStudio
1314
{
14-
[Export(typeof(EditorFormatDefinition))]
15-
[ClassificationType(ClassificationTypeNames="PSharp.Keyword")]
16-
[Name("PSharp.Keyword")]
17-
[UserVisible(true)]
18-
internalsealedclassPSharpKeywordFormat:ClassificationFormatDefinition
15+
internalsealedclassClassificationTypeDefinitions
1916
{
20-
publicPSharpKeywordFormat()
21-
{
22-
this.ForegroundColor=Colors.CornflowerBlue;
23-
}
24-
}
17+
[Export]
18+
[ClassificationType(ClassificationTypeNames="PSharp.Keyword")]
19+
[Name("PSharp.Keyword")]
20+
[UserVisible(true)]
21+
[BaseDefinition(PredefinedClassificationTypeNames.Keyword)]
22+
internalreadonlyClassificationTypeDefinitionPSharpKeywordFormat;
2523

26-
[Export(typeof(EditorFormatDefinition))]
27-
[ClassificationType(ClassificationTypeNames="PSharp.TypeIdentifier")]
28-
[Name("PSharp.TypeIdentifier")]
29-
[UserVisible(true)]
30-
internalsealedclassPSharpTypeIdentifierFormat:ClassificationFormatDefinition
31-
{
32-
publicPSharpTypeIdentifierFormat()
33-
{
34-
this.ForegroundColor=Colors.MediumAquamarine;
35-
}
36-
}
24+
[Export]
25+
[ClassificationType(ClassificationTypeNames="PSharp.TypeIdentifier")]
26+
[Name("PSharp.TypeIdentifier")]
27+
[UserVisible(true)]
28+
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
29+
internalreadonlyClassificationTypeDefinitionPSharpTypeIdentifierFormat;
3730

38-
[Export(typeof(EditorFormatDefinition))]
39-
[ClassificationType(ClassificationTypeNames="PSharp.Comment")]
40-
[Name("PSharp.Comment")]
41-
[UserVisible(true)]
42-
internalsealedclassPSharpCommentFormat:ClassificationFormatDefinition
43-
{
44-
publicPSharpCommentFormat()
45-
{
46-
this.ForegroundColor=Colors.SeaGreen;
47-
}
48-
}
31+
[Export]
32+
[ClassificationType(ClassificationTypeNames="PSharp.Comment")]
33+
[Name("PSharp.Comment")]
34+
[UserVisible(true)]
35+
[BaseDefinition(PredefinedClassificationTypeNames.Comment)]
36+
internalreadonlyClassificationTypeDefinitionPSharpCommentFormat;
4937

50-
[Export(typeof(EditorFormatDefinition))]
51-
[ClassificationType(ClassificationTypeNames="PSharp.QuotedString")]
52-
[Name("PSharp.QuotedString")]
53-
[UserVisible(true)]
54-
internalsealedclassPSharpQuotedStringFormat:ClassificationFormatDefinition
55-
{
56-
publicPSharpQuotedStringFormat()
57-
{
58-
this.ForegroundColor=Colors.Brown;
59-
}
38+
[Export]
39+
[ClassificationType(ClassificationTypeNames="PSharp.QuotedString")]
40+
[Name("PSharp.QuotedString")]
41+
[UserVisible(true)]
42+
[BaseDefinition(PredefinedClassificationTypeNames.String)]
43+
internalreadonlyClassificationTypeDefinitionPSharpQuotedStringFormat;
44+
45+
[Export]
46+
[Name(BraceMatchingName)]
47+
[BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)]
48+
internalreadonlyClassificationTypeDefinitionBraceMatching;
49+
50+
51+
internalconststringBraceMatchingName="brace matching";
6052
}
6153
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp