Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make FSAC initialization assume workspacePaths[0] instead of RootPath #1223

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"args": [
"--debug",
"--filter",
"FSAC.lsp.${input:loader}.${input:lsp-server}.${input:testName}"
"FSAC.lsp.${input:loader}.${input:testName}"
]
}
],
Expand All @@ -77,21 +77,10 @@
"default": "WorkspaceLoader",
"type": "pickString"
},

{
"id": "lsp-server",
"description": "The lsp serrver",
"options": [
"FSharpLspServer",
"AdaptiveLspServer"
],
"default": "AdaptiveLspServer",
"type": "pickString"
},
{
"id": "testName",
"description": "the name of the test as provided to `testCase`",
"type": "promptString"
}
]
}
}
48 changes: 30 additions & 18 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "format codebase",
"command": "dotnet",
"args": [
"build",
"-t",
"Format"
],
"detail": "Format all source code using Fantomas",
"type": "shell",
"problemMatcher": []
}
]
}
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "format codebase",
"command": "dotnet",
"args": [
"build",
"-t",
"Format"
],
"detail": "Format all source code using Fantomas",
"type": "shell",
"problemMatcher": []
},
{
"type": "msbuild",
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
},
"label": "Build: FsAutoComplete.fsproj",
"detail": "Build the FsAutoComplete.fsproj project using dotnet build"
}
]
}
6 changes: 0 additions & 6 deletions global.json

This file was deleted.

2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ NUGET
System.Reflection.Metadata (>= 5.0)
Ionide.Analyzers (0.7)
Ionide.KeepAChangelog.Tasks (0.1.8) - copy_local: true
Ionide.LanguageServerProtocol (0.4.20)
Ionide.LanguageServerProtocol (0.4.22)
FSharp.Core (>= 6.0)
Newtonsoft.Json (>= 13.0.1)
StreamJsonRpc (>= 2.16.36)
Expand Down
18 changes: 14 additions & 4 deletions src/FsAutoComplete.Core/KeywordList.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ open FSharp.Compiler.Tokenization
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Symbols

// 44 is the 'This construct is deprecated' error - we've addressed these by moving to TextEdit for the completionItems here,
// but the helper function for the CompletionItem record has to init the field to None, so it's still being counted as used.
#nowarn "44"

module KeywordList =

let keywordDescriptions = FSharpKeywords.KeywordsWithDescription |> dict
Expand Down Expand Up @@ -39,15 +43,21 @@ module KeywordList =
"line", "Indicates the original source code line" ]
|> dict

let hashSymbolCompletionItems =
let private textEdit text pos : U2<TextEdit, _> =
U2.First(
{ Range = { Start = pos; End = pos }
NewText = text }
)

let hashSymbolCompletionItems pos =
hashDirectives
|> Seq.map (fun kv ->
let label = "#" + kv.Key

{ CompletionItem.Create(kv.Key) with
Data = Some(Newtonsoft.Json.Linq.JValue(label))
Kind = Some CompletionItemKind.Keyword
InsertText = Some kv.Key
TextEdit = Some(textEdit kv.Value pos)
FilterText = Some kv.Key
SortText = Some kv.Key
Documentation = Some(Documentation.String kv.Value)
Expand All @@ -57,13 +67,13 @@ module KeywordList =
let allKeywords: string list =
keywordDescriptions |> Seq.map ((|KeyValue|) >> fst) |> Seq.toList

let keywordCompletionItems =
let keywordCompletionItems pos =
allKeywords
|> List.mapi (fun id k ->
{ CompletionItem.Create(k) with
Data = Some(Newtonsoft.Json.Linq.JValue(k))
Kind = Some CompletionItemKind.Keyword
InsertText = Some k
TextEdit = Some(textEdit k pos)
SortText = Some(sprintf "1000000%d" id)
FilterText = Some k
Label = k })
Expand Down
4 changes: 4 additions & 0 deletions src/FsAutoComplete.Logging/FsAutoComplete.Logging.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
<Compile Include="FsOpenTelemetry.fs" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />

<Target Name="Blah" AfterTargets="AfterBuild">
<Warning Message="farts" />
</Target>
</Project>
47 changes: 38 additions & 9 deletions src/FsAutoComplete/LspHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
type FcsPos = FSharp.Compiler.Text.Position
module FcsPos = FSharp.Compiler.Text.Position

#nowarn "44" // We're not using the Deprecated member of DocumentSymbol here, but it's still required to be _set_.

module FcsPos =
let subtractColumn (pos: FcsPos) (column: int) = FcsPos.mkPos pos.Line (pos.Column - column)
Expand Down Expand Up @@ -115,13 +116,13 @@
Data = None
CodeDescription = Some { Href = Some(Uri(urlForCompilerCode error.ErrorNumber)) } }

let getSymbolInformations
let getWorkspaceSymbols
(uri: DocumentUri)
(glyphToSymbolKind: FSharpGlyph -> SymbolKind option)
(topLevel: NavigationTopLevelDeclaration)
(symbolFilter: SymbolInformation -> bool)
: SymbolInformation[] =
let inner (container: string option) (decl: NavigationItem) : SymbolInformation option =
(symbolFilter: WorkspaceSymbol -> bool)
: WorkspaceSymbol[] =

Check notice

Code scanning / Ionide.Analyzers.Cli

Detect if generic type should be in the postfix position. Note

Prefer postfix syntax for arrays.
let inner (container: string option) (decl: NavigationItem) : WorkspaceSymbol option =
// We should nearly always have a kind, if the client doesn't send weird capabilities,
// if we don't why not assume module...
let kind = defaultArg (glyphToSymbolKind decl.Glyph) SymbolKind.Module
Expand All @@ -130,20 +131,48 @@
{ Uri = uri
Range = fcsRangeToLsp decl.Range }

let sym: SymbolInformation =
let sym: WorkspaceSymbol =
{ Name = decl.LogicalName
Kind = kind
Location = location
ContainerName = container
Location = U2.First location
Kind = kind
Tags = None
Deprecated = None }
Data = None }

if symbolFilter sym then Some sym else None

[| yield! inner None topLevel.Declaration |> Option.toArray
yield! topLevel.Nested |> Array.choose (inner (Some topLevel.Declaration.LogicalName)) |]

let applyQuery (query: string) (info: SymbolInformation) =
let getDocumentSymbol
(glyphToSymbolKind: FSharpGlyph -> SymbolKind option)
(topLevelItem: NavigationTopLevelDeclaration)
: DocumentSymbol =
let makeChildDocumentSymbol (item: NavigationItem) : DocumentSymbol =
{ Name = item.LogicalName
Detail = None
Kind = defaultArg (glyphToSymbolKind item.Glyph) SymbolKind.Module
Deprecated = None
Range = fcsRangeToLsp item.Range
SelectionRange = fcsRangeToLsp item.Range
Children = None
Tags = None }

{ Name = topLevelItem.Declaration.LogicalName
// TODO: what Detail actually influences
Detail = None
Kind = defaultArg (glyphToSymbolKind topLevelItem.Declaration.Glyph) SymbolKind.Module
Deprecated = None
// TODO: it would be good if we could get just the 'interesting' part of the Declaration.Range here for the SelectionRange
Range = fcsRangeToLsp topLevelItem.Declaration.Range
SelectionRange = fcsRangeToLsp topLevelItem.Declaration.Range
Children =
match topLevelItem.Nested with
| [||] -> None
| children -> Some(Array.map makeChildDocumentSymbol children)
Tags = None }

let applyQuery (query: string) (info: WorkspaceSymbol) =
match query.Split([| '.' |], StringSplitOptions.RemoveEmptyEntries) with
| [||] -> false
| [| fullName |] -> info.Name.StartsWith(fullName, StringComparison.Ordinal)
Expand Down
13 changes: 9 additions & 4 deletions src/FsAutoComplete/LspHelpers.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ module Conversions =
val urlForCompilerCode: number: int -> string
val fcsErrorToDiagnostic: error: FSharpDiagnostic -> Diagnostic

val getSymbolInformations:
val getWorkspaceSymbols:
uri: DocumentUri ->
glyphToSymbolKind: (FSharpGlyph -> SymbolKind option) ->
topLevel: NavigationTopLevelDeclaration ->
symbolFilter: (SymbolInformation -> bool) ->
SymbolInformation array
symbolFilter: (WorkspaceSymbol -> bool) ->
WorkspaceSymbol array

val applyQuery: query: string -> info: SymbolInformation -> bool
val getDocumentSymbol:
glyphToSymbolKind: (FSharpGlyph -> SymbolKind option) ->
topLevelItem: NavigationTopLevelDeclaration ->
DocumentSymbol

val applyQuery: query: string -> info: WorkspaceSymbol -> bool

val getCodeLensInformation:
uri: DocumentUri -> typ: string -> topLevel: NavigationTopLevelDeclaration -> CodeLens array
Expand Down
Loading
Loading