Skip to content

Commit

Permalink
Adjust for 1-based column indexing
Browse files Browse the repository at this point in the history
Add unit test project to check parsing functionality is correct
  • Loading branch information
rneatherway committed Jun 3, 2015
1 parent 916c162 commit ece8298
Show file tree
Hide file tree
Showing 25 changed files with 250 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ FSharp.AutoComplete/test/unit/build
packages
.paket/paket.exe

TestResults.xml

.DS_Store
34 changes: 11 additions & 23 deletions FSharp.AutoComplete.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,31 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.CompilerBinding", "F
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.AutoComplete", "FSharp.AutoComplete\FSharp.AutoComplete.fsproj", "{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.CompilerBinding.Tests", "FSharp.CompilerBinding.Tests\FSharp.CompilerBinding.Tests.fsproj", "{F5EBDD99-5ED7-4311-A5CB-7CFCE696FF88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Debug|x86.ActiveCfg = Debug|Any CPU
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Release|Any CPU.Build.0 = Release|Any CPU
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{88F6940F-D300-474C-B2A7-E2ECD5B04B57}.Release|x86.ActiveCfg = Release|Any CPU
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Debug|Any CPU.ActiveCfg = Debug|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Debug|Any CPU.Build.0 = Debug|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Debug|Mixed Platforms.Build.0 = Debug|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Debug|x86.ActiveCfg = Debug|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Debug|x86.Build.0 = Debug|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Release|Any CPU.ActiveCfg = Release|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Release|Any CPU.Build.0 = Release|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Release|Mixed Platforms.ActiveCfg = Release|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Release|Mixed Platforms.Build.0 = Release|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Release|x86.ActiveCfg = Release|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Release|x86.Build.0 = Release|x86
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}.Release|Any CPU.Build.0 = Release|Any CPU
{F5EBDD99-5ED7-4311-A5CB-7CFCE696FF88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5EBDD99-5ED7-4311-A5CB-7CFCE696FF88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5EBDD99-5ED7-4311-A5CB-7CFCE696FF88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5EBDD99-5ED7-4311-A5CB-7CFCE696FF88}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = FSharp.AutoComplete.fsproj
StartupItem = FSharp.AutoComplete\FSharp.AutoComplete.fsproj
EndGlobalSection
EndGlobal
8 changes: 3 additions & 5 deletions FSharp.AutoComplete/FSharp.AutoComplete.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B6AB4EF3-8F60-41A1-AB0C-851A6DEB169E}</ProjectGuid>
Expand All @@ -17,26 +17,24 @@
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<Tailcalls>False</Tailcalls>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Debug\FSharp.InteractiveAutocomplete.XML</DocumentationFile>
<OtherFlags>--warnon:1182</OtherFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
<Tailcalls>True</Tailcalls>
<OutputPath>bin\Release</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Release\FSharp.InteractiveAutocomplete.XML</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
</PropertyGroup>
Expand Down
7 changes: 4 additions & 3 deletions FSharp.AutoComplete/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ module internal CommandInput =
// Parses always and returns default error message
let error = parser { return Error("Unknown command or wrong arguments") }

// Parase any of the supported commands
// Parse any of the supported commands
let parseCommand =
function
| null -> Quit
Expand Down Expand Up @@ -390,11 +390,12 @@ module internal Main =
ok

/// Is the specified position consistent with internal state of file?
// Note that both emacs and FSC use 1-based line indexing
// Note that both emacs and FCS use 1-based line indexing
// while emacs uses 0-based column indexing and FCS is 1-based
let posok file line col =
let lines = state.Files.[file].Lines
let ok = line <= lines.Length && line >= 1 &&
col <= lines.[line - 1].Length && col >= 0
col <= lines.[line - 1].Length + 1 && col >= 1
if not ok then printMsg "ERROR" "Position is out of range"
ok

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ File.Delete "output.txt"
let p = new FSharpAutoCompleteWrapper()

p.parse "Script.fsx"
p.completion "Script.fsx" 2 6
p.completionFilter "Script.fsx" 2 6 "StartsWith"
p.completionFilter "Script.fsx" 2 6 "Contains"
p.completion "Script.fsx" 2 7
p.completionFilter "Script.fsx" 2 7 "StartsWith"
p.completionFilter "Script.fsx" 2 7 "Contains"
p.send "quit\n"
p.finalOutput ()
|> writeNormalizedOutput "output.txt"
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ let p = new FSharpAutoCompleteWrapper()

p.project "Test1.fsproj"
p.parse "Program.fs"
p.completion "Program.fs" 6 13
p.completion "Program.fs" 6 14
p.parse "Script.fsx"
p.completion "Script.fsx" 6 13
p.completion "Script.fsx" 6 14
p.send "quit\n"
p.finalOutput ()
|> writeNormalizedOutput "output.txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ p.project "Test1.fsproj"
p.parse "Program.fs"
p.parse "Script.fsx"
Threading.Thread.Sleep(8000)
p.completion "Program.fs" 6 13
p.completion "Script.fsx" 6 13
p.completion "Program.fs" 6 14
p.completion "Script.fsx" 6 14
p.send "quit\n"
p.finalOutput ()
|> writeNormalizedOutput "output.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ p.project "FindDecl.fsproj"
p.parse "FileTwo.fs"
p.parse "Script.fsx"
p.parse "Program.fs"
p.finddeclaration "Program.fs" 6 15
p.finddeclaration "Program.fs" 8 19
p.finddeclaration "Program.fs" 14 25
p.finddeclaration "Program.fs" 10 19
p.finddeclaration "Script.fsx" 6 16
p.finddeclaration "Program.fs" 6 16
p.finddeclaration "Program.fs" 8 20
p.finddeclaration "Program.fs" 14 26
p.finddeclaration "Program.fs" 10 20
p.finddeclaration "Script.fsx" 6 17
p.send "quit\n"
p.finalOutput ()
|> writeNormalizedOutput "output.txt"
32 changes: 16 additions & 16 deletions FSharp.AutoComplete/test/integration/MultiProj/MultiProjRunner.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ let p = new FSharpAutoCompleteWrapper()
p.project "Proj1/Proj1.fsproj"
p.parse "Proj1/Ops.fs"
p.parse "Proj1/Program.fs"
p.completion "Proj1/Program.fs" 8 19
p.completion "Proj1/Program.fs" 4 22
p.completion "Proj1/Program.fs" 6 13
p.completion "Proj1/Program.fs" 10 19
p.completion "Proj1/Program.fs" 8 20
p.completion "Proj1/Program.fs" 4 23
p.completion "Proj1/Program.fs" 6 14
p.completion "Proj1/Program.fs" 10 20

p.project "Proj2/Proj2.fsproj"
p.parse "Proj2/Core.fs"
p.parse "Proj2/Program.fs"
p.completion "Proj2/Program.fs" 8 19
p.completion "Proj2/Program.fs" 4 22
p.completion "Proj2/Program.fs" 6 13
p.completion "Proj2/Program.fs" 10 19
p.completion "Proj2/Program.fs" 8 20
p.completion "Proj2/Program.fs" 4 23
p.completion "Proj2/Program.fs" 6 14
p.completion "Proj2/Program.fs" 10 20

p.parse "Proj1/Ops.fs"
p.parse "Proj1/Program.fs"
p.completion "Proj1/Program.fs" 8 19
p.completion "Proj1/Program.fs" 4 22
p.completion "Proj1/Program.fs" 6 13
p.completion "Proj1/Program.fs" 10 19
p.completion "Proj1/Program.fs" 8 20
p.completion "Proj1/Program.fs" 4 23
p.completion "Proj1/Program.fs" 6 14
p.completion "Proj1/Program.fs" 10 20

p.parse "Proj2/Core.fs"
p.parse "Proj2/Program.fs"
p.completion "Proj2/Program.fs" 8 19
p.completion "Proj2/Program.fs" 4 22
p.completion "Proj2/Program.fs" 6 13
p.completion "Proj2/Program.fs" 10 19
p.completion "Proj2/Program.fs" 8 20
p.completion "Proj2/Program.fs" 4 23
p.completion "Proj2/Program.fs" 6 14
p.completion "Proj2/Program.fs" 10 20

p.send "quit\n"
p.finalOutput ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ File.Delete "output.txt"
let p = new FSharpAutoCompleteWrapper()

p.parse "Script.fsx"
p.completion "Script.fsx" 6 17
p.completion "Script.fsx" 6 16
p.completion "Script.fsx" 6 15
p.tooltip "Script.fsx" 6 13
p.tooltip "Script.fsx" 6 14
p.tooltip "Script.fsx" 6 15
p.tooltip "Script.fsx" 6 16
p.finddeclaration "Script.fsx" 6 13
p.tooltip "Script.fsx" 6 17
p.finddeclaration "Script.fsx" 6 14
p.finddeclaration "Script.fsx" 6 15
p.finddeclaration "Script.fsx" 6 16
p.finddeclaration "Script.fsx" 6 17

p.send "quit\n"
p.finalOutput ()
Expand Down
12 changes: 6 additions & 6 deletions FSharp.AutoComplete/test/integration/RawIdTest/Runner.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ let p = new FSharpAutoCompleteWrapper()

p.parse "Test-Module.fsx"
p.parse "Test-Class.fsx"
p.completion "Test-Module.fsx" 9 2
p.completion "Test-Module.fsx" 11 12
p.completion "Test-Module.fsx" 13 13
p.completion "Test-Class.fsx" 9 2
p.completion "Test-Class.fsx" 11 12
p.completion "Test-Class.fsx" 13 13
p.completion "Test-Module.fsx" 9 3
p.completion "Test-Module.fsx" 11 13
p.completion "Test-Module.fsx" 13 14
p.completion "Test-Class.fsx" 9 3
p.completion "Test-Class.fsx" 11 13
p.completion "Test-Class.fsx" 13 14
p.send "quit\n"
p.finalOutput ()
|> writeNormalizedOutput "output.txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ File.Delete "completenosuchfile.txt"
let p = new FSharpAutoCompleteWrapper()

p.project "Project/Test1.fsproj"
p.completion "NoSuchFile.fs" 0 0
p.completion "NoSuchFile.fs" 1 1
p.send "quit\n"
p.finalOutput ()
|> writeNormalizedOutput "completenosuchfile.txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ File.Delete "completewithoutproject.txt"
let p = new FSharpAutoCompleteWrapper()

p.parse "Project/Script.fsx"
p.completion "Project/Script.fsx" 6 13
p.completion "Project/Script.fsx" 6 14
p.parse "Project/Program.fs"
p.completion "Project/Program.fs" 4 22
p.completion "Project/Program.fs" 4 23
p.send "quit\n"
p.finalOutput ()
|> writeNormalizedOutput "completewithoutproject.txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ File.Delete "output.txt"
let p = new FSharpAutoCompleteWrapper()

p.parse "Script.fsx"
p.tooltip "Script.fsx" 6 13
p.tooltip "Script.fsx" 6 14
p.tooltip "Script.fsx" 6 15
p.tooltip "Script.fsx" 6 16
Expand All @@ -28,9 +27,10 @@ p.tooltip "Script.fsx" 6 23
p.tooltip "Script.fsx" 6 24
p.tooltip "Script.fsx" 6 25
p.tooltip "Script.fsx" 6 26
p.tooltip "Script.fsx" 8 6
p.tooltip "Script.fsx" 8 10
p.tooltip "Script.fsx" 8 15
p.tooltip "Script.fsx" 6 27
p.tooltip "Script.fsx" 8 7
p.tooltip "Script.fsx" 8 11
p.tooltip "Script.fsx" 8 16
p.send "quit\n"
p.finalOutput ()
|> writeNormalizedOutput "output.txt"
Expand Down
19 changes: 10 additions & 9 deletions FSharp.AutoComplete/test/integration/Test1/Test1Runner.fsx
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env fsharpi --exec
#load "../TestHelpers.fsx"
open TestHelpers
open System.IO
Expand All @@ -17,15 +18,15 @@ p.project "Test1.fsproj"
p.parse "FileTwo.fs"
p.parse "Script.fsx"
p.parse "Program.fs"
p.completion "Script.fsx" 6 15
p.completion "Program.fs" 8 19
p.completion "Program.fs" 4 22
p.completion "Program.fs" 6 13
p.completion "Program.fs" 10 19
p.tooltip "FileTwo.fs" 9 6
p.tooltip "Program.fs" 6 15
p.tooltip "Program.fs" 4 8
p.tooltip "Script.fsx" 4 9
p.completion "Script.fsx" 6 16
p.completion "Program.fs" 8 20
p.completion "Program.fs" 4 23
p.completion "Program.fs" 6 14
p.completion "Program.fs" 10 20
p.tooltip "FileTwo.fs" 9 7
p.tooltip "Program.fs" 6 16
p.tooltip "Program.fs" 4 9
p.tooltip "Script.fsx" 4 10
p.declarations "Program.fs"
p.declarations "FileTwo.fs"
p.declarations "Script.fsx"
Expand Down
22 changes: 11 additions & 11 deletions FSharp.AutoComplete/test/integration/Test1Json/Test1JsonRunner.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ p.parse "FileTwo.fs"
p.parse "Script.fsx"
p.parse "Program.fs"
Threading.Thread.Sleep(8000)
p.completion "Script.fsx" 6 15
p.completion "Program.fs" 8 19
p.completion "Program.fs" 4 22
p.completion "Program.fs" 6 13
p.completion "Program.fs" 10 19
p.tooltip "FileTwo.fs" 9 6
p.tooltip "Program.fs" 6 15
p.tooltip "Program.fs" 4 8
p.tooltip "Script.fsx" 4 9
p.finddeclaration "Program.fs" 8 22
p.finddeclaration "Script.fsx" 6 15
p.completion "Script.fsx" 6 16
p.completion "Program.fs" 8 20
p.completion "Program.fs" 4 23
p.completion "Program.fs" 6 14
p.completion "Program.fs" 10 20
p.tooltip "FileTwo.fs" 9 7
p.tooltip "Program.fs" 6 16
p.tooltip "Program.fs" 4 9
p.tooltip "Script.fsx" 4 10
p.finddeclaration "Program.fs" 8 23
p.finddeclaration "Script.fsx" 6 16
p.declarations "Program.fs"
p.declarations "FileTwo.fs"
p.declarations "Script.fsx"
Expand Down
Loading

0 comments on commit ece8298

Please sign in to comment.