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

Commitfed4612

Browse files
committed
Colorize Punctuation
also `<-` as keyword
1 parent6f3f040 commitfed4612

File tree

6 files changed

+52
-26
lines changed

6 files changed

+52
-26
lines changed

‎src/fsharp/PrettyNaming.fs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,19 @@ module internal Microsoft.FSharp.Compiler.PrettyNaming
386386
// by the call to String.forall; it is a fast check used to avoid the call if possible.
387387
||(s.[0]='~'&& String.forall(fun c-> c='~') s)
388388

389+
letIsPunctuation s=
390+
if System.String.IsNullOrEmpty sthenfalseelse
391+
match swith
392+
|","|";"|"|"|":"|"."|"*"
393+
|"("|")"
394+
|"["|"]"
395+
|"{"|"}"
396+
|"<"|">"
397+
|"[|"|"|]"
398+
|"[<"|">]"
399+
->true
400+
|_->false
401+
389402
letIsTernaryOperator s=
390403
(DecompileOpName s= qmarkSet)
391404

‎src/fsharp/vs/ServiceLexing.fs‎

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module FSharpTokenTag =
6868
letCOLON_EQUALS= tagOfToken COLON_EQUALS
6969
letBAR_BAR= tagOfToken BAR_BAR
7070
letRARROW= tagOfToken RARROW
71+
letLARROW= tagOfToken LARROW
7172
letQUOTE= tagOfToken QUOTE
7273

7374

@@ -88,14 +89,15 @@ type FSharpTokenColorKind =
8889
| PreprocessorKeyword=8
8990
| Number=9
9091
| Operator=10
92+
| Punctuation=11
9193

9294
/// Categorize an action the editor should take in response to a token, e.g. brace matching
9395
///
9496
/// NOTE: This corresponds to a token categorization originally used in Visual Studio 2003 and the original Babel source code.
9597
/// It is not clear it is a primary logical classification that should be being used in the
9698
/// more recent language service work.
9799
typeFSharpTokenTriggerClass=
98-
None=0x00000000
100+
| None=0x00000000
99101
| MemberSelect=0x00000001
100102
| MatchBraces=0x00000002
101103
| ChoiceSelect=0x00000004
@@ -111,7 +113,7 @@ type FSharpTokenTriggerClass =
111113
/// It is not clear it is a primary logical classification that should be being used in the
112114
/// more recent language service work.
113115
typeFSharpTokenCharKind=
114-
Default=0x00000000
116+
| Default=0x00000000
115117
| Text=0x00000000
116118
| Keyword=0x00000001
117119
| Identifier=0x00000002
@@ -126,13 +128,13 @@ type FSharpTokenCharKind =
126128

127129
/// Information about a particular token from the tokenizer
128130
typeFSharpTokenInfo={
129-
LeftColumn:int;
130-
RightColumn:int;
131-
ColorClass:FSharpTokenColorKind;
132-
CharClass:FSharpTokenCharKind;
133-
FSharpTokenTriggerClass:FSharpTokenTriggerClass;
131+
LeftColumn:int
132+
RightColumn:int
133+
ColorClass:FSharpTokenColorKind
134+
CharClass:FSharpTokenCharKind
135+
FSharpTokenTriggerClass:FSharpTokenTriggerClass
134136
Tag:int
135-
TokenName:string;
137+
TokenName:string
136138
FullMatchedLength:int}
137139

138140
//----------------------------------------------------------------------------
@@ -181,9 +183,11 @@ module internal TokenClassifications =
181183
| PERCENT_OP_| PLUS_MINUS_OP_| PREFIX_OP_| COLON_QMARK_GREATER
182184
| AMP| AMP_AMP| BAR_BAR| QMARK| QMARK_QMARK| COLON_QMARK
183185
| QUOTE| STAR| HIGH_PRECEDENCE_TYAPP
184-
|COLON|COLON_EQUALS| LARROW| EQUALS| RQUOTE_DOT_
186+
| COLON_EQUALS| EQUALS| RQUOTE_DOT_
185187
| MINUS| ADJACENT_PREFIX_OP_
186188
->(FSharpTokenColorKind.Operator,FSharpTokenCharKind.Operator,FSharpTokenTriggerClass.None)
189+
| COLON
190+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.None)
187191

188192
| INFIX_COMPARE_OP_// This is a whole family: .< .> .= .!= .$
189193
| FUNKY_OPERATOR_NAME_// This is another whole family, including: .[] and .()
@@ -200,17 +204,18 @@ module internal TokenClassifications =
200204
(FSharpTokenColorKind.Operator,FSharpTokenCharKind.Operator,FSharpTokenTriggerClass.MemberSelect)
201205

202206
| COMMA
203-
->(FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.ParamNext)
207+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.ParamNext)
204208

205209
| DOT
206210
->(FSharpTokenColorKind.Operator,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.MemberSelect)
207211

208212
| BAR
209-
->(FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.None(* FSharpTokenTriggerClass.ChoiceSelect*))
210-
211-
| HASH| UNDERSCORE
213+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.None(* FSharpTokenTriggerClass.ChoiceSelect*))
214+
| HASH
212215
| SEMICOLON| SEMICOLON_SEMICOLON
213-
->(FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.None)
216+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.None)
217+
| UNDERSCORE
218+
->(FSharpTokenColorKind.Identifier,FSharpTokenCharKind.Identifier,FSharpTokenTriggerClass.None)
214219

215220
| LESS_
216221
->(FSharpTokenColorKind.Operator,FSharpTokenCharKind.Operator,FSharpTokenTriggerClass.ParamStart)// for type provider static arguments
@@ -220,28 +225,28 @@ module internal TokenClassifications =
220225
| LPAREN
221226
// We need 'ParamStart' to trigger the 'GetDeclarations' method to show param info automatically
222227
// this is needed even if we don't use MPF for determining information about params
223-
->(FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.ParamStart||| FSharpTokenTriggerClass.MatchBraces)
228+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.ParamStart||| FSharpTokenTriggerClass.MatchBraces)
224229

225230
| RPAREN| RPAREN_COMING_SOON| RPAREN_IS_HERE
226-
->(FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.ParamEnd||| FSharpTokenTriggerClass.MatchBraces)
231+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.ParamEnd||| FSharpTokenTriggerClass.MatchBraces)
227232

228233
| LBRACK_LESS| LBRACE_LESS
229-
->(FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.None)
234+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.None)
230235

231236
| LQUOTE_| LBRACK| LBRACE| LBRACK_BAR
232-
->(FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.MatchBraces)
237+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.MatchBraces)
233238

234239
| GREATER_RBRACE| GREATER_RBRACK| GREATER_BAR_RBRACK
235-
->(FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.None)
240+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.None)
236241

237242
| RQUOTE_| RBRACK| RBRACE| RBRACE_COMING_SOON| RBRACE_IS_HERE| BAR_RBRACK
238-
->(FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.MatchBraces)
243+
->(FSharpTokenColorKind.Punctuation,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.MatchBraces)
239244

240245
| PUBLIC| PRIVATE| INTERNAL| BASE| GLOBAL
241246
| CONSTRAINT| INSTANCE| DELEGATE| INHERIT|CONSTRUCTOR|DEFAULT|OVERRIDE|ABSTRACT|CLASS
242247
| MEMBER| STATIC| NAMESPACE
243248
| OASSERT| OLAZY| ODECLEND| OBLOCKSEP| OEND| OBLOCKBEGIN| ORIGHT_BLOCK_END| OBLOCKEND| OBLOCKEND_COMING_SOON| OBLOCKEND_IS_HERE| OTHEN| OELSE| OLET(_)| OBINDER_| BINDER_| ODO| OWITH| OFUNCTION| OFUN| ORESET| ODUMMY_| DO_BANG| ODO_BANG| YIELD_| YIELD_BANG_| OINTERFACE_MEMBER
244-
| ELIF| RARROW| SIG| STRUCT
249+
| ELIF| RARROW|LARROW|SIG| STRUCT
245250
| UPCAST| DOWNCAST| NULL| RESERVED| MODULE| AND| AS| ASSERT| ASR
246251
| DOWNTO| EXCEPTION| FALSE| FOR| FUN| FUNCTION
247252
| FINALLY| LAZY| MATCH| MUTABLE| NEW| OF| OPEN| OR| VOID| EXTERN

‎src/fsharp/vs/ServiceLexing.fsi‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type internal FSharpTokenColorKind =
5252
| PreprocessorKeyword=8
5353
| Number=9
5454
| Operator=10
55+
| Punctuation=11
5556

5657
/// Gives an indication of what should happen when the token is typed in an IDE
5758
typeinternalFSharpTokenTriggerClass=
@@ -166,6 +167,8 @@ module internal FSharpTokenTag =
166167
valBAR_BAR:int
167168
/// Indicates the token is a `->`
168169
valRARROW:int
170+
/// Indicates the token is a `<-`
171+
valLARROW:int
169172
/// Indicates the token is a `"`
170173
valQUOTE:int
171174

‎src/fsharp/vs/service.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ type TypeCheckInfo
11401140
items
11411141

11421142

1143-
static letkeywordTypes= Lexhelp.Keywords.keywordTypes
1143+
//static let keywordTypes = Lexhelp.Keywords.keywordTypes
11441144

11451145
memberx.IsRelativeNameResolvable(cursorPos:pos,plid:string list,item:Item):bool=
11461146
/// Determines if a long ident is resolvable at a specific point.
@@ -1483,8 +1483,8 @@ type TypeCheckInfo
14831483
| CNR(_,(Item.CustomBuilder_| Item.CustomOperation_), ItemOccurence.Use,_,_,_, m)->
14841484
Some(m, SemanticClassificationType.ComputationExpression)
14851485
// well known type aliases get colored as keywords
1486-
| CNR(_,(Item.Types(n,_)),_,_,_,_, m)when keywordTypes.Contains(n)->
1487-
Some(m, SemanticClassificationType.IntrinsicType)
1486+
//| CNR(_, (Item.Types (n, _)), _, _, _, _, m) when keywordTypes.Contains(n) ->
1487+
// Some (m, SemanticClassificationType.IntrinsicType)
14881488
// types get colored as types when they occur in syntactic types or custom attributes
14891489
// typevariables get colored as types when they occur in syntactic types custom builders, custom operations get colored as keywords
14901490
| CNR(_, Item.Types(_,[OptionalArgumentAttribute]), LegitTypeOccurence,_,_,_,_)-> None

‎vsintegration/src/FSharp.Editor/Common/CommonHelpers.fs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ open Microsoft.FSharp.Compiler.SourceCodeServices.ItemDescriptionIcons
2222
typeinternalLexerSymbolKind=
2323
| Ident
2424
| Operator
25+
| Punctuation
2526
| GenericTypeParameter
2627
| StaticallyResolvedTypeParameter
2728
| Other
@@ -87,8 +88,8 @@ module internal CommonHelpers =
8788
| FSharpTokenColorKind.InactiveCode-> ClassificationTypeNames.ExcludedCode
8889
| FSharpTokenColorKind.PreprocessorKeyword-> ClassificationTypeNames.PreprocessorKeyword
8990
| FSharpTokenColorKind.Operator-> ClassificationTypeNames.Operator
90-
| FSharpTokenColorKind.Default
91-
|_-> ClassificationTypeNames.Text
91+
| FSharpTokenColorKind.Punctuation-> ClassificationTypeNames.Punctuation
92+
|FSharpTokenColorKind.Default|_-> ClassificationTypeNames.Text
9293

9394
letprivatescanSourceLine(sourceTokenizer:FSharpSourceTokenizer,textLine:TextLine,lineContents:string,lexState:FSharpTokenizerLexState):SourceLineData=
9495
letcolorMap= Array.create textLine.Span.Length ClassificationTypeNames.Text
@@ -197,6 +198,7 @@ module internal CommonHelpers =
197198
letprivategetSymbolFromTokens(fileName:string,tokens:FSharpTokenInfo list,linePos:LinePosition,lineStr:string,lookupKind:SymbolLookupKind):LexerSymbol option=
198199
letisIdentifier t= t.CharClass= FSharpTokenCharKind.Identifier
199200
letisOperator t= t.ColorClass= FSharpTokenColorKind.Operator
201+
letisPunctuation t= t.ColorClass= FSharpTokenColorKind.Punctuation
200202

201203
let inline(|GenericTypeParameterPrefix|StaticallyResolvedTypeParameterPrefix|Other|)(token:FSharpTokenInfo)=
202204
if token.Tag= FSharpTokenTag.QUOTEthen GenericTypeParameterPrefix
@@ -243,6 +245,7 @@ module internal CommonHelpers =
243245
letkind=
244246
if isOperator tokenthen LexerSymbolKind.Operator
245247
elif isIdentifier tokenthen LexerSymbolKind.Ident
248+
elif isPunctuation tokenthen LexerSymbolKind.Punctuation
246249
else LexerSymbolKind.Other
247250

248251
DraftToken.Create kind token
@@ -384,6 +387,7 @@ module internal CommonHelpers =
384387
// Different from union cases, active patterns don't accept double-backtick identifiers
385388
isFixableIdentifier name&&not(String.IsNullOrEmpty name)&& Char.IsUpper(name.[0])
386389
| LexerSymbolKind.Operator,_-> PrettyNaming.IsOperatorName name
390+
| LexerSymbolKind.Punctuation,_-> PrettyNaming.IsPunctuation name
387391
| LexerSymbolKind.GenericTypeParameter,_-> isGenericTypeParameter name
388392
| LexerSymbolKind.StaticallyResolvedTypeParameter,_-> isStaticallyResolvedTypeParameter name
389393
|(LexerSymbolKind.Ident| LexerSymbolKind.Other),_->

‎vsintegration/src/FSharp.Editor/Common/CommonRoslynHelpers.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module internal CommonRoslynHelpers =
4545
Assert.Exception(task.Exception.GetBaseException())
4646
raise(task.Exception.GetBaseException())
4747

48+
/// Converts `TaggedText` from the F# Compiler to `Microsoft.CodeAnalysis.TaggedText` format for use in tooltips
4849
letTaggedTextToRoslyn t=
4950
match twith
5051
| TaggedText.ActivePatternCase t

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp