-
Notifications
You must be signed in to change notification settings - Fork 789
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
[WIP] Service formatting #3542
[WIP] Service formatting #3542
Changes from 8 commits
6b9d58e
6b2f223
0547c21
f7b21f3
c6ee06a
797aa39
af43963
e2b56b3
cab536f
2ac0d22
2c644ed
7b075ed
ce87698
8cb1166
0b34875
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,43 @@ | |
</FilesToSign> | ||
</ItemGroup> | ||
</Target> | ||
<Choose> | ||
<When Condition="$(MonoPackaging) != 'true'"> | ||
<ItemGroup Condition="'$(TargetDotnetProfile)' != 'coreclr'"> | ||
<Reference Include="Microsoft.Build.Framework, Version=$(VisualStudioVersion).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.Framework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Build, Version=$(VisualStudioVersion).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Utilities.Core, Version=$(VisualStudioVersion).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.Utilities.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Tasks.Core, Version=$(VisualStudioVersion).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.Tasks.Core.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
</When> | ||
<Otherwise> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.Build.Framework, Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Engine, Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Build, Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Utilities.$(MonoPackagingMSBuildVersionSuffix), Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Tasks.$(MonoPackagingMSBuildVersionSuffix), Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
</ItemGroup> | ||
</Otherwise> | ||
</Choose> | ||
<ItemGroup> | ||
<FilesToLocalize Include="$(OutDir)$(AssemblyName).dll"> | ||
<TranslationFile>$(FSharpSourcesRoot)\..\loc\lcl\{Lang}\$(AssemblyName).dll.lcl</TranslationFile> | ||
|
@@ -454,8 +491,6 @@ | |
<Compile Include="..\TypeChecker.fs"> | ||
<Link>Logic\TypeChecker.fs</Link> | ||
</Compile> | ||
|
||
<!-- includes the optimizer and code generator --> | ||
<Compile Include="..\Optimizer.fsi"> | ||
<Link>Optimize\Optimizer.fsi</Link> | ||
</Compile> | ||
|
@@ -486,8 +521,6 @@ | |
<Compile Include="..\IlxGen.fs"> | ||
<Link>CodeGen\IlxGen.fs</Link> | ||
</Compile> | ||
|
||
<!-- includes the core of the F# Compiler fsc.exe implementation --> | ||
<Compile Include="..\CompileOps.fsi"> | ||
<Link>Driver\CompileOps.fsi</Link> | ||
</Compile> | ||
|
@@ -506,8 +539,6 @@ | |
<Compile Include="..\fsc.fs"> | ||
<Link>Driver\fsc.fs</Link> | ||
</Compile> | ||
|
||
<!-- the symbol API. --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can undo all such changes in this file |
||
<Compile Include="..\symbols\SymbolHelpers.fsi"> | ||
<Link>Symbols/SymbolHelpers.fsi</Link> | ||
</Compile> | ||
|
@@ -526,8 +557,6 @@ | |
<Compile Include="..\symbols\Exprs.fs"> | ||
<Link>Symbols/Exprs.fs</Link> | ||
</Compile> | ||
|
||
<!-- the incremental builder and service . --> | ||
<Compile Include="..\vs\IncrementalBuild.fsi"> | ||
<Link>Service/IncrementalBuild.fsi</Link> | ||
</Compile> | ||
|
@@ -618,8 +647,30 @@ | |
<Compile Include="..\vs\ServiceStructure.fs"> | ||
<Link>Service/ServiceStructure.fs</Link> | ||
</Compile> | ||
|
||
<!-- the core of the F# Interactive fsi.exe implementation --> | ||
<Compile Include="..\vs\ServiceFormatting\Utils.fs"> | ||
<Link>Service/ServiceFormatting/Utils.fs</Link> | ||
</Compile> | ||
<Compile Include="..\vs\ServiceFormatting\TokenMatcher.fs"> | ||
<Link>Service/ServiceFormatting/TokenMatcher.fs</Link> | ||
</Compile> | ||
<Compile Include="..\vs\ServiceFormatting\FormatConfig.fs"> | ||
<Link>Service/ServiceFormatting/FormatConfig.fs</Link> | ||
</Compile> | ||
<Compile Include="..\vs\ServiceFormatting\SourceParser.fs"> | ||
<Link>Service/ServiceFormatting/SourceParser.fs</Link> | ||
</Compile> | ||
<Compile Include="..\vs\ServiceFormatting\SourceTransformer.fs"> | ||
<Link>Service/ServiceFormatting/SourceTransformer.fs</Link> | ||
</Compile> | ||
<Compile Include="..\vs\ServiceFormatting\CodePrinter.fs"> | ||
<Link>Service/ServiceFormatting/CodePrinter.fs</Link> | ||
</Compile> | ||
<Compile Include="..\vs\ServiceFormatting\CodeFormatterImpl.fs"> | ||
<Link>Service/ServiceFormatting/CodeFormatterImpl.fs</Link> | ||
</Compile> | ||
<Compile Include="..\vs\ServiceFormatting\CodeFormatter.fs"> | ||
<Link>Service/ServiceFormatting/CodeFormatter.fs</Link> | ||
</Compile> | ||
<FsSrGen Include="..\fsi\FSIstrings.txt"> | ||
<Link>FSIstrings.txt</Link> | ||
</FsSrGen> | ||
|
@@ -629,25 +680,19 @@ | |
<Compile Include="..\fsi\fsi.fs"> | ||
<Link>InteractiveSession\fsi.fs</Link> | ||
</Compile> | ||
|
||
<Compile Include="InternalsVisibleTo.fs" Condition="'$(TargetDotnetProfile)' != 'coreclr'"> | ||
<Link>Misc/InternalsVisibleTo.fs</Link> | ||
</Compile> | ||
<Compile Include="..\MSBuildReferenceResolver.fs"> | ||
<Link>Misc/MSBuildReferenceResolver.fs</Link> | ||
</Compile> | ||
<!-- an old API for testing the compiler and gathering diagnostics in-memory --> | ||
<Compile Include="..\LegacyHostedCompilerForTesting.fs"> | ||
<Link>Misc/LegacyHostedCompilerForTesting.fs</Link> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageNuspec Include="FSharp.Compiler.Private.netcore.nuspec" Condition="'$(TargetDotnetProfile)' == 'coreclr'" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetDotnetProfile)' == 'coreclr'"> | ||
<None Include="project.json" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetDotnetProfile)' != 'coreclr'"> | ||
<ItemGroup> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
|
@@ -669,45 +714,6 @@ | |
<HintPath>..\..\..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll</HintPath> | ||
<Private>true</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<Choose> | ||
<When Condition="$(MonoPackaging) != 'true'"> | ||
<ItemGroup Condition="'$(TargetDotnetProfile)' != 'coreclr'"> | ||
<Reference Include="Microsoft.Build.Framework, Version=$(VisualStudioVersion).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.Framework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Build, Version=$(VisualStudioVersion).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Utilities.Core, Version=$(VisualStudioVersion).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.Utilities.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Tasks.Core, Version=$(VisualStudioVersion).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.Tasks.Core.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
</When> | ||
<Otherwise> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.Build.Framework, Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Engine, Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Build, Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Utilities.$(MonoPackagingMSBuildVersionSuffix), Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Build.Tasks.$(MonoPackagingMSBuildVersionSuffix), Version=$(MonoPackagingMSBuildVersionFull), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
</ItemGroup> | ||
</Otherwise> | ||
</Choose> | ||
<ItemGroup> | ||
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj"> | ||
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project> | ||
<Name>FSharp.Core</Name> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is hilarious ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just copied this from another file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Apache Licence requires us to retain the original copyright notices of this code and identify prominently any files that we changed. So we should drop the copyright notice additions, and replace them with the original copyright notice if one existed. I appreciate that many projects don't really follow those practices, but we should strive to minimize the risk to this repo, and products built from it. Snipped from Apache License: Thanks Kevin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I removed the MS copyright and added the following comment: // Copied from https://github.com/dungpa/fantomas and modified by Vasily Kirichenko I'm not sure I should add my name though. |
||
|
||
namespace Microsoft.FSharp.Compiler.SourceCodeServices.ServiceFormatting | ||
|
||
[<Sealed>] | ||
type internal CodeFormatter = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be public in the FCS API |
||
static member FormatSelection(fileName, selection, source, config, ast) = | ||
CodeFormatterImpl.formatSelection selection config fileName source ast | ||
|
||
static member FormatAroundCursor(fileName, cursorPos, source, config, ast) = | ||
CodeFormatterImpl.formatAroundCursor cursorPos config fileName source ast | ||
|
||
static member InferSelectionFromCursorPos(fileName, cursorPos, source) = | ||
CodeFormatterImpl.inferSelectionFromCursorPos cursorPos fileName source | ||
|
||
static member internal FormatSelectionInDocument(fileName, selection, source, config, ast) = | ||
CodeFormatterImpl.formatSelectionInDocument selection config fileName source ast | ||
|
||
static member FormatAST(ast, fileName, source, config) = CodeFormatterImpl.formatAST ast fileName source config | ||
|
||
static member MakePos(line, col) = CodeFormatterImpl.makePos line col | ||
|
||
static member MakeRange(fileName, startLine, startCol, endLine, endCol) = | ||
CodeFormatterImpl.makeRange fileName startLine startCol endLine endCol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this change needed for? There should be no MSBuild dependency added to FSharp.Compiler.Private. I suspect this is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, it's been moved around. I guess just move it back