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

Graph typechecking issue fix when using global namespace. #17553

Merged
merged 15 commits into from
Aug 19, 2024
Merged
Prev Previous commit
Next Next commit
Skip the global namespace when transforming longident to path
  • Loading branch information
vzarytovskii committed Aug 19, 2024
commit ba9153a91ffa7a6cb0c98fff50abf09f70c1c932
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ let rec processStateEntry (trie: TrieNode) (state: FileContentQueryState) (entry
FoundDependencies = foundDependencies
}

| ModuleName name ->
| FileContentEntry.ModuleName name ->
// We need to check if the module name is a hit in the Trie.
let state' =
let queryResult = queryTrie trie [ name ]
10 changes: 7 additions & 3 deletions src/Compiler/Driver/GraphChecking/FileContentMapping.fs
Original file line number Diff line number Diff line change
@@ -8,10 +8,14 @@ type Continuations = ((FileContentEntry list -> FileContentEntry list) -> FileCo
/// Collect a list of 'U from option 'T via a mapping function.
let collectFromOption (mapping: 'T -> 'U list) (t: 'T option) : 'U list = List.collect mapping (Option.toList t)

let longIdentToPath (skipLast: bool) (longId: LongIdent) : LongIdentifier =
let rec longIdentToPath (skipLast: bool) (longId: LongIdent) : LongIdentifier =
match skipLast, longId with
| true, _ :: _ -> List.take (longId.Length - 1) longId
| _ -> longId
| true, h :: t when h.idText = "`global`" ->
List.take (t.Length - 1) t
| true, _ :: _ ->
List.take (longId.Length - 1) longId
| _ ->
longId
|> List.map (fun ident -> ident.idText)

let synLongIdentToPath (skipLast: bool) (synLongIdent: SynLongIdent) =
1 change: 1 addition & 0 deletions src/Compiler/Driver/GraphChecking/Types.fs
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ type internal TrieNode =

/// A significant construct found in the syntax tree of a file.
/// This construct needs to be processed in order to deduce potential links to other files in the project.
[<RequireQualifiedAccess; NoComparison; NoEquality>]
type internal FileContentEntry =
/// Any toplevel namespace a file might have.
/// In case a file has `module X.Y.Z`, then `X.Y` is considered to be the toplevel namespace
1 change: 1 addition & 0 deletions src/Compiler/Driver/GraphChecking/Types.fsi
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ type internal TrieNode =

/// A significant construct found in the syntax tree of a file.
/// This construct needs to be processed in order to deduce potential links to other files in the project.
[<RequireQualifiedAccess; NoComparison; NoEquality>]
type internal FileContentEntry =
/// Any toplevel namespace a file might have.
/// In case a file has `module X.Y.Z`, then `X.Y` is considered to be the toplevel namespace
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ let private nestedModule name content =

let private prefIdent (lid: string) =
let parts = lid.Split(".")
Array.take (parts.Length - 1) parts |> List.ofArray |> PrefixedIdentifier
Array.take (parts.Length - 1) parts |> List.ofArray |> FileContentEntry.PrefixedIdentifier

// Some hardcoded files that reflect the file content of the first files in the Fantomas.Core project.
// See https://github.com/fsprojects/fantomas/tree/0938a3daabec80a22d2e17f82aba38456bb793df/src/Fantomas.Core
Loading