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

Commitf2748ff

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Better attribute completion (dotnet#2095)
* add FSharpDeclarationListItem.IsAttributetry to handle attributes in a special way at attribute application point (wip)* almost works* suggest all types, modules and namespaces at attribute application position* fix Context.AttributeApplication detection* autocomplete does not remove "Attribute" suffix if an attribute type does not have itfix related tests* do not try to use AstVisitorBase to determine that we are at attribute application position* try to fix tests* fix some tests* cut attribute prefix on editor side* fixed: IsAttribute can throw exceptions which results with empty completion list* fix tests
1 parentee84eb7 commitf2748ff

File tree

12 files changed

+391
-342
lines changed

12 files changed

+391
-342
lines changed

‎src/fsharp/ast.fs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,12 +1063,12 @@ and
10631063
SynBindingKind*
10641064
mustInline:bool*
10651065
isMutable:bool*
1066-
SynAttributes*
1066+
attrs:SynAttributes*
10671067
xmlDoc:PreXmlDoc*
10681068
SynValData*
10691069
headPat:SynPat*
10701070
SynBindingReturnInfo option*
1071-
SynExpr*
1071+
expr:SynExpr*
10721072
range:range*
10731073
SequencePointInfoForBinding
10741074
// no member just named "Range", as that would be confusing:
@@ -1178,7 +1178,7 @@ and
11781178
[<NoEquality; NoComparison>]
11791179
SynEnumCase=
11801180
/// The untyped, unchecked syntax tree for one case in an enum definition.
1181-
| EnumCaseofSynAttributes*ident:Ident*SynConst*PreXmlDoc*range:range
1181+
| EnumCaseofattrs:SynAttributes*ident:Ident*SynConst*PreXmlDoc*range:range
11821182
memberthis.Range=
11831183
match thiswith
11841184
| EnumCase(range=m)-> m
@@ -1234,7 +1234,7 @@ and
12341234
[<NoEquality; NoComparison>]
12351235
/// The untyped, unchecked syntax tree for a field declaration in a record or class
12361236
SynField=
1237-
| FieldofSynAttributes*isStatic:bool*Identoption*SynType*bool*xmlDoc:PreXmlDoc*accessibility:SynAccessoption*range:range
1237+
| Fieldofattrs:SynAttributes*isStatic:bool*Identoption*SynType*bool*xmlDoc:PreXmlDoc*accessibility:SynAccessoption*range:range
12381238

12391239

12401240
and
@@ -1344,7 +1344,7 @@ and
13441344
| InheritofSynType*Identoption*range:range
13451345
| ValFieldofSynField*range:range
13461346
/// A feature that is not implemented
1347-
| NestedTypeofSynTypeDefn*accessibility:SynAccessoption*range:range
1347+
| NestedTypeoftypeDefn:SynTypeDefn*accessibility:SynAccessoption*range:range
13481348
/// SynMemberDefn.AutoProperty (attribs,isStatic,id,tyOpt,propKind,memberFlags,xmlDoc,access,synExpr,mGetSet,mWholeAutoProp).
13491349
///
13501350
/// F# syntax: 'member val X = expr'

‎src/fsharp/vs/ServiceAssemblyContent.fs‎

Lines changed: 3 additions & 281 deletions
Large diffs are not rendered by default.

‎src/fsharp/vs/ServiceDeclarations.fs‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,17 @@ module internal ItemDescriptionsImpl =
705705
|_->
706706
GetXmlCommentForItemAux None infoReader m d
707707

708+
letIsAttribute(infoReader:InfoReader)d=
709+
try
710+
letg= infoReader.g
711+
letamap= infoReader.amap
712+
match dwith
713+
| Item.Types(_,((TType_app(tcref,_))::_))->
714+
letty= generalizedTyconRef tcref
715+
Infos.ExistsHeadTypeInEntireHierarchy g amap range0 ty g.tcref_System_Attribute
716+
|_->false
717+
with_->false
718+
708719
/// Output a the description of a language item
709720
let recFormatItemDescriptionToToolTipElement isDecl(infoReader:InfoReader)m denv d=
710721
letg= infoReader.g
@@ -1168,7 +1179,6 @@ module internal ItemDescriptionsImpl =
11681179

11691180
// Compute the index of the VS glyph shown with an item in the Intellisense menu
11701181
letGlyphOfItem(denv,d)=
1171-
11721182
/// Find the glyph for the given representation.
11731183
letreprToGlyph repr=
11741184
match reprwith
@@ -1255,7 +1265,7 @@ module internal ItemDescriptionsImpl =
12551265

12561266
/// An intellisense declaration
12571267
[<Sealed>]
1258-
typeFSharpDeclarationListItem(name,glyphMajor:GlyphMajor,glyphMinor:GlyphMinor,info)=
1268+
typeFSharpDeclarationListItem(name: string,glyphMajor:GlyphMajor,glyphMinor:GlyphMinor,info,isAttribute: bool)=
12591269
let mutabledescriptionTextHolder:FSharpToolTipText option= None
12601270
let mutabletask=null
12611271

@@ -1302,18 +1312,17 @@ type FSharpDeclarationListItem(name, glyphMajor:GlyphMajor, glyphMinor:GlyphMino
13021312

13031313
memberdecl.Glyph=6* int glyphMajor+ int glyphMinor
13041314
memberdecl.GlyphMajor= glyphMajor
1305-
memberdecl.GlyphMinor= glyphMinor
1315+
memberdecl.GlyphMinor= glyphMinor
1316+
memberdecl.IsAttribute= isAttribute
13061317

13071318
/// A table of declarations for Intellisense completion
13081319
[<Sealed>]
13091320
typeFSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[])=
1310-
13111321
memberself.Items= declarations
13121322

13131323
// Make a 'Declarations' object for a set of selected items
13141324
static memberCreate(infoReader:InfoReader,m,denv,items,reactor,checkAlive)=
13151325
letg= infoReader.g
1316-
13171326
letitems= items|> RemoveExplicitlySuppressed g
13181327

13191328
// Sort by name. For things with the same name,
@@ -1363,11 +1372,11 @@ type FSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[]) =
13631372
|[]-> failwith"Unexpected empty bag"
13641373
| items->
13651374
letglyphMajor,glyphMinor= GlyphOfItem(denv,items.Head)
1366-
new FSharpDeclarationListItem(nm, glyphMajor, glyphMinor, Choice1Of2(items, infoReader, m, denv, reactor, checkAlive)))
1375+
new FSharpDeclarationListItem(nm, glyphMajor, glyphMinor, Choice1Of2(items, infoReader, m, denv, reactor, checkAlive), IsAttribute infoReader items.Head))
13671376

13681377
new FSharpDeclarationListInfo(Array.ofList decls)
1369-
13701378

1371-
static memberError msg=new FSharpDeclarationListInfo([|new FSharpDeclarationListItem("<Note>", GlyphMajor.Error, GlyphMinor.Normal, Choice2Of2(FSharpToolTipText[FSharpToolTipElement.CompositionError msg]))|])
1372-
static memberEmpty=new FSharpDeclarationListInfo([||])
1373-
1379+
static memberError msg=
1380+
new FSharpDeclarationListInfo(
1381+
[|new FSharpDeclarationListItem("<Note>", GlyphMajor.Error, GlyphMinor.Normal, Choice2Of2(FSharpToolTipText[FSharpToolTipElement.CompositionError msg]),false)|])
1382+
static memberEmpty= FSharpDeclarationListInfo([||])

‎src/fsharp/vs/ServiceDeclarations.fsi‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ type internal FSharpDeclarationListItem =
6969
memberGlyph:int
7070
memberGlyphMajor:ItemDescriptionIcons.GlyphMajor
7171
memberGlyphMinor:ItemDescriptionIcons.GlyphMinor
72-
72+
memberIsAttribute:bool
73+
7374
[<Sealed>]
7475
/// Represents a set of declarations in F# source code, with information attached ready for display by an editor.
7576
/// Returned by GetDeclarations.

‎src/fsharp/vs/ServiceParseTreeWalk.fs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,5 +535,4 @@ module internal AstTraversal =
535535
range0// only used for asserting, does not matter in non-debug
536536
#endif
537537
l|> List.map(fun x-> dive x x.Range(traverseSynModuleOrNamespace[]))|> pick fileRange l
538-
| ParsedInput.SigFile_sigFile-> None
539-
538+
| ParsedInput.SigFile_sigFile-> None

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp