Skip to content

Commit f24019f

Browse files
committed
Merge pull request #78 from rneatherway/unreferenced-projects-fcs
Fix for uncompiled referenced projects
2 parents 49f88e6 + f5db7de commit f24019f

File tree

31 files changed

+368
-192
lines changed

31 files changed

+368
-192
lines changed

FsAutoComplete.Core/CommandResponse.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ module CommandResponse =
7272
Files: List<string>
7373
Output: string
7474
References: List<string>
75-
Framework: string
7675
}
7776

7877
type OverloadSignature =
@@ -204,13 +203,12 @@ module CommandResponse =
204203
let data = TipFormatter.formatTip tip |> List.map(List.map(fun (n,m) -> {Signature = n; Comment = m} ))
205204
serialize { Kind = "helptext"; Data = { HelpTextResponse.Name = name; Overloads = data } }
206205

207-
let project (serialize : obj -> string) (projectFileName, projectFiles, outFileOpt, references, frameworkOpt) =
206+
let project (serialize : obj -> string) (projectFileName, projectFiles, outFileOpt, references) =
208207
let projectData =
209208
{ Project = projectFileName
210209
Files = projectFiles
211210
Output = match outFileOpt with Some x -> x | None -> "null"
212-
References = List.sortBy IO.Path.GetFileName references
213-
Framework = match frameworkOpt with Some x -> x | None -> "null" }
211+
References = List.sortBy IO.Path.GetFileName references }
214212
serialize { Kind = "project"; Data = projectData }
215213

216214
let completion (serialize : obj -> string) (decls: FSharpDeclarationListItem[]) =

FsAutoComplete.Core/CompilerServiceInterface.fs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type ParseAndCheckResults(parseResults: FSharpParseFileResults,
6262
| Some(col,identIsland) ->
6363

6464
// TODO: Display other tooltip types, for example for strings or comments where appropriate
65-
let tip = checkResults.GetToolTipTextAlternate(line, col + 1, lineStr, identIsland, Parser.tagOfToken(Parser.token.IDENT("")))
65+
let tip = checkResults.GetToolTipTextAlternate(line, col + 1, lineStr, identIsland, FSharpTokenTag.Identifier)
6666
|> Async.RunSynchronously
6767
match tip with
6868
| FSharpToolTipText(elems) when elems |> List.forall (function
@@ -138,22 +138,24 @@ type FSharpCompilerServiceChecker() =
138138
Failure (sprintf "File '%s' does not exist" file)
139139
else
140140
try
141-
let p = FSharpProjectFileInfo.Parse(file)
142-
let args, references =
143-
if not (Seq.exists (fun (s: string) -> s.Contains "FSharp.Core.dll") p.Options) then
144-
ensureCorrectFSharpCore (Array.ofList p.Options), Option.toList Environment.fsharpCoreOpt @ p.References
145-
else
146-
Array.ofList p.Options, p.References
147-
148-
let projectOptions = checker.GetProjectOptionsFromCommandLineArgs(file, args)
149-
let referencedProjectOptions =
150-
[| for file in p.ProjectReferences do
151-
yield file, checker.GetProjectOptionsFromProjectFile(file) |]
152-
153141
let po =
154-
{ projectOptions
155-
with ReferencedProjects = referencedProjectOptions }
156-
Success (po, p.CompileFiles, p.OutputFile, references, p.FrameworkVersion)
142+
let p = checker.GetProjectOptionsFromProjectFile(file)
143+
let opts =
144+
if not (Seq.exists (fun (s: string) -> s.Contains "FSharp.Core.dll") p.OtherOptions) then
145+
ensureCorrectFSharpCore p.OtherOptions
146+
else
147+
p.OtherOptions
148+
{ p with OtherOptions = opts }
149+
150+
let chooseByPrefix prefix (s: string) =
151+
if s.StartsWith(prefix) then Some (s.Substring(prefix.Length))
152+
else None
153+
154+
let compileFiles = Seq.filter (fun (s:string) -> s.EndsWith(".fs")) po.OtherOptions
155+
let outputFile = Seq.tryPick (chooseByPrefix "--out:") po.OtherOptions
156+
let references = Seq.choose (chooseByPrefix "-r:") po.OtherOptions
157+
158+
Success (po, Seq.toList compileFiles, outputFile, Seq.toList references)
157159
with e ->
158160
Failure e.Message
159161

FsAutoComplete.Core/FsAutoComplete.Core.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ module Commands =
5050

5151
match checker.TryGetProjectOptions(file) with
5252
| Result.Failure s -> [Response.error serialize s],state
53-
| Result.Success(po, projectFiles, outFileOpt, references, frameworkOpt) ->
54-
let res = Response.project serialize (file, projectFiles, outFileOpt, references, frameworkOpt)
53+
| Result.Success(po, projectFiles, outFileOpt, references) ->
54+
let res = Response.project serialize (file, projectFiles, outFileOpt, references)
5555
let checkOptions =
5656
projectFiles
5757
|> List.fold (fun s f -> Map.add f po s) state.FileCheckOptions

FsAutoComplete.Core/FsAutoComplete.Core.fsproj

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -55,17 +55,6 @@
5555
<Target Name="AfterBuild">
5656
</Target>
5757
-->
58-
<Choose>
59-
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6')">
60-
<ItemGroup>
61-
<Reference Include="FSharp.Compiler.Service">
62-
<HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll</HintPath>
63-
<Private>True</Private>
64-
<Paket>True</Paket>
65-
</Reference>
66-
</ItemGroup>
67-
</When>
68-
</Choose>
6958
<ItemGroup>
7059
<Compile Include="Utils.fs" />
7160
<Compile Include="Environment.fs" />
@@ -87,4 +76,15 @@
8776
<Reference Include="System.Core" />
8877
<Reference Include="System.Numerics" />
8978
</ItemGroup>
90-
</Project>
79+
<Choose>
80+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6')">
81+
<ItemGroup>
82+
<Reference Include="FSharp.Compiler.Service">
83+
<HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll</HintPath>
84+
<Private>True</Private>
85+
<Paket>True</Paket>
86+
</Reference>
87+
</ItemGroup>
88+
</When>
89+
</Choose>
90+
</Project>

FsAutoComplete.Suave/FsAutoComplete.Suave.fsproj

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -92,53 +92,6 @@
9292
</ItemGroup>
9393
</When>
9494
</Choose>
95-
<Choose>
96-
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
97-
<ItemGroup>
98-
<Reference Include="FsPickler">
99-
<HintPath>..\packages\FsPickler\lib\net35\FsPickler.dll</HintPath>
100-
<Private>True</Private>
101-
<Paket>True</Paket>
102-
</Reference>
103-
<Reference Include="System.Runtime.Serialization">
104-
<Paket>True</Paket>
105-
</Reference>
106-
<Reference Include="System.Xml">
107-
<Paket>True</Paket>
108-
</Reference>
109-
</ItemGroup>
110-
</When>
111-
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0')">
112-
<ItemGroup>
113-
<Reference Include="FsPickler">
114-
<HintPath>..\packages\FsPickler\lib\net40\FsPickler.dll</HintPath>
115-
<Private>True</Private>
116-
<Paket>True</Paket>
117-
</Reference>
118-
<Reference Include="System.Runtime.Serialization">
119-
<Paket>True</Paket>
120-
</Reference>
121-
<Reference Include="System.Xml">
122-
<Paket>True</Paket>
123-
</Reference>
124-
</ItemGroup>
125-
</When>
126-
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6')">
127-
<ItemGroup>
128-
<Reference Include="FsPickler">
129-
<HintPath>..\packages\FsPickler\lib\net45\FsPickler.dll</HintPath>
130-
<Private>True</Private>
131-
<Paket>True</Paket>
132-
</Reference>
133-
<Reference Include="System.Runtime.Serialization">
134-
<Paket>True</Paket>
135-
</Reference>
136-
<Reference Include="System.Xml">
137-
<Paket>True</Paket>
138-
</Reference>
139-
</ItemGroup>
140-
</When>
141-
</Choose>
14295
<Choose>
14396
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
14497
<ItemGroup>
@@ -206,4 +159,4 @@
206159
</ItemGroup>
207160
</When>
208161
</Choose>
209-
</Project>
162+
</Project>

FsAutoComplete.Tests/FsAutoComplete.Tests.fsproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -80,10 +80,12 @@
8080
<Project>{4e4786f3-4566-44e1-8787-91790007f0f6}</Project>
8181
<Private>True</Private>
8282
</ProjectReference>
83+
</ItemGroup>
84+
<ItemGroup>
8385
<Reference Include="nunit.framework">
8486
<HintPath>..\packages\NUnit\lib\nunit.framework.dll</HintPath>
8587
<Private>True</Private>
8688
<Paket>True</Paket>
8789
</Reference>
8890
</ItemGroup>
89-
</Project>
91+
</Project>

FsAutoComplete/test/integration/ErrorTestsJson/output.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"<absolute path removed>/System.Core.dll",
1313
"<absolute path removed>/System.dll",
1414
"<absolute path removed>/mscorlib.dll"
15-
],
16-
"Framework": "v4.0"
15+
]
1716
}
1817
}
1918
{

FsAutoComplete/test/integration/FindDeclarations/output.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"<absolute path removed>/System.Core.dll",
1313
"<absolute path removed>/System.dll",
1414
"<absolute path removed>/mscorlib.dll"
15-
],
16-
"Framework": "v4.0"
15+
]
1716
}
1817
}
1918
{

FsAutoComplete/test/integration/MultiProj/output.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"<absolute path removed>/System.Core.dll",
1313
"<absolute path removed>/System.dll",
1414
"<absolute path removed>/mscorlib.dll"
15-
],
16-
"Framework": "v4.0"
15+
]
1716
}
1817
}
1918
{
@@ -212,8 +211,7 @@
212211
"<absolute path removed>/System.Core.dll",
213212
"<absolute path removed>/System.dll",
214213
"<absolute path removed>/mscorlib.dll"
215-
],
216-
"Framework": "v4.0"
214+
]
217215
}
218216
}
219217
{

FsAutoComplete/test/integration/MultipleUnsavedFiles/output.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"<absolute path removed>/System.Core.dll",
1313
"<absolute path removed>/System.dll",
1414
"<absolute path removed>/mscorlib.dll"
15-
],
16-
"Framework": "v4.0"
15+
]
1716
}
1817
}
1918
{

0 commit comments

Comments
 (0)