diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index 325b5531ea6..78131431041 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -560,6 +560,8 @@ type TcConfigBuilder = /// If true - every expression in quotations will be augmented with full debug info (fileName, location in file) mutable emitDebugInfoInQuotations: bool + mutable strictIndentation: bool option + mutable exename: string option // If true - the compiler will copy FSharp.Core.dll along the produced binaries @@ -815,6 +817,7 @@ type TcConfigBuilder = DumpGraph = false } dumpSignatureData = false + strictIndentation = None } member tcConfigB.FxResolver = @@ -1215,6 +1218,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = member _.bufferWidth = data.bufferWidth member _.fsiMultiAssemblyEmit = data.fsiMultiAssemblyEmit member _.FxResolver = data.FxResolver + member _.strictIndentation = data.strictIndentation member _.primaryAssembly = data.primaryAssembly member _.noFeedback = data.noFeedback member _.stackReserveSize = data.stackReserveSize diff --git a/src/Compiler/Driver/CompilerConfig.fsi b/src/Compiler/Driver/CompilerConfig.fsi index 234c2594197..f59950f9e28 100644 --- a/src/Compiler/Driver/CompilerConfig.fsi +++ b/src/Compiler/Driver/CompilerConfig.fsi @@ -471,6 +471,8 @@ type TcConfigBuilder = mutable emitDebugInfoInQuotations: bool + mutable strictIndentation: bool option + mutable exename: string option mutable copyFSharpCore: CopyFSharpCoreFlag @@ -808,6 +810,8 @@ type TcConfig = member FxResolver: FxResolver + member strictIndentation: bool option + member ComputeIndentationAwareSyntaxInitialStatus: string -> bool member GetTargetFrameworkDirectories: unit -> string list diff --git a/src/Compiler/Driver/CompilerOptions.fs b/src/Compiler/Driver/CompilerOptions.fs index ffaa016ba22..56e788ae95e 100644 --- a/src/Compiler/Driver/CompilerOptions.fs +++ b/src/Compiler/Driver/CompilerOptions.fs @@ -1142,8 +1142,18 @@ let languageFlags tcConfigB = None, Some(FSComp.SR.optsChecked ()) ) + CompilerOption("define", tagString, OptionString(defineSymbol tcConfigB), None, Some(FSComp.SR.optsDefine ())) + mlCompatibilityFlag tcConfigB + + CompilerOption( + "strict-indentation", + tagNone, + OptionSwitch(fun switch -> tcConfigB.strictIndentation <- Some(switch = OptionSwitch.On)), + None, + Some(FSComp.SR.optsStrictIndentation ()) + ) ] // OptionBlock: Advanced user options @@ -1332,7 +1342,6 @@ let advancedFlagsFsc tcConfigB = None, Some(FSComp.SR.optsEmitDebugInfoInQuotations ()) ) - ] // OptionBlock: Internal options (test use only) diff --git a/src/Compiler/Driver/ParseAndCheckInputs.fs b/src/Compiler/Driver/ParseAndCheckInputs.fs index a731cc2e05a..8525b1bfd3c 100644 --- a/src/Compiler/Driver/ParseAndCheckInputs.fs +++ b/src/Compiler/Driver/ParseAndCheckInputs.fs @@ -710,7 +710,7 @@ let parseInputStreamAux // Set up the LexBuffer for the file let lexbuf = - UnicodeLexing.StreamReaderAsLexbuf(not tcConfig.compilingFSharpCore, tcConfig.langVersion, reader) + UnicodeLexing.StreamReaderAsLexbuf(not tcConfig.compilingFSharpCore, tcConfig.langVersion, tcConfig.strictIndentation, reader) // Parse the file drawing tokens from the lexbuf ParseOneInputLexbuf(tcConfig, lexResourceManager, lexbuf, fileName, isLastCompiland, diagnosticsLogger) @@ -726,7 +726,7 @@ let parseInputSourceTextAux ) = // Set up the LexBuffer for the file let lexbuf = - UnicodeLexing.SourceTextAsLexbuf(not tcConfig.compilingFSharpCore, tcConfig.langVersion, sourceText) + UnicodeLexing.SourceTextAsLexbuf(not tcConfig.compilingFSharpCore, tcConfig.langVersion, tcConfig.strictIndentation, sourceText) // Parse the file drawing tokens from the lexbuf ParseOneInputLexbuf(tcConfig, lexResourceManager, lexbuf, fileName, isLastCompiland, diagnosticsLogger) @@ -738,7 +738,7 @@ let parseInputFileAux (tcConfig: TcConfig, lexResourceManager, fileName, isLastC // Set up the LexBuffer for the file let lexbuf = - UnicodeLexing.StreamReaderAsLexbuf(not tcConfig.compilingFSharpCore, tcConfig.langVersion, reader) + UnicodeLexing.StreamReaderAsLexbuf(not tcConfig.compilingFSharpCore, tcConfig.langVersion, tcConfig.strictIndentation, reader) // Parse the file drawing tokens from the lexbuf ParseOneInputLexbuf(tcConfig, lexResourceManager, lexbuf, fileName, isLastCompiland, diagnosticsLogger) diff --git a/src/Compiler/Driver/ScriptClosure.fs b/src/Compiler/Driver/ScriptClosure.fs index 00d38e1f234..83af161b353 100644 --- a/src/Compiler/Driver/ScriptClosure.fs +++ b/src/Compiler/Driver/ScriptClosure.fs @@ -135,7 +135,7 @@ module ScriptPreprocessClosure = let tcConfig = TcConfig.Create(tcConfigB, false) let lexbuf = - UnicodeLexing.SourceTextAsLexbuf(true, tcConfig.langVersion, sourceText) + UnicodeLexing.SourceTextAsLexbuf(true, tcConfig.langVersion, tcConfig.strictIndentation, sourceText) // The root compiland is last in the list of compilands. let isLastCompiland = (IsScript fileName, tcConfig.target.IsExe) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 8e49696ba72..9962c04abd4 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1531,6 +1531,7 @@ useSdkRefs,"Use reference assemblies for .NET framework references when availabl optsGetLangVersions,"Display the allowed values for language version." optsSetLangVersion,"Specify language version such as 'latest' or 'preview'." optsSupportedLangVersions,"Supported language versions:" +optsStrictIndentation,"Override indentation rules implied by the language version" nativeResourceFormatError,"Stream does not begin with a null resource and is not in '.RES' format." nativeResourceHeaderMalformed,"Resource header beginning at offset %s is malformed." formatDashItem," - %s" diff --git a/src/Compiler/Facilities/prim-lexing.fs b/src/Compiler/Facilities/prim-lexing.fs index af9816b8d22..785b7fbdf6f 100644 --- a/src/Compiler/Facilities/prim-lexing.fs +++ b/src/Compiler/Facilities/prim-lexing.fs @@ -162,7 +162,13 @@ type internal Position = type internal LexBufferFiller<'Char> = LexBuffer<'Char> -> unit -and [] internal LexBuffer<'Char>(filler: LexBufferFiller<'Char>, reportLibraryOnlyFeatures: bool, langVersion: LanguageVersion) = +and [] internal LexBuffer<'Char> + ( + filler: LexBufferFiller<'Char>, + reportLibraryOnlyFeatures: bool, + langVersion: LanguageVersion, + strictIndentation: bool option + ) = let context = Dictionary(1) let mutable buffer = [||] /// number of valid characters beyond bufferScanStart. @@ -263,10 +269,18 @@ and [] internal LexBuffer<'Char>(filler: LexBufferFiller<'Char>, reportL member _.SupportsFeature featureId = langVersion.SupportsFeature featureId + member _.StrictIndentation = strictIndentation + member _.CheckLanguageFeatureAndRecover featureId range = FSharp.Compiler.DiagnosticsLogger.checkLanguageFeatureAndRecover langVersion featureId range - static member FromFunction(reportLibraryOnlyFeatures, langVersion, f: 'Char[] * int * int -> int) : LexBuffer<'Char> = + static member FromFunction + ( + reportLibraryOnlyFeatures, + langVersion, + strictIndentation, + f: 'Char[] * int * int -> int + ) : LexBuffer<'Char> = let extension = Array.zeroCreate 4096 let filler (lexBuffer: LexBuffer<'Char>) = @@ -275,32 +289,33 @@ and [] internal LexBuffer<'Char>(filler: LexBufferFiller<'Char>, reportL Array.blit extension 0 lexBuffer.Buffer lexBuffer.BufferScanPos n lexBuffer.BufferMaxScanLength <- lexBuffer.BufferScanLength + n - new LexBuffer<'Char>(filler, reportLibraryOnlyFeatures, langVersion) + new LexBuffer<'Char>(filler, reportLibraryOnlyFeatures, langVersion, strictIndentation) // Important: This method takes ownership of the array - static member FromArrayNoCopy(reportLibraryOnlyFeatures, langVersion, buffer: 'Char[]) : LexBuffer<'Char> = + static member FromArrayNoCopy(reportLibraryOnlyFeatures, langVersion, strictIndentation, buffer: 'Char[]) : LexBuffer<'Char> = let lexBuffer = - new LexBuffer<'Char>((fun _ -> ()), reportLibraryOnlyFeatures, langVersion) + new LexBuffer<'Char>((fun _ -> ()), reportLibraryOnlyFeatures, langVersion, strictIndentation) lexBuffer.Buffer <- buffer lexBuffer.BufferMaxScanLength <- buffer.Length lexBuffer // Important: this method does copy the array - static member FromArray(reportLibraryOnlyFeatures, langVersion, s: 'Char[]) : LexBuffer<'Char> = + static member FromArray(reportLibraryOnlyFeatures, langVersion, strictIndentation, s: 'Char[]) : LexBuffer<'Char> = let buffer = Array.copy s - LexBuffer<'Char>.FromArrayNoCopy (reportLibraryOnlyFeatures, langVersion, buffer) + LexBuffer<'Char>.FromArrayNoCopy (reportLibraryOnlyFeatures, langVersion, strictIndentation, buffer) // Important: This method takes ownership of the array - static member FromChars(reportLibraryOnlyFeatures, langVersion, arr: char[]) = - LexBuffer.FromArrayNoCopy(reportLibraryOnlyFeatures, langVersion, arr) + static member FromChars(reportLibraryOnlyFeatures, langVersion, strictIndentation, arr: char[]) = + LexBuffer.FromArrayNoCopy(reportLibraryOnlyFeatures, langVersion, strictIndentation, arr) - static member FromSourceText(reportLibraryOnlyFeatures, langVersion, sourceText: ISourceText) = + static member FromSourceText(reportLibraryOnlyFeatures, langVersion, strictIndentation, sourceText: ISourceText) = let mutable currentSourceIndex = 0 LexBuffer.FromFunction (reportLibraryOnlyFeatures, langVersion, + strictIndentation, fun (chars, start, length) -> let lengthToCopy = if currentSourceIndex + length <= sourceText.Length then diff --git a/src/Compiler/Facilities/prim-lexing.fsi b/src/Compiler/Facilities/prim-lexing.fsi index e662c1edf37..a7c919991d3 100644 --- a/src/Compiler/Facilities/prim-lexing.fsi +++ b/src/Compiler/Facilities/prim-lexing.fsi @@ -133,21 +133,29 @@ type internal LexBuffer<'Char> = /// True if the specified language feature is supported. member SupportsFeature: LanguageFeature -> bool + member StrictIndentation: bool option + /// Logs a recoverable error if a language feature is unsupported, at the specified range. member CheckLanguageFeatureAndRecover: LanguageFeature -> range -> unit /// Create a lex buffer suitable for Unicode lexing that reads characters from the given array. /// Important: does take ownership of the array. - static member FromChars: reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * char[] -> LexBuffer + static member FromChars: + reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * strictIndentation: bool option * char[] -> + LexBuffer /// Create a lex buffer that reads character or byte inputs by using the given function. static member FromFunction: - reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * ('Char[] * int * int -> int) -> + reportLibraryOnlyFeatures: bool * + langVersion: LanguageVersion * + strictIndentation: bool option * + ('Char[] * int * int -> int) -> LexBuffer<'Char> /// Create a lex buffer backed by source text. static member FromSourceText: - reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * ISourceText -> LexBuffer + reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * strictIndentation: bool option * ISourceText -> + LexBuffer /// The type of tables for an unicode lexer generated by fslex.exe. [] diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 4457ac3142d..f88e7365015 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -3512,6 +3512,7 @@ type FsiStdinLexerProvider UnicodeLexing.FunctionAsLexbuf( true, tcConfigB.langVersion, + tcConfigB.strictIndentation, (fun (buf: char[], start, len) -> //fprintf fsiConsoleOutput.Out "Calling ReadLine\n" let inputOption = @@ -3604,12 +3605,16 @@ type FsiStdinLexerProvider // Create a new lexer to read an "included" script file member _.CreateIncludedScriptLexer(sourceFileName, reader, diagnosticsLogger) = - let lexbuf = UnicodeLexing.StreamReaderAsLexbuf(true, tcConfigB.langVersion, reader) + let lexbuf = + UnicodeLexing.StreamReaderAsLexbuf(true, tcConfigB.langVersion, tcConfigB.strictIndentation, reader) + CreateLexerForLexBuffer(sourceFileName, lexbuf, diagnosticsLogger) // Create a new lexer to read a string member _.CreateStringLexer(sourceFileName, source, diagnosticsLogger) = - let lexbuf = UnicodeLexing.StringAsLexbuf(true, tcConfigB.langVersion, source) + let lexbuf = + UnicodeLexing.StringAsLexbuf(true, tcConfigB.langVersion, tcConfigB.strictIndentation, source) + CreateLexerForLexBuffer(sourceFileName, lexbuf, diagnosticsLogger) member _.ConsoleInput = fsiConsoleInput @@ -4224,7 +4229,9 @@ type FsiInteractionProcessor use _ = UseBuildPhase BuildPhase.Interactive use _ = UseDiagnosticsLogger diagnosticsLogger use _scope = SetCurrentUICultureForThread fsiOptions.FsiLCID - let lexbuf = UnicodeLexing.StringAsLexbuf(true, tcConfigB.langVersion, sourceText) + + let lexbuf = + UnicodeLexing.StringAsLexbuf(true, tcConfigB.langVersion, tcConfigB.strictIndentation, sourceText) let tokenizer = fsiStdinLexerProvider.CreateBufferLexer(scriptFileName, lexbuf, diagnosticsLogger) @@ -4244,7 +4251,9 @@ type FsiInteractionProcessor use _unwind1 = UseBuildPhase BuildPhase.Interactive use _unwind2 = UseDiagnosticsLogger diagnosticsLogger use _scope = SetCurrentUICultureForThread fsiOptions.FsiLCID - let lexbuf = UnicodeLexing.StringAsLexbuf(true, tcConfigB.langVersion, sourceText) + + let lexbuf = + UnicodeLexing.StringAsLexbuf(true, tcConfigB.langVersion, tcConfigB.strictIndentation, sourceText) let tokenizer = fsiStdinLexerProvider.CreateBufferLexer(scriptFileName, lexbuf, diagnosticsLogger) diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 311b5a82f66..f29cf95d3dc 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -2170,6 +2170,7 @@ type FSharpParsingOptions = LangVersionText: string IsInteractive: bool IndentationAwareSyntax: bool option + StrictIndentation: bool option CompilingFSharpCore: bool IsExe: bool } @@ -2187,6 +2188,7 @@ type FSharpParsingOptions = LangVersionText = LanguageVersion.Default.VersionText IsInteractive = false IndentationAwareSyntax = None + StrictIndentation = None CompilingFSharpCore = false IsExe = false } @@ -2200,6 +2202,7 @@ type FSharpParsingOptions = LangVersionText = tcConfig.langVersion.VersionText IsInteractive = isInteractive IndentationAwareSyntax = tcConfig.indentationAwareSyntax + StrictIndentation = tcConfig.strictIndentation CompilingFSharpCore = tcConfig.compilingFSharpCore IsExe = tcConfig.target.IsExe } @@ -2213,6 +2216,7 @@ type FSharpParsingOptions = LangVersionText = tcConfigB.langVersion.VersionText IsInteractive = isInteractive IndentationAwareSyntax = tcConfigB.indentationAwareSyntax + StrictIndentation = tcConfigB.strictIndentation CompilingFSharpCore = tcConfigB.compilingFSharpCore IsExe = tcConfigB.target.IsExe } @@ -2341,8 +2345,8 @@ module internal ParseAndCheckFile = (fun _ -> tokenizer.GetToken()) - let createLexbuf langVersion sourceText = - UnicodeLexing.SourceTextAsLexbuf(true, LanguageVersion(langVersion), sourceText) + let createLexbuf langVersion strictIndentation sourceText = + UnicodeLexing.SourceTextAsLexbuf(true, LanguageVersion(langVersion), strictIndentation, sourceText) let matchBraces (sourceText: ISourceText, fileName, options: FSharpParsingOptions, userOpName: string, suggestNamesForErrors: bool) = // Make sure there is an DiagnosticsLogger installed whenever we do stuff that might record errors, even if we ultimately ignore the errors @@ -2354,7 +2358,7 @@ module internal ParseAndCheckFile = let matchingBraces = ResizeArray<_>() - usingLexbufForParsing (createLexbuf options.LangVersionText sourceText, fileName) (fun lexbuf -> + usingLexbufForParsing (createLexbuf options.LangVersionText options.StrictIndentation sourceText, fileName) (fun lexbuf -> let errHandler = DiagnosticsHandler(false, fileName, options.DiagnosticOptions, sourceText, suggestNamesForErrors, false) @@ -2466,7 +2470,7 @@ module internal ParseAndCheckFile = use _ = UseBuildPhase BuildPhase.Parse let parseResult = - usingLexbufForParsing (createLexbuf options.LangVersionText sourceText, fileName) (fun lexbuf -> + usingLexbufForParsing (createLexbuf options.LangVersionText options.StrictIndentation sourceText, fileName) (fun lexbuf -> let lexfun = createLexerFunction fileName options lexbuf errHandler diff --git a/src/Compiler/Service/FSharpCheckerResults.fsi b/src/Compiler/Service/FSharpCheckerResults.fsi index 81d50d90b78..a42f795895a 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fsi +++ b/src/Compiler/Service/FSharpCheckerResults.fsi @@ -220,6 +220,8 @@ type public FSharpParsingOptions = IndentationAwareSyntax: bool option + StrictIndentation: bool option + CompilingFSharpCore: bool IsExe: bool diff --git a/src/Compiler/Service/ServiceLexing.fs b/src/Compiler/Service/ServiceLexing.fs index f85b3231e3d..75c9b8b1240 100644 --- a/src/Compiler/Service/ServiceLexing.fs +++ b/src/Compiler/Service/ServiceLexing.fs @@ -1214,7 +1214,13 @@ type FSharpLineTokenizer(lexbuf: UnicodeLexing.Lexbuf, maxLength: int option, fi } [] -type FSharpSourceTokenizer(conditionalDefines: string list, fileName: string option, langVersion: string option) = +type FSharpSourceTokenizer + ( + conditionalDefines: string list, + fileName: string option, + langVersion: string option, + strictIndentation: bool option + ) = let langVersion = langVersion @@ -1241,13 +1247,13 @@ type FSharpSourceTokenizer(conditionalDefines: string list, fileName: string opt member _.CreateLineTokenizer(lineText: string) = let lexbuf = - UnicodeLexing.StringAsLexbuf(reportLibraryOnlyFeatures, langVersion, lineText) + UnicodeLexing.StringAsLexbuf(reportLibraryOnlyFeatures, langVersion, strictIndentation, lineText) FSharpLineTokenizer(lexbuf, Some lineText.Length, fileName, lexargs) member _.CreateBufferTokenizer bufferFiller = let lexbuf = - UnicodeLexing.FunctionAsLexbuf(reportLibraryOnlyFeatures, langVersion, bufferFiller) + UnicodeLexing.FunctionAsLexbuf(reportLibraryOnlyFeatures, langVersion, strictIndentation, bufferFiller) FSharpLineTokenizer(lexbuf, None, fileName, lexargs) @@ -1837,6 +1843,7 @@ module FSharpLexerImpl = (flags: FSharpLexerFlags) reportLibraryOnlyFeatures langVersion + strictIndentation diagnosticsLogger onToken pathMap @@ -1858,7 +1865,7 @@ module FSharpLexerImpl = (flags &&& FSharpLexerFlags.UseLexFilter) = FSharpLexerFlags.UseLexFilter let lexbuf = - UnicodeLexing.SourceTextAsLexbuf(reportLibraryOnlyFeatures, langVersion, text) + UnicodeLexing.SourceTextAsLexbuf(reportLibraryOnlyFeatures, langVersion, strictIndentation, text) let indentationSyntaxStatus = IndentationAwareSyntaxStatus(isLightSyntaxOn, true) let applyLineDirectives = isCompiling @@ -1894,7 +1901,7 @@ module FSharpLexerImpl = ct.ThrowIfCancellationRequested() onToken (getNextToken lexbuf) lexbuf.LexemeRange - let lex text conditionalDefines flags reportLibraryOnlyFeatures langVersion lexCallback pathMap ct = + let lex text conditionalDefines flags reportLibraryOnlyFeatures langVersion strictIndentation lexCallback pathMap ct = let diagnosticsLogger = CompilationDiagnosticLogger("Lexer", FSharpDiagnosticOptions.Default) @@ -1904,6 +1911,7 @@ module FSharpLexerImpl = flags reportLibraryOnlyFeatures langVersion + strictIndentation diagnosticsLogger lexCallback pathMap @@ -1912,7 +1920,18 @@ module FSharpLexerImpl = [] type FSharpLexer = - static member Tokenize(text: ISourceText, tokenCallback, ?langVersion, ?filePath: string, ?conditionalDefines, ?flags, ?pathMap, ?ct) = + static member Tokenize + ( + text: ISourceText, + tokenCallback, + ?langVersion, + ?strictIndentation, + ?filePath: string, + ?conditionalDefines, + ?flags, + ?pathMap, + ?ct + ) = let langVersion = defaultArg langVersion "latestmajor" |> LanguageVersion let flags = defaultArg flags FSharpLexerFlags.Default ignore filePath // can be removed at later point @@ -1932,4 +1951,4 @@ type FSharpLexer = | _ -> tokenCallback fsTok let reportLibraryOnlyFeatures = true - lex text conditionalDefines flags reportLibraryOnlyFeatures langVersion onToken pathMap ct + lex text conditionalDefines flags reportLibraryOnlyFeatures langVersion strictIndentation onToken pathMap ct diff --git a/src/Compiler/Service/ServiceLexing.fsi b/src/Compiler/Service/ServiceLexing.fsi index 5abca96922d..9dcc8e64efd 100755 --- a/src/Compiler/Service/ServiceLexing.fsi +++ b/src/Compiler/Service/ServiceLexing.fsi @@ -326,7 +326,12 @@ type FSharpLineTokenizer = type FSharpSourceTokenizer = /// Create a tokenizer for a source file. - new: conditionalDefines: string list * fileName: string option * langVersion: string option -> FSharpSourceTokenizer + new: + conditionalDefines: string list * + fileName: string option * + langVersion: string option * + strictIndentation: bool option -> + FSharpSourceTokenizer /// Create a tokenizer for a line of this source file member CreateLineTokenizer: lineText: string -> FSharpLineTokenizer @@ -581,6 +586,7 @@ type public FSharpLexer = text: ISourceText * tokenCallback: (FSharpToken -> unit) * ?langVersion: string * + ?strictIndentation: bool * ?filePath: string * ?conditionalDefines: string list * ?flags: FSharpLexerFlags * diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index ae56b28acb2..a079864c1a9 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -1738,7 +1738,7 @@ type FSharpChecker /// Tokenize a single line, returning token information and a tokenization state represented by an integer member _.TokenizeLine(line: string, state: FSharpTokenizerLexState) = - let tokenizer = FSharpSourceTokenizer([], None, None) + let tokenizer = FSharpSourceTokenizer([], None, None, None) let lineTokenizer = tokenizer.CreateLineTokenizer line let mutable state = (None, state) diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index 19f8eae9533..00f7317a509 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -736,7 +736,9 @@ type LexFilterImpl ( //-------------------------------------------------------------------------- let relaxWhitespace2 = lexbuf.SupportsFeature LanguageFeature.RelaxWhitespace2 - let strictIndentation = lexbuf.SupportsFeature LanguageFeature.StrictIndentation + + let strictIndentation = + lexbuf.StrictIndentation |> Option.defaultWith (fun _ -> lexbuf.SupportsFeature LanguageFeature.StrictIndentation) //let indexerNotationWithoutDot = lexbuf.SupportsFeature LanguageFeature.IndexerNotationWithoutDot diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fs b/src/Compiler/SyntaxTree/ParseHelpers.fs index 0af284534ae..ccab923c760 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fs +++ b/src/Compiler/SyntaxTree/ParseHelpers.fs @@ -367,7 +367,7 @@ and LexCont = LexerContinuation // Parse IL assembly code //------------------------------------------------------------------------ -let ParseAssemblyCodeInstructions s reportLibraryOnlyFeatures langVersion m : IL.ILInstr[] = +let ParseAssemblyCodeInstructions s reportLibraryOnlyFeatures langVersion strictIndentation m : IL.ILInstr[] = #if NO_INLINE_IL_PARSER ignore s ignore isFeatureSupported @@ -376,13 +376,13 @@ let ParseAssemblyCodeInstructions s reportLibraryOnlyFeatures langVersion m : IL [||] #else try - AsciiParser.ilInstrs AsciiLexer.token (StringAsLexbuf(reportLibraryOnlyFeatures, langVersion, s)) + AsciiParser.ilInstrs AsciiLexer.token (StringAsLexbuf(reportLibraryOnlyFeatures, langVersion, strictIndentation, s)) with _ -> errorR (Error(FSComp.SR.astParseEmbeddedILError (), m)) [||] #endif -let ParseAssemblyCodeType s reportLibraryOnlyFeatures langVersion m = +let ParseAssemblyCodeType s reportLibraryOnlyFeatures langVersion strictIndentation m = ignore s #if NO_INLINE_IL_PARSER @@ -390,7 +390,7 @@ let ParseAssemblyCodeType s reportLibraryOnlyFeatures langVersion m = IL.PrimaryAssemblyILGlobals.typ_Object #else try - AsciiParser.ilType AsciiLexer.token (StringAsLexbuf(reportLibraryOnlyFeatures, langVersion, s)) + AsciiParser.ilType AsciiLexer.token (StringAsLexbuf(reportLibraryOnlyFeatures, langVersion, strictIndentation, s)) with RecoverableParseError -> errorR (Error(FSComp.SR.astParseEmbeddedILTypeError (), m)) IL.PrimaryAssemblyILGlobals.typ_Object diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fsi b/src/Compiler/SyntaxTree/ParseHelpers.fsi index 1ec98ddabb0..ebde1ae5e8b 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fsi +++ b/src/Compiler/SyntaxTree/ParseHelpers.fsi @@ -151,14 +151,24 @@ type LexerContinuation = and LexCont = LexerContinuation val ParseAssemblyCodeInstructions: - s: string -> reportLibraryOnlyFeatures: bool -> langVersion: LanguageVersion -> m: range -> ILInstr[] + s: string -> + reportLibraryOnlyFeatures: bool -> + langVersion: LanguageVersion -> + strictIndentation: bool option -> + m: range -> + ILInstr[] val grabXmlDocAtRangeStart: parseState: IParseState * optAttributes: SynAttributeList list * range: range -> PreXmlDoc val grabXmlDoc: parseState: IParseState * optAttributes: SynAttributeList list * elemIdx: int -> PreXmlDoc val ParseAssemblyCodeType: - s: string -> reportLibraryOnlyFeatures: bool -> langVersion: LanguageVersion -> m: range -> ILType + s: string -> + reportLibraryOnlyFeatures: bool -> + langVersion: LanguageVersion -> + strictIndentation: bool option -> + m: range -> + ILType val reportParseErrorAt: range -> (int * string) -> unit diff --git a/src/Compiler/SyntaxTree/UnicodeLexing.fs b/src/Compiler/SyntaxTree/UnicodeLexing.fs index 66192a60310..1b30825ad43 100644 --- a/src/Compiler/SyntaxTree/UnicodeLexing.fs +++ b/src/Compiler/SyntaxTree/UnicodeLexing.fs @@ -8,21 +8,22 @@ open Internal.Utilities.Text.Lexing type Lexbuf = LexBuffer -let StringAsLexbuf (reportLibraryOnlyFeatures, langVersion, s: string) = - LexBuffer.FromChars (reportLibraryOnlyFeatures, langVersion, s.ToCharArray()) +let StringAsLexbuf (reportLibraryOnlyFeatures, langVersion, strictIndentation, s: string) = + LexBuffer.FromChars (reportLibraryOnlyFeatures, langVersion, strictIndentation, s.ToCharArray()) -let FunctionAsLexbuf (reportLibraryOnlyFeatures, langVersion, bufferFiller) = - LexBuffer.FromFunction (reportLibraryOnlyFeatures, langVersion, bufferFiller) +let FunctionAsLexbuf (reportLibraryOnlyFeatures, langVersion, strictIndentation, bufferFiller) = + LexBuffer.FromFunction (reportLibraryOnlyFeatures, langVersion, strictIndentation, bufferFiller) -let SourceTextAsLexbuf (reportLibraryOnlyFeatures, langVersion, sourceText) = - LexBuffer.FromSourceText (reportLibraryOnlyFeatures, langVersion, sourceText) +let SourceTextAsLexbuf (reportLibraryOnlyFeatures, langVersion, strictIndentation, sourceText) = + LexBuffer.FromSourceText (reportLibraryOnlyFeatures, langVersion, strictIndentation, sourceText) -let StreamReaderAsLexbuf (reportLibraryOnlyFeatures, langVersion, reader: StreamReader) = +let StreamReaderAsLexbuf (reportLibraryOnlyFeatures, langVersion, strictIndentation, reader: StreamReader) = let mutable isFinished = false FunctionAsLexbuf( reportLibraryOnlyFeatures, langVersion, + strictIndentation, fun (chars, start, length) -> if isFinished then 0 diff --git a/src/Compiler/SyntaxTree/UnicodeLexing.fsi b/src/Compiler/SyntaxTree/UnicodeLexing.fsi index 41bbc768ff5..80d772e03e1 100644 --- a/src/Compiler/SyntaxTree/UnicodeLexing.fsi +++ b/src/Compiler/SyntaxTree/UnicodeLexing.fsi @@ -9,14 +9,27 @@ open Internal.Utilities.Text.Lexing type Lexbuf = LexBuffer -val StringAsLexbuf: reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * string -> Lexbuf +val StringAsLexbuf: + reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * strictIndentation: bool option * string -> Lexbuf val FunctionAsLexbuf: - reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * bufferFiller: (char[] * int * int -> int) -> Lexbuf + reportLibraryOnlyFeatures: bool * + langVersion: LanguageVersion * + strictIndentation: bool option * + bufferFiller: (char[] * int * int -> int) -> + Lexbuf val SourceTextAsLexbuf: - reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * sourceText: ISourceText -> Lexbuf + reportLibraryOnlyFeatures: bool * + langVersion: LanguageVersion * + strictIndentation: bool option * + sourceText: ISourceText -> + Lexbuf /// Will not dispose of the stream reader. val StreamReaderAsLexbuf: - reportLibraryOnlyFeatures: bool * langVersion: LanguageVersion * reader: StreamReader -> Lexbuf + reportLibraryOnlyFeatures: bool * + langVersion: LanguageVersion * + strictIndentation: bool option * + reader: StreamReader -> + Lexbuf diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index b42d33a5cde..9101e177167 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -194,8 +194,8 @@ let shouldStartFile args lexbuf (m:range) err tok = if (m.StartColumn <> 0 || m.StartLine <> 1) then fail args lexbuf err tok else tok -let evalIfDefExpression startPos reportLibraryOnlyFeatures langVersion args (lookup:string->bool) (lexed:string) = - let lexbuf = LexBuffer.FromChars (reportLibraryOnlyFeatures, langVersion, lexed.ToCharArray ()) +let evalIfDefExpression startPos reportLibraryOnlyFeatures langVersion strictIndentation args (lookup: string -> bool) (lexed: string) = + let lexbuf = LexBuffer.FromChars (reportLibraryOnlyFeatures, langVersion, strictIndentation, lexed.ToCharArray ()) lexbuf.StartPos <- startPos lexbuf.EndPos <- startPos let tokenStream = FSharp.Compiler.PPLexer.tokenstream args @@ -985,7 +985,7 @@ rule token (args: LexArgs) (skip: bool) = parse { let m = lexbuf.LexemeRange let lookup id = List.contains id args.conditionalDefines let lexed = lexeme lexbuf - let isTrue, expr = evalIfDefExpression lexbuf.StartPos lexbuf.ReportLibraryOnlyFeatures lexbuf.LanguageVersion args lookup lexed + let isTrue, expr = evalIfDefExpression lexbuf.StartPos lexbuf.ReportLibraryOnlyFeatures lexbuf.LanguageVersion lexbuf.StrictIndentation args lookup lexed args.ifdefStack <- (IfDefIf,m) :: args.ifdefStack LexbufIfdefStore.SaveIfHash(lexbuf, lexed, expr, m) @@ -1062,7 +1062,7 @@ and ifdefSkip (n: int) (m: range) (args: LexArgs) (skip: bool) = parse else let lexed = lexeme lexbuf let lookup id = List.contains id args.conditionalDefines - let _, expr = evalIfDefExpression lexbuf.StartPos lexbuf.ReportLibraryOnlyFeatures lexbuf.LanguageVersion args lookup lexed + let _, expr = evalIfDefExpression lexbuf.StartPos lexbuf.ReportLibraryOnlyFeatures lexbuf.LanguageVersion lexbuf.StrictIndentation args lookup lexed LexbufIfdefStore.SaveIfHash(lexbuf, lexed, expr, m) let tok = INACTIVECODE(LexCont.EndLine(args.ifdefStack, args.stringNest, LexerEndlineContinuation.Skip(n+1, m))) if not skip then tok else endline (LexerEndlineContinuation.Skip(n+1, m)) args skip lexbuf } diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 8086f056055..26414673888 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2428,7 +2428,7 @@ tyconDefnOrSpfnSimpleRepr: if parseState.LexBuffer.ReportLibraryOnlyFeatures then libraryOnlyError mLhs if Option.isSome $2 then errorR(Error(FSComp.SR.parsInlineAssemblyCannotHaveVisibilityDeclarations(), rhs parseState 2)) let s, _ = $5 - let ilType = ParseAssemblyCodeType s parseState.LexBuffer.ReportLibraryOnlyFeatures parseState.LexBuffer.LanguageVersion (rhs parseState 5) + let ilType = ParseAssemblyCodeType s parseState.LexBuffer.ReportLibraryOnlyFeatures parseState.LexBuffer.LanguageVersion parseState.LexBuffer.StrictIndentation (rhs parseState 5) SynTypeDefnSimpleRepr.LibraryOnlyILAssembly(box ilType, mLhs) } @@ -5198,7 +5198,7 @@ inlineAssemblyExpr: { if parseState.LexBuffer.ReportLibraryOnlyFeatures then libraryOnlyWarning (lhs parseState) let (s, _), sm = $2, rhs parseState 2 (fun m -> - let ilInstrs = ParseAssemblyCodeInstructions s parseState.LexBuffer.ReportLibraryOnlyFeatures parseState.LexBuffer.LanguageVersion sm + let ilInstrs = ParseAssemblyCodeInstructions s parseState.LexBuffer.ReportLibraryOnlyFeatures parseState.LexBuffer.LanguageVersion parseState.LexBuffer.StrictIndentation sm SynExpr.LibraryOnlyILAssembly(box ilInstrs, $3, List.rev $4, $5, m)) } optCurriedArgExprs: diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index dbf7c3dc89d..3098741d674 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -727,6 +727,11 @@ Zahrnout informace o rozhraní F#, výchozí je soubor. Klíčové pro distribuci knihoven. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: Podporované jazykové verze: diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index d883e6a3a9d..2277d79cbbb 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -727,6 +727,11 @@ Schließen Sie F#-Schnittstelleninformationen ein, der Standardwert ist „file“. Wesentlich für die Verteilung von Bibliotheken. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: Unterstützte Sprachversionen: diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index f3e0e6ffb2c..231200689ee 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -727,6 +727,11 @@ Incluir información de interfaz de F#, el valor predeterminado es file. Esencial para distribuir bibliotecas. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: Versiones de lenguaje admitidas: diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index fcc144579f3..00825630174 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -727,6 +727,11 @@ Incluez les informations de l’interface F#, la valeur par défaut est un fichier. Essentiel pour la distribution des bibliothèques. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: Versions linguistiques prises en charge : diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 2bdef80be67..4fb3debe94f 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -727,6 +727,11 @@ Includere le informazioni sull'interfaccia F#. Il valore predefinito è file. Essential per la distribuzione di librerie. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: Versioni del linguaggio supportate: diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index c1d1522d793..89bbcfc639b 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -727,6 +727,11 @@ F# インターフェイス情報を含めます。既定値は file です。ライブラリの配布に不可欠です。 + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: サポートされる言語バージョン: diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 207e46daeec..f48dc4ad136 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -727,6 +727,11 @@ F# 인터페이스 정보를 포함합니다. 기본값은 파일입니다. 라이브러리를 배포하는 데 필수적입니다. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: 지원되는 언어 버전: diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index d891ca542b8..fae8595a137 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -727,6 +727,11 @@ Uwzględnij informacje o interfejsie języka F#. Wartość domyślna to plik. Niezbędne do rozpowszechniania bibliotek. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: Obsługiwane wersje językowe: diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 82e94682905..0377a0a1229 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -727,6 +727,11 @@ Inclua informações da interface F#, o padrão é file. Essencial para distribuir bibliotecas. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: Versões de linguagens com suporte: diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 4f6c6cc0244..db5d1c8d4b8 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -727,6 +727,11 @@ Включить сведения об интерфейсе F#, по умолчанию используется файл. Необходимо для распространения библиотек. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: Поддерживаемые языковые версии: diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 8f3ff9088ae..40647aabc76 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -727,6 +727,11 @@ F# arabirim bilgilerini dahil edin; varsayılan değer dosyadır. Kitaplıkları dağıtmak için gereklidir. + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: Desteklenen dil sürümleri: diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 5659e17b622..e46bf93fb8c 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -727,6 +727,11 @@ 包括 F# 接口信息,默认值为文件。对于分发库必不可少。 + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: 支持的语言版本: diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index dfe9aabb1d8..007b002b5cc 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -727,6 +727,11 @@ 包含 F# 介面資訊,預設值為檔案。發佈程式庫的基本功能。 + + Override indentation rules implied by the language version + Override indentation rules implied by the language version + + Supported language versions: 支援的語言版本: diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/misc/compiler_help_output.bsl b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/misc/compiler_help_output.bsl index 90ec39abd82..2e064aacf82 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/misc/compiler_help_output.bsl +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/misc/compiler_help_output.bsl @@ -79,6 +79,7 @@ Copyright (c) Microsoft Corporation. All Rights Reserved. --checked[+|-] Generate overflow checks --define: Define conditional compilation symbols (Short form: -d) --mlcompatibility Ignore ML compatibility warnings +--strict-indentation[+|-] Override indentation rules implied by the language version - MISCELLANEOUS - diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index c7e8a41a916..be1414fc12f 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -2129,13 +2129,15 @@ FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Int32 GetHashCode(System.Coll FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Collections.FSharpList`1[System.String] ConditionalDefines FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Collections.FSharpList`1[System.String] get_ConditionalDefines() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Core.FSharpOption`1[System.Boolean] IndentationAwareSyntax +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Core.FSharpOption`1[System.Boolean] StrictIndentation FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Core.FSharpOption`1[System.Boolean] get_IndentationAwareSyntax() +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Core.FSharpOption`1[System.Boolean] get_StrictIndentation() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String LangVersionText FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String get_LangVersionText() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] SourceFiles FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] get_SourceFiles() -FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Void .ctor(System.String[], Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions, System.String, Boolean, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Boolean, Boolean) +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Void .ctor(System.String[], Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions, System.String, Boolean, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Boolean, Boolean) FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions ProjectOptions FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions get_ProjectOptions() FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.Symbols.FSharpAccessibilityRights AccessibilityRights @@ -10156,7 +10158,7 @@ FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharp FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.String,System.String]] KeywordsWithDescription FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.String,System.String]] get_KeywordsWithDescription() FSharp.Compiler.Tokenization.FSharpKeywords: System.String NormalizeIdentifierBackticks(System.String) -FSharp.Compiler.Tokenization.FSharpLexer: Void Tokenize(FSharp.Compiler.Text.ISourceText, Microsoft.FSharp.Core.FSharpFunc`2[FSharp.Compiler.Tokenization.FSharpToken,Microsoft.FSharp.Core.Unit], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.String]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Tokenization.FSharpLexerFlags], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpMap`2[System.String,System.String]], Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken]) +FSharp.Compiler.Tokenization.FSharpLexer: Void Tokenize(FSharp.Compiler.Text.ISourceText, Microsoft.FSharp.Core.FSharpFunc`2[FSharp.Compiler.Tokenization.FSharpToken,Microsoft.FSharp.Core.Unit], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.String]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Tokenization.FSharpLexerFlags], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpMap`2[System.String,System.String]], Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken]) FSharp.Compiler.Tokenization.FSharpLexerFlags: FSharp.Compiler.Tokenization.FSharpLexerFlags Compiling FSharp.Compiler.Tokenization.FSharpLexerFlags: FSharp.Compiler.Tokenization.FSharpLexerFlags CompilingFSharpCore FSharp.Compiler.Tokenization.FSharpLexerFlags: FSharp.Compiler.Tokenization.FSharpLexerFlags Default @@ -10169,7 +10171,7 @@ FSharp.Compiler.Tokenization.FSharpLineTokenizer: FSharp.Compiler.Tokenization.F FSharp.Compiler.Tokenization.FSharpLineTokenizer: System.Tuple`2[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Tokenization.FSharpTokenInfo],FSharp.Compiler.Tokenization.FSharpTokenizerLexState] ScanToken(FSharp.Compiler.Tokenization.FSharpTokenizerLexState) FSharp.Compiler.Tokenization.FSharpSourceTokenizer: FSharp.Compiler.Tokenization.FSharpLineTokenizer CreateBufferTokenizer(Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`3[System.Char[],System.Int32,System.Int32],System.Int32]) FSharp.Compiler.Tokenization.FSharpSourceTokenizer: FSharp.Compiler.Tokenization.FSharpLineTokenizer CreateLineTokenizer(System.String) -FSharp.Compiler.Tokenization.FSharpSourceTokenizer: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.Tokenization.FSharpSourceTokenizer: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) FSharp.Compiler.Tokenization.FSharpToken: Boolean IsCommentTrivia FSharp.Compiler.Tokenization.FSharpToken: Boolean IsIdentifier FSharp.Compiler.Tokenization.FSharpToken: Boolean IsKeyword diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 7c914e2c8d1..f4b2e93a5f4 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -2129,13 +2129,15 @@ FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Int32 GetHashCode(System.Coll FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Collections.FSharpList`1[System.String] ConditionalDefines FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Collections.FSharpList`1[System.String] get_ConditionalDefines() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Core.FSharpOption`1[System.Boolean] IndentationAwareSyntax +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Core.FSharpOption`1[System.Boolean] StrictIndentation FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Core.FSharpOption`1[System.Boolean] get_IndentationAwareSyntax() +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Microsoft.FSharp.Core.FSharpOption`1[System.Boolean] get_StrictIndentation() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String LangVersionText FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String get_LangVersionText() FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] SourceFiles FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] get_SourceFiles() -FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Void .ctor(System.String[], Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions, System.String, Boolean, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Boolean, Boolean) +FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Void .ctor(System.String[], Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions, System.String, Boolean, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Boolean, Boolean) FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions ProjectOptions FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions get_ProjectOptions() FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.Symbols.FSharpAccessibilityRights AccessibilityRights @@ -10156,7 +10158,7 @@ FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharp FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.String,System.String]] KeywordsWithDescription FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.String,System.String]] get_KeywordsWithDescription() FSharp.Compiler.Tokenization.FSharpKeywords: System.String NormalizeIdentifierBackticks(System.String) -FSharp.Compiler.Tokenization.FSharpLexer: Void Tokenize(FSharp.Compiler.Text.ISourceText, Microsoft.FSharp.Core.FSharpFunc`2[FSharp.Compiler.Tokenization.FSharpToken,Microsoft.FSharp.Core.Unit], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.String]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Tokenization.FSharpLexerFlags], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpMap`2[System.String,System.String]], Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken]) +FSharp.Compiler.Tokenization.FSharpLexer: Void Tokenize(FSharp.Compiler.Text.ISourceText, Microsoft.FSharp.Core.FSharpFunc`2[FSharp.Compiler.Tokenization.FSharpToken,Microsoft.FSharp.Core.Unit], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.String]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Tokenization.FSharpLexerFlags], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpMap`2[System.String,System.String]], Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken]) FSharp.Compiler.Tokenization.FSharpLexerFlags: FSharp.Compiler.Tokenization.FSharpLexerFlags Compiling FSharp.Compiler.Tokenization.FSharpLexerFlags: FSharp.Compiler.Tokenization.FSharpLexerFlags CompilingFSharpCore FSharp.Compiler.Tokenization.FSharpLexerFlags: FSharp.Compiler.Tokenization.FSharpLexerFlags Default @@ -10169,7 +10171,7 @@ FSharp.Compiler.Tokenization.FSharpLineTokenizer: FSharp.Compiler.Tokenization.F FSharp.Compiler.Tokenization.FSharpLineTokenizer: System.Tuple`2[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Tokenization.FSharpTokenInfo],FSharp.Compiler.Tokenization.FSharpTokenizerLexState] ScanToken(FSharp.Compiler.Tokenization.FSharpTokenizerLexState) FSharp.Compiler.Tokenization.FSharpSourceTokenizer: FSharp.Compiler.Tokenization.FSharpLineTokenizer CreateBufferTokenizer(Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`3[System.Char[],System.Int32,System.Int32],System.Int32]) FSharp.Compiler.Tokenization.FSharpSourceTokenizer: FSharp.Compiler.Tokenization.FSharpLineTokenizer CreateLineTokenizer(System.String) -FSharp.Compiler.Tokenization.FSharpSourceTokenizer: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.Tokenization.FSharpSourceTokenizer: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) FSharp.Compiler.Tokenization.FSharpToken: Boolean IsCommentTrivia FSharp.Compiler.Tokenization.FSharpToken: Boolean IsIdentifier FSharp.Compiler.Tokenization.FSharpToken: Boolean IsKeyword diff --git a/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl b/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl index 6bb20c71312..bd71cfb26da 100644 --- a/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl +++ b/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl @@ -119,6 +119,8 @@ --define: Define conditional compilation symbols (Short form: -d) --mlcompatibility Ignore ML compatibility warnings +--strict-indentation[+|-] Override indentation rules implied + by the language version - MISCELLANEOUS - diff --git a/tests/FSharp.Compiler.UnitTests/HashIfExpression.fs b/tests/FSharp.Compiler.UnitTests/HashIfExpression.fs index 0d81eff6cd5..9f94b7b1c06 100644 --- a/tests/FSharp.Compiler.UnitTests/HashIfExpression.fs +++ b/tests/FSharp.Compiler.UnitTests/HashIfExpression.fs @@ -67,7 +67,7 @@ type public HashIfExpression() = DiagnosticsThreadStatics.DiagnosticsLogger <- diagnosticsLogger let parser (s : string) = - let lexbuf = LexBuffer.FromChars (true, LanguageVersion.Default, s.ToCharArray ()) + let lexbuf = LexBuffer.FromChars (true, LanguageVersion.Default, None, s.ToCharArray ()) lexbuf.StartPos <- startPos lexbuf.EndPos <- startPos let tokenStream = PPLexer.tokenstream args diff --git a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fs b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fs index fc2eac106f9..679989520c2 100644 --- a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fs +++ b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fs @@ -83,6 +83,7 @@ type CompilerServiceBenchmarks() = IsInteractive = false ApplyLineDirectives = false IndentationAwareSyntax = None + StrictIndentation = None CompilingFSharpCore = false IsExe = false } diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl index 4d506d958dc..21b795880a3 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl +++ b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl @@ -62,6 +62,8 @@ Usage: fsiAnyCpu [script.fsx []] --define: Define conditional compilation symbols (Short form: -d) --mlcompatibility Ignore ML compatibility warnings +--strict-indentation[+|-] Override indentation rules implied + by the language version - MISCELLANEOUS - diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl index 8ef52cd6466..da80f614ab5 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl +++ b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl @@ -64,6 +64,8 @@ Usage: fsiAnyCpu [script.fsx []] --define: Define conditional compilation symbols (Short form: -d) --mlcompatibility Ignore ML compatibility warnings +--strict-indentation[+|-] Override indentation rules implied + by the language version - MISCELLANEOUS - diff --git a/tests/service/TokenizerTests.fs b/tests/service/TokenizerTests.fs index 37d9025bc47..7d6737363e2 100644 --- a/tests/service/TokenizerTests.fs +++ b/tests/service/TokenizerTests.fs @@ -12,7 +12,7 @@ open FSharp.Compiler.Tokenization open FsUnit open NUnit.Framework -let sourceTok = FSharpSourceTokenizer([], Some "C:\\test.fsx", None) +let sourceTok = FSharpSourceTokenizer([], Some "C:\\test.fsx", None, None) let rec parseLine(line: string, state: FSharpTokenizerLexState ref, tokenizer: FSharpLineTokenizer) = seq { match tokenizer.ScanToken(state.Value) with diff --git a/vsintegration/src/FSharp.Editor/AutomaticCompletion/BraceCompletionSessionProvider.fs b/vsintegration/src/FSharp.Editor/AutomaticCompletion/BraceCompletionSessionProvider.fs index 9f00d6a0b07..aaef7be91b7 100644 --- a/vsintegration/src/FSharp.Editor/AutomaticCompletion/BraceCompletionSessionProvider.fs +++ b/vsintegration/src/FSharp.Editor/AutomaticCompletion/BraceCompletionSessionProvider.fs @@ -507,6 +507,7 @@ type EditorBraceCompletionSessionFactory() = Some(document.FilePath), [], None, + None, cancellationToken ) diff --git a/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs b/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs index 6afae8b6aaf..f64904512cc 100644 --- a/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs +++ b/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs @@ -139,7 +139,8 @@ type internal FSharpClassificationService [] () = let! cancellationToken = CancellableTask.getCurrentCancellationToken () - let defines, langVersion = document.GetFSharpQuickDefinesAndLangVersion() + let defines, langVersion, strictIndentation = document.GetFsharpParsingOptions() + let! sourceText = document.GetTextAsync(cancellationToken) // For closed documents, only get classification for the text within the span. @@ -172,6 +173,7 @@ type internal FSharpClassificationService [] () = Some(document.FilePath), defines, Some langVersion, + strictIndentation, cancellationToken ) ) diff --git a/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingFunKeyword.fs b/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingFunKeyword.fs index 921cb77f149..c990b137208 100644 --- a/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingFunKeyword.fs +++ b/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingFunKeyword.fs @@ -41,8 +41,8 @@ type internal AddMissingFunKeywordCodeFixProvider [] () = let! cancellationToken = CancellableTask.getCurrentCancellationToken () let document = context.Document - let! defines, langVersion = - document.GetFSharpCompilationDefinesAndLangVersionAsync(nameof AddMissingFunKeywordCodeFixProvider) + let! defines, langVersion, strictIndentation = + document.GetFsharpParsingOptionsAsync(nameof AddMissingFunKeywordCodeFixProvider) let! sourceText = context.GetSourceTextAsync() let adjustedPosition = adjustPosition sourceText context.Span @@ -58,6 +58,7 @@ type internal AddMissingFunKeywordCodeFixProvider [] () = false, false, Some langVersion, + strictIndentation, cancellationToken ) |> Option.bind (fun intendedArgLexerSymbol -> diff --git a/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingRecToMutuallyRecFunctions.fs b/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingRecToMutuallyRecFunctions.fs index 5d510bf381b..517d63532c4 100644 --- a/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingRecToMutuallyRecFunctions.fs +++ b/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingRecToMutuallyRecFunctions.fs @@ -26,10 +26,8 @@ type internal AddMissingRecToMutuallyRecFunctionsCodeFixProvider [ Option.bind (fun funcLexerSymbol -> RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, funcLexerSymbol.Range)) diff --git a/vsintegration/src/FSharp.Editor/CodeFixes/AddOpenCodeFixProvider.fs b/vsintegration/src/FSharp.Editor/CodeFixes/AddOpenCodeFixProvider.fs index a9b71bac3fb..43bd9e6824d 100644 --- a/vsintegration/src/FSharp.Editor/CodeFixes/AddOpenCodeFixProvider.fs +++ b/vsintegration/src/FSharp.Editor/CodeFixes/AddOpenCodeFixProvider.fs @@ -73,8 +73,8 @@ type internal AddOpenCodeFixProvider [] (assemblyContentPr let line = sourceText.Lines.GetLineFromPosition(context.Span.End) let linePos = sourceText.Lines.GetLinePosition(context.Span.End) - let! defines, langVersion = - document.GetFSharpCompilationDefinesAndLangVersionAsync(nameof (AddOpenCodeFixProvider)) + let! defines, langVersion, strictIndentation = + document.GetFsharpParsingOptionsAsync(nameof (AddOpenCodeFixProvider)) |> liftAsync let! symbol = @@ -90,6 +90,7 @@ type internal AddOpenCodeFixProvider [] (assemblyContentPr false, false, Some langVersion, + strictIndentation, context.CancellationToken ) diff --git a/vsintegration/src/FSharp.Editor/CodeFixes/ImplementInterfaceCodeFixProvider.fs b/vsintegration/src/FSharp.Editor/CodeFixes/ImplementInterfaceCodeFixProvider.fs index ad0ca1c0f77..c1ea7719391 100644 --- a/vsintegration/src/FSharp.Editor/CodeFixes/ImplementInterfaceCodeFixProvider.fs +++ b/vsintegration/src/FSharp.Editor/CodeFixes/ImplementInterfaceCodeFixProvider.fs @@ -213,6 +213,7 @@ type internal ImplementInterfaceCodeFixProvider [] () = context.Document.FilePath, defines, langVersionOpt, + parsingOptions.StrictIndentation, context.CancellationToken ) @@ -252,6 +253,7 @@ type internal ImplementInterfaceCodeFixProvider [] () = false, false, langVersionOpt, + parsingOptions.StrictIndentation, context.CancellationToken ) diff --git a/vsintegration/src/FSharp.Editor/Commands/HelpContextService.fs b/vsintegration/src/FSharp.Editor/Commands/HelpContextService.fs index bba2e4a4cd6..73fdb5d265b 100644 --- a/vsintegration/src/FSharp.Editor/Commands/HelpContextService.fs +++ b/vsintegration/src/FSharp.Editor/Commands/HelpContextService.fs @@ -111,7 +111,9 @@ type internal FSharpHelpContextService [] () = cancellableTask { let! cancellationToken = CancellableTask.getCurrentCancellationToken () let! sourceText = document.GetTextAsync(cancellationToken) - let defines, langVersion = document.GetFSharpQuickDefinesAndLangVersion() + + let defines, langVersion, strictIndentation = document.GetFsharpParsingOptions() + let textLine = sourceText.Lines.GetLineFromPosition(textSpan.Start) let classifiedSpans = @@ -122,6 +124,7 @@ type internal FSharpHelpContextService [] () = Some document.Name, defines, Some langVersion, + strictIndentation, cancellationToken ) diff --git a/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs b/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs index 7ca569d57b7..f5bbcf10b4c 100644 --- a/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs +++ b/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs @@ -104,7 +104,7 @@ type internal FSharpCompletionProvider sourceText: SourceText, caretPosition: int, trigger: CompletionTriggerKind, - getInfo: (unit -> DocumentId * string * string list * string option), + getInfo: (unit -> DocumentId * string * string list * string option * bool option), intelliSenseOptions: IntelliSenseOptions, cancellationToken: CancellationToken ) = @@ -130,13 +130,14 @@ type internal FSharpCompletionProvider then false else - let documentId, filePath, defines, langVersion = getInfo () + let documentId, filePath, defines, langVersion, strictIndentation = getInfo () CompletionUtils.shouldProvideCompletion ( documentId, filePath, defines, langVersion, + strictIndentation, sourceText, triggerPosition, cancellationToken @@ -298,8 +299,10 @@ type internal FSharpCompletionProvider let getInfo () = let documentId = workspace.GetDocumentIdInCurrentContext(sourceText.Container) let document = workspace.CurrentSolution.GetDocument(documentId) - let defines, langVersion = document.GetFSharpQuickDefinesAndLangVersion() - (documentId, document.FilePath, defines, Some langVersion) + + let defines, langVersion, strictIndentation = document.GetFsharpParsingOptions() + + (documentId, document.FilePath, defines, Some langVersion, strictIndentation) FSharpCompletionProvider.ShouldTriggerCompletionAux( sourceText, @@ -329,7 +332,8 @@ type internal FSharpCompletionProvider TelemetryReporter.ReportSingleEventWithDuration(TelemetryEvents.ProvideCompletions, eventProps) let! sourceText = context.Document.GetTextAsync(ct) - let defines, langVersion = document.GetFSharpQuickDefinesAndLangVersion() + + let defines, langVersion, strictIndentation = document.GetFsharpParsingOptions() let shouldProvideCompetion = CompletionUtils.shouldProvideCompletion ( @@ -337,6 +341,7 @@ type internal FSharpCompletionProvider document.FilePath, defines, Some langVersion, + strictIndentation, sourceText, context.Position, ct diff --git a/vsintegration/src/FSharp.Editor/Completion/CompletionService.fs b/vsintegration/src/FSharp.Editor/Completion/CompletionService.fs index d879b718b98..e5f555c38b3 100644 --- a/vsintegration/src/FSharp.Editor/Completion/CompletionService.fs +++ b/vsintegration/src/FSharp.Editor/Completion/CompletionService.fs @@ -55,7 +55,7 @@ type internal FSharpCompletionService let documentId = workspace.GetDocumentIdInCurrentContext(sourceText.Container) let document = workspace.CurrentSolution.GetDocument(documentId) - let defines, langVersion = + let defines, langVersion, strictIndentation = projectInfoManager.GetCompilationDefinesAndLangVersionForEditingDocument(document) CompletionUtils.getDefaultCompletionListSpan ( @@ -65,6 +65,7 @@ type internal FSharpCompletionService document.FilePath, defines, Some langVersion, + strictIndentation, CancellationToken.None ) diff --git a/vsintegration/src/FSharp.Editor/Completion/CompletionUtils.fs b/vsintegration/src/FSharp.Editor/Completion/CompletionUtils.fs index e2cf7b2e114..0c823f0efc1 100644 --- a/vsintegration/src/FSharp.Editor/Completion/CompletionUtils.fs +++ b/vsintegration/src/FSharp.Editor/Completion/CompletionUtils.fs @@ -96,6 +96,7 @@ module internal CompletionUtils = filePath: string, defines: string list, langVersion: string option, + strictIndentation: bool option, sourceText: SourceText, triggerPosition: int, ct: CancellationToken @@ -104,7 +105,16 @@ module internal CompletionUtils = let triggerLine = textLines.GetLineFromPosition triggerPosition let classifiedSpans = - Tokenizer.getClassifiedSpans (documentId, sourceText, triggerLine.Span, Some filePath, defines, langVersion, ct) + Tokenizer.getClassifiedSpans ( + documentId, + sourceText, + triggerLine.Span, + Some filePath, + defines, + langVersion, + strictIndentation, + ct + ) classifiedSpans.Count = 0 || // we should provide completion at the start of empty line, where there are no tokens at all @@ -141,6 +151,7 @@ module internal CompletionUtils = filePath, defines, langVersion, + strictIndentation, ct: CancellationToken ) = @@ -178,7 +189,7 @@ module internal CompletionUtils = // the majority of common cases. let classifiedSpans = - Tokenizer.getClassifiedSpans (documentId, sourceText, line.Span, Some filePath, defines, langVersion, ct) + Tokenizer.getClassifiedSpans (documentId, sourceText, line.Span, Some filePath, defines, langVersion, strictIndentation, ct) let isBacktickIdentifier (classifiedSpan: ClassifiedSpan) = classifiedSpan.ClassificationType = ClassificationTypeNames.Identifier diff --git a/vsintegration/src/FSharp.Editor/Completion/HashDirectiveCompletionProvider.fs b/vsintegration/src/FSharp.Editor/Completion/HashDirectiveCompletionProvider.fs index 539df9b6a7c..4dd4ee2122c 100644 --- a/vsintegration/src/FSharp.Editor/Completion/HashDirectiveCompletionProvider.fs +++ b/vsintegration/src/FSharp.Editor/Completion/HashDirectiveCompletionProvider.fs @@ -68,7 +68,7 @@ type internal HashDirectiveCompletionProvider let documentId = workspace.GetDocumentIdInCurrentContext(text.Container) let document = workspace.CurrentSolution.GetDocument(documentId) - let defines, langVersion = + let defines, langVersion, strictIndentation = projectInfoManager.GetCompilationDefinesAndLangVersionForEditingDocument(document) let textLines = text.Lines @@ -81,6 +81,7 @@ type internal HashDirectiveCompletionProvider Some document.FilePath, defines, Some langVersion, + strictIndentation, CancellationToken.None ) diff --git a/vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs b/vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs index c8e408d4321..2002ec439bc 100644 --- a/vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs +++ b/vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs @@ -285,6 +285,7 @@ type internal FSharpSignatureHelpProvider [] (serviceProvi documentId: DocumentId, defines: string list, langVersion: string option, + strictIndentation: bool option, documentationBuilder: IDocumentationBuilder, sourceText: SourceText, caretPosition: int, @@ -322,6 +323,7 @@ type internal FSharpSignatureHelpProvider [] (serviceProvi false, false, langVersion, + strictIndentation, ct ) @@ -598,6 +600,7 @@ type internal FSharpSignatureHelpProvider [] (serviceProvi document: Document, defines: string list, langVersion: string option, + strictIndentation: bool option, documentationBuilder: IDocumentationBuilder, caretPosition: int, triggerTypedChar: char option, @@ -640,6 +643,7 @@ type internal FSharpSignatureHelpProvider [] (serviceProvi document.Id, defines, langVersion, + strictIndentation, documentationBuilder, sourceText, caretPosition, @@ -658,6 +662,7 @@ type internal FSharpSignatureHelpProvider [] (serviceProvi document.Id, defines, langVersion, + strictIndentation, documentationBuilder, sourceText, caretPosition, @@ -688,7 +693,7 @@ type internal FSharpSignatureHelpProvider [] (serviceProvi member _.GetItemsAsync(document, position, triggerInfo, cancellationToken) = asyncMaybe { - let defines, langVersion = document.GetFSharpQuickDefinesAndLangVersion() + let defines, langVersion, strictIndentation = document.GetFsharpParsingOptions() let triggerTypedChar = if @@ -706,6 +711,7 @@ type internal FSharpSignatureHelpProvider [] (serviceProvi document, defines, Some langVersion, + strictIndentation, documentationBuilder, position, triggerTypedChar, diff --git a/vsintegration/src/FSharp.Editor/Debugging/LanguageDebugInfoService.fs b/vsintegration/src/FSharp.Editor/Debugging/LanguageDebugInfoService.fs index ce952c78ade..8105c45ade6 100644 --- a/vsintegration/src/FSharp.Editor/Debugging/LanguageDebugInfoService.fs +++ b/vsintegration/src/FSharp.Editor/Debugging/LanguageDebugInfoService.fs @@ -56,7 +56,8 @@ type internal FSharpLanguageDebugInfoService [] () = cancellationToken: CancellationToken ) : Task = cancellableTask { - let defines, langVersion = document.GetFSharpQuickDefinesAndLangVersion() + let defines, langVersion, strictIndentation = document.GetFsharpParsingOptions() + let! cancellationToken = CancellableTask.getCurrentCancellationToken () let! sourceText = document.GetTextAsync(cancellationToken) let textSpan = TextSpan.FromBounds(0, sourceText.Length) @@ -69,6 +70,7 @@ type internal FSharpLanguageDebugInfoService [] () = Some(document.Name), defines, Some langVersion, + strictIndentation, cancellationToken ) diff --git a/vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs b/vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs index cb7e2c5a0a6..88aa10e23ab 100644 --- a/vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs +++ b/vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs @@ -57,6 +57,7 @@ type internal FSharpEditorFormattingService [] (settings: filePath, defines, Some parsingOptions.LangVersionText, + parsingOptions.StrictIndentation, cancellationToken ) diff --git a/vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs b/vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs index c2897774a7d..0e46d180073 100644 --- a/vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs +++ b/vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs @@ -41,6 +41,7 @@ type internal FSharpIndentationService [] () = filePath, defines, Some parsingOptions.LangVersionText, + parsingOptions.StrictIndentation, CancellationToken.None ) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs b/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs index fbabbfa43ed..c84ebfd8104 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs @@ -541,7 +541,7 @@ type internal FSharpProjectOptionsManager(checker: FSharpChecker, workspace: Wor IsInteractive = CompilerEnvironment.IsScriptFile document.Name } - CompilerEnvironment.GetConditionalDefinesForEditing parsingOptions, parsingOptions.LangVersionText + CompilerEnvironment.GetConditionalDefinesForEditing parsingOptions, parsingOptions.LangVersionText, parsingOptions.StrictIndentation member _.TryGetOptionsByProject(project) = reactor.TryGetOptionsByProjectAsync(project) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs b/vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs index 3be0f1ea218..2b02a33c73e 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs @@ -20,7 +20,7 @@ module internal SymbolHelpers = asyncMaybe { let userOpName = "getSymbolUsesOfSymbolAtLocationInDocument" let! _, checkFileResults = document.GetFSharpParseAndCheckResultsAsync(userOpName) |> liftAsync - let! defines, langVersion = document.GetFSharpCompilationDefinesAndLangVersionAsync(userOpName) |> liftAsync + let! defines, langVersion, strictIndentation = document.GetFsharpParsingOptionsAsync(userOpName) |> liftAsync let! cancellationToken = Async.CancellationToken |> liftAsync let! sourceText = document.GetTextAsync(cancellationToken) @@ -39,6 +39,7 @@ module internal SymbolHelpers = false, false, Some langVersion, + strictIndentation, cancellationToken ) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs b/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs index f70a6bbdb25..5cdcdccbef1 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs @@ -697,12 +697,15 @@ module internal Tokenizer = fileName: string option, defines: string list, langVersion, + strictIndentation, cancellationToken: CancellationToken ) : ResizeArray = let result = new ResizeArray() try - let sourceTokenizer = FSharpSourceTokenizer(defines, fileName, langVersion) + let sourceTokenizer = + FSharpSourceTokenizer(defines, fileName, langVersion, strictIndentation) + let lines = sourceText.Lines let sourceTextData = getSourceTextData (documentKey, defines, lines.Count) @@ -899,10 +902,13 @@ module internal Tokenizer = fileName: string, defines: string list, langVersion, + strictIndentation, cancellationToken ) = let textLinePos = sourceText.Lines.GetLinePosition(position) - let sourceTokenizer = FSharpSourceTokenizer(defines, Some fileName, langVersion) + + let sourceTokenizer = + FSharpSourceTokenizer(defines, Some fileName, langVersion, strictIndentation) // We keep incremental data per-document. When text changes we correlate text line-by-line (by hash codes of lines) let sourceTextData = getSourceTextData (documentKey, defines, sourceText.Lines.Count) @@ -915,10 +921,19 @@ module internal Tokenizer = lineData, textLinePos, contents - let tokenizeLine (documentKey, sourceText, position, fileName, defines, langVersion, cancellationToken) = + let tokenizeLine (documentKey, sourceText, position, fileName, defines, langVersion, strictIndentation, cancellationToken) = try let lineData, _, _ = - getCachedSourceLineData (documentKey, sourceText, position, fileName, defines, langVersion, cancellationToken) + getCachedSourceLineData ( + documentKey, + sourceText, + position, + fileName, + defines, + langVersion, + strictIndentation, + cancellationToken + ) lineData.SavedTokens with ex -> @@ -936,12 +951,22 @@ module internal Tokenizer = wholeActivePatterns: bool, allowStringToken: bool, langVersion, + strictIndentation, cancellationToken ) : LexerSymbol option = try let lineData, textLinePos, lineContents = - getCachedSourceLineData (documentKey, sourceText, position, fileName, defines, langVersion, cancellationToken) + getCachedSourceLineData ( + documentKey, + sourceText, + position, + fileName, + defines, + langVersion, + strictIndentation, + cancellationToken + ) getSymbolFromSavedTokens ( fileName, diff --git a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs index ebc208baae1..07efc7b04fa 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs @@ -169,10 +169,14 @@ type Document with } /// Get the compilation defines and language version from F# project that is associated with the given F# document. - member this.GetFSharpCompilationDefinesAndLangVersionAsync(userOpName) = + member this.GetFsharpParsingOptionsAsync(userOpName) = async { let! _, _, parsingOptions, _ = this.GetFSharpCompilationOptionsAsync(userOpName) - return CompilerEnvironment.GetConditionalDefinesForEditing parsingOptions, parsingOptions.LangVersionText + + return + CompilerEnvironment.GetConditionalDefinesForEditing parsingOptions, + parsingOptions.LangVersionText, + parsingOptions.StrictIndentation } /// Get the instance of the FSharpChecker from the workspace by the given F# document. @@ -193,14 +197,15 @@ type Document with /// A non-async call that quickly gets the defines and F# language version of the given F# document. /// This tries to get the data by looking at an internal cache; if it doesn't exist in the cache it will create an inaccurate but usable form of the defines and the language version. - member this.GetFSharpQuickDefinesAndLangVersion() = + member this.GetFsharpParsingOptions() = let workspaceService = this.Project.Solution.GetFSharpWorkspaceService() workspaceService.FSharpProjectOptionsManager.GetCompilationDefinesAndLangVersionForEditingDocument(this) /// A non-async call that quickly gets the defines of the given F# document. /// This tries to get the defines by looking at an internal cache; if it doesn't exist in the cache it will create an inaccurate but usable form of the defines. member this.GetFSharpQuickDefines() = - this.GetFSharpQuickDefinesAndLangVersion() |> fst + match this.GetFsharpParsingOptions() with + | defines, _, _ -> defines /// Parses the given F# document. member this.GetFSharpParseResultsAsync(userOpName) = @@ -250,7 +255,7 @@ type Document with /// Try to find a F# lexer/token symbol of the given F# document and position. member this.TryFindFSharpLexerSymbolAsync(position, lookupKind, wholeActivePattern, allowStringToken, userOpName) = async { - let! defines, langVersion = this.GetFSharpCompilationDefinesAndLangVersionAsync(userOpName) + let! defines, langVersion, strictIndentation = this.GetFsharpParsingOptionsAsync(userOpName) let! ct = Async.CancellationToken let! sourceText = this.GetTextAsync(ct) |> Async.AwaitTask @@ -265,6 +270,7 @@ type Document with wholeActivePattern, allowStringToken, Some langVersion, + strictIndentation, ct ) } diff --git a/vsintegration/src/FSharp.Editor/TaskList/TaskListService.fs b/vsintegration/src/FSharp.Editor/TaskList/TaskListService.fs index f3edadb7746..52c486157fe 100644 --- a/vsintegration/src/FSharp.Editor/TaskList/TaskListService.fs +++ b/vsintegration/src/FSharp.Editor/TaskList/TaskListService.fs @@ -23,9 +23,12 @@ type internal FSharpTaskListService [] () as this = doc.GetFSharpCompilationOptionsAsync(nameof (FSharpTaskListService)) |> liftAsync - return CompilerEnvironment.GetConditionalDefinesForEditing parsingOptions, Some parsingOptions.LangVersionText + return + CompilerEnvironment.GetConditionalDefinesForEditing parsingOptions, + Some parsingOptions.LangVersionText, + parsingOptions.StrictIndentation } - |> Async.map (Option.defaultValue ([], None)) + |> Async.map (Option.defaultValue ([], None, None)) let extractContractedComments (tokens: Tokenizer.SavedTokenInfo[]) = let granularTokens = @@ -53,6 +56,7 @@ type internal FSharpTaskListService [] () as this = sourceText: SourceText, defines: string list, langVersion: string option, + strictIndentation: bool option, descriptors: (string * FSharpTaskListDescriptor)[], cancellationToken ) = @@ -62,7 +66,16 @@ type internal FSharpTaskListService [] () as this = for line in sourceText.Lines do let contractedTokens = - Tokenizer.tokenizeLine (doc.Id, sourceText, line.Span.Start, doc.FilePath, defines, langVersion, cancellationToken) + Tokenizer.tokenizeLine ( + doc.Id, + sourceText, + line.Span.Start, + doc.FilePath, + defines, + langVersion, + strictIndentation, + cancellationToken + ) |> extractContractedComments for ct in contractedTokens do @@ -90,6 +103,6 @@ type internal FSharpTaskListService [] () as this = backgroundTask { let descriptors = desc |> Seq.map (fun d -> d.Text, d) |> Array.ofSeq let! sourceText = doc.GetTextAsync(cancellationToken) - let! defines, langVersion = doc |> getDefinesAndLangVersion - return this.GetTaskListItems(doc, sourceText, defines, langVersion, descriptors, cancellationToken) + let! defines, langVersion, strictIndentation = doc |> getDefinesAndLangVersion + return this.GetTaskListItems(doc, sourceText, defines, langVersion, strictIndentation, descriptors, cancellationToken) } diff --git a/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs index eab0a63997a..3f92173e206 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs @@ -20,7 +20,7 @@ module CompletionProviderTests = let filePath = "C:\\test.fs" let mkGetInfo documentId = - fun () -> documentId, filePath, [], (Some "preview") + fun () -> documentId, filePath, [], (Some "preview"), None let formatCompletions (completions: string seq) = "\n\t" + String.Join("\n\t", completions) @@ -111,7 +111,16 @@ module CompletionProviderTests = let sourceText = SourceText.From(fileContents) let resultSpan = - CompletionUtils.getDefaultCompletionListSpan (sourceText, caretPosition, documentId, filePath, [], None, CancellationToken.None) + CompletionUtils.getDefaultCompletionListSpan ( + sourceText, + caretPosition, + documentId, + filePath, + [], + None, + None, + CancellationToken.None + ) Assert.Equal(expected, sourceText.ToString(resultSpan)) diff --git a/vsintegration/tests/FSharp.Editor.Tests/GoToDefinitionServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/GoToDefinitionServiceTests.fs index face43ab811..6fd9f08729b 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/GoToDefinitionServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/GoToDefinitionServiceTests.fs @@ -38,6 +38,7 @@ module GoToDefinitionServiceTests = false, false, langVersion, + None, System.Threading.CancellationToken.None ) diff --git a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs index f52ef63b53c..d35b708c3e3 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs @@ -50,6 +50,7 @@ type HelpContextServiceTests() = Some "test.fs", [], None, + None, CancellationToken.None ) diff --git a/vsintegration/tests/FSharp.Editor.Tests/LanguageDebugInfoServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/LanguageDebugInfoServiceTests.fs index 2f34a78f38b..9b220a69f70 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/LanguageDebugInfoServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/LanguageDebugInfoServiceTests.fs @@ -60,6 +60,7 @@ let main argv = Some(fileName), defines, None, + None, CancellationToken.None ) diff --git a/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs index af6f3f3016f..525a17eef67 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs @@ -170,6 +170,7 @@ module SignatureHelpProvider = document.Id, [], None, + None, DefaultDocumentationProvider, sourceText, caretPosition, @@ -512,6 +513,7 @@ M.f document.Id, [], None, + None, DefaultDocumentationProvider, sourceText, caretPosition, diff --git a/vsintegration/tests/FSharp.Editor.Tests/SyntacticColorizationServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/SyntacticColorizationServiceTests.fs index 5120cd71d8f..8b42693aded 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/SyntacticColorizationServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/SyntacticColorizationServiceTests.fs @@ -38,6 +38,7 @@ type SyntacticClassificationServiceTests() = Some(fileName), defines, langVersion, + None, CancellationToken.None ) diff --git a/vsintegration/tests/FSharp.Editor.Tests/TaskListServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/TaskListServiceTests.fs index f342b0e92aa..d84a049ada6 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/TaskListServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/TaskListServiceTests.fs @@ -26,7 +26,7 @@ let assertTasks expectedTasks fileContents = let sourceText = doc.GetTextAsync().Result let t = - service.GetTaskListItems(doc, sourceText, [], (Some "preview"), descriptors, ct) + service.GetTaskListItems(doc, sourceText, [], (Some "preview"), None, descriptors, ct) let tasks = t |> Seq.map (fun t -> t.Message) |> List.ofSeq Assert.Equal(expectedTasks |> List.sort, tasks |> List.sort) diff --git a/vsintegration/tests/Salsa/FSharpLanguageServiceTestable.fs b/vsintegration/tests/Salsa/FSharpLanguageServiceTestable.fs index f0189d75b4c..f2813f92c2a 100644 --- a/vsintegration/tests/Salsa/FSharpLanguageServiceTestable.fs +++ b/vsintegration/tests/Salsa/FSharpLanguageServiceTestable.fs @@ -212,7 +212,7 @@ type internal FSharpLanguageServiceTestable() as this = let fileName = VsTextLines.GetFilename buffer let rdt = this.ServiceProvider.RunningDocumentTable let defines = this.ProjectSitesAndFiles.GetDefinesForFile_DEPRECATED(rdt, fileName, this.FSharpChecker) - let sourceTokenizer = FSharpSourceTokenizer(defines,Some(fileName), None) + let sourceTokenizer = FSharpSourceTokenizer(defines,Some(fileName), None, None) sourceTokenizer.CreateLineTokenizer(source)) let colorizer = new FSharpColorizer_DEPRECATED(this.CloseColorizer, buffer, scanner) diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.General.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.General.fs index 214d6ddf054..872966b43cb 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.General.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.General.fs @@ -133,7 +133,7 @@ type UsingMSBuild() = let fileName = "test.fs" let defines = [ "COMPILED"; "EDITING" ] - FSharpSourceTokenizer(defines,Some(fileName),None).CreateLineTokenizer(source)) + FSharpSourceTokenizer(defines,Some(fileName), None, None).CreateLineTokenizer(source)) let cm = Microsoft.VisualStudio.FSharp.LanguageService.TokenColor.Comment let kw = Microsoft.VisualStudio.FSharp.LanguageService.TokenColor.Keyword