-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial upgrade to FCS 40. * Fix remaining unit tests. * Remove AST workaround for Attributes. * Update for SynTyparDecls, SynPat.As and ParsedHashDirectiveArgument. * Re-enable ignored tests. * Update to FCS 40.0.1-preview.21366.4
- Loading branch information
Showing
19 changed files
with
694 additions
and
681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
module Fantomas.AstExtensions | ||
|
||
open FSharp.Compiler.SyntaxTree | ||
open FSharp.Compiler.Syntax | ||
open FSharp.Compiler.Text | ||
open FSharp.Compiler.Text.Range | ||
|
||
type SynTypeDefnSig with | ||
/// Combines the range of type name and the body. | ||
member this.FullRange: Range = | ||
match this with | ||
| SynTypeDefnSig.TypeDefnSig (comp, _, _, r) -> mkRange r.FileName comp.Range.Start r.End | ||
|
||
let longIdentFullRange (li: LongIdent) : Range = | ||
match li with | ||
| [] -> range.Zero | ||
| h :: _ -> unionRanges h.idRange (List.last li).idRange | ||
|
||
let private hasLinesBetweenAttributesAndFirstNode (attributes: SynAttributes) (firstNodeRange: Range) : Range option = | ||
let fileName = firstNodeRange.FileName | ||
|
||
List.tryLast attributes | ||
|> Option.bind | ||
(fun lastAttribute -> | ||
if lastAttribute.Range.EndLine + 1 < firstNodeRange.StartLine | ||
&& firstNodeRange.Start.Column > 0 then | ||
let pos = | ||
Position.mkPos firstNodeRange.StartLine 0 | ||
|
||
mkRange fileName pos pos |> Some | ||
else | ||
None) | ||
|
||
type SynBinding with | ||
/// Construct an artificial range after the attributes and before the head pattern. | ||
/// This is to detect newline or comment trivia in that exact location. | ||
member this.AfterAttributesBeforeHeadPattern: Range option = | ||
match this with | ||
| SynBinding(attributes = []) -> None | ||
| SynBinding (attributes = attrs; headPat = pat) -> hasLinesBetweenAttributesAndFirstNode attrs pat.Range | ||
|
||
type SynTypeDefn with | ||
member this.AfterAttributesBeforeComponentInfo: Range option = | ||
match this with | ||
| SynTypeDefn(typeInfo = SynComponentInfo(attributes = [])) -> None | ||
| SynTypeDefn(typeInfo = SynComponentInfo (attributes = attrs; range = compRange)) -> | ||
hasLinesBetweenAttributesAndFirstNode attrs compRange | ||
|
||
type SynField with | ||
member this.AfterAttributesBeforeIdentifier: Range option = | ||
match this with | ||
| SynField(attributes = []) -> None | ||
| SynField (attributes = _ :: _; idOpt = None) -> None | ||
| SynField (attributes = attrs; idOpt = Some ident) -> hasLinesBetweenAttributesAndFirstNode attrs ident.idRange |
Oops, something went wrong.