├── .gitattributes
├── .gitignore
├── .nuget
├── NuGet.Config
├── NuGet.exe
└── NuGet.targets
├── .paket
├── paket.bootstrapper.exe
└── paket.targets
├── LICENSE.md
├── Makefile
├── MonoDevelop.FSharp.Gui
├── FSharpCompilerOptionsWidget.cs
├── FSharpSettingsWidget.cs
├── MonoDevelop.FSharp.Gui.csproj
└── gtk-gui
│ ├── MonoDevelop.FSharp.Gui.FSharpCompilerOptionsWidget.cs
│ ├── MonoDevelop.FSharp.Gui.FSharpSettingsWidget.cs
│ ├── generated.cs
│ └── gui.stetic
├── MonoDevelop.FSharp.Shared
├── AssemblyInfo.fs
├── Completions.fs
├── Extensions.fs
├── FSharpSymbolHelper.fs
├── KeywordList.fs
├── Lexer.fs
├── MonoDevelop.FSharp.Shared.fsproj
├── ParameterHinting.fs
├── Parser.fs
└── paket.references
├── MonoDevelop.FSharp.Tests
├── Checker.fs
├── CompletionListsAdhocManualTests.fsx
├── CompletionTests.fs
├── DebuggerExpressionResolver.fs
├── FSharpUnitTestTextEditorExtensionTests.fs
├── GlobalSearch.fs
├── HighlightUsagesTests.fs
├── IndentationTrackerTests.fs
├── MonoDevelop.FSharp.Tests.fsproj
├── ParameterHinting.fs
├── ParsingTests.fs
├── ProjectCracking.fs
├── ProjectTests.fs
├── Samples
│ └── Xamarin.iOS.fsproj
├── Script.fsx
├── SemanticHighlighting.fs
├── SyntaxHighlighting.fs
├── TestBase.fs
├── TestDocument.fs
├── TestHelpers.fs
├── TestTooltipProvider.fs
├── TestViewContent.fs
├── TestWorkbenchWindow.fs
└── paket.references
├── MonoDevelop.FSharp.sln
├── MonoDevelop.FSharpBinding
├── CompilerService.exe.config
├── FSharpBinding.addin.xml
├── FSharpBraceMatcher.fs
├── FSharpDebuggerExpressionResolver.fs
├── FSharpFoldingParser.fs
├── FSharpFormatter.fs
├── FSharpFormattingPanelWidget.fs
├── FSharpFormattingPolicy.fs
├── FSharpFormattingPolicy.xml
├── FSharpFormattingPolicyPanel.fs
├── FSharpHighlightUsagesExtension.fs
├── FSharpIndentationTracker.fs
├── FSharpInteractivePad.fs
├── FSharpNavigationTextEditorExtension.fs
├── FSharpOptionsPanels.fs
├── FSharpOutlineTextEditorExtension.fs
├── FSharpParsedDocument.fs
├── FSharpParser.fs
├── FSharpPathExtension.fs
├── FSharpProject.fs
├── FSharpProjectFileNodeExtension.fs
├── FSharpResolverProvider.fs
├── FSharpStylePolicy.xml
├── FSharpSymbolHelper.fs
├── FSharpSyntaxMode.fs
├── FSharpSyntaxMode.xml
├── FSharpTextEditorCompletion.fs
├── FSharpTokens.fs
├── FSharpTooltipProvider.fs
├── FSharpUnitTestTextEditorExtension.fs
├── FakeSearchCategory.fs
├── MonoDevelop.FSharp.fsproj
├── ProjectSearchCategory.fs
├── Properties
│ └── AddinInfo.fs
├── RefactoringOperationsHandler.fs
├── Services
│ ├── CompilerArguments.fs
│ ├── CompilerLocationUtils.fs
│ ├── CompilerService.fs
│ ├── Extensions.fs
│ ├── FSharpConsoleView.fs
│ ├── FileService.fs
│ ├── InteractiveSession.fs
│ ├── LanguageService.fs
│ ├── Lexer.fs
│ ├── MDLanguageService.fs
│ ├── NRefactory.fs
│ ├── OrderAssemblyReferences.fs
│ ├── Parameters.fs
│ ├── Parser.fs
│ └── TooltipHelpers.fs
├── Templates
│ ├── AssemblyInfo.xft.xml
│ ├── EmptyFSharpScript.xft.xml
│ ├── EmptyFSharpSignature.xft.xml
│ ├── EmptyFSharpSource.xft.xml
│ ├── FSharp-templates.xml
│ ├── FSharpConsoleProject.xpt.xml
│ ├── FSharpGtkProject.xpt.xml
│ ├── FSharpLibraryProject.xpt.xml
│ ├── FSharpNUnitLibraryProject.xpt.xml
│ ├── FSharpNUnitTestType.xft.xml
│ ├── FSharpTutorialProject.xpt.xml
│ ├── PortableLibrary.xpt.xml
│ └── SharedAssetsProject.xpt.xml
├── UnformattedTextFileDescriptionTemplate.fs
├── paket.references
├── templates.AssemblyInfo.xft.xml
└── templates.targets
├── MonoDevelop.FSharpi.Service
├── AssemblyInfo.fs
├── MonoDevelop.FSharpInteractive.Service.fsproj
├── Program.fs
├── app.config
├── lib
│ └── FSharp.Compiler.Interactive.Settings.dll
└── paket.references
├── README.md
├── RELEASE_NOTES.md
├── addin-project.xml
├── build.cmd
├── build.fsx
├── build.sh
├── configure.sh
├── launch.bat
├── paket.dependencies
└── paket.lock
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
24 | *.sh text eol=lf
25 | *.fs text eol=lf
26 | Makefile.orig text eol=lf
27 | configure.sh text eol=lf
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # F#
2 | [Bb]in/
3 | [Oo]bj/
4 | .fake/
5 | monodevelop/pack/*
6 | monodevelop/packages/*
7 | monodevelop/build-and*
8 | repository/*
9 | *.suo
10 | *.pidb
11 | *.userprefs
12 | *.GhostDoc.xml
13 | *.user
14 | *.dll
15 | *.pdb
16 | *.cache
17 | *.swp
18 | *.swo
19 | *.swn
20 | *.pyc
21 | *.orig
22 | =======
23 | *~
24 | pack/*
25 |
26 | .DS_Store
27 |
28 | /packages
29 |
30 | /MonoDevelop.FSharp.Tests/tests
31 |
32 | .paket/paket.exe
33 |
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fsprojects/zarchive-xamarin-monodevelop-fsharp-addin/43dc90dbb354f06458dc7f48614716533f8735c6/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config"))
32 |
33 |
34 |
35 |
36 | $(SolutionDir).nuget
37 | packages.config
38 |
39 |
40 |
41 |
42 | $(NuGetToolsPath)\NuGet.exe
43 | @(PackageSource)
44 |
45 | "$(NuGetExePath)"
46 | mono --runtime=v4.0.30319 $(NuGetExePath)
47 |
48 | $(TargetDir.Trim('\\'))
49 |
50 | -RequireConsent
51 | -NonInteractive
52 |
53 | "$(SolutionDir) "
54 | "$(SolutionDir)"
55 |
56 |
57 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
58 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
59 |
60 |
61 |
62 | RestorePackages;
63 | $(BuildDependsOn);
64 |
65 |
66 |
67 |
68 | $(BuildDependsOn);
69 | BuildPackage;
70 |
71 |
72 |
73 |
74 |
75 |
76 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
91 |
92 |
95 |
96 |
97 |
98 |
100 |
101 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
133 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/.paket/paket.bootstrapper.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fsprojects/zarchive-xamarin-monodevelop-fsharp-addin/43dc90dbb354f06458dc7f48614716533f8735c6/.paket/paket.bootstrapper.exe
--------------------------------------------------------------------------------
/.paket/paket.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 |
7 | true
8 | $(MSBuildThisFileDirectory)
9 | $(MSBuildThisFileDirectory)..\
10 | /Library/Frameworks/Mono.framework/Commands/mono
11 | mono
12 |
13 |
14 |
15 | $(PaketToolsPath)paket.exe
16 | $(PaketToolsPath)paket.bootstrapper.exe
17 | "$(PaketExePath)"
18 | $(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"
19 | "$(PaketBootStrapperExePath)"
20 | $(MonoPath) --runtime=v4.0.30319 $(PaketBootStrapperExePath)
21 |
22 | $(MSBuildProjectDirectory)\paket.references
23 | $(MSBuildProjectFullPath).paket.references
24 | $(PaketCommand) restore --references-files "$(PaketReferences)"
25 | $(PaketBootStrapperCommand)
26 |
27 | RestorePackages; $(BuildDependsOn);
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for compiling, installing and packing F# MonoDevelop plugin on Mono
2 | #
3 | # run 'make' to compile the plugin against the installed version of MonoDevelop detected by ./configure.sh
4 | # run 'make install' to compile and install the plugin against the installed version of MonoDevelop detected by ./configure.sh
5 | # run 'make pack-all' to create a deployment binary packages for the known set of supported MonoDevelop versions
6 |
7 | VERSION=6.0.0
8 |
9 | MDTOOL = mono '../../build/bin/mdtool.exe'
10 |
11 | # (MDVERSION4) can be set to something like (3.0.4, 3.0.4.7) to compile
12 | # against the dependencies/... binaries for a specific version of MonoDevelop. This allows
13 | # us to prepare new editions of the binding for several different versions of MonoDevelop.
14 | MDVERSION4=6.0
15 |
16 | MDROOT=../../build
17 |
18 |
19 | # The default configuration is Release since Roslyn
20 | ifeq ($(config),)
21 | config=Release
22 | endif
23 |
24 | .PHONY: all
25 |
26 | all: build
27 |
28 | build: MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj MonoDevelop.FSharpBinding/FSharpBinding.addin.xml
29 | (xbuild MonoDevelop.FSharp.sln /p:Configuration=$(config))
30 |
31 | pack: build
32 | -rm -fr pack/$(config)
33 | @-mkdir -p pack/$(config)
34 | $(MDTOOL) setup pack bin/FSharpBinding.dll -d:pack/$(config)
35 |
36 | install: pack
37 | $(MDTOOL) setup install -y pack/$(config)/MonoDevelop.FSharpBinding_$(MDVERSION4).mpack
38 |
39 | uninstall:
40 | $(MDTOOL) setup uninstall MonoDevelop.FSharpBinding
41 |
42 | release:
43 | $(MAKE) config=Release pack
44 |
45 | clean:
46 | -rm -fr bin
47 | -rm -fr pack
48 | -rm -fr MonoDevelop.FSharpBinding/MonoDevelop.FSharp.*.fsproj
49 | -rm -fr MonoDevelop.FSharpBinding/obj
50 | (cd MonoDevelop.FSharp.Gui && xbuild MonoDevelop.FSharp.Gui.csproj /target:Clean)
51 |
52 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Gui/FSharpCompilerOptionsWidget.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace MonoDevelop.FSharp.Gui
3 | {
4 | [System.ComponentModel.ToolboxItem(true)]
5 | public partial class FSharpCompilerOptionsWidget : Gtk.Bin
6 | {
7 | public FSharpCompilerOptionsWidget ()
8 | {
9 | this.Build ();
10 | }
11 |
12 | public Gtk.Entry EntryCommandLine { get { return this.entryCustomParameters; } }
13 | public Gtk.Entry EntryDefines { get { return this.entryDefines; } }
14 | public Gtk.CheckButton CheckOptimize { get { return this.checkOptimize; } }
15 | public Gtk.CheckButton CheckTailCalls { get { return this.checkTailCalls; } }
16 | public Gtk.CheckButton CheckXmlDocumentation { get { return this.checkXmlDocumentation; } }
17 | public Gtk.ComboBox ComboDebugInformation { get { return this.comboboxDebugInformation; } }
18 | public Gtk.CheckButton CheckDebugInformation { get { return this.checkGenerateDebugInformation; } }
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Gui/FSharpSettingsWidget.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace MonoDevelop.FSharp.Gui
3 | {
4 | [System.ComponentModel.ToolboxItem(true)]
5 | public partial class FSharpSettingsWidget : Gtk.Bin
6 | {
7 | public FSharpSettingsWidget ()
8 | {
9 | this.Build ();
10 | }
11 |
12 | public Gtk.CheckButton CheckInteractiveUseDefault { get { return checkInteractiveUseDefault; } }
13 | public Gtk.Button ButtonBrowse { get { return buttonBrowse; } }
14 | public Gtk.Entry EntryArguments { get { return entryArguments; } }
15 | public Gtk.CheckButton AdvanceLine { get { return advanceToNextLineCheckbox; } }
16 | public Gtk.Entry EntryPath { get { return entryPath; } }
17 | public Gtk.FontButton FontInteractive { get { return fontbutton1; } }
18 | public Gtk.CheckButton MatchThemeCheckBox { get { return matchThemeCheckbox; } }
19 | public Gtk.HBox ColorsHBox { get { return hbox7; } }
20 | public Gtk.ColorButton BaseColorButton { get { return baseColorButton; } }
21 | public Gtk.ColorButton TextColorButton { get { return textColorButton; } }
22 | public Gtk.CheckButton CheckCompilerUseDefault { get { return checkCompilerUseDefault; } }
23 | public Gtk.Button ButtonCompilerBrowse { get { return buttonCompilerBrowse; } }
24 | public Gtk.Entry EntryCompilerPath { get { return entryCompilerPath; } }
25 | public Gtk.CheckButton CheckHighlightMutables { get { return checkHighlightMutables; } }
26 |
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Gui/MonoDevelop.FSharp.Gui.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {FD0D1033-9145-48E5-8ED8-E2365252878C}
9 | Library
10 | FSharpBinding.Gui
11 | MonoDevelop.FSharp.Gui
12 | v4.5
13 |
14 |
15 |
16 | True
17 | full
18 | False
19 | ..\bin\
20 | prompt
21 | 4
22 | True
23 |
24 |
25 | none
26 | True
27 | ..\bin\
28 | prompt
29 | 4
30 | True
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | gui.stetic
47 | Designer
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Gui/gtk-gui/generated.cs:
--------------------------------------------------------------------------------
1 |
2 | // This file has been generated by the GUI designer. Do not modify.
3 | namespace Stetic
4 | {
5 | internal class Gui
6 | {
7 | private static bool initialized;
8 |
9 | internal static void Initialize (Gtk.Widget iconRenderer)
10 | {
11 | if ((Stetic.Gui.initialized == false)) {
12 | Stetic.Gui.initialized = true;
13 | }
14 | }
15 | }
16 |
17 | internal class BinContainer
18 | {
19 | private Gtk.Widget child;
20 |
21 | private Gtk.UIManager uimanager;
22 |
23 | public static BinContainer Attach (Gtk.Bin bin)
24 | {
25 | BinContainer bc = new BinContainer ();
26 | bin.SizeRequested += new Gtk.SizeRequestedHandler (bc.OnSizeRequested);
27 | bin.SizeAllocated += new Gtk.SizeAllocatedHandler (bc.OnSizeAllocated);
28 | bin.Added += new Gtk.AddedHandler (bc.OnAdded);
29 | return bc;
30 | }
31 |
32 | private void OnSizeRequested (object sender, Gtk.SizeRequestedArgs args)
33 | {
34 | if ((this.child != null)) {
35 | args.Requisition = this.child.SizeRequest ();
36 | }
37 | }
38 |
39 | private void OnSizeAllocated (object sender, Gtk.SizeAllocatedArgs args)
40 | {
41 | if ((this.child != null)) {
42 | this.child.Allocation = args.Allocation;
43 | }
44 | }
45 |
46 | private void OnAdded (object sender, Gtk.AddedArgs args)
47 | {
48 | this.child = args.Widget;
49 | }
50 |
51 | public void SetUiManager (Gtk.UIManager uim)
52 | {
53 | this.uimanager = uim;
54 | this.child.Realized += new System.EventHandler (this.OnRealized);
55 | }
56 |
57 | private void OnRealized (object sender, System.EventArgs args)
58 | {
59 | if ((this.uimanager != null)) {
60 | Gtk.Widget w;
61 | w = this.child.Toplevel;
62 | if (((w != null)
63 | && typeof(Gtk.Window).IsInstanceOfType (w))) {
64 | ((Gtk.Window)(w)).AddAccelGroup (this.uimanager.AccelGroup);
65 | this.uimanager = null;
66 | }
67 | }
68 | }
69 | }
70 |
71 | internal class ActionGroups
72 | {
73 | public static Gtk.ActionGroup GetActionGroup (System.Type type)
74 | {
75 | return Stetic.ActionGroups.GetActionGroup (type.FullName);
76 | }
77 |
78 | public static Gtk.ActionGroup GetActionGroup (string name)
79 | {
80 | return null;
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Shared/AssemblyInfo.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelop.FSharp.Shared
2 | open System.Reflection
3 | open System.Runtime.CompilerServices
4 |
5 | []
6 | []
7 | []
8 | []
9 | []
10 | []
11 | []
12 |
13 | // The assembly version has the format {Major}.{Minor}.{Build}.{Revision}
14 |
15 | []
16 |
17 | //[]
18 | //[]
19 |
20 | ()
21 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug
4 | AnyCPU
5 | 8.0.30703
6 | 2.0
7 | {AF5FEAD5-B50E-4F07-A274-32F23D5C504D}
8 | Library
9 | MonoDevelop.FSharp.Shared
10 | MonoDevelop.FSharp.Shared
11 | v4.5
12 | 4.4.0.0
13 |
14 |
15 | true
16 | full
17 | false
18 | bin\Debug
19 | DEBUG
20 | prompt
21 | false
22 |
23 |
24 |
25 | true
26 | bin\Release
27 |
28 | prompt
29 | false
30 | true
31 |
32 |
33 |
34 |
35 |
36 | True
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets
57 |
58 |
59 | $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | ..\packages\ExtCore\lib\net40\ExtCore.dll
68 | True
69 | True
70 |
71 |
72 |
73 |
74 |
75 |
76 | ..\packages\ExtCore\lib\net45\ExtCore.dll
77 | True
78 | True
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | ..\packages\FSharp.Compiler.Service\lib\net40\FSharp.Compiler.Service.dll
88 | True
89 | True
90 |
91 |
92 |
93 |
94 |
95 |
96 | ..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll
97 | True
98 | True
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Shared/ParameterHinting.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelop.FSharp.Shared
2 | open Microsoft.FSharp.Compiler.SourceCodeServices
3 |
4 | module ParameterHinting =
5 | let getTooltipInformation (symbol: FSharpSymbolUse) =
6 | match symbol with
7 | | MemberFunctionOrValue m ->
8 | let parameters =
9 | match m.CurriedParameterGroups |> Seq.toList with
10 | | [single] ->
11 | single
12 | |> Seq.map (fun param ->
13 | match param.Name with
14 | | Some n -> n
15 | | _ -> param.DisplayName)
16 | |> List.ofSeq
17 | | _ -> []
18 | let signature = SymbolTooltips.getFuncSignatureWithFormat symbol.DisplayContext m {Indent=3;Highlight=None}
19 | let summary = SymbolTooltips.getSummaryFromSymbol m
20 | ParameterTooltip.ToolTip (signature, summary, parameters)
21 | | _ -> ParameterTooltip.EmptyTip
22 |
23 | let parameterCount (symbol: FSharpSymbol) =
24 | match symbol with
25 | | :? FSharpMemberOrFunctionOrValue as fsm ->
26 | let cpg = fsm.CurriedParameterGroups
27 | cpg.[0].Count
28 | | _ -> 0
29 |
30 | let isParameterListAllowed (symbol: FSharpSymbol) =
31 | match symbol with
32 | | :? FSharpMemberOrFunctionOrValue as fsm
33 | when fsm.CurriedParameterGroups.Count > 0 ->
34 | //TODO: How do we handle non tupled arguments?
35 | let group = fsm.CurriedParameterGroups.[0]
36 | if group.Count > 0 then
37 | let last = group |> Seq.last
38 | last.IsParamArrayArg
39 | else
40 | false
41 | | _ -> false
42 |
43 | let getParameterName (symbol: FSharpSymbol) i =
44 | match symbol with
45 | | :? FSharpMemberOrFunctionOrValue as fsm
46 | when fsm.CurriedParameterGroups.Count > 0 &&
47 | fsm.CurriedParameterGroups.[0].Count > 0 ->
48 | //TODO: How do we handle non tupled arguments?
49 | let group = fsm.CurriedParameterGroups.[0]
50 | let param = group.[i]
51 | match param.Name with
52 | | Some n -> n
53 | | None -> param.DisplayName
54 | | _ -> ""
55 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Shared/Parser.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelop.FSharp.Shared
2 | open System
3 | open Microsoft.FSharp.Compiler.SourceCodeServices
4 | open Microsoft.FSharp.Compiler
5 | open System.Globalization
6 |
7 | // --------------------------------------------------------------------------------------
8 | /// Parsing utilities for IntelliSense (e.g. parse identifier on the left-hand side
9 | /// of the current cursor location etc.)
10 | module Parsing =
11 | let inline private tryGetLexerSymbolIslands sym =
12 | match sym.Text with "" -> None | _ -> Some (sym.RightColumn, sym.Text.Split '.' |> Array.toList)
13 |
14 | // Parsing - find the identifier around the current location
15 | // (we look for full identifier in the backward direction, but only
16 | // for a short identifier forward - this means that when you hover
17 | // 'B' in 'A.B.C', you will get intellisense for 'A.B' module)
18 | let findIdents col lineStr lookupType =
19 | if lineStr = "" then None
20 | else
21 | Lexer.getSymbol lineStr 0 col lineStr lookupType [||] Lexer.singleLineQueryLexState
22 | |> Option.bind tryGetLexerSymbolIslands
23 |
24 | let findLongIdentsAndResidue (col, lineStr:string) =
25 | let lineStr = lineStr.Substring(0, col)
26 |
27 | match Lexer.getSymbol lineStr 0 col lineStr SymbolLookupKind.ByLongIdent [||] Lexer.singleLineQueryLexState with
28 | | Some sym ->
29 | match sym.Text with
30 | | "" -> [], ""
31 | | text ->
32 | let res = text.Split '.' |> List.ofArray |> List.rev
33 | if lineStr.[col - 1] = '.' then res |> List.rev, ""
34 | else
35 | match res with
36 | | head :: tail -> tail |> List.rev, head
37 | | [] -> [], ""
38 | | _ -> [], ""
39 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Shared/paket.references:
--------------------------------------------------------------------------------
1 | ExtCore
2 | FSharp.Compiler.Service
3 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/Checker.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open System
3 | open System.IO
4 | open NUnit.Framework
5 | open FsUnit
6 | open System.Reflection
7 | open MonoDevelop.FSharp
8 | open MonoDevelop.Projects
9 |
10 | type TestPlatform =
11 | | Windows = 0
12 | | Mono = 1
13 |
14 | //[]
15 | type CompilerArgumentsTests() =
16 |
17 | member private x.``Run Only mscorlib referenced`` (assemblyName) =
18 | use testProject = Services.ProjectService.CreateDotNetProject ("F#")
19 | let assemblyName = match assemblyName with Fqn a -> fromFqn a | File a -> a
20 | let _ = testProject.AddReference assemblyName
21 | let references =
22 | CompilerArguments.generateReferences(testProject,
23 | Some (FSharpCompilerVersion.FSharp_3_1),
24 | FSharpTargetFramework.NET_4_5,
25 | ConfigurationSelector.Default,
26 | true)
27 |
28 | //there should be two references
29 | references.Length |> should equal 3
30 |
31 | //The two paths for mscorlib and FSharp.Core should match
32 | let makeTestableReference (path: string) =
33 | let path = path.Substring(4)
34 | let path = path.Substring(0,path.Length - 1)
35 | path
36 | let testPaths = references |> List.map makeTestableReference
37 | match testPaths |> List.map Path.GetDirectoryName with
38 | | [one; two; three] -> ()//one |> should equal three
39 | | _ -> Assert.Fail("Too many references returned")
40 |
41 | member private x.``Run Only FSharp.Core referenced``(assemblyName) =
42 | use testProject = Services.ProjectService.CreateDotNetProject ("F#")
43 | let assemblyName = match assemblyName with Fqn a -> fromFqn a | File a -> a
44 | let reference = testProject.AddReference assemblyName
45 | let references =
46 | CompilerArguments.generateReferences(testProject,
47 | Some (FSharpCompilerVersion.FSharp_3_1),
48 | FSharpTargetFramework.NET_4_5,
49 | ConfigurationSelector.Default,
50 | false)
51 |
52 | //there should be two references
53 | references.Length |> should equal 3
54 |
55 | //find the mscorlib inside the FSharp.Core ref
56 | let mscorlibContained =
57 | let assemblyDef = Mono.Cecil.AssemblyDefinition.ReadAssembly(reference.HintPath.ToString())
58 | match assemblyDef.MainModule.AssemblyReferences |> Seq.tryFind (fun name -> name.Name = "mscorlib") with
59 | |Some name ->
60 | let resolved = assemblyDef.MainModule.AssemblyResolver.Resolve(name)
61 | Some(Path.neutralise resolved.MainModule.FullyQualifiedName)
62 | | None -> None
63 |
64 | //find the mscorlib from the returned references (removing unwanted chars "" / \ etc)
65 | let mscorlibReferenced =
66 | references
67 | |> List.tryFind (fun ref -> ref.Contains("mscorlib"))
68 | |> Option.map (fun r -> Path.neutralise (r.Replace("-r:", "")))
69 |
70 | mscorlibContained |> should equal mscorlibReferenced
71 |
72 | //[]
73 | //[]
74 | //[]
75 | //[]
76 | []
77 | member x.``Only mscorlib referenced`` (platform, assemblyName:string) =
78 | match platform with
79 | | TestPlatform.Mono when MonoDevelop.Core.Platform.IsWindows -> ()
80 | | TestPlatform.Mono -> x.``Run Only mscorlib referenced`` (assemblyName)
81 | | TestPlatform.Windows when not MonoDevelop.Core.Platform.IsWindows -> ()
82 | | TestPlatform.Windows -> x.``Run Only mscorlib referenced`` (assemblyName)
83 | | _ -> ()
84 |
85 |
86 | //[]
87 | //[]
88 | //[]
89 | //[]
90 | //[]
91 | []
92 | member x.``Only FSharp.Core referenced`` (platform: TestPlatform, assemblyName:string) =
93 | match platform with
94 | | TestPlatform.Mono when MonoDevelop.Core.Platform.IsWindows -> ()
95 | | TestPlatform.Mono -> x.``Run Only FSharp.Core referenced``(assemblyName)
96 | | TestPlatform.Windows when not MonoDevelop.Core.Platform.IsWindows -> ()
97 | | TestPlatform.Windows -> x.``Run Only FSharp.Core referenced``(assemblyName)
98 | | _ -> ()
99 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/CompletionListsAdhocManualTests.fsx:
--------------------------------------------------------------------------------
1 |
2 | // This file is a set of manual tests you can run through to test the quality of
3 | // autocomplete, quick info and parameter info.
4 |
5 |
6 | open System
7 |
8 | open System // press '.' here. Only namespaces should appear.
9 |
10 | //----------------------------------------------------
11 | // Check some basic completions and declaration lists
12 |
13 | System // press 'space' here
14 |
15 | System.Math.Max(3,4) // press '.' here
16 |
17 | System.Char
18 |
19 | System.
20 | List.
21 | System.Application
22 | System.Console.Wr // check formatting of description here
23 |
24 | let test1 (x: System.Applicati (* complete here *) ) = ()
25 |
26 | Array.map
27 |
28 | List.a // Ctrl-space completion here
29 |
30 | System.C // Ctrl-space completion here
31 |
32 | //System.Math.Max(3,4).CompareTo // BUG press '(' here
33 |
34 | //----------------------------------------------------
35 | // Check performance
36 |
37 | System // press '.' here - should be instantaneous
38 |
39 | System.Console.WriteLine // type through this line
40 |
41 | Microsoft.FSharp.Collections.Array.append // type through this line
42 |
43 |
44 | //------------------------------------------------------
45 | // check that type providers give parameter info
46 |
47 | #r "/Users/tomaspetricek/Projects/GitHub/fsharp/FSharp.Data/bin/FSharp.Data.dll"
48 |
49 | type X = FSharp.Data.CsvProvider // press '<' here
50 |
51 | //------------------------------------------------------
52 | // check parameter info
53 |
54 | Console.WriteLine // press '(' here, parameter/method/overloads info should appear
55 | b
56 | List.map // press '(' here, parameter/method info should appear
57 |
58 | Console.WriteLine(Console.WriteLine(), // press ',' here
59 |
60 | //-------------------------------------------------------
61 | // Check some experession typings
62 |
63 |
64 | ("") // press '.' here, expect string menu
65 | ("").Length // press '.' here, expect int32 menu
66 |
67 | let x = ""
68 | let y = (x) // press '.' here, expect string menu
69 |
70 | let a = (x). (* press '.' before here *) + (x)
71 |
72 | []
73 | let main args =
74 | Console.WriteLine("Hello world!")
75 | 0
76 |
77 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/CompletionTests.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 |
3 | open System
4 | open NUnit.Framework
5 | open MonoDevelop.FSharp
6 | open Mono.TextEditor
7 | open MonoDevelop.Ide.Editor
8 | open MonoDevelop.Ide.CodeCompletion
9 | open FsUnit
10 | open MonoDevelop
11 |
12 | type ``Completion Tests``() =
13 | let getParseResults (documentContext:DocumentContext, _text) =
14 | async {
15 | return documentContext.TryGetAst()
16 | }
17 |
18 | let getCompletions (input: string) =
19 | let offset = input.LastIndexOf "|"
20 | if offset = -1 then
21 | failwith "Input must contain a |"
22 | let input = input.Remove(offset, 1)
23 | let doc = TestHelpers.createDoc input "defined"
24 | let editor = doc.Editor
25 | editor.CaretOffset <- offset
26 | let ctx = new CodeCompletionContext()
27 | ctx.TriggerOffset <- offset
28 | let results =
29 | Completion.codeCompletionCommandImpl(editor, doc, ctx, false)
30 | |> Async.RunSynchronously
31 | |> Seq.map (fun c -> c.DisplayText)
32 |
33 | results |> Seq.toList
34 |
35 | []
36 | member x.``Completes namespace``() =
37 | let results = getCompletions "open System.Text.|"
38 | results |> should contain "RegularExpressions"
39 |
40 | []
41 | member x.``Completes local identifier``() =
42 | let results = getCompletions
43 | """
44 | module mymodule =
45 | let completeme = 1
46 | let x = compl|
47 | """
48 |
49 | results |> should contain "completeme"
50 |
51 | []
52 | []
53 | []
54 | []
55 | []
56 | []
57 | []
58 | //[]
59 | []
60 | []
61 | []
62 | []
63 | []
64 | []
65 | []
66 | member x.``Empty completions``(input: string) =
67 | let results = getCompletions input
68 | results |> should be Empty
69 |
70 | []
71 | []
72 | []
73 | []
74 | member x.``Not empty completions``(input: string) =
75 | let results = getCompletions input
76 | results |> shouldnot be Empty
77 |
78 | []
79 | member x.``Keywords don't appear after dot``() =
80 | let results = getCompletions @"let x = string.l|"
81 | results |> shouldnot contain "let"
82 |
83 | []
84 | member x.``Keywords appear after whitespace``() =
85 | let results = getCompletions @" l|"
86 | results |> should contain "let"
87 |
88 | []
89 | member x.``Keywords appear at start of line``() =
90 | let results = getCompletions @" l|"
91 | results |> should contain "let"
92 |
93 | []
94 | member x.``Keywords appear at column 0``() =
95 | let results = getCompletions @"o|"
96 | results |> should contain "open"
97 |
98 | []
99 | member x.``Keywords can be parameters``() =
100 | let results = getCompletions @"let x = new System.IO.FileInfo(n|"
101 | results |> should contain "null"
102 |
103 | []
104 | member x.``Completes modifiers``() =
105 | let results = getCompletions @"let mut|"
106 | results |> should contain "mutable"
107 |
108 | []
109 | member x.``Completes lambda``() =
110 | let results = getCompletions @"let x = ""string"" |> Seq.map (fun c -> c.|"
111 | results |> should contain "ToString"
112 | results |> shouldnot contain "mutable"
113 |
114 | []
115 | member x.``Completes local identifier with mismatched parens``() =
116 | let identifier = 1
117 |
118 | let results = getCompletions
119 | """
120 | type rectangle(width, height) =
121 | class end
122 |
123 | module s =
124 | let height = 10
125 | let x = rectangle(he|
126 | """
127 | results |> should contain "height"
128 |
129 | []
130 | member x.``Completes attribute``() =
131 | let input =
132 | """
133 | type TestAttribute() =
134 | inherit System.Attribute()
135 |
136 | type TestCaseAttribute() =
137 | inherit TestAttribute()
138 | [ should contain "Test"
142 | results |> should contain "TestCase"
143 | results |> shouldnot contain "Array"
144 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/DebuggerExpressionResolver.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open System
3 | open NUnit.Framework
4 | open MonoDevelop.FSharp
5 | open FsUnit
6 | open MonoDevelop.Debugger
7 |
8 | []
9 | type DebuggerExpressionResolver() =
10 |
11 | let content =
12 | """
13 | type TestOne() =
14 | member val PropertyOne = "42" with get, set
15 | member x.FunctionOne(parameter) = ()
16 |
17 | let local|One = TestOne()
18 | let local|Two = localOne.Prope|rtyOne
19 | let localThree = local|One.PropertyOne
20 | let localFour = localOne.Property|One"""
21 |
22 | let getOffset expr =
23 | let startOffset = content.IndexOf (expr, StringComparison.Ordinal)
24 | let previousMarkers =
25 | content
26 | |> String.toArray
27 | |> Array.findIndices((=) '|')
28 | |> Array.filter(fun i -> i < startOffset-1)
29 | |> Array.length
30 | let offset = content.IndexOf('|',startOffset) - previousMarkers
31 | offset
32 |
33 | let resolveExpression (doc:TestDocument, content:string, offset:int) =
34 | let resolver = new FSharpDebuggerExpressionResolver() :> IDebuggerExpressionResolver
35 | Async.AwaitTask (resolver.ResolveExpressionAsync(doc.Editor, doc, offset, Async.DefaultCancellationToken))
36 | |> Async.RunSynchronously
37 |
38 | []
39 | []
40 | []
41 | []
42 | []
43 | member x.TestBasicLocalVariable(localVariable, expected) =
44 | let basicOffset = getOffset (localVariable)
45 | let doc = TestHelpers.createDoc (content.Replace("|" ,"")) ""
46 |
47 | let loc = doc.Editor.OffsetToLocation basicOffset
48 | let lineTxt = doc.Editor.GetLineText(loc.Line, false)
49 | let markedLine = (String.replicate loc.Column " " + "^" )
50 | System.Console.WriteLine(sprintf "%s\n%s" lineTxt markedLine)
51 |
52 | let debugDataTipInfo = resolveExpression (doc, content, basicOffset)
53 | debugDataTipInfo.Text |> should equal expected
54 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/FSharpUnitTestTextEditorExtensionTests.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open System
3 | open NUnit.Framework
4 | open MonoDevelop.FSharp
5 | open FsUnit
6 |
7 | []
8 | type FSharpUnitTestTextEditorExtensionTests() =
9 | let gatherTests (text:string) =
10 | let editor = TestHelpers.createDoc text ""
11 | let ast = editor.Ast
12 | let symbols = ast.GetAllUsesOfAllSymbolsInFile() |> Async.RunSynchronously
13 |
14 | unitTestGatherer.gatherUnitTests (editor.Editor, symbols)
15 | |> Seq.toList
16 |
17 | let gatherTestsWithReference (text:string) =
18 | let attributes = """
19 | namespace NUnit.Framework
20 | open System
21 | type TestAttribute =
22 | inherit Attribute
23 | new() = { inherit Attribute() }
24 | new(name) = { inherit Attribute() }
25 | type TestFixtureAttribute() =
26 | inherit Attribute()
27 | type IgnoreAttribute() =
28 | inherit Attribute()
29 | type TestCaseAttribute =
30 | inherit TestAttribute
31 | new() = { inherit Attribute() }
32 | new(name) = { inherit Attribute() }
33 | """
34 | gatherTests (attributes + text)
35 |
36 | []
37 | member x.BasicTestCoveringNormalAndDoubleQuotedTestsInATestFixture () =
38 | let normalAndDoubleTick = """
39 | open System
40 | open NUnit.Framework
41 | []
42 | type Test() =
43 | []
44 | member x.TestOne() = ()
45 |
46 | []
47 | []
48 | member x.``Test Two``() = ()
49 | """
50 | let res = gatherTestsWithReference normalAndDoubleTick
51 | match res with
52 | | [fixture;t1;t2] ->
53 | fixture.IsFixture |> should equal true
54 | fixture.UnitTestIdentifier |> should equal "NUnit.Framework.Test"
55 |
56 | t1.UnitTestIdentifier |> should equal "NUnit.Framework.Test.TestOne"
57 | t1.IsIgnored |> should equal false
58 |
59 | t2.UnitTestIdentifier |> should equal "NUnit.Framework.Test.``Test Two``"
60 | t2.IsIgnored |> should equal true
61 | | _ -> NUnit.Framework.Assert.Fail "invalid number of tests returned"
62 |
63 | []
64 | member x.NoTests () =
65 | let noTests = """
66 | open System
67 | open NUnit.Framework
68 |
69 | type Test() =
70 | member x.TestOne() = ()
71 | """
72 |
73 | let tests = gatherTestsWithReference noTests
74 | tests.Length |> should equal 0
75 |
76 | []
77 | member x.``Module tests without TestFixtureAttribute are detected`` () =
78 | let noTests = """
79 | module someModule =
80 |
81 | open NUnit.Framework
82 |
83 | []
84 | let atest () =
85 | ()
86 | """
87 |
88 | let tests = gatherTestsWithReference noTests
89 | tests.Length |> should equal 1
90 |
91 | []
92 | member x.NestedTestCoveringNormalAndDoubleQuotedTestsInATestFixture () =
93 | let nestedTests = """
94 | open System
95 | open NUnit.Framework
96 | module Test =
97 | []
98 | type Test() =
99 | []
100 | member x.TestOne() = ()
101 |
102 | []
103 | []
104 | member x.``Test Two``() = ()
105 | """
106 | let tests = gatherTestsWithReference nestedTests
107 |
108 | match tests with
109 | | [fixture;t1;t2] ->
110 | fixture.IsFixture |> should equal true
111 | fixture.UnitTestIdentifier |> should equal "NUnit.Framework.Test+Test"
112 |
113 | t1.UnitTestIdentifier |> should equal "NUnit.Framework.Test+Test.TestOne"
114 | t1.IsIgnored |> should equal false
115 |
116 | t2.UnitTestIdentifier |> should equal "NUnit.Framework.Test+Test.``Test Two``"
117 | t2.IsIgnored |> should equal true
118 | | _ -> NUnit.Framework.Assert.Fail "invalid number of tests returned"
119 |
120 | []
121 | member x.TestsPresentButNoNUnitReference () =
122 | let normalAndDoubleTick = """
123 | open System
124 | open NUnit.Framework
125 | []
126 | type Test() =
127 | []
128 | member x.TestOne() = ()
129 |
130 | []
131 | []
132 | member x.``Test Two``() = ()
133 | """
134 | let tests = gatherTests normalAndDoubleTick
135 |
136 | tests.Length |> should equal 0
137 |
138 | []
139 | member x.``Test cases`` () =
140 | let nestedTests = """
141 | open System
142 | open NUnit.Framework
143 | module Test =
144 | []
145 | type Test() =
146 | []
147 | member x.TestOne(s:string) = ()
148 | """
149 | let tests = gatherTestsWithReference nestedTests
150 |
151 | match tests with
152 | | [fixture;t1] ->
153 | t1.UnitTestIdentifier |> should equal "NUnit.Framework.Test+Test.TestOne"
154 | t1.IsIgnored |> should equal false
155 | | _ -> NUnit.Framework.Assert.Fail "invalid number of tests returned"
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/GlobalSearch.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open System.Collections.Generic
3 | open Microsoft.FSharp.Compiler.SourceCodeServices
4 | open NUnit.Framework
5 | open FsUnit
6 | open MonoDevelop.FSharp
7 |
8 | []
9 | type TestGlobalSearch() =
10 |
11 |
12 | let input = """
13 | module Test
14 | let (++) a b = a + b
15 | let (|Full|Empty|) x = if x = "" then Empty else Full
16 | type MyRecord = {Test : int}
17 | type MyType() =
18 | member x.Foo = 42
19 | member x.Bar() = 43
20 | type MyUnion = First of int
21 |
22 | []
23 | type MyPoint3D =
24 | val x: float
25 | val y: float
26 | val z: float
27 |
28 | type IMyInterface =
29 | abstract member Test : int -> int
30 |
31 | type MyEnum = First = 1 | Second = 2
32 |
33 | type MyDelegate = delegate of (int * int) -> int
34 | """
35 | let searchByTag tag =
36 | match TestHelpers.getAllSymbols input with
37 | | Some xs ->
38 | let tags = Search.byTag tag xs
39 | tags
40 | |> Seq.map(fun s -> s.Symbol.DisplayName)
41 | |> Seq.toList
42 | | _ -> []
43 |
44 | []
45 | member x.Operators_Can_Be_Filtered() =
46 | searchByTag "op" |> shouldEqual ["( + )"; "( ++ )"; "( = )"] // ( + ) and ( = ) aren't user defined operators
47 |
48 | []
49 | member x.ActivePatterns_Can_Be_Filtered() =
50 | searchByTag "ap" |> shouldEqual ["( |Full|Empty| )"]
51 |
52 | []
53 | member x.Records_Can_Be_Filtered() =
54 | searchByTag "r" |> shouldEqual ["MyRecord"]
55 |
56 | []
57 | []
58 | []
59 | member x.Types_Can_Be_Filtered(search) =
60 | searchByTag search |> shouldEqual ["MyType"; "StructAttribute"; "StructAttribute"] // needs fixing
61 |
62 | []
63 | member x.Unions_Can_Be_Filtered() =
64 | searchByTag "u" |> shouldEqual ["MyUnion"]
65 |
66 | []
67 | member x.Modules_Can_Be_Filtered() =
68 | searchByTag "mod" |> shouldEqual ["Test"]
69 |
70 | []
71 | member x.Structs_Can_Be_Filtered() =
72 | searchByTag "s" |> shouldEqual ["MyPoint3D"]
73 |
74 | []
75 | member x.Interfaces_Can_Be_Filtered() =
76 | searchByTag "i" |> shouldEqual ["IMyInterface"]
77 |
78 | []
79 | member x.Enums_Can_Be_Filtered() =
80 | searchByTag "e" |> shouldEqual ["MyEnum"]
81 |
82 | []
83 | member x.Properties_Can_Be_Filtered() =
84 | searchByTag "p" |> shouldEqual ["Foo"]
85 |
86 | []
87 | member x.Members_Can_Be_Filtered() =
88 | searchByTag "m" |> shouldEqual ["Bar"; "Test"; "Invoke"] //Invoke?
89 |
90 | []
91 | member x.Fields_Can_Be_Filtered() =
92 | searchByTag "f" |> shouldEqual ["Test"; "x"; "y"; "z"; "First"; "Second"] //Test?
93 |
94 | []
95 | member x.Delegates_Can_Be_Filtered() =
96 | searchByTag "d" |> shouldEqual ["MyDelegate"]
97 |
98 | []
99 | member x.Search_By_Unique_Pattern_Is_Correct() =
100 | match TestHelpers.getAllSymbols input with
101 | | Some xs ->
102 | let result =
103 | Search.byPattern (Dictionary<_,_>()) "++" xs
104 | |> Seq.map (fun (a, b) -> a.Symbol.DisplayName )
105 | |> Seq.toList
106 | result |> shouldEqual ["( ++ )"]
107 | | _ -> Assert.Fail "Not found"
108 |
109 | []
110 | member x.Search_By_Pattern_Is_Correct() =
111 | match TestHelpers.getAllSymbols input with
112 | | Some xs ->
113 | let result = Search.byPattern (Dictionary<_,_>()) "My" xs
114 |
115 | result
116 | |> Seq.map (fun (a, b) -> a.Symbol.DisplayName, a.Symbol.GetType() )
117 | |> Seq.toList
118 | |> shouldEqual
119 | [ "MyRecord", typeof
120 | "MyType", typeof
121 | "( .ctor )", typeof
122 | "MyUnion", typeof
123 | "MyPoint3D", typeof
124 | "IMyInterface", typeof
125 | "MyEnum", typeof
126 | "MyDelegate", typeof ]
127 | | _ -> Assert.Fail "Not found"
128 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/HighlightUsagesTests.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open System.Text.RegularExpressions
3 | open System.Threading
4 | open NUnit.Framework
5 | open FsUnit
6 | open MonoDevelop.FSharp.MonoDevelop
7 | open MonoDevelop.FSharp
8 | open ExtCore
9 | open ExtCore.Control
10 | open ExtCore.Control.Collections
11 | []
12 | type HighlightUsagesTests() =
13 | let assertUsages (source:string, expectedCount) =
14 | let offset = source.IndexOf "|"
15 | let source = source.Replace("|", "")
16 | let doc = TestHelpers.createDoc source ""
17 | let line, col, lineStr = doc.Editor.GetLineInfoFromOffset offset
18 | //doc.Ast
19 |
20 | match Parsing.findIdents col lineStr SymbolLookupKind.ByLongIdent with
21 | | None -> Assert.Fail "Could not find ident"
22 | | Some(colu, ident) -> let symbolUse = doc.Ast.GetSymbolAtLocation(line, col, lineStr) |> Async.RunSynchronously
23 | match symbolUse with
24 | | Some symbol ->
25 | let references = doc.Ast.GetUsesOfSymbolInFile(symbol.Symbol) |> Async.RunSynchronously
26 | references.Length |> should equal expectedCount
27 | | None -> Assert.Fail "No symbol found"
28 |
29 | []
30 | member x.``Highlight usages from declaration``() =
31 | let source =
32 | """
33 | let ast|ring = "astring"
34 | let b = astring
35 | """
36 | assertUsages(source, 2)
37 |
38 | []
39 | member x.``Highlight usages from usage``() =
40 | let source =
41 | """
42 | let astring = "astring"
43 | let b = astr|ing
44 | """
45 | assertUsages(source, 2)
46 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/IndentationTrackerTests.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open NUnit.Framework
3 | open MonoDevelop.FSharp
4 | open FsUnit
5 | open Mono.TextEditor
6 |
7 | []
8 | type IndentationTrackerTests() =
9 |
10 | let docWithCaretAt (content:string) =
11 | let d = TestHelpers.createDoc(content.Replace("§", "")) ""
12 | d.Editor.SetIndentationTracker (new FSharpIndentationTracker(d.Editor))
13 | do match content.IndexOf('§') with
14 | | -1 -> ()
15 | | x -> let l = d.Editor.OffsetToLocation(x)
16 | d.Editor.SetCaretLocation(l.Line, l.Column)
17 | d
18 |
19 | let getIndent (content:string) =
20 | let doc = docWithCaretAt content
21 | let tracker = FSharpIndentationTracker(doc.Editor)
22 | let caretLine = doc.Editor.CaretLine
23 | tracker.GetIndentationString(caretLine).Length
24 |
25 | let insertEnterAtSection (text:string) =
26 | let idx = text.IndexOf ('§')
27 | let doc = TextDocument(text.Replace("§", ""))
28 | use data = new TextEditorData (doc)
29 | data.Caret.Offset <- idx
30 | MiscActions.InsertNewLine(data)
31 | data.Document.Text
32 |
33 | []
34 | member x.``Basic indents``() =
35 | let getIndent (doc:TestDocument, line:int, col) =
36 | doc.Editor.SetCaretLocation (2, 2)
37 | let column = doc.Editor.GetVirtualIndentationColumn (line)
38 | column
39 |
40 | let doc = "" |> TestHelpers.createDoc """
41 | let a =
42 |
43 | let b = (fun a ->
44 |
45 | let b = a
46 | """
47 | doc.Editor.SetIndentationTracker (FSharpIndentationTracker(doc.Editor))
48 | getIndent (doc, 3, 1) |> should equal 5
49 | getIndent (doc, 5, 1) |> should equal 5
50 | getIndent (doc, 7, 1) |> should equal 3
51 |
52 | []
53 | member x.``Match expression``() =
54 | getIndent("let m = match 123 with\n§") |> should equal 8
55 |
56 | []
57 | member x.``If then expression``() =
58 | getIndent("if true then\n§") |> should equal 4
59 |
60 | []
61 | member x.``Indented match expression``() =
62 | getIndent("""let m =
63 | match 123 with
64 | §""") |> should equal 3
65 |
66 | []
67 | member x.``Enter doesnt change indentation at indent position``() =
68 | let input = """ let a = 123
69 | §let c = 321"""
70 | input
71 | |> insertEnterAtSection
72 | |> should equal @" let a = 123
73 |
74 | let c = 321"
75 |
76 | []
77 | member x.``Enter after equals indents``() =
78 | let input = """ let a = §123"""
79 | input
80 | |> insertEnterAtSection
81 | |> shouldEqualIgnoringLineEndings """ let a =
82 | 123"""
83 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/ParameterHinting.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 |
3 | open System
4 | open NUnit.Framework
5 | open NUnit.Framework.Extensibility
6 | open MonoDevelop.FSharp
7 | open Mono.TextEditor
8 | open MonoDevelop.Ide.Editor
9 | open MonoDevelop.Ide.CodeCompletion
10 | open FsUnit
11 | open MonoDevelop
12 |
13 | type ``Parameter Hinting``() =
14 | let getHints (input: string) =
15 | let offset = input.LastIndexOf "|"
16 | if offset = -1 then
17 | failwith "Input must contain a |"
18 | let input = input.Remove(offset, 1)
19 | let doc = TestHelpers.createDoc input "defined"
20 | let editor = doc.Editor
21 | editor.CaretOffset <- offset
22 | let ctx = new CodeCompletionContext()
23 | ctx.TriggerOffset <- offset
24 |
25 | let index = ParameterHinting.getParameterIndex(editor, editor.Text.LastIndexOf("("))
26 | let hints = ParameterHinting.getHints(editor, doc, ctx)
27 | |> Async.RunSynchronously
28 | hints.[0].GetParameterName(index - 1) // index is 1 based
29 |
30 | []
31 | []
32 | []
33 | []
34 | []
35 | member x.``Parameter hinting``(input, expected) =
36 | getHints input |> should equal expected
37 |
38 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/ParsingTests.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open NUnit.Framework
3 | open FsUnit
4 | open MonoDevelop.FSharp
5 | open ExtCore
6 |
7 |
8 | []
9 | type ParsingTests() =
10 | let checkGetSymbol col lineStr expected expectedColumn =
11 | let expected = if expected = "" then [] else expected.Split '.' |> Array.toList
12 | match Parsing.findIdents col lineStr SymbolLookupKind.ByLongIdent
13 | |> Option.orTry (fun () -> Parsing.findIdents col lineStr SymbolLookupKind.Fuzzy) with
14 | | Some(colu, ident) -> ident |> should equal expected
15 | colu |> should equal expectedColumn
16 | | None -> Assert.Fail "Could not find ident"
17 |
18 | let assertIdents (source: string) expected expectedColumn =
19 | let col = source.IndexOf "|"
20 | let source = source.Replace("|", "")
21 | checkGetSymbol col source expected expectedColumn
22 |
23 | let assertLongIdentsAndResidue (source: string) expectedIdent expectedResidue =
24 | let col = source.IndexOf "|"
25 | let source = source.Replace("|", "")
26 | let ident, residue = Parsing.findLongIdentsAndResidue(col, source)
27 | let expectedIdent = if expectedIdent = "" then [] else expectedIdent.Split '.'
28 | |> Array.toList
29 | ident |> should equal expectedIdent
30 | residue |> should equal expectedResidue
31 |
32 | let assertResidue (source: string) expectedResidue =
33 | let col = source.IndexOf "|"
34 | let source = source.Replace("|", "")
35 | let residue = Parsing.findResidue(col, source)
36 | residue |> should equal expectedResidue
37 |
38 | []
39 | []
40 | []
41 | []
42 | member x.``Find long idents``(source: string, expected, expectedColumn) =
43 | assertIdents source expected expectedColumn
44 |
45 | []
46 | []
47 | []
48 | []
49 | []
50 | []
51 | []
52 | member x.``Find long idents and residue``(source: string, expectedIdent, expectedResidue) =
53 | assertLongIdentsAndResidue source expectedIdent expectedResidue
54 |
55 | []
56 | member x.``Find residue``(source: string, expectedResidue) =
57 | assertResidue source expectedResidue
58 |
59 | []
60 | member x.``Find custom operator``() =
61 | let source = "let ( >|.> ) a b = a + b"
62 | assertIdents source ">.>" 9
63 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/ProjectCracking.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open FsUnit
3 | open NUnit.Framework
4 | open MonoDevelop.Core
5 | open MonoDevelop.Core.ProgressMonitoring
6 | open MonoDevelop.Projects
7 | open MonoDevelop.Projects.MSBuild
8 | open System
9 | open MonoDevelop.FSharp
10 |
11 | []
12 | type ProjectCracking() =
13 | let fsproj = "/Users/jason/src/monodevelop/main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj"
14 |
15 | []
16 | member x.``Can crack fsharpbinding project``() =
17 | Environment.SetEnvironmentVariable ("MONO_ADDINS_REGISTRY", "/tmp")
18 | Environment.SetEnvironmentVariable ("XDG_CONFIG_HOME", "/tmp")
19 | Runtime.Initialize (true)
20 | MonoDevelop.Ide.DesktopService.Initialize()
21 | let sln = "/Users/jason/src/monodevelop/main/external/fsharpbinding/MonoDevelop.FSharp.sln"
22 | let monitor = new ConsoleProgressMonitor()
23 | let w = Services.ProjectService.ReadWorkspaceItem (monitor, FilePath(sln))
24 | |> Async.AwaitTask
25 | |> Async.RunSynchronously
26 |
27 | let s = w :?> Solution
28 | let fsproj = s.Items.[0] :?> DotNetProject
29 | let opts = languageService.GetProjectOptionsFromProjectFile fsproj
30 | printfn "%A" opts
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/ProjectTests.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open NUnit.Framework
3 | open FsUnit
4 | open MonoDevelop.Core
5 | open MonoDevelop.FSharp
6 | open MonoDevelop.Ide
7 | open MonoDevelop.Ide.Gui.Components
8 | open MonoDevelop.Projects
9 | open System
10 | open System.IO
11 |
12 | []
13 | type ProjectTests() =
14 |
15 | []
16 | member this.Can_reorder_nodes() =
17 | if not MonoDevelop.Core.Platform.IsWindows then
18 | let xml =
19 | """
20 |
21 |
22 |
23 |
24 |
25 |
26 | """
27 | let path = Path.GetTempPath() + Guid.NewGuid().ToString() + ".fsproj"
28 | File.WriteAllText (path, xml)
29 | let project = Services.ProjectService.CreateDotNetProject ("F#")
30 | project.FileName <- new FilePath(path)
31 | let movingNode = project.AddFile("test1.fs")
32 | let moveToNode = project.AddFile("test2.fs")
33 |
34 | let fsp = new FSharpProjectNodeCommandHandler()
35 | fsp.MoveNodes moveToNode movingNode DropPosition.After
36 |
37 | let newXml = File.ReadAllText path
38 | let expected =
39 | """
40 |
41 |
42 |
43 |
44 | """
45 | newXml |> should equal expected
46 |
47 | []
48 | member this.``Adds desktop conditional FSharp targets``() =
49 | if not MonoDevelop.Core.Platform.IsWindows then
50 | let project = Services.ProjectService.CreateDotNetProject ("F#") :?> FSharpProject
51 | Project.addConditionalTargets project.MSBuildProject
52 | let s = project.MSBuildProject.SaveToString()
53 | s |> shouldEqualIgnoringLineEndings
54 | """
55 |
56 |
57 |
58 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets
59 |
60 |
61 | $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets
62 |
63 | """
64 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/Script.fsx:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/SemanticHighlighting.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 |
3 | open System
4 | open Microsoft.FSharp.Compiler.SourceCodeServices
5 | open NUnit.Framework
6 | open MonoDevelop.FSharp
7 | open MonoDevelop.Ide.Editor
8 | open Mono.TextEditor.Highlighting
9 | open FsUnit
10 |
11 | []
12 | type SemanticHighlighting() =
13 | let defaultStyles = SyntaxModeService.DefaultColorStyle
14 | let getStyle (content : string) =
15 | let fixedc = content.Replace("§", "")
16 | let doc = TestHelpers.createDoc fixedc "defined"
17 | let style = SyntaxModeService.GetColorStyle "Gruvbox"
18 | let tsc = SyntaxMode.tryGetTokensSymbolsAndColours doc
19 |
20 | let segments =
21 | doc.Editor.GetLines()
22 | |> Seq.map (fun line -> SyntaxMode.getColouredSegment tsc line.LineNumber line.Offset (doc.Editor.GetLineText line) style)
23 |
24 | for line in segments do
25 | line |> Seq.toList |> List.rev |> List.iteri (fun i seg ->
26 | printfn """%s"%s" Style:%s S:%i E:%i L:%i"""
27 | (String.replicate i " ")
28 | (doc.Editor.GetTextBetween(seg.Offset, seg.EndOffset))
29 | seg.ColorStyleKey
30 | seg.Offset
31 | seg.EndOffset
32 | seg.Length )
33 | printfn "\n"
34 |
35 | let offset = content.IndexOf("§")
36 | let endOffset = content.LastIndexOf("§") - 1
37 | let segment = segments |> Seq.concat |> Seq.tryFind (fun s -> s.Offset = offset && s.EndOffset = endOffset)
38 | match segment with
39 | | Some(s) -> s.ColorStyleKey
40 | | _ -> "segment not found"
41 |
42 | []
43 | member x.Undefined_IfDef() =
44 | let content ="""
45 | #if undefined
46 | let sub = (-)
47 | §let§ add = (+)
48 | #endif"""
49 | getStyle content |> should equal "Excluded Code"
50 |
51 | []
52 | member x.Module_is_highlighted() =
53 | let content = """
54 | module MyModule =
55 | let someFunc() = ()
56 |
57 | module Consumer =
58 | §MyModule§.someFunc()"""
59 | let output = getStyle content
60 | output |> should equal "User Types"
61 |
62 | []
63 | member x.Type_is_highlighted() =
64 | let content = """
65 | open System
66 |
67 | module MyModule =
68 | let guid = §Guid§.NewGuid()"""
69 | let output = getStyle content
70 | output |> should equal "User Types(Value types)"
71 |
72 | []
73 | member x.Add_is_plain_text() =
74 | let content = "let §add§ = (+)"
75 | getStyle content |> should equal "User Method Declaration"
76 |
77 | []
78 | []
79 | member x.Semantic_highlighting(source, expectedStyle) =
80 | getStyle source |> should equal expectedStyle
81 |
82 | []
83 | member x.Generics_are_highlighted() =
84 | let content = """
85 | type Class<§'a§>() = class end
86 | let _ = new Class<_>()"""
87 | let output = getStyle content
88 | output |> should equal defaultStyles.UserTypesTypeParameters.Name
89 |
90 | []
91 | member x.Type_constraints_are_highlighted() =
92 | let content = """type Constrained<'a when §'a§ :> IDisposable> = class end"""
93 | let output = getStyle content
94 | output |> should equal defaultStyles.UserTypesTypeParameters.Name
95 |
96 | []
97 | member x.Static_inlined_type_constraints_are_highlighted() =
98 | let content = """let inline test (x: §^a§) (y: ^b) = x + y"""
99 | let output = getStyle content
100 | output |> should equal defaultStyles.UserTypesTypeParameters.Name
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/SyntaxHighlighting.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 |
3 | open System
4 | open NUnit.Framework
5 | open MonoDevelop.FSharp
6 | open Mono.TextEditor
7 | open Mono.TextEditor.Highlighting
8 | open MonoDevelop.Ide.Editor
9 | open FsUnit
10 |
11 | []
12 | type SyntaxHighlighting() =
13 | let assertStyle (input:string, expectedStyle:string) =
14 | let offset = input.IndexOf("§")
15 | let length = input.LastIndexOf("§") - offset - 1
16 | let input = input.Replace("§", "")
17 | let data = new TextEditorData (new TextDocument (input))
18 | let syntaxMode = SyntaxModeService.GetSyntaxMode (data.Document, "text/x-fsharp")
19 | let style = SyntaxModeService.GetColorStyle ("Gruvbox")
20 | let line = data.Lines |> Seq.head
21 | let chunks = syntaxMode.GetChunks(style, line, offset, line.Length)
22 | let chunk = chunks |> Seq.tryFind (fun c -> c.Offset = offset && c.Length = length)
23 |
24 | match chunk with
25 | | Some (c) -> c.Style |> should equal expectedStyle
26 | | _ -> printfn "Offset - %d, Length - %d" offset length
27 | printfn "%A" chunks
28 | Assert.Fail()
29 |
30 | []
31 | []
32 | []
33 | []
34 | []
35 | []
36 | []
37 | []
38 | []
39 | []
40 | []
41 | []
42 | []
43 | []
44 | []
45 | []
46 | []
47 | []
48 | []
49 | []
50 | []
51 | []
52 | []
53 | []
54 | []
55 | []
56 | []
57 | []
58 | []
59 | []
60 | [ §ignore§", "User Method Declaration")>]
61 | []
62 | []
63 | []
64 | [ §should equal", "Plain Text")>]
65 | [ §should§ equal", "User Method Declaration")>]
66 | []
67 | [", "Plain Text")>]
68 | []
69 | []
70 | []
71 | []
72 | []
73 | []
74 | []
75 | []
76 | []
77 | [ ", "User Field Declaration")>]
78 | []
79 | []
80 | [ §SomeType§", "User Types")>]
81 | []
82 | []
83 | []
84 | []
85 | []
86 | []
87 | []
88 | []
89 | []
90 | [>§", "Punctuation(Brackets)")>]
91 | []
92 | []
93 | []
94 | []
95 | [§ Option.bind", "Punctuation(Brackets)")>]
96 | [", "User Field Declaration")>]
97 | []
98 | []
99 | []
100 | []
101 | [", "User Field Declaration")>]
102 | []
103 | [(§fun e", "Punctuation(Brackets)")>]
104 | []
105 | []
106 | []
107 | []
108 | []
109 | []
110 | []
111 | []
112 | member x.``Syntax highlighting``(source, expectedStyle) =
113 | assertStyle (source, expectedStyle)
114 |
115 | []
116 | []
117 | [ §^T§ :", "User Types")>]
118 | [ §seq§<'T>", "User Types")>]
119 | []
120 |
121 | member x.``Tooltip highlighting``(source, expectedStyle) =
122 | assertStyle (source, expectedStyle)
123 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/TestBase.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open System
3 | open System.Reflection
4 | open System.IO
5 | open NUnit.Framework
6 |
7 | module FsUnit =
8 |
9 | open System.Diagnostics
10 | open NUnit.Framework
11 | open NUnit.Framework.Constraints
12 |
13 | []
14 | let should (f : 'a -> #Constraint) x (y : obj) =
15 | let c = f x
16 | let y =
17 | match y with
18 | | :? (unit -> unit) -> box (new TestDelegate(y :?> unit -> unit))
19 | | _ -> y
20 | Assert.That(y, c)
21 |
22 | let shouldnot (f : 'a -> #Constraint) x (y : obj) =
23 | let c = f x
24 | let y =
25 | match y with
26 | | :? (unit -> unit) -> box (new TestDelegate(y :?> unit -> unit))
27 | | _ -> y
28 | Assert.That(y, new NotConstraint(c))
29 |
30 | let equal x = new EqualConstraint(x)
31 |
32 | // like "should equal", but validates same-type
33 | let shouldEqual (x: 'a) (y: 'a) = Assert.AreEqual(x, y, sprintf "Expected: %A\nActual: %A" x y)
34 | let replaceLineEnding (s:string) =
35 | s.Replace("\r\n", "\n")
36 |
37 | let shouldEqualIgnoringLineEndings (x: string) (y: string) =
38 | Assert.AreEqual((replaceLineEnding x), (replaceLineEnding y), sprintf "Expected: %A\nActual: %A" x y)
39 |
40 | let notEqual x = new NotConstraint(new EqualConstraint(x))
41 |
42 | let NOT c = new NotConstraint(c)
43 |
44 | let contain x = new ContainsConstraint(x)
45 |
46 | let haveLength n = Has.Length.EqualTo(n)
47 |
48 | let haveCount n = Has.Count.EqualTo(n)
49 |
50 | let NotEmpty = Has.Length.GreaterThan(0)
51 |
52 | let endWith (s:string) = new EndsWithConstraint(s)
53 |
54 | let startWith (s:string) = new StartsWithConstraint(s)
55 |
56 | let be = id
57 |
58 | let Null = new NullConstraint()
59 |
60 | let Empty = new EmptyConstraint()
61 |
62 | let EmptyString = new EmptyStringConstraint()
63 |
64 | let NullOrEmptyString = new NullOrEmptyStringConstraint()
65 |
66 | let True = new TrueConstraint()
67 |
68 | let False = new FalseConstraint()
69 |
70 | let sameAs x = new SameAsConstraint(x)
71 |
72 | let throw = Throws.TypeOf
73 |
74 |
75 | []
76 | module Path =
77 | let (++) (a:string) (b:string) = Path.Combine(a,b)
78 | ///Cleans up a path removing trailing double quotes and also consistant forward slash handling
79 | let neutralise (path:string) =
80 | Path.GetFullPath( path.TrimStart('\"').TrimEnd('\"'))
81 |
82 |
83 | []
84 | module AssemblyLocation =
85 | let fromFqn (fqn:string) =
86 | let assembly = Assembly.ReflectionOnlyLoad fqn
87 | assembly.Location
88 |
89 | let (|Fqn|File|) (input:string) =
90 | if input.Contains "," then Fqn(input)
91 | else File(input)
92 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/TestDocument.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 |
3 | open MonoDevelop.FSharp
4 | open MonoDevelop.Ide.Editor
5 | open System.Threading.Tasks
6 |
7 | type TestDocument(name, parsedDocument, editor: TextEditor) =
8 | inherit DocumentContext()
9 |
10 | override x.Name = name
11 | override x.Project = null
12 | override x.AnalysisDocument = null
13 | override x.ParsedDocument = parsedDocument
14 | override x.AttachToProject(_) = ()
15 | override x.ReparseDocument() = ()
16 | override x.GetOptionSet() = null
17 | override x.UpdateParseDocument() = Task.FromResult parsedDocument
18 | member x.Editor = editor
19 | member x.Ast = parsedDocument.Ast :?> ParseAndCheckResults
20 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/TestHelpers.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open System
3 | open Microsoft.FSharp.Compiler.SourceCodeServices
4 | open MonoDevelop.FSharp
5 | open MonoDevelop.Ide.Editor
6 | open MonoDevelop.Ide.TypeSystem
7 | open MonoDevelop.Core
8 | open MonoDevelop.Core.Text
9 |
10 | type FixtureSetup() =
11 | static let firstRun = ref true
12 |
13 | member x.Initialise() =
14 | if !firstRun then
15 | firstRun := false
16 | MonoDevelop.FSharp.MDLanguageService.DisableVirtualFileSystem()
17 | MonoDevelop.Ide.DesktopService.Initialize()
18 |
19 | GuiUnit.TestRunner.ExitCode |> ignore // hack to get GuiUnit into the AppDomain
20 |
21 | module TestHelpers =
22 | let filename = if Platform.IsWindows then "c:\\test.fsx" else "test.fsx"
23 |
24 | let parseAndCheckFile source =
25 | async {
26 | try
27 | let checker = FSharpChecker.Create()
28 | let! projOptions = checker.GetProjectOptionsFromScript(filename, source)
29 | let! parseResults, checkAnswer = checker.ParseAndCheckFileInProject(filename, 0, source , projOptions)
30 |
31 | // Construct new typed parse result if the task succeeded
32 | let results =
33 | match checkAnswer with
34 | | FSharpCheckFileAnswer.Succeeded(checkResults) ->
35 | ParseAndCheckResults(Some checkResults, Some parseResults)
36 | | FSharpCheckFileAnswer.Aborted ->
37 | ParseAndCheckResults(None, Some parseResults)
38 |
39 | return results
40 | with exn ->
41 | printf "%A" exn
42 | return ParseAndCheckResults(None, None) }
43 |
44 | let createDoc source compilerDefines =
45 | FixtureSetup().Initialise()
46 |
47 | let results = parseAndCheckFile source |> Async.RunSynchronously
48 | let options = ParseOptions(FileName = filename, Content = StringTextSource(source))
49 |
50 | let parsedDocument =
51 | ParsedDocument.create options results [compilerDefines] (Some (new DocumentLocation(0,0))) |> Async.RunSynchronously
52 |
53 | let doc = TextEditorFactory.CreateNewReadonlyDocument(StringTextSource(source), filename, "text/fsharp")
54 | let editor = MonoDevelop.Ide.Editor.TextEditorFactory.CreateNewEditor (doc)
55 |
56 | TestDocument(filename, parsedDocument, editor)
57 |
58 | let getAllSymbols source =
59 | async {
60 | let! results = parseAndCheckFile source
61 | return! results.GetAllUsesOfAllSymbolsInFile()
62 | } |> Async.RunSynchronously
63 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/TestViewContent.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open System
3 | open System.Linq
4 | open MonoDevelop.Core
5 | open Mono.TextEditor
6 | open MonoDevelop.Projects.Text
7 | open MonoDevelop.Ide.Gui
8 | open MonoDevelop.Ide.Gui.Content
9 | open MonoDevelop.Ide.Editor
10 |
11 | type TestViewContent() =
12 | inherit ViewContent()
13 | let caretPositionSet = Event<_>()
14 | let textChanged = Event<_>()
15 | let name = FilePath()
16 |
17 | let data = MonoDevelop.Ide.Editor.TextEditorFactory.CreateNewEditor ()
18 |
19 | member val Contents = ResizeArray([data :> obj]) with get, set
20 | member val Data = data
21 |
22 | override x.Load(fileName:FileOpenInformation) = null
23 | override x.Control = null
24 |
25 | override x.OnGetContents (t) =
26 | base.OnGetContents(t).Concat(x.Contents)
27 |
28 | //interface ITextEditorDataProvider with
29 | member x.GetTextEditorData() = data
30 |
31 | //interface IEditableTextBuffer with
32 | member x.HasInputFocus = false
33 | member x.LineCount = data.LineCount
34 | []
35 | member x.CaretPositionSet = caretPositionSet.Publish
36 | []
37 | member x.TextChanged = textChanged.Publish
38 | member x.SetCaretTo(line, column) =()
39 | member x.SetCaretTo(line, column, highlightCaretLine) =()
40 | member x.SetCaretTo(line, column, highlightCaretLine, centerCaret) =()
41 | member x.RunWhenLoaded(f) = f()
42 | member x.SelectedText with get() = "" and set (v:string) = ()
43 | member x.CursorPosition with get() = data.CaretOffset and set v = data.CaretOffset <- v
44 | member x.SelectionStartPosition with get() = if data.IsSomethingSelected then data.SelectionRange.Offset else data.CaretOffset
45 | member x.SelectionEndPosition with get() = if data.IsSomethingSelected then data.SelectionRange.EndOffset else data.CaretOffset
46 | member x.Select(s, e) =
47 | if not (data.IsSomethingSelected) then data.CaretOffset
48 | else data.SelectionRange.EndOffset
49 | member x.ShowPosition(pos) = ()
50 |
51 | member x.InsertText(pos, str:string) =
52 | data.InsertText(pos, str)
53 | str.Length
54 | member x.DeleteText(pos, length) = data.ReplaceText (pos, length, "")
55 | member x.EnableUndo = false
56 | member x.EnableRedo = false
57 | member x.Undo() = ()
58 | member x.Redo() = ()
59 | member x.OpenUndoGroup() = {new IDisposable with member x.Dispose() = ()}
60 | member x.Text with get() = data.Text and set v = data.Text <- v
61 |
62 | interface ITextFile with
63 | member x.Text with get() = data.Text
64 | member x.Name with get() = name
65 | member x.Length = data.Length
66 | member x.GetText(s, e) = data.GetTextBetween (s, e)
67 | member x.GetCharAt(pos) = data.GetCharAt(pos)
68 | member x.GetPositionFromLineColumn(line, column) = data.LocationToOffset (line, column)
69 | member x.GetLineColumnFromPosition(position, line, col) =
70 | let loc = data.OffsetToLocation (position)
71 | line <- loc.Line
72 | col <- loc.Column
73 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/TestWorkbenchWindow.fs:
--------------------------------------------------------------------------------
1 | namespace MonoDevelopTests
2 | open System
3 | open Mono.Addins
4 | open MonoDevelop.Ide.Gui
5 |
6 | type TestWorkbenchWindow(viewContent) =
7 |
8 | let edc = DelegateEvent<_>()
9 | let closed = DelegateEvent<_>()
10 | let closing = DelegateEvent<_>()
11 | let avcc = DelegateEvent<_>()
12 | let viewsChanged = DelegateEvent<_>()
13 |
14 | interface IWorkbenchWindow with
15 | member x.SelectWindow () = ()
16 | member x.SwitchView (viewNumber:int) = ()
17 | member x.SwitchView (viewNumber:BaseViewContent) = ()
18 | member x.FindView<'a>() = -1
19 | member val Title = "" with get,set
20 | member val Document = null with get, set
21 | member val DocumentType = "" with get, set
22 | member val ShowNotification = false with get, set
23 | member x.ViewContent with get() = viewContent
24 | member x.ActiveViewContent with get() = viewContent :> BaseViewContent and set v = ()
25 | member x.ExtensionContext with get() = AddinManager.AddinEngine :> _
26 | member x.CloseWindow (force) = true
27 | member x.AttachViewContent (subViewContent) = ()
28 | member x.InsertViewContent(index, subViewContent) = ()
29 | member x.SubViewContents with get() = Seq.empty
30 | member x.GetToolbar(targetView) = failwith "Not Implemented"
31 |
32 | []
33 | member x.DocumentChanged = edc.Publish
34 | []
35 | member x.Closed = closed.Publish
36 | []
37 | member x.Closing = closing.Publish
38 | []
39 | member x.ActiveViewContentChanged = avcc.Publish
40 | []
41 | member x.ViewsChanged = viewsChanged.Publish
42 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.Tests/paket.references:
--------------------------------------------------------------------------------
1 | ExtCore
2 | FSharp.Compiler.Service
3 | FSharp.Core
4 | Mono.Cecil
--------------------------------------------------------------------------------
/MonoDevelop.FSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{165E4D13-19CC-4FCA-B4EC-F86DA08E6003}"
5 | ProjectSection(SolutionItems) = preProject
6 | paket.dependencies = paket.dependencies
7 | EndProjectSection
8 | EndProject
9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.FSharp.Gui", "MonoDevelop.FSharp.Gui\MonoDevelop.FSharp.Gui.csproj", "{FD0D1033-9145-48E5-8ED8-E2365252878C}"
10 | EndProject
11 | Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "MonoDevelop.FSharp", "MonoDevelop.FSharpBinding\MonoDevelop.FSharp.fsproj", "{4C10F8F9-3816-4647-BA6E-85F5DE39883A}"
12 | EndProject
13 | Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "MonoDevelop.FSharp.Tests", "MonoDevelop.FSharp.Tests\MonoDevelop.FSharp.Tests.fsproj", "{A1A45375-7FB8-4F2A-850F-FBCC67739927}"
14 | EndProject
15 | Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "MonoDevelop.FSharpInteractive.Service", "MonoDevelop.FSharpi.Service\MonoDevelop.FSharpInteractive.Service.fsproj", "{20D6EC2C-B62E-49D1-B685-90D8967A5B5D}"
16 | EndProject
17 | Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "MonoDevelop.FSharp.Shared", "MonoDevelop.FSharp.Shared\MonoDevelop.FSharp.Shared.fsproj", "{AF5FEAD5-B50E-4F07-A274-32F23D5C504D}"
18 | EndProject
19 | Global
20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
21 | Debug|Any CPU = Debug|Any CPU
22 | Release|Any CPU = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
25 | {4C10F8F9-3816-4647-BA6E-85F5DE39883A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {4C10F8F9-3816-4647-BA6E-85F5DE39883A}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {4C10F8F9-3816-4647-BA6E-85F5DE39883A}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {4C10F8F9-3816-4647-BA6E-85F5DE39883A}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {A1A45375-7FB8-4F2A-850F-FBCC67739927}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {A1A45375-7FB8-4F2A-850F-FBCC67739927}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {A1A45375-7FB8-4F2A-850F-FBCC67739927}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {A1A45375-7FB8-4F2A-850F-FBCC67739927}.Release|Any CPU.Build.0 = Release|Any CPU
33 | {FD0D1033-9145-48E5-8ED8-E2365252878C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {FD0D1033-9145-48E5-8ED8-E2365252878C}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {FD0D1033-9145-48E5-8ED8-E2365252878C}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {FD0D1033-9145-48E5-8ED8-E2365252878C}.Release|Any CPU.Build.0 = Release|Any CPU
37 | {20D6EC2C-B62E-49D1-B685-90D8967A5B5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38 | {20D6EC2C-B62E-49D1-B685-90D8967A5B5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
39 | {20D6EC2C-B62E-49D1-B685-90D8967A5B5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {20D6EC2C-B62E-49D1-B685-90D8967A5B5D}.Release|Any CPU.Build.0 = Release|Any CPU
41 | {AF5FEAD5-B50E-4F07-A274-32F23D5C504D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42 | {AF5FEAD5-B50E-4F07-A274-32F23D5C504D}.Debug|Any CPU.Build.0 = Debug|Any CPU
43 | {AF5FEAD5-B50E-4F07-A274-32F23D5C504D}.Release|Any CPU.ActiveCfg = Release|Any CPU
44 | {AF5FEAD5-B50E-4F07-A274-32F23D5C504D}.Release|Any CPU.Build.0 = Release|Any CPU
45 | EndGlobalSection
46 | GlobalSection(NestedProjects) = preSolution
47 | EndGlobalSection
48 | EndGlobal
49 |
--------------------------------------------------------------------------------
/MonoDevelop.FSharpBinding/CompilerService.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |