Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2017-03-24 20:14:15 +0300
committerLluis Sanchez <lluis@xamarin.com>2017-03-24 20:14:15 +0300
commita306f11d84bfb6dfc8702a7c0817547bd76f7ebf (patch)
tree02ce156f6502f431aa7d8a9eba93a8e78c94cc45
parenta2060f18c243d70e58b7edb2f63b76515d295a8b (diff)
parent84efb9eaea49a3f4bcaeeae46d1c4e86512dc709 (diff)
Merge remote-tracking branch 'origin/master' into vNext-webtools-platform
-rw-r--r--.editorconfig90
-rw-r--r--.gitmodules4
-rw-r--r--NuGet.config2
-rw-r--r--dependency_checker.rb9
-rw-r--r--main/Main.sln62
-rw-r--r--main/Makefile.am1
-rw-r--r--main/MonoDevelop.props12
-rw-r--r--main/contrib/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj1
m---------main/external/RefactoringEssentials0
m---------main/external/debugger-libs0
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharp.Gui/MonoDevelop.FSharp.Gui.csproj6
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj14
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompilerArguments.fs4
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Interactive.fs2
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj43
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharp.Tests/ProjectTests.fs35
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormatter.fs47
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPanelWidget.fs3
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicy.fs56
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicyPanel.fs5
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProject.fs2
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProjectFileNodeExtension.fs23
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj65
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs4
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj24
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpi.Service/Program.fs11
-rw-r--r--main/external/fsharpbinding/paket.dependencies2
-rw-r--r--main/external/fsharpbinding/paket.lock4
m---------main/external/libgit2sharp0
-rw-r--r--main/msbuild/GenerateInternalsVisibleTo.targets66
-rwxr-xr-xmain/msbuild/MonoDevelop-Public.snkbin0 -> 160 bytes
-rw-r--r--main/msbuild/MonoDevelop.AfterCommon.props16
-rw-r--r--main/msbuild/MonoDevelop.AfterCommon.targets8
-rw-r--r--main/msbuild/MonoDevelop.BeforeCommon.props6
-rw-r--r--main/msbuild/MonoDevelop.BeforeCommon.targets29
-rw-r--r--main/po/Gettext.targets3
-rw-r--r--main/po/po.mdproj1
-rw-r--r--main/src/addins/AspNet/MonoDevelop.AspNet.csproj7
-rw-r--r--main/src/addins/AspNet/Properties/AssemblyInfo.cs2
-rw-r--r--main/src/addins/AspNet/Tests/MonoDevelop.AspNet.Tests.csproj5
-rw-r--r--main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj7
-rw-r--r--main/src/addins/CSharpBinding/AssemblyInfo.cs7
-rw-r--r--main/src/addins/CSharpBinding/Autotools/Autotools.csproj12
-rw-r--r--main/src/addins/CSharpBinding/Autotools/CSharpAutotoolsSetup.cs14
-rw-r--r--main/src/addins/CSharpBinding/CSharpBinding.addin.xml15
-rw-r--r--main/src/addins/CSharpBinding/CSharpBinding.csproj501
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/AddImport/AbstractAddImportCodeFixProvider.cs526
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/AddImport/CSharpAddImportCodeFixProvider.cs642
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/AbstractAsyncCodeFix.cs88
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpAddAsyncCodeFixProvider.cs229
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpAddAwaitCodeFixProvider.cs147
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpConvertToAsyncMethodCodeFixProvider.cs124
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/EncapsulateField/AbstractEncapsulateFieldRefactoringProvider.cs20
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/EncapsulateField/EncapsulateFieldCodeRefactoringProvider.cs13
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/FullyQualify/CSharpFullyQualifyCodeFixProvider.cs331
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateConstructor/AbstractGenerateMemberCodeFixProvider.cs106
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs63
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs39
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs65
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs75
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateType/GenerateTypeCodeFixProvider.cs77
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateVariable/GenerateVariableCodeFixProvider.cs59
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/ImplementAbstractClass/ImplementAbstractClassCodeFixProvider.cs95
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/ImplementInterface/ImplementInterfaceCodeFixProvider.cs70
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/MoveTypeToFile/MoveTypeToFile.cs256
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/PredefinedCodeFixProviderNames.cs64
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryCast/RemoveUnnecessaryCastCodeFixProvider.RemoveUnnecessaryCastFixAllProvider.cs42
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryCast/RemoveUnnecessaryCastCodeFixProvider.cs122
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryUsings/RemoveUnnecessaryUsingsCodeFixProvider.cs58
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.SimplifyTypeNamesFixAllProvider.cs29
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.cs143
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CodeGenerationOptions.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CreateConstructorGenerator.cs62
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/OverrideMembersGenerator.cs11
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/PartialGenerator.cs3
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/RaiseEventMethodGenerator.cs11
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/CSharpSyntaxContext.cs574
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/CodeRefactoring.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ExtractMethod/ExtractMethodCodeRefactoringProvider.cs105
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.InitializerRewriter.cs105
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.ReferenceRewriter.cs106
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs575
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/IntroduceVariable/IntroduceVariableCodeRefactoringProvider.cs41
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/TypeGuessing.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/UsingRefactorings/SortImportsCodeRefactoringProvider.cs84
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs50
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs4
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCodeCompletionFactory.cs11
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCompletionCategory.cs11
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/DiagnosticCustomTags.cs35
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/IDEDiagnosticIds.cs8
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/MonoNameConventionPolicy.xml179
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionEditRuleDialog.cs213
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPanel.cs73
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPanelWidget.cs163
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPolicy.cs96
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionRule.cs587
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/MonoTODO/MonoTODODiagnosticAnalyzer.cs10
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastDiagnosticAnalyzer.cs42
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastDiagnosticAnalyzerBase.cs85
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs50
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryImports/RemoveUnnecessaryImportsDiagnosticAnalyzerBase.cs127
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/SimplifyTypeNames/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs154
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs112
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/AbstractTokenBraceCompletionSession.cs49
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/CSharpAutoInsertBracketHandler.cs57
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolatedStringCompletionSession.cs4
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolationCompletionSession.cs1
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/LessAndGreaterThanCompletionSession.cs45
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CSharpCodeGenerationService.cs330
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationDestination.cs47
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationHelpers.cs39
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationOptions.cs61
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationTypeParameterSymbol.cs89
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerator.cs137
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/SyntaxAnnotationExtensions.cs58
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/CompletionEngine.cs42
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/AttributeNamedParameterContextHandler.cs3
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/CastCompletionContextHandler.cs32
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/DelegateCreationContextHandler.cs19
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/EnumMemberContextHandler.cs14
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExplicitInterfaceContextHandler.cs12
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExternAliasContextHandler.cs12
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/KeywordContextHandler.cs62
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/NamedParameterContextHandler.cs4
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectCreationContextHandler.cs6
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectInitializerContextHandler.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/OverrideContextHandler.cs10
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/PartialContextHandler.cs10
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/RoslynRecommendationsCompletionContextHandler.cs19
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SenderCompletionContextHandler.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SnippetContextHandler.cs58
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeNameContextHandler.cs11
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeTContextHandler.cs3
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/XmlDocCommentContextHandler.cs11
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ICompletionDataFactory.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AbstractKeywordRecommender.cs55
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AbstractSyntacticSingleKeywordRecommender.cs79
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AddKeywordRecommender.cs22
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AliasKeywordRecommender.cs36
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AsKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AscendingKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AssemblyKeywordRecommender.cs32
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AsyncKeywordRecommender.cs39
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AwaitKeywordRecommender.cs54
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BaseKeywordRecommender.cs69
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BoolKeywordRecommender.cs47
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BreakKeywordRecommender.cs54
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ByKeywordRecommender.cs53
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ByteKeywordRecommender.cs49
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CaseKeywordRecommender.cs41
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CatchKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CharKeywordRecommender.cs47
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CheckedKeywordRecommender.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ChecksumKeywordRecommender.cs28
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ClassKeywordRecommender.cs44
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ConstKeywordRecommender.cs65
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ContinueKeywordRecommender.cs47
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DecimalKeywordRecommender.cs47
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DefaultKeywordRecommender.cs42
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DefineKeywordRecommender.cs25
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DelegateKeywordRecommender.cs53
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DescendingKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DisableKeywordRecommender.cs30
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DoKeywordRecommender.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DoubleKeywordRecommender.cs47
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DynamicKeywordRecommender.cs65
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ElifKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ElseKeywordRecommender.cs63
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EndIfKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EndRegionKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EnumKeywordRecommender.cs37
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EqualsKeywordRecommender.cs45
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ErrorKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EventKeywordRecommender.cs44
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ExplicitKeywordRecommender.cs41
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ExternKeywordRecommender.cs100
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FalseKeywordRecommender.cs26
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FieldKeywordRecommender.cs30
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FinallyKeywordRecommender.cs22
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FixedKeywordRecommender.cs50
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FloatKeywordRecommender.cs47
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ForEachKeywordRecommender.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ForKeywordRecommender.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FromKeywordRecommender.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GetKeywordRecommender.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GlobalKeywordRecommender.cs42
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GotoKeywordRecommender.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GroupKeywordRecommender.cs32
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/HiddenKeywordRecommender.cs32
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IfKeywordRecommender.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ImplicitKeywordRecommender.cs41
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InKeywordRecommender.cs112
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IntKeywordRecommender.cs48
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InterfaceKeywordRecommender.cs38
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InternalKeywordRecommender.cs69
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IntoKeywordRecommender.cs117
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IsKeywordRecommender.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/JoinKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LetKeywordRecommender.cs32
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LineKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LockKeywordRecommender.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LongKeywordRecommender.cs48
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/MethodKeywordRecommender.cs43
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ModuleKeywordRecommender.cs32
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NameOfKeywordRecommender.cs34
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NamespaceKeywordRecommender.cs160
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NewKeywordRecommender.cs123
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NullKeywordRecommender.cs52
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ObjectKeywordRecommender.cs46
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OnKeywordRecommender.cs49
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OperatorKeywordRecommender.cs36
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OrderByKeywordRecommender.cs32
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OutKeywordRecommender.cs30
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OverrideKeywordRecommender.cs38
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ParamKeywordRecommender.cs37
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ParamsKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PartialKeywordRecommender.cs64
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PragmaKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PrivateKeywordRecommender.cs87
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PropertyKeywordRecommender.cs22
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ProtectedKeywordRecommender.cs74
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PublicKeywordRecommender.cs60
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReadOnlyKeywordRecommender.cs40
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RefKeywordRecommender.cs27
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReferenceKeywordRecommender.cs26
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RegionKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RemoveKeywordRecommender.cs22
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RestoreKeywordRecommender.cs30
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReturnKeywordRecommender.cs33
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SByteKeywordRecommender.cs48
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SealedKeywordRecommender.cs55
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SelectKeywordRecommender.cs38
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SetKeywordRecommender.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ShortKeywordRecommender.cs48
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SizeOfKeywordRecommender.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StackAllocKeywordRecommender.cs42
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StaticKeywordRecommender.cs83
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StringKeywordRecommender.cs46
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StructKeywordRecommender.cs40
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SwitchKeywordRecommender.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ThisKeywordRecommender.cs97
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ThrowKeywordRecommender.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TrueKeywordRecommender.cs26
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TryKeywordRecommender.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeOfKeywordRecommender.cs34
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeVarKeywordRecommender.cs51
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UIntKeywordRecommender.cs48
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ULongKeywordRecommender.cs48
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UShortKeywordRecommender.cs48
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UncheckedKeywordRecommender.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UndefKeywordRecommender.cs25
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UnsafeKeywordRecommender.cs74
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UsingKeywordRecommender.cs139
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VarKeywordRecommender.cs36
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VirtualKeywordRecommender.cs37
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VoidKeywordRecommender.cs112
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VolatileKeywordRecommender.cs40
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WarningKeywordRecommender.cs34
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhenKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhereKeywordRecommender.cs142
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhileKeywordRecommender.cs50
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/YieldKeywordRecommender.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/AbstractEncapsulateFieldRefactoringProvider.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/AbstractEncapsulateFieldService.cs426
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/CSharpEncapsulateFieldService.cs193
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/EncapsulateFieldCodeAction.cs31
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/EncapsulateFieldResult.cs38
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractExtractMethodService.cs45
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractSyntaxTriviaService.Result.cs296
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractSyntaxTriviaService.cs131
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpExtractMethodService.cs27
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.Analyzer.cs136
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs392
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs242
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.MultipleStatementsCodeGenerator.cs139
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.SingleStatementCodeGenerator.cs87
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.cs583
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.FormattingProvider.cs66
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.PostProcessor.cs314
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.TriviaResult.cs161
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.cs128
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.ExpressionResult.cs140
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.StatementResult.cs88
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.cs207
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionValidator.Validator.cs86
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionValidator.cs486
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSyntaxTriviaService.cs16
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSyntaxTriviaServiceFactory.cs20
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/Extensions.cs285
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/Enums.cs55
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/Extensions.cs121
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodMatrix.cs229
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodOptions.cs17
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodResult.cs66
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodService.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/FailedExtractMethodResult.cs13
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/IExtractMethodService.cs16
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ISyntaxTriviaService.cs66
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/InsertionPoint.cs64
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.Analyzer.SymbolMapBuilder.cs79
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.Analyzer.cs957
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.AnalyzerResult.cs176
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.CodeGenerator.cs316
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.GeneratedCode.cs39
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.TriviaResult.cs181
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.TypeParameterCollector.cs57
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.VariableInfo.cs138
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.VariableSymbol.cs357
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.cs171
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus.cs68
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus_Statics.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus`1.cs29
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ParameterStyle.cs41
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ReturnStyle.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionResult.cs158
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionValidator.NullSelectionResult.cs52
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionValidator.cs185
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SimpleExtractMethodResult.cs17
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/UniqueNameGenerator.cs28
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/VariableStyle.cs49
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/CommonFormattingHelpers.cs372
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/FormattingHelpers.cs552
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/FormattingRangeHelper.cs434
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/AbstractCodeRefactoringResult.cs31
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/AbstractGenerateFromMembersService.cs160
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/AbstractGenerateConstructorService.cs263
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/CSharpGenerateConstructorService.cs53
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/GenerateConstructorResult.cs17
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateFromMembersHelpers.cs36
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/AbstractCodeRefactoringResult.cs31
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/AbstractGenerateMemberService.cs138
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/AbstractGenerateConstructorService.cs701
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/CSharpGenerateConstructorService.cs278
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/GenerateConstructorHelpers.cs35
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/AbstractGenerateDefaultConstructorsService.cs239
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs48
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/GenerateDefaultConstructorsResult.cs17
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateEnumMember/AbstractGenerateEnumMemberService.cs238
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateEnumMember/CSharpGenerateEnumMemberService.cs54
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateConversionService.cs136
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateMethodService.cs267
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.cs595
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs36
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs233
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs173
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs172
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/MethodGenerationKind.cs11
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateVariable/AbstractGenerateVariableService.cs710
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateVariable/CSharpGenerateVariableService.cs167
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/AbstractGenerateTypeService.cs1814
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/CSharpGenerateTypeService.cs943
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/GenerateTypeDialogOptions.cs27
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/GenerateTypeOptionsResult.cs55
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/TypeKindOptions.cs89
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GotoDefinition/GotoDefinitionService.cs57
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.Editor.cs167
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.State.cs70
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.cs35
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/CSharpImplementAbstractClassService.cs46
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs560
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Conflicts.cs89
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Method.cs80
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Property.cs150
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.DisposePatternCodeAction.cs150
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.State.cs84
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.cs109
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/CSharpImplementInterfaceService.cs170
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.AbstractIntroduceVariableCodeAction.cs134
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.CodeAction.cs28
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.IntroduceVariableAllOccurrenceCodeAction.cs39
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State.cs271
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Attribute.cs25
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Block.cs38
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_ConstructorInitializer.cs43
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Field.cs50
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Parameter.cs35
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Query.cs37
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.cs330
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService.Rewriter.cs61
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService.cs131
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceField.cs199
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceLocal.cs378
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceQueryLocal.cs107
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/IntroduceVariableResult.cs33
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/OrganizeImports/CSharpOrganizeImportsService.Rewriter.cs87
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/OrganizeImports/CSharpOrganizeImportsService.cs56
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ParameterHinting/ParameterHintingEngine.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.Rewriter.cs168
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs115
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs6
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs3
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs31
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/AbstractAsyncHighlighter.cs9
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ConditionalPreprocessorHighlighter.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ReturnStatementHighlighter.cs77
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/SwitchStatementHighlighter.cs3
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/YieldStatementHighlighter.cs37
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindBaseSymbolsHandler.cs1
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindDerivedSymbolsHandler.cs20
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindExtensionMethodsHandler.cs8
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindMemberOverloadsHandler.cs11
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs187
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs43
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerationService.cs62
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethodCommandHandler.cs24
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindReferencesHandler.cs20
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/OrganizeImportsCommandHandler.cs53
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs161
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DebuggerExpressionResolver.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs4
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBraceMatcher.cs3
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp/ProjectSearchCategory.cs25
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs2
-rw-r--r--main/src/addins/CSharpBinding/Util/AccessibilityUtilities.cs67
-rw-r--r--main/src/addins/CSharpBinding/Util/AnnotationTable.cs275
-rw-r--r--main/src/addins/CSharpBinding/Util/CSharpSemanticFactsService.cs270
-rw-r--r--main/src/addins/CSharpBinding/Util/CSharpSyntaxContext.cs572
-rw-r--r--main/src/addins/CSharpBinding/Util/CSharpSyntaxFactsService.cs1040
-rw-r--r--main/src/addins/CSharpBinding/Util/CSharpUtil.cs138
-rw-r--r--main/src/addins/CSharpBinding/Util/CastExpressionSyntaxExtensions.cs32
-rw-r--r--main/src/addins/CSharpBinding/Util/CodeFixContextExtensions.cs37
-rw-r--r--main/src/addins/CSharpBinding/Util/CodeGenerationSymbolFactory.cs466
-rw-r--r--main/src/addins/CSharpBinding/Util/CodeRefactoringContextExtensions.cs43
-rw-r--r--main/src/addins/CSharpBinding/Util/CommonAccessibilityUtilities.cs75
-rw-r--r--main/src/addins/CSharpBinding/Util/CommonLocationExtensions.cs28
-rw-r--r--main/src/addins/CSharpBinding/Util/CommonSyntaxNodeOrTokenExtensions.cs36
-rw-r--r--main/src/addins/CSharpBinding/Util/ConflictResolver.cs114
-rw-r--r--main/src/addins/CSharpBinding/Util/CrefSyntaxExtensions.cs136
-rw-r--r--main/src/addins/CSharpBinding/Util/DirectiveSyntaxExtensions.cs56
-rw-r--r--main/src/addins/CSharpBinding/Util/DocumentExtensions.cs137
-rw-r--r--main/src/addins/CSharpBinding/Util/EnumValueUtilities.cs57
-rw-r--r--main/src/addins/CSharpBinding/Util/EnumerableExtensions.cs351
-rw-r--r--main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs2380
-rw-r--r--main/src/addins/CSharpBinding/Util/FindTokenHelper.cs141
-rw-r--r--main/src/addins/CSharpBinding/Util/GeneratedCodeRecognitionService.cs10
-rw-r--r--main/src/addins/CSharpBinding/Util/Glyph.cs130
-rw-r--r--main/src/addins/CSharpBinding/Util/Hash.cs350
-rw-r--r--main/src/addins/CSharpBinding/Util/HelpLink.cs38
-rw-r--r--main/src/addins/CSharpBinding/Util/IAssemblySymbolExtensions.cs84
-rw-r--r--main/src/addins/CSharpBinding/Util/ICodeDefinitionFactoryExtensions.cs147
-rw-r--r--main/src/addins/CSharpBinding/Util/ICompilationExtensions.cs124
-rw-r--r--main/src/addins/CSharpBinding/Util/IDictionaryExtensions.cs90
-rw-r--r--main/src/addins/CSharpBinding/Util/IDocumentExtensions.cs45
-rw-r--r--main/src/addins/CSharpBinding/Util/IMethodSymbolExtensions.cs325
-rw-r--r--main/src/addins/CSharpBinding/Util/INamedTypeSymbolExtensions.cs518
-rw-r--r--main/src/addins/CSharpBinding/Util/INamespaceOrTypeSymbolExtensions.cs69
-rw-r--r--main/src/addins/CSharpBinding/Util/IParameterSymbolExtensions.cs43
-rw-r--r--main/src/addins/CSharpBinding/Util/IPropertySymbolExtensions.cs69
-rw-r--r--main/src/addins/CSharpBinding/Util/ISymbolExtensions.cs49
-rw-r--r--main/src/addins/CSharpBinding/Util/ITypeParameterSymbolExtensions.cs26
-rw-r--r--main/src/addins/CSharpBinding/Util/ITypeSymbolExtensions.cs1108
-rw-r--r--main/src/addins/CSharpBinding/Util/ImmutableArrayExtensions.cs60
-rw-r--r--main/src/addins/CSharpBinding/Util/LinkedListExtension.cs50
-rw-r--r--main/src/addins/CSharpBinding/Util/Matcher.cs188
-rw-r--r--main/src/addins/CSharpBinding/Util/MemberDeclarationSyntaxExtensions.cs341
-rw-r--r--main/src/addins/CSharpBinding/Util/NameGenerator.cs159
-rw-r--r--main/src/addins/CSharpBinding/Util/NameSyntaxComparer.cs177
-rw-r--r--main/src/addins/CSharpBinding/Util/NameSyntaxExtensions.cs120
-rw-r--r--main/src/addins/CSharpBinding/Util/NamespaceDeclarationSyntaxExtensions.cs50
-rw-r--r--main/src/addins/CSharpBinding/Util/ObjectExtensions.cs7667
-rw-r--r--main/src/addins/CSharpBinding/Util/PortingExtensions.cs203
-rw-r--r--main/src/addins/CSharpBinding/Util/PredefinedOperator.cs32
-rw-r--r--main/src/addins/CSharpBinding/Util/QueryExpressionSyntaxExtensions.cs49
-rw-r--r--main/src/addins/CSharpBinding/Util/RefactoringHelpers.cs140
-rw-r--r--main/src/addins/CSharpBinding/Util/ReflectionCompatibilityExtensions.cs127
-rw-r--r--main/src/addins/CSharpBinding/Util/SemanticDocument.cs30
-rw-r--r--main/src/addins/CSharpBinding/Util/SemanticEquivalence.cs69
-rw-r--r--main/src/addins/CSharpBinding/Util/SemanticMap.cs81
-rw-r--r--main/src/addins/CSharpBinding/Util/SemanticModelExtensions.cs622
-rw-r--r--main/src/addins/CSharpBinding/Util/SignatureComparer.cs94
-rw-r--r--main/src/addins/CSharpBinding/Util/SimpleNameSyntaxExtensions.cs64
-rw-r--r--main/src/addins/CSharpBinding/Util/SourceTextExtensions.cs191
-rw-r--r--main/src/addins/CSharpBinding/Util/SpecializedCollections.cs673
-rw-r--r--main/src/addins/CSharpBinding/Util/SpeculationAnalyzer.cs137
-rw-r--r--main/src/addins/CSharpBinding/Util/StringExtensions.cs551
-rw-r--r--main/src/addins/CSharpBinding/Util/StringPclExtensions.cs32
-rw-r--r--main/src/addins/CSharpBinding/Util/SymbolEquivalenceComparer.cs49
-rw-r--r--main/src/addins/CSharpBinding/Util/SymbolExtensions.cs1382
-rw-r--r--main/src/addins/CSharpBinding/Util/SymbolInfoExtensions.cs73
-rw-r--r--main/src/addins/CSharpBinding/Util/SymbolKeyExtensions.cs151
-rw-r--r--main/src/addins/CSharpBinding/Util/SymbolKeyResolutionExtensions.cs44
-rw-r--r--main/src/addins/CSharpBinding/Util/SyntacticDocument.cs39
-rw-r--r--main/src/addins/CSharpBinding/Util/SyntaxContext.cs3
-rw-r--r--main/src/addins/CSharpBinding/Util/SyntaxExtensions.cs550
-rw-r--r--main/src/addins/CSharpBinding/Util/SyntaxListExtension.cs33
-rw-r--r--main/src/addins/CSharpBinding/Util/SyntaxNodeExtensions.cs1721
-rw-r--r--main/src/addins/CSharpBinding/Util/SyntaxTokenExtensions.cs1106
-rw-r--r--main/src/addins/CSharpBinding/Util/SyntaxTreeExtensions.cs3322
-rw-r--r--main/src/addins/CSharpBinding/Util/SyntaxTriviaExtensions.cs209
-rw-r--r--main/src/addins/CSharpBinding/Util/SyntaxTriviaListExtensions.cs48
-rw-r--r--main/src/addins/CSharpBinding/Util/TaskExtensions.cs349
-rw-r--r--main/src/addins/CSharpBinding/Util/TextLineExtension.cs63
-rw-r--r--main/src/addins/CSharpBinding/Util/TokenComparer.cs83
-rw-r--r--main/src/addins/CSharpBinding/Util/TypeDeclarationSyntaxExtensions.cs321
-rw-r--r--main/src/addins/CSharpBinding/Util/TypeExtensions.cs154
-rw-r--r--main/src/addins/CSharpBinding/Util/TypeGenerator.cs104
-rw-r--r--main/src/addins/CSharpBinding/Util/TypeSyntaxComparer.cs64
-rw-r--r--main/src/addins/CSharpBinding/Util/TypeSyntaxExtensions.cs114
-rw-r--r--main/src/addins/CSharpBinding/Util/UsingsAndExternAliasesDirectiveComparer.cs121
-rw-r--r--main/src/addins/CSharpBinding/Util/UsingsAndExternAliasesOrganizer.cs63
-rw-r--r--main/src/addins/CSharpBinding/Util/ValueTuple.cs18
-rw-r--r--main/src/addins/CSharpBinding/Util/ValueTuple`2.cs57
-rw-r--r--main/src/addins/CSharpBinding/gtk-gui/gui.stetic618
-rw-r--r--main/src/addins/CSharpBinding/packages.config4
-rw-r--r--main/src/addins/ChangeLogAddIn/ChangeLogAddIn.csproj3
-rw-r--r--main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj3
-rw-r--r--main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj3
-rw-r--r--main/src/addins/GnomePlatform/GnomePlatform.csproj3
-rw-r--r--main/src/addins/ILAsmBinding/ILAsmBinding.csproj7
-rw-r--r--main/src/addins/MacPlatform/AssemblyInfo.cs2
-rw-r--r--main/src/addins/MacPlatform/MacPlatform.csproj6
-rw-r--r--main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.csproj4
-rw-r--r--main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.csproj3
-rw-r--r--main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics.csproj1
-rw-r--r--main/src/addins/MonoDevelop.ConnectedServices/MonoDevelop.ConnectedServices.csproj22
-rw-r--r--main/src/addins/MonoDevelop.ConnectedServices/packages.config2
-rw-r--r--main/src/addins/MonoDevelop.Debugger.Gdb/MonoDevelop.Debugger.Gdb.csproj3
-rw-r--r--main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/MonoDevelop.Debugger.Soft.AspNet.csproj3
-rw-r--r--main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.Moonlight/MonoDevelop.Debugger.Soft.Moonlight.csproj1
-rw-r--r--main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.csproj3
-rw-r--r--main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol.csproj5
-rw-r--r--main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.csproj7
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj3
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj3
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/BreakpointPropertiesDialog.cs3
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.csproj3
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/BindingService.cs11
-rw-r--r--main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj3
-rw-r--r--main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs24
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests.csproj5
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.csproj9
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs5
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreRunConfiguration.cs1
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/Properties/AssemblyInfo.cs3
-rw-r--r--main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj7
-rw-r--r--main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/MakefileHandler.cs2
-rw-r--r--main/src/addins/MonoDevelop.Gettext/templates/Makefile_am.template (renamed from main/src/addins/MonoDevelop.Gettext/templates/Makefile.am.template)2
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj3
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/libstetic/libstetic.csproj3
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/libsteticui/libsteticui.csproj1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/AssemblyInfo.cs9
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/Makefile.am3
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Commands/GtkCommands.cs45
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/BindDesignDialog.cs186
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/ConfirmWindowDeleteDialog.cs79
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/GtkDesignerOptionsPanelWidget.cs64
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs81
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/ProjectConversionDialog.cs40
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/SelectRenamedClassDialog.cs93
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs143
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs206
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs316
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs64
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs360
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/CombinedDesignView.cs307
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs71
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDisplayBinding.cs105
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDocumentOutline.cs104
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs743
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs635
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs613
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs260
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/PropertiesWidget.cs211
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs77
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ToolboxProvider.cs201
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs145
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolder.cs42
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolderNodeBuilder.cs177
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs52
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs179
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs156
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs140
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs88
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/Counters.cs38
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/GtkCoreService.cs43
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/GtkDesignInfo.cs676
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ObjectsDocument.cs301
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ProjectResourceProvider.cs89
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ReferenceManager.cs291
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs172
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/WidgetParser.cs226
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.addin.xml210
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.csproj206
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.sln32
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.xbuild.csproj215
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/README14
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/addin-project.xml7
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/build/debug/Mono.TextEditor.dll.config18
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Core.dll.config4
-rwxr-xr-xmain/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Projects.Formats.MSBuild.exebin11264 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Projects.Formats.MSBuild.exe.config16
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/build/debug/libstetic2.dll.config8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/build/debug/libsteticui2.dll.config8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/changes.patch6455
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/gtk-gui/MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.cs40
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/gtk-gui/MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs183
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/gtk-gui/generated.cs82
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/gtk-gui/gui.stetic231
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/gui.glade710
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/icons/actiongroup.pngbin274 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/icons/dialog.pngbin671 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/icons/gtk-logo-orig.pngbin31621 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/icons/gtk-logo.pngbin21915 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/icons/gtkx.pngbin4683 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/icons/image-x-generic.pngbin558 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/icons/widget.pngbin337 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/icons/window.pngbin321 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ClassDescriptor.cs344
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/Clipboard.cs91
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/CommandDescriptor.cs152
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/CustomWidget.cs27
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/DND.cs630
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/EnumDescriptor.cs86
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ErrorWidget.cs111
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/GeneratorContext.cs546
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/GladeException.cs59
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/GladeUtils.cs773
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/IDesignArea.cs39
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/IEditableObject.cs18
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/IProject.cs33
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/IPropertyEditor.cs23
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/IRadioGroupManager.cs21
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/IResourceProvider.cs72
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ImageInfo.cs215
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemDescriptor.cs158
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemGroup.cs78
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemGroupCollection.cs42
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/Makefile.am1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/NoGuiDispatchAttribute.cs9
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectReader.cs38
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWrapper.cs482
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWrapperEventHandler.cs20
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWriter.cs38
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ParamSpec.cs225
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/Placeholder.cs151
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/ProjectIconFactory.cs335
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyDescriptor.cs310
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyEditorAttribute.cs36
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyEditorCell.cs303
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/RadioGroupManager.cs212
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/Registry.cs370
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/Set.cs51
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/SignalDescriptor.cs70
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/TopLevelDialog.cs39
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/TopLevelWindow.cs57
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/TranslatableAttribute.cs8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedClassDescriptor.cs221
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedPropertyDescriptor.cs321
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedSignalDescriptor.cs59
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/WidgetLibrary.cs163
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/WidgetUtils.cs393
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/bin/Release/libstetic2.dll.config8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Accelerator.cs196
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionGroupEditor.cs577
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionItem.cs209
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenu.cs650
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenuBar.cs555
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenuItem.cs588
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionToolItem.cs371
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionToolbar.cs542
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Boolean.cs67
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/CellRendererComboBox.cs111
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Char.cs45
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Color.cs54
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/DateTimeEditor.cs72
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/EditIconDialog.cs284
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/EditIconFactoryDialog.cs95
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Enumeration.cs87
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Flags.cs174
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/FlagsSelectorDialog.cs79
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/FloatRange.cs47
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/GroupPicker.cs175
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconList.cs205
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorItem.cs285
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorMenu.cs56
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorMenuItem.cs59
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Identifier.cs78
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Image.cs265
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ImageFile.cs10
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ImageSelector.cs177
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IntRange.cs120
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/NonContainerWarningDialog.cs51
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/OptIntRange.cs90
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ProjectIconList.cs29
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ProjectIconSelectorItem.cs21
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ResponseId.cs100
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/SelectIconDialog.cs179
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/SelectImageDialog.cs314
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockIconList.cs27
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockIconSelectorItem.cs134
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockItem.cs200
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/String.cs44
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StringArray.cs99
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Text.cs14
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextBox.cs51
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextEditor.cs83
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextEditorDialog.cs70
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ThemedIcon.cs162
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ThemedIconList.cs1018
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TimeSpanEditor.cs67
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Translatable.cs233
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TreeViewCellContainer.cs82
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/WidgetSelector.cs98
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic.csproj455
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic.dll.config8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic2.csproj455
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic2.dll.config8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/stetic.glade2107
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/ActionDiffAdaptor.cs273
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/DiffGenerator.cs319
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/IDiffAdaptor.cs31
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/UndoManager.cs315
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/XmlDiffAdaptor.cs230
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/AboutDialog.cs75
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Action.cs504
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionGroup.cs425
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionToolbarWrapper.cs294
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionTree.cs351
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Bin.cs388
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Box.cs276
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Button.cs339
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ButtonBox.cs161
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/CheckButton.cs90
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ColorButton.cs37
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ComboBox.cs122
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ComboBoxEntry.cs32
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Container.cs1456
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Custom.cs123
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Dialog.cs183
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Entry.cs15
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Expander.cs80
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Fixed.cs91
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/FontButton.cs22
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/FontSelectionDialog.cs19
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Frame.cs92
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/HScale.cs18
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/HScrollbar.cs18
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/IconView.cs39
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Image.cs80
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ImageMenuItem.cs62
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Label.cs49
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MenuBar.cs261
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MenuItem.cs110
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MessageDialog.cs141
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Misc.cs35
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Notebook.cs269
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Object.cs49
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/OptionMenu.cs79
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Paned.cs73
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioActionGroupManager.cs144
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioButton.cs80
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioMenuItem.cs75
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioToolButton.cs80
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Range.cs24
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Scale.cs24
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ScrolledWindow.cs112
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Signal.cs60
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalChangedEventHandler.cs19
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalCollection.cs89
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalEventHandler.cs19
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SpinButton.cs12
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Table.cs520
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/TextView.cs62
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ToggleToolButton.cs12
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ToolButton.cs147
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Toolbar.cs178
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/TreeView.cs21
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/VScale.cs18
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/VScrollbar.cs18
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Viewport.cs28
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Widget.cs1094
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/WidgetEventHandler.cs33
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/WidgetNameChangedHandler.cs25
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Window.cs223
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/objects.xml2274
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/COPIED1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/accellabel.pngbin489 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/actiongroup.pngbin274 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/add-check-label.pngbin626 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/add-menu.pngbin381 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/alignment.pngbin213 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/arrow.pngbin378 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/box-expand.pngbin338 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/box-fill.pngbin357 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/button.pngbin374 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/calendar.pngbin478 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-expand-h.pngbin332 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-expand-v.pngbin341 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-fill-h.pngbin296 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-fill-v.pngbin332 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/checkbutton.pngbin360 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorbutton.pngbin1136 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorselection.pngbin1136 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorselectiondialog.pngbin1136 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/combo.pngbin456 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/comboentry.pngbin529 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/custom.pngbin212 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/dec-border.pngbin363 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/dialog.pngbin671 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/drawingarea.pngbin926 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/entry.pngbin606 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/eventbox.pngbin565 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/expander.pngbin536 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fileselection.pngbin1230 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fixed.pngbin122 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontbutton.pngbin774 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontselection.pngbin774 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontselectiondialog.pngbin605 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/frame.pngbin307 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/globe-not.pngbin795 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/globe.pngbin715 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/handlebox.pngbin339 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hbox.pngbin397 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hbuttonbox.pngbin274 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hpaned.pngbin655 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hscale.pngbin255 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hscrollbar.pngbin324 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hseparator.pngbin315 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/iconview.pngbin590 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/image.pngbin594 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/inc-border.pngbin370 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/label.pngbin420 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/menu.pngbin284 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/menubar.pngbin593 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/messagedialog.pngbin726 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/missing.pngbin357 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/notebook.pngbin752 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/optionmenu.pngbin501 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/progressbar.pngbin194 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/radiobutton.pngbin560 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/remove-check-label.pngbin593 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/remove-menu.pngbin324 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/scrolledwindow.pngbin667 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/spinbutton.pngbin523 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/statusbar.pngbin199 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/table.pngbin499 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/textview.pngbin592 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/togglebutton.pngbin612 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/toolbar.pngbin788 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/treeview.pngbin556 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vbox.pngbin373 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vbuttonbox.pngbin268 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/viewport.pngbin204 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vpaned.pngbin787 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vscale.pngbin279 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vscrollbar.pngbin362 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vseparator.pngbin327 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/widget.pngbin337 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/window.pngbin321 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionComponent.cs75
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupComponent.cs58
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupDesigner.cs278
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupDesignerBackend.cs45
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupEditSession.cs355
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupToolbar.cs275
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Application.cs584
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ApplicationBackend.cs653
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ApplicationBackendController.cs105
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/AssemblyResolver.cs242
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/AssemblyWidgetLibrary.cs141
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilClassDescriptor.cs382
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilPropertyDescriptor.cs127
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilSignalDescriptor.cs88
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilWidgetLibrary.cs368
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGenerationResult.cs26
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGenerator.cs432
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGeneratorPartialClass.cs143
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Component.cs112
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentEventHandler.cs67
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentSignalEventHandler.cs27
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentType.cs94
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ContainerUndoRedoManager.cs18
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ContextMenu.cs174
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Designer.cs44
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Glade.cs63
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Grid.cs347
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/GuiDispatchServerSink.cs142
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/GuiDispatchServerSinkProvider.cs30
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/IProjectDesignInfo.cs22
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/LibraryCache.cs793
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Makefile.am1
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ButtonFunction.cs20
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ButtonLayout.cs36
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/FrameFlags.cs30
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/FrameType.cs22
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ObjectManager.cs19
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/Preview.cs227
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/Theme.cs41
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Palette.cs46
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/PaletteBackend.cs409
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/PluggableWidget.cs154
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Project.cs870
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ProjectBackend.cs1237
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/ProjectViewBackend.cs345
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyEditor.cs64
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyGrid.cs275
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyTree.cs567
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Shadow.cs116
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/SignalsEditor.cs90
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/SignalsEditorBackend.cs481
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/UndoQueue.cs282
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/UserInterface.cs34
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetActionBar.cs251
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetComponent.cs122
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetDesigner.cs423
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetDesignerBackend.cs961
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetEditSession.cs368
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetFactory.cs136
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetInfoEventHandler.cs41
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetPropertyTree.cs28
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetPropertyTreeBackend.cs118
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetTree.cs92
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetTreeCombo.cs213
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Windows/Preview.cs109
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/Windows/WindowsTheme.cs201
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/action.pngbin319 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/bin/Release/libstetic2.dll.config8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/bin/Release/libsteticui2.dll.config8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui.csproj156
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui.dll.config8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui2.csproj172
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui2.dll.config8
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/libsteticui/missing.pngbin357 -> 0 bytes
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/monodevelop-slim.sln146
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/templates/ActionGroup.xft.xml66
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/templates/ActionGroupPartial.xft.xml62
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/templates/Dialog.xft.xml126
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/templates/DialogPartial.xft.xml122
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/templates/DrawingArea.xft.xml171
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/templates/Widget.xft.xml76
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/templates/WidgetPartial.xft.xml72
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/templates/Window.xft.xml75
-rw-r--r--main/src/addins/MonoDevelop.GtkCore2/templates/WindowPartial.xft.xml71
-rw-r--r--main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor.csproj3
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/AssemblyInfo.cs9
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Makefile.am1
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanel.cs52
-rwxr-xr-xmain/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanelWidget.cs128
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.addin.xml103
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.csproj155
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightBuildExtension.cs605
-rwxr-xr-xmain/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightEditorExtension.cs204
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightExecutionCommand.cs50
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightExecutionHandler.cs48
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightFrameworkBackend.cs171
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightParser.cs186
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProject.cs437
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProjectBinding.cs50
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProjectConfiguration.cs48
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/XamlG.cs289
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-ApplicationProject.xpt.xml108
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-ApplicationXaml.xft.xml52
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-LibraryProject.xpt.xml41
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-UserControlXaml.xft.xml54
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Templates/PreviewTemplate.html76
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Templates/Silverlight.js891
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_2_0.xml15
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_3_0.xml15
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_4_0.xml15
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/gtk-gui/MonoDevelop.Moonlight.Gui.MoonlightOptionsPanelWidget.cs308
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/gtk-gui/generated.cs81
-rw-r--r--main/src/addins/MonoDevelop.Moonlight/gtk-gui/gui.stetic404
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/AssemblyInfo.cs7
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.csproj8
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/packages.config2
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj16
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs19
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SearchPackagesSearchCategory.cs2
-rw-r--r--main/src/addins/MonoDevelop.PackageManagement/packages.config2
-rw-r--r--main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.Tests/MonoDevelop.Packaging.Tests.csproj5
-rw-r--r--main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.csproj8
-rw-r--r--main/src/addins/MonoDevelop.Packaging/Properties/AssemblyInfo.cs1
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/AssemblyInfo.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisCommands.cs267
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisExtensions.cs240
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisService.cs56
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/AnalysisRuleAddinNode.cs150
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/AnalysisTypeExtensionNode.cs40
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/FixHandlerExtensionNode.cs44
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/FixableResult.cs68
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/GenericFix.cs107
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/RenameMemberFix.cs145
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs14
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/README.txt71
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Result.cs5
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/RuleTree.cs205
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/RuleTreeType.cs34
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/TODO.txt48
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs604
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeFixMenuService.cs510
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeRefactoringService.cs12
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalyzersFromAssembly.cs62
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BuiltInCodeDiagnosticProvider.cs10
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CSharpSuppressionFixProvider.cs119
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticDescriptor.cs85
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticFixDescriptor.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticRunner.cs10
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs82
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DiagnosticResult.cs11
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ISuppressionFixProvider.cs63
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml56
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj41
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/InsertionPointService.cs2
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs23
-rw-r--r--main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit.csproj3
-rw-r--r--main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/ValidateActionCodeRefactoringProvider.cs2
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/AssemblyInfo.cs10
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs2
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj16
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting.NUnit.Runners/MonoDevelop.UnitTesting.NUnit.Runners.csproj5
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit.csproj3
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnit3Runner/NUnit3Runner.csproj5
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/NUnitRunner.csproj3
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj3
-rw-r--r--main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.csproj3
-rw-r--r--main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.csproj3
-rw-r--r--main/src/addins/MonoDeveloperExtensions/NUnit/NUnit.csproj6
-rw-r--r--main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/PerformanceDiagnosticsAddIn.csproj5
-rw-r--r--main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/AssemblyInfo.cs2
-rw-r--r--main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/Properties/AssemblyInfo.cs2
-rw-r--r--main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/UIThreadMonitorDaemon.csproj5
-rw-r--r--main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj6
-rw-r--r--main/src/addins/VBNetBinding/VBNetBinding.addin.xml2
-rw-r--r--main/src/addins/VBNetBinding/VBNetBinding.csproj7
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/MonoDevelop.VersionControl.Git.Tests.csproj3
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/AssemblyInfo.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj6
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/MonoDevelop.VersionControl.Subversion.Tests.csproj3
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/AssemblyInfo.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj8
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/AssemblyInfo.cs3
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj8
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/AssemblyInfo.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj7
-rw-r--r--main/src/addins/VersionControl/Subversion.Win32.Tests/VersionControl.Subversion.Win32.Tests.csproj5
-rw-r--r--main/src/addins/VersionControl/Subversion.Win32/Properties/AssemblyInfo.cs2
-rw-r--r--main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj8
-rw-r--r--main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Core.csproj8
-rw-r--r--main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Properties/AssemblyInfo.cs5
-rw-r--r--main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Properties/AssemblyInfo.cs4
-rw-r--r--main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Shell.csproj7
-rw-r--r--main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.csproj5
-rw-r--r--main/src/addins/Xml/MonoDevelop.Xml.csproj3
-rw-r--r--main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj3
-rw-r--r--main/src/core/MonoDevelop.Core/AssemblyInfo.cs4
-rw-r--r--main/src/core/MonoDevelop.Core/BuildVariables.cs.in1
-rw-r--r--main/src/core/MonoDevelop.Core/BuildVariables.gen.cs30
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MsNetTargetRuntime.cs20
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj149
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs5
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs13
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs46
-rw-r--r--main/src/core/MonoDevelop.Core/packages.config88
-rw-r--r--main/src/core/MonoDevelop.Ide/AssemblyInfo.cs28
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs5
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/AutoSave.cs14
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Extensions/MimeTypeNode.cs8
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceData.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/RunConfigurationsPanel.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/SolutionRunConfigurationsPanel.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/DocumentTrackingService.cs59
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/EditorNotificationServiceFactory.cs84
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/GlobalOptionPersister.cs115
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs8
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopPersistentStorageServiceFactory.cs254
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopProjectCacheHostServiceFactory.cs134
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTemporaryStorageServiceFactory.cs139
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs22
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/NR5CompatibiltyExtensions.cs136
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ProjectCacheService.cs676
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TextPolicyDocumentOptionsProvider.cs98
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs46
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs173
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj99
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs14
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/AssemblyInfo.v15.0.cs (renamed from main/src/core/MonoDevelop.Projects.Formats.MSBuild/AssemblyInfo.v14.1.cs)0
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.csproj2
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v12.0.csproj70
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.0.csproj60
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v15.0.csproj (renamed from main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.1.csproj)19
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v4.0.csproj63
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v12.0.csproj4
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v14.0.csproj4
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v4.0.csproj4
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.windows.config1
-rw-r--r--main/src/core/MonoDevelop.Startup/MonoDevelop.Startup.csproj3
-rw-r--r--main/src/core/MonoDevelop.Startup/app.config79
-rw-r--r--main/src/core/MonoDevelop.TextEditor.Tests/MonoDevelop.TextEditor.Tests.csproj3
-rw-r--r--main/src/tools/mdhost/mdhost.csproj3
-rw-r--r--main/src/tools/mdmonitor/AssemblyInfo.cs2
-rw-r--r--main/src/tools/mdmonitor/mdmonitor.csproj5
-rw-r--r--main/src/tools/mdtool/mdtool.csproj3
-rw-r--r--main/tests/Ide.Tests/Ide.Tests.csproj3
-rw-r--r--main/tests/MacPlatform.Tests/AssemblyInfo.cs2
-rw-r--r--main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj3
-rw-r--r--main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/CodeCompletionBugTests.cs12
-rw-r--r--main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/ImportCompletionTests.cs2
-rw-r--r--main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/NameContextTests.cs6
-rw-r--r--main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/VariableDeclarationStatementTests.cs1
-rw-r--r--main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/PortedRoslynTests/SymbolCompletionHandlerTests.cs4
-rw-r--r--main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding.Tests.csproj13
-rw-r--r--main/tests/TestRunner/Properties/AssemblyInfo.cs2
-rw-r--r--main/tests/TestRunner/TestRunner.csproj5
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/GetSourceFilesAsyncTests.cs16
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs35
-rw-r--r--main/tests/UnitTests/MonoDevelop.SourceEditor/JSonIndentEngineTests.cs2
-rw-r--r--main/tests/UnitTests/UnitTests.csproj6
-rw-r--r--main/tests/UserInterfaceTests/UserInterfaceTests.csproj5
-rw-r--r--main/tests/UserInterfaceTests/packages.config2
-rw-r--r--main/tests/WindowsPlatform.Tests/Properties/AssemblyInfo.cs2
-rw-r--r--main/tests/WindowsPlatform.Tests/WindowsPlatform.Tests.csproj5
-rw-r--r--main/tests/test-projects/project-with-corecompiledepends/project-with-conditioned-file.csproj81
-rw-r--r--main/winbuild.bat45
-rw-r--r--main/xbuild.include2
1121 files changed, 3592 insertions, 143444 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000000..df5b803581
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,90 @@
+# EditorConfig is awesome:http://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+# Baseline
+[*]
+charset = utf-8
+indent_style = tab
+trim_trailing_whitespace = true
+max_line_length = 120
+
+# MSBuild
+[*.{csproj,proj,projitems,shproj,fsproj,target,props}]
+indent_style = space
+indent_size = 2
+
+# XML config files
+[*.{config,nuspec,resx}]
+indent_style = space
+indent_size = 2
+
+# JSON files
+[*.json]
+indent_style = space
+indent_size = 2
+
+# Dotnet code style settings:
+[*.{cs,vb}]
+
+# Sort using and Import directives with System.* appearing first
+dotnet_sort_system_directives_first = true
+
+# Avoid "this." and "Me." if not necessary
+dotnet_style_qualification_for_field = false:suggestion
+dotnet_style_qualification_for_property = false:suggestion
+dotnet_style_qualification_for_method = false:suggestion
+dotnet_style_qualification_for_event = false:suggestion
+
+# Use language keywords instead of framework type names for type references
+dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
+dotnet_style_predefined_type_for_member_access = true:suggestion
+
+# Suggest more modern language features when available
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_collection_initializer = true:suggestion
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_null_propagation = true:suggestion
+dotnet_style_explicit_tuple_names = true:suggestion
+
+# CSharp code style settings:
+[*.cs]
+
+# spaces before parens
+csharp_space_between_method_declaration_name_and_open_parenthesis = true
+csharp_space_between_method_call_name_and_opening_parenthesis = true
+csharp_space_after_keywords_in_control_flow_statements = true
+
+# Newline settings
+csharp_new_line_before_open_brace = types,methods
+csharp_new_line_before_else = true
+csharp_new_line_before_catch = true
+csharp_new_line_before_finally = true
+csharp_new_line_before_members_in_object_initializers = true
+csharp_new_line_before_members_in_anonymous_types = true
+
+# Switch indentation
+csharp_indent_switch_labels = false
+
+# Prefer "var" everywhere it's apparent
+csharp_style_var_for_built_in_types = true:suggestion
+csharp_style_var_when_type_is_apparent = true:suggestion
+csharp_style_var_elsewhere = false:suggestion
+
+# Prefer method-like constructs to have a block body
+csharp_style_expression_bodied_methods = false:none
+csharp_style_expression_bodied_constructors = false:none
+csharp_style_expression_bodied_operators = false:none
+
+# Prefer property-like constructs to have an expression-body
+csharp_style_expression_bodied_properties = true:none
+csharp_style_expression_bodied_indexers = true:none
+csharp_style_expression_bodied_accessors = true:none
+
+# Suggest more modern language features when available
+csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
+csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
+csharp_style_inlined_variable_declaration = true:suggestion
+csharp_style_throw_expression = true:suggestion
+csharp_style_conditional_delegate_call = true:suggestion
diff --git a/.gitmodules b/.gitmodules
index ffbc060f8b..91a0d92958 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -53,8 +53,8 @@
branch = xs-5.10-v2
[submodule "main/external/RefactoringEssentials"]
path = main/external/RefactoringEssentials
- url = git://github.com/icsharpcode/RefactoringEssentials.git
- branch = monodevelop
+ url = git://github.com/mhutch/RefactoringEssentials.git
+ branch = roslyn2
[submodule "main/external/macdoc"]
path = main/external/macdoc
url = git://github.com/xamarin/macdoc
diff --git a/NuGet.config b/NuGet.config
index dff8e67d3f..b5e8933c61 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -2,6 +2,8 @@
<configuration>
<packageSources>
<add key="Nuget Official" value ="https://www.nuget.org/api/v2/" />
+ <add key="Nuget Official" value ="https://api.nuget.org/v3/index.json" />
+ <add key="Roslyn Nightlies" value ="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
<add key="NuGetizer3000" value="https://ci.appveyor.com/nuget/nugetizer3000" />
<add key="VSTest" value="https://dotnet.myget.org/F/vstest/" />
<add key="Templating" value="https://dotnet.myget.org/F/templating/" />
diff --git a/dependency_checker.rb b/dependency_checker.rb
index ff4ba3533e..e0b10ed9ce 100644
--- a/dependency_checker.rb
+++ b/dependency_checker.rb
@@ -3,7 +3,7 @@ require 'pp'
NOT_INSTALLED_VERSION="-1"
XAMARIN_MAC_MIN_VERSION="2.3"
-XAMARIN_MAC_VERSION=lambda { product_version ("/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin/mmp") }
+XAMARIN_MAC_VERSION=lambda { product_version ("/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version") }
XAMARIN_MAC_URL="http://www.xamarin.com"
MONO_MIN_VERSION="4.2"
@@ -33,10 +33,9 @@ def mono_version(binary)
end
end
-def product_version(binary)
- if File.exist?("#{binary}")
- version = `#{binary} --version`
- return version.split(' ')[1]
+def product_version(version_file)
+ if File.exist?(version_file)
+ return File.open(version_file, 'rb') { |f| f.read }
else
return NOT_INSTALLED_VERSION
end
diff --git a/main/Main.sln b/main/Main.sln
index f998f12103..bc46a8fae4 100644
--- a/main/Main.sln
+++ b/main/Main.sln
@@ -1,6 +1,7 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26228.4
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{9D360D43-0C05-49D6-84DB-4E7AB2F38F82}"
ProjectSection(MonoDevelopProperties) = preProject
BaseDirectory = src\core
@@ -18,16 +19,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MonoDevelop.Projects.Format
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild", "src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.csproj", "{A437F1A3-78DF-4F00-8053-D32A8B1EB679}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild.dotnet.v4.0", "src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.dotnet.v4.0.csproj", "{DB96F55E-41C5-4330-A427-15A4EC028BBE}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild.v12.0", "src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.v12.0.csproj", "{5C1BC0B9-735E-45DA-ACAC-4BD466917608}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild.v14.0", "src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.v14.0.csproj", "{34B0441E-59E4-4F5C-9BBE-26F3C02A39C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild.v4.0", "src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.v4.0.csproj", "{B257A1A3-78DF-4F00-8053-D32A8B1EB679}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild.dotnet.v12.0", "src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.dotnet.v12.0.csproj", "{C4B0275C-37D3-43F2-927D-ABF556600804}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Addins", "Addins", "{D417E929-2B3A-46AC-BBE8-027ADB63A790}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILAsmBinding", "src\addins\ILAsmBinding\ILAsmBinding.csproj", "{961B9266-C44A-42B6-BA3D-3FB229C9C417}"
@@ -272,12 +269,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ide.Tests", "tests\Ide.Test
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsPlatform.Tests", "tests\WindowsPlatform.Tests\WindowsPlatform.Tests.csproj", "{865100E2-A29C-4FCD-B803-1A0B9A0A6EF7}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RefactoringEssentials", "external\RefactoringEssentials\RefactoringEssentials\RefactoringEssentials.csproj", "{C465A5DC-AD28-49A2-89C0-F81838814A7E}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RefactoringEssentials", "external\RefactoringEssentials\RefactoringEssentials.2017\RefactoringEssentials.csproj", "{C465A5DC-AD28-49A2-89C0-F81838814A7E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.CSharpBinding.Tests", "tests\MonoDevelop.CSharpBinding.Tests\MonoDevelop.CSharpBinding.Tests.csproj", "{84E22F5F-0562-4B51-8B9A-FD79FF33A8B5}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.0", "src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.0.csproj", "{8EE5A588-9445-48EC-97BD-BF066E7FFD51}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.UnitTesting.NUnit", "src\addins\MonoDevelop.UnitTesting.NUnit\MonoDevelop.UnitTesting.NUnit.csproj", "{6224D87E-2AC1-4D9F-91ED-714F797297BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NUnit3Runner", "src\addins\MonoDevelop.UnitTesting.NUnit\NUnit3Runner\NUnit3Runner.csproj", "{D2A4E99E-FC2D-45A9-8BE7-1AB7DF95BA2A}"
@@ -287,15 +282,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FSharpBinding", "FSharpBind
external\fsharpbinding\build.fsx = external\fsharpbinding\build.fsx
EndProjectSection
EndProject
-Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "MonoDevelop.FSharp", "external\fsharpbinding\MonoDevelop.FSharpBinding\MonoDevelop.FSharp.fsproj", "{4C10F8F9-3816-4647-BA6E-85F5DE39883A}"
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "MonoDevelop.FSharp", "external\fsharpbinding\MonoDevelop.FSharpBinding\MonoDevelop.FSharp.fsproj", "{4C10F8F9-3816-4647-BA6E-85F5DE39883A}"
EndProject
-Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "MonoDevelop.FSharp.Shared", "external\fsharpbinding\MonoDevelop.FSharp.Shared\MonoDevelop.FSharp.Shared.fsproj", "{AF5FEAD5-B50E-4F07-A274-32F23D5C504D}"
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "MonoDevelop.FSharp.Shared", "external\fsharpbinding\MonoDevelop.FSharp.Shared\MonoDevelop.FSharp.Shared.fsproj", "{AF5FEAD5-B50E-4F07-A274-32F23D5C504D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.FSharp.Gui", "external\fsharpbinding\MonoDevelop.FSharp.Gui\MonoDevelop.FSharp.Gui.csproj", "{FD0D1033-9145-48E5-8ED8-E2365252878C}"
EndProject
-Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "MonoDevelop.FSharpInteractive.Service", "external\fsharpbinding\MonoDevelop.FSharpi.Service\MonoDevelop.FSharpInteractive.Service.fsproj", "{20D6EC2C-B62E-49D1-B685-90D8967A5B5D}"
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "MonoDevelop.FSharpInteractive.Service", "external\fsharpbinding\MonoDevelop.FSharpi.Service\MonoDevelop.FSharpInteractive.Service.fsproj", "{20D6EC2C-B62E-49D1-B685-90D8967A5B5D}"
EndProject
-Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "MonoDevelop.FSharp.Tests", "external\fsharpbinding\MonoDevelop.FSharp.Tests\MonoDevelop.FSharp.Tests.fsproj", "{A1A45375-7FB8-4F2A-850F-FBCC67739927}"
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "MonoDevelop.FSharp.Tests", "external\fsharpbinding\MonoDevelop.FSharp.Tests\MonoDevelop.FSharp.Tests.fsproj", "{A1A45375-7FB8-4F2A-850F-FBCC67739927}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Mono.TextEditor.Shared", "src\core\Mono.TextEditor.Shared\Mono.TextEditor.Shared.shproj", "{FBAAD910-F29B-4AC5-9FC0-27F6EB36C495}"
EndProject
@@ -305,7 +300,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Packaging", "sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Packaging.Tests", "src\addins\MonoDevelop.Packaging\MonoDevelop.Packaging.Tests\MonoDevelop.Packaging.Tests.csproj", "{25FBDD35-1CA0-4BED-93F6-927FAF33F96B}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.1", "src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.1.csproj", "{7F5B649A-3572-4713-83FD-C28A6AA70445}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild.dotnet.v15.0", "src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.dotnet.v15.0.csproj", "{7F5B649A-3572-4713-83FD-C28A6AA70445}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PerformanceDiagnostics", "PerformanceDiagnostics", "{19C4CC37-7050-4944-B11F-60F52121B24C}"
EndProject
@@ -1422,16 +1417,6 @@ Global
{C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
{C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
{C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
- {C4B0275C-37D3-43F2-927D-ABF556600804}.Debug|Any CPU.ActiveCfg = Debug|x86
- {C4B0275C-37D3-43F2-927D-ABF556600804}.DebugGnome|Any CPU.ActiveCfg = Debug|x86
- {C4B0275C-37D3-43F2-927D-ABF556600804}.DebugMac|Any CPU.ActiveCfg = Debug|x86
- {C4B0275C-37D3-43F2-927D-ABF556600804}.DebugWin32|Any CPU.ActiveCfg = Debug|x86
- {C4B0275C-37D3-43F2-927D-ABF556600804}.DebugWin32|Any CPU.Build.0 = Debug|x86
- {C4B0275C-37D3-43F2-927D-ABF556600804}.Release|Any CPU.ActiveCfg = Release|x86
- {C4B0275C-37D3-43F2-927D-ABF556600804}.ReleaseGnome|Any CPU.ActiveCfg = Release|x86
- {C4B0275C-37D3-43F2-927D-ABF556600804}.ReleaseMac|Any CPU.ActiveCfg = Release|x86
- {C4B0275C-37D3-43F2-927D-ABF556600804}.ReleaseWin32|Any CPU.ActiveCfg = Release|x86
- {C4B0275C-37D3-43F2-927D-ABF556600804}.ReleaseWin32|Any CPU.Build.0 = Release|x86
{C93D746E-1586-4D4F-B411-BF5A966E6A08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C93D746E-1586-4D4F-B411-BF5A966E6A08}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
{C93D746E-1586-4D4F-B411-BF5A966E6A08}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU
@@ -1522,16 +1507,6 @@ Global
{DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}.ReleaseMac|Any CPU.Build.0 = Release|x64
{DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}.ReleaseWin32|Any CPU.ActiveCfg = Release|x86
{DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}.ReleaseWin32|Any CPU.Build.0 = Release|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.Debug|Any CPU.ActiveCfg = Debug|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.DebugGnome|Any CPU.ActiveCfg = Debug|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.DebugMac|Any CPU.ActiveCfg = Debug|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.DebugWin32|Any CPU.ActiveCfg = Debug|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.DebugWin32|Any CPU.Build.0 = Debug|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.Release|Any CPU.ActiveCfg = Release|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.ReleaseGnome|Any CPU.ActiveCfg = Release|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.ReleaseMac|Any CPU.ActiveCfg = Release|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.ReleaseWin32|Any CPU.ActiveCfg = Release|x86
- {DB96F55E-41C5-4330-A427-15A4EC028BBE}.ReleaseWin32|Any CPU.Build.0 = Release|x86
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
@@ -1807,20 +1782,6 @@ Global
{84E22F5F-0562-4B51-8B9A-FD79FF33A8B5}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
{84E22F5F-0562-4B51-8B9A-FD79FF33A8B5}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
{84E22F5F-0562-4B51-8B9A-FD79FF33A8B5}.ReleaseGnome|Any CPU.Build.0 = Release|Any CPU
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.Debug|Any CPU.ActiveCfg = Debug|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.DebugMac|Any CPU.ActiveCfg = Debug|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.DebugWin32|Any CPU.ActiveCfg = Debug|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.DebugWin32|Any CPU.Build.0 = Debug|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.Release|Any CPU.ActiveCfg = Release|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.DebugGnome|Any CPU.ActiveCfg = Debug|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.ReleaseMac|Any CPU.ActiveCfg = Release|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.ReleaseWin32|Any CPU.ActiveCfg = Release|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.ReleaseWin32|Any CPU.Build.0 = Release|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.ReleaseGnome|Any CPU.ActiveCfg = Release|x86
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.Debug|x86.ActiveCfg = Debug|Any CPU
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.Debug|x86.Build.0 = Debug|Any CPU
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.Release|x86.ActiveCfg = Release|Any CPU
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51}.Release|x86.Build.0 = Release|Any CPU
{6224D87E-2AC1-4D9F-91ED-714F797297BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6224D87E-2AC1-4D9F-91ED-714F797297BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6224D87E-2AC1-4D9F-91ED-714F797297BF}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU
@@ -2138,11 +2099,9 @@ Global
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2} = {9D360D43-0C05-49D6-84DB-4E7AB2F38F82}
{8F48ECA6-CFFF-4EBF-BC92-817199EDE9AF} = {9D360D43-0C05-49D6-84DB-4E7AB2F38F82}
{A437F1A3-78DF-4F00-8053-D32A8B1EB679} = {8F48ECA6-CFFF-4EBF-BC92-817199EDE9AF}
- {DB96F55E-41C5-4330-A427-15A4EC028BBE} = {8F48ECA6-CFFF-4EBF-BC92-817199EDE9AF}
{B257A1A3-78DF-4F00-8053-D32A8B1EB679} = {8F48ECA6-CFFF-4EBF-BC92-817199EDE9AF}
{5C1BC0B9-735E-45DA-ACAC-4BD466917608} = {8F48ECA6-CFFF-4EBF-BC92-817199EDE9AF}
{34B0441E-59E4-4F5C-9BBE-26F3C02A39C9} = {8F48ECA6-CFFF-4EBF-BC92-817199EDE9AF}
- {C4B0275C-37D3-43F2-927D-ABF556600804} = {8F48ECA6-CFFF-4EBF-BC92-817199EDE9AF}
{961B9266-C44A-42B6-BA3D-3FB229C9C417} = {D417E929-2B3A-46AC-BBE8-027ADB63A790}
{DEEB9163-3966-4E5E-9AB5-FBB3E01AC82A} = {D417E929-2B3A-46AC-BBE8-027ADB63A790}
{02280E65-C507-4931-AE68-AA2E89E15EEF} = {D417E929-2B3A-46AC-BBE8-027ADB63A790}
@@ -2252,7 +2211,6 @@ Global
{865100E2-A29C-4FCD-B803-1A0B9A0A6EF7} = {78C10DAE-D3D7-44FC-93DF-831D8D54ECF9}
{C465A5DC-AD28-49A2-89C0-F81838814A7E} = {F12939F1-D55A-4CE9-9F33-8D959BFC7D6C}
{84E22F5F-0562-4B51-8B9A-FD79FF33A8B5} = {78C10DAE-D3D7-44FC-93DF-831D8D54ECF9}
- {8EE5A588-9445-48EC-97BD-BF066E7FFD51} = {8F48ECA6-CFFF-4EBF-BC92-817199EDE9AF}
{6224D87E-2AC1-4D9F-91ED-714F797297BF} = {DE462010-393D-4655-A42C-2C78BB14D2FA}
{D2A4E99E-FC2D-45A9-8BE7-1AB7DF95BA2A} = {DE462010-393D-4655-A42C-2C78BB14D2FA}
{FBAAD910-F29B-4AC5-9FC0-27F6EB36C495} = {9D360D43-0C05-49D6-84DB-4E7AB2F38F82}
diff --git a/main/Makefile.am b/main/Makefile.am
index 9e50ddc974..16ad128a16 100644
--- a/main/Makefile.am
+++ b/main/Makefile.am
@@ -28,6 +28,7 @@ NUGET_RESTORE = mono external/nuget-binary/nuget.exe restore -DisableParallelPro
# see: https://github.com/kzu/NuGet.Restore
restore-packages:
@$(NUGET_RESTORE)
+ msbuild /t:Restore external/RefactoringEssentials/RefactoringEssentials.2017/RefactoringEssentials.csproj
vcrevision:
touch vcrevision
diff --git a/main/MonoDevelop.props b/main/MonoDevelop.props
new file mode 100644
index 0000000000..55fbe3f65b
--- /dev/null
+++ b/main/MonoDevelop.props
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolVersion="14.0">
+ <PropertyGroup>
+ <MonoDevelopRootDir>$(MSBuildThisFileDirectory)</MonoDevelopRootDir>
+ <CustomBeforeMicrosoftCommonTargets>$(MonoDevelopRootDir)\msbuild\MonoDevelop.BeforeCommon.targets</CustomBeforeMicrosoftCommonTargets>
+ <CustomAfterMicrosoftCommonTargets>$(MonoDevelopRootDir)\msbuild\MonoDevelop.AfterCommon.targets</CustomAfterMicrosoftCommonTargets>
+ <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+ </PropertyGroup>
+ <Import Project="$(MonoDevelopRootDir)\msbuild\MonoDevelop.BeforeCommon.props" />
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
+ <Import Project="$(MonoDevelopRootDir)\msbuild\MonoDevelop.AfterCommon.props" />
+</Project>
diff --git a/main/contrib/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj b/main/contrib/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
index 08ad03daf0..cb5be247e4 100644
--- a/main/contrib/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
+++ b/main/contrib/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
@@ -14,7 +14,6 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\external\nrefactory\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
- <DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
diff --git a/main/external/RefactoringEssentials b/main/external/RefactoringEssentials
-Subproject 270f880559676a8ea7798bf161a352f88971449
+Subproject b93da963deb78add55a9576b9a44ca791f4a209
diff --git a/main/external/debugger-libs b/main/external/debugger-libs
-Subproject 70f0517352284aaabf640735e912e6145dd24fd
+Subproject 06e92f0f95ff10cb1dc958d1b0c5606e473ffa2
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Gui/MonoDevelop.FSharp.Gui.csproj b/main/external/fsharpbinding/MonoDevelop.FSharp.Gui/MonoDevelop.FSharp.Gui.csproj
index 97ddaea74f..15bcd53295 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharp.Gui/MonoDevelop.FSharp.Gui.csproj
+++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Gui/MonoDevelop.FSharp.Gui.csproj
@@ -9,14 +9,14 @@
<OutputType>Library</OutputType>
<AssemblyName>FSharpBinding.Gui</AssemblyName>
<RootNamespace>MonoDevelop.FSharp.Gui</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\FSharpBinding</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
@@ -24,7 +24,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>True</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\FSharpBinding</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj
index 8813fa8a1f..d93bc0799e 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj
+++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj
@@ -1,4 +1,5 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -8,7 +9,8 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.FSharp.Shared</RootNamespace>
<AssemblyName>MonoDevelop.FSharp.Shared</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -59,7 +61,7 @@
<Import Project="$(FSharpTargetsPath)" />
<Import Project="..\.paket\paket.targets" />
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="ExtCore">
<HintPath>..\packages\ExtCore\lib\net45\ExtCore.dll</HintPath>
@@ -70,7 +72,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Compiler.Service.MSBuild.v12">
<HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.MSBuild.v12.dll</HintPath>
@@ -86,7 +88,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath>
@@ -97,7 +99,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll</HintPath>
@@ -108,7 +110,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="System.Reflection.Metadata">
<HintPath>..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll</HintPath>
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompilerArguments.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompilerArguments.fs
index cf3065784e..78552b14b5 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompilerArguments.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompilerArguments.fs
@@ -104,10 +104,10 @@ type CompilerArgumentsTests() =
[<Test>]
member x.``Explicit FSharp.Core and mscorlib referenced``() =
- if not Platform.IsWindows then
+ if Platform.IsMac then
use testProject = createFSharpProject()
let _ = testProject.AddReference "mscorlib"
- let reference = testProject.AddReference "FSharp.Core.dll"
+ let reference = testProject.AddReference "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/FSharp.Core.dll"
let references =
CompilerArguments.generateReferences(testProject,
Some (FSharpCompilerVersion.FSharp_3_1),
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Interactive.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Interactive.fs
index a0937e152c..9d11a9128d 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Interactive.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Interactive.fs
@@ -17,7 +17,7 @@ module Interactive =
async {
let (/) a b = Path.Combine(a,b)
let testDllFolder = Assembly.GetExecutingAssembly().Location |> Path.GetDirectoryName
- let pathToExe = "\"" + testDllFolder/".."/".."/".."/".."/".."/"build"/"AddIns"/"BackendBindings"/"MonoDevelop.FSharpInteractive.Service.exe\""
+ let pathToExe = "\"" + testDllFolder/".."/".."/".."/".."/".."/"build"/"AddIns"/"FSharpBinding"/"MonoDevelop.FSharpInteractive.Service.exe\""
let ses = InteractiveSession(pathToExe)
do! Async.Sleep 1000 // give the process chance to start
if ses.HasExited() then
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj
index 2fc42173a5..3ac983682b 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj
+++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj
@@ -1,4 +1,5 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,10 +10,14 @@
<RootNamespace>MonoDevelop.FSharp.Tests</RootNamespace>
<AssemblyName>MonoDevelop.FSharp.Tests</AssemblyName>
<UsePartialTypes>False</UsePartialTypes>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
<TestRunnerCommand>..\..\..\..\main\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>..\..\..\msbuild\MonoDevelop-Public.snk</AssemblyOriginatorKeyFile>
+ <OtherFlags>--publicsign</OtherFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -27,6 +32,7 @@
<StartAction>Program</StartAction>
<StartProgram>$(MSBuildProjectDirectory)\..\..\..\build\bin\mdtool</StartProgram>
<StartArguments>run-md-tests $(MSBuildProjectDirectory)\bin\Debug\MonoDevelop.FSharp.Tests.dll</StartArguments>
+ <OtherFlags>--publicsign</OtherFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -39,6 +45,7 @@
<ConsolePause>false</ConsolePause>
<Tailcalls>true</Tailcalls>
<DefineConstants>$(DefineConstants)</DefineConstants>
+ <OtherFlags>--publicsign</OtherFlags>
</PropertyGroup>
<ItemGroup>
<Reference Include="pango-sharp">
@@ -73,9 +80,6 @@
<Private>False</Private>
<HintPath>..\..\..\build\bin\Xwt.Gtk.dll</HintPath>
</Reference>
- <Reference Include="monodoc">
- <HintPath>..\..\..\..\main\build\bin\monodoc.dll</HintPath>
- </Reference>
<ProjectReference Include="..\..\..\src\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
<Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
<Name>MonoDevelop.Core</Name>
@@ -100,10 +104,6 @@
<Name>MonoDevelop.Debugger</Name>
<Private>False</Private>
</ProjectReference>
- <Reference Include="MonoDevelop.UnitTesting">
- <Private>False</Private>
- <HintPath>..\..\..\build\AddIns\MonoDevelop.UnitTesting\MonoDevelop.UnitTesting.dll</HintPath>
- </Reference>
<Reference Include="GuiUnit">
<HintPath>..\..\guiunit\bin\net_4_5\GuiUnit.exe</HintPath>
</Reference>
@@ -133,6 +133,21 @@
<ProjectReference Include="..\..\..\src\addins\MonoDevelop.PackageManagement\MonoDevelop.PackageManagement.csproj">
<Project>{F218643D-2E74-4309-820E-206A54B7133F}</Project>
<Name>MonoDevelop.PackageManagement</Name>
+ <Private>False</Private>
+ </ProjectReference>
+ <ProjectReference Include="..\MonoDevelop.FSharpBinding\MonoDevelop.FSharp.fsproj">
+ <Project>{4C10F8F9-3816-4647-BA6E-85F5DE39883A}</Project>
+ <Name>MonoDevelop.FSharp</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\src\addins\MonoDevelop.UnitTesting\MonoDevelop.UnitTesting.csproj">
+ <Project>{A7A4246D-CEC4-42DF-A3C1-C31B9F51C4EC}</Project>
+ <Name>MonoDevelop.UnitTesting</Name>
+ <Private>False</Private>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\src\addins\MonoDevelop.SourceEditor2\MonoDevelop.SourceEditor.csproj">
+ <Project>{F8F92AA4-A376-4679-A9D4-60E7B7FBF477}</Project>
+ <Name>MonoDevelop.SourceEditor</Name>
+ <Private>False</Private>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
@@ -217,7 +232,7 @@
</MonoDevelop>
</ProjectExtensions>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="ExtCore">
<HintPath>..\packages\ExtCore\lib\net45\ExtCore.dll</HintPath>
@@ -228,7 +243,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Compiler.Service.MSBuild.v12">
<HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.MSBuild.v12.dll</HintPath>
@@ -244,7 +259,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath>
@@ -255,7 +270,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="Mono.Cecil.Mdb">
<HintPath>..\packages\Mono.Cecil\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
@@ -281,7 +296,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll</HintPath>
@@ -292,7 +307,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="System.Reflection.Metadata">
<HintPath>..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll</HintPath>
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/ProjectTests.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/ProjectTests.fs
index d92ccc2e18..cd98962fe6 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/ProjectTests.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/ProjectTests.fs
@@ -19,7 +19,7 @@ type ProjectTests() =
let (/) a b = Path.Combine (a, b)
[<Test>]
- member this.Can_reorder_nodes() =
+ member this.``Can reorder nodes``() =
if not MonoDevelop.Core.Platform.IsWindows then
let xml =
"""
@@ -50,6 +50,39 @@ type ProjectTests() =
</Project>"""
newXml |> should equal expected
+ [<Test>]
+ member this.``Can reorder dotnet core project files``() =
+ if not MonoDevelop.Core.Platform.IsWindows then
+ let xml =
+ """
+ <Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
+ <ItemGroup>
+ <Compile Include="test1.fs" />
+ <Compile Include="test2.fs" />
+ </ItemGroup>
+ </Project>
+ """
+ let path = Path.GetTempPath() + Guid.NewGuid().ToString() + ".fsproj"
+ File.WriteAllText (path, xml)
+ let project = Services.ProjectService.CreateDotNetProject ("F#")
+ project.FileName <- new FilePath(path)
+ let movingNode = project.AddFile("test1.fs")
+ let moveToNode = project.AddFile("test2.fs")
+
+ let fsp = new FSharpProjectNodeCommandHandler()
+ fsp.MoveNodes moveToNode movingNode DropPosition.After
+
+ let newXml = File.ReadAllText path
+ let expected =
+ """<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
+ <ItemGroup>
+ <Compile Include="test2.fs" />
+ <Compile Include="test1.fs" />
+ </ItemGroup>
+</Project>"""
+
+ newXml |> should equal expected
+
[<Test;AsyncStateMachine(typeof<Task>)>]
member this.``Orders and groups files correctly for Visual Studio``() =
toTask <| async {
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormatter.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormatter.fs
index 5b69603a68..f54ff1405a 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormatter.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormatter.fs
@@ -31,11 +31,8 @@ type FSharpFormatter() =
searchPos 0 (positions.Length - 1)
let getConfig (textStylePolicy:TextStylePolicy) (formattingPolicy: FSharpFormattingPolicy) =
- match textStylePolicy, formattingPolicy with
- | null, null ->
- LoggingService.LogWarning("**Fantomas**: Fall back to default config")
- FormatConfig.Default
- | null, _ ->
+ match textStylePolicy with
+ | null ->
let format = formattingPolicy.DefaultFormat
{ FormatConfig.Default with
IndentOnTryWith = format.IndentOnTryWith
@@ -46,10 +43,6 @@ type FSharpFormatter() =
SpaceBeforeArgument = format.SpaceBeforeArgument
SpaceBeforeColon = format.SpaceBeforeColon
SemicolonAtEndOfLine = false }
- | _, null ->
- { FormatConfig.Default with
- PageWidth = textStylePolicy.FileWidth
- IndentSpaceNum = textStylePolicy.IndentWidth }
| _ ->
let format = formattingPolicy.DefaultFormat
{ FormatConfig.Default with
@@ -70,18 +63,23 @@ type FSharpFormatter() =
else output
let format (editor : Editor.TextEditor option) style formatting input options : ITextSource =
- let isFsiFile =
+ let filename, projFileName =
match editor with
- | Some d -> d.FileName.Extension.Equals(".fsi", StringComparison.OrdinalIgnoreCase)
- | _ -> false
-
+ | Some ed ->
+ match ed.DocumentContext.HasProject with
+ | true -> ed.FileName.FullPath.ToString(), ed.DocumentContext.Project.FileName.FullPath.ToString()
+ | false -> ed.FileName.FullPath.ToString(), ed.FileName.FullPath.ToString()
+ | _ -> "tmp.fsx", "tmp.fsx"
+ let projOptions = languageService.GetCheckerOptions(filename, projFileName, input)
let config = getConfig style formatting
-
- match options with
- | Document ->
+ match options, projOptions with
+ | Document, Some projectOptions ->
let output =
try
- let result = trimIfNeeded input (CodeFormatter.formatSourceString isFsiFile input config)
+ let formatted = CodeFormatter.FormatDocumentAsync(filename, input, config, projectOptions, languageService.Checker)
+ |> Async.RunSynchronously
+
+ let result = trimIfNeeded input formatted
//If onTheFly do the replacements in the document
editor
|> Option.iter (fun editor ->
@@ -89,13 +87,13 @@ type FSharpFormatter() =
let col = editor.CaretColumn
editor.ReplaceText(0, input.Length, result)
editor.SetCaretLocation (line, col, false))
- StringTextSource (result)
+ StringTextSource result
with exn ->
- LoggingService.LogError("Error occured: {0}", exn.Message)
+ LoggingService.LogError("**Fantomas**: Error occured: {0}", exn.Message)
StringTextSource input
output :> ITextSource
- | Selection(fromOffset, toOffset) ->
+ | Selection(fromOffset, toOffset), Some projectOptions ->
// Convert from offsets to line and column position
let positions =
input.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n')
@@ -113,8 +111,9 @@ type FSharpFormatter() =
let! result =
try
let selection = input.Substring(fromOffset, toOffset - fromOffset)
- let result = trimIfNeeded selection (CodeFormatter.formatSelectionOnly isFsiFile range input config)
-
+ let formatted = CodeFormatter.FormatSelectionAsync(filename, range, input, config, projectOptions, languageService.Checker)
+ |> Async.RunSynchronously
+ let result = trimIfNeeded input formatted
match editor with
| Some editor ->
//If onTheFly do the replacements in the document
@@ -130,8 +129,8 @@ type FSharpFormatter() =
match tryFormat with
| Some newCode -> StringTextSource (newCode)
| None -> StringTextSource.Empty
- formatted :> ITextSource
-
+ formatted :> _
+ | _, None -> StringTextSource input :> _
let formatText (editor : Editor.TextEditor option) (policyParent : PolicyContainer) (mimeType:string) input formattingOption =
let textStylePolicy = policyParent.Get<TextStylePolicy>(mimeType)
let formattingPolicy = policyParent.Get<FSharpFormattingPolicy>(mimeType)
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPanelWidget.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPanelWidget.fs
index 82994d180f..5d477df0de 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPanelWidget.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPanelWidget.fs
@@ -11,7 +11,8 @@ type FSharpFormattingPolicyPanelWidget() =
inherit Gtk.Bin()
let store = new ListStore (typedefof<string>, typedefof<FSharpFormattingSettings>)
- let mutable policy = FSharpFormattingPolicy()
+
+ let mutable policy = DefaultFSharpFormatting.policy
let mutable vbox2 : Gtk.VBox = null
let mutable hbox1 : Gtk.HBox = null
let mutable boxScopes : Gtk.VBox = null
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicy.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicy.fs
index 5f00d18175..5b7b16ed07 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicy.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicy.fs
@@ -1,71 +1,65 @@
namespace MonoDevelop.FSharp
-open System
open MonoDevelop.Core
open MonoDevelop.Core.Serialization
open MonoDevelop.Projects.Policies
-type FSharpFormattingSettings() =
+[<CLIMutable>]
+type FSharpFormattingSettings = {
[<ItemProperty>]
[<LocalizedCategory ("Layout")>]
[<LocalizedDisplayName ("Indent on try/with")>]
- member val IndentOnTryWith = false with get, set
+ mutable IndentOnTryWith : bool;
[<ItemProperty>]
[<LocalizedCategory ("Refactoring")>]
[<LocalizedDisplayName ("Reorder open declaration")>]
- member val ReorderOpenDeclaration = false with get, set
+ mutable ReorderOpenDeclaration : bool
[<ItemProperty>]
[<LocalizedCategory ("Spacing")>]
[<LocalizedDisplayName ("Space after comma")>]
- member val SpaceAfterComma = true with get, set
+ mutable SpaceAfterComma : bool
[<ItemProperty>]
[<LocalizedCategory ("Spacing")>]
[<LocalizedDisplayName ("Space after semicolon")>]
- member val SpaceAfterSemicolon = true with get, set
+ mutable SpaceAfterSemicolon : bool
[<ItemProperty>]
[<LocalizedCategory ("Spacing")>]
[<LocalizedDisplayName ("Space around delimiter")>]
- member val SpaceAroundDelimiter = true with get, set
+ mutable SpaceAroundDelimiter : bool
[<ItemProperty>]
[<LocalizedCategory ("Spacing")>]
[<LocalizedDisplayName ("Space before argument")>]
- member val SpaceBeforeArgument = true with get, set
+ mutable SpaceBeforeArgument : bool
[<ItemProperty>]
[<LocalizedCategory ("Spacing")>]
[<LocalizedDisplayName ("Space before colon")>]
- member val SpaceBeforeColon = true with get, set
+ mutable SpaceBeforeColon : bool
+}
-// [<ItemProperty>]
-// [<LocalizedCategory ("Syntax")>]
-// [<LocalizedDisplayName ("Semicolon at End of Line")>]
-// member val SemicolonAtEndOfLine = false with get, set
-
- member x.Clone() =
- x.MemberwiseClone() :?> FSharpFormattingSettings
-
-[<AllowNullLiteral>]
+[<CLIMutable>]
[<PolicyType ("F# formatting")>]
-type FSharpFormattingPolicy() =
+type FSharpFormattingPolicy = {
[<ItemProperty>]
- member val Formats = ResizeArray<FSharpFormattingSettings>() with get, set
+ mutable Formats : ResizeArray<FSharpFormattingSettings>
[<ItemProperty>]
- member val DefaultFormat = FSharpFormattingSettings() with get, set
+ mutable DefaultFormat : FSharpFormattingSettings
+}
- member x.Clone() =
- let clone = FSharpFormattingPolicy()
- clone.DefaultFormat <- x.DefaultFormat.Clone()
- for f in x.Formats do
- clone.Formats.Add (f.Clone())
- clone
+module DefaultFSharpFormatting =
+ let settings =
+ { IndentOnTryWith=false
+ ReorderOpenDeclaration=false
+ SpaceAfterComma=true
+ SpaceAfterSemicolon=true
+ SpaceAroundDelimiter=true
+ SpaceBeforeArgument=true
+ SpaceBeforeColon=true }
- interface IEquatable<FSharpFormattingPolicy> with
- member this.Equals(other) =
- this.DefaultFormat = other.DefaultFormat
- && Seq.forall (fun f -> Seq.exists (fun f' -> f' = f) other.Formats) this.Formats
+ let policy = { Formats = ResizeArray<FSharpFormattingSettings>(); DefaultFormat=settings }
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicyPanel.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicyPanel.fs
index 85bd5a5d6b..7b477b516c 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicyPanel.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormattingPolicyPanel.fs
@@ -5,7 +5,7 @@ open MonoDevelop.Ide.Gui.Dialogs
type FSharpFormattingPolicyPanel() =
inherit MimeTypePolicyOptionsPanel<FSharpFormattingPolicy>()
- let mutable policy = FSharpFormattingPolicy()
+ let mutable policy = DefaultFSharpFormatting.policy
let mutable panel = new FSharpFormattingPolicyPanelWidget()
override __.CreatePanelWidget() =
panel <- new FSharpFormattingPolicyPanelWidget()
@@ -13,7 +13,8 @@ type FSharpFormattingPolicyPanel() =
Control.op_Implicit panel
override __.LoadFrom(p : FSharpFormattingPolicy) =
- policy <- p.Clone()
+ let formats = p.Formats |> function null -> ResizeArray<FSharpFormattingSettings>() | _ -> ResizeArray<FSharpFormattingSettings>(p.Formats)
+ policy <- { p with DefaultFormat=p.DefaultFormat; Formats=formats }
panel.SetFormat(policy)
override __.GetPolicy() =
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProject.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProject.fs
index c16966382b..461c22ed3d 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProject.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProject.fs
@@ -126,7 +126,7 @@ type FSharpProject() as self =
| [_single, items] when items = sortedItems -> false
| _ -> true
- if needsSort then
+ if needsSort && sortedItems.Length > 0 then
let newGroup = project.AddNewItemGroup()
for item in sortedItems do
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProjectFileNodeExtension.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProjectFileNodeExtension.fs
index c822384c7e..24cce980c3 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProjectFileNodeExtension.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpProjectFileNodeExtension.fs
@@ -27,15 +27,15 @@ type FSharpProjectNodeCommandHandler() =
member x.MoveNodes (moveToNode: ProjectFile) (movingNode:ProjectFile) position =
let projectFile = movingNode.Project.FileName.ToString()
- let descendantsNamed name ancestor =
+ let descendantsNamed ns name ancestor =
///partially apply the default namespace of msbuild to xs
- let xd = xs "http://schemas.microsoft.com/developer/msbuild/2003"
+ let xd = xs ns
descendants (xd name) ancestor
// If the "Compile" element contains a "Link" element then it is a linked file,
// so use that value for comparison when finding the node.
- let nodeName (node:XElement) =
- let link = node |> descendantsNamed "Link" |> firstOrNone
+ let nodeName ns (node:XElement) =
+ let link = node |> descendantsNamed ns "Link" |> firstOrNone
match link with
| Some l -> l.Value
| None -> node |> attributeValue "Include"
@@ -44,15 +44,16 @@ type FSharpProjectNodeCommandHandler() =
use file = IO.File.Open(projectFile, FileMode.Open)
let xdoc = XElement.Load(file)
file.Close()
-
+ let defaultNamespace = xdoc.GetDefaultNamespace().NamespaceName
+ let descendantsByNamespace = descendantsNamed defaultNamespace
//get movable nodes from the project file
- let movableNodes = (descendantsNamed "Compile" xdoc).
- Concat(descendantsNamed "EmbeddedResource" xdoc).
- Concat(descendantsNamed "Content" xdoc).
- Concat(descendantsNamed "None" xdoc)
+ let movableNodes = (descendantsByNamespace "Compile" xdoc).
+ Concat(descendantsByNamespace "EmbeddedResource" xdoc).
+ Concat(descendantsByNamespace "Content" xdoc).
+ Concat(descendantsByNamespace "None" xdoc)
let findByIncludeFile name seq =
- seq |> where (fun elem -> nodeName elem = name )
+ seq |> where (fun elem -> nodeName defaultNamespace elem = name )
|> firstOrNone
let getFullName (pf:ProjectFile) = pf.ProjectVirtualPath.ToString().Replace("/", "\\")
@@ -70,7 +71,7 @@ type FSharpProjectNodeCommandHandler() =
| Some(moving), Some(moveTo), (DropPosition.Before | DropPosition.After) ->
moving.Remove()
//if the moving node contains a DependentUpon node as a child remove the DependentUpon nodes
- moving |> descendantsNamed "DependentUpon" |> Seq.iter (fun node -> node.Remove())
+ moving |> descendantsByNamespace "DependentUpon" |> Seq.iter (fun node -> node.Remove())
//get the add function using the position
let add = addFunction moveTo position
add(moving)
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj
index 7a69dc41b7..3c62456e54 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj
@@ -1,4 +1,5 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,20 +12,23 @@
<Name>MonoDevelop.FSharp</Name>
<UsePartialTypes>False</UsePartialTypes>
<RestorePackages>true</RestorePackages>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
+ <SignAssembly>true</SignAssembly>
+ <OtherFlags>--publicsign</OtherFlags>
+ <AssemblyOriginatorKeyFile>..\..\..\msbuild\MonoDevelop-Public.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
- <OutputPath>..\..\..\build\AddIns\BackendBindings</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\FSharpBinding</OutputPath>
<DefineConstants>TRACE;DEBUG;$(DefineConstants)</DefineConstants>
<WarningLevel>3</WarningLevel>
<Externalconsole>true</Externalconsole>
<StartAction>Program</StartAction>
- <OtherFlags>--warnon:1182</OtherFlags>
+ <OtherFlags>--publicsign --warnon:1182</OtherFlags>
<StartAction>Program</StartAction>
<StartProgram>$(MSBuildProjectDirectory)\..\..\..\build\bin\MonoDevelop.exe</StartProgram>
<StartWorkingDirectory>$(MSBuildProjectDirectory)\..\..\..\build</StartWorkingDirectory>
@@ -36,7 +40,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
- <OutputPath>..\..\..\build\AddIns\BackendBindings</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\FSharpBinding</OutputPath>
<DefineConstants>TRACE;$(DefineConstants)</DefineConstants>
<WarningLevel>3</WarningLevel>
<OptimizeCode>true</OptimizeCode>
@@ -117,10 +121,10 @@
<Compile Include="FSharpBraceMatcher.fs" />
<Compile Include="FSharpDebuggerExpressionResolver.fs" />
<Compile Include="FSharpSelection.fs" />
- <EmbeddedResource Include="FSharpSyntaxMode.xml" />
- <EmbeddedResource Include="FSharpFormattingPolicy.xml" />
- <EmbeddedResource Include="FSharpStylePolicy.xml" />
- <EmbeddedResource Include="FSharpBinding.addin.xml" />
+ <AdditionalEmbeddedResource Include="FSharpSyntaxMode.xml" />
+ <AdditionalEmbeddedResource Include="FSharpFormattingPolicy.xml" />
+ <AdditionalEmbeddedResource Include="FSharpStylePolicy.xml" />
+ <AdditionalEmbeddedResource Include="FSharpBinding.addin.xml" />
<None Include="paket.references" />
<Compile Include="Properties\AddinInfo.fs" />
<Compile Include="HighlightUnusedCode.fs" />
@@ -140,10 +144,6 @@
<Reference Include="mscorlib" />
<Reference Include="Mono.Cairo" />
<Reference Include="Mono.Posix" />
- <Reference Include="MonoDevelop.DesignerSupport">
- <HintPath>..\..\..\build\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll</HintPath>
- <Private>False</Private>
- </Reference>
<Reference Include="Mono.Addins">
<Private>False</Private>
<HintPath>..\..\..\build\bin\Mono.Addins.dll</HintPath>
@@ -156,10 +156,6 @@
<Private>False</Private>
<HintPath>..\..\..\build\bin\Xwt.Gtk.dll</HintPath>
</Reference>
- <Reference Include="MonoDevelop.SourceEditor" Condition=" '$(Configuration)' == 'Debug' Or '$(Configuration)' == 'Release' ">
- <Private>False</Private>
- <HintPath>..\..\..\build\AddIns\DisplayBindings\SourceEditor\MonoDevelop.SourceEditor.dll</HintPath>
- </Reference>
<ProjectReference Include="..\..\..\src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.csproj">
<Project>{A437F1A3-78DF-4F00-8053-D32A8B1EB679}</Project>
<Name>MonoDevelop.Projects.Formats.MSBuild</Name>
@@ -172,10 +168,6 @@
<Private>False</Private>
<HintPath>..\..\..\build\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
- <Reference Include="MonoDevelop.UnitTesting">
- <Private>False</Private>
- <HintPath>..\..\..\build\AddIns\MonoDevelop.UnitTesting\MonoDevelop.UnitTesting.dll</HintPath>
- </Reference>
<ProjectReference Include="..\MonoDevelop.FSharp.Gui\MonoDevelop.FSharp.Gui.csproj">
<Project>{FD0D1033-9145-48E5-8ED8-E2365252878C}</Project>
<Name>MonoDevelop.FSharp.Gui</Name>
@@ -216,6 +208,21 @@
<Name>MonoDevelop.Refactoring</Name>
<Private>False</Private>
</ProjectReference>
+ <ProjectReference Include="..\..\..\src\addins\MonoDevelop.SourceEditor2\MonoDevelop.SourceEditor.csproj">
+ <Project>{F8F92AA4-A376-4679-A9D4-60E7B7FBF477}</Project>
+ <Name>MonoDevelop.SourceEditor</Name>
+ <Private>False</Private>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\src\addins\MonoDevelop.UnitTesting\MonoDevelop.UnitTesting.csproj">
+ <Project>{A7A4246D-CEC4-42DF-A3C1-C31B9F51C4EC}</Project>
+ <Name>MonoDevelop.UnitTesting</Name>
+ <Private>False</Private>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\src\addins\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.csproj">
+ <Project>{2C24D515-4A2C-445C-8419-C09231913CFA}</Project>
+ <Name>MonoDevelop.DesignerSupport</Name>
+ <Private>False</Private>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
@@ -233,7 +240,7 @@
</MonoDevelop>
</ProjectExtensions>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="ExtCore">
<HintPath>..\packages\ExtCore\lib\net45\ExtCore.dll</HintPath>
@@ -244,7 +251,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FantomasLib">
<HintPath>..\packages\Fantomas\lib\FantomasLib.dll</HintPath>
@@ -255,7 +262,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Compiler.CodeDom">
<HintPath>..\packages\FSharp.Compiler.CodeDom\lib\net40\FSharp.Compiler.CodeDom.dll</HintPath>
@@ -266,7 +273,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Compiler.Service.MSBuild.v12">
<HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.MSBuild.v12.dll</HintPath>
@@ -282,7 +289,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath>
@@ -293,7 +300,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="Mono.Cecil.Mdb">
<HintPath>..\packages\Mono.Cecil\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
@@ -319,7 +326,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
@@ -330,7 +337,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll</HintPath>
@@ -341,7 +348,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="System.Reflection.Metadata">
<HintPath>..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll</HintPath>
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs
index 4a637716ae..86d714417f 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs
@@ -276,7 +276,7 @@ type LanguageService(dirtyNotify, _extraProjectInfo) as x =
//cache 50 project infos, then start evicting the least recently used entries
ref (ExtCore.Caching.LruCache.create 50u)
-
+ member x.Checker = checker
member x.RemoveFromProjectInfoCache(projFilename:string, ?properties) =
let properties = defaultArg properties ["Configuration", "Debug"]
@@ -350,7 +350,7 @@ type LanguageService(dirtyNotify, _extraProjectInfo) as x =
let referencedProjectOptions =
referencedProject
|> getReferencedProjects
- |> Seq.fold (fun (acc) reference ->
+ |> Seq.fold (fun acc reference ->
match getOptions reference with
| Some outFile, opts -> (outFile, opts) :: acc
| None,_ -> acc) ([])
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj
index 8b7c88597f..3e2bf7e43c 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj
@@ -1,4 +1,5 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -8,14 +9,15 @@
<OutputType>Exe</OutputType>
<RootNamespace>MonoDevelop.FSharpi.Service</RootNamespace>
<AssemblyName>MonoDevelop.FSharpInteractive.Service</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\FSharpBinding</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<ExternalConsole>true</ExternalConsole>
@@ -27,7 +29,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>true</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\FSharpBinding</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
@@ -67,7 +69,7 @@
<Import Project="$(FSharpTargetsPath)" />
<Import Project="..\.paket\paket.targets" />
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="ExtCore">
<HintPath>..\packages\ExtCore\lib\net45\ExtCore.dll</HintPath>
@@ -78,7 +80,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Compiler.Service.MSBuild.v12">
<HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.MSBuild.v12.dll</HintPath>
@@ -94,7 +96,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath>
@@ -105,18 +107,18 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
- <Private>True</Private>
+ <Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll</HintPath>
@@ -127,7 +129,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="System.Reflection.Metadata">
<HintPath>..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll</HintPath>
@@ -138,7 +140,7 @@
</When>
</Choose>
<Choose>
- <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
+ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="System.ValueTuple">
<HintPath>..\packages\System.ValueTuple\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/Program.fs b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/Program.fs
index 2aa32f48fb..eeaa739c4e 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/Program.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/Program.fs
@@ -15,7 +15,7 @@ module CompletionServer =
let outStream = Console.Out
let server = "MonoDevelop" + Guid.NewGuid().ToString("n")
- let editorPid = Int32.Parse argv.[0]
+ let editorPid = if argv.Length > 0 then Some (Int32.Parse argv.[0]) else None
// This flag makes fsi send the SERVER-PROMPT> prompt
// once it's output the header
let fsiServerArg = sprintf "--fsi-server:%s " server
@@ -98,12 +98,15 @@ module CompletionServer =
let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration(fsi, true)
let fsiSession = FsiEvaluationSession.Create(fsiConfig, argv, inStream, outStream, outStream, true)
+
// Add a watch on the editor PID. If it goes away we will self terminate.
+ let editorProcess = editorPid |> Option.bind(fun pid -> Some (Process.GetProcessById pid))
- let editorProcess = Process.GetProcessById(editorPid)
let rec main(currentInput) =
- if editorProcess.HasExited then
- Process.GetCurrentProcess().Kill()
+ editorProcess
+ |> Option.iter(fun editor ->
+ if editor.HasExited then
+ Process.GetCurrentProcess().Kill())
let parseInput() =
async {
diff --git a/main/external/fsharpbinding/paket.dependencies b/main/external/fsharpbinding/paket.dependencies
index e279b82c31..7d30609aec 100644
--- a/main/external/fsharpbinding/paket.dependencies
+++ b/main/external/fsharpbinding/paket.dependencies
@@ -1,4 +1,4 @@
-framework: 45
+framework: net461
source https://nuget.org/api/v2/
nuget ExtCore framework: >= net40
diff --git a/main/external/fsharpbinding/paket.lock b/main/external/fsharpbinding/paket.lock
index df4cdf44f7..cdac4a8ff9 100644
--- a/main/external/fsharpbinding/paket.lock
+++ b/main/external/fsharpbinding/paket.lock
@@ -1,8 +1,8 @@
-FRAMEWORK: NET45
+FRAMEWORK: NET461
NUGET
remote: https://www.nuget.org/api/v2
ExtCore (0.8.46)
- FAKE (4.50.1)
+ FAKE (4.54)
Fantomas (2.5)
FSharp.Compiler.Service (>= 10.0.1)
FSharp.Compiler.CodeDom (0.9.2)
diff --git a/main/external/libgit2sharp b/main/external/libgit2sharp
-Subproject 06bbc96251eea534ed66a32e8f2e2edaaa90307
+Subproject 319fa363ef12bba42680d880ac00a127d335fb4
diff --git a/main/msbuild/GenerateInternalsVisibleTo.targets b/main/msbuild/GenerateInternalsVisibleTo.targets
new file mode 100644
index 0000000000..099176f0f5
--- /dev/null
+++ b/main/msbuild/GenerateInternalsVisibleTo.targets
@@ -0,0 +1,66 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <!-- based on Roslyn's build/Targets/GenerateInternalsVisibleTo.targets -->
+
+ <PropertyGroup>
+ <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <GeneratedInternalsVisibleToFile>$(IntermediateOutputPath)GeneratedInternalsVisibleTo$(DefaultLanguageSourceExtension)</GeneratedInternalsVisibleToFile>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <CoreCompileDependsOn>GenerateInternalsVisibleToFile;$(CoreCompileDependsOn)</CoreCompileDependsOn>
+ </PropertyGroup>
+
+ <ItemDefinitionGroup>
+ <InternalsVisibleTo>
+ <Visible>false</Visible>
+ </InternalsVisibleTo>
+ </ItemDefinitionGroup>
+
+ <PropertyGroup Condition="'$(SignAssembly)' == 'True'">
+ <MonoDevelopPublicKey>002400000c800000940000000602000000240000525341310004000001000100e1290d741888d13312c0cd1f72bb843236573c80158a286f11bb98de5ee8acc3142c9c97b472684e521ae45125d7414558f2e70ac56504f3e8fe80830da2cdb1cda8504e8d196150d05a214609234694ec0ebf4b37fc7537e09d877c3e65000f7467fa3adb6e62c82b10ada1af4a83651556c7d949959817fed97480839dd39b</MonoDevelopPublicKey>
+ <InternalsVisibleToSuffix>, PublicKey=$(MonoDevelopPublicKey)</InternalsVisibleToSuffix>
+ </PropertyGroup>
+
+ <!-- Dependency on PrepareForBuild is necessary so that we don't accidentally get ordered before it.
+ We rely on PrepareForBuild to create the IntermediateOutputDirectory if it doesn't exist. -->
+ <Target Name="GenerateInternalsVisibleToFile"
+ Inputs="$(MSBuildThisFileFullPath);$(MSBuildProjectFile)"
+ Outputs="$(GeneratedInternalsVisibleToFile)"
+ DependsOnTargets="PrepareForBuild"
+ Condition="'@(InternalsVisibleTo)' != ''">
+
+ <!--
+ This is a slightly evil trick. What we have is a group of InternalsVisibleTo items which
+ we need to convert to the items that the WriteCodeFragment expects. They look like this:
+
+ <InternalsVisibleTo Include="Foo" />
+
+ And need to convert it to:
+
+ <InternalsVisibleToAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
+ <_Parameter1>Foo</Parameter1>
+ </InternalsVisibleToAttribute>
+
+ One way (although a bit evil) is to use the old CreateItem task. Since we use the well-defined
+ "Identity" metadata on each of our itemgroups, MSBuild batching will take effect and this task
+ will be invoked once for each InternalsVisibleTo item.
+ -->
+ <CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute"
+ AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity)$(InternalsVisibleToSuffix)"
+ Condition="'@(InternalsVisibleTo)' != ''">
+ <Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
+ </CreateItem>
+
+ <WriteCodeFragment
+ AssemblyAttributes="@(InternalsVisibleToAttribute)"
+ Language="$(Language)"
+ OutputFile="$(GeneratedInternalsVisibleToFile)">
+ <Output TaskParameter="OutputFile" ItemName="Compile" />
+ <Output TaskParameter="OutputFile" ItemName="FileWrites" />
+ </WriteCodeFragment>
+
+ </Target>
+</Project>
diff --git a/main/msbuild/MonoDevelop-Public.snk b/main/msbuild/MonoDevelop-Public.snk
new file mode 100755
index 0000000000..ed91706e6a
--- /dev/null
+++ b/main/msbuild/MonoDevelop-Public.snk
Binary files differ
diff --git a/main/msbuild/MonoDevelop.AfterCommon.props b/main/msbuild/MonoDevelop.AfterCommon.props
new file mode 100644
index 0000000000..db8ce05a38
--- /dev/null
+++ b/main/msbuild/MonoDevelop.AfterCommon.props
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+ </PropertyGroup>
+
+ <!--
+ Sign assemblies so they get IVT access to Roslyn.
+ Disable for F# as its targets do not support public signing.
+ -->
+ <PropertyGroup Condition="'$(MSBuildProjectExtension)'!='.fsproj'">
+ <SignAssembly>true</SignAssembly>
+ <PublicSign>True</PublicSign>
+ <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\MonoDevelop-Public.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+</Project>
diff --git a/main/msbuild/MonoDevelop.AfterCommon.targets b/main/msbuild/MonoDevelop.AfterCommon.targets
new file mode 100644
index 0000000000..3ca7156572
--- /dev/null
+++ b/main/msbuild/MonoDevelop.AfterCommon.targets
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+ </PropertyGroup>
+
+ <Import Project="$(MSBuildThisFileDirectory)\GenerateInternalsVisibleTo.targets" />
+</Project>
diff --git a/main/msbuild/MonoDevelop.BeforeCommon.props b/main/msbuild/MonoDevelop.BeforeCommon.props
new file mode 100644
index 0000000000..184008056e
--- /dev/null
+++ b/main/msbuild/MonoDevelop.BeforeCommon.props
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+ </PropertyGroup>
+</Project>
diff --git a/main/msbuild/MonoDevelop.BeforeCommon.targets b/main/msbuild/MonoDevelop.BeforeCommon.targets
new file mode 100644
index 0000000000..7d6f766b24
--- /dev/null
+++ b/main/msbuild/MonoDevelop.BeforeCommon.targets
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+ </PropertyGroup>
+
+ <!-- force Roslyn compiler -->
+ <PropertyGroup Condition="'$(OS)'=='Unix' And '$(MSBuildProjectExtension)'=='.csproj'">
+ <_MonoBinDir>$(MSBuildBinPath)\..\..\..\4.5\</_MonoBinDir>
+ <CscToolExe>csc.exe</CscToolExe>
+ <CscToolPath>$(_MonoBinDir)</CscToolPath>
+ <DebugType>portable</DebugType>
+ <CscDebugFileExt>.pdb</CscDebugFileExt>
+ <_DebugFileExt>.pdb</_DebugFileExt>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <Deterministic>True</Deterministic>
+ <OutputPath Condition="!HasTrailingSlash('$(OutputPath)')">$(OutputPath)\</OutputPath>
+ <DocumentationFile Condition="'$(SuppressDocs)'!='True'">$(OutputPath)$(AssemblyName).xml</DocumentationFile>
+ <NoWarn>$(NoWarn);1591</NoWarn>
+ </PropertyGroup>
+
+ <!-- C# only -->
+ <PropertyGroup Condition="'$(MSBuildProjectExtension)'=='.csproj'">
+ <Deterministic>True</Deterministic>
+ <NoWarn>$(NoWarn);1591</NoWarn>
+ </PropertyGroup>
+</Project>
diff --git a/main/po/Gettext.targets b/main/po/Gettext.targets
index c84f07d422..9a4934356a 100644
--- a/main/po/Gettext.targets
+++ b/main/po/Gettext.targets
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets"/>
<Target Name="_GettextPrepareInputs">
<!-- validate properties -->
<Error Condition="'$(OutputPath)' == ''"
@@ -59,4 +60,4 @@
<Target Name="AfterBuild" />
<Target Name="BeforeClean" />
<Target Name="AfterClean" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/po/po.mdproj b/main/po/po.mdproj
index e8855a228a..ce55684ea7 100644
--- a/main/po/po.mdproj
+++ b/main/po/po.mdproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj
index fd4fff59af..7e7e39268d 100644
--- a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj
+++ b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.AspNet</AssemblyName>
<RootNamespace>MonoDevelop.AspNet</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -569,6 +570,10 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
+ <ItemGroup>
+ <InternalsVisibleTo Include="MonoDevelop.AspNet.Tests" />
+ <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.AspNet" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
diff --git a/main/src/addins/AspNet/Properties/AssemblyInfo.cs b/main/src/addins/AspNet/Properties/AssemblyInfo.cs
index c509a6f3af..6cbc7387fd 100644
--- a/main/src/addins/AspNet/Properties/AssemblyInfo.cs
+++ b/main/src/addins/AspNet/Properties/AssemblyInfo.cs
@@ -8,5 +8,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyDescription ("Support for ASP.NET projects, including editing, compiling, previewing and deploying to remote servers.")]
[assembly: AssemblyVersion ("2.6")]
[assembly: AssemblyCopyright ("MIT X11")]
-[assembly: InternalsVisibleTo("MonoDevelop.AspNet.Tests")]
-[assembly: InternalsVisibleTo("MonoDevelop.CSharpBinding.AspNet")]
diff --git a/main/src/addins/AspNet/Tests/MonoDevelop.AspNet.Tests.csproj b/main/src/addins/AspNet/Tests/MonoDevelop.AspNet.Tests.csproj
index 036b4a7a40..caf5d08d7b 100644
--- a/main/src/addins/AspNet/Tests/MonoDevelop.AspNet.Tests.csproj
+++ b/main/src/addins/AspNet/Tests/MonoDevelop.AspNet.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>MonoDevelop.AspNet.Tests</AssemblyName>
<TestRunnerCommand>..\..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -79,7 +80,6 @@
<Compile Include="Razor\RazorParserTests.cs" />
<Compile Include="WebForms\WebFormsSyntaxModeTests.cs" />
</ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
<Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
@@ -145,4 +145,5 @@
</Properties>
</MonoDevelop>
</ProjectExtensions>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj b/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj
index 8813be65c6..1e7aa12047 100644
--- a/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj
+++ b/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,13 +10,13 @@
<OutputType>Library</OutputType>
<RootNamespace>AspNet</RootNamespace>
<AssemblyName>MonoDevelop.CSharpBinding.AspNet</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\..\build\AddIns\CSharpBinding</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -26,7 +27,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\..\build\AddIns\CSharpBinding</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
diff --git a/main/src/addins/CSharpBinding/AssemblyInfo.cs b/main/src/addins/CSharpBinding/AssemblyInfo.cs
index 754c5f2e56..9e1aca742d 100644
--- a/main/src/addins/CSharpBinding/AssemblyInfo.cs
+++ b/main/src/addins/CSharpBinding/AssemblyInfo.cs
@@ -8,10 +8,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyDescription ("CSharp Language Binding")]
[assembly: AssemblyVersion ("2.6")]
[assembly: AssemblyCopyright ("MIT X11")]
-[assembly: InternalsVisibleTo("UnitTests")]
-[assembly: InternalsVisibleTo("MonoDevelop.CSharpBinding.AspNet")]
-[assembly: InternalsVisibleTo("MonoDevelop.CSharpBinding.Tests")]
-[assembly: InternalsVisibleTo("MonoDevelop.DocFood")]
-[assembly: InternalsVisibleTo("Xamarin.Forms.Addin")]
-[assembly: InternalsVisibleTo("MonoDevelop.GtkCore")]
-[assembly: InternalsVisibleTo("MonoDevelop.IPhone")]
diff --git a/main/src/addins/CSharpBinding/Autotools/Autotools.csproj b/main/src/addins/CSharpBinding/Autotools/Autotools.csproj
index f6784fc266..568c376f2a 100644
--- a/main/src/addins/CSharpBinding/Autotools/Autotools.csproj
+++ b/main/src/addins/CSharpBinding/Autotools/Autotools.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,13 +10,13 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.CSharpBinding.Autotools</AssemblyName>
<RootNamespace>Autotools</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\..\build\AddIns\CSharpBinding</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
@@ -24,12 +25,11 @@
</Execution>
<DefineConstants>DEBUG</DefineConstants>
<NoWarn>1591;1573</NoWarn>
- <DocumentationFile>..\..\..\..\build\AddIns\BackendBindings\MonoDevelop.CSharpBinding.Autotools.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\..\build\AddIns\CSharpBinding</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
@@ -37,7 +37,6 @@
<Execution clr-version="Net_2_0" />
</Execution>
<DebugSymbols>true</DebugSymbols>
- <DocumentationFile>..\..\..\..\build\AddIns\BackendBindings\MonoDevelop.CSharpBinding.Autotools.xml</DocumentationFile>
<NoWarn>1591;1573</NoWarn>
</PropertyGroup>
<ItemGroup>
@@ -84,11 +83,10 @@
<Compile Include="CSharpAutotoolsSetup.cs" />
<Compile Include="AddinInfo.cs" />
</ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="..\..\..\..\md.targets" />
<ItemGroup>
<EmbeddedResource Include="ExtensionModel.addin.xml">
<LogicalName>ExtensionModel.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/addins/CSharpBinding/Autotools/CSharpAutotoolsSetup.cs b/main/src/addins/CSharpBinding/Autotools/CSharpAutotoolsSetup.cs
index 74eb99329f..53e283dd27 100644
--- a/main/src/addins/CSharpBinding/Autotools/CSharpAutotoolsSetup.cs
+++ b/main/src/addins/CSharpBinding/Autotools/CSharpAutotoolsSetup.cs
@@ -78,17 +78,9 @@ namespace CSharpBinding.Autotools
writer.Write (" -define:DEBUG");
}
- switch (parameters.LangVersion) {
- case LangVersion.Default:
- break;
- case LangVersion.ISO_1:
- writer.Write (" -langversion:ISO-1 ");
- break;
- case LangVersion.ISO_2:
- writer.Write (" -langversion:ISO-2 ");
- break;
- default:
- throw new Exception ("Invalid LangVersion enum value '" + parameters.LangVersion.ToString () + "'");
+ var langVersion = config.Properties.GetValue<string> ("LangVersion");
+ if (!string.IsNullOrEmpty (langVersion)) {
+ writer.Write (" -langversion:" + langVersion + " ");
}
diff --git a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml
index 58a463e11d..5645db1be8 100644
--- a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml
+++ b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml
@@ -181,7 +181,7 @@
</Extension>
<Extension path = "/MonoDevelop/Core/MimeTypes">
- <MimeType id="text/x-csharp" _description="C# source code" icon="md-csharp-file" isText="true">
+ <MimeType id="text/x-csharp" _description="C# source code" icon="md-csharp-file" isText="true" roslynName="C#">
<File pattern="*.cs" />
</MimeType>
<MimeType id="application/x-csproject" _description="C# project file" baseType="application/x-msbuild">
@@ -211,7 +211,6 @@
<Extension path = "/MonoDevelop/ProjectModel/PolicySets/Mono" >
<Policies resource="MonoCSharpPolicy.xml" />
- <Policies resource="MonoNameConventionPolicy.xml" />
</Extension>
<Extension path = "/MonoDevelop/ProjectModel/PolicySets" >
@@ -280,16 +279,6 @@
<Class class = "MonoDevelop.CodeGeneration.WriteLineGenerator" />
</Extension>
- <Extension path = "/MonoDevelop/ProjectModel/Gui/DefaultPolicyPanels/SourceCode">
- <Section id="NameConventions" _label="Name Conventions" fill = "true" class="MonoDevelop.CSharp.Diagnostics.InconsistentNaming.NameConventionPanel" icon="md-prefs-name-conventions" />
- </Extension>
- <Extension path = "/MonoDevelop/ProjectModel/Gui/ItemOptionPanels/SourceCode">
- <Section id="NameConventions" _label="Name Conventions" fill = "true" class="MonoDevelop.CSharp.Diagnostics.InconsistentNaming.NameConventionPanel" icon="md-prefs-name-conventions" />
- </Extension>
- <Extension path = "/MonoDevelop/Ide/GlobalOptionsDialog/SourceCode">
- <Section id="NameConventions" _label="Name Conventions" fill = "true" class="MonoDevelop.CSharp.Diagnostics.InconsistentNaming.NameConventionPanel" icon="md-prefs-name-conventions" />
- </Extension>
-
<Extension path = "/MonoDevelop/SourceEditor2/TooltipProviders">
<Class id="LanguageItem" class="MonoDevelop.SourceEditor.LanguageItemTooltipProvider" />
</Extension>
@@ -352,4 +341,4 @@
<Extension path = "/MonoDevelop/Ide/AutoInsertBracketHandler">
<Class class="MonoDevelop.CSharp.Features.AutoInsertBracket.CSharpAutoInsertBracketHandler" insertbefore="Default"/>
</Extension>
-</ExtensionModel> \ No newline at end of file
+</ExtensionModel>
diff --git a/main/src/addins/CSharpBinding/CSharpBinding.csproj b/main/src/addins/CSharpBinding/CSharpBinding.csproj
index 987cfec373..59a1741fa1 100644
--- a/main/src/addins/CSharpBinding/CSharpBinding.csproj
+++ b/main/src/addins/CSharpBinding/CSharpBinding.csproj
@@ -1,5 +1,6 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -7,7 +8,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.CSharpBinding</AssemblyName>
<RootNamespace>CSharpBinding</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
@@ -15,7 +16,7 @@
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\CSharpBinding</OutputPath>
<DefineConstants>GMCS_SOURCE;NET_2_0;MS_COMPATIBLE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -29,7 +30,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\CSharpBinding</OutputPath>
<DefineConstants>GMCS_SOURCE;NET_2_0;MS_COMPATIBLE;FULL_AST;BOOTSTRAP_BASIC</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -102,11 +103,6 @@
<Name>Xwt</Name>
<Private>False</Private>
</ProjectReference>
- <ProjectReference Include="..\..\..\external\RefactoringEssentials\RefactoringEssentials\RefactoringEssentials.csproj">
- <Project>{C465A5DC-AD28-49A2-89C0-F81838814A7E}</Project>
- <Name>RefactoringEssentials</Name>
- <Private>False</Private>
- </ProjectReference>
<ProjectReference Include="..\MonoDevelop.UnitTesting\MonoDevelop.UnitTesting.csproj">
<Project>{A7A4246D-CEC4-42DF-A3C1-C31B9F51C4EC}</Project>
<Name>MonoDevelop.UnitTesting</Name>
@@ -168,6 +164,19 @@
<HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
+ <Reference Include="Microsoft.CodeAnalysis.CSharp.Features">
+ <HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.CSharp.Features.dll</HintPath>
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.CodeAnalysis.Features">
+ <HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.Features.dll</HintPath>
+ <Private>False</Private>
+ </Reference>
+ <!-- NOTE: On Mono this conflicts with the one in mscorlib -->
+ <Reference Include="System.ValueTuple" Condition="'$(OS)' != 'Unix'">
+ <HintPath>..\..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
+ <Aliases>SystemValueTuple</Aliases>
+ </Reference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="templates\ConsoleProject.xpt.xml">
@@ -212,9 +221,6 @@
<EmbeddedResource Include="templates\SharedAssetsProject.xpt.xml">
<LogicalName>SharedAssetsProject.xpt.xml</LogicalName>
</EmbeddedResource>
- <EmbeddedResource Include="MonoDevelop.CSharp.Diagnostics\InconsistentNaming\MonoNameConventionPolicy.xml">
- <LogicalName>MonoNameConventionPolicy.xml</LogicalName>
- </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Compile Include="gtk-gui\generated.cs" />
@@ -276,7 +282,6 @@
<Compile Include="MonoDevelop.CSharp.UnitTests\UnitTestTextEditorExtension.cs" />
<Compile Include="MonoDevelop.CSharp.CodeGeneration\PartialGenerator.cs" />
<Compile Include="AddinInfo.cs" />
- <Compile Include="MonoDevelop.CSharp.Refactoring\CSharpCodeGenerationService.cs" />
<Compile Include="MonoDevelop.CSharp.Project\CSharpProjectExtension.cs" />
<Compile Include="MonoDevelop.CSharp.Project\PortableCSharpProjectFlavor.cs" />
<Compile Include="MonoDevelop.CSharp.Completion\RoslynSymbolCompletionData.cs" />
@@ -304,54 +309,12 @@
<Compile Include="MonoDevelop.JSon\JSonTextEditorExtension.cs" />
<Compile Include="MonoDevelop.CSharp.Refactoring\ExtractMethodCommandHandler.cs" />
<Compile Include="MonoDevelop.CSharp.Refactoring\RefactoryCommands.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\AddImport\CSharpAddImportCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\AddImport\AbstractAddImportCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\FullyQualify\CSharpFullyQualifyCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\PredefinedCodeFixProviderNames.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\Async\CSharpConvertToAsyncMethodCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\Async\CSharpAddAwaitCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\Async\CSharpAddAsyncCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\Async\AbstractAsyncCodeFix.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\MoveTypeToFile\MoveTypeToFile.cs" />
<Compile Include="MonoDevelop.CSharp.Refactoring\GotoDeclarationHandler.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\GenerateConstructor\GenerateConstructorCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\GenerateConstructor\AbstractGenerateMemberCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\GenerateEnumMember\GenerateEnumMemberCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\GenerateMethod\GenerateConversionCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\GenerateMethod\GenerateMethodCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\GenerateVariable\GenerateVariableCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\ImplementAbstractClass\ImplementAbstractClassCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\ImplementInterface\ImplementInterfaceCodeFixProvider.cs" />
<Compile Include="MonoDevelop.CSharp.Completion\RoslynCompletionCategory.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeRefactorings\IntroduceVariable\IntroduceVariableCodeRefactoringProvider.cs" />
<Compile Include="MonoDevelop.CSharp.CodeRefactorings\PredefinedCodeRefactoringProviderNames.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.InitializerRewriter.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.ReferenceRewriter.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeRefactorings\ExtractMethod\ExtractMethodCodeRefactoringProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\GenerateType\GenerateTypeCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\DiagnosticCustomTags.cs" />
<Compile Include="MonoDevelop.CSharp.Diagnostics\IDEDiagnosticIds.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\SimplifyTypeNames\SimplifyTypeNamesCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\SimplifyTypeNames\SimplifyTypeNamesCodeFixProvider.SimplifyTypeNamesFixAllProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\RemoveUnnecessaryUsings\RemoveUnnecessaryUsingsCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\RemoveUnnecessaryCast\RemoveUnnecessaryCastDiagnosticAnalyzerBase.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\RemoveUnnecessaryCast\CSharpRemoveUnnecessaryCastDiagnosticAnalyzer.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\RemoveUnnecessaryImports\RemoveUnnecessaryImportsDiagnosticAnalyzerBase.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\SimplifyTypeNames\SimplifyTypeNamesDiagnosticAnalyzerBase.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\SimplifyTypeNames\CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.RemoveUnnecessaryCastFixAllProvider.cs" />
<Compile Include="MonoDevelop.CSharp.Diagnostics\MonoTODO\MonoTODODiagnosticAnalyzer.cs" />
<Compile Include="MonoDevelop.CSharp.CodeRefactorings\ConvertToEnum\ConvertToEnumDialog.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\InconsistentNaming\NameConventionEditRuleDialog.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\InconsistentNaming\NameConventionPanel.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\InconsistentNaming\NameConventionPanelWidget.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\InconsistentNaming\NameConventionPolicy.cs" />
- <Compile Include="MonoDevelop.CSharp.Diagnostics\InconsistentNaming\NameConventionRule.cs" />
- <Compile Include="gtk-gui\MonoDevelop.CSharp.Diagnostics.InconsistentNaming.NameConventionPanelWidget.cs" />
- <Compile Include="gtk-gui\MonoDevelop.CSharp.Diagnostics.InconsistentNaming.NameConventionEditRuleDialog.cs" />
<Compile Include="MonoDevelop.CSharp.Refactoring\CSharpFeaturesTextEditorExtension.cs" />
<Compile Include="MonoDevelop.CSharp.Refactoring\RenameHandler.cs" />
<Compile Include="MonoDevelop.CSharp.Refactoring\FindReferencesHandler.cs" />
@@ -359,51 +322,6 @@
<Compile Include="MonoDevelop.CSharp.Refactoring\CodeGenerationService.cs" />
<Compile Include="MonoDevelop.CSharp\CSharpBraceMatcher.cs" />
<Compile Include="MonoDevelop.CSharp.Refactoring\FindProjectReferenceUsagesHandler.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateFromMembers\GenerateConstructor\AbstractGenerateConstructorService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateFromMembers\GenerateConstructor\CSharpGenerateConstructorService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateFromMembers\GenerateConstructor\GenerateConstructorResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateFromMembers\AbstractCodeRefactoringResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateFromMembers\AbstractGenerateFromMembersService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateFromMembers\GenerateFromMembersHelpers.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateConstructor\AbstractGenerateConstructorService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateConstructor\CSharpGenerateConstructorService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateConstructor\GenerateConstructorHelpers.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateDefaultConstructors\AbstractGenerateDefaultConstructorsService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateDefaultConstructors\CSharpGenerateDefaultConstructorsService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateDefaultConstructors\GenerateDefaultConstructorsResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateEnumMember\AbstractGenerateEnumMemberService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateEnumMember\CSharpGenerateEnumMemberService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateParameterizedMember\AbstractGenerateConversionService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateParameterizedMember\AbstractGenerateMethodService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateParameterizedMember\AbstractGenerateParameterizedMemberService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateParameterizedMember\CSharpCommonGenerationServiceMethods.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateParameterizedMember\CSharpGenerateConversionService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateParameterizedMember\CSharpGenerateMethodService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateParameterizedMember\CSharpGenerateParameterizedMemberService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateParameterizedMember\MethodGenerationKind.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateVariable\AbstractGenerateVariableService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\GenerateVariable\CSharpGenerateVariableService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\AbstractCodeRefactoringResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateMember\AbstractGenerateMemberService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateType\AbstractGenerateTypeService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateType\CSharpGenerateTypeService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateType\GenerateTypeDialogOptions.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateType\GenerateTypeOptionsResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GenerateType\TypeKindOptions.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GotoDefinition\GotoDefinitionHelpers.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\GotoDefinition\GotoDefinitionService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementAbstractClass\AbstractImplementAbstractClassService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementAbstractClass\AbstractImplementAbstractClassService.Editor.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementAbstractClass\AbstractImplementAbstractClassService.State.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementAbstractClass\CSharpImplementAbstractClassService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementInterface\AbstractImplementInterfaceService.CodeAction.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementInterface\AbstractImplementInterfaceService.CodeAction_Conflicts.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementInterface\AbstractImplementInterfaceService.CodeAction_Method.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementInterface\AbstractImplementInterfaceService.CodeAction_Property.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementInterface\AbstractImplementInterfaceService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementInterface\AbstractImplementInterfaceService.DisposePatternCodeAction.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementInterface\AbstractImplementInterfaceService.State.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ImplementInterface\CSharpImplementInterfaceService.cs" />
<Compile Include="MonoDevelop.CSharp.Features\IndentEngine\CacheIndentEngine.cs" />
<Compile Include="MonoDevelop.CSharp.Features\IndentEngine\CSharpIndentEngine.cs" />
<Compile Include="MonoDevelop.CSharp.Features\IndentEngine\IDocumentIndentEngine.cs" />
@@ -412,221 +330,16 @@
<Compile Include="MonoDevelop.CSharp.Features\IndentEngine\ITextPasteHandler.cs" />
<Compile Include="MonoDevelop.CSharp.Features\IndentEngine\NullIStateMachineIndentEngine.cs" />
<Compile Include="MonoDevelop.CSharp.Features\IndentEngine\TextPasteIndentEngine.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.AbstractIntroduceVariableCodeAction.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.CodeAction.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.IntroduceVariableAllOccurrenceCodeAction.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.State.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.State_Attribute.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.State_Block.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.State_ConstructorInitializer.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.State_Field.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.State_Parameter.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\AbstractIntroduceVariableService.State_Query.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\CSharpIntroduceVariableService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\CSharpIntroduceVariableService.Rewriter.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\CSharpIntroduceVariableService_IntroduceField.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\CSharpIntroduceVariableService_IntroduceQueryLocal.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\IntroduceVariable\IntroduceVariableResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\OrganizeImports\CSharpOrganizeImportsService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\OrganizeImports\CSharpOrganizeImportsService.Rewriter.cs" />
<Compile Include="MonoDevelop.CSharp.Features\ParameterHinting\IParameterHintingData.cs" />
<Compile Include="MonoDevelop.CSharp.Features\ParameterHinting\IParameterHintingDataFactory.cs" />
<Compile Include="MonoDevelop.CSharp.Features\ParameterHinting\ParameterHintingEngine.cs" />
<Compile Include="MonoDevelop.CSharp.Features\ParameterHinting\ParameterHintingResult.cs" />
<Compile Include="MonoDevelop.CSharp.Features\ParameterHinting\ParameterUtil.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsService.Rewriter.cs" />
<Compile Include="MonoDevelop.CSharp.Features\SemanticHighlighting\SemanticHighlightingVisitor.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Formatter\CommonFormattingHelpers.cs" />
<Compile Include="MonoDevelop.CSharp.Features\Formatter\CSharpEditorFormattingService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Formatter\FormattingHelpers.cs" />
<Compile Include="MonoDevelop.CSharp.Features\Formatter\FormattingOptionsFactory.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Formatter\FormattingRangeHelper.cs" />
<Compile Include="MonoDevelop.CSharp.Features\Formatter\Indent.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpExtractMethodService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.Analyzer.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.CSharpCodeGenerator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.CSharpCodeGenerator.MultipleStatementsCodeGenerator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.CSharpCodeGenerator.SingleStatementCodeGenerator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.FormattingProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.PostProcessor.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpMethodExtractor.TriviaResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpSelectionResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpSelectionResult.ExpressionResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpSelectionResult.StatementResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpSelectionValidator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpSelectionValidator.Validator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpSyntaxTriviaService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\CSharpSyntaxTriviaServiceFactory.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\CSharp\Extensions.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\AbstractExtractMethodService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\AbstractSyntaxTriviaService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\AbstractSyntaxTriviaService.Result.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\Enums.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\Extensions.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\ExtractMethodMatrix.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\ExtractMethodOptions.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\ExtractMethodResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\ExtractMethodService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\FailedExtractMethodResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\IExtractMethodService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\InsertionPoint.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\ISyntaxTriviaService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.Analyzer.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.Analyzer.SymbolMapBuilder.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.AnalyzerResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.CodeGenerator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.GeneratedCode.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.TriviaResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.TypeParameterCollector.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.VariableInfo.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\MethodExtractor.VariableSymbol.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\OperationStatus.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\OperationStatus_Statics.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\OperationStatus`1.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\ParameterStyle.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\ReturnStyle.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\SelectionResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\SelectionValidator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\SelectionValidator.NullSelectionResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\SimpleExtractMethodResult.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\UniqueNameGenerator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\ExtractMethod\VariableStyle.cs" />
<Compile Include="MonoDevelop.CSharp.Features\Completion\ContextHandler\AttributeNamedParameterContextHandler.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\AbstractKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\AbstractSyntacticSingleKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\AddKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\AliasKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\AscendingKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\AsKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\AssemblyKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\AsyncKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\AwaitKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\BaseKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\BoolKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\BreakKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ByKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ByteKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\CaseKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\CatchKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\CharKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\CheckedKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ChecksumKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ClassKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ConstKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ContinueKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\DecimalKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\DefaultKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\DefineKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\DelegateKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\DescendingKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\DisableKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\DoKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\DoubleKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\DynamicKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ElifKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ElseKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\EndIfKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\EndRegionKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\EnumKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\EqualsKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ErrorKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\EventKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ExplicitKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ExternKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\FalseKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\FieldKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\FinallyKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\FixedKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\FloatKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ForEachKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ForKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\FromKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\GetKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\GlobalKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\GotoKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\GroupKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\HiddenKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\IfKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ImplicitKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\InKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\InterfaceKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\InternalKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\IntKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\IntoKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\IsKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\JoinKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\LetKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\LineKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\LockKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\LongKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\MethodKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ModuleKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\NameOfKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\NamespaceKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\NewKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\NullKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ObjectKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\OnKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\OperatorKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\OrderByKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\OutKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\OverrideKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ParamKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ParamsKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\PartialKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\PragmaKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\PrivateKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\PropertyKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ProtectedKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\PublicKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ReadOnlyKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ReferenceKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\RefKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\RegionKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\RemoveKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\RestoreKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ReturnKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\SByteKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\SealedKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\SelectKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\SetKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ShortKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\SizeOfKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\StackAllocKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\StaticKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\StringKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\StructKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\SwitchKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ThisKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ThrowKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\TrueKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\TryKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\TypeKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\TypeOfKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\TypeVarKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\UIntKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\ULongKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\UncheckedKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\UndefKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\UnsafeKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\UShortKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\UsingKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\VarKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\VirtualKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\VoidKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\VolatileKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\WarningKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\WhenKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\WhereKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\WhileKeywordRecommender.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Completion\KeywordRecommender\YieldKeywordRecommender.cs" />
<Compile Include="MonoDevelop.CSharp.Features\Completion\CompletionContext.cs" />
<Compile Include="MonoDevelop.CSharp.Features\Completion\CompletionEngine.cs" />
<Compile Include="MonoDevelop.CSharp.Features\Completion\CompletionResult.cs" />
@@ -654,123 +367,24 @@
<Compile Include="MonoDevelop.CSharp.Features\Completion\ContextHandler\XmlDocCommentContextHandler.cs" />
<Compile Include="MonoDevelop.CSharp\DeclaredSymbolInfo.cs" />
<Compile Include="MonoDevelop.CSharp\ProjectSearchCategory.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\CodeGeneration\CodeGenerationDestination.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\CodeGeneration\CodeGenerationHelpers.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\CodeGeneration\CodeGenerationOptions.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\CodeGeneration\CodeGenerationTypeParameterSymbol.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\CodeGeneration\CodeGenerator.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\CodeGeneration\CSharpCodeGenerationService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\CodeGeneration\SyntaxAnnotationExtensions.cs" />
<Compile Include="Util\7BitEncodedInts.cs" />
- <Compile Include="Util\AnnotationTable.cs" />
<Compile Include="Util\ArgumentSyntaxExtensions.cs" />
- <Compile Include="Util\CastExpressionSyntaxExtensions.cs" />
<Compile Include="Util\CloneableStack.cs" />
- <Compile Include="Util\CodeFixContextExtensions.cs" />
- <Compile Include="Util\CodeGenerationSymbolFactory.cs" />
- <Compile Include="Util\CodeRefactoringContextExtensions.cs" />
- <Compile Include="Util\CommonAccessibilityUtilities.cs" />
- <Compile Include="Util\CommonLocationExtensions.cs" />
- <Compile Include="Util\CommonSyntaxNodeOrTokenExtensions.cs" />
<Compile Include="Util\CompilationExtensions.cs" />
<Compile Include="Util\CompilationUnitSyntaxExtensions.cs" />
- <Compile Include="Util\CrefSyntaxExtensions.cs" />
- <Compile Include="Util\CSharpSemanticFactsService.cs" />
- <Compile Include="Util\CSharpSyntaxContext.cs" />
- <Compile Include="Util\CSharpSyntaxFactsService.cs" />
<Compile Include="Util\CSharpUtil.cs" />
- <Compile Include="Util\DocumentExtensions.cs" />
- <Compile Include="Util\EnumerableExtensions.cs" />
- <Compile Include="Util\EnumValueUtilities.cs" />
- <Compile Include="Util\ExpressionSyntaxExtensions.cs" />
<Compile Include="Util\FastSerializer.cs" />
- <Compile Include="Util\FindTokenHelper.cs" />
<Compile Include="Util\FormatStringHelper.cs" />
<Compile Include="Util\GeneratedCodeRecognitionService.cs" />
- <Compile Include="Util\Hash.cs" />
- <Compile Include="Util\HelpLink.cs" />
- <Compile Include="Util\IAssemblySymbolExtensions.cs" />
- <Compile Include="Util\ICodeDefinitionFactoryExtensions.cs" />
- <Compile Include="Util\ICompilationExtensions.cs" />
- <Compile Include="Util\IDictionaryExtensions.cs" />
- <Compile Include="Util\IDocumentExtensions.cs" />
- <Compile Include="Util\IMethodSymbolExtensions.cs" />
- <Compile Include="Util\ImmutableArrayExtensions.cs" />
- <Compile Include="Util\INamedTypeSymbolExtensions.cs" />
- <Compile Include="Util\INamespaceOrTypeSymbolExtensions.cs" />
- <Compile Include="Util\IParameterSymbolExtensions.cs" />
- <Compile Include="Util\IPropertySymbolExtensions.cs" />
- <Compile Include="Util\ISymbolExtensions.cs" />
- <Compile Include="Util\ITypeParameterSymbolExtensions.cs" />
- <Compile Include="Util\ITypeSymbolExtensions.cs" />
- <Compile Include="Util\LinkedListExtension.cs" />
- <Compile Include="Util\Matcher.cs" />
- <Compile Include="Util\MemberDeclarationSyntaxExtensions.cs" />
- <Compile Include="Util\NameGenerator.cs" />
- <Compile Include="Util\NamespaceDeclarationSyntaxExtensions.cs" />
- <Compile Include="Util\NameSyntaxComparer.cs" />
- <Compile Include="Util\NameSyntaxExtensions.cs" />
<Compile Include="Util\NRefactory6Host.cs" />
- <Compile Include="Util\ObjectExtensions.cs" />
- <Compile Include="Util\PredefinedOperator.cs" />
- <Compile Include="Util\QueryExpressionSyntaxExtensions.cs" />
- <Compile Include="Util\RefactoringHelpers.cs" />
<Compile Include="Util\ReferenceComparer.cs" />
- <Compile Include="Util\ReflectionCompatibilityExtensions.cs" />
- <Compile Include="Util\SemanticDocument.cs" />
- <Compile Include="Util\SemanticEquivalence.cs" />
- <Compile Include="Util\SemanticMap.cs" />
- <Compile Include="Util\SemanticModelExtensions.cs" />
- <Compile Include="Util\SignatureComparer.cs" />
- <Compile Include="Util\SimpleNameSyntaxExtensions.cs" />
- <Compile Include="Util\SourceTextExtensions.cs" />
- <Compile Include="Util\SpecializedCollections.cs" />
- <Compile Include="Util\SpeculationAnalyzer.cs" />
- <Compile Include="Util\StringExtensions.cs" />
- <Compile Include="Util\StringPclExtensions.cs" />
- <Compile Include="Util\SymbolEquivalenceComparer.cs" />
- <Compile Include="Util\SymbolExtensions.cs" />
- <Compile Include="Util\SymbolInfoExtensions.cs" />
- <Compile Include="Util\SymbolKeyExtensions.cs" />
- <Compile Include="Util\SymbolKeyResolutionExtensions.cs" />
- <Compile Include="Util\SyntacticDocument.cs" />
<Compile Include="Util\SyntaxContext.cs" />
- <Compile Include="Util\SyntaxExtensions.cs" />
<Compile Include="Util\SyntaxKindSet.cs" />
- <Compile Include="Util\SyntaxListExtension.cs" />
- <Compile Include="Util\SyntaxNodeExtensions.cs" />
- <Compile Include="Util\SyntaxTokenExtensions.cs" />
- <Compile Include="Util\SyntaxTreeExtensions.cs" />
- <Compile Include="Util\SyntaxTriviaExtensions.cs" />
- <Compile Include="Util\SyntaxTriviaListExtensions.cs" />
- <Compile Include="Util\TaskExtensions.cs" />
- <Compile Include="Util\TextLineExtension.cs" />
- <Compile Include="Util\TokenComparer.cs" />
- <Compile Include="Util\TypeDeclarationSyntaxExtensions.cs" />
- <Compile Include="Util\TypeExtensions.cs" />
- <Compile Include="Util\TypeGenerator.cs" />
- <Compile Include="Util\TypeSyntaxComparer.cs" />
- <Compile Include="Util\TypeSyntaxExtensions.cs" />
- <Compile Include="Util\UsingsAndExternAliasesDirectiveComparer.cs" />
- <Compile Include="Util\UsingsAndExternAliasesOrganizer.cs" />
- <Compile Include="Util\ValueTuple.cs" />
- <Compile Include="Util\ValueTuple`2.cs" />
<Compile Include="Util\WordParser.cs" />
<Compile Include="MonoDevelop.CSharp.CodeRefactorings\CodeRefactoring.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeRefactorings\CSharpSyntaxContext.cs" />
<Compile Include="MonoDevelop.CSharp.CodeRefactorings\TypeGuessing.cs" />
<Compile Include="MonoDevelop.CSharp.CodeRefactorings\Resources.cs" />
<Compile Include="MonoDevelop.CSharp\CSharpNavigationTextEditorExtension.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\EncapsulateField\AbstractEncapsulateFieldRefactoringProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\EncapsulateField\AbstractEncapsulateFieldService.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\EncapsulateField\EncapsulateFieldCodeAction.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\EncapsulateField\EncapsulateFieldResult.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\EncapsulateField\EncapsulateFieldCodeRefactoringProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeFixes\EncapsulateField\AbstractEncapsulateFieldRefactoringProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\EncapsulateField\CSharpEncapsulateFieldService.cs" />
- <Compile Include="Util\ConflictResolver.cs" />
- <Compile Include="Util\AccessibilityUtilities.cs" />
- <Compile Include="Util\Glyph.cs" />
<Compile Include="MonoDevelop.CSharp.Features\Completion\ContextHandler\RegexContextHandler.cs" />
<Compile Include="MonoDevelop.CSharp.Refactoring\CSharpFindReferencesProvider.cs" />
<Compile Include="MonoDevelop.CSharp.Refactoring\CSharpJumpToDeclarationHandler.cs" />
@@ -785,6 +399,15 @@
<Compile Include="MonoDevelop.CSharp.Features\AutoInsertBracket\Sessions\ParenthesisCompletionSession.cs" />
<Compile Include="MonoDevelop.CSharp.Features\AutoInsertBracket\Sessions\StringLiteralCompletionSession.cs" />
<Compile Include="MonoDevelop.CSharp.Features\AutoInsertBracket\Sessions\InterpolationCompletionSession.cs" />
+ <Compile Include="MonoDevelop.CSharp.Refactoring\OrganizeImportsCommandHandler.cs" />
+ <Compile Include="MonoDevelop.CSharp.CodeRefactorings\UsingRefactorings\SortImportsCodeRefactoringProvider.cs" />
+ <Compile Include="MonoDevelop.CSharp.Navigation\FindMemberOverloadsHandler.cs" />
+ <Compile Include="MonoDevelop.CSharp.Navigation\FindExtensionMethodsHandler.cs" />
+ <Compile Include="MonoDevelop.CSharp.Navigation\FindDerivedSymbolsHandler.cs" />
+ <Compile Include="MonoDevelop.CSharp.Navigation\FindBaseSymbolsHandler.cs" />
+ <Compile Include="MonoDevelop.CSharp.Navigation\FindImplementingMembersHandler.cs" />
+ <Compile Include="MonoDevelop.CSharp.Refactoring\ConstructFixer.cs" />
+ <Compile Include="MonoDevelop.CSharp.Highlighting\AbstractKeywordHighlighter.cs" />
<Compile Include="MonoDevelop.CSharp.Highlighting\KeywordHighlighters\AbstractAsyncHighlighter.cs" />
<Compile Include="MonoDevelop.CSharp.Highlighting\KeywordHighlighters\AsyncAnonymousMethodHighlighter.cs" />
<Compile Include="MonoDevelop.CSharp.Highlighting\KeywordHighlighters\AsyncMethodHighlighter.cs" />
@@ -804,16 +427,9 @@
<Compile Include="MonoDevelop.CSharp.Highlighting\KeywordHighlighters\UnsafeStatementHighlighter.cs" />
<Compile Include="MonoDevelop.CSharp.Highlighting\KeywordHighlighters\UsingStatementHighlighter.cs" />
<Compile Include="MonoDevelop.CSharp.Highlighting\KeywordHighlighters\YieldStatementHighlighter.cs" />
- <Compile Include="MonoDevelop.CSharp.Highlighting\AbstractKeywordHighlighter.cs" />
- <Compile Include="Util\DirectiveSyntaxExtensions.cs" />
- <Compile Include="MonoDevelop.CSharp.Refactoring\OrganizeImportsCommandHandler.cs" />
- <Compile Include="MonoDevelop.CSharp.CodeRefactorings\UsingRefactorings\SortImportsCodeRefactoringProvider.cs" />
- <Compile Include="MonoDevelop.CSharp.Navigation\FindMemberOverloadsHandler.cs" />
- <Compile Include="MonoDevelop.CSharp.Navigation\FindExtensionMethodsHandler.cs" />
- <Compile Include="MonoDevelop.CSharp.Navigation\FindDerivedSymbolsHandler.cs" />
- <Compile Include="MonoDevelop.CSharp.Navigation\FindBaseSymbolsHandler.cs" />
- <Compile Include="MonoDevelop.CSharp.Navigation\FindImplementingMembersHandler.cs" />
- <Compile Include="MonoDevelop.CSharp.Refactoring\ConstructFixer.cs" />
+ <Compile Include="MonoDevelop.CSharp.Features\GotoDefinition\GotoDefinitionHelpers.cs" />
+ <Compile Include="MonoDevelop.CSharp.Features\GotoDefinition\GotoDefinitionService.cs" />
+ <Compile Include="Util\PortingExtensions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.am" />
@@ -822,55 +438,20 @@
<None Include="MonoDevelop.CSharp.Completion\ArrayTypeParameterDataProvider.cs" />
<None Include="MonoDevelop.CSharp.Completion\AbstractParameterDataProvider.cs" />
<None Include="MonoDevelop.CSharp.CodeRefactorings\ConvertToEnum\ConvertToEnumCodeRefactoringProvider.cs" />
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <InternalsVisibleTo Include="UnitTests" />
+ <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.AspNet" />
+ <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.Tests" />
+ <InternalsVisibleTo Include="MonoDevelop.DocFood" />
+ <InternalsVisibleTo Include="Xamarin.Forms.Addin" />
+ <InternalsVisibleTo Include="MonoDevelop.GtkCore" />
+ <InternalsVisibleTo Include="MonoDevelop.IPhone" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
- <Folder Include="MonoDevelop.CSharp.Parser\" />
- <Folder Include="MonoDevelop.CSharp.Resolver\" />
- <Folder Include="MonoDevelop.CSharp.Highlighting\" />
- <Folder Include="MonoDevelop.CSharp.Formatting\" />
- <Folder Include="MonoDevelop.CSharp.Refactoring\" />
- <Folder Include="MonoDevelop.CSharp.Project\" />
- <Folder Include="MonoDevelop.CSharp\" />
- <Folder Include="MonoDevelop.CSharp.Completion\" />
- <Folder Include="MonoDevelop.CSharp.CodeGeneration\" />
- <Folder Include="MonoDevelop.CSharp.Formatting\policies\" />
- <Folder Include="MonoDevelop.CSharp.Tooltips\" />
- <Folder Include="MonoDevelop.CSharp.UnitTests\" />
<Folder Include="icons\" />
- <Folder Include="MonoDevelop.CSharp.ClassOutline\" />
<Folder Include="MonoDevelop.CSharp.NRefactoryWrapper\" />
- <Folder Include="MonoDevelop.JSon\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\AddImport\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\FullyQualify\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\Async\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\MoveTypeToFile\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\GenerateConstructor\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\GenerateEnumMember\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\GenerateMethod\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\GenerateVariable\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\ImplementAbstractClass\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\ImplementInterface\" />
- <Folder Include="MonoDevelop.CSharp.CodeRefactorings\" />
- <Folder Include="MonoDevelop.CSharp.CodeRefactorings\IntroduceVariable\" />
- <Folder Include="MonoDevelop.CSharp.CodeRefactorings\InlineTemporary\" />
- <Folder Include="MonoDevelop.CSharp.CodeRefactorings\ExtractMethod\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\GenerateType\" />
- <Folder Include="MonoDevelop.CSharp.Diagnostics\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\SimplifyTypeNames\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\RemoveUnnecessaryUsings\" />
- <Folder Include="MonoDevelop.CSharp.Diagnostics\RemoveUnnecessaryCast\" />
- <Folder Include="MonoDevelop.CSharp.Diagnostics\RemoveUnnecessaryImports\" />
- <Folder Include="MonoDevelop.CSharp.Diagnostics\SimplifyTypeNames\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\RemoveUnnecessaryCast\" />
- <Folder Include="MonoDevelop.CSharp.Diagnostics\MonoTODO\" />
- <Folder Include="MonoDevelop.CSharp.CodeRefactorings\ConvertToEnum\" />
- <Folder Include="MonoDevelop.CSharp.CodeFixes\EncapsulateField\" />
- <Folder Include="MonoDevelop.CSharp.Features\AutoInsertBracket\" />
- <Folder Include="MonoDevelop.CSharp.Features\AutoInsertBracket\Sessions\" />
- <Folder Include="MonoDevelop.CSharp.Highlighting\KeywordHighlighters\" />
- <Folder Include="MonoDevelop.CSharp.CodeRefactorings\UsingRefactorings\" />
- <Folder Include="MonoDevelop.CSharp.Navigation\" />
</ItemGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/AddImport/AbstractAddImportCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/AddImport/AbstractAddImportCodeFixProvider.cs
deleted file mode 100644
index 29a9f41fc2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/AddImport/AbstractAddImportCodeFixProvider.cs
+++ /dev/null
@@ -1,526 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeFixes;
-using MonoDevelop.Ide.TypeSystem;
-using RefactoringEssentials;
-
-namespace MonoDevelop.CSharp.CodeFixes
-{
- internal abstract partial class AbstractAddImportCodeFixProvider : CodeFixProvider
- {
- protected abstract bool IgnoreCase { get; }
-
- protected abstract bool CanAddImport(SyntaxNode node, CancellationToken cancellationToken);
- protected abstract bool CanAddImportForMethod(Diagnostic diagnostic, ref SyntaxNode node);
- protected abstract bool CanAddImportForNamespace(Diagnostic diagnostic, ref SyntaxNode node);
- protected abstract bool CanAddImportForQuery(Diagnostic diagnostic, ref SyntaxNode node);
- protected abstract bool CanAddImportForType(Diagnostic diagnostic, ref SyntaxNode node);
-
- protected abstract ISet<INamespaceSymbol> GetNamespacesInScope(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
- protected abstract ITypeSymbol GetQueryClauseInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
- protected abstract string GetDescription(INamespaceOrTypeSymbol symbol, SemanticModel semanticModel, SyntaxNode root);
- protected abstract Task<Document> AddImportAsync(SyntaxNode contextNode, INamespaceOrTypeSymbol symbol, Document documemt, bool specialCaseSystem, CancellationToken cancellationToken);
- protected abstract bool IsViableExtensionMethod(IMethodSymbol method, SyntaxNode expression, SemanticModel semanticModel, CancellationToken cancellationToken);
- protected abstract IEnumerable<ITypeSymbol> GetProposedTypes(string name, List<ITypeSymbol> accessibleTypeSymbols, SemanticModel semanticModel, ISet<INamespaceSymbol> namespacesInScope);
- internal abstract bool IsViableField(IFieldSymbol field, SyntaxNode expression, SemanticModel semanticModel, CancellationToken cancellationToken);
- internal abstract bool IsViableProperty(IPropertySymbol property, SyntaxNode expression, SemanticModel semanticModel, CancellationToken cancellationToken);
- internal abstract bool IsAddMethodContext(SyntaxNode node, SemanticModel semanticModel);
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- var document = context.Document;
- var span = context.Span;
- var diagnostics = context.Diagnostics;
- var cancellationToken = context.CancellationToken;
-
- var project = document.Project;
- var diagnostic = diagnostics.First();
- var model = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (context.CancellationToken))
- return;
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- if (root.FullSpan.Length < span.Start)
- return;
- var ancestors = root.FindToken(span.Start, findInsideTrivia: true).GetAncestors<SyntaxNode>();
- if (!ancestors.Any())
- {
- return;
- }
-
- var node = ancestors.FirstOrDefault(n => n.Span.Contains(span) && n != root);
- if (node == null)
- {
- return;
- }
-
- var placeSystemNamespaceFirst = true; //document.Project.Solution.Workspace.Options.GetOption(Microsoft.CodeAnalysis.Shared.Options.OrganizerOptions.PlaceSystemNamespaceFirst, document.Project.Language);
-
- if (!cancellationToken.IsCancellationRequested)
- {
- if (this.CanAddImport(node, cancellationToken))
- {
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- //var containingType = semanticModel.GetEnclosingNamedType(node.SpanStart, cancellationToken);
- //var containingTypeOrAssembly = containingType ?? (ISymbol)semanticModel.Compilation.Assembly;
- var namespacesInScope = this.GetNamespacesInScope(semanticModel, node, cancellationToken);
-
- var matchingTypesNamespaces = await this.GetNamespacesForMatchingTypesAsync(project, diagnostic, node, semanticModel, namespacesInScope, cancellationToken).ConfigureAwait(false);
- var matchingTypes = await this.GetMatchingTypesAsync(project, diagnostic, node, semanticModel, namespacesInScope, cancellationToken).ConfigureAwait(false);
- var matchingNamespaces = await this.GetNamespacesForMatchingNamespacesAsync(project, diagnostic, node, semanticModel, namespacesInScope, cancellationToken).ConfigureAwait(false);
- var matchingExtensionMethodsNamespaces = await this.GetNamespacesForMatchingExtensionMethodsAsync(project, diagnostic, node, semanticModel, namespacesInScope, cancellationToken).ConfigureAwait(false);
- var matchingFieldsAndPropertiesAsync = await this.GetNamespacesForMatchingFieldsAndPropertiesAsync(project, diagnostic, node, semanticModel, namespacesInScope, cancellationToken).ConfigureAwait(false);
- var queryPatternsNamespaces = await this.GetNamespacesForQueryPatternsAsync(project, diagnostic, node, semanticModel, namespacesInScope, cancellationToken).ConfigureAwait(false);
-
- if (matchingTypesNamespaces != null || matchingNamespaces != null || matchingExtensionMethodsNamespaces != null || matchingFieldsAndPropertiesAsync != null || queryPatternsNamespaces != null || matchingTypes != null)
- {
- matchingTypesNamespaces = matchingTypesNamespaces ?? SpecializedCollections.EmptyList<INamespaceSymbol>();
- matchingNamespaces = matchingNamespaces ?? SpecializedCollections.EmptyList<INamespaceSymbol>();
- matchingExtensionMethodsNamespaces = matchingExtensionMethodsNamespaces ?? SpecializedCollections.EmptyList<INamespaceSymbol>();
- matchingFieldsAndPropertiesAsync = matchingFieldsAndPropertiesAsync ?? SpecializedCollections.EmptyList<INamespaceSymbol>();
- queryPatternsNamespaces = queryPatternsNamespaces ?? SpecializedCollections.EmptyList<INamespaceSymbol>();
- matchingTypes = matchingTypes ?? SpecializedCollections.EmptyList<ITypeSymbol>();
-
- var proposedImports =
- matchingTypesNamespaces.Cast<INamespaceOrTypeSymbol> ()
- .Concat (matchingNamespaces.Cast<INamespaceOrTypeSymbol> ())
- .Concat (matchingExtensionMethodsNamespaces.Cast<INamespaceOrTypeSymbol> ())
- .Concat (matchingFieldsAndPropertiesAsync.Cast<INamespaceOrTypeSymbol> ())
- .Concat (queryPatternsNamespaces.Cast<INamespaceOrTypeSymbol> ())
- .Concat (matchingTypes.Cast<INamespaceOrTypeSymbol> ())
- .Distinct ()
- .Where (NotNull)
- .Where (NotGlobalNamespace)
- .ToList ();
- proposedImports.Sort (INamespaceOrTypeSymbolExtensions.CompareNamespaceOrTypeSymbols);
- proposedImports = proposedImports.Take (8).ToList ();
-
- if (proposedImports.Count > 0)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- foreach (var import in proposedImports)
- {
- var action = new DocumentChangeAction(
- node.Span,
- DiagnosticSeverity.Error,
- this.GetDescription(import, semanticModel, node),
- (c) => this.AddImportAsync(node, import, document, placeSystemNamespaceFirst, cancellationToken)
- );
-
- context.RegisterCodeFix(action, diagnostic);
- }
- }
- }
- }
- }
- }
-
- private async Task<IEnumerable<INamespaceSymbol>> GetNamespacesForMatchingTypesAsync(
- Microsoft.CodeAnalysis.Project project,
- Diagnostic diagnostic,
- SyntaxNode node,
- SemanticModel semanticModel,
- ISet<INamespaceSymbol> namespacesInScope,
- CancellationToken cancellationToken)
- {
- if (!this.CanAddImportForType(diagnostic, ref node))
- {
- return null;
- }
-
- string name;
- int arity;
- bool inAttributeContext, hasIncompleteParentMember;
- CalculateContext(node, out name, out arity, out inAttributeContext, out hasIncompleteParentMember);
-
- var symbols = await GetTypeSymbols(project, node, semanticModel, name, inAttributeContext, cancellationToken).ConfigureAwait(false);
- if (symbols == null)
- {
- return null;
- }
-
- return GetNamespacesForMatchingTypesAsync(semanticModel, namespacesInScope, arity, inAttributeContext, hasIncompleteParentMember, symbols);
- }
-
- private IEnumerable<INamespaceSymbol> GetNamespacesForMatchingTypesAsync(SemanticModel semanticModel, ISet<INamespaceSymbol> namespacesInScope, int arity, bool inAttributeContext, bool hasIncompleteParentMember, IEnumerable<ITypeSymbol> symbols)
- {
- var accessibleTypeSymbols = symbols
- .Where(s => s.ContainingSymbol is INamespaceSymbol
- && ArityAccessibilityAndAttributeContextAreCorrect(
- semanticModel, s, arity,
- inAttributeContext, hasIncompleteParentMember))
- .ToList();
-
- return GetProposedNamespaces(
- accessibleTypeSymbols.Select(s => s.ContainingNamespace),
- semanticModel,
- namespacesInScope);
- }
-
- private async Task<IEnumerable<ITypeSymbol>> GetMatchingTypesAsync(
- Microsoft.CodeAnalysis.Project project,
- Diagnostic diagnostic,
- SyntaxNode node,
- SemanticModel semanticModel,
- ISet<INamespaceSymbol> namespacesInScope,
- CancellationToken cancellationToken)
- {
- if (!this.CanAddImportForType(diagnostic, ref node))
- {
- return null;
- }
-
- string name;
- int arity;
- bool inAttributeContext, hasIncompleteParentMember;
- CalculateContext(node, out name, out arity, out inAttributeContext, out hasIncompleteParentMember);
-
- var symbols = await GetTypeSymbols(project, node, semanticModel, name, inAttributeContext, cancellationToken).ConfigureAwait(false);
- if (symbols == null)
- {
- return null;
- }
-
- return GetMatchingTypes(semanticModel, namespacesInScope, name, arity, inAttributeContext, symbols, hasIncompleteParentMember);
- }
-
- private async Task<IEnumerable<INamespaceSymbol>> GetNamespacesForMatchingNamespacesAsync(
- Microsoft.CodeAnalysis.Project project,
- Diagnostic diagnostic,
- SyntaxNode node,
- SemanticModel semanticModel,
- ISet<INamespaceSymbol> namespacesInScope,
- CancellationToken cancellationToken)
- {
- if (!this.CanAddImportForNamespace(diagnostic, ref node))
- {
- return null;
- }
-
- string name;
- int arity;
- node.GetNameAndArityOfSimpleName(out name, out arity);
-
- if (ExpressionBinds(node, semanticModel, cancellationToken))
- {
- return null;
- }
-
- var symbols = await SymbolFinder.FindDeclarationsAsync(
- project, name, this.IgnoreCase, SymbolFilter.Namespace, cancellationToken).ConfigureAwait(false);
-
- return GetProposedNamespaces(
- symbols.OfType<INamespaceSymbol>().Select(n => n.ContainingNamespace),
- semanticModel,
- namespacesInScope);
- }
-
- private async Task<IEnumerable<INamespaceSymbol>> GetNamespacesForMatchingExtensionMethodsAsync(
- Microsoft.CodeAnalysis.Project project,
- Diagnostic diagnostic,
- SyntaxNode node,
- SemanticModel semanticModel,
- ISet<INamespaceSymbol> namespacesInScope,
- CancellationToken cancellationToken)
- {
- if (!this.CanAddImportForMethod(diagnostic, ref node))
- {
- return null;
- }
-
- var expression = node.Parent;
-
- var extensionMethods = SpecializedCollections.EmptyEnumerable<INamespaceSymbol>();
- var symbols = await GetSymbolsAsync(project, node, semanticModel, cancellationToken).ConfigureAwait(false);
- if (symbols != null)
- {
- extensionMethods = FilterForExtensionMethods(semanticModel, namespacesInScope, expression, symbols, cancellationToken);
- }
-
- var addMethods = SpecializedCollections.EmptyEnumerable<INamespaceSymbol>();
- var methodSymbols = await GetAddMethodsAsync(project, diagnostic, node, semanticModel, namespacesInScope, expression, cancellationToken).ConfigureAwait(false);
- if (methodSymbols != null)
- {
- addMethods = GetProposedNamespaces(
- methodSymbols.Select(s => s.ContainingNamespace),
- semanticModel,
- namespacesInScope);
- }
-
- return extensionMethods.Concat(addMethods);
- }
-
- private async Task<IEnumerable<INamespaceSymbol>> GetNamespacesForMatchingFieldsAndPropertiesAsync(
- Microsoft.CodeAnalysis.Project project,
- Diagnostic diagnostic,
- SyntaxNode node,
- SemanticModel semanticModel,
- ISet<INamespaceSymbol> namespacesInScope,
- CancellationToken cancellationToken)
- {
- if (!this.CanAddImportForMethod(diagnostic, ref node))
- {
- return null;
- }
-
- var expression = node.Parent;
-
- var symbols = await GetSymbolsAsync(project, node, semanticModel, cancellationToken).ConfigureAwait(false);
-
- if (symbols != null)
- {
- return FilterForFieldsAndProperties(semanticModel, namespacesInScope, expression, symbols, cancellationToken);
- }
-
- return null;
- }
-
- private IEnumerable<INamespaceSymbol> FilterForFieldsAndProperties(SemanticModel semanticModel, ISet<INamespaceSymbol> namespacesInScope, SyntaxNode expression, IEnumerable<ISymbol> symbols, CancellationToken cancellationToken)
- {
- var propertySymbols = symbols
- .OfType<IPropertySymbol>()
- .Where(property => property.ContainingType?.IsAccessibleWithin(semanticModel.Compilation.Assembly) == true &&
- IsViableProperty(property, expression, semanticModel, cancellationToken))
- .ToList();
-
- var fieldSymbols = symbols
- .OfType<IFieldSymbol>()
- .Where(field => field.ContainingType?.IsAccessibleWithin(semanticModel.Compilation.Assembly) == true &&
- IsViableField(field, expression, semanticModel, cancellationToken))
- .ToList();
-
- return GetProposedNamespaces(
- propertySymbols.Select(s => s.ContainingNamespace).Concat(fieldSymbols.Select(s => s.ContainingNamespace)),
- semanticModel,
- namespacesInScope);
- }
-
- private Task<IEnumerable<ISymbol>> GetSymbolsAsync(
- Microsoft.CodeAnalysis.Project project,
- SyntaxNode node,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- // See if the name binds. If it does, there's nothing further we need to do.
- if (ExpressionBinds(node, semanticModel, cancellationToken, checkForExtensionMethods: true))
- {
- return Task.FromResult (Enumerable.Empty<ISymbol>());
- }
-
- string name;
- int arity;
- node.GetNameAndArityOfSimpleName(out name, out arity);
- if (name == null)
- {
- return Task.FromResult (Enumerable.Empty<ISymbol>());
- }
-
- return SymbolFinder.FindDeclarationsAsync(project, name, this.IgnoreCase, SymbolFilter.Member, cancellationToken);
- }
-
- private async Task<IEnumerable<IMethodSymbol>> GetAddMethodsAsync(
- Microsoft.CodeAnalysis.Project project,
- Diagnostic diagnostic,
- SyntaxNode node,
- SemanticModel semanticModel,
- ISet<INamespaceSymbol> namespacesInScope,
- SyntaxNode expression,
- CancellationToken cancellationToken)
- {
- string name;
- int arity;
- node.GetNameAndArityOfSimpleName(out name, out arity);
- if (name != null)
- {
- return SpecializedCollections.EmptyEnumerable<IMethodSymbol>();
- }
-
- if (IsAddMethodContext(node, semanticModel))
- {
- var symbols = await SymbolFinder.FindDeclarationsAsync(project, "Add", this.IgnoreCase, SymbolFilter.Member, cancellationToken).ConfigureAwait(false);
- return symbols
- .OfType<IMethodSymbol>()
- .Where(method => method.IsExtensionMethod &&
- method.ContainingType?.IsAccessibleWithin(semanticModel.Compilation.Assembly) == true &&
- IsViableExtensionMethod(method, expression, semanticModel, cancellationToken));
- }
-
- return SpecializedCollections.EmptyEnumerable<IMethodSymbol>();
- }
-
- private IEnumerable<INamespaceSymbol> FilterForExtensionMethods(SemanticModel semanticModel, ISet<INamespaceSymbol> namespacesInScope, SyntaxNode expression, IEnumerable<ISymbol> symbols, CancellationToken cancellationToken)
- {
- var extensionMethodSymbols = symbols
- .OfType<IMethodSymbol>()
- .Where(method => method.IsExtensionMethod &&
- method.ContainingType?.IsAccessibleWithin(semanticModel.Compilation.Assembly) == true &&
- IsViableExtensionMethod(method, expression, semanticModel, cancellationToken))
- .ToList();
-
- return GetProposedNamespaces(
- extensionMethodSymbols.Select(s => s.ContainingNamespace),
- semanticModel,
- namespacesInScope);
- }
-
- private async Task<IEnumerable<INamespaceSymbol>> GetNamespacesForQueryPatternsAsync(
- Microsoft.CodeAnalysis.Project project,
- Diagnostic diagnostic,
- SyntaxNode node,
- SemanticModel semanticModel,
- ISet<INamespaceSymbol> namespacesInScope,
- CancellationToken cancellationToken)
- {
- if (!this.CanAddImportForQuery(diagnostic, ref node))
- {
- return null;
- }
-
- ITypeSymbol type = this.GetQueryClauseInfo(semanticModel, node, cancellationToken);
- if (type == null)
- {
- return null;
- }
-
- // find extension methods named "Select"
- var symbols = await SymbolFinder.FindDeclarationsAsync(project, "Select", this.IgnoreCase, SymbolFilter.Member, cancellationToken).ConfigureAwait(false);
-
- var extensionMethodSymbols = symbols
- .OfType<IMethodSymbol>()
- .Where(s => s.IsExtensionMethod && IsViableExtensionMethod(type, s))
- .ToList();
-
- return GetProposedNamespaces(
- extensionMethodSymbols.Select(s => s.ContainingNamespace),
- semanticModel,
- namespacesInScope);
- }
-
- private bool IsViableExtensionMethod(
- ITypeSymbol typeSymbol,
- IMethodSymbol method)
- {
- return typeSymbol != null && method.ReduceExtensionMethod(typeSymbol) != null;
- }
-
- private static bool ArityAccessibilityAndAttributeContextAreCorrect(
- SemanticModel semanticModel,
- ITypeSymbol symbol,
- int arity,
- bool inAttributeContext,
- bool hasIncompleteParentMember)
- {
- return (arity == 0 || symbol.GetArity() == arity || hasIncompleteParentMember)
- && symbol.IsAccessibleWithin(semanticModel.Compilation.Assembly)
- && (!inAttributeContext || symbol.IsAttribute());
- }
-
- private async Task<IEnumerable<ITypeSymbol>> GetTypeSymbols(
- Microsoft.CodeAnalysis.Project project,
- SyntaxNode node,
- SemanticModel semanticModel,
- string name,
- bool inAttributeContext,
- CancellationToken cancellationToken)
- {
- if (cancellationToken.IsCancellationRequested)
- {
- return null;
- }
-
- if (ExpressionBinds(node, semanticModel, cancellationToken))
- {
- return null;
- }
-
- var symbols = await SymbolFinder.FindDeclarationsAsync(project, name, this.IgnoreCase, SymbolFilter.Type, cancellationToken).ConfigureAwait(false);
-
- // also lookup type symbols with the "Attribute" suffix.
- if (inAttributeContext)
- {
- symbols = symbols.Concat(
- await SymbolFinder.FindDeclarationsAsync(project, name + "Attribute", this.IgnoreCase, SymbolFilter.Type, cancellationToken).ConfigureAwait(false));
- }
-
- return symbols.OfType<ITypeSymbol>();
- }
-
- private IEnumerable<ITypeSymbol> GetMatchingTypes(SemanticModel semanticModel, ISet<INamespaceSymbol> namespacesInScope, string name, int arity, bool inAttributeContext, IEnumerable<ITypeSymbol> symbols, bool hasIncompleteParentMember)
- {
- var accessibleTypeSymbols = symbols
- .Where(s => ArityAccessibilityAndAttributeContextAreCorrect(
- semanticModel, s, arity,
- inAttributeContext, hasIncompleteParentMember))
- .ToList();
-
- return GetProposedTypes(
- name,
- accessibleTypeSymbols,
- semanticModel,
- namespacesInScope);
- }
-
- private static void CalculateContext(SyntaxNode node, out string name, out int arity, out bool inAttributeContext, out bool hasIncompleteParentMember)
- {
- // Has to be a simple identifier or generic name.
- node.GetNameAndArityOfSimpleName(out name, out arity);
-
- inAttributeContext = node.IsAttributeName();
- hasIncompleteParentMember = node.HasIncompleteParentMember();
- }
-
- protected bool ExpressionBinds(SyntaxNode expression, SemanticModel semanticModel, CancellationToken cancellationToken, bool checkForExtensionMethods = false)
- {
- // See if the name binds to something other then the error type. If it does, there's nothing further we need to do.
- // For extension methods, however, we will continue to search if there exists any better matched method.
- cancellationToken.ThrowIfCancellationRequested();
- var symbolInfo = semanticModel.GetSymbolInfo(expression, cancellationToken);
- if (symbolInfo.CandidateReason == CandidateReason.OverloadResolutionFailure && !checkForExtensionMethods)
- {
- return true;
- }
-
- return symbolInfo.Symbol != null;
- }
-
- protected IEnumerable<INamespaceSymbol> GetProposedNamespaces(
- IEnumerable<INamespaceSymbol> namespaces,
- SemanticModel semanticModel,
- ISet<INamespaceSymbol> namespacesInScope)
- {
- // We only want to offer to add a using if we don't already have one.
- return
- namespaces.Where(n => !n.IsGlobalNamespace)
- .Select(n => semanticModel.Compilation.GetCompilationNamespace(n) ?? n)
- .Where(n => n != null && !namespacesInScope.Contains(n));
- }
-
- private static bool NotGlobalNamespace(INamespaceOrTypeSymbol symbol)
- {
- return symbol.IsNamespace ? !((INamespaceSymbol)symbol).IsGlobalNamespace : true;
- }
-
- private static bool NotNull(INamespaceOrTypeSymbol symbol)
- {
- return symbol != null;
- }
-
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/AddImport/CSharpAddImportCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/AddImport/CSharpAddImportCodeFixProvider.cs
deleted file mode 100644
index f4b4f56329..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/AddImport/CSharpAddImportCodeFixProvider.cs
+++ /dev/null
@@ -1,642 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
-using MonoDevelop.CSharp.CodeFixes;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace MonoDevelop.CSharp.CodeFixes
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddUsingOrImport), Shared]
- class CSharpAddImportCodeFixProvider : AbstractAddImportCodeFixProvider
- {
- /// <summary>
- /// name does not exist in context
- /// </summary>
- private const string CS0103 = "CS0103";
-
- /// <summary>
- /// type or namespace could not be found
- /// </summary>
- private const string CS0246 = "CS0246";
-
- /// <summary>
- /// wrong number of type args
- /// </summary>
- private const string CS0305 = "CS0305";
-
- /// <summary>
- /// type does not contain a definition of method or extension method
- /// </summary>
- private const string CS1061 = "CS1061";
-
- /// <summary>
- /// cannot find implementation of query pattern
- /// </summary>
- private const string CS1935 = "CS1935";
-
- /// <summary>
- /// The non-generic type 'A' cannot be used with type arguments
- /// </summary>
- private const string CS0308 = "CS0308";
-
- /// <summary>
- /// 'A' is inaccessible due to its protection level
- /// </summary>
- private const string CS0122 = "CS0122";
-
- /// <summary>
- /// The using alias 'A' cannot be used with type arguments
- /// </summary>
- private const string CS0307 = "CS0307";
-
- /// <summary>
- /// 'A' is not an attribute class
- /// </summary>
- private const string CS0616 = "CS0616";
-
- /// <summary>
- /// ; expected.
- /// </summary>
- private const string CS1002 = "CS1002";
-
- /// <summary>
- /// Syntax error, 'A' expected
- /// </summary>
- private const string CS1003 = "CS1003";
-
- /// <summary>
- /// cannot convert from 'int' to 'string'
- /// </summary>
- private const string CS1503 = "CS1503";
-
- /// <summary>
- /// XML comment on 'construct' has syntactically incorrect cref attribute 'name'
- /// </summary>
- private const string CS1574 = "CS1574";
-
- /// <summary>
- /// Invalid type for parameter 'parameter number' in XML comment cref attribute
- /// </summary>
- private const string CS1580 = "CS1580";
-
- /// <summary>
- /// Invalid return type in XML comment cref attribute
- /// </summary>
- private const string CS1581 = "CS1581";
-
- /// <summary>
- /// XML comment has syntactically incorrect cref attribute
- /// </summary>
- private const string CS1584 = "CS1584";
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get
- {
- return ImmutableArray.Create(
- CS0103,
- CS0246,
- CS0305,
- CS1061,
- CS1935,
- CS0308,
- CS0122,
- CS0307,
- CS0616,
- CS1002,
- CS1003,
- CS1503,
- CS1574,
- CS1580,
- CS1581,
- CS1584);
- }
- }
-
- protected override bool IgnoreCase
- {
- get { return false; }
- }
-
- protected override bool CanAddImport(SyntaxNode node, CancellationToken cancellationToken)
- {
- if (cancellationToken.IsCancellationRequested)
- {
- return false;
- }
-
- return node.CanAddUsingDirectives(cancellationToken);
- }
-
- protected override bool CanAddImportForMethod(Diagnostic diagnostic, ref SyntaxNode node)
- {
- switch (diagnostic.Id)
- {
- case CS1061:
- if (node.IsKind(SyntaxKind.ConditionalAccessExpression))
- {
- node = (node as ConditionalAccessExpressionSyntax).WhenNotNull;
- }
- else if (node.IsKind(SyntaxKind.MemberBindingExpression))
- {
- node = (node as MemberBindingExpressionSyntax).Name;
- }
- else if (node.Parent.IsKind(SyntaxKind.CollectionInitializerExpression))
- {
- return true;
- }
-
- break;
- case CS0122:
- break;
-
- case CS1503:
- //// look up its corresponding method name
- var parent = node.GetAncestor<InvocationExpressionSyntax>();
- if (parent == null)
- {
- return false;
- }
-
- var method = parent.Expression as MemberAccessExpressionSyntax;
- if (method != null)
- {
- node = method.Name;
- }
-
- break;
-
- default:
- return false;
- }
-
- var simpleName = node as SimpleNameSyntax;
- if (!simpleName.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) &&
- !simpleName.IsParentKind(SyntaxKind.MemberBindingExpression))
- {
- return false;
- }
-
- var memberAccess = simpleName.Parent as MemberAccessExpressionSyntax;
- var memberBinding = simpleName.Parent as MemberBindingExpressionSyntax;
- if (memberAccess.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) ||
- memberAccess.IsParentKind(SyntaxKind.ElementAccessExpression) ||
- memberBinding.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) ||
- memberBinding.IsParentKind(SyntaxKind.ElementAccessExpression))
- {
- return false;
- }
-
- if (!node.IsMemberAccessExpressionName())
- {
- return false;
- }
-
- return true;
- }
-
- protected override bool CanAddImportForNamespace(Diagnostic diagnostic, ref SyntaxNode node)
- {
- return false;
- }
-
- protected override bool CanAddImportForQuery(Diagnostic diagnostic, ref SyntaxNode node)
- {
- if (diagnostic.Id != CS1935)
- {
- return false;
- }
-
- return node.AncestorsAndSelf().Any(n => n is QueryExpressionSyntax && !(n.Parent is QueryContinuationSyntax));
- }
-
- protected override bool CanAddImportForType(Diagnostic diagnostic, ref SyntaxNode node)
- {
- switch (diagnostic.Id)
- {
- case CS0103:
- case CS0246:
- case CS0305:
- case CS0308:
- case CS0122:
- case CS0307:
- case CS0616:
- case CS1003:
- case CS1580:
- case CS1581:
- break;
-
- case CS1002:
- //// only lookup errors inside ParenthesizedLambdaExpression e.g., () => { ... }
- if (node.Ancestors().OfType<ParenthesizedLambdaExpressionSyntax>().Any())
- {
- if (node is SimpleNameSyntax)
- {
- break;
- }
- else if (node is BlockSyntax || node is MemberAccessExpressionSyntax || node is BinaryExpressionSyntax)
- {
- var last = node.DescendantNodes().OfType<SimpleNameSyntax>().LastOrDefault();
- if (!TryFindStandaloneType(ref node))
- {
- node = node.DescendantNodes().OfType<SimpleNameSyntax>().FirstOrDefault();
- }
- else
- {
- node = last;
- }
- }
- }
- else
- {
- return false;
- }
-
- break;
-
- case CS1574:
- case CS1584:
- var cref = node as QualifiedCrefSyntax;
- if (cref != null)
- {
- node = cref.Container;
- }
-
- break;
-
- default:
- return false;
- }
-
- return TryFindStandaloneType(ref node);
- }
-
- private static bool TryFindStandaloneType(ref SyntaxNode node)
- {
- var qn = node as QualifiedNameSyntax;
- if (qn != null)
- {
- node = GetLeftMostSimpleName(qn);
- }
-
- var simpleName = node as SimpleNameSyntax;
- return simpleName.LooksLikeStandaloneTypeName();
- }
-
- private static SimpleNameSyntax GetLeftMostSimpleName(QualifiedNameSyntax qn)
- {
- while (qn != null)
- {
- var left = qn.Left;
- var simpleName = left as SimpleNameSyntax;
- if (simpleName != null)
- {
- return simpleName;
- }
-
- qn = left as QualifiedNameSyntax;
- }
-
- return null;
- }
-
- protected override ISet<INamespaceSymbol> GetNamespacesInScope(
- SemanticModel semanticModel,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- return semanticModel.GetUsingNamespacesInScope(node);
- }
-
- protected override ITypeSymbol GetQueryClauseInfo(
- SemanticModel semanticModel,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- var query = node.AncestorsAndSelf().OfType<QueryExpressionSyntax>().First();
-
- if (InfoBoundSuccessfully(semanticModel.GetQueryClauseInfo(query.FromClause, cancellationToken)))
- {
- return null;
- }
-
- foreach (var clause in query.Body.Clauses)
- {
- if (InfoBoundSuccessfully(semanticModel.GetQueryClauseInfo(clause, cancellationToken)))
- {
- return null;
- }
- }
-
- if (InfoBoundSuccessfully(semanticModel.GetSymbolInfo(query.Body.SelectOrGroup, cancellationToken)))
- {
- return null;
- }
-
- var fromClause = query.FromClause;
- return semanticModel.GetTypeInfo(fromClause.Expression, cancellationToken).Type;
- }
-
- private bool InfoBoundSuccessfully(SymbolInfo symbolInfo)
- {
- return InfoBoundSuccessfully(symbolInfo.Symbol);
- }
-
- private bool InfoBoundSuccessfully(QueryClauseInfo semanticInfo)
- {
- return InfoBoundSuccessfully(semanticInfo.OperationInfo);
- }
-
- private static bool InfoBoundSuccessfully(ISymbol operation)
- {
- operation = operation.GetOriginalUnreducedDefinition();
- return operation != null;
- }
-
- protected override string GetDescription(INamespaceOrTypeSymbol namespaceSymbol, SemanticModel semanticModel, SyntaxNode contextNode)
- {
- var root = GetCompilationUnitSyntaxNode(contextNode);
-
- // No localization necessary
- string externAliasString;
- if (TryGetExternAliasString(namespaceSymbol, semanticModel, root, out externAliasString))
- {
- return string.Format ("extern alias {0};", externAliasString);
- }
-
- string namespaceString;
- if (TryGetNamespaceString(namespaceSymbol, root, false, null, out namespaceString))
- {
- return string.Format ("using {0};", namespaceString);
- }
-
- // If we get here then neither a namespace or a an extern alias can be added.
- // There is no valid string to show to the user and there is
- // likely a bug in that we should know about.
- throw new InvalidOperationException ();
- }
-
- protected override async Task<Document> AddImportAsync(
- SyntaxNode contextNode,
- INamespaceOrTypeSymbol namespaceSymbol,
- Document document,
- bool placeSystemNamespaceFirst,
- CancellationToken cancellationToken)
- {
- var root = GetCompilationUnitSyntaxNode(contextNode, cancellationToken);
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var simpleUsingDirective = GetUsingDirective(root, namespaceSymbol, semanticModel, fullyQualify: false);
- var externAliasUsingDirective = GetExternAliasUsingDirective(root, namespaceSymbol, semanticModel);
- if (externAliasUsingDirective != null)
- {
- root = root.AddExterns(
- externAliasUsingDirective
- .WithAdditionalAnnotations(Formatter.Annotation));
- }
-
- if (simpleUsingDirective != null)
- {
- // Because of the way usings can be nested inside of namespace declarations,
- // we need to check if the usings must be fully qualified so as not to be
- // ambiguous with the containing namespace.
- if (UsingsAreContainedInNamespace(contextNode))
- {
- // When we add usings we try and place them, as best we can, where the user
- // wants them according to their settings. This means we can't just add the fully-
- // qualified usings and expect the simplifier to take care of it, the usings have to be
- // simplified before we attempt to add them to the document.
- // You might be tempted to think that we could call
- // AddUsings -> Simplifier -> SortUsings
- // But this will clobber the users using settings without asking. Instead we create a new
- // Document and check if our using can be simplified. Worst case we need to back out the
- // fully qualified change and reapply with the simple name.
- var fullyQualifiedUsingDirective = GetUsingDirective(root, namespaceSymbol, semanticModel, fullyQualify: true);
- SyntaxNode newRoot = root.AddUsingDirective(
- fullyQualifiedUsingDirective, contextNode, placeSystemNamespaceFirst,
- Formatter.Annotation);
- var newDocument = document.WithSyntaxRoot(newRoot);
- var newSemanticModel = await newDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- newRoot = await newDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var newUsing = newRoot
- .DescendantNodes ().OfType<UsingDirectiveSyntax> ().Single (uds => uds.IsEquivalentTo (fullyQualifiedUsingDirective, topLevel: true));
- var speculationAnalyzer = new SpeculationAnalyzer(newUsing.Name, simpleUsingDirective.Name, newSemanticModel, cancellationToken);
- if (speculationAnalyzer.ReplacementChangesSemantics())
- {
- // Not fully qualifying the using causes to refer to a different namespace so we need to keep it as is.
- return newDocument;
- }
- else
- {
- // It does not matter if it is fully qualified or simple so lets return the simple name.
- return document.WithSyntaxRoot(root.AddUsingDirective(
- simpleUsingDirective, contextNode, placeSystemNamespaceFirst,
- Formatter.Annotation));
- }
- }
- else
- {
- // simple form
- return document.WithSyntaxRoot(root.AddUsingDirective(
- simpleUsingDirective, contextNode, placeSystemNamespaceFirst,
- Formatter.Annotation));
- }
- }
-
- return document.WithSyntaxRoot(root);
- }
-
- private static ExternAliasDirectiveSyntax GetExternAliasUsingDirective(CompilationUnitSyntax root, INamespaceOrTypeSymbol namespaceSymbol, SemanticModel semanticModel)
- {
- string externAliasString;
- if (TryGetExternAliasString(namespaceSymbol, semanticModel, root, out externAliasString))
- {
- return SyntaxFactory.ExternAliasDirective(SyntaxFactory.Identifier(externAliasString));
- }
-
- return null;
- }
-
- private UsingDirectiveSyntax GetUsingDirective(CompilationUnitSyntax root, INamespaceOrTypeSymbol namespaceSymbol, SemanticModel semanticModel, bool fullyQualify)
- {
- string namespaceString;
- string externAliasString;
- TryGetExternAliasString(namespaceSymbol, semanticModel, root, out externAliasString);
- if (externAliasString != null)
- {
- if (TryGetNamespaceString(namespaceSymbol, root, false, externAliasString, out namespaceString))
- {
- return SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(namespaceString));
- }
-
- return null;
- }
-
- if (TryGetNamespaceString(namespaceSymbol, root, fullyQualify, null, out namespaceString))
- {
- return SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(namespaceString));
- }
-
- return null;
- }
-
- private bool UsingsAreContainedInNamespace(SyntaxNode contextNode)
- {
- return contextNode.GetAncestor<NamespaceDeclarationSyntax>()?.DescendantNodes().OfType<UsingDirectiveSyntax>().FirstOrDefault() != null;
- }
-
- private static bool TryGetExternAliasString(INamespaceOrTypeSymbol namespaceSymbol, SemanticModel semanticModel, CompilationUnitSyntax root, out string externAliasString)
- {
- externAliasString = null;
- var metadataReference = semanticModel.Compilation.GetMetadataReference(namespaceSymbol.ContainingAssembly);
- if (metadataReference == null)
- {
- return false;
- }
-
- var properties = metadataReference.Properties;
- var aliases = properties.Aliases;
- if (aliases.IsDefaultOrEmpty)
- {
- return false;
- }
-
- aliases = properties.Aliases.Where(a => a != MetadataReferenceProperties.GlobalAlias).ToImmutableArray();
- if (!aliases.Any())
- {
- return false;
- }
-
- externAliasString = aliases.First();
- return ShouldAddExternAlias(aliases, root);
- }
-
- private static bool TryGetNamespaceString(INamespaceOrTypeSymbol namespaceSymbol, CompilationUnitSyntax root, bool fullyQualify, string alias, out string namespaceString)
- {
- namespaceString = fullyQualify
- ? namespaceSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)
- : namespaceSymbol.ToDisplayString();
-
- if (alias != null)
- {
- namespaceString = alias + "::" + namespaceString;
- }
-
- return ShouldAddUsing(namespaceString, root);
- }
-
- private static bool ShouldAddExternAlias(ImmutableArray<string> aliases, CompilationUnitSyntax root)
- {
- var identifiers = root.DescendantNodes().OfType<ExternAliasDirectiveSyntax>().Select(e => e.Identifier.ToString());
- var externAliases = aliases.Where(identifiers.Contains);
- return !externAliases.Any();
- }
-
- private static bool ShouldAddUsing(string usingDirective, CompilationUnitSyntax root)
- {
- return !root.Usings.Select(u => u.Name.ToString()).Contains(usingDirective);
- }
-
- private static CompilationUnitSyntax GetCompilationUnitSyntaxNode(SyntaxNode contextNode, CancellationToken cancellationToken = default(CancellationToken))
- {
- return (CompilationUnitSyntax)contextNode.SyntaxTree.GetRoot(cancellationToken);
- }
-
- protected override bool IsViableExtensionMethod(IMethodSymbol method, SyntaxNode expression, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- var leftExpression = expression.GetExpressionOfMemberAccessExpression() ?? expression.GetExpressionOfConditionalMemberAccessExpression();
- if (leftExpression == null)
- {
- if (expression.IsKind(SyntaxKind.CollectionInitializerExpression))
- {
- leftExpression = expression.GetAncestor<ObjectCreationExpressionSyntax>();
- }
- else
- {
- return false;
- }
- }
-
- var semanticInfo = semanticModel.GetTypeInfo(leftExpression, cancellationToken);
- var leftExpressionType = semanticInfo.Type;
-
- return leftExpressionType != null && method.ReduceExtensionMethod(leftExpressionType) != null;
- }
-
- protected override IEnumerable<ITypeSymbol> GetProposedTypes(string name, List<ITypeSymbol> accessibleTypeSymbols, SemanticModel semanticModel, ISet<INamespaceSymbol> namespacesInScope)
- {
- if (accessibleTypeSymbols == null)
- {
- yield break;
- }
-
- foreach (var typeSymbol in accessibleTypeSymbols)
- {
- if ((typeSymbol != null) && (typeSymbol.ContainingType != null) && typeSymbol.ContainingType.IsStatic)
- {
- yield return typeSymbol.ContainingType;
- }
- }
- }
-
- internal override bool IsViableField(IFieldSymbol field, SyntaxNode expression, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- return IsViablePropertyOrField(field, expression, semanticModel, cancellationToken);
- }
-
- internal override bool IsViableProperty(IPropertySymbol property, SyntaxNode expression, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- return IsViablePropertyOrField(property, expression, semanticModel, cancellationToken);
- }
-
- private bool IsViablePropertyOrField(ISymbol propertyOrField, SyntaxNode expression, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- if (!propertyOrField.IsStatic)
- {
- return false;
- }
-
- var leftName = (expression as MemberAccessExpressionSyntax)?.Expression as SimpleNameSyntax;
- if (leftName == null)
- {
- return false;
- }
-
- return string.Compare(propertyOrField.ContainingType.Name, leftName.Identifier.Text, this.IgnoreCase) == 0;
- }
-
- internal override bool IsAddMethodContext(SyntaxNode node, SemanticModel semanticModel)
- {
- if (node.Parent.IsKind(SyntaxKind.CollectionInitializerExpression))
- {
- var objectCreationExpressionSyntax = node.GetAncestor<ObjectCreationExpressionSyntax>();
- if (objectCreationExpressionSyntax == null)
- {
- return false;
- }
-
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/AbstractAsyncCodeFix.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/AbstractAsyncCodeFix.cs
deleted file mode 100644
index 263d637f26..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/AbstractAsyncCodeFix.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// AbstractAsyncCodeFix.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System.Collections.Immutable;
-using System.Linq;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.CodeActions;
-using ICSharpCode.NRefactory6.CSharp;
-using MonoDevelop.CSharp.CodeFixes;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using RefactoringEssentials;
-
-namespace MonoDevelop.CSharp.CodeFixes
-{
-
- internal abstract partial class AbstractAsyncCodeFix : CodeFixProvider
- {
- protected abstract Task<CodeAction> GetCodeFix(SyntaxNode root, SyntaxNode node, Document document, Diagnostic diagnostic, CancellationToken cancellationToken);
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- var model = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (context.CancellationToken))
- return;
- var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
-
- SyntaxNode node;
- if (!TryGetNode(root, context.Span, out node))
- {
- return;
- }
-
- var diagnostic = context.Diagnostics.FirstOrDefault();
-
- var codeAction = await GetCodeFix(root, node, context.Document, diagnostic, context.CancellationToken).ConfigureAwait(false);
-
- if (codeAction != null)
- {
- context.RegisterCodeFix(codeAction, diagnostic);
- }
- }
-
- private bool TryGetNode(SyntaxNode root, Microsoft.CodeAnalysis.Text.TextSpan span, out SyntaxNode node)
- {
- node = null;
- var ancestors = root.FindToken(span.Start).GetAncestors<SyntaxNode>();
- if (!ancestors.Any())
- {
- return false;
- }
-
- node = ancestors.FirstOrDefault(n => n.Span.Contains(span) && n != root);
- return node != null;
- }
- }
-
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpAddAsyncCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpAddAsyncCodeFixProvider.cs
deleted file mode 100644
index a5fcc5b4b2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpAddAsyncCodeFixProvider.cs
+++ /dev/null
@@ -1,229 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Immutable;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.CodeActions;
-using RefactoringEssentials;
-using MonoDevelop.CSharp.CodeFixes;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.CSharp;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.CSharp.CodeFixes
-{
- internal abstract partial class AbstractAddAsyncAwaitCodeFixProvider : AbstractAsyncCodeFix
- {
- protected abstract string GetDescription(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken);
- protected abstract Task<SyntaxNode> GetNewRoot(SyntaxNode root, SyntaxNode oldNode, SemanticModel semanticModel, Diagnostic diagnostic, Document document, CancellationToken cancellationToken);
-
- protected override async Task<CodeAction> GetCodeFix(SyntaxNode root, SyntaxNode node, Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
- {
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
-
- var newRoot = await this.GetNewRoot(root, node, semanticModel, diagnostic, document, cancellationToken).ConfigureAwait(false);
- if (newRoot != null)
- {
- return new DocumentChangeAction(node.Span, DiagnosticSeverity.Error,
- this.GetDescription(diagnostic, node, semanticModel, cancellationToken),
- token => Task.FromResult(document.WithSyntaxRoot(newRoot)));
- }
-
- return null;
- }
-
- protected bool TryGetTypes(
- SyntaxNode expression,
- SemanticModel semanticModel,
- out INamedTypeSymbol source,
- out INamedTypeSymbol destination)
- {
- source = null;
- destination = null;
-
- var info = semanticModel.GetSymbolInfo(expression);
- var methodSymbol = info.Symbol as IMethodSymbol;
- if (methodSymbol == null)
- {
- return false;
- }
-
- var compilation = semanticModel.Compilation;
- var taskType = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task");
- if (taskType == null)
- {
- return false;
- }
-
- var returnType = methodSymbol.ReturnType as INamedTypeSymbol;
- if (returnType == null)
- {
- return false;
- }
-
- source = taskType;
- destination = returnType;
- return true;
- }
-
- }
-
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddAsync), Shared]
- internal class CSharpAddAsyncCodeFixProvider : AbstractAddAsyncCodeFixProvider
- {
- /// <summary>
- /// The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.
- /// </summary>
- private const string CS4032 = "CS4032";
-
- /// <summary>
- /// The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.
- /// </summary>
- private const string CS4033 = "CS4033";
-
- /// <summary>
- /// The 'await' operator can only be used within an async lambda expression. Consider marking this method with the 'async' modifier.
- /// </summary>
- private const string CS4034 = "CS4034";
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS4032, CS4033, CS4034); }
- }
-
- protected override string GetDescription(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- return GettextCatalog.GetString ("Make async");
- }
-
- protected override async Task<SyntaxNode> GetNewRoot(SyntaxNode root, SyntaxNode oldNode, SemanticModel semanticModel, Diagnostic diagnostic, Document document, CancellationToken cancellationToken)
- {
- var methodNode = GetContainingMember(oldNode);
- if (methodNode == null)
- {
- return null;
- }
-
- var newMethodNode = await ConvertToAsync(methodNode, semanticModel, document, cancellationToken).ConfigureAwait(false);
- if (newMethodNode != null)
- {
- return root.ReplaceNode(methodNode, newMethodNode);
- }
-
- return null;
- }
-
- private static SyntaxNode GetContainingMember(SyntaxNode oldNode)
- {
- var parenthesizedLambda = oldNode
- .Ancestors()
- .FirstOrDefault(n =>
- n.IsKind(SyntaxKind.ParenthesizedLambdaExpression));
-
- if (parenthesizedLambda != null)
- {
- return parenthesizedLambda;
- }
-
- var simpleLambda = oldNode
- .Ancestors()
- .FirstOrDefault(n =>
- n.IsKind(SyntaxKind.SimpleLambdaExpression));
-
- if (simpleLambda != null)
- {
- return simpleLambda;
- }
-
- return oldNode
- .Ancestors()
- .FirstOrDefault(n =>
- n.IsKind(SyntaxKind.MethodDeclaration));
- }
-
- private async Task<SyntaxNode> ConvertToAsync(SyntaxNode node, SemanticModel semanticModel, Document document, CancellationToken cancellationToken)
- {
- var methodNode = node as MethodDeclarationSyntax;
- if (methodNode != null)
- {
- return await ConvertMethodToAsync(document, semanticModel, methodNode, cancellationToken).ConfigureAwait(false);
- }
-
- var parenthesizedLambda = node as ParenthesizedLambdaExpressionSyntax;
- if (parenthesizedLambda != null)
- {
- return ConvertParenthesizedLambdaToAsync(parenthesizedLambda);
- }
-
- var simpleLambda = node as SimpleLambdaExpressionSyntax;
- if (simpleLambda != null)
- {
- return ConvertSimpleLambdaToAsync(simpleLambda);
- }
-
- return null;
- }
-
- private static SyntaxNode ConvertParenthesizedLambdaToAsync(ParenthesizedLambdaExpressionSyntax parenthesizedLambda)
- {
- return SyntaxFactory.ParenthesizedLambdaExpression(
- SyntaxFactory.Token(SyntaxKind.AsyncKeyword),
- parenthesizedLambda.ParameterList,
- parenthesizedLambda.ArrowToken,
- parenthesizedLambda.Body)
- .WithAdditionalAnnotations(Formatter.Annotation);
- }
-
- private static SyntaxNode ConvertSimpleLambdaToAsync(SimpleLambdaExpressionSyntax simpleLambda)
- {
- return SyntaxFactory.SimpleLambdaExpression(
- SyntaxFactory.Token(SyntaxKind.AsyncKeyword),
- simpleLambda.Parameter,
- simpleLambda.ArrowToken,
- simpleLambda.Body)
- .WithAdditionalAnnotations(Formatter.Annotation);
- }
-
- protected override SyntaxNode AddAsyncKeyword(SyntaxNode node)
- {
- var methodNode = node as MethodDeclarationSyntax;
- if (methodNode == null)
- {
- return null;
- }
-
- return methodNode
- .AddModifiers(SyntaxFactory.Token(SyntaxKind.AsyncKeyword))
- .WithAdditionalAnnotations(Formatter.Annotation);
- }
-
- protected override SyntaxNode AddAsyncKeywordAndTaskReturnType(SyntaxNode node, ITypeSymbol existingReturnType, INamedTypeSymbol taskTypeSymbol)
- {
- var methodNode = node as MethodDeclarationSyntax;
- if (methodNode == null)
- {
- return null;
- }
-
- if (taskTypeSymbol == null)
- {
- return null;
- }
-
- var returnType = taskTypeSymbol.Construct(existingReturnType).GenerateTypeSyntax();
- return AddAsyncKeyword(methodNode.WithReturnType(returnType));
- }
-
- protected override bool DoesConversionExist(Compilation compilation, ITypeSymbol source, ITypeSymbol destination)
- {
- return compilation.ClassifyConversion(source, destination).Exists;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpAddAwaitCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpAddAwaitCodeFixProvider.cs
deleted file mode 100644
index 9bcb3033d1..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpAddAwaitCodeFixProvider.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Immutable;
-using System.Linq;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.CodeActions;
-using ICSharpCode.NRefactory6.CSharp;
-using MonoDevelop.CSharp.CodeFixes;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.CSharp.CodeFixes
-{
- internal abstract partial class AbstractAddAsyncCodeFixProvider : AbstractAddAsyncAwaitCodeFixProvider
- {
- protected const string SystemThreadingTasksTask = "System.Threading.Tasks.Task";
- protected const string SystemThreadingTasksTaskT = "System.Threading.Tasks.Task`1";
- protected abstract SyntaxNode AddAsyncKeyword(SyntaxNode methodNode);
- protected abstract SyntaxNode AddAsyncKeywordAndTaskReturnType(SyntaxNode methodNode, ITypeSymbol existingReturnType, INamedTypeSymbol taskTypeSymbol);
- protected abstract bool DoesConversionExist(Compilation compilation, ITypeSymbol source, ITypeSymbol destination);
-
- protected async Task<SyntaxNode> ConvertMethodToAsync(Document document, SemanticModel semanticModel, SyntaxNode methodNode, CancellationToken cancellationToken)
- {
- var methodSymbol = semanticModel.GetDeclaredSymbol(methodNode, cancellationToken) as IMethodSymbol;
-
- if (methodSymbol.ReturnsVoid)
- {
- return AddAsyncKeyword(methodNode);
- }
-
- var returnType = methodSymbol.ReturnType;
- var compilation = semanticModel.Compilation;
-
- var taskSymbol = compilation.GetTypeByMetadataName(SystemThreadingTasksTask);
- var genericTaskSymbol = compilation.GetTypeByMetadataName(SystemThreadingTasksTaskT);
- if (taskSymbol == null)
- {
- return null;
- }
-
- if (returnType is IErrorTypeSymbol)
- {
- // The return type of the method will not bind. This could happen for a lot of reasons.
- // The type may not actually exist or the user could just be missing a using/import statement.
- // We're going to try and see if there are any known types that have the same name as
- // our return type, and then check if those are convertible to Task. If they are then
- // we assume the user just has a missing using. If they are not, we wrap the return
- // type in a generic Task.
- var typeName = returnType.Name;
-
- var results = await SymbolFinder.FindDeclarationsAsync(
- document.Project, typeName, ignoreCase: false, filter: SymbolFilter.Type, cancellationToken: cancellationToken).ConfigureAwait(false);
-
- if (results.OfType<ITypeSymbol>().Any(s => DoesConversionExist(compilation, s, taskSymbol)))
- {
- return AddAsyncKeyword(methodNode);
- }
-
- return AddAsyncKeywordAndTaskReturnType(methodNode, returnType, genericTaskSymbol);
- }
-
- if (DoesConversionExist(compilation, returnType, taskSymbol))
- {
- return AddAsyncKeyword(methodNode);
- }
-
- return AddAsyncKeywordAndTaskReturnType(methodNode, returnType, genericTaskSymbol);
- }
- }
-
-
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddAwait), Shared]
- internal class CSharpAddAwaitCodeFixProvider : AbstractAddAsyncAwaitCodeFixProvider
- {
- /// <summary>
- /// Since this is an async method, the return expression must be of type 'blah' rather than 'baz'
- /// </summary>
- private const string CS4014 = "CS4014";
-
- /// <summary>
- /// Because this call is not awaited, execution of the current method continues before the call is completed.
- /// </summary>
- private const string CS4016 = "CS4016";
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS4014, CS4016); }
- }
-
- protected override string GetDescription(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- return GettextCatalog.GetString ("Insert 'await'");
- }
-
- protected override Task<SyntaxNode> GetNewRoot(SyntaxNode root, SyntaxNode oldNode, SemanticModel semanticModel, Diagnostic diagnostic, Document document, CancellationToken cancellationToken)
- {
- var expression = oldNode as ExpressionSyntax;
-
- switch (diagnostic.Id)
- {
- case CS4014:
- if (expression == null)
- {
- return Task.FromResult<SyntaxNode>(null);
- }
-
- return Task.FromResult(root.ReplaceNode(oldNode, ConvertToAwaitExpression(expression)));
- case CS4016:
- if (expression == null)
- {
- return Task.FromResult (default (SyntaxNode));
- }
-
- if (!IsCorrectReturnType(expression, semanticModel))
- {
- return Task.FromResult (default (SyntaxNode));
- }
-
- return Task.FromResult(root.ReplaceNode(oldNode, ConvertToAwaitExpression(expression)));
- default:
- return Task.FromResult (default (SyntaxNode));
- }
- }
-
- private bool IsCorrectReturnType(ExpressionSyntax expression, SemanticModel semanticModel)
- {
- INamedTypeSymbol taskType = null;
- INamedTypeSymbol returnType = null;
- return TryGetTypes(expression, semanticModel, out taskType, out returnType) &&
- semanticModel.Compilation.ClassifyConversion(taskType, returnType).Exists;
- }
-
- private static ExpressionSyntax ConvertToAwaitExpression(ExpressionSyntax expression)
- {
- return SyntaxFactory.AwaitExpression(expression)
- .WithAdditionalAnnotations(Formatter.Annotation);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpConvertToAsyncMethodCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpConvertToAsyncMethodCodeFixProvider.cs
deleted file mode 100644
index b1bd4224f6..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/Async/CSharpConvertToAsyncMethodCodeFixProvider.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CodeActions;
-using RefactoringEssentials;
-using MonoDevelop.CSharp.CodeFixes;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.CSharp.CodeFixes
-{
- internal abstract partial class AbstractChangeToAsyncCodeFixProvider : AbstractAsyncCodeFix
- {
- protected abstract Task<string> GetDescription(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken);
- protected abstract Task<Tuple<SyntaxTree, SyntaxNode>> GetRootInOtherSyntaxTree(SyntaxNode node, SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken);
-
- protected override async Task<CodeAction> GetCodeFix(SyntaxNode root, SyntaxNode node, Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
- {
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
-
- var result = await GetRootInOtherSyntaxTree(node, semanticModel, diagnostic, cancellationToken).ConfigureAwait(false);
- if (result != null)
- {
- var syntaxTree = result.Item1;
- var newRoot = result.Item2;
- var otherDocument = document.Project.Solution.GetDocument(syntaxTree);
- return new DocumentChangeAction(node.Span, DiagnosticSeverity.Error,
- await this.GetDescription(diagnostic, node, semanticModel, cancellationToken).ConfigureAwait(false),
- token => Task.FromResult(otherDocument.WithSyntaxRoot(newRoot)));
- }
-
- return null;
- }
- }
-
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ConvertToAsync), Shared]
- internal class CSharpConvertToAsyncMethodCodeFixProvider : AbstractChangeToAsyncCodeFixProvider
- {
- /// <summary>
- /// Cannot await void.
- /// </summary>
- private const string CS4008 = "CS4008";
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS4008); }
- }
-
- protected override async Task<string> GetDescription(
- Diagnostic diagnostic,
- SyntaxNode node,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- var methodNode = await GetMethodDeclaration(node, semanticModel, cancellationToken).ConfigureAwait(false);
- return string.Format(GettextCatalog.GetString ("Make {0} return Task instead of void"), methodNode.WithBody(null));
- }
-
- protected override async Task<Tuple<SyntaxTree, SyntaxNode>> GetRootInOtherSyntaxTree(
- SyntaxNode node,
- SemanticModel semanticModel,
- Diagnostic diagnostic,
- CancellationToken cancellationToken)
- {
- var methodDeclaration = await GetMethodDeclaration(node, semanticModel, cancellationToken).ConfigureAwait(false);
- if (methodDeclaration == null)
- {
- return null;
- }
-
- var oldRoot = await methodDeclaration.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
- var newRoot = oldRoot.ReplaceNode(methodDeclaration, ConvertToAsyncFunction(methodDeclaration));
- return Tuple.Create(oldRoot.SyntaxTree, newRoot);
- }
-
- private async Task<MethodDeclarationSyntax> GetMethodDeclaration(
- SyntaxNode node,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- var invocationExpression = node.ChildNodes().FirstOrDefault(n => n.IsKind(SyntaxKind.InvocationExpression));
- var methodSymbol = semanticModel.GetSymbolInfo(invocationExpression, cancellationToken).Symbol as IMethodSymbol;
- if (methodSymbol == null)
- {
- return null;
- }
-
- var methodReference = methodSymbol.DeclaringSyntaxReferences.FirstOrDefault();
- if (methodReference == null)
- {
- return null;
- }
-
- var methodDeclaration = (await methodReference.GetSyntaxAsync(cancellationToken).ConfigureAwait(false)) as MethodDeclarationSyntax;
- if (methodDeclaration == null)
- {
- return null;
- }
-
- if (!methodDeclaration.Modifiers.Any(m => m.IsKind(SyntaxKind.AsyncKeyword)))
- {
- return null;
- }
-
- return methodDeclaration;
- }
-
- private MethodDeclarationSyntax ConvertToAsyncFunction(MethodDeclarationSyntax methodDeclaration)
- {
- return methodDeclaration.WithReturnType(
- SyntaxFactory.ParseTypeName("Task")
- .WithLeadingTrivia(methodDeclaration.ReturnType.GetLeadingTrivia())
- .WithTrailingTrivia(methodDeclaration.ReturnType.GetTrailingTrivia()));
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/EncapsulateField/AbstractEncapsulateFieldRefactoringProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/EncapsulateField/AbstractEncapsulateFieldRefactoringProvider.cs
deleted file mode 100644
index dcda5767d2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/EncapsulateField/AbstractEncapsulateFieldRefactoringProvider.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading.Tasks;
-using ICSharpCode.NRefactory6.CSharp.CodeRefactorings.EncapsulateField;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-
-namespace Microsoft.CodeAnalysis.CodeRefactorings.EncapsulateField
-{
- internal abstract class AbstractEncapsulateFieldRefactoringProvider : CodeRefactoringProvider
- {
- CSharpEncapsulateFieldService service = new CSharpEncapsulateFieldService ();
-
- public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
- {
- var actions = await service.GetEncapsulateFieldCodeActionsAsync(context.Document, context.Span, context.CancellationToken).ConfigureAwait(false);
- foreach (var action in actions)
- context.RegisterRefactoring(action);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/EncapsulateField/EncapsulateFieldCodeRefactoringProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/EncapsulateField/EncapsulateFieldCodeRefactoringProvider.cs
deleted file mode 100644
index b65d232c50..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/EncapsulateField/EncapsulateFieldCodeRefactoringProvider.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeRefactorings.EncapsulateField
-{
- [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = "Encapsulate Field"), Shared]
- internal class EncapsulateFieldRefactoringProvider : AbstractEncapsulateFieldRefactoringProvider
- {
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/FullyQualify/CSharpFullyQualifyCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/FullyQualify/CSharpFullyQualifyCodeFixProvider.cs
deleted file mode 100644
index 83d779f9b3..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/FullyQualify/CSharpFullyQualifyCodeFixProvider.cs
+++ /dev/null
@@ -1,331 +0,0 @@
-//
-// CSharpFullyQualifyCodeFixProvider.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System.Collections.Immutable;
-using System.Threading;
-using Microsoft.CodeAnalysis.CodeFixes;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using System.Threading.Tasks;
-using System.Linq;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.FindSymbols;
-using System.Runtime.CompilerServices;
-using Microsoft.CodeAnalysis.CodeActions;
-using System;
-using RefactoringEssentials;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.CSharp.Completion;
-
-namespace MonoDevelop.CSharp.CodeFixes.FullyQualify
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = "Fully Qualify")]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.AddUsingOrImport)]
- class CSharpFullyQualifyCodeFixProvider : CodeFixProvider
- {
- /// <summary>
- /// name does not exist in context
- /// </summary>
- private const string CS0103 = "CS0103";
-
- /// <summary>
- /// 'reference' is an ambiguous reference between 'identifier' and 'identifier'
- /// </summary>
- private const string CS0104 = "CS0104";
-
- /// <summary>
- /// type or namespace could not be found
- /// </summary>
- private const string CS0246 = "CS0246";
-
- /// <summary>
- /// wrong number of type args
- /// </summary>
- private const string CS0305 = "CS0305";
-
- /// <summary>
- /// The non-generic type 'A' cannot be used with type arguments
- /// </summary>
- private const string CS0308 = "CS0308";
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS0103, CS0104, CS0246, CS0305, CS0308); }
- }
-
- protected bool IgnoreCase
- {
- get { return false; }
- }
-
- protected bool CanFullyQualify(Diagnostic diagnostic, ref SyntaxNode node)
- {
- var simpleName = node as SimpleNameSyntax;
- if (simpleName == null)
- {
- return false;
- }
-
- if (!simpleName.LooksLikeStandaloneTypeName())
- {
- return false;
- }
-
- if (!simpleName.CanBeReplacedWithAnyName())
- {
- return false;
- }
-
- return true;
- }
-
- protected SyntaxNode ReplaceNode(SyntaxNode node, string containerName, CancellationToken cancellationToken)
- {
- var simpleName = (SimpleNameSyntax)node;
-
- var leadingTrivia = simpleName.GetLeadingTrivia();
- var newName = simpleName.WithLeadingTrivia(SyntaxTriviaList.Empty);
-
- var qualifiedName = SyntaxFactory.QualifiedName(
- SyntaxFactory.ParseName(containerName), newName);
-
- qualifiedName = qualifiedName.WithLeadingTrivia(leadingTrivia);
- qualifiedName = qualifiedName.WithAdditionalAnnotations(Formatter.Annotation);
-
- var syntaxTree = simpleName.SyntaxTree;
- return syntaxTree.GetRoot(cancellationToken).ReplaceNode((NameSyntax)simpleName, qualifiedName);
- }
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- var document = context.Document;
- var span = context.Span;
- var diagnostics = context.Diagnostics;
- var cancellationToken = context.CancellationToken;
-
- var project = document.Project;
- var diagnostic = diagnostics.First();
- var model = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (context.CancellationToken))
- return;
-
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var node = root.FindToken(span.Start).GetAncestors<SyntaxNode>().First(n => n.Span.Contains(span));
-
- // Has to be a simple identifier or generic name.
- if (node != null && CanFullyQualify(diagnostic, ref node))
- {
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
-
- var matchingTypes = await this.GetMatchingTypesAsync(project, semanticModel, node, cancellationToken).ConfigureAwait(false);
- var matchingNamespaces = await this.GetMatchingNamespacesAsync(project, semanticModel, node, cancellationToken).ConfigureAwait(false);
-
- if (matchingTypes != null || matchingNamespaces != null)
- {
- matchingTypes = matchingTypes ?? SpecializedCollections.EmptyEnumerable<ISymbol>();
- matchingNamespaces = matchingNamespaces ?? SpecializedCollections.EmptyEnumerable<ISymbol>();
-
- var matchingTypeContainers = FilterAndSort(GetContainers(matchingTypes, semanticModel.Compilation));
- var matchingNamespaceContainers = FilterAndSort(GetContainers(matchingNamespaces, semanticModel.Compilation));
-
- var proposedContainers =
- matchingTypeContainers.Concat(matchingNamespaceContainers)
- .Distinct()
- .Take(8);
-
- foreach (var container in proposedContainers)
- {
- var containerName = RoslynCompletionData.SafeMinimalDisplayString (container, semanticModel, node.SpanStart);
-
- string name;
- int arity;
- node.GetNameAndArityOfSimpleName(out name, out arity);
-
- // Actual member name might differ by case.
- string memberName;
- if (this.IgnoreCase)
- {
- var member = container.GetMembers(name).FirstOrDefault();
- memberName = member != null ? member.Name : name;
- }
- else
- {
- memberName = name;
- }
-
- var codeAction = new DocumentChangeAction(
- node.Span,
- DiagnosticSeverity.Info,
- string.Format(GettextCatalog.GetString ("Change '{0}' to '{1}.{2}'"), name, containerName, memberName),
- (c) =>
- {
- var newRoot = this.ReplaceNode(node, containerName, c);
- return Task.FromResult(document.WithSyntaxRoot(newRoot));
- });
-
- context.RegisterCodeFix(codeAction, diagnostic);
- }
- }
- }
- }
-
- internal async Task<IEnumerable<ISymbol>> GetMatchingTypesAsync(
- Microsoft.CodeAnalysis.Project project, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
- {
- // Can't be on the right hand side of binary expression (like 'dot').
- cancellationToken.ThrowIfCancellationRequested();
- string name;
- int arity;
- node.GetNameAndArityOfSimpleName(out name, out arity);
-
- var symbols = await SymbolFinder.FindDeclarationsAsync(project, name, this.IgnoreCase, SymbolFilter.Type, cancellationToken).ConfigureAwait(false);
-
- // also lookup type symbols with the "Attribute" suffix.
- var inAttributeContext = node.IsAttributeName();
- if (inAttributeContext)
- {
- symbols = symbols.Concat(
- await SymbolFinder.FindDeclarationsAsync(project, name + "Attribute", this.IgnoreCase, SymbolFilter.Type, cancellationToken).ConfigureAwait(false));
- }
-
- var accessibleTypeSymbols = symbols
- .OfType<INamedTypeSymbol>()
- .Where(s => (arity == 0 || s.GetArity() == arity)
- && s.IsAccessibleWithin(semanticModel.Compilation.Assembly)
- && (!inAttributeContext || s.IsAttribute())
- && HasValidContainer(s))
- .ToList();
-
- return accessibleTypeSymbols;
- }
-
- private static bool HasValidContainer(ISymbol symbol)
- {
- var container = symbol.ContainingSymbol;
- return container is INamespaceSymbol ||
- (container is INamedTypeSymbol && !((INamedTypeSymbol)container).IsGenericType);
- }
-
- internal async Task<IEnumerable<ISymbol>> GetMatchingNamespacesAsync(
- Microsoft.CodeAnalysis.Project project,
- SemanticModel semanticModel,
- SyntaxNode simpleName,
- CancellationToken cancellationToken)
- {
- if (simpleName.IsAttributeName())
- {
- return null;
- }
-
- string name;
- int arity;
- simpleName.GetNameAndArityOfSimpleName(out name, out arity);
- if (cancellationToken.IsCancellationRequested)
- {
- return null;
- }
-
- var symbols = await SymbolFinder.FindDeclarationsAsync(project, name, this.IgnoreCase, SymbolFilter.Namespace, cancellationToken).ConfigureAwait(false);
-
- var namespaces = symbols
- .OfType<INamespaceSymbol>()
- .Where(n => !n.IsGlobalNamespace &&
- HasAccessibleTypes(n, semanticModel, cancellationToken));
-
- return namespaces;
- }
-
- private bool HasAccessibleTypes(INamespaceSymbol @namespace, SemanticModel model, CancellationToken cancellationToken)
- {
- return Enumerable.Any(@namespace.GetAllTypes(cancellationToken), t => t.IsAccessibleWithin(model.Compilation.Assembly));
- }
-
- private static IEnumerable<INamespaceOrTypeSymbol> GetContainers(IEnumerable<ISymbol> symbols, Compilation compilation)
- {
- foreach (var symbol in symbols)
- {
- var containingSymbol = symbol.ContainingSymbol as INamespaceOrTypeSymbol;
- if (containingSymbol is INamespaceSymbol)
- {
- containingSymbol = compilation.GetCompilationNamespace((INamespaceSymbol)containingSymbol);
- }
-
- if (containingSymbol != null)
- {
- yield return containingSymbol;
- }
- }
- }
-
- private IEnumerable<INamespaceOrTypeSymbol> FilterAndSort(IEnumerable<INamespaceOrTypeSymbol> symbols)
- {
- symbols = symbols ?? SpecializedCollections.EmptyList<INamespaceOrTypeSymbol>();
- var list = symbols.Distinct ().Where<INamespaceOrTypeSymbol> (n => n is INamedTypeSymbol || !((INamespaceSymbol)n).IsGlobalNamespace).ToList ();
- list.Sort (this.Compare);
- return list;
- }
-
- private static readonly ConditionalWeakTable<INamespaceOrTypeSymbol, IList<string>> s_symbolToNameMap =
- new ConditionalWeakTable<INamespaceOrTypeSymbol, IList<string>>();
-
- private static IList<string> GetNameParts(INamespaceOrTypeSymbol symbol)
- {
- return symbol.ToDisplayString(MonoDevelop.Ide.TypeSystem.Ambience.NameFormat).Split('.');
- }
-
- private int Compare(INamespaceOrTypeSymbol n1, INamespaceOrTypeSymbol n2)
- {
- if (n1 is INamedTypeSymbol && n2 is INamespaceSymbol)
- {
- return -1;
- }
- else if (n1 is INamespaceSymbol && n2 is INamedTypeSymbol)
- {
- return 1;
- }
-
- var names1 = s_symbolToNameMap.GetValue(n1, GetNameParts);
- var names2 = s_symbolToNameMap.GetValue(n2, GetNameParts);
-
- for (var i = 0; i < Math.Min(names1.Count, names2.Count); i++)
- {
- var comp = names1[i].CompareTo(names2[i]);
- if (comp != 0)
- {
- return comp;
- }
- }
-
- return names1.Count - names2.Count;
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateConstructor/AbstractGenerateMemberCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateConstructor/AbstractGenerateMemberCodeFixProvider.cs
deleted file mode 100644
index 1c735ea833..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateConstructor/AbstractGenerateMemberCodeFixProvider.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-//
-// AbstractGenerateMemberCodeFixProvider.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-using ICSharpCode.NRefactory6.CSharp;
-using RefactoringEssentials;
-
-namespace MonoDevelop.CSharp.CodeFixes.GenerateConstructor
-{
- internal abstract class AbstractGenerateMemberCodeFixProvider : CodeFixProvider
- {
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- // NOTE(DustinCa): Not supported in REPL for now.
- if (context.Document.SourceCodeKind == SourceCodeKind.Script)
- {
- return;
- }
- var model = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (context.CancellationToken))
- return;
-
- var root = await model.SyntaxTree.GetRootAsync (context.CancellationToken).ConfigureAwait (false);
- var names = GetTargetNodes(root, context.Span);
- foreach (var name in names)
- {
- var codeActions = await GetCodeActionsAsync(context.Document, name, context.CancellationToken).ConfigureAwait(false);
- if (codeActions == null)
- {
- continue;
- }
- foreach (var act in codeActions)
- context.RegisterCodeFix (act, context.Diagnostics);
- return;
- }
- }
-
- protected abstract Task<IEnumerable<CodeAction>> GetCodeActionsAsync(Document document, SyntaxNode node, CancellationToken cancellationToken);
-
- protected virtual SyntaxNode GetTargetNode(SyntaxNode node)
- {
- return node;
- }
-
- protected virtual bool IsCandidate(SyntaxNode node)
- {
- return false;
- }
-
- protected virtual IEnumerable<SyntaxNode> GetTargetNodes(SyntaxNode root, TextSpan span)
- {
- var token = root.FindToken(span.Start);
- if (!token.Span.IntersectsWith(span))
- {
- yield break;
- }
-
- var nodes = token.GetAncestors<SyntaxNode>().Where(IsCandidate);
- foreach (var node in nodes)
- {
- var name = GetTargetNode(node);
-
- if (name != null)
- {
- yield return name;
- }
- }
- }
- }
-
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
deleted file mode 100644
index 42853f44da..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp;
-using System.Linq;
-using ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateConstructor;
-using System;
-
-namespace MonoDevelop.CSharp.CodeFixes.GenerateConstructor
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateConstructor), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.FullyQualify)]
- internal class GenerateConstructorCodeFixProvider : AbstractGenerateMemberCodeFixProvider
- {
- private const string CS0122 = "CS0122"; // CS0122: 'C' is inaccessible due to its protection level
- private const string CS1729 = "CS1729"; // CS1729: 'C' does not contain a constructor that takes n arguments
- private const string CS1739 = "CS1739"; // CS1739: The best overload for 'Program' does not have a parameter named 'v'
- private const string CS1503 = "CS1503"; // CS1503: Argument 1: cannot convert from 'T1' to 'T2'
- private const string CS7036 = "CS7036"; // CS7036: There is no argument given that corresponds to the required formal parameter 'v' of 'C.C(int)'
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS0122, CS1729, CS1739, CS1503, CS7036); }
- }
-
- protected override Task<IEnumerable<CodeAction>> GetCodeActionsAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- return new CSharpGenerateConstructorService ().GenerateConstructorAsync (document, node, cancellationToken);
- }
-
- protected override bool IsCandidate(SyntaxNode node)
- {
- return node is SimpleNameSyntax || node is ObjectCreationExpressionSyntax || node is ConstructorInitializerSyntax || node is AttributeSyntax;
- }
-
- protected override SyntaxNode GetTargetNode(SyntaxNode node)
- {
- var objectCreationNode = node as ObjectCreationExpressionSyntax;
- if (objectCreationNode != null)
- {
- return objectCreationNode.Type.GetRightmostName();
- }
-
- var attributeNode = node as AttributeSyntax;
- if (attributeNode != null)
- {
- return attributeNode.Name;
- }
-
- return node;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
deleted file mode 100644
index 29823cc623..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.CSharp.CodeFixes.GenerateConstructor;
-using ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateEnumMember;
-
-namespace MonoDevelop.CSharp.CodeFixes.GenerateEnumMember
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateEnumMember), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateConstructor)]
- internal class GenerateEnumMemberCodeFixProvider : AbstractGenerateMemberCodeFixProvider
- {
- private const string CS0117 = "CS0117"; // error CS0117: 'Color' does not contain a definition for 'Red'
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS0117); }
- }
- static CSharpGenerateEnumMemberService service = new CSharpGenerateEnumMemberService();
-
- protected override Task<IEnumerable<CodeAction>> GetCodeActionsAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- return service.GenerateEnumMemberAsync(document, node, cancellationToken);
- }
-
- protected override bool IsCandidate(SyntaxNode node)
- {
- return node is IdentifierNameSyntax;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
deleted file mode 100644
index 4db9c211a7..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.CSharp.CodeFixes.GenerateConstructor;
-using Microsoft.CodeAnalysis.CSharp;
-using ICSharpCode.NRefactory6.CSharp;
-using ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember;
-
-namespace MonoDevelop.CSharp.CodeFixes.GenerateMethod
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateConversion), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateEnumMember)]
- internal class GenerateConversionCodeFixProvider : AbstractGenerateMemberCodeFixProvider
- {
- private const string CS0029 = "CS0029"; // error CS0029: Cannot implicitly convert type 'type' to 'type'
- private const string CS0030 = "CS0030"; // error CS0030: Cannot convert type 'type' to 'type'
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS0029, CS0030); }
- }
-
- protected override bool IsCandidate(SyntaxNode node)
- {
- return node.IsKind(SyntaxKind.IdentifierName) ||
- node.IsKind(SyntaxKind.MethodDeclaration) ||
- node.IsKind(SyntaxKind.InvocationExpression) ||
- node.IsKind(SyntaxKind.CastExpression) ||
- node is LiteralExpressionSyntax ||
- node is SimpleNameSyntax ||
- node is ExpressionSyntax;
- }
-
- protected override SyntaxNode GetTargetNode(SyntaxNode node)
- {
- var invocation = node as InvocationExpressionSyntax;
- if (invocation != null)
- {
- return invocation.Expression.GetRightmostName();
- }
-
- var memberBindingExpression = node as MemberBindingExpressionSyntax;
- if (memberBindingExpression != null)
- {
- return memberBindingExpression.Name;
- }
-
- return node;
- }
- static CSharpGenerateConversionService service = new CSharpGenerateConversionService ();
-
- protected override Task<IEnumerable<CodeAction>> GetCodeActionsAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- return service.GenerateConversionAsync(document, node, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
deleted file mode 100644
index c1c8396fa3..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.CSharp.CodeFixes.GenerateConstructor;
-using ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember;
-using Microsoft.CodeAnalysis.CSharp;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace MonoDevelop.CSharp.CodeFixes.GenerateMethod
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateMethod), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateEnumMember)]
- internal class GenerateMethodCodeFixProvider : AbstractGenerateMemberCodeFixProvider
- {
- private const string CS0103 = "CS0103"; // error CS0103: Error The name 'Foo' does not exist in the current context
- private const string CS1061 = "CS1061"; // error CS1061: Error 'Class' does not contain a definition for 'Foo' and no extension method 'Foo'
- private const string CS0117 = "CS0117"; // error CS0117: 'Class' does not contain a definition for 'Foo'
- private const string CS0122 = "CS0122"; // error CS0122: 'Class' is inaccessible due to its protection level.
- private const string CS0539 = "CS0539"; // error CS0539: 'A.Foo<T>()' in explicit interface declaration is not a member of interface
- private const string CS1501 = "CS1501"; // error CS1501: No overload for method 'M' takes 1 arguments
- private const string CS1503 = "CS1503"; // error CS1503: Argument 1: cannot convert from 'double' to 'int'
- private const string CS0305 = "CS0305"; // error CS0305: Using the generic method 'CA.M<V>()' requires 1 type arguments
- private const string CS0308 = "CS0308"; // error CS0308: The non-generic method 'Program.Foo()' cannot be used with type arguments
- private const string CS1660 = "CS1660"; // error CS1660: Cannot convert lambda expression to type 'string[]' because it is not a delegate type
- private const string CS1739 = "CS1739"; // error CS1739: The best overload for 'M' does not have a parameter named 'x'
- private const string CS7036 = "CS7036"; // error CS7036: There is no argument given that corresponds to the required formal parameter 'x' of 'C.M(int)'
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS0103, CS1061, CS0117, CS0122, CS0539, CS1501, CS1503, CS0305, CS0308, CS1660, CS1739, CS7036); }
- }
-
- protected override bool IsCandidate(SyntaxNode node)
- {
- return node.IsKind(SyntaxKind.IdentifierName) ||
- node.IsKind(SyntaxKind.MethodDeclaration) ||
- node.IsKind(SyntaxKind.InvocationExpression) ||
- node.IsKind(SyntaxKind.CastExpression) ||
- node is LiteralExpressionSyntax ||
- node is SimpleNameSyntax ||
- node is ExpressionSyntax;
- }
-
- protected override SyntaxNode GetTargetNode(SyntaxNode node)
- {
- var invocation = node as InvocationExpressionSyntax;
- if (invocation != null)
- {
- return invocation.Expression.GetRightmostName();
- }
-
- var memberBindingExpression = node as MemberBindingExpressionSyntax;
- if (memberBindingExpression != null)
- {
- return memberBindingExpression.Name;
- }
-
- return node;
- }
- static CSharpGenerateMethodService service = new CSharpGenerateMethodService ();
-
- protected override Task<IEnumerable<CodeAction>> GetCodeActionsAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- return service.GenerateMethodAsync(document, node, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateType/GenerateTypeCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateType/GenerateTypeCodeFixProvider.cs
deleted file mode 100644
index 6039a17dc7..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateType/GenerateTypeCodeFixProvider.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.CSharp.CodeFixes.GenerateConstructor;
-using ICSharpCode.NRefactory6.CSharp.GenerateType;
-using Microsoft.CodeAnalysis.CSharp;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace MonoDevelop.CSharp.CodeFixes.GenerateType
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateType), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateVariable)]
- internal class GenerateTypeCodeFixProvider : AbstractGenerateMemberCodeFixProvider
- {
- private const string CS0103 = "CS0103"; // error CS0103: The name 'Foo' does not exist in the current context
- private const string CS0117 = "CS0117"; // error CS0117: 'x' does not contain a definition for 'y'
- private const string CS0234 = "CS0234"; // error CS0234: The type or namespace name 'C' does not exist in the namespace 'N' (are you missing an assembly reference?)
- private const string CS0246 = "CS0246"; // error CS0246: The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
- private const string CS0305 = "CS0305"; // error CS0305: Using the generic type 'C<T1>' requires 1 type arguments
- private const string CS0308 = "CS0308"; // error CS0308: The non-generic type 'A' cannot be used with type arguments
- private const string CS0426 = "CS0426"; // error CS0426: The type name 'S' does not exist in the type 'Program'
- private const string CS0616 = "CS0616"; // error CS0616: 'x' is not an attribute class
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS0103, CS0117, CS0234, CS0246, CS0305, CS0308, CS0426, CS0616); }
- }
-
- protected override bool IsCandidate(SyntaxNode node)
- {
- var qualified = node as QualifiedNameSyntax;
- if (qualified != null)
- {
- return true;
- }
-
- var simple = node as SimpleNameSyntax;
- if (simple != null)
- {
- return !simple.IsParentKind(SyntaxKind.QualifiedName);
- }
-
- var memberAccess = node as MemberAccessExpressionSyntax;
- if (memberAccess != null)
- {
- return true;
- }
- if (node.IsKind (SyntaxKind.ObjectCreationExpression))
- return true;
- return false;
- }
-
- protected override SyntaxNode GetTargetNode(SyntaxNode node)
- {
- if (node.IsKind (SyntaxKind.ObjectCreationExpression))
- node = ((ObjectCreationExpressionSyntax)node).Type;
- return ((ExpressionSyntax)node).GetRightmostName();
- }
-
- static readonly CSharpGenerateTypeService service = new CSharpGenerateTypeService ();
-
- protected override Task<IEnumerable<CodeAction>> GetCodeActionsAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- return service.GenerateTypeAsync(document, node, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateVariable/GenerateVariableCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateVariable/GenerateVariableCodeFixProvider.cs
deleted file mode 100644
index 11e589fc05..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/GenerateVariable/GenerateVariableCodeFixProvider.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.GenerateMember.GenerateVariable;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.CSharp.CodeFixes.GenerateConstructor;
-
-namespace MonoDevelop.CSharp.CodeFixes.GenerateVariable
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateVariable), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateMethod)]
- internal class GenerateVariableCodeFixProvider : AbstractGenerateMemberCodeFixProvider
- {
- private const string CS1061 = "CS1061"; // error CS1061: 'C' does not contain a definition for 'Foo' and no extension method 'Foo' accepting a first argument of type 'C' could be found
- private const string CS0103 = "CS0103"; // error CS0103: The name 'Foo' does not exist in the current context
- private const string CS0117 = "CS0117"; // error CS0117: 'TestNs.Program' does not contain a definition for 'blah'
- private const string CS0539 = "CS0539"; // error CS0539: 'Class.SomeProp' in explicit interface declaration is not a member of interface
- private const string CS0246 = "CS0246"; // error CS0246: The type or namespace name 'Version' could not be found
-
- public override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS1061, CS0103, CS0117, CS0539, CS0246); }
- }
-
- protected override bool IsCandidate(SyntaxNode node)
- {
- return node is SimpleNameSyntax || node is PropertyDeclarationSyntax || node is MemberBindingExpressionSyntax;
- }
-
- protected override SyntaxNode GetTargetNode(SyntaxNode node)
- {
- if (node.IsKind(SyntaxKind.MemberBindingExpression))
- {
- var nameNode = node.ChildNodes().FirstOrDefault(n => n.IsKind(SyntaxKind.IdentifierName));
- if (nameNode != null)
- {
- return nameNode;
- }
- }
-
- return base.GetTargetNode(node);
- }
- static readonly CSharpGenerateVariableService service = new CSharpGenerateVariableService ();
-
- protected override Task<IEnumerable<CodeAction>> GetCodeActionsAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- return service.GenerateVariableAsync(document, node, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/ImplementAbstractClass/ImplementAbstractClassCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/ImplementAbstractClass/ImplementAbstractClassCodeFixProvider.cs
deleted file mode 100644
index 25c8b7f949..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/ImplementAbstractClass/ImplementAbstractClassCodeFixProvider.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.Features.ImplementAbstractClass;
-using MonoDevelop.Core;
-using RefactoringEssentials;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace MonoDevelop.CSharp.CodeFixes.ImplementAbstractClass
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ImplementAbstractClass), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateType)]
- internal class ImplementAbstractClassCodeFixProvider : CodeFixProvider
- {
- private const string CS0534 = "CS0534"; // 'Program' does not implement inherited abstract member 'Foo.bar()'
-
- public sealed override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS0534); }
- }
-
- public sealed override FixAllProvider GetFixAllProvider()
- {
- return WellKnownFixAllProviders.BatchFixer;
- }
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
-
- var token = root.FindToken(context.Span.Start);
- if (!token.Span.IntersectsWith(context.Span))
- {
- return;
- }
-
- var classNode = token.Parent as ClassDeclarationSyntax;
- if (classNode == null)
- {
- return;
- }
-
- var model = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false);
- if (model.IsFromGeneratedCode (context.CancellationToken))
- return;
-
- foreach (var baseTypeSyntax in classNode.BaseList.Types)
- {
- var node = baseTypeSyntax.Type;
-
- if (service.CanImplementAbstractClass(
- context.Document,
- model,
- node,
- context.CancellationToken))
- {
- var title = GettextCatalog.GetString ("Implement Abstract Class");
- var abstractType = model.GetTypeInfo(node, context.CancellationToken).Type;
- //var id = GetCodeActionId(abstractType.ContainingAssembly.Name, abstractType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat));
- context.RegisterCodeFix(
- new DocumentChangeAction(node.Span, DiagnosticSeverity.Error, title,
- (c) => ImplementAbstractClassAsync(context.Document, node, c)),
- context.Diagnostics);
- return;
- }
- }
- }
-
- // internal for testing purposes.
- internal static string GetCodeActionId(string assemblyName, string abstractTypeFullyQualifiedName)
- {
- return "ImplementAbstractClass;" +
- assemblyName + ";" +
- abstractTypeFullyQualifiedName;
- }
- static CSharpImplementAbstractClassService service = new CSharpImplementAbstractClassService ();
-
- private async Task<Document> ImplementAbstractClassAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- return await service.ImplementAbstractClassAsync(
- document,
- await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false),
- node,
- cancellationToken).ConfigureAwait(false);
- }
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/ImplementInterface/ImplementInterfaceCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/ImplementInterface/ImplementInterfaceCodeFixProvider.cs
deleted file mode 100644
index 89f89add8a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/ImplementInterface/ImplementInterfaceCodeFixProvider.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.Features.ImplementInterface;
-using ICSharpCode.NRefactory6.CSharp;
-using RefactoringEssentials;
-
-namespace MonoDevelop.CSharp.CodeFixes.ImplementInterface
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ImplementInterface), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.ImplementAbstractClass)]
- internal class ImplementInterfaceCodeFixProvider : CodeFixProvider
- {
- private readonly Func<TypeSyntax, bool> _interfaceName = n => n.Parent is BaseTypeSyntax && n.Parent.Parent is BaseListSyntax && ((BaseTypeSyntax)n.Parent).Type == n;
- private readonly Func<IEnumerable<CodeAction>, bool> _codeActionAvailable = actions => actions != null && actions.Any();
-
- internal const string CS0535 = "CS0535"; // 'Program' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'
- internal const string CS0737 = "CS0737"; // 'Class' does not implement interface member 'IInterface.M()'. 'Class.M()' cannot implement an interface member because it is not public.
- internal const string CS0738 = "CS0738"; // 'C' does not implement interface member 'I.Method1()'. 'B.Method1()' cannot implement 'I.Method1()' because it does not have the matching return type of 'void'.
-
- public sealed override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(CS0535, CS0737, CS0738); }
- }
- static CSharpImplementInterfaceService service = new CSharpImplementInterfaceService();
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- var document = context.Document;
- var span = context.Span;
- var cancellationToken = context.CancellationToken;
-
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
-
- var token = root.FindToken(span.Start);
- if (!token.Span.IntersectsWith(span))
- {
- return;
- }
-
- var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- if (model.IsFromGeneratedCode (cancellationToken))
- return;
-
- var actions = token.Parent.GetAncestorsOrThis<TypeSyntax>()
- .Where(_interfaceName)
- .Select(n => service.GetCodeActions(document, model, n, cancellationToken))
- .FirstOrDefault(_codeActionAvailable);
-
- if (_codeActionAvailable(actions))
- {
- context.RegisterFixes(actions, context.Diagnostics);
- }
- }
-
- public sealed override FixAllProvider GetFixAllProvider()
- {
- return WellKnownFixAllProviders.BatchFixer;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/MoveTypeToFile/MoveTypeToFile.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/MoveTypeToFile/MoveTypeToFile.cs
deleted file mode 100644
index b9dd28cf76..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/MoveTypeToFile/MoveTypeToFile.cs
+++ /dev/null
@@ -1,256 +0,0 @@
-//
-// MoveTypeToFile.cs
-//
-// Author:
-// Mike Krüger <mkrueger@novell.com>
-//
-// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using ICSharpCode.NRefactory.CSharp;
-using RefactoringEssentials;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Editor;
-using MonoDevelop.Core.Text;
-using MonoDevelop.Ide;
-using System.Collections.Generic;
-using MonoDevelop.Ide.StandardHeader;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.SharedAssetsProjects;
-
-namespace MonoDevelop.CSharp.CodeFixes.MoveTypeToFile
-{
- [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = "Move type to file")]
- class MoveTypeToFile : CodeRefactoringProvider
- {
- public async override Task ComputeRefactoringsAsync (CodeRefactoringContext context)
- {
- var document = context.Document;
- var span = context.Span;
- var cancellationToken = context.CancellationToken;
-
- var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (cancellationToken))
- return;
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait (false);
- var token = root.FindToken(span.Start);
-
- var type = token.Parent as BaseTypeDeclarationSyntax;
- if (type == null)
- return;
- if (type.Parent is BaseTypeDeclarationSyntax)
- return;
-
- if (Path.GetFileNameWithoutExtension (document.FilePath) == type.Identifier.ToString ())
- return;
-
- string title;
- if (IsSingleType (root)) {
- title = String.Format (GettextCatalog.GetString ("Rename file to '{0}'"), Path.GetFileName (GetCorrectFileName (document, type)));
- } else {
- title = String.Format (GettextCatalog.GetString ("Move type to file '{0}'"), Path.GetFileName (GetCorrectFileName (document, type)));
- }
- context.RegisterRefactoring (new MyCodeAction (document, title, root, type));
- }
-
- class MyCodeAction : CodeAction
- {
- readonly Document document;
- readonly BaseTypeDeclarationSyntax type;
- readonly SyntaxNode root;
-
- bool generatePreview;
-
- public MyCodeAction (Document document, string title, SyntaxNode root, BaseTypeDeclarationSyntax type)
- {
- this.root = root;
- this.title = title;
- this.type = type;
- this.document = document;
-
- }
-
- string title;
- public override string Title {
- get {
- return this.title;
- }
- }
-
- protected override Task<IEnumerable<CodeActionOperation>> ComputePreviewOperationsAsync (System.Threading.CancellationToken cancellationToken)
- {
- generatePreview = true;
- var result = base.ComputePreviewOperationsAsync (cancellationToken);
- generatePreview = false;
- return result;
- }
-
- protected override async Task<Document> GetChangedDocumentAsync (System.Threading.CancellationToken cancellationToken)
- {
- if (generatePreview) {
- var removeType =
- root.DescendantNodesAndSelf (n => !(n is BaseTypeDeclarationSyntax))
- .OfType<BaseTypeDeclarationSyntax> ()
- .FirstOrDefault (t => t.SpanStart == type.SpanStart);
- if (removeType == null)
- return document;
-
- var st = await document.GetTextAsync ().ConfigureAwait (false);
- var bounds = CalcTypeBounds (removeType);
-
- return document.WithText (st.WithChanges (new Microsoft.CodeAnalysis.Text.TextChange (new TextSpan (bounds.Offset, bounds.Length), "")));
- }
-
- var correctFileName = GetCorrectFileName (document, type);
- if (IsSingleType (root)) {
- FileService.RenameFile (document.FilePath, correctFileName);
- var doc = IdeApp.Workbench.ActiveDocument;
- if (doc.HasProject) {
- var prj = DetermineRealProject (doc);
- IdeApp.ProjectOperations.SaveAsync (prj);
- }
- return document;
- }
- return CreateNewFile (type, correctFileName);
- }
-
- Document CreateNewFile (BaseTypeDeclarationSyntax type, string correctFileName)
- {
- var doc = IdeApp.Workbench.ActiveDocument;
- var content = doc.Editor.Text;
-
- var types = new List<BaseTypeDeclarationSyntax> (
- root
- .DescendantNodesAndSelf (n => !(n is BaseTypeDeclarationSyntax))
- .OfType<BaseTypeDeclarationSyntax> ()
- .Where (t => t.SpanStart != type.SpanStart)
- );
- types.Sort ((x, y) => y.SpanStart.CompareTo (x.SpanStart));
-
- foreach (var removeType in types) {
- var bounds = CalcTypeBounds (removeType);
- content = content.Remove (bounds.Offset, bounds.Length);
- }
-
- if (doc.HasProject) {
- string header = StandardHeaderService.GetHeader (doc.Project, correctFileName, true);
- if (!string.IsNullOrEmpty (header))
- content = header + doc.Editor.GetEolMarker () + StripHeader (content);
- }
- content = StripDoubleBlankLines (content);
-
- File.WriteAllText (correctFileName, content);
- if (doc.HasProject) {
- var prj = DetermineRealProject (doc);
-
- prj.AddFile (correctFileName);
- IdeApp.ProjectOperations.SaveAsync (prj);
- }
-
- doc.Editor.RemoveText (CalcTypeBounds (type));
-
- return document;
- }
-
- static Projects.Project DetermineRealProject (Ide.Gui.Document doc)
- {
- // try to search for a shared project
- var allProjects = IdeApp.Workspace.GetAllItems<SharedAssetsProject> ();
- var projects = new List<SharedAssetsProject> (allProjects.Where (p => p.IsFileInProject (doc.FileName)));
- if (projects.Count > 0)
- return projects [0];
-
- return doc.Project;
- }
-
- ISegment CalcTypeBounds (BaseTypeDeclarationSyntax type)
- {
- int start = type.Span.Start;
- int end = type.Span.End;
- foreach (var trivia in type.GetLeadingTrivia ()) {
- if (trivia.Kind () == SyntaxKind.SingleLineDocumentationCommentTrivia) {
- start = trivia.FullSpan.Start;
- }
- }
-
- return TextSegment.FromBounds (start, end);
- }
- }
-
- static bool IsBlankLine (IReadonlyTextDocument doc, int i)
- {
- var line = doc.GetLine (i);
- return line.Length == line.GetIndentation (doc).Length;
- }
-
- static string StripDoubleBlankLines (string content)
- {
- var doc = TextEditorFactory.CreateNewDocument (new StringTextSource (content), "a.cs");
- for (int i = 1; i + 1 <= doc.LineCount; i++) {
- if (IsBlankLine (doc, i) && IsBlankLine (doc, i + 1)) {
- doc.RemoveText (doc.GetLine (i).SegmentIncludingDelimiter);
- i--;
- continue;
- }
- }
- return doc.Text;
- }
-
- static string StripHeader (string content)
- {
- var doc = TextEditorFactory.CreateNewDocument (new StringTextSource (content), "");
- while (true) {
- string lineText = doc.GetLineText (1);
- if (lineText == null)
- break;
- if (lineText.StartsWith ("//", StringComparison.Ordinal)) {
- doc.RemoveText (doc.GetLine (1).SegmentIncludingDelimiter);
- continue;
- }
- break;
- }
- return doc.Text;
- }
-
- static bool IsSingleType (SyntaxNode root)
- {
- return root.DescendantNodesAndSelf (c => !(c is BaseTypeDeclarationSyntax)).OfType<BaseTypeDeclarationSyntax> ().Count () == 1;
- }
-
- internal static string GetCorrectFileName (Document document, BaseTypeDeclarationSyntax type)
- {
- if (type == null)
- return document.FilePath;
- return Path.Combine (Path.GetDirectoryName (document.FilePath), type.Identifier + Path.GetExtension (document.FilePath));
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/PredefinedCodeFixProviderNames.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/PredefinedCodeFixProviderNames.cs
deleted file mode 100644
index 71e0e7e62e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/PredefinedCodeFixProviderNames.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// PredefinedCodeFixProviderNames.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using MonoDevelop.Core;
-
-namespace MonoDevelop.CSharp.CodeFixes
-{
- static class PredefinedCodeFixProviderNames
- {
- public const string AddAwait = "Add Await For Expression";
- public const string AddAsync = "Add Async To Member";
- public const string ChangeReturnType = "Change Return Type";
- public const string ChangeToYield = "Change To Yield";
- public const string ConvertToAsync = "Convert To Async";
- public const string ConvertToIterator = "Convert To Iterator";
- public const string CorrectNextControlVariable = "Correct Next Control Variable";
- public const string AddMissingReference = "Add Missing Reference";
- public const string AddUsingOrImport = "Add Using or Import";
- public const string FullyQualify = "Fully Qualify";
- public const string FixIncorrectFunctionReturnType = "Fix Incorrect Function Return Type";
- public const string FixIncorrectExitContinue = "Fix Incorrect Exit Continue";
- public const string GenerateConstructor = "Generate Constructor";
- public const string GenerateEndConstruct = "Generate End Construct";
- public const string GenerateEnumMember = "Generate Enum Member";
- public const string GenerateEvent = "Generate Event";
- public const string GenerateVariable = "Generate Variable";
- public const string GenerateMethod = "Generate Method";
- public const string GenerateConversion = "Generate Conversion";
- public const string GenerateType = "Generate Type";
- public const string ImplementAbstractClass = "Implement Abstract Class";
- public const string ImplementInterface = "Implement Interface";
- public const string InsertMissingCast = "InsertMissingCast";
- public const string MoveToTopOfFile = "Move To Top Of File";
- public const string RemoveUnnecessaryCast = "Remove Unnecessary Casts";
- public const string RemoveUnnecessaryImports = "Remove Unnecessary Usings or Imports";
- public const string RenameTracking = "Rename Tracking";
- public const string SimplifyNames = "Simplify Names";
- public const string SpellCheck = "Spell Check";
- public const string Suppression = "Suppression";
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryCast/RemoveUnnecessaryCastCodeFixProvider.RemoveUnnecessaryCastFixAllProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryCast/RemoveUnnecessaryCastCodeFixProvider.RemoveUnnecessaryCastFixAllProvider.cs
deleted file mode 100644
index ec7d818390..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryCast/RemoveUnnecessaryCastCodeFixProvider.RemoveUnnecessaryCastFixAllProvider.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-
-namespace MonoDevelop.CSharp.CodeFixes.RemoveUnnecessaryCast
-{
- internal partial class RemoveUnnecessaryCastCodeFixProvider : CodeFixProvider
- {
-// private class RemoveUnnecessaryCastFixAllProvider : BatchSimplificationFixAllProvider
-// {
-// internal static new readonly RemoveUnnecessaryCastFixAllProvider Instance = new RemoveUnnecessaryCastFixAllProvider();
-//
-// protected override SyntaxNode GetNodeToSimplify(SyntaxNode root, SemanticModel model, Diagnostic diagnostic, Workspace workspace, out string codeActionId, CancellationToken cancellationToken)
-// {
-// codeActionId = null;
-// return GetCastNode(root, model, diagnostic.Location.SourceSpan, cancellationToken);
-// }
-//
-// protected override bool NeedsParentFixup
-// {
-// get
-// {
-// return true;
-// }
-// }
-//
-// protected override async Task<Document> AddSimplifyAnnotationsAsync(Document document, SyntaxNode nodeToSimplify, CancellationToken cancellationToken)
-// {
-// var cast = nodeToSimplify as CastExpressionSyntax;
-// if (cast == null)
-// {
-// return null;
-// }
-//
-// return await RemoveUnnecessaryCastAsync(document, cast, cancellationToken).ConfigureAwait(false);
-// }
-// }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryCast/RemoveUnnecessaryCastCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryCast/RemoveUnnecessaryCastCodeFixProvider.cs
deleted file mode 100644
index 26283ce45d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryCast/RemoveUnnecessaryCastCodeFixProvider.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.CSharp.Diagnostics;
-using ICSharpCode.NRefactory6.CSharp;
-using MonoDevelop.Core;
-using RefactoringEssentials;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace MonoDevelop.CSharp.CodeFixes.RemoveUnnecessaryCast
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.RemoveUnnecessaryCast), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.ImplementInterface)]
- internal partial class RemoveUnnecessaryCastCodeFixProvider : CodeFixProvider
- {
- public sealed override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(IDEDiagnosticIds.RemoveUnnecessaryCastDiagnosticId); }
- }
-
-// public sealed override FixAllProvider GetFixAllProvider()
-// {
-// return RemoveUnnecessaryCastFixAllProvider.Instance;
-// }
-//
- private static CastExpressionSyntax GetCastNode(SyntaxNode root, SemanticModel model, TextSpan span, CancellationToken cancellationToken)
- {
- var token = root.FindToken(span.Start);
- if (!token.Span.IntersectsWith(span))
- {
- return null;
- }
-
- return token.GetAncestors<CastExpressionSyntax>()
- .FirstOrDefault(c => c.Span.IntersectsWith(span) && c.IsUnnecessaryCast(model, cancellationToken));
- }
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- var document = context.Document;
- var span = context.Span;
- var cancellationToken = context.CancellationToken;
-
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var node = GetCastNode(root, model, span, cancellationToken);
- if (node == null)
- {
- return;
- }
-
- context.RegisterCodeFix(
- new DocumentChangeAction(node.Span, DiagnosticSeverity.Warning,
- GettextCatalog.GetString ("Remove Unnecessary Cast"),
- (c) => RemoveUnnecessaryCastAsync(document, node, c)),
- context.Diagnostics);
- }
-
- private static async Task<Document> RemoveUnnecessaryCastAsync(Document document, CastExpressionSyntax cast, CancellationToken cancellationToken)
- {
- var annotatedCast = cast.WithAdditionalAnnotations(Simplifier.Annotation);
-
- if (annotatedCast.Expression is ParenthesizedExpressionSyntax)
- {
- annotatedCast = annotatedCast.WithExpression(
- annotatedCast.Expression.WithAdditionalAnnotations(Simplifier.Annotation));
- }
- else
- {
- annotatedCast = annotatedCast.WithExpression(
- annotatedCast.Expression.Parenthesize());
- }
-
- ExpressionSyntax oldNode = cast;
- ExpressionSyntax newNode = annotatedCast;
-
- // Ensure that we simplify any parenting parenthesized expressions not just on the syntax tree level but also on Token based
- // Case 1:
- // In the syntax, (((Task<Action>)x).Result)()
- // oldNode = (Task<Action>)x
- // newNode = (Task<Action>)(x)
- // Final newNode will be (((Task<Action>)(x)).Result)
- while (oldNode.Parent.IsKind(SyntaxKind.ParenthesizedExpression) || oldNode.GetFirstToken().GetPreviousToken().Parent.IsKind(SyntaxKind.ParenthesizedExpression))
- {
- var parenthesizedExpression = (ParenthesizedExpressionSyntax)oldNode.GetFirstToken().GetPreviousToken().Parent;
- newNode = parenthesizedExpression.ReplaceNode(oldNode, newNode)
- .WithAdditionalAnnotations(Simplifier.Annotation);
- oldNode = parenthesizedExpression;
- }
-
- newNode = newNode.WithAdditionalAnnotations(Formatter.Annotation);
-
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var newRoot = root.ReplaceNode(oldNode, newNode);
-
- return document.WithSyntaxRoot(newRoot);
- }
-//
-// private class MyCodeAction : CodeAction.DocumentChangeAction
-// {
-// public MyCodeAction(string title, Func<CancellationToken, Task<Document>> createChangedDocument) :
-// base(title, createChangedDocument)
-// {
-// }
-// }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryUsings/RemoveUnnecessaryUsingsCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryUsings/RemoveUnnecessaryUsingsCodeFixProvider.cs
deleted file mode 100644
index e3ed5cea15..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/RemoveUnnecessaryUsings/RemoveUnnecessaryUsingsCodeFixProvider.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.Features.RemoveUnnecessaryImports;
-using MonoDevelop.Core;
-using RefactoringEssentials;
-using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.CSharp.Diagnostics;
-
-namespace MonoDevelop.CSharp.CodeFixes.RemoveUnusedUsings
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.RemoveUnnecessaryImports), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.AddMissingReference)]
- internal class RemoveUnnecessaryUsingsCodeFixProvider : CodeFixProvider
- {
- public sealed override ImmutableArray<string> FixableDiagnosticIds
- {
- get { return ImmutableArray.Create(IDEDiagnosticIds.RemoveUnnecessaryImportsDiagnosticId); }
- }
-
- public sealed override FixAllProvider GetFixAllProvider()
- {
- return WellKnownFixAllProviders.BatchFixer;
- }
-
- static readonly CSharpRemoveUnnecessaryImportsService service = new CSharpRemoveUnnecessaryImportsService();
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- var document = context.Document;
- var span = context.Span;
- var cancellationToken = context.CancellationToken;
-
- var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var newDocument = service.RemoveUnnecessaryImports(document, model, root, cancellationToken);
- if (newDocument == document || newDocument == null)
- {
- return;
- }
-
- context.RegisterCodeFix(
- new DocumentChangeAction(context.Diagnostics[0].Location.SourceSpan, DiagnosticSeverity.Warning,
- GettextCatalog.GetString ("Remove Unnecessary Usings"),
- (c) => Task.FromResult(newDocument)),
- context.Diagnostics);
- }
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.SimplifyTypeNamesFixAllProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.SimplifyTypeNamesFixAllProvider.cs
deleted file mode 100644
index 543c9b3b38..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.SimplifyTypeNamesFixAllProvider.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis;
-
-namespace MonoDevelop.CSharp.CodeFixes.SimplifyTypeNames
-{
- internal partial class SimplifyTypeNamesCodeFixProvider : CodeFixProvider
- {
-// private class SimplifyTypeNamesFixAllProvider : BatchSimplificationFixAllProvider
-// {
-// internal static new readonly SimplifyTypeNamesFixAllProvider Instance = new SimplifyTypeNamesFixAllProvider();
-//
-// protected override SyntaxNode GetNodeToSimplify(SyntaxNode root, SemanticModel model, Diagnostic diagnostic, Workspace workspace, out string codeActionId, CancellationToken cancellationToken)
-// {
-// codeActionId = null;
-// string diagnosticId;
-// var node = SimplifyTypeNamesCodeFixProvider.GetNodeToSimplify(root, model, diagnostic.Location.SourceSpan, workspace.Options, out diagnosticId, cancellationToken);
-// if (node != null)
-// {
-// codeActionId = GetCodeActionId(diagnosticId, node.ToString());
-// }
-//
-// return node;
-// }
-// }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.cs
deleted file mode 100644
index 0b2b11df09..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Immutable;
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.CSharp.Diagnostics;
-using ICSharpCode.NRefactory6.CSharp;
-using MonoDevelop.Core;
-using System;
-using Microsoft.CodeAnalysis.CSharp;
-using RefactoringEssentials;
-using MonoDevelop.CSharp.Diagnostics.SimplifyTypeNames;
-
-namespace MonoDevelop.CSharp.CodeFixes.SimplifyTypeNames
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.SimplifyNames), Shared]
- [ExtensionOrder(After = PredefinedCodeFixProviderNames.RemoveUnnecessaryCast)]
- internal partial class SimplifyTypeNamesCodeFixProvider : CodeFixProvider
- {
- public sealed override ImmutableArray<string> FixableDiagnosticIds
- {
- get
- {
- return ImmutableArray.Create(
- IDEDiagnosticIds.SimplifyNamesDiagnosticId,
- IDEDiagnosticIds.SimplifyMemberAccessDiagnosticId,
- IDEDiagnosticIds.SimplifyThisOrMeDiagnosticId);
- }
- }
-
-// public sealed override FixAllProvider GetFixAllProvider()
-// {
-// return SimplifyTypeNamesFixAllProvider.Instance;
-// }
-
- internal static SyntaxNode GetNodeToSimplify(SyntaxNode root, SemanticModel model, TextSpan span, OptionSet optionSet, out string diagnosticId, CancellationToken cancellationToken)
- {
- diagnosticId = null;
- var token = root.FindToken(span.Start, findInsideTrivia: true);
- if (!token.Span.IntersectsWith(span))
- {
- return null;
- }
-
- foreach (var n in token.GetAncestors<SyntaxNode>())
- {
- if (n.Span.IntersectsWith(span) && CanSimplifyTypeNameExpression(model, n, optionSet, span, out diagnosticId, cancellationToken))
- {
- return n;
- }
- }
-
- return null;
- }
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- var document = context.Document;
- var span = context.Span;
- var cancellationToken = context.CancellationToken;
-
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var optionSet = document.Project.Solution.Workspace.Options;
- string diagnosticId;
- var node = GetNodeToSimplify(root, model, span, optionSet, out diagnosticId, cancellationToken);
- if (node == null)
- {
- return;
- }
-
- var id = GetCodeActionId(diagnosticId, node.ToString());
- var title = id;
- var codeAction = new DocumentChangeAction(node.Span, DiagnosticSeverity.Warning, title,
- (c) => SimplifyTypeNameAsync(document, node, c));
-
- context.RegisterCodeFix(codeAction, context.Diagnostics);
- }
-
- // internal for testing purpose
- internal static string GetCodeActionId(string diagnosticId, string nodeText)
- {
- switch (diagnosticId)
- {
- case IDEDiagnosticIds.SimplifyNamesDiagnosticId:
- return string.Format(GettextCatalog.GetString ("Simplify name '{0}'"), nodeText);
-
- case IDEDiagnosticIds.SimplifyMemberAccessDiagnosticId:
- return string.Format(GettextCatalog.GetString ("Simplify member access '{0}'"), nodeText);
-
- case IDEDiagnosticIds.SimplifyThisOrMeDiagnosticId:
- return GettextCatalog.GetString ("Remove 'this' qualification");
-
- default:
- throw new InvalidOperationException();
- }
- }
-
- private static bool CanSimplifyTypeNameExpression(SemanticModel model, SyntaxNode node, OptionSet optionSet, TextSpan span, out string diagnosticId, CancellationToken cancellationToken)
- {
- diagnosticId = null;
- TextSpan issueSpan;
- if (!CSharpSimplifyTypeNamesDiagnosticAnalyzer.IsCandidate(node) ||
- !CSharpSimplifyTypeNamesDiagnosticAnalyzer.CanSimplifyTypeNameExpression(model, node, optionSet, out issueSpan, out diagnosticId, cancellationToken))
- {
- return false;
- }
-
- return issueSpan.Equals(span);
- }
-
- private async Task<Document> SimplifyTypeNameAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- var expressionSyntax = node;
- var annotatedexpressionSyntax = expressionSyntax.WithAdditionalAnnotations(Simplifier.Annotation, Formatter.Annotation);
-
- if (annotatedexpressionSyntax.Kind() == SyntaxKind.IsExpression || annotatedexpressionSyntax.Kind() == SyntaxKind.AsExpression)
- {
- var right = ((BinaryExpressionSyntax)annotatedexpressionSyntax).Right;
- annotatedexpressionSyntax = annotatedexpressionSyntax.ReplaceNode(right, right.WithAdditionalAnnotations(Simplifier.Annotation));
- }
-
- SyntaxNode oldNode = expressionSyntax;
- SyntaxNode newNode = annotatedexpressionSyntax;
-
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var newRoot = root.ReplaceNode(oldNode, newNode);
-
- return document.WithSyntaxRoot(newRoot);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CodeGenerationOptions.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CodeGenerationOptions.cs
index 82fbc7abe2..fc856bd3e5 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CodeGenerationOptions.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CodeGenerationOptions.cs
@@ -23,25 +23,22 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System.Linq;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide;
-using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.Core;
-using System;
using System.Threading;
+using System.Threading.Tasks;
+using ICSharpCode.NRefactory6.CSharp;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis.Formatting;
+using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Simplification;
+using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using MonoDevelop.Core;
+using MonoDevelop.CSharp.Completion;
+using MonoDevelop.Ide;
using MonoDevelop.Ide.Editor;
-using Microsoft.CodeAnalysis.Options;
using MonoDevelop.Ide.Gui.Content;
-using Microsoft.CodeAnalysis.Formatting;
-using System.Diagnostics;
-using ICSharpCode.NRefactory6.CSharp;
-using MonoDevelop.CSharp.Completion;
+using MonoDevelop.Ide.TypeSystem;
namespace MonoDevelop.CodeGeneration
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CreateConstructorGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CreateConstructorGenerator.cs
index 29e0d44547..7f5f2fe841 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CreateConstructorGenerator.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CreateConstructorGenerator.cs
@@ -1,42 +1,38 @@
-//
-// CreateConstructorGenerator.cs
-//
-// Author:
-// Mike Krüger <mkrueger@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
+//
+// CreateConstructorGenerator.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
using System.Collections.Generic;
-using System.Text;
using System.Linq;
-using MonoDevelop.Core;
+using Gtk;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.ExtractMethod;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Simplification;
-using ICSharpCode.NRefactory6.CSharp;
-using Gtk;
+using MonoDevelop.Core;
using MonoDevelop.Ide.TypeSystem;
-using ICSharpCode.NRefactory6.CSharp.ExtractMethod;
namespace MonoDevelop.CodeGeneration
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/OverrideMembersGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/OverrideMembersGenerator.cs
index 8d1b747b4b..3d60dbcf50 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/OverrideMembersGenerator.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/OverrideMembersGenerator.cs
@@ -24,16 +24,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using Gtk;
using System.Collections.Generic;
using MonoDevelop.Core;
-using MonoDevelop.Refactoring;
-using ICSharpCode.NRefactory6.CSharp;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.CSharp.Refactoring;
-using MonoDevelop.Ide.TypeSystem;
namespace MonoDevelop.CodeGeneration
{
@@ -83,7 +80,7 @@ namespace MonoDevelop.CodeGeneration
var result = new HashSet<ISymbol> ();
- var cancellationToken = default(CancellationToken);
+ var cancellationToken = default (CancellationToken);
var baseTypes = encType.GetBaseTypes ().Reverse ();
foreach (var type in baseTypes) {
RemoveOverriddenMembers (result, type, cancellationToken);
@@ -96,7 +93,7 @@ namespace MonoDevelop.CodeGeneration
static void AddOverridableMembers (HashSet<ISymbol> result, INamedTypeSymbol containingType, INamedTypeSymbol type, CancellationToken cancellationToken)
{
- foreach (var member in type.GetMembers()) {
+ foreach (var member in type.GetMembers ()) {
if (IsOverridable (member, containingType)) {
result.Add (member);
}
@@ -105,7 +102,7 @@ namespace MonoDevelop.CodeGeneration
protected static void RemoveOverriddenMembers (HashSet<ISymbol> result, INamedTypeSymbol containingType, CancellationToken cancellationToken)
{
- foreach (var member in containingType.GetMembers()) {
+ foreach (var member in containingType.GetMembers ()) {
var overriddenMember = member.OverriddenMember ();
if (overriddenMember != null) {
result.Remove (overriddenMember);
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/PartialGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/PartialGenerator.cs
index c2329223d2..f4d23de20f 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/PartialGenerator.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/PartialGenerator.cs
@@ -32,6 +32,9 @@ using System.Threading;
using ICSharpCode.NRefactory6.CSharp;
using MonoDevelop.CSharp.Refactoring;
using MonoDevelop.Ide.TypeSystem;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace MonoDevelop.CodeGeneration
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/RaiseEventMethodGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/RaiseEventMethodGenerator.cs
index ef38ac7adc..b146938938 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/RaiseEventMethodGenerator.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/RaiseEventMethodGenerator.cs
@@ -23,19 +23,16 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
-using Gtk;
+using System;
using System.Collections.Generic;
-using MonoDevelop.Refactoring;
-using System.Text;
using System.Linq;
-using Microsoft.CodeAnalysis;
using ICSharpCode.NRefactory6.CSharp;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using MonoDevelop.Core;
using MonoDevelop.Ide.TypeSystem;
namespace MonoDevelop.CodeGeneration
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/CSharpSyntaxContext.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/CSharpSyntaxContext.cs
deleted file mode 100644
index 95efd8254e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/CSharpSyntaxContext.cs
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Reflection;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- public class ReflectionNamespaces
- {
- public const string WorkspacesAsmName = ", Microsoft.CodeAnalysis.Workspaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
- public const string CSWorkspacesAsmName = ", Microsoft.CodeAnalysis.CSharp.Workspaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
- public const string CAAsmName = ", Microsoft.CodeAnalysis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
- public const string CACSharpAsmName = ", Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
- }
-
- public class CSharpSyntaxContext
- {
- readonly static Type typeInfoCSharpSyntaxContext;
- readonly static Type typeInfoAbstractSyntaxContext;
- readonly static MethodInfo createContextMethod;
- readonly static PropertyInfo leftTokenProperty;
- readonly static PropertyInfo targetTokenProperty;
- readonly static FieldInfo isIsOrAsTypeContextField;
- readonly static FieldInfo isInstanceContextField;
- readonly static FieldInfo isNonAttributeExpressionContextField;
- readonly static FieldInfo isPreProcessorKeywordContextField;
- readonly static FieldInfo isPreProcessorExpressionContextField;
- readonly static FieldInfo containingTypeDeclarationField;
- readonly static FieldInfo isGlobalStatementContextField;
- readonly static FieldInfo isParameterTypeContextField;
- readonly static PropertyInfo syntaxTreeProperty;
-
-
- object instance;
-
- public SyntaxToken LeftToken {
- get {
- return (SyntaxToken)leftTokenProperty.GetValue (instance);
- }
- }
-
- public SyntaxToken TargetToken {
- get {
- return (SyntaxToken)targetTokenProperty.GetValue (instance);
- }
- }
-
- public bool IsIsOrAsTypeContext {
- get {
- return (bool)isIsOrAsTypeContextField.GetValue (instance);
- }
- }
-
- public bool IsInstanceContext {
- get {
- return (bool)isInstanceContextField.GetValue (instance);
- }
- }
-
- public bool IsNonAttributeExpressionContext {
- get {
- return (bool)isNonAttributeExpressionContextField.GetValue (instance);
- }
- }
-
- public bool IsPreProcessorKeywordContext {
- get {
- return (bool)isPreProcessorKeywordContextField.GetValue (instance);
- }
- }
-
- public bool IsPreProcessorExpressionContext {
- get {
- return (bool)isPreProcessorExpressionContextField.GetValue (instance);
- }
- }
-
- public TypeDeclarationSyntax ContainingTypeDeclaration {
- get {
- return (TypeDeclarationSyntax)containingTypeDeclarationField.GetValue (instance);
- }
- }
-
- public bool IsGlobalStatementContext {
- get {
- return (bool)isGlobalStatementContextField.GetValue (instance);
- }
- }
-
- public bool IsParameterTypeContext {
- get {
- return (bool)isParameterTypeContextField.GetValue (instance);
- }
- }
-
- public SyntaxTree SyntaxTree {
- get {
- return (SyntaxTree)syntaxTreeProperty.GetValue (instance);
- }
- }
-
-
- readonly static MethodInfo isMemberDeclarationContextMethod;
-
- public bool IsMemberDeclarationContext (
- ISet<SyntaxKind> validModifiers = null,
- ISet<SyntaxKind> validTypeDeclarations = null,
- bool canBePartial = false,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (bool)isMemberDeclarationContextMethod.Invoke (instance, new object[] {
- validModifiers,
- validTypeDeclarations,
- canBePartial,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- readonly static MethodInfo isTypeDeclarationContextMethod;
-
- public bool IsTypeDeclarationContext (
- ISet<SyntaxKind> validModifiers = null,
- ISet<SyntaxKind> validTypeDeclarations = null,
- bool canBePartial = false,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (bool)isTypeDeclarationContextMethod.Invoke (instance, new object[] {
- validModifiers,
- validTypeDeclarations,
- canBePartial,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- readonly static PropertyInfo isPreProcessorDirectiveContextProperty;
-
- public bool IsPreProcessorDirectiveContext {
- get {
- return (bool)isPreProcessorDirectiveContextProperty.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isInNonUserCodeField;
-
- public bool IsInNonUserCode {
- get {
- return (bool)isInNonUserCodeField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isIsOrAsContextField;
-
- public bool IsIsOrAsContext {
- get {
- return (bool)isIsOrAsContextField.GetValue (instance);
- }
- }
-
- readonly static MethodInfo isTypeAttributeContextMethod;
-
- public bool IsTypeAttributeContext (CancellationToken cancellationToken)
- {
- try {
- return (bool)isTypeAttributeContextMethod.Invoke (instance, new object[] { cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- readonly static PropertyInfo isAnyExpressionContextProperty;
-
- public bool IsAnyExpressionContext {
- get {
- return (bool)isAnyExpressionContextProperty.GetValue (instance);
- }
- }
-
- readonly static PropertyInfo isStatementContextProperty;
-
- public bool IsStatementContext {
- get {
- return (bool)isStatementContextProperty.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isDefiniteCastTypeContextField;
-
- public bool IsDefiniteCastTypeContext {
- get {
- return (bool)isDefiniteCastTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isObjectCreationTypeContextField;
-
- public bool IsObjectCreationTypeContext {
- get {
- return (bool)isObjectCreationTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isGenericTypeArgumentContextField;
-
- public bool IsGenericTypeArgumentContext {
- get {
- return (bool)isGenericTypeArgumentContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isLocalVariableDeclarationContextField;
-
- public bool IsLocalVariableDeclarationContext {
- get {
- return (bool)isLocalVariableDeclarationContextField.GetValue (instance);
- }
- }
-
-
- readonly static FieldInfo isFixedVariableDeclarationContextField;
-
- public bool IsFixedVariableDeclarationContext {
- get {
- return (bool)isFixedVariableDeclarationContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isPossibleLambdaOrAnonymousMethodParameterTypeContextField;
-
- public bool IsPossibleLambdaOrAnonymousMethodParameterTypeContext {
- get {
- return (bool)isPossibleLambdaOrAnonymousMethodParameterTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isImplicitOrExplicitOperatorTypeContextField;
-
- public bool IsImplicitOrExplicitOperatorTypeContext {
- get {
- return (bool)isImplicitOrExplicitOperatorTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isPrimaryFunctionExpressionContextField;
-
- public bool IsPrimaryFunctionExpressionContext {
- get {
- return (bool)isPrimaryFunctionExpressionContextField.GetValue (instance);
- }
- }
-
-
- readonly static FieldInfo isCrefContextField;
-
- public bool IsCrefContext {
- get {
- return (bool)isCrefContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isDelegateReturnTypeContextField;
-
- public bool IsDelegateReturnTypeContext {
- get {
- return (bool)isDelegateReturnTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isEnumBaseListContextField;
-
- public bool IsEnumBaseListContext {
- get {
- return (bool)isEnumBaseListContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isConstantExpressionContextField;
-
- public bool IsConstantExpressionContext {
- get {
- return (bool)isConstantExpressionContextField.GetValue (instance);
- }
- }
-
- readonly static MethodInfo isMemberAttributeContextMethod;
- public bool IsMemberAttributeContext(ISet<SyntaxKind> validTypeDeclarations, CancellationToken cancellationToken)
- {
- try {
- return (bool)isMemberAttributeContextMethod.Invoke (instance, new object [] {
- validTypeDeclarations,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
-
- }
-
- readonly static FieldInfo precedingModifiersField;
-
- public ISet<SyntaxKind> PrecedingModifiers {
- get {
- return (ISet<SyntaxKind>)precedingModifiersField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isTypeOfExpressionContextField;
-
- public bool IsTypeOfExpressionContext {
- get {
- return (bool)isTypeOfExpressionContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo containingTypeOrEnumDeclarationField;
-
- public BaseTypeDeclarationSyntax ContainingTypeOrEnumDeclaration {
- get {
- return (BaseTypeDeclarationSyntax)containingTypeOrEnumDeclarationField.GetValue (instance);
- }
- }
- static readonly PropertyInfo isAttributeNameContextProperty;
-
- public bool IsAttributeNameContext {
- get {
- return (bool)isAttributeNameContextProperty.GetValue (instance);
- }
- }
-
- static readonly PropertyInfo isInQueryProperty;
- public bool IsInQuery {
- get {
- return (bool)isInQueryProperty.GetValue (instance);
- }
- }
-
-
- static CSharpSyntaxContext ()
- {
- typeInfoAbstractSyntaxContext = Type.GetType("Microsoft.CodeAnalysis.Shared.Extensions.ContextQuery.AbstractSyntaxContext" + ReflectionNamespaces.WorkspacesAsmName, true);
- typeInfoCSharpSyntaxContext = Type.GetType ("Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery.CSharpSyntaxContext" + ReflectionNamespaces.CSWorkspacesAsmName, true);
-
- createContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("CreateContext", BindingFlags.Static | BindingFlags.Public);
- leftTokenProperty = typeInfoAbstractSyntaxContext.GetProperty ("LeftToken");
- targetTokenProperty = typeInfoAbstractSyntaxContext.GetProperty ("TargetToken");
- isIsOrAsTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsIsOrAsTypeContext");
- isInstanceContextField = typeInfoCSharpSyntaxContext.GetField ("IsInstanceContext");
- isNonAttributeExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsNonAttributeExpressionContext");
- isPreProcessorKeywordContextField = typeInfoCSharpSyntaxContext.GetField ("IsPreProcessorKeywordContext");
- isPreProcessorExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsPreProcessorExpressionContext");
- containingTypeDeclarationField = typeInfoCSharpSyntaxContext.GetField ("ContainingTypeDeclaration");
- isGlobalStatementContextField = typeInfoCSharpSyntaxContext.GetField ("IsGlobalStatementContext");
- isParameterTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsParameterTypeContext");
- isMemberDeclarationContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("IsMemberDeclarationContext", BindingFlags.Instance | BindingFlags.Public);
- isTypeDeclarationContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("IsTypeDeclarationContext", BindingFlags.Instance | BindingFlags.Public);
- syntaxTreeProperty = typeInfoAbstractSyntaxContext.GetProperty ("SyntaxTree");
- isPreProcessorDirectiveContextProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsPreProcessorDirectiveContext");
- isInNonUserCodeField = typeInfoCSharpSyntaxContext.GetField ("IsInNonUserCode");
- isIsOrAsContextField = typeInfoCSharpSyntaxContext.GetField ("IsIsOrAsContext");
- isTypeAttributeContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("IsTypeAttributeContext", BindingFlags.Instance | BindingFlags.Public);
- isAnyExpressionContextProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsAnyExpressionContext");
- isStatementContextProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsStatementContext");
- isDefiniteCastTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsDefiniteCastTypeContext");
- isObjectCreationTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsObjectCreationTypeContext");
- isGenericTypeArgumentContextField = typeInfoCSharpSyntaxContext.GetField ("IsGenericTypeArgumentContext");
- isLocalVariableDeclarationContextField = typeInfoCSharpSyntaxContext.GetField ("IsLocalVariableDeclarationContext");
- isFixedVariableDeclarationContextField = typeInfoCSharpSyntaxContext.GetField ("IsFixedVariableDeclarationContext");
- isPossibleLambdaOrAnonymousMethodParameterTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsPossibleLambdaOrAnonymousMethodParameterTypeContext");
- isImplicitOrExplicitOperatorTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsImplicitOrExplicitOperatorTypeContext");
- isPrimaryFunctionExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsPrimaryFunctionExpressionContext");
- isCrefContextField = typeInfoCSharpSyntaxContext.GetField ("IsCrefContext");
- isDelegateReturnTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsDelegateReturnTypeContext");
- isEnumBaseListContextField = typeInfoCSharpSyntaxContext.GetField ("IsEnumBaseListContext");
- isConstantExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsConstantExpressionContext");
- isMemberAttributeContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("IsMemberAttributeContext", BindingFlags.Instance | BindingFlags.Public);
- precedingModifiersField = typeInfoCSharpSyntaxContext.GetField ("PrecedingModifiers");
- isTypeOfExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsTypeOfExpressionContext");
- containingTypeOrEnumDeclarationField = typeInfoCSharpSyntaxContext.GetField ("ContainingTypeOrEnumDeclaration");
-
- isAttributeNameContextProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsAttributeNameContext");
- isInQueryProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsInQuery");
- }
-
- public SemanticModel SemanticModel {
- get;
- private set;
- }
-
- public int Position {
- get;
- private set;
- }
-
- CSharpSyntaxContext (object instance)
- {
- this.instance = instance;
- }
-
- public static CSharpSyntaxContext CreateContext (Workspace workspace, SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- try {
- return new CSharpSyntaxContext (createContextMethod.Invoke (null, new object[] {
- workspace,
- semanticModel,
- position,
- cancellationToken
- })) {
- SemanticModel = semanticModel,
- Position = position
- };
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-
- class CSharpTypeInferenceService
- {
- readonly static Type typeInfo;
- readonly static MethodInfo inferTypesMethod;
- readonly static MethodInfo inferTypes2Method;
- readonly object instance;
-
- static CSharpTypeInferenceService ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CSharp.CSharpTypeInferenceService" + ReflectionNamespaces.CSWorkspacesAsmName, true);
-
- inferTypesMethod = typeInfo.GetMethod ("InferTypes", new[] {
- typeof(SemanticModel),
- typeof(int),
- typeof(CancellationToken)
- });
- inferTypes2Method = typeInfo.GetMethod ("InferTypes", new[] {
- typeof(SemanticModel),
- typeof(SyntaxNode),
- typeof(CancellationToken)
- });
- }
-
- public CSharpTypeInferenceService ()
- {
- instance = Activator.CreateInstance (typeInfo);
- }
-
- public IEnumerable<ITypeSymbol> InferTypes (SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- try {
- return (IEnumerable<ITypeSymbol>)inferTypesMethod.Invoke (instance, new object[] {
- semanticModel,
- position,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public IEnumerable<ITypeSymbol> InferTypes (SemanticModel semanticModel, SyntaxNode expression, CancellationToken cancellationToken)
- {
- try {
- return (IEnumerable<ITypeSymbol>)inferTypes2Method.Invoke (instance, new object[] {
- semanticModel,
- expression,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- public ITypeSymbol InferType(
- SemanticModel semanticModel,
- SyntaxNode expression,
- bool objectAsDefault,
- CancellationToken cancellationToken)
- {
- var types = InferTypes(semanticModel, expression, cancellationToken)
- .WhereNotNull();
-
- if (!types.Any())
- {
- return objectAsDefault ? semanticModel.Compilation.ObjectType : null;
- }
-
- return types.FirstOrDefault();
- }
-
-
- public INamedTypeSymbol InferDelegateType(
- SemanticModel semanticModel,
- SyntaxNode expression,
- CancellationToken cancellationToken)
- {
- var type = this.InferType(semanticModel, expression, objectAsDefault: false, cancellationToken: cancellationToken);
- return type.GetDelegateType(semanticModel.Compilation);
- }
-
-
- public ITypeSymbol InferType(
- SemanticModel semanticModel,
- int position,
- bool objectAsDefault,
- CancellationToken cancellationToken)
- {
- var types = this.InferTypes(semanticModel, position, cancellationToken)
- .WhereNotNull();
-
- if (!types.Any())
- {
- return objectAsDefault ? semanticModel.Compilation.ObjectType : null;
- }
-
- return types.FirstOrDefault();
- }
-
- }
-
- public class CaseCorrector
- {
- readonly static Type typeInfo;
- readonly static MethodInfo caseCorrectAsyncMethod;
-
- static CaseCorrector ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CaseCorrection.CaseCorrector" + ReflectionNamespaces.WorkspacesAsmName, true);
-
- Annotation = (SyntaxAnnotation)typeInfo.GetField ("Annotation", BindingFlags.Public | BindingFlags.Static).GetValue (null);
-
- caseCorrectAsyncMethod = typeInfo.GetMethod ("CaseCorrectAsync", new[] {
- typeof(Document),
- typeof(SyntaxAnnotation),
- typeof(CancellationToken)
- });
- }
-
- public static readonly SyntaxAnnotation Annotation;
-
- public static Task<Document> CaseCorrectAsync (Document document, SyntaxAnnotation annotation, CancellationToken cancellationToken)
- {
- try {
- return (Task<Document>)caseCorrectAsyncMethod.Invoke (null, new object[] { document, annotation, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-
-
-}
-*/ \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/CodeRefactoring.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/CodeRefactoring.cs
index 5efc6b7113..8d45e30e5b 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/CodeRefactoring.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/CodeRefactoring.cs
@@ -7,7 +7,7 @@ using Microsoft.CodeAnalysis.CodeActions;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.CodeRefactorings;
-namespace RefactoringEssentials
+namespace MonoDevelop.CSharp.CodeRefactorings
{
/// <summary>
/// Represents a set of transformations that can be applied to a piece of code.
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ExtractMethod/ExtractMethodCodeRefactoringProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ExtractMethod/ExtractMethodCodeRefactoringProvider.cs
deleted file mode 100644
index 3ce95e78c7..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ExtractMethod/ExtractMethodCodeRefactoringProvider.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using System;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.Text;
-using System.Threading;
-using ICSharpCode.NRefactory6.CSharp.ExtractMethod;
-using RefactoringEssentials;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace MonoDevelop.CSharp.CodeRefactorings.ExtractMethod
-{
- [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = PredefinedCodeRefactoringProviderNames.ExtractMethod), Shared]
- internal class ExtractMethodCodeRefactoringProvider : CodeRefactoringProvider
- {
- public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
- {
- // Don't bother if there isn't a selection
- var textSpan = context.Span;
- if (textSpan.IsEmpty)
- {
- return;
- }
- var document = context.Document;
- var cancellationToken = context.CancellationToken;
-
- var workspace = document.Project.Solution.Workspace;
- if (workspace.Kind == WorkspaceKind.MiscellaneousFiles)
- {
- return;
- }
- if (IdeApp.Workbench.ActiveDocument == null || IdeApp.Workbench.ActiveDocument.Editor == null)
- return;
- var activeInlineRenameSession = IdeApp.Workbench.ActiveDocument.Editor.EditMode != MonoDevelop.Ide.Editor.EditMode.Edit;
- if (activeInlineRenameSession)
- {
- return;
- }
- var model = await context.Document.GetSemanticModelAsync (context.CancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (context.CancellationToken))
- return;
-
- if (cancellationToken.IsCancellationRequested)
- {
- return;
- }
-
- var action = await GetCodeActionAsync(document, textSpan, cancellationToken: cancellationToken).ConfigureAwait(false);
- if (action == null)
- {
- return;
- }
-
- context.RegisterRefactoring(action.Item1);
- }
-
- static CSharpExtractMethodService service = new CSharpExtractMethodService ();
-
- private async Task<Tuple<CodeAction, string>> GetCodeActionAsync(
- Document document,
- TextSpan textSpan,
- CancellationToken cancellationToken)
- {
- var options = document.Project.Solution.Workspace.Options;
- try {
- var result = await service.ExtractMethodAsync(
- document,
- textSpan,
- options,
- cancellationToken).ConfigureAwait(false);
-
- if (result.Succeeded || result.SucceededWithSuggestion)
- {
- var description = options.GetOption(ExtractMethodOptions.AllowMovingDeclaration, document.Project.Language) ?
- GettextCatalog.GetString ("Extract Method + Local") : GettextCatalog.GetString ("Extract Method");
-
- var codeAction = new DocumentChangeAction(textSpan, DiagnosticSeverity.Info, description, (c) => AddRenameAnnotationAsync(result.Document, result.InvocationNameToken, c));
- var methodBlock = result.MethodDeclarationNode;
-
- return Tuple.Create<CodeAction, string>(codeAction, methodBlock.ToString());
- }
- } catch (Exception) {
- // currently the extract method refactoring crashes often. Ignore the roslyn issues for now.
- }
- return null;
- }
-
- private async Task<Document> AddRenameAnnotationAsync(Document document, SyntaxToken invocationNameToken, CancellationToken cancellationToken)
- {
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
-
- var finalRoot = root.ReplaceToken(
- invocationNameToken,
- invocationNameToken.WithAdditionalAnnotations(RenameAnnotation.Create()));
-
- return document.WithSyntaxRoot(finalRoot);
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.InitializerRewriter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.InitializerRewriter.cs
deleted file mode 100644
index 6ab7a54616..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.InitializerRewriter.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Microsoft.CodeAnalysis.CSharp;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace MonoDevelop.CSharp.CodeRefactorings.InlineTemporary
-{
- internal partial class InlineTemporaryCodeRefactoringProvider
- {
- /// <summary>
- /// This class handles rewriting initializer expressions that refer to the variable
- /// being initialized into a simpler form. For example, in "int x = x = 1", we want to
- /// get just "1" back as the initializer.
- /// </summary>
- private class InitializerRewriter : CSharpSyntaxRewriter
- {
- private readonly SemanticModel _semanticModel;
- private readonly ILocalSymbol _localSymbol;
-
- private InitializerRewriter(ExpressionSyntax initializer, ILocalSymbol localSymbol, SemanticModel semanticModel)
- {
- _semanticModel = semanticModel;
- _localSymbol = localSymbol;
- }
-
- private bool IsReference(SimpleNameSyntax name)
- {
- if (name.Identifier.ValueText != _localSymbol.Name)
- {
- return false;
- }
-
- var symbol = _semanticModel.GetSymbolInfo(name).Symbol;
- return symbol != null
- && symbol.Equals(_localSymbol);
- }
-
- public override SyntaxNode VisitAssignmentExpression(AssignmentExpressionSyntax node)
- {
- // Note - leave this as SyntaxNode for now, we might have already re-written it
- var newNode = base.VisitAssignmentExpression(node);
-
- if (newNode.Kind() == SyntaxKind.SimpleAssignmentExpression)
- {
- // It's okay to just look at the text, since we're explicitly looking for an
- // identifier standing alone, and we know we're in a local's initializer.
- // The text can only bind to the initializer.
- var assignment = (AssignmentExpressionSyntax)newNode;
- var name = assignment.Left.Kind() == SyntaxKind.IdentifierName
- ? (IdentifierNameSyntax)assignment.Left
- : null;
-
- if (name != null && IsReference(name))
- {
- return assignment.Right;
- }
- }
-
- return newNode;
- }
-
- public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node)
- {
- if (IsReference(node))
- {
- var assignmentExpression = node.Parent as AssignmentExpressionSyntax;
- if (assignmentExpression != null)
- {
- if (assignmentExpression.IsCompoundAssignExpression() &&
- assignmentExpression.Left == node)
- {
- return node.Update(node.Identifier.WithAdditionalAnnotations(CreateConflictAnnotation()));
- }
- }
- }
-
- return base.VisitIdentifierName(node);
- }
-
- public override SyntaxNode VisitParenthesizedExpression(ParenthesizedExpressionSyntax node)
- {
- var newNode = base.VisitParenthesizedExpression(node);
-
- if (node != newNode && newNode.Kind() == SyntaxKind.ParenthesizedExpression)
- {
- return newNode.WithAdditionalAnnotations(Simplifier.Annotation);
- }
-
- return newNode;
- }
-
- public static ExpressionSyntax Visit(ExpressionSyntax initializer, ILocalSymbol local, SemanticModel semanticModel)
- {
- var simplifier = new InitializerRewriter(initializer, local, semanticModel);
- return (ExpressionSyntax)simplifier.Visit(initializer);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.ReferenceRewriter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.ReferenceRewriter.cs
deleted file mode 100644
index 16d712e672..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.ReferenceRewriter.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace MonoDevelop.CSharp.CodeRefactorings.InlineTemporary
-{
- internal partial class InlineTemporaryCodeRefactoringProvider
- {
- private class ReferenceRewriter : CSharpSyntaxRewriter
- {
- private readonly SemanticModel _semanticModel;
- private readonly ILocalSymbol _localSymbol;
- private readonly VariableDeclaratorSyntax _variableDeclarator;
- private readonly ExpressionSyntax _expressionToInline;
- private readonly CancellationToken _cancellationToken;
-
- private ReferenceRewriter(
- SemanticModel semanticModel,
- VariableDeclaratorSyntax variableDeclarator,
- ExpressionSyntax expressionToInline,
- CancellationToken cancellationToken)
- {
- _semanticModel = semanticModel;
- _localSymbol = (ILocalSymbol)semanticModel.GetDeclaredSymbol(variableDeclarator, cancellationToken);
- _variableDeclarator = variableDeclarator;
- _expressionToInline = expressionToInline;
- _cancellationToken = cancellationToken;
- }
-
- private bool IsReference(SimpleNameSyntax name)
- {
- if (name.Identifier.ValueText != _variableDeclarator.Identifier.ValueText)
- {
- return false;
- }
-
- var symbol = _semanticModel.GetSymbolInfo(name).Symbol;
- return symbol != null
- && symbol.Equals(_localSymbol);
- }
-
- public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node)
- {
- _cancellationToken.ThrowIfCancellationRequested();
-
- if (IsReference(node))
- {
- if (HasConflict(node, _variableDeclarator))
- {
- return node.Update(node.Identifier.WithAdditionalAnnotations(CreateConflictAnnotation()));
- }
-
- return _expressionToInline
- .Parenthesize()
- .WithAdditionalAnnotations(Formatter.Annotation, Simplifier.Annotation);
- }
-
- return base.VisitIdentifierName(node);
- }
-
- public override SyntaxNode VisitAnonymousObjectMemberDeclarator(AnonymousObjectMemberDeclaratorSyntax node)
- {
- var nameEquals = node.NameEquals;
- var expression = node.Expression;
- var identifier = expression as IdentifierNameSyntax;
-
- if (nameEquals != null || identifier == null || !IsReference(identifier) || HasConflict(identifier, _variableDeclarator))
- {
- return base.VisitAnonymousObjectMemberDeclarator(node);
- }
-
- // Special case inlining into anonymous types to ensure that we keep property names:
- //
- // E.g.
- // int x = 42;
- // var a = new { x; };
- //
- // Should become:
- // var a = new { x = 42; };
- nameEquals = SyntaxFactory.NameEquals(identifier);
- expression = (ExpressionSyntax)this.Visit(expression);
- return node.Update(nameEquals, expression).WithAdditionalAnnotations(Simplifier.Annotation, Formatter.Annotation);
- }
-
- public static SyntaxNode Visit(
- SemanticModel semanticModel,
- SyntaxNode scope,
- VariableDeclaratorSyntax variableDeclarator,
- ExpressionSyntax expressionToInline,
- CancellationToken cancellationToken)
- {
- var rewriter = new ReferenceRewriter(semanticModel, variableDeclarator, expressionToInline, cancellationToken);
- return rewriter.Visit(scope);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs
deleted file mode 100644
index a9491b4c87..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs
+++ /dev/null
@@ -1,575 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.CSharp;
-using RefactoringEssentials;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.CSharp.CodeRefactorings.InlineTemporary
-{
- [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = PredefinedCodeRefactoringProviderNames.InlineTemporary), Shared]
- internal partial class InlineTemporaryCodeRefactoringProvider : CodeRefactoringProvider
- {
- internal static readonly SyntaxAnnotation DefinitionAnnotation = new SyntaxAnnotation();
- internal static readonly SyntaxAnnotation ReferenceAnnotation = new SyntaxAnnotation();
- internal static readonly SyntaxAnnotation InitializerAnnotation = new SyntaxAnnotation();
- internal static readonly SyntaxAnnotation ExpressionToInlineAnnotation = new SyntaxAnnotation();
-
- public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
- {
- var document = context.Document;
- var textSpan = context.Span;
- var cancellationToken = context.CancellationToken;
-
- if (document.Project.Solution.Workspace.Kind == WorkspaceKind.MiscellaneousFiles)
- {
- return;
- }
- var model = await document.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (cancellationToken))
- return;
- var root = await document.GetCSharpSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- if (textSpan.Start >= root.FullSpan.Length)
- return;
- var token = root.FindToken(textSpan.Start);
-
- if (!token.Span.Contains(textSpan))
- {
- return;
- }
-
- var node = token.Parent;
-
- if (!node.IsKind(SyntaxKind.VariableDeclarator) ||
- !node.IsParentKind(SyntaxKind.VariableDeclaration) ||
- !node.Parent.IsParentKind(SyntaxKind.LocalDeclarationStatement))
- {
- return;
- }
-
- var variableDeclarator = (VariableDeclaratorSyntax)node;
- var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent;
- var localDeclarationStatement = (LocalDeclarationStatementSyntax)variableDeclaration.Parent;
-
- if (variableDeclarator.Identifier != token ||
- variableDeclarator.Initializer == null ||
- variableDeclarator.Initializer.Value.IsMissing ||
- variableDeclarator.Initializer.Value.IsKind(SyntaxKind.StackAllocArrayCreationExpression))
- {
- return;
- }
-
- if (localDeclarationStatement.ContainsDiagnostics)
- {
- return;
- }
-
- var references = await GetReferencesAsync(document, variableDeclarator, cancellationToken).ConfigureAwait(false);
- if (!references.Any())
- {
- return;
- }
-
- context.RegisterRefactoring(
- new DocumentChangeAction(node.Span, DiagnosticSeverity.Info,
- GettextCatalog.GetString ("Inline temporary variable"),
- (c) => this.InlineTemporaryAsync(document, variableDeclarator, c)));
- }
-
- private async Task<IEnumerable<ReferenceLocation>> GetReferencesAsync(
- Document document,
- VariableDeclaratorSyntax variableDeclarator,
- CancellationToken cancellationToken)
- {
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var local = semanticModel.GetDeclaredSymbol(variableDeclarator, cancellationToken);
-
- if (local != null)
- {
- var findReferencesResult = await SymbolFinder.FindReferencesAsync(local, document.Project.Solution, cancellationToken).ConfigureAwait(false);
- var locations = findReferencesResult.Single(r => r.Definition == local).Locations;
- if (!locations.Any(loc => semanticModel.SyntaxTree.OverlapsHiddenPosition(loc.Location.SourceSpan, cancellationToken)))
- {
- return locations;
- }
- }
-
- return SpecializedCollections.EmptyEnumerable<ReferenceLocation>();
- }
-
- private static bool HasConflict(IdentifierNameSyntax identifier, VariableDeclaratorSyntax variableDeclarator)
- {
- // TODO: Check for more conflict types.
- if (identifier.SpanStart < variableDeclarator.SpanStart)
- {
- return true;
- }
-
- var identifierNode = identifier
- .Ancestors()
- .TakeWhile(n => n.Kind() == SyntaxKind.ParenthesizedExpression || n.Kind() == SyntaxKind.CastExpression)
- .LastOrDefault();
-
- if (identifierNode == null)
- {
- identifierNode = identifier;
- }
-
- if (identifierNode.IsParentKind(SyntaxKind.Argument))
- {
- var argument = (ArgumentSyntax)identifierNode.Parent;
- if (argument.RefOrOutKeyword.Kind() != SyntaxKind.None)
- {
- return true;
- }
- }
- else if (identifierNode.Parent.IsKind(
- SyntaxKind.PreDecrementExpression,
- SyntaxKind.PreIncrementExpression,
- SyntaxKind.PostDecrementExpression,
- SyntaxKind.PostIncrementExpression,
- SyntaxKind.AddressOfExpression))
- {
- return true;
- }
- else if (identifierNode.Parent is AssignmentExpressionSyntax)
- {
- var binaryExpression = (AssignmentExpressionSyntax)identifierNode.Parent;
- if (binaryExpression.Left == identifierNode)
- {
- return true;
- }
- }
-
- return false;
- }
-
- private static SyntaxAnnotation CreateConflictAnnotation()
- {
- return ConflictAnnotation.Create(GettextCatalog.GetString ("Conflict(s) detected."));
- }
-
- private async Task<Document> InlineTemporaryAsync(Document document, VariableDeclaratorSyntax declarator, CancellationToken cancellationToken)
- {
- var workspace = document.Project.Solution.Workspace;
-
- // Annotate the variable declarator so that we can get back to it later.
- var updatedDocument = await document.ReplaceNodeAsync(declarator, declarator.WithAdditionalAnnotations(DefinitionAnnotation), cancellationToken).ConfigureAwait(false);
- var semanticModel = await updatedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
-
- var variableDeclarator = await FindDeclaratorAsync(updatedDocument, cancellationToken).ConfigureAwait(false);
-
- // Create the expression that we're actually going to inline.
- var expressionToInline = await CreateExpressionToInlineAsync(variableDeclarator, updatedDocument, cancellationToken).ConfigureAwait(false);
-
- // Collect the identifier names for each reference.
- var local = (ILocalSymbol)semanticModel.GetDeclaredSymbol(variableDeclarator, cancellationToken);
- var symbolRefs = await SymbolFinder.FindReferencesAsync(local, updatedDocument.Project.Solution, cancellationToken).ConfigureAwait(false);
- var references = symbolRefs.Single(r => r.Definition == local).Locations;
- var syntaxRoot = await updatedDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
-
- // Collect the topmost parenting expression for each reference.
- var nonConflictingIdentifierNodes = references
- .Select(loc => (IdentifierNameSyntax)syntaxRoot.FindToken(loc.Location.SourceSpan.Start).Parent)
- .Where(ident => !HasConflict(ident, variableDeclarator));
-
- // Add referenceAnnotions to identifier nodes being replaced.
- updatedDocument = await updatedDocument.ReplaceNodesAsync(
- nonConflictingIdentifierNodes,
- (o, n) => n.WithAdditionalAnnotations(ReferenceAnnotation),
- cancellationToken).ConfigureAwait(false);
-
- semanticModel = await updatedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- variableDeclarator = await FindDeclaratorAsync(updatedDocument, cancellationToken).ConfigureAwait(false);
-
- // Get the annotated reference nodes.
- nonConflictingIdentifierNodes = await FindReferenceAnnotatedNodesAsync(updatedDocument, cancellationToken).ConfigureAwait(false);
-
- var topmostParentingExpressions = nonConflictingIdentifierNodes
- .Select(GetTopMostParentingExpression)
- .Distinct();
-
- var originalInitializerSymbolInfo = semanticModel.GetSymbolInfo(variableDeclarator.Initializer.Value, cancellationToken);
-
- // Make each topmost parenting statement or Equals Clause Expressions semantically explicit.
- updatedDocument = await updatedDocument.ReplaceNodesAsync(topmostParentingExpressions, (o, n) => Simplifier.Expand(n, semanticModel, workspace, cancellationToken: cancellationToken), cancellationToken).ConfigureAwait(false);
- semanticModel = await updatedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var semanticModelBeforeInline = semanticModel;
-
- variableDeclarator = await FindDeclaratorAsync(updatedDocument, cancellationToken).ConfigureAwait(false);
- var scope = GetScope(variableDeclarator);
-
- var newScope = ReferenceRewriter.Visit(semanticModel, scope, variableDeclarator, expressionToInline, cancellationToken);
-
- updatedDocument = await updatedDocument.ReplaceNodeAsync(scope, newScope, cancellationToken).ConfigureAwait(false);
- semanticModel = await updatedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
-
- variableDeclarator = await FindDeclaratorAsync(updatedDocument, cancellationToken).ConfigureAwait(false);
- newScope = GetScope(variableDeclarator);
- var conflicts = newScope.GetAnnotatedNodesAndTokens(ConflictAnnotation.Kind);
- var declaratorConflicts = variableDeclarator.GetAnnotatedNodesAndTokens(ConflictAnnotation.Kind);
-
- // Note that we only remove the local declaration if there weren't any conflicts,
- // unless those conflicts are inside the local declaration.
- if (conflicts.Count() == declaratorConflicts.Count())
- {
- // Certain semantic conflicts can be detected only after the reference rewriter has inlined the expression
- var newDocument = await DetectSemanticConflicts(updatedDocument,
- semanticModel,
- semanticModelBeforeInline,
- originalInitializerSymbolInfo,
- cancellationToken).ConfigureAwait(false);
-
- if (updatedDocument == newDocument)
- {
- // No semantic conflicts, we can remove the definition.
- updatedDocument = await updatedDocument.ReplaceNodeAsync(newScope, RemoveDeclaratorFromScope(variableDeclarator, newScope), cancellationToken).ConfigureAwait(false);
- }
- else
- {
- // There were some semantic conflicts, don't remove the definition.
- updatedDocument = newDocument;
- }
- }
-
- return updatedDocument;
- }
-
- private static async Task<VariableDeclaratorSyntax> FindDeclaratorAsync(Document document, CancellationToken cancellationToken)
- {
- return await FindNodeWithAnnotationAsync<VariableDeclaratorSyntax>(document, DefinitionAnnotation, cancellationToken).ConfigureAwait(false);
- }
-
- private static async Task<ExpressionSyntax> FindInitializerAsync(Document document, CancellationToken cancellationToken)
- {
- return await FindNodeWithAnnotationAsync<ExpressionSyntax>(document, InitializerAnnotation, cancellationToken).ConfigureAwait(false);
- }
-
- private static async Task<T> FindNodeWithAnnotationAsync<T>(Document document, SyntaxAnnotation annotation, CancellationToken cancellationToken)
- where T : SyntaxNode
- {
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- return root
- .GetAnnotatedNodesAndTokens(annotation)
- .Single()
- .AsNode() as T;
- }
-
- private static async Task<IEnumerable<IdentifierNameSyntax>> FindReferenceAnnotatedNodesAsync(Document document, CancellationToken cancellationToken)
- {
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- return FindReferenceAnnotatedNodes(root);
- }
-
- private static IEnumerable<IdentifierNameSyntax> FindReferenceAnnotatedNodes(SyntaxNode root)
- {
- var annotatedNodesAndTokens = root.GetAnnotatedNodesAndTokens(ReferenceAnnotation);
- foreach (var nodeOrToken in annotatedNodesAndTokens)
- {
- if (nodeOrToken.IsNode && nodeOrToken.AsNode().IsKind(SyntaxKind.IdentifierName))
- {
- yield return (IdentifierNameSyntax)nodeOrToken.AsNode();
- }
- }
- }
-
- private SyntaxNode GetScope(VariableDeclaratorSyntax variableDeclarator)
- {
- var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent;
- var localDeclaration = (LocalDeclarationStatementSyntax)variableDeclaration.Parent;
- var scope = localDeclaration.Parent;
-
- while (scope.IsKind(SyntaxKind.LabeledStatement))
- {
- scope = scope.Parent;
- }
-
- var parentExpressions = scope.AncestorsAndSelf().OfType<ExpressionSyntax>();
- if (parentExpressions.Any())
- {
- scope = parentExpressions.LastOrDefault().Parent;
- }
-
- return scope;
- }
-
- private VariableDeclaratorSyntax FindDeclarator(SyntaxNode node)
- {
- var annotatedNodesOrTokens = node.GetAnnotatedNodesAndTokens(DefinitionAnnotation).ToList();
-
- return (VariableDeclaratorSyntax)annotatedNodesOrTokens.First().AsNode();
- }
-
- private SyntaxTriviaList GetTriviaToPreserve(SyntaxTriviaList syntaxTriviaList)
- {
- return ShouldPreserve(syntaxTriviaList) ? syntaxTriviaList : default(SyntaxTriviaList);
- }
-
- private static bool ShouldPreserve(SyntaxTriviaList trivia)
- {
- return trivia.Any(
- t => t.Kind() == SyntaxKind.SingleLineCommentTrivia ||
- t.Kind() == SyntaxKind.MultiLineCommentTrivia ||
- t.IsDirective);
- }
-
- private SyntaxNode RemoveDeclaratorFromVariableList(VariableDeclaratorSyntax variableDeclarator, VariableDeclarationSyntax variableDeclaration)
- {
- Debug.Assert(variableDeclaration.Variables.Count > 1);
- Debug.Assert(variableDeclaration.Variables.Contains(variableDeclarator));
-
- var localDeclaration = (LocalDeclarationStatementSyntax)variableDeclaration.Parent;
- var scope = GetScope(variableDeclarator);
-
- var newLocalDeclaration = localDeclaration.RemoveNode(variableDeclarator, SyntaxRemoveOptions.KeepNoTrivia)
- .WithAdditionalAnnotations(Formatter.Annotation);
-
- return scope.ReplaceNode(localDeclaration, newLocalDeclaration);
- }
-
- private SyntaxNode RemoveDeclaratorFromScope(VariableDeclaratorSyntax variableDeclarator, SyntaxNode scope)
- {
- var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent;
-
- // If there is more than one variable declarator, remove this one from the variable declaration.
- if (variableDeclaration.Variables.Count > 1)
- {
- return RemoveDeclaratorFromVariableList(variableDeclarator, variableDeclaration);
- }
-
- var localDeclaration = (LocalDeclarationStatementSyntax)variableDeclaration.Parent;
-
- // There's only one variable declarator, so we'll remove the local declaration
- // statement entirely. This means that we'll concatenate the leading and trailing
- // trivia of this declaration and move it to the next statement.
- var leadingTrivia = localDeclaration
- .GetLeadingTrivia()
- .Reverse()
- .SkipWhile(t => t.MatchesKind(SyntaxKind.WhitespaceTrivia))
- .Reverse()
- .ToSyntaxTriviaList();
-
- var trailingTrivia = localDeclaration
- .GetTrailingTrivia()
- .SkipWhile(t => t.MatchesKind(SyntaxKind.WhitespaceTrivia, SyntaxKind.EndOfLineTrivia))
- .ToSyntaxTriviaList();
-
- var newLeadingTrivia = leadingTrivia.Concat(trailingTrivia);
-
- var nextToken = localDeclaration.GetLastToken().GetNextTokenOrEndOfFile();
- var newNextToken = nextToken.WithPrependedLeadingTrivia(newLeadingTrivia)
- .WithAdditionalAnnotations(Formatter.Annotation);
-
- var newScope = scope.ReplaceToken(nextToken, newNextToken);
-
- var newLocalDeclaration = (LocalDeclarationStatementSyntax)FindDeclarator(newScope).Parent.Parent;
-
- // If the local is parented by a label statement, we can't remove this statement. Instead,
- // we'll replace the local declaration with an empty expression statement.
- if (newLocalDeclaration.IsParentKind(SyntaxKind.LabeledStatement))
- {
- var labeledStatement = (LabeledStatementSyntax)newLocalDeclaration.Parent;
- var newLabeledStatement = labeledStatement.ReplaceNode(newLocalDeclaration, SyntaxFactory.ParseStatement(""));
-
- return newScope.ReplaceNode(labeledStatement, newLabeledStatement);
- }
-
- return newScope.RemoveNode(newLocalDeclaration, SyntaxRemoveOptions.KeepNoTrivia);
- }
-
- private ExpressionSyntax SkipRedundantExteriorParentheses(ExpressionSyntax expression)
- {
- while (expression.IsKind(SyntaxKind.ParenthesizedExpression))
- {
- var parenthesized = (ParenthesizedExpressionSyntax)expression;
- if (parenthesized.Expression == null ||
- parenthesized.Expression.IsMissing)
- {
- break;
- }
-
- if (parenthesized.Expression.IsKind(SyntaxKind.ParenthesizedExpression) ||
- parenthesized.Expression.IsKind(SyntaxKind.IdentifierName))
- {
- expression = parenthesized.Expression;
- }
- else
- {
- break;
- }
- }
-
- return expression;
- }
-
- public static IEnumerable<SyntaxTrivia> SkipInitialWhitespace(SyntaxTriviaList triviaList)
- {
- return triviaList.SkipWhile(t => t.Kind() == SyntaxKind.WhitespaceTrivia);
- }
-
- private async Task<ExpressionSyntax> CreateExpressionToInlineAsync(
- VariableDeclaratorSyntax variableDeclarator,
- Document document,
- CancellationToken cancellationToken)
- {
- var updatedDocument = document;
-
- var expression = SkipRedundantExteriorParentheses(variableDeclarator.Initializer.Value);
- var semanticModel = await updatedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var localSymbol = (ILocalSymbol)semanticModel.GetDeclaredSymbol(variableDeclarator, cancellationToken);
- var newExpression = InitializerRewriter.Visit(expression, localSymbol, semanticModel);
-
- // If this is an array initializer, we need to transform it into an array creation
- // expression for inlining.
- if (newExpression.Kind() == SyntaxKind.ArrayInitializerExpression)
- {
- var arrayType = (ArrayTypeSyntax)localSymbol.Type.GenerateTypeSyntax();
- var arrayInitializer = (InitializerExpressionSyntax)newExpression;
-
- // Add any non-whitespace trailing trivia from the equals clause to the type.
- var equalsToken = variableDeclarator.Initializer.EqualsToken;
- if (equalsToken.HasTrailingTrivia)
- {
- var trailingTrivia = SkipInitialWhitespace(equalsToken.TrailingTrivia);
- if (trailingTrivia.Any())
- {
- arrayType = arrayType.WithTrailingTrivia(trailingTrivia);
- }
- }
-
- newExpression = SyntaxFactory.ArrayCreationExpression(arrayType, arrayInitializer);
- }
-
- newExpression = newExpression.WithAdditionalAnnotations(InitializerAnnotation);
-
- updatedDocument = await updatedDocument.ReplaceNodeAsync(variableDeclarator.Initializer.Value, newExpression, cancellationToken).ConfigureAwait(false);
- semanticModel = await updatedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- newExpression = await FindInitializerAsync(updatedDocument, cancellationToken).ConfigureAwait(false);
- var newVariableDeclarator = await FindDeclaratorAsync(updatedDocument, cancellationToken).ConfigureAwait(false);
- localSymbol = (ILocalSymbol)semanticModel.GetDeclaredSymbol(newVariableDeclarator, cancellationToken);
-
- var explicitCastExpression = newExpression.CastIfPossible(localSymbol.Type, newVariableDeclarator.SpanStart, semanticModel);
-
- if (explicitCastExpression != newExpression)
- {
- updatedDocument = await updatedDocument.ReplaceNodeAsync(newExpression, explicitCastExpression, cancellationToken).ConfigureAwait(false);
- semanticModel = await updatedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- newVariableDeclarator = await FindDeclaratorAsync(updatedDocument, cancellationToken).ConfigureAwait(false);
- }
-
- // Now that the variable declarator is normalized, make its initializer
- // value semantically explicit.
- newExpression = await Simplifier.ExpandAsync(newVariableDeclarator.Initializer.Value, updatedDocument, cancellationToken: cancellationToken).ConfigureAwait(false);
- return newExpression.WithAdditionalAnnotations(ExpressionToInlineAnnotation);
- }
-
- private static SyntaxNode GetTopMostParentingExpression(ExpressionSyntax expression)
- {
- return expression.AncestorsAndSelf().OfType<ExpressionSyntax>().Last();
- }
-
- private static async Task<Document> DetectSemanticConflicts(
- Document inlinedDocument,
- SemanticModel newSemanticModelForInlinedDocument,
- SemanticModel semanticModelBeforeInline,
- SymbolInfo originalInitializerSymbolInfo,
- CancellationToken cancellationToken)
- {
- // In this method we detect if inlining the expression introduced the following semantic change:
- // The symbol info associated with any of the inlined expressions does not match the symbol info for original initializer expression prior to inline.
-
- // If any semantic changes were introduced by inlining, we update the document with conflict annotations.
- // Otherwise we return the given inlined document without any changes.
-
- var syntaxRootBeforeInline = await semanticModelBeforeInline.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
-
- // Get all the identifier nodes which were replaced with inlined expression.
- var originalIdentifierNodes = FindReferenceAnnotatedNodes(syntaxRootBeforeInline).ToList ();
-
- if (!originalIdentifierNodes.Any())
- {
- // No conflicts
- return inlinedDocument;
- }
-
- // Get all the inlined expression nodes.
- var syntaxRootAfterInline = await inlinedDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var inlinedExprNodes = syntaxRootAfterInline.GetAnnotatedNodesAndTokens(ExpressionToInlineAnnotation).ToList ();
- Debug.Assert(originalIdentifierNodes.Count() == inlinedExprNodes.Count());
-
- Dictionary<SyntaxNode, SyntaxNode> replacementNodesWithChangedSemantics = null;
- using (var originalNodesEnum = originalIdentifierNodes.GetEnumerator())
- {
- using (var inlinedNodesOrTokensEnum = inlinedExprNodes.GetEnumerator())
- {
- while (originalNodesEnum.MoveNext())
- {
- inlinedNodesOrTokensEnum.MoveNext();
- var originalNode = originalNodesEnum.Current;
-
- // expressionToInline is Parenthesized prior to replacement, so get the parenting parenthesized expression.
- var inlinedNode = (ExpressionSyntax)inlinedNodesOrTokensEnum.Current.Parent;
- Debug.Assert(inlinedNode.IsKind(SyntaxKind.ParenthesizedExpression));
-
- // inlinedNode is the expanded form of the actual initializer expression in the original document.
- // We have annotated the inner initializer with a special syntax annotation "InitializerAnnotation".
- // Get this annotated node and compute the symbol info for this node in the inlined document.
- var innerInitializerInInlineNodeorToken = inlinedNode.GetAnnotatedNodesAndTokens(InitializerAnnotation).First();
-
- ExpressionSyntax innerInitializerInInlineNode = (ExpressionSyntax)(innerInitializerInInlineNodeorToken.IsNode ?
- innerInitializerInInlineNodeorToken.AsNode() :
- innerInitializerInInlineNodeorToken.AsToken().Parent);
- var newInializerSymbolInfo = newSemanticModelForInlinedDocument.GetSymbolInfo(innerInitializerInInlineNode, cancellationToken);
-
- // Verification: The symbol info associated with any of the inlined expressions does not match the symbol info for original initializer expression prior to inline.
- if (!SpeculationAnalyzer.SymbolInfosAreCompatible(originalInitializerSymbolInfo, newInializerSymbolInfo, performEquivalenceCheck: true))
- {
- newInializerSymbolInfo = newSemanticModelForInlinedDocument.GetSymbolInfo(inlinedNode, cancellationToken);
- if (!SpeculationAnalyzer.SymbolInfosAreCompatible(originalInitializerSymbolInfo, newInializerSymbolInfo, performEquivalenceCheck: true))
- {
- if (replacementNodesWithChangedSemantics == null)
- {
- replacementNodesWithChangedSemantics = new Dictionary<SyntaxNode, SyntaxNode>();
- }
-
- replacementNodesWithChangedSemantics.Add(inlinedNode, originalNode);
- }
- }
- }
- }
- }
-
- if (replacementNodesWithChangedSemantics == null)
- {
- // No conflicts.
- return inlinedDocument;
- }
-
- // Replace the conflicting inlined nodes with the original nodes annotated with conflict annotation.
- Func<SyntaxNode, SyntaxNode, SyntaxNode> conflictAnnotationAdder =
- (SyntaxNode oldNode, SyntaxNode newNode) =>
- newNode.WithAdditionalAnnotations(ConflictAnnotation.Create(GettextCatalog.GetString ("Conflict(s) detected.")));
-
- return await inlinedDocument.ReplaceNodesAsync(replacementNodesWithChangedSemantics.Keys, conflictAnnotationAdder, cancellationToken).ConfigureAwait(false);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/IntroduceVariable/IntroduceVariableCodeRefactoringProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/IntroduceVariable/IntroduceVariableCodeRefactoringProvider.cs
deleted file mode 100644
index 59f1b83585..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/IntroduceVariable/IntroduceVariableCodeRefactoringProvider.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable;
-using ICSharpCode.NRefactory6.CSharp;
-using RefactoringEssentials;
-
-namespace MonoDevelop.CSharp.CodeRefactorings.IntroduceVariable
-{
- [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = PredefinedCodeRefactoringProviderNames.IntroduceVariable), Shared]
- class IntroduceVariableCodeRefactoringProvider : CodeRefactoringProvider
- {
- static readonly CSharpIntroduceVariableService service = new CSharpIntroduceVariableService ();
-
- public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
- {
- var document = context.Document;
- var textSpan = context.Span;
- var cancellationToken = context.CancellationToken;
- if (document.Project.Solution.Workspace.Kind == WorkspaceKind.MiscellaneousFiles)
- {
- return;
- }
- var model = await document.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (cancellationToken))
- return;
- var result = await service.IntroduceVariableAsync(document, textSpan, cancellationToken).ConfigureAwait(false);
-
- if (!result.ContainsChanges)
- {
- return;
- }
-
- var actions = result.GetCodeRefactoring(cancellationToken).Actions;
- context.RegisterRefactorings(actions);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/TypeGuessing.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/TypeGuessing.cs
index bc53ea931c..7657d1e30b 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/TypeGuessing.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/TypeGuessing.cs
@@ -27,6 +27,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.CSharp;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/UsingRefactorings/SortImportsCodeRefactoringProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/UsingRefactorings/SortImportsCodeRefactoringProvider.cs
index 388386c4b4..b1670c44cb 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/UsingRefactorings/SortImportsCodeRefactoringProvider.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/UsingRefactorings/SortImportsCodeRefactoringProvider.cs
@@ -23,94 +23,96 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+using System;
using System.Composition;
+using System.Linq;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable;
using ICSharpCode.NRefactory6.CSharp;
-using RefactoringEssentials;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CodeActions;
+using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Core;
-using System;
-using System.Threading;
using MonoDevelop.CSharp.Refactoring;
-using System.Linq;
namespace MonoDevelop.CSharp.CodeRefactorings.IntroduceVariable
{
- [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = "Sort Imports Code Action Provider"), Shared]
+ [ExportCodeRefactoringProvider (LanguageNames.CSharp, Name = "Sort Imports Code Action Provider"), Shared]
class SortImportsCodeRefactoringProvider : CodeRefactoringProvider
{
- public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
+ public override async Task ComputeRefactoringsAsync (CodeRefactoringContext context)
{
var document = context.Document;
var textSpan = context.Span;
var cancellationToken = context.CancellationToken;
- if (document.Project.Solution.Workspace.Kind == WorkspaceKind.MiscellaneousFiles)
- {
+
+ if (document.Project.Solution.Workspace.Kind == WorkspaceKind.MiscellaneousFiles) {
return;
}
- var model = await document.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (cancellationToken))
+
+ if (document.IsGeneratedCode()) {
return;
- var root = await document.GetCSharpSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
+ }
+
+ var model = await document.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
+ var root = await document.GetCSharpSyntaxRootAsync (cancellationToken).ConfigureAwait (false);
if (textSpan.Start >= root.FullSpan.Length)
return;
- var token = root.FindToken(textSpan.Start);
+ var token = root.FindToken (textSpan.Start);
- if (!token.Span.Contains(textSpan))
- {
+ if (!token.Span.Contains (textSpan)) {
return;
}
- var node = token.Parent.AncestorsAndSelf ().FirstOrDefault (n => n.IsKind(SyntaxKind.UsingDirective) || n.IsParentKind(SyntaxKind.ExternAliasDirective));
- if (node == null)
- {
+ var node = token.Parent.AncestorsAndSelf ().FirstOrDefault (n => n.IsKind (SyntaxKind.UsingDirective) || n.IsParentKind (SyntaxKind.ExternAliasDirective));
+ if (node == null) {
return;
}
- context.RegisterRefactoring(
- new DocumentChangeAction(node.Span, DiagnosticSeverity.Info,
- GettextCatalog.GetString ("Sort usings"),
- (t) => OrganizeImportsCommandHandler.SortUsingsAsync(document, t)));
+ context.RegisterRefactoring (
+ new CodeAction.DocumentChangeAction (
+ GettextCatalog.GetString ("Sort usings"),
+ (t) => OrganizeImportsCommandHandler.SortUsingsAsync (document, t)));
}
}
- [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = "Sort And Remove Imports Code Action Provider"), Shared]
+ [ExportCodeRefactoringProvider (LanguageNames.CSharp, Name = "Sort And Remove Imports Code Action Provider"), Shared]
class SortAndRemoveImportsCodeRefactoringProvider : CodeRefactoringProvider
{
- public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
+ public override async Task ComputeRefactoringsAsync (CodeRefactoringContext context)
{
var document = context.Document;
var textSpan = context.Span;
var cancellationToken = context.CancellationToken;
- if (document.Project.Solution.Workspace.Kind == WorkspaceKind.MiscellaneousFiles)
- {
+
+ if (document.Project.Solution.Workspace.Kind == WorkspaceKind.MiscellaneousFiles) {
return;
}
- var model = await document.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
- if (model.IsFromGeneratedCode (cancellationToken))
+
+ if (document.IsGeneratedCode ()) {
return;
- var root = await document.GetCSharpSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
+ }
+
+ var model = await document.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
+ var root = await document.GetCSharpSyntaxRootAsync (cancellationToken).ConfigureAwait (false);
if (textSpan.Start >= root.FullSpan.Length)
return;
- var token = root.FindToken(textSpan.Start);
- if (!token.Span.Contains(textSpan))
- {
+ var token = root.FindToken (textSpan.Start);
+ if (!token.Span.Contains (textSpan)) {
return;
}
- var node = token.Parent.AncestorsAndSelf ().FirstOrDefault (n => n.IsKind(SyntaxKind.UsingDirective) || n.IsParentKind(SyntaxKind.ExternAliasDirective));
- if (node == null)
- {
+ var node = token.Parent.AncestorsAndSelf ().FirstOrDefault (n => n.IsKind (SyntaxKind.UsingDirective) || n.IsParentKind (SyntaxKind.ExternAliasDirective));
+ if (node == null) {
return;
}
- context.RegisterRefactoring(
- new DocumentChangeAction(node.Span, DiagnosticSeverity.Info,
- GettextCatalog.GetString ("Sort and remove usings"),
- (t) => SortAndRemoveImportsCommandHandler.SortAndRemoveAsync(document, t)));
+ context.RegisterRefactoring (
+ new CodeAction.DocumentChangeAction (
+ GettextCatalog.GetString ("Sort and remove usings"),
+ (t) => SortAndRemoveImportsCommandHandler.SortAndRemoveAsync (document, t)));
}
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs
index ac2a8a1d90..d2b2cb44c3 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs
@@ -25,41 +25,36 @@
// THE SOFTWARE.
using System;
-using System.Linq;
-using MonoDevelop.Core;
using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.ExceptionServices;
+using System.Threading;
+using System.Threading.Tasks;
-using MonoDevelop.Debugger;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.CodeGeneration;
-using MonoDevelop.Ide.Gui.Content;
-using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.Components.Commands;
-
-using MonoDevelop.CSharp.Formatting;
-
+using ICSharpCode.NRefactory6.CSharp;
using ICSharpCode.NRefactory6.CSharp.Completion;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.Ide.Editor.Extension;
-using MonoDevelop.Ide.Editor;
-using System.Threading.Tasks;
-using System.Threading;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
-using System.Xml;
-using ICSharpCode.NRefactory6.CSharp;
-using MonoDevelop.Refactoring;
-using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using MonoDevelop.Ide;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
+using Microsoft.CodeAnalysis.Text;
+
using Mono.Addins;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
+using MonoDevelop.CodeGeneration;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Core;
+using MonoDevelop.CSharp.Formatting;
+using MonoDevelop.Debugger;
+using MonoDevelop.Ide;
+using MonoDevelop.Ide.CodeCompletion;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.Ide.Editor.Extension;
using MonoDevelop.Ide.TypeSystem;
-using RefactoringEssentials;
-using MonoDevelop.CSharp.Diagnostics.InconsistentNaming;
-using RefactoringEssentials.CSharp.Diagnostics;
+using MonoDevelop.Refactoring;
namespace MonoDevelop.CSharp.Completion
{
@@ -157,7 +152,6 @@ namespace MonoDevelop.CSharp.Completion
snippets = newSnippets;
return Task.FromResult ((IEnumerable<CompletionData>)newSnippets);
};
- NameProposalService.Replace (new NameConventionRule.NamePropsalStrategy ());
} catch (Exception e) {
LoggingService.LogError ("Error while loading c# completion text editor extension.", e);
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs
index 46f5f07534..f555b81179 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs
@@ -88,8 +88,8 @@ namespace MonoDevelop.CSharp.Completion
var parsedDocument = document.UpdateParseDocument ().Result;
var semanticModel = parsedDocument.GetAst<SemanticModel> ();
- var declaringType = semanticModel.GetEnclosingSymbol<INamedTypeSymbol> (position, default(CancellationToken));
- var enclosingSymbol = semanticModel.GetEnclosingSymbol<ISymbol> (position, default(CancellationToken));
+ var declaringType = semanticModel.GetEnclosingSymbol (position, default(CancellationToken)) as ITypeSymbol;
+ var enclosingSymbol = semanticModel.GetEnclosingSymbol (position, default(CancellationToken));
var insertionPoints = InsertionPointService.GetInsertionPoints (
document.Editor,
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCodeCompletionFactory.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCodeCompletionFactory.cs
index 6b29f44542..536f59fa8f 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCodeCompletionFactory.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCodeCompletionFactory.cs
@@ -75,16 +75,13 @@ namespace MonoDevelop.CSharp.Completion
{
static SignatureMarkupCreator creator = new SignatureMarkupCreator (null, 0);
- SyntaxKind kind;
-
protected readonly RoslynCodeCompletionFactory factory;
protected CSharpCompletionTextEditorExtension ext { get { return factory?.Ext; } }
- public KeywordCompletionData (ICompletionDataKeyHandler keyHandler, RoslynCodeCompletionFactory factory, SyntaxKind kind) : base (keyHandler)
+ public KeywordCompletionData (ICompletionDataKeyHandler keyHandler, RoslynCodeCompletionFactory factory) : base (keyHandler)
{
- this.kind = kind;
this.factory = factory;
}
@@ -109,7 +106,7 @@ namespace MonoDevelop.CSharp.Completion
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, MonoDevelop.Ide.Editor.Extension.KeyDescriptor descriptor)
{
- if (kind == SyntaxKind.SizeOfKeyword || kind == SyntaxKind.NameOfKeyword || kind == SyntaxKind.TypeOfKeyword) {
+ if (this.CompletionText == "sizeof" || this.CompletionText == "nameof" || this.CompletionText == "typeof") {
string partialWord = GetCurrentWord (window, descriptor);
int skipChars = 0;
bool runCompletionCompletionCommand = false;
@@ -157,9 +154,9 @@ namespace MonoDevelop.CSharp.Completion
}
}
- CompletionData ICompletionDataFactory.CreateKeywordCompletion (ICompletionDataKeyHandler keyHandler, string data, SyntaxKind syntaxKind)
+ CompletionData ICompletionDataFactory.CreateKeywordCompletion (ICompletionDataKeyHandler keyHandler, string data)
{
- return new KeywordCompletionData (keyHandler, this, syntaxKind) {
+ return new KeywordCompletionData (keyHandler, this) {
CompletionText = data,
DisplayText = data,
Icon = "md-keyword"
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCompletionCategory.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCompletionCategory.cs
index fda1e6b5dd..4a4d5fc062 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCompletionCategory.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynCompletionCategory.cs
@@ -23,13 +23,14 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using MonoDevelop.Ide.CodeCompletion;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp;
+
using System.Linq;
-using MonoDevelop.Ide.TypeSystem;
using ICSharpCode.NRefactory6.CSharp.Completion;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using MonoDevelop.Ide.CodeCompletion;
+using MonoDevelop.Ide.TypeSystem;
namespace MonoDevelop.CSharp.Completion
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/DiagnosticCustomTags.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/DiagnosticCustomTags.cs
deleted file mode 100644
index d05d91c55f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/DiagnosticCustomTags.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// DiagnosticCustomTags.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis;
-
-namespace MonoDevelop.CSharp.Diagnostics
-{
- static class DiagnosticCustomTags
- {
- public static readonly string[] Unnecessary = { WellKnownDiagnosticTags.Unnecessary, WellKnownDiagnosticTags.Telemetry };
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/IDEDiagnosticIds.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/IDEDiagnosticIds.cs
index 7d067e38d2..604bba97b7 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/IDEDiagnosticIds.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/IDEDiagnosticIds.cs
@@ -29,15 +29,7 @@ namespace MonoDevelop.CSharp.Diagnostics
{
static class IDEDiagnosticIds
{
- public const string SimplifyNamesDiagnosticId = "IDE0001";
- public const string SimplifyMemberAccessDiagnosticId = "IDE0002";
- public const string SimplifyThisOrMeDiagnosticId = "IDE0003";
- public const string RemoveUnnecessaryCastDiagnosticId = "IDE0004";
- public const string RemoveUnnecessaryImportsDiagnosticId = "IDE0005";
-
public const string MonoTODODiagnosticDiagnosticId = "XS0001";
-
-
}
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/MonoNameConventionPolicy.xml b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/MonoNameConventionPolicy.xml
deleted file mode 100644
index 4643473284..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/MonoNameConventionPolicy.xml
+++ /dev/null
@@ -1,179 +0,0 @@
-<NameConventionPolicy>
- <Rules>
- <NamingRule>
- <Name>Namespaces</Name>
- <AffectedEntity>Namespace</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Types</Name>
- <AffectedEntity>Class, Struct, Enum, Delegate</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Interfaces</Name>
- <RequiredPrefixes>
- <String>I</String>
- </RequiredPrefixes>
- <AffectedEntity>Interface</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Attributes</Name>
- <RequiredSuffixes>
- <String>Attribute</String>
- </RequiredSuffixes>
- <AffectedEntity>CustomAttributes</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Event Arguments</Name>
- <RequiredSuffixes>
- <String>EventArgs</String>
- </RequiredSuffixes>
- <AffectedEntity>CustomEventArgs</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Exceptions</Name>
- <RequiredSuffixes>
- <String>Exception</String>
- </RequiredSuffixes>
- <AffectedEntity>CustomExceptions</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Methods</Name>
- <AffectedEntity>Methods</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Static Readonly Fields</Name>
- <AffectedEntity>ReadonlyField</AffectedEntity>
- <VisibilityMask>Internal, Protected, Public</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>False</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Fields (Non Private)</Name>
- <AffectedEntity>Field</AffectedEntity>
- <VisibilityMask>Internal, Protected, Public</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>ReadOnly Fields (Non Private)</Name>
- <AffectedEntity>ReadonlyField</AffectedEntity>
- <VisibilityMask>Internal, Protected, Public</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>False</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Fields (Private)</Name>
- <AllowedPrefixes>
- <String>_</String>
- <String>m_</String>
- </AllowedPrefixes>
- <AffectedEntity>Field, ReadonlyField</AffectedEntity>
- <VisibilityMask>Private</VisibilityMask>
- <NamingStyle>CamelCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>False</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Static Fields (Private)</Name>
- <AffectedEntity>Field</AffectedEntity>
- <VisibilityMask>Private</VisibilityMask>
- <NamingStyle>CamelCase</NamingStyle>
- <IncludeInstanceMembers>False</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>ReadOnly Fields (Private)</Name>
- <AllowedPrefixes>
- <String>_</String>
- <String>m_</String>
- </AllowedPrefixes>
- <AffectedEntity>ReadonlyField</AffectedEntity>
- <VisibilityMask>Private</VisibilityMask>
- <NamingStyle>CamelCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>False</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Constant Fields</Name>
- <AffectedEntity>ConstantField</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Properties</Name>
- <AffectedEntity>Property</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Events</Name>
- <AffectedEntity>Event</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Enum Members</Name>
- <AffectedEntity>EnumMember</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Parameters</Name>
- <AffectedEntity>Parameter</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>CamelCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- <NamingRule>
- <Name>Type Parameters</Name>
- <RequiredPrefixes>
- <String>T</String>
- </RequiredPrefixes>
- <AffectedEntity>TypeParameter</AffectedEntity>
- <VisibilityMask>VisibilityMask</VisibilityMask>
- <NamingStyle>PascalCase</NamingStyle>
- <IncludeInstanceMembers>True</IncludeInstanceMembers>
- <IncludeStaticEntities>True</IncludeStaticEntities>
- </NamingRule>
- </Rules>
-</NameConventionPolicy> \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionEditRuleDialog.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionEditRuleDialog.cs
deleted file mode 100644
index f522cda640..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionEditRuleDialog.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-//
-// NamingConventionEditRuleDialog.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Linq;
-using Gtk;
-using System.Collections.Generic;
-using MonoDevelop.Core;
-using RefactoringEssentials.CSharp.Diagnostics;
-
-namespace MonoDevelop.CSharp.Diagnostics.InconsistentNaming
-{
- partial class NameConventionEditRuleDialog : Gtk.Dialog
- {
- static readonly Dictionary<AffectedEntity, string> EntityName = new Dictionary<AffectedEntity, string> ();
- static readonly Dictionary<Modifiers, string> AccessibilityName = new Dictionary<Modifiers, string> ();
-
- static NameConventionEditRuleDialog ()
- {
- EntityName [AffectedEntity.Namespace] = GettextCatalog.GetString ("Namespaces");
-
- EntityName [AffectedEntity.Class] = GettextCatalog.GetString ("Classes");
- EntityName [AffectedEntity.Struct] = GettextCatalog.GetString ("Structs");
- EntityName [AffectedEntity.Enum] = GettextCatalog.GetString ("Enums");
- EntityName [AffectedEntity.Interface] = GettextCatalog.GetString ("Interfaces");
- EntityName [AffectedEntity.Delegate] = GettextCatalog.GetString ("Delegates");
-
- EntityName [AffectedEntity.CustomAttributes] = GettextCatalog.GetString ("Attributes");
- EntityName [AffectedEntity.CustomEventArgs] = GettextCatalog.GetString ("Event Arguments");
- EntityName [AffectedEntity.CustomExceptions] = GettextCatalog.GetString ("Exceptions");
-
- EntityName [AffectedEntity.Property] = GettextCatalog.GetString ("Properties");
- EntityName [AffectedEntity.AsyncMethod] = GettextCatalog.GetString ("Async methods");
- EntityName [AffectedEntity.Method] = GettextCatalog.GetString ("Methods");
- EntityName [AffectedEntity.Field] = GettextCatalog.GetString ("Fields");
- EntityName [AffectedEntity.ConstantField] = GettextCatalog.GetString ("Constant fields");
- EntityName [AffectedEntity.ReadonlyField] = GettextCatalog.GetString ("Readonly fields");
- EntityName [AffectedEntity.Event] = GettextCatalog.GetString ("Events");
- EntityName [AffectedEntity.EnumMember] = GettextCatalog.GetString ("Enum Members");
-
- EntityName [AffectedEntity.Parameter] = GettextCatalog.GetString ("Parameters");
- EntityName [AffectedEntity.TypeParameter] = GettextCatalog.GetString ("Type Parameters");
-
- // Unit test special case
- EntityName [AffectedEntity.TestType] = GettextCatalog.GetString ("Test Types");
- EntityName [AffectedEntity.TestMethod] = GettextCatalog.GetString ("Test Methods");
-
- // private entities
- EntityName [AffectedEntity.LambdaParameter] = GettextCatalog.GetString ("Lambda Parameters");
- EntityName [AffectedEntity.LocalVariable] = GettextCatalog.GetString ("Local Variables");
- EntityName [AffectedEntity.LocalConstant] = GettextCatalog.GetString ("Local Constants");
- EntityName [AffectedEntity.Label] = GettextCatalog.GetString ("Labels");
-
- AccessibilityName [Modifiers.Public] = GettextCatalog.GetString ("Public");
- AccessibilityName [Modifiers.Private] = GettextCatalog.GetString ("Private");
- AccessibilityName [Modifiers.Internal] = GettextCatalog.GetString ("Internal");
- AccessibilityName [Modifiers.Protected] = GettextCatalog.GetString ("Protected");
- }
-
- NameConventionRule rule;
-
- ListStore entityStore = new ListStore (typeof(string), typeof(AffectedEntity), typeof(bool));
- ListStore accessibiltyStore = new ListStore (typeof(string), typeof(Modifiers), typeof(bool));
-
- public NameConventionEditRuleDialog (NameConventionRule rule)
- {
- if (rule == null)
- throw new System.ArgumentNullException ("rule");
- this.rule = rule;
- this.Build ();
-
- var ct1 = new CellRendererToggle ();
- ct1.Toggled += delegate(object o, Gtk.ToggledArgs args) {
- TreeIter iter;
- if (!entityStore.GetIterFromString (out iter, args.Path))
- return;
- entityStore.SetValue (iter, 2, !(bool)entityStore.GetValue (iter, 2));
- };
- treeviewEntities.AppendColumn ("IsChecked", ct1, "active", 2);
- treeviewEntities.AppendColumn ("Entity", new CellRendererText (), "text", 0);
- treeviewEntities.Model = entityStore;
- treeviewEntities.SearchColumn = -1; // disable the interactive search
-
- var ct2 = new CellRendererToggle ();
- ct2.Toggled += delegate(object o, Gtk.ToggledArgs args) {
- TreeIter iter;
- if (!accessibiltyStore.GetIterFromString (out iter, args.Path))
- return;
- accessibiltyStore.SetValue (iter, 2, !(bool)accessibiltyStore.GetValue (iter, 2));
- };
- treeviewAccessibility.AppendColumn ("IsChecked", ct2, "active", 2);
- treeviewAccessibility.AppendColumn ("Entity", new CellRendererText (), "text", 0);
- treeviewAccessibility.Model = accessibiltyStore;
- treeviewAccessibility.SearchColumn = -1; // disable the interactive search
- buttonOk.Clicked += (sender, e) => Apply ();
-
- FillDialog ();
- }
-
- public void FillDialog ()
- {
- entryRuleName.Text = rule.Name ?? "";
- if (rule.RequiredPrefixes != null)
- entryPrefix.Text = rule.RequiredPrefixes.FirstOrDefault ();
- if (rule.AllowedPrefixes != null)
- entryPrefixAllowed.Text = string.Join (", ", rule.AllowedPrefixes);
- if (rule.RequiredSuffixes != null)
- entrySuffix.Text = rule.RequiredSuffixes.FirstOrDefault ();
- styleComboBox.AppendText ("PascalCase");
- styleComboBox.AppendText ("CamelCase");
- styleComboBox.AppendText ("ALLUPPER");
- styleComboBox.AppendText ("alllower");
- styleComboBox.AppendText ("Firstupper");
- styleComboBox.AppendText ("PascalCase_underscoreTolerant");
- styleComboBox.AppendText ("PascalCase_UnderscoreTolerant");
- styleComboBox.AppendText ("CamelCase_underscoreTolerant");
- styleComboBox.AppendText ("CamelCase_UnderscoreTolerant");
-
- styleComboBox.Active = (int)rule.NamingStyle - 1;
-
- foreach (AffectedEntity ae in Enum.GetValues (typeof (AffectedEntity))) {
- if (!EntityName.ContainsKey (ae))
- continue;
- entityStore.AppendValues (EntityName [ae], ae, rule.AffectedEntity.HasFlag (ae));
- }
-
- foreach (Modifiers mod in Enum.GetValues (typeof (Modifiers))) {
- if (!AccessibilityName.ContainsKey (mod))
- continue;
- accessibiltyStore.AppendValues (AccessibilityName [mod], mod, rule.VisibilityMask.HasFlag (mod));
- }
-
- checkbuttonStatic.Active = rule.IncludeStaticEntities;
- checkbuttonInstanceMembers.Active = rule.IncludeInstanceMembers;
-
- }
-
- public void Apply ()
- {
- rule.Name = entryRuleName.Text;
- rule.NamingStyle = (NamingStyle)(1 + styleComboBox.Active);
-
- var prefix = entryPrefix.Text.Trim ();
- if (string.IsNullOrEmpty (prefix)) {
- rule.RequiredPrefixes = null;
- } else {
- rule.RequiredPrefixes = new [] { prefix };
- }
-
- var allowedPrefix = entryPrefixAllowed.Text.Trim ();
- if (string.IsNullOrEmpty (allowedPrefix)) {
- rule.AllowedPrefixes = null;
- } else {
- rule.AllowedPrefixes = allowedPrefix.Split (',', ';').Select (s => s.Trim ()).ToArray ();
- }
-
- var suffix = entrySuffix.Text.Trim ();
- if (string.IsNullOrEmpty (suffix)) {
- rule.RequiredSuffixes = null;
- } else {
- rule.RequiredSuffixes = new [] { suffix };
- }
-
- var ae = AffectedEntity.None;
- TreeIter iter;
- if (entityStore.GetIterFirst (out iter)) {
- do {
- var entity = (AffectedEntity)entityStore.GetValue (iter, 1);
- var include = (bool)entityStore.GetValue (iter, 2);
- if (include)
- ae |= entity;
- } while (entityStore.IterNext (ref iter));
- }
- rule.AffectedEntity = ae;
-
- var mod = Modifiers.None;
- if (accessibiltyStore.GetIterFirst (out iter)) {
- do {
- var entity = (Modifiers)accessibiltyStore.GetValue (iter, 1);
- var include = (bool)accessibiltyStore.GetValue (iter, 2);
- if (include)
- mod |= entity;
- } while (accessibiltyStore.IterNext (ref iter));
- }
- rule.VisibilityMask = mod;
- rule.IncludeStaticEntities = checkbuttonStatic.Active;
- rule.IncludeInstanceMembers = checkbuttonInstanceMembers.Active;
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPanel.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPanel.cs
deleted file mode 100644
index b71b916792..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPanel.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// NamingConventionPanel.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2012 Xamarin <http://xamarin.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using MonoDevelop.Ide.Gui.Dialogs;
-using MonoDevelop.Components;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Editor;
-
-namespace MonoDevelop.CSharp.Diagnostics.InconsistentNaming
-{
- class NameConventionPanel : PolicyOptionsPanel<NameConventionPolicy>
- {
- NameConventionPanelWidget panel;
-
- static NameConventionPanel ()
- {
- // ensure that custom text editor shemes are loaded.
- TextEditorDisplayBinding.InitSourceEditor ();
- }
-
- protected override string PolicyTitleWithMnemonic {
- get {
- return GettextCatalog.GetString ("_Naming Style");
- }
- }
-
- public override Control CreatePanelWidget ()
- {
- panel = new NameConventionPanelWidget ();
- panel.PolicyChanged += delegate {
- UpdateSelectedNamedPolicy ();
- };
- return panel;
- }
-
- protected override void LoadFrom (NameConventionPolicy policy)
- {
- panel.Policy = policy.Clone ();
- }
-
- protected override NameConventionPolicy GetPolicy ()
- {
- // return cloned policy
- panel.ApplyChanges ();
- return panel.Policy;
- }
- }
-
-}
-
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPanelWidget.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPanelWidget.cs
deleted file mode 100644
index fcf325cf47..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPanelWidget.cs
+++ /dev/null
@@ -1,163 +0,0 @@
-//
-// NamingConventionPanelWidget.cs
-//
-// Author:
-// Mike Krüger <mkrueger@novell.com>
-//
-// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Gtk;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-using System.Collections.Generic;
-
-namespace MonoDevelop.CSharp.Diagnostics.InconsistentNaming
-{
- [System.ComponentModel.ToolboxItem(true)]
- partial class NameConventionPanelWidget : Gtk.Bin
- {
- TreeStore treeStore = new TreeStore (typeof(NameConventionRule));
- NameConventionPolicy policy;
-
- internal NameConventionPolicy Policy {
- get {
- return policy;
- }
- set {
- policy = value;
- FillRules (policy.Rules);
- }
- }
-
- public NameConventionPanelWidget ()
- {
- Build ();
- Show ();
-
- var ct1 = new CellRendererText ();
- var col1 = treeviewConventions.AppendColumn (GettextCatalog.GetString ("Rule"), ct1);
- col1.Expand = true;
- col1.SetCellDataFunc (ct1, NameConventionRuleNameDataFunc);
-
-
- var ct2 = new CellRendererText ();
- var col2 = treeviewConventions.AppendColumn (GettextCatalog.GetString ("Example"), ct2);
- col2.Expand = true;
- col2.SetCellDataFunc (ct2, NameConventionRulePreviewDataFunc);
-
- treeviewConventions.Model = treeStore;
- treeviewConventions.SearchColumn = -1; // disable the interactive search
- treeviewConventions.Selection.Changed += HandleSelectionChanged;
- treeviewConventions.RowActivated += (o, args) => EditSelectedEntry ();
- buttonEdit.Clicked += (o, s) => EditSelectedEntry ();
- buttonRemove.Clicked += (o, s) => RemoveSelectedEntry ();
- buttonAdd.Clicked += (o, s) => AddEntry ();
-
- HandleSelectionChanged (null, null);
- }
-
- static void NameConventionRuleNameDataFunc (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
- {
- var rule = (NameConventionRule)model.GetValue (iter, 0);
- ((CellRendererText)cell).Text = rule.Name;
- }
-
- static void NameConventionRulePreviewDataFunc (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
- {
- var rule = (NameConventionRule)model.GetValue (iter, 0);
- ((CellRendererText)cell).Text = rule.GetPreview ();
- }
-
- void HandleSelectionChanged (object sender, EventArgs e)
- {
- TreeIter iter;
- buttonEdit.Sensitive = treeviewConventions.Selection.GetSelected (out iter);
- }
-
- public void ApplyChanges ()
- {
- var rules = new List<NameConventionRule> ();
- TreeIter iter;
- if (treeStore.GetIterFirst (out iter)) {
- do {
- var rule = (NameConventionRule)treeStore.GetValue (iter, 0);
- rules.Add (rule);
- } while (treeStore.IterNext (ref iter));
- }
- policy.Rules = rules.ToArray ();
- if (IdeApp.Workbench.ActiveDocument != null)
- IdeApp.Workbench.ActiveDocument.UpdateParseDocument ();
- }
-
- void AddEntry ()
- {
- var newRule = new NameConventionRule ();
- newRule.Name = "New Rule";
- using (var diag = new NameConventionEditRuleDialog (newRule)) {
- var result = MessageService.ShowCustomDialog (diag);
- if (result == (int)ResponseType.Ok)
- treeStore.AppendValues (newRule);
- OnPolicyChanged (EventArgs.Empty);
- }
- }
-
- void EditSelectedEntry ()
- {
- TreeIter iter;
- if (!treeviewConventions.Selection.GetSelected (out iter))
- return;
- var rule = treeStore.GetValue (iter, 0) as NameConventionRule;
- using (var diag = new NameConventionEditRuleDialog (rule)) {
- int result = MessageService.ShowCustomDialog (diag);
- treeviewConventions.QueueResize ();
- if (result == (int)Gtk.ResponseType.Ok)
- OnPolicyChanged (EventArgs.Empty);
- }
- }
-
- void RemoveSelectedEntry ()
- {
- TreeIter iter;
- if (!treeviewConventions.Selection.GetSelected (out iter))
- return;
- treeStore.Remove (ref iter);
- OnPolicyChanged (EventArgs.Empty);
- }
-
- void FillRules (IEnumerable<NameConventionRule> rules)
- {
- treeStore.Clear ();
- foreach (var rule in rules) {
- treeStore.AppendValues (rule);
- }
- }
-
- protected virtual void OnPolicyChanged (EventArgs e)
- {
- var handler = PolicyChanged;
- if (handler != null)
- handler (this, e);
- }
-
- public event EventHandler PolicyChanged;
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPolicy.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPolicy.cs
deleted file mode 100644
index bf2805536f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionPolicy.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// NamingConventions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@novell.com>
-//
-// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using MonoDevelop.Projects.Policies;
-using MonoDevelop.Core.Serialization;
-using RefactoringEssentials.CSharp.Diagnostics;
-
-namespace MonoDevelop.CSharp.Diagnostics.InconsistentNaming
-{
- [PolicyType ("Naming Conventions Policy")]
- class NameConventionPolicy : IEquatable<NameConventionPolicy>
- {
- NameConventionRule[] rules = new NameConventionRule[0];
-
- [ItemProperty]
- public NameConventionRule[] Rules {
- get { return rules; }
- set { rules = value; }
- }
-
- public NameConventionPolicy Clone ()
- {
- var result = new NameConventionPolicy ();
- result.rules = new List<NameConventionRule> (rules.Select (r => r.Clone ())).ToArray ();
- return result;
- }
-
- public NameConventionPolicy ()
- {
- rules = new List<NameConventionRule> (DefaultRules.GetFdgRules ().Select (r => new NameConventionRule (r))).ToArray ();
- }
-
- class NamingConventionService : RefactoringEssentials.CSharp.Diagnostics.NamingConventionService
- {
- NameConventionPolicy policy;
- NamingRule[] rules = null;
- public override IEnumerable<RefactoringEssentials.CSharp.Diagnostics.NamingRule> Rules {
- get {
- if (rules == null) {
- this.rules = policy.Rules.Select (r => r.GetNRefactoryRule ()).ToArray ();
- }
- return rules;
- }
- }
-
- public NamingConventionService (NameConventionPolicy policy)
- {
- this.policy = policy;
- }
-
- }
-
- public RefactoringEssentials.CSharp.Diagnostics.NamingConventionService CreateNRefactoryService ()
- {
- return new NamingConventionService (this);
- }
-
- #region IEquatable implementation
- public bool Equals (NameConventionPolicy other)
- {
- if (Rules.Length != other.Rules.Length)
- return false;
- for (int i = 0; i < rules.Length; i++) {
- if (!rules [i].Equals (other.Rules[i]))
- return false;
- }
- return true;
- }
- #endregion
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionRule.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionRule.cs
deleted file mode 100644
index d9f24284bc..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/InconsistentNaming/NameConventionRule.cs
+++ /dev/null
@@ -1,587 +0,0 @@
-//
-// NamingRule.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Text;
-using MonoDevelop.Projects.Policies;
-using MonoDevelop.Core.Serialization;
-using RefactoringEssentials.CSharp.Diagnostics;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.Ide;
-using System.Globalization;
-using System.Collections.Generic;
-using System.Linq;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace MonoDevelop.CSharp.Diagnostics.InconsistentNaming
-{
- [DataItem ("NamingRule")]
- sealed class NameConventionRule
- {
- NamingRule wrappedRule = new NamingRule (AffectedEntity.None);
-
- [ItemProperty]
- public string Name {
- get { return wrappedRule.Name; }
- set { wrappedRule.Name = value;}
- }
-
- [ItemProperty]
- public string[] RequiredPrefixes {
- get { return wrappedRule.RequiredPrefixes; }
- set { wrappedRule.RequiredPrefixes = value;}
- }
-
- [ItemProperty]
- public string[] AllowedPrefixes {
- get { return wrappedRule.AllowedPrefixes; }
- set { wrappedRule.AllowedPrefixes = value;}
- }
-
- [ItemProperty]
- public string[] RequiredSuffixes {
- get { return wrappedRule.RequiredSuffixes; }
- set { wrappedRule.RequiredSuffixes = value;}
- }
-
- [ItemProperty]
- public string[] ForbiddenPrefixes {
- get { return wrappedRule.ForbiddenPrefixes; }
- set { wrappedRule.ForbiddenPrefixes = value;}
- }
-
- [ItemProperty]
- public string[] ForbiddenSuffixes {
- get { return wrappedRule.ForbiddenSuffixes; }
- set { wrappedRule.ForbiddenSuffixes = value;}
- }
-
- [ItemProperty]
- public AffectedEntity AffectedEntity {
- get { return wrappedRule.AffectedEntity; }
- set { wrappedRule.AffectedEntity = value;}
- }
-
- [ItemProperty]
- public Modifiers VisibilityMask {
- get { return wrappedRule.VisibilityMask; }
- set { wrappedRule.VisibilityMask = value;}
- }
-
- [ItemProperty]
- public NamingStyle NamingStyle {
- get { return wrappedRule.NamingStyle; }
- set { wrappedRule.NamingStyle = value;}
- }
-
- [ItemProperty]
- public bool IncludeInstanceMembers {
- get { return wrappedRule.IncludeInstanceMembers; }
- set { wrappedRule.IncludeInstanceMembers = value;}
- }
-
- [ItemProperty]
- public bool IncludeStaticEntities {
- get { return wrappedRule.IncludeStaticEntities; }
- set { wrappedRule.IncludeStaticEntities = value;}
- }
-
- internal NameConventionRule (NamingRule wrappedRule)
- {
- this.wrappedRule = wrappedRule;
- }
-
- public NameConventionRule ()
- {
- }
-
- public NameConventionRule Clone ()
- {
- return new NameConventionRule () {
- wrappedRule = this.wrappedRule.Clone ()
- };
- }
-
- public string GetPreview ()
- {
- return wrappedRule.GetPreview ();
- }
-
- internal NamingRule GetNRefactoryRule ()
- {
- return wrappedRule;
- }
-
- public string CorrectName (string name)
- {
- string prefix = null, suffix = null;
- string realName = name;
- string id = name;
-
- // check prefix
- if (AllowedPrefixes != null && AllowedPrefixes.Length > 0) {
- var allowedPrefix = AllowedPrefixes.FirstOrDefault (p => id.StartsWith (p, StringComparison.Ordinal));
- if (allowedPrefix != null) {
- prefix = allowedPrefix;
- id = id.Substring (allowedPrefix.Length);
- }
- }
-
- if (prefix == null && RequiredPrefixes != null && RequiredPrefixes.Length > 0) {
- var requiredPrefix = RequiredPrefixes.FirstOrDefault (p => id.StartsWith (p, StringComparison.Ordinal));
- if (requiredPrefix == null) {
- prefix = RequiredPrefixes[0];
- } else {
- prefix = requiredPrefix;
- id = id.Substring (requiredPrefix.Length);
- }
- }
-
- if (prefix == null && ForbiddenPrefixes != null && ForbiddenPrefixes.Length > 0) {
- var forbiddenPrefix = ForbiddenPrefixes.FirstOrDefault (p => id.StartsWith (p, StringComparison.Ordinal));
- if (forbiddenPrefix != null) {
- id = id.Substring (forbiddenPrefix.Length);
- }
- }
-
- // check suffix
- if (RequiredSuffixes != null && RequiredSuffixes.Length > 0) {
- var requiredSuffix = RequiredSuffixes.FirstOrDefault (s => id.EndsWith (s, StringComparison.Ordinal));
- if (requiredSuffix == null) {
- suffix = RequiredSuffixes[0];
- } else {
- suffix = requiredSuffix;
- id = id.Substring (0, id.Length - requiredSuffix.Length);
- }
- }
-
- if (suffix == null && ForbiddenSuffixes != null && ForbiddenSuffixes.Length > 0) {
- var forbiddenSuffix = ForbiddenSuffixes.FirstOrDefault (p => id.EndsWith (p, StringComparison.Ordinal));
- if (forbiddenSuffix != null) {
- id = id.Substring (0, id.Length - forbiddenSuffix.Length);
- }
- }
- Console.WriteLine ("style: " + NamingStyle);
- switch (NamingStyle) {
- case NamingStyle.AllLower:
- if (id.Any (ch => char.IsLetter (ch) && char.IsUpper (ch))) {
- realName = LowerCaseIdentifier (WordParser.BreakWords (id));
- } else {
- realName = id;
- }
- break;
- case NamingStyle.AllUpper:
- if (id.Any (ch => char.IsLetter (ch) && char.IsLower (ch))) {
- realName = UpperCaseIdentifier (WordParser.BreakWords (id));
- } else {
- realName = id;
- }
- break;
-
- case NamingStyle.CamelCase:
- if (id.Length > 0 && !char.IsLower (id [0])) {
- } else if (!CheckUnderscore (id, UnderscoreHandling.Forbid)) {
- } else {
- realName = id;
- break;
- }
- realName = CamelCaseIdentifier (id);
- break;
- case NamingStyle.CamelCaseWithLowerLetterUnderscore:
- if (id.Length > 0 && !char.IsLower (id [0])) {
- } else if (!CheckUnderscore (id, UnderscoreHandling.AllowWithLowerStartingLetter)) {
- } else {
- realName = id;
- break;
- }
- realName = CamelCaseWithLowerLetterUnderscore (id);
- break;
- case NamingStyle.CamelCaseWithUpperLetterUnderscore:
- if (id.Length > 0 && !char.IsLower (id [0])) {
- } else if (!CheckUnderscore (id, UnderscoreHandling.AllowWithUpperStartingLetter)) {
- } else {
- realName = id;
- break;
- }
- realName = CamelCaseWithUpperLetterUnderscore (id);
- break;
-
- case NamingStyle.PascalCase:
- if (id.Length > 0 && !char.IsUpper (id [0])) {
- } else if (!CheckUnderscore (id, UnderscoreHandling.Forbid)) {
- } else {
- realName = id;
- break;
- }
- realName = PascalCaseIdentifier (id);
- break;
- case NamingStyle.PascalCaseWithLowerLetterUnderscore:
- if (id.Length > 0 && !char.IsUpper (id [0])) {
- } else if (!CheckUnderscore (id, UnderscoreHandling.AllowWithLowerStartingLetter)) {
- } else {
- realName = id;
- break;
- }
- realName = PascalCaseWithLowerLetterUnderscore (id);
- break;
- case NamingStyle.PascalCaseWithUpperLetterUnderscore:
- if (id.Length > 0 && !char.IsUpper (id [0])) {
- } else if (!CheckUnderscore (id, UnderscoreHandling.AllowWithUpperStartingLetter)) {
- } else {
- realName = id;
- break;
- }
- realName = PascalCaseWithUpperLetterUnderscore (id);
- break;
- case NamingStyle.FirstUpper:
- if (id.Length > 0 && !char.IsUpper (id [0])) {
- } else if (id.Take (1).Any (ch => char.IsLetter (ch) && char.IsUpper (ch))) {
- } else {
- realName = id;
- break;
- }
- realName = FirstUpperIdentifier (WordParser.BreakWords (id));
- break;
- }
-
- return prefix + realName + suffix;
- }
-
- static string ConvertToValidName(string id, Func<char, char> firstCharFunc, Func<char, char> followingCharFunc)
- {
- var sb = new StringBuilder();
- bool first = true;
- for (int i = 0; i < id.Length; i++) {
- char ch = id[i];
- if (i == 0 && ch == '_')
- continue;
- if (first && char.IsLetter(ch)) {
- sb.Append(firstCharFunc(ch));
- firstCharFunc = followingCharFunc;
- first = false;
- continue;
- }
- if (ch == '_') {
- if (first)
- continue;
- if (i + 1 < id.Length && id[i + 1] == '_')
- continue;
-
- if (i + 1 < id.Length) {
- if (char.IsDigit(id[i + 1])) {
- sb.Append('_');
- } else {
- first = true;
- }
- }
- continue;
- }
- sb.Append(ch);
- }
- return sb.ToString();
- }
-
- static string ConvertToValidNameWithSpecialUnderscoreHandling(string id, Func<char, char> firstCharFunc, Func<char, char> afterUnderscoreLetter)
- {
- var sb = new StringBuilder();
- bool first = true;
- for (int i = 0; i < id.Length; i++) {
- char ch = id[i];
- if (first && char.IsLetter(ch)) {
- sb.Append(firstCharFunc(ch));
- first = false;
- continue;
- }
- if (ch == '_') {
- if (first)
- continue;
- if (i + 1 < id.Length && id[i + 1] == '_')
- continue;
- sb.Append('_');
- i++;
- if (i < id.Length)
- sb.Append(afterUnderscoreLetter (id[i]));
- continue;
- }
- sb.Append(ch);
- }
- return sb.ToString();
- }
-
- static string CamelCaseIdentifier(string id)
- {
- return ConvertToValidName(id, ch => char.ToLower(ch), ch => char.ToUpper (ch));
- }
-
- static string CamelCaseWithLowerLetterUnderscore(string id)
- {
- return ConvertToValidNameWithSpecialUnderscoreHandling(id, ch => char.ToLower(ch), ch => char.ToLower(ch));
- }
-
- static string CamelCaseWithUpperLetterUnderscore(string id)
- {
- return ConvertToValidNameWithSpecialUnderscoreHandling(id, ch => char.ToLower(ch), ch => char.ToUpper(ch));
- }
-
- static string PascalCaseIdentifier(string id)
- {
- return ConvertToValidName(id, ch => char.ToUpper(ch), ch => char.ToUpper (ch));
- }
-
- static string PascalCaseWithLowerLetterUnderscore(string id)
- {
- return ConvertToValidNameWithSpecialUnderscoreHandling(id, ch => char.ToUpper(ch), ch => char.ToLower (ch));
- }
-
- static string PascalCaseWithUpperLetterUnderscore(string id)
- {
- return ConvertToValidNameWithSpecialUnderscoreHandling(id, ch => char.ToUpper(ch), ch => char.ToUpper(ch));
- }
-
- static string LowerCaseIdentifier(List<string> words)
- {
- var sb = new StringBuilder();
- sb.Append(words [0].ToLower());
- for (int i = 1; i < words.Count; i++) {
- sb.Append('_');
- sb.Append(words [i].ToLower());
- }
- return sb.ToString();
- }
-
- static string UpperCaseIdentifier(List<string> words)
- {
- var sb = new StringBuilder();
- sb.Append(words [0].ToUpper());
- for (int i = 1; i < words.Count; i++) {
- sb.Append('_');
- sb.Append(words [i].ToUpper());
- }
- return sb.ToString();
- }
-
- static string FirstUpperIdentifier(List<string> words)
- {
- var sb = new StringBuilder();
- AppendCapitalized(words [0], sb);
- for (int i = 1; i < words.Count; i++) {
- sb.Append('_');
- sb.Append(words [i].ToLower());
- }
- return sb.ToString();
- }
-
- static void AppendCapitalized(string word, StringBuilder sb)
- {
- sb.Append(word.ToLower());
- sb [sb.Length - word.Length] = char.ToUpper(sb [sb.Length - word.Length]);
- }
-
- static bool CheckUnderscore(string id, UnderscoreHandling handling)
- {
- for (int i = 1; i < id.Length; i++) {
- char ch = id [i];
- if (ch == '_' && !HandleUnderscore(handling, id, ref i))
- return false;
- }
- return true;
- }
-
- enum UnderscoreHandling {
- Forbid,
- Allow,
- AllowWithLowerStartingLetter,
- AllowWithUpperStartingLetter
- }
-
- static bool HandleUnderscore(UnderscoreHandling handling, string id, ref int i)
- {
- switch (handling) {
- case UnderscoreHandling.Forbid:
- if (i + 1 < id.Length) {
- char ch = id [i + 1];
- if (char.IsDigit(ch)) {
- i++;
- return true;
- }
- }
- return false;
- case UnderscoreHandling.Allow:
- return true;
- case UnderscoreHandling.AllowWithLowerStartingLetter:
- if (i + 1 < id.Length) {
- char ch = id [i + 1];
- if (char.IsLetter(ch) && !char.IsLower(ch) || ch =='_')
- return false;
- i++;
- }
- return true;
- case UnderscoreHandling.AllowWithUpperStartingLetter:
- if (i + 1 < id.Length) {
- char ch = id [i + 1];
- if (char.IsLetter(ch) && !char.IsUpper(ch) || ch =='_')
- return false;
- i++;
- }
- return true;
- default:
- throw new ArgumentOutOfRangeException();
- }
- }
-
- internal class NamePropsalStrategy : RefactoringEssentials.INameProposalStrategy
- {
- static readonly char[] s_underscoreCharArray = new[] { '_' };
- static readonly CultureInfo EnUSCultureInfo = new CultureInfo("en-US");
-
- string DefaultGetNameProposal(string baseName, SyntaxKind syntaxKindHint, Document document, int position)
- {
- switch (syntaxKindHint)
- {
- case SyntaxKind.ClassDeclaration:
- case SyntaxKind.StructDeclaration:
- case SyntaxKind.InterfaceDeclaration:
- case SyntaxKind.EnumDeclaration:
- case SyntaxKind.DelegateDeclaration:
- case SyntaxKind.MethodDeclaration:
- case SyntaxKind.PropertyDeclaration:
- case SyntaxKind.EventDeclaration:
- case SyntaxKind.EventFieldDeclaration:
- case SyntaxKind.EnumMemberDeclaration:
-
- // Trim leading underscores
- var newBaseName = baseName.TrimStart(s_underscoreCharArray);
-
- // Trim leading "m_"
- if (newBaseName.Length >= 2 && newBaseName[0] == 'm' && newBaseName[1] == '_')
- {
- newBaseName = newBaseName.Substring(2);
- }
-
- // Take original name if no characters left
- if (newBaseName.Length == 0)
- {
- newBaseName = baseName;
- }
-
- // Make the first character upper case using the "en-US" culture. See discussion at
- // https://github.com/dotnet/roslyn/issues/5524.
- var firstCharacter = EnUSCultureInfo.TextInfo.ToUpper(newBaseName[0]);
- return firstCharacter.ToString() + newBaseName.Substring(1);
-
- case SyntaxKind.Parameter:
- case SyntaxKind.FieldDeclaration:
- case SyntaxKind.VariableDeclaration:
- case SyntaxKind.LocalDeclarationStatement:
- return char.ToLower(baseName[0]).ToString() + baseName.Substring(1);
- }
- return baseName;
- }
-
- public string GetNameProposal(string baseName, SyntaxKind syntaxKindHint, Accessibility accessibility, bool isStatic, Document document, int position)
- {
- var container = PolicyService.DefaultPolicies;
- var project = TypeSystemService.GetMonoProject (document.Id);
- if (project == null)
- project = IdeApp.ProjectOperations.CurrentSelectedProject;
- if (project != null)
- container = project.Policies;
- var policy = container.Get<NameConventionPolicy> ();
- var entity = GetAffectedEntity (syntaxKindHint);
-
- var mod = Modifiers.None;
- switch (accessibility) {
- case Accessibility.Private:
- mod = Modifiers.Private;
- break;
- case Accessibility.ProtectedAndInternal:
- mod = Modifiers.Internal | Modifiers.Protected;
- break;
- case Accessibility.Protected:
- mod = Modifiers.Protected;
- break;
- case Accessibility.Internal:
- mod = Modifiers.Internal;
- break;
- case Accessibility.ProtectedOrInternal:
- mod = Modifiers.Internal | Modifiers.Protected;
- break;
- case Accessibility.Public:
- mod = Modifiers.Public;
- break;
- }
-
- foreach (var rule in policy.Rules) {
- if ((rule.AffectedEntity & entity) != entity)
- continue;
- if (isStatic && !rule.IncludeStaticEntities)
- continue;
- if ((rule.VisibilityMask & mod) != mod)
- continue;
- return rule.CorrectName (baseName);
- }
-
- return DefaultGetNameProposal (baseName, syntaxKindHint, document, position);
- }
-
- AffectedEntity GetAffectedEntity (SyntaxKind syntaxKindHint)
- {
- switch (syntaxKindHint) {
- case SyntaxKind.ClassDeclaration:
- return AffectedEntity.Class;
- case SyntaxKind.StructDeclaration:
- return AffectedEntity.Struct;
- case SyntaxKind.InterfaceDeclaration:
- return AffectedEntity.Interface;
- case SyntaxKind.EnumDeclaration:
- return AffectedEntity.Enum;
- case SyntaxKind.DelegateDeclaration:
- return AffectedEntity.Delegate;
- case SyntaxKind.MethodDeclaration:
- return AffectedEntity.Method;
- case SyntaxKind.PropertyDeclaration:
- return AffectedEntity.Property;
- case SyntaxKind.EventDeclaration:
- return AffectedEntity.Event;
- case SyntaxKind.EventFieldDeclaration:
- return AffectedEntity.Event;
- case SyntaxKind.EnumMemberDeclaration:
- return AffectedEntity.EnumMember;
- case SyntaxKind.Parameter:
- return AffectedEntity.Parameter;
- case SyntaxKind.FieldDeclaration:
- return AffectedEntity.Field;
- case SyntaxKind.VariableDeclaration:
- return AffectedEntity.LocalVariable;
- case SyntaxKind.LocalDeclarationStatement:
- return AffectedEntity.LocalVariable;
- }
- return AffectedEntity.None;
- }
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/MonoTODO/MonoTODODiagnosticAnalyzer.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/MonoTODO/MonoTODODiagnosticAnalyzer.cs
index ad7f68ea93..a4da73f782 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/MonoTODO/MonoTODODiagnosticAnalyzer.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/MonoTODO/MonoTODODiagnosticAnalyzer.cs
@@ -29,10 +29,8 @@ using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
-using ICSharpCode.NRefactory6.CSharp;
using System.Threading;
using MonoDevelop.Ide.TypeSystem;
-using RefactoringEssentials;
namespace MonoDevelop.CSharp.Diagnostics.MonoTODODiagnostic
{
@@ -48,10 +46,10 @@ namespace MonoDevelop.CSharp.Diagnostics.MonoTODODiagnostic
static readonly DiagnosticDescriptor descriptor = new DiagnosticDescriptor(
IDEDiagnosticIds.MonoTODODiagnosticDiagnosticId,
- "Find usages of mono todo items",
+ "Find APIs marked as TODO in Mono",
"{0}",
- DiagnosticAnalyzerCategories.Notifications,
- DiagnosticSeverity.Warning,
+ DiagnosticCategory.Style,
+ defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics {
@@ -81,7 +79,7 @@ namespace MonoDevelop.CSharp.Diagnostics.MonoTODODiagnostic
{
var info = semanticModel.GetSymbolInfo (node);
diagnostic = default(Diagnostic);
- if (info.Symbol == null || semanticModel.IsFromGeneratedCode (cancellationToken))
+ if (info.Symbol == null)
return false;
foreach (var attr in info.Symbol.GetAttributes ()) {
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastDiagnosticAnalyzer.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastDiagnosticAnalyzer.cs
deleted file mode 100644
index dcb06caf87..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastDiagnosticAnalyzer.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace MonoDevelop.CSharp.Diagnostics.RemoveUnnecessaryCast
-{
- [DiagnosticAnalyzer(LanguageNames.CSharp)]
- internal sealed class CSharpRemoveUnnecessaryCastDiagnosticAnalyzer : RemoveUnnecessaryCastDiagnosticAnalyzerBase<SyntaxKind>
- {
- private static readonly ImmutableArray<SyntaxKind> s_kindsOfInterest = ImmutableArray.Create(SyntaxKind.CastExpression);
-
- public override ImmutableArray<SyntaxKind> SyntaxKindsOfInterest
- {
- get
- {
- return s_kindsOfInterest;
- }
- }
-
- protected override bool IsUnnecessaryCast(SemanticModel model, SyntaxNode node, CancellationToken cancellationToken)
- {
- var cast = (CastExpressionSyntax)node;
- return cast.IsUnnecessaryCast(model, cancellationToken);
- }
-
- protected override TextSpan GetDiagnosticSpan(SyntaxNode node)
- {
- var cast = (CastExpressionSyntax)node;
- return TextSpan.FromBounds(cast.OpenParenToken.SpanStart, cast.CloseParenToken.Span.End);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastDiagnosticAnalyzerBase.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastDiagnosticAnalyzerBase.cs
deleted file mode 100644
index 350c09e970..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastDiagnosticAnalyzerBase.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using MonoDevelop.Core;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp;
-using RefactoringEssentials;
-
-namespace MonoDevelop.CSharp.Diagnostics.RemoveUnnecessaryCast
-{
- internal abstract class RemoveUnnecessaryCastDiagnosticAnalyzerBase<TLanguageKindEnum> : DiagnosticAnalyzer where TLanguageKindEnum : struct
- {
- private static string s_localizableTitle = GettextCatalog.GetString ("Remove Unnecessary Cast");
- private static string s_localizableMessage = GettextCatalog.GetString ("Cast is redundant.");
-
- private static readonly DiagnosticDescriptor s_descriptor = new DiagnosticDescriptor(IDEDiagnosticIds.RemoveUnnecessaryCastDiagnosticId,
- s_localizableTitle,
- s_localizableMessage,
- DiagnosticAnalyzerCategories.RedundanciesInCode,
- DiagnosticSeverity.Warning,
- isEnabledByDefault: true,
- customTags: DiagnosticCustomTags.Unnecessary);
-
- #region Interface methods
-
- public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
- {
- get
- {
- return ImmutableArray.Create(s_descriptor);
- }
- }
-
- public override void Initialize(AnalysisContext context)
- {
- context.RegisterSyntaxNodeAction(
- (nodeContext) =>
- {
- Diagnostic diagnostic;
- if (TryRemoveCastExpression(nodeContext.SemanticModel, nodeContext.Node, out diagnostic, nodeContext.CancellationToken))
- {
- nodeContext.ReportDiagnostic(diagnostic);
- }
- },
- this.SyntaxKindsOfInterest.ToArray());
- }
-
- public abstract ImmutableArray<TLanguageKindEnum> SyntaxKindsOfInterest { get; }
-
- #endregion
-
- protected abstract bool IsUnnecessaryCast(SemanticModel model, SyntaxNode node, CancellationToken cancellationToken);
- protected abstract TextSpan GetDiagnosticSpan(SyntaxNode node);
-
- private bool TryRemoveCastExpression(
- SemanticModel model, SyntaxNode node, out Diagnostic diagnostic, CancellationToken cancellationToken)
- {
- diagnostic = default(Diagnostic);
- if (model.IsFromGeneratedCode (cancellationToken))
- return false;
- if (!IsUnnecessaryCast(model, node, cancellationToken))
- {
- return false;
- }
-
- var tree = model.SyntaxTree;
- var span = GetDiagnosticSpan(node);
- if (tree.OverlapsHiddenPosition(span, cancellationToken))
- {
- return false;
- }
-
- diagnostic = Diagnostic.Create(s_descriptor, tree.GetLocation(span));
- return true;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs
deleted file mode 100644
index 30c1046d09..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.Features.RemoveUnnecessaryImports;
-using ICSharpCode.NRefactory6.CSharp;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.CSharp.Diagnostics.RemoveUnnecessaryImports
-{
- [DiagnosticAnalyzer(LanguageNames.CSharp)]
- internal sealed class CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer : RemoveUnnecessaryImportsDiagnosticAnalyzerBase
- {
- private static readonly string s_TitleAndMessageFormat = GettextCatalog.GetString ("Using directive is unnecessary.");
-
- protected override LocalizableString GetTitleAndMessageFormatForClassificationIdDescriptor()
- {
- return s_TitleAndMessageFormat;
- }
-
- protected override IEnumerable<SyntaxNode> GetUnnecessaryImports(SemanticModel semanticModel, SyntaxNode root, CancellationToken cancellationToken = default(CancellationToken))
- {
- return CSharpRemoveUnnecessaryImportsService.GetUnnecessaryImports(semanticModel, root, cancellationToken);
- }
-
- protected override IEnumerable<TextSpan> GetFixableDiagnosticSpans(IEnumerable<SyntaxNode> nodes, SyntaxTree tree, CancellationToken cancellationToken = default(CancellationToken))
- {
- //var nodesContainingUnnecessaryUsings = new HashSet<SyntaxNode>();
- foreach (var node in nodes) {
- yield return node.Span;
-// var nodeContainingUnnecessaryUsings = node.GetAncestors().First(n => n is NamespaceDeclarationSyntax || n is CompilationUnitSyntax);
-// if (!nodesContainingUnnecessaryUsings.Add(nodeContainingUnnecessaryUsings))
-// {
-// continue;
-// }
-//
-// yield return nodeContainingUnnecessaryUsings is NamespaceDeclarationSyntax ?
-// ((NamespaceDeclarationSyntax)nodeContainingUnnecessaryUsings).Usings.GetContainedSpan() :
-// ((CompilationUnitSyntax)nodeContainingUnnecessaryUsings).Usings.GetContainedSpan();
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryImports/RemoveUnnecessaryImportsDiagnosticAnalyzerBase.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryImports/RemoveUnnecessaryImportsDiagnosticAnalyzerBase.cs
deleted file mode 100644
index 338c130b6f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/RemoveUnnecessaryImports/RemoveUnnecessaryImportsDiagnosticAnalyzerBase.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp;
-using RefactoringEssentials;
-
-namespace MonoDevelop.CSharp.Diagnostics.RemoveUnnecessaryImports
-{
- internal abstract class RemoveUnnecessaryImportsDiagnosticAnalyzerBase : DiagnosticAnalyzer
- {
- // NOTE: This is a trigger diagnostic, which doesn't show up in the ruleset editor and hence doesn't need a conventional IDE Diagnostic ID string.
- internal const string DiagnosticFixableId = "RemoveUnnecessaryImportsFixable";
-
- // The NotConfigurable custom tag ensures that user can't turn this diagnostic into a warning / error via
- // ruleset editor or solution explorer. Setting messageFormat to empty string ensures that we won't display
- // this diagnostic in the preview pane header.
- //private static readonly DiagnosticDescriptor s_fixableIdDescriptor =
- // new DiagnosticDescriptor(DiagnosticFixableId,
- // title: "", messageFormat: "", category: "",
- // defaultSeverity: DiagnosticSeverity.Hidden,
- // isEnabledByDefault: true,
- // customTags: WellKnownDiagnosticTags.NotConfigurable);
-
- protected abstract LocalizableString GetTitleAndMessageFormatForClassificationIdDescriptor();
-
- private DiagnosticDescriptor _classificationIdDescriptor;
- private DiagnosticDescriptor GetClassificationIdDescriptor()
- {
- if (_classificationIdDescriptor == null)
- {
- var titleAndMessageFormat = GetTitleAndMessageFormatForClassificationIdDescriptor();
- _classificationIdDescriptor =
- new DiagnosticDescriptor(IDEDiagnosticIds.RemoveUnnecessaryImportsDiagnosticId,
- titleAndMessageFormat,
- titleAndMessageFormat,
- DiagnosticAnalyzerCategories.RedundanciesInCode,
- DiagnosticSeverity.Warning,
- isEnabledByDefault: true,
- customTags: DiagnosticCustomTags.Unnecessary);
- }
-
- return _classificationIdDescriptor;
- }
-
- private ImmutableArray<DiagnosticDescriptor> _descriptors;
- public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
- {
- get
- {
- if (_descriptors == null)
- {
- _descriptors = ImmutableArray.Create(GetClassificationIdDescriptor());
- }
-
- return _descriptors;
- }
- }
-
- public override void Initialize(AnalysisContext context)
- {
- context.RegisterSemanticModelAction(this.AnalyzeSemanticModel);
- }
-
- private void AnalyzeSemanticModel(SemanticModelAnalysisContext context)
- {
- if (context.IsFromGeneratedCode ())
- return;
- var tree = context.SemanticModel.SyntaxTree;
- var root = tree.GetRoot();
- var unncessaryImports = GetUnnecessaryImports(context.SemanticModel, root);
- if (unncessaryImports != null && unncessaryImports.Any())
- {
- Func<SyntaxNode, SyntaxToken> getLastTokenFunc = GetLastTokenDelegateForContiguousSpans();
- var contiguousSpans = unncessaryImports.GetContiguousSpans(getLastTokenFunc);
- var diagnostics = CreateClassificationDiagnostics(contiguousSpans, tree).Concat(
- CreateFixableDiagnostics(unncessaryImports, tree));
- var spans = new List<TextSpan> ();
- foreach (var diagnostic in diagnostics)
- {
- if (spans.Any (s => s.OverlapsWith (diagnostic.Location.SourceSpan)))
- continue;
- spans.Add (diagnostic.Location.SourceSpan);
- context.ReportDiagnostic(diagnostic);
- }
- }
- }
-
- protected abstract IEnumerable<SyntaxNode> GetUnnecessaryImports(SemanticModel semanticModel, SyntaxNode root, CancellationToken cancellationToken = default(CancellationToken));
- protected virtual Func<SyntaxNode, SyntaxToken> GetLastTokenDelegateForContiguousSpans()
- {
- return null;
- }
-
- // Create one diagnostic for each unnecessary span that will be classified as Unnecessary
- private IEnumerable<Diagnostic> CreateClassificationDiagnostics(IEnumerable<TextSpan> contiguousSpans, SyntaxTree tree, CancellationToken cancellationToken = default(CancellationToken))
- {
- foreach (var span in contiguousSpans)
- {
- if (tree.OverlapsHiddenPosition(span, cancellationToken))
- {
- continue;
- }
-
- yield return Diagnostic.Create(GetClassificationIdDescriptor(), tree.GetLocation(span));
- }
- }
-
- protected abstract IEnumerable<TextSpan> GetFixableDiagnosticSpans(IEnumerable<SyntaxNode> nodes, SyntaxTree tree, CancellationToken cancellationToken = default(CancellationToken));
-
- private IEnumerable<Diagnostic> CreateFixableDiagnostics(IEnumerable<SyntaxNode> nodes, SyntaxTree tree, CancellationToken cancellationToken = default(CancellationToken))
- {
- var spans = GetFixableDiagnosticSpans(nodes, tree, cancellationToken);
- foreach (var span in spans) {
- yield return Diagnostic.Create(GetClassificationIdDescriptor(), tree.GetLocation(span));
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/SimplifyTypeNames/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/SimplifyTypeNames/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs
deleted file mode 100644
index 962207b8a7..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/SimplifyTypeNames/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using ICSharpCode.NRefactory6.CSharp;
-using RefactoringEssentials;
-
-namespace MonoDevelop.CSharp.Diagnostics.SimplifyTypeNames
-{
- [DiagnosticAnalyzer(LanguageNames.CSharp)]
- internal sealed class CSharpSimplifyTypeNamesDiagnosticAnalyzer : SimplifyTypeNamesDiagnosticAnalyzerBase<SyntaxKind>
- {
- private static readonly ImmutableArray<SyntaxKind> s_kindsOfInterest = ImmutableArray.Create(SyntaxKind.QualifiedName,
- SyntaxKind.AliasQualifiedName,
- SyntaxKind.GenericName,
- SyntaxKind.IdentifierName,
- SyntaxKind.SimpleMemberAccessExpression,
- SyntaxKind.QualifiedCref);
-
- public override void Initialize(AnalysisContext analysisContext)
- {
- analysisContext.RegisterSyntaxNodeAction(AnalyzeNode, s_kindsOfInterest.ToArray());
- }
-
- protected override void AnalyzeNode(SyntaxNodeAnalysisContext context)
- {
- if (context.IsFromGeneratedCode ())
- return;
- foreach (var n in context.Node.Ancestors (ascendOutOfTrivia: false)) {
- if (s_kindsOfInterest.Contains (n.Kind ())) {
- // Already simplified an ancestor of this node.
- return;
- }
- }
-
- Diagnostic diagnostic;
- Func<SyntaxNode, bool> descendIntoChildren = n =>
- {
- if (!IsRegularCandidate(n) ||
- !TrySimplifyTypeNameExpression(context.SemanticModel, n, context.Options, out diagnostic, context.CancellationToken))
- {
- return true;
- }
- context.ReportDiagnostic(diagnostic);
- return false;
- };
-
- // find regular node first - search from top to down. once found one, don't get into its children
- foreach (var candidate in context.Node.DescendantNodesAndSelf(descendIntoChildren))
- {
- context.CancellationToken.ThrowIfCancellationRequested();
- }
-
- // now search structure trivia
- foreach (var candidate in context.Node.DescendantNodesAndSelf(descendIntoChildren: n => !IsCrefCandidate(n), descendIntoTrivia: true))
- {
- context.CancellationToken.ThrowIfCancellationRequested();
-
- if (IsCrefCandidate(candidate) &&
- TrySimplifyTypeNameExpression(context.SemanticModel, candidate, context.Options, out diagnostic, context.CancellationToken))
- {
- context.ReportDiagnostic(diagnostic);
- }
- }
- }
-
- internal static bool IsCandidate(SyntaxNode node)
- {
- return IsRegularCandidate(node) || IsCrefCandidate(node);
- }
-
- private static bool IsRegularCandidate(SyntaxNode node)
- {
- return node != null && s_kindsOfInterest.Contains(node.Kind());
- }
-
- private static bool IsCrefCandidate(SyntaxNode node)
- {
- return node is QualifiedCrefSyntax;
- }
-
- protected sealed override bool CanSimplifyTypeNameExpressionCore(SemanticModel model, SyntaxNode node, OptionSet optionSet, out TextSpan issueSpan, out string diagnosticId, CancellationToken cancellationToken)
- {
- return CanSimplifyTypeNameExpression(model, node, optionSet, out issueSpan, out diagnosticId, cancellationToken);
- }
-
- internal static bool CanSimplifyTypeNameExpression(SemanticModel model, SyntaxNode node, OptionSet optionSet, out TextSpan issueSpan, out string diagnosticId, CancellationToken cancellationToken)
- {
- issueSpan = default(TextSpan);
- diagnosticId = IDEDiagnosticIds.SimplifyNamesDiagnosticId;
-
- // For Crefs, currently only Qualified Crefs needs to be handled separately
- if (node.Kind() == SyntaxKind.QualifiedCref)
- {
- if (node.ContainsDiagnostics)
- {
- return false;
- }
-
- var crefSyntax = (CrefSyntax)node;
-
- CrefSyntax replacementNode;
- if (!crefSyntax.TryReduceOrSimplifyExplicitName (model, out replacementNode, out issueSpan, optionSet, cancellationToken))
- {
- return false;
- }
- }
- else
- {
- var expression = (ExpressionSyntax)node;
- if (expression.ContainsDiagnostics)
- {
- return false;
- }
-
- // in case of an As or Is expression we need to handle the binary expression, because it might be
- // required to add parenthesis around the expression. Adding the parenthesis is done in the CSharpNameSimplifier.Rewriter
- var expressionToCheck = expression.Kind() == SyntaxKind.AsExpression || expression.Kind() == SyntaxKind.IsExpression
- ? ((BinaryExpressionSyntax)expression).Right
- : expression;
-
- ExpressionSyntax replacementSyntax;
- if (!expressionToCheck.TryReduceOrSimplifyExplicitName(model, out replacementSyntax, out issueSpan, optionSet, cancellationToken))
- {
- return false;
- }
-
- if (expression.Kind() == SyntaxKind.SimpleMemberAccessExpression)
- {
- var memberAccess = (MemberAccessExpressionSyntax)expression;
- diagnosticId = memberAccess.Expression.Kind() == SyntaxKind.ThisExpression ?
- IDEDiagnosticIds.SimplifyThisOrMeDiagnosticId :
- IDEDiagnosticIds.SimplifyMemberAccessDiagnosticId;
- }
- }
-
- return true;
- }
-
- protected override string GetLanguageName()
- {
- return LanguageNames.CSharp;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs
deleted file mode 100644
index 6734509864..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Diagnostics/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Immutable;
-using System.Threading;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Diagnostics;
-using ICSharpCode.NRefactory6.CSharp;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.TypeSystem;
-using System;
-using RefactoringEssentials;
-
-namespace MonoDevelop.CSharp.Diagnostics.SimplifyTypeNames
-{
- internal abstract class SimplifyTypeNamesDiagnosticAnalyzerBase<TLanguageKindEnum> : DiagnosticAnalyzer where TLanguageKindEnum : struct
- {
- private static string s_localizableMessage = GettextCatalog.GetString ("Name can be simplified.");
- private static string s_localizableTitleSimplifyNames = GettextCatalog.GetString ("Simplify Names");
-
- private static readonly DiagnosticDescriptor s_descriptorSimplifyNames = new DiagnosticDescriptor(IDEDiagnosticIds.SimplifyNamesDiagnosticId,
- s_localizableTitleSimplifyNames,
- s_localizableMessage,
- DiagnosticAnalyzerCategories.RedundanciesInCode,
- DiagnosticSeverity.Warning,
- isEnabledByDefault: true,
- customTags: DiagnosticCustomTags.Unnecessary);
-
- private static string s_localizableTitleSimplifyMemberAccess = GettextCatalog.GetString ("Simplify member access '{0}'");
- private static readonly DiagnosticDescriptor s_descriptorSimplifyMemberAccess = new DiagnosticDescriptor(IDEDiagnosticIds.SimplifyMemberAccessDiagnosticId,
- s_localizableTitleSimplifyMemberAccess,
- s_localizableMessage,
- DiagnosticAnalyzerCategories.RedundanciesInCode,
- DiagnosticSeverity.Warning,
- isEnabledByDefault: true,
- customTags: DiagnosticCustomTags.Unnecessary);
-
- private static string s_localizableTitleSimplifyThisOrMe = GettextCatalog.GetString ("Remove 'this'");
- private static readonly DiagnosticDescriptor s_descriptorSimplifyThisOrMe = new DiagnosticDescriptor(IDEDiagnosticIds.SimplifyThisOrMeDiagnosticId,
- s_localizableTitleSimplifyThisOrMe,
- s_localizableMessage,
- DiagnosticAnalyzerCategories.RedundanciesInCode,
- DiagnosticSeverity.Warning,
- isEnabledByDefault: true,
- customTags: DiagnosticCustomTags.Unnecessary);
-
-
- public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
- {
- get
- {
- return ImmutableArray.Create(s_descriptorSimplifyNames, s_descriptorSimplifyMemberAccess, s_descriptorSimplifyThisOrMe);
- }
- }
-
- protected abstract void AnalyzeNode(SyntaxNodeAnalysisContext context);
-
- protected abstract bool CanSimplifyTypeNameExpressionCore(SemanticModel model, SyntaxNode node, OptionSet optionSet, out TextSpan issueSpan, out string diagnosticId, CancellationToken cancellationToken);
-
- private OptionSet GetOptionSet(AnalyzerOptions analyzerOptions)
- {
- return TypeSystemService.Workspace.Options;
- }
-
- protected abstract string GetLanguageName();
-
- protected bool TrySimplifyTypeNameExpression(SemanticModel model, SyntaxNode node, AnalyzerOptions analyzerOptions, out Diagnostic diagnostic, CancellationToken cancellationToken)
- {
- diagnostic = default(Diagnostic);
-
- var optionSet = GetOptionSet(analyzerOptions);
- string diagnosticId;
-
- TextSpan issueSpan;
- if (!CanSimplifyTypeNameExpressionCore(model, node, optionSet, out issueSpan, out diagnosticId, cancellationToken))
- {
- return false;
- }
-
- if (model.SyntaxTree.OverlapsHiddenPosition(issueSpan, cancellationToken))
- {
- return false;
- }
-
- DiagnosticDescriptor descriptor;
- switch (diagnosticId)
- {
- case IDEDiagnosticIds.SimplifyNamesDiagnosticId:
- descriptor = s_descriptorSimplifyNames;
- break;
-
- case IDEDiagnosticIds.SimplifyMemberAccessDiagnosticId:
- descriptor = s_descriptorSimplifyMemberAccess;
- break;
-
- case IDEDiagnosticIds.SimplifyThisOrMeDiagnosticId:
- descriptor = s_descriptorSimplifyThisOrMe;
- break;
-
- default:
- throw new InvalidOperationException();
- }
-
- var tree = model.SyntaxTree;
- diagnostic = Diagnostic.Create(descriptor, tree.GetLocation(issueSpan));
- return true;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/AbstractTokenBraceCompletionSession.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/AbstractTokenBraceCompletionSession.cs
index a02300da1b..d14e549979 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/AbstractTokenBraceCompletionSession.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/AbstractTokenBraceCompletionSession.cs
@@ -1,4 +1,4 @@
-//
+//
// AbstractTokenBraceCompletionSession.cs
//
// Author:
@@ -23,12 +23,12 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using MonoDevelop.Ide.Editor;
-using ICSharpCode.NRefactory6.CSharp;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Ide;
using MonoDevelop.Core.Text;
@@ -52,22 +52,21 @@ namespace MonoDevelop.CSharp.Features.AutoInsertBracket
readonly char closingChar;
protected AbstractTokenBraceCompletionSession (DocumentContext ctx,
- int openingTokenKind, int closingTokenKind, char ch)
+ int openingTokenKind, int closingTokenKind, char ch)
{
this.closingChar = ch;
this.ctx = ctx;
this.OpeningTokenKind = openingTokenKind;
this.ClosingTokenKind = closingTokenKind;
}
-
- public virtual bool CheckOpeningPoint(TextEditor editor, DocumentContext ctx, CancellationToken cancellationToken)
+
+ public virtual bool CheckOpeningPoint (TextEditor editor, DocumentContext ctx, CancellationToken cancellationToken)
{
var snapshot = CurrentSnapshot;
var position = StartOffset;
- var token = FindToken(snapshot, position, cancellationToken);
+ var token = FindToken (snapshot, position, cancellationToken);
- if (!IsValidToken(token))
- {
+ if (!IsValidToken (token)) {
return false;
}
@@ -85,10 +84,10 @@ namespace MonoDevelop.CSharp.Features.AutoInsertBracket
public override void BeforeType (char ch, out bool handledCommand)
{
handledCommand = false;
- if (!CheckIsValid() || ch != this.closingChar) {
+ if (!CheckIsValid () || ch != this.closingChar) {
return;
}
- if (AllowOverType (default(CancellationToken))) {
+ if (AllowOverType (default (CancellationToken))) {
Editor.CaretOffset++;
this.endOffset = this.startOffset = 0;
handledCommand = true;
@@ -112,29 +111,28 @@ namespace MonoDevelop.CSharp.Features.AutoInsertBracket
}
}
- protected bool IsValidToken(SyntaxToken token)
+ protected bool IsValidToken (SyntaxToken token)
{
return token.Parent != null && !(token.Parent is SkippedTokensTriviaSyntax);
}
- public virtual void AfterStart(CancellationToken cancellationToken)
+ public virtual void AfterStart (CancellationToken cancellationToken)
{
}
- public virtual void AfterReturn(CancellationToken cancellationToken)
+ public virtual void AfterReturn (CancellationToken cancellationToken)
{
}
- public virtual bool AllowOverType(CancellationToken cancellationToken)
+ public virtual bool AllowOverType (CancellationToken cancellationToken)
{
- return CheckCurrentPosition(cancellationToken) && CheckClosingTokenKind(cancellationToken);
+ return CheckCurrentPosition (cancellationToken) && CheckClosingTokenKind (cancellationToken);
}
- protected bool CheckClosingTokenKind(CancellationToken cancellationToken)
+ protected bool CheckClosingTokenKind (CancellationToken cancellationToken)
{
var document = Document;
- if (document != null)
- {
+ if (document != null) {
var root = document.GetSyntaxRootAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var position = EndOffset + 1;
@@ -144,14 +142,13 @@ namespace MonoDevelop.CSharp.Features.AutoInsertBracket
return true;
}
- protected bool CheckCurrentPosition(CancellationToken cancellationToken)
+ protected bool CheckCurrentPosition (CancellationToken cancellationToken)
{
var document = Document;
- if (document != null)
- {
+ if (document != null) {
// make sure auto closing is called from a valid position
- var tree = document.GetSyntaxTreeAsync(cancellationToken).WaitAndGetResult(cancellationToken);
- return !tree.IsInNonUserCode(Editor.CaretOffset, cancellationToken);
+ var tree = document.GetSyntaxTreeAsync (cancellationToken).WaitAndGetResult (cancellationToken);
+ return !tree.IsInNonUserCode (Editor.CaretOffset, cancellationToken);
}
return true;
@@ -159,8 +156,8 @@ namespace MonoDevelop.CSharp.Features.AutoInsertBracket
internal static SyntaxToken FindToken (SyntaxTree snapshot, int position, CancellationToken cancellationToken)
{
- var root = snapshot.GetRootAsync(cancellationToken).WaitAndGetResult(CancellationToken.None);
- return root.FindToken(position, findInsideTrivia: true);
+ var root = snapshot.GetRootAsync (cancellationToken).WaitAndGetResult (CancellationToken.None);
+ return root.FindToken (position, findInsideTrivia: true);
}
}
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/CSharpAutoInsertBracketHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/CSharpAutoInsertBracketHandler.cs
index 9545658e62..b484ba6df9 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/CSharpAutoInsertBracketHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/CSharpAutoInsertBracketHandler.cs
@@ -23,13 +23,11 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using MonoDevelop.Ide.Editor;
using MonoDevelop.Ide.Editor.Extension;
using MonoDevelop.CSharp.Formatting;
-using MonoDevelop.Ide.TypeSystem;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using System.Threading;
-using ICSharpCode.NRefactory6.CSharp;
namespace MonoDevelop.CSharp.Features.AutoInsertBracket
{
@@ -37,16 +35,16 @@ namespace MonoDevelop.CSharp.Features.AutoInsertBracket
{
public override bool CanHandle (TextEditor editor)
{
-
+
return editor.MimeType == CSharpFormatter.MimeType;
}
public override bool Handle (TextEditor editor, DocumentContext ctx, KeyDescriptor descriptor)
{
char closingBrace;
- if (!IsSupportedOpeningBrace (descriptor.KeyChar, out closingBrace) || !CheckCodeContext (editor, ctx, editor.CaretOffset - 1, descriptor.KeyChar, default (CancellationToken)) || ctx.AnalysisDocument == null)
+ if (!IsSupportedOpeningBrace (descriptor.KeyChar, out closingBrace) || !CheckCodeContext (editor, ctx, editor.CaretOffset - 1, descriptor.KeyChar, default (CancellationToken)) || ctx.AnalysisDocument == null)
return false;
-
+
var session = CreateEditorSession (editor, ctx, editor.CaretOffset, descriptor.KeyChar, default (CancellationToken));
session.SetEditor (editor);
if (session == null | !((ICheckPointEditSession)session).CheckOpeningPoint (editor, ctx, default (CancellationToken)))
@@ -60,45 +58,42 @@ namespace MonoDevelop.CSharp.Features.AutoInsertBracket
return true;
}
- protected virtual bool CheckCodeContext(TextEditor editor, DocumentContext ctx, int position, char openingBrace, CancellationToken cancellationToken)
+ protected virtual bool CheckCodeContext (TextEditor editor, DocumentContext ctx, int position, char openingBrace, CancellationToken cancellationToken)
{
// SPECIAL CASE: Allow in curly braces in string literals to support interpolated strings.
if (openingBrace == CurlyBrace.OpenCharacter &&
- InterpolationCompletionSession.IsContext(editor, ctx, position, cancellationToken))
- {
+ InterpolationCompletionSession.IsContext (editor, ctx, position, cancellationToken)) {
return true;
}
if (openingBrace == DoubleQuote.OpenCharacter &&
- InterpolatedStringCompletionSession.IsContext(editor, ctx, position, cancellationToken))
- {
+ InterpolatedStringCompletionSession.IsContext (editor, ctx, position, cancellationToken)) {
return true;
}
-
+
// check that the user is not typing in a string literal or comment
- var tree = ctx.AnalysisDocument.GetSyntaxTreeAsync(cancellationToken).Result;
+ var tree = ctx.AnalysisDocument.GetSyntaxTreeAsync (cancellationToken).Result;
- return !tree.IsInNonUserCode(position, cancellationToken);
+ return !tree.IsInNonUserCode (position, cancellationToken);
}
- EditSession CreateEditorSession(TextEditor editor, DocumentContext ctx, int openingPosition, char openingBrace, CancellationToken cancellationToken)
+ EditSession CreateEditorSession (TextEditor editor, DocumentContext ctx, int openingPosition, char openingBrace, CancellationToken cancellationToken)
{
- switch (openingBrace)
- {
- case CurlyBrace.OpenCharacter:
- return InterpolationCompletionSession.IsContext(editor, ctx, openingPosition, cancellationToken)
- ? (EditSession)new InterpolationCompletionSession()
- : new CurlyBraceCompletionSession(ctx);
-
- case DoubleQuote.OpenCharacter:
- return InterpolatedStringCompletionSession.IsContext(editor, ctx, openingPosition, cancellationToken)
- ? (EditSession)new InterpolatedStringCompletionSession()
- : new StringLiteralCompletionSession(ctx);
-
- case Bracket.OpenCharacter: return new BracketCompletionSession(ctx);
- case Parenthesis.OpenCharacter: return new ParenthesisCompletionSession(ctx);
- case SingleQuote.OpenCharacter: return new CharLiteralCompletionSession(ctx);
- case LessAndGreaterThan.OpenCharacter: return new LessAndGreaterThanCompletionSession(ctx);
+ switch (openingBrace) {
+ case CurlyBrace.OpenCharacter:
+ return InterpolationCompletionSession.IsContext (editor, ctx, openingPosition, cancellationToken)
+ ? (EditSession)new InterpolationCompletionSession ()
+ : new CurlyBraceCompletionSession (ctx);
+
+ case DoubleQuote.OpenCharacter:
+ return InterpolatedStringCompletionSession.IsContext (editor, ctx, openingPosition, cancellationToken)
+ ? (EditSession)new InterpolatedStringCompletionSession ()
+ : new StringLiteralCompletionSession (ctx);
+
+ case Bracket.OpenCharacter: return new BracketCompletionSession (ctx);
+ case Parenthesis.OpenCharacter: return new ParenthesisCompletionSession (ctx);
+ case SingleQuote.OpenCharacter: return new CharLiteralCompletionSession (ctx);
+ case LessAndGreaterThan.OpenCharacter: return new LessAndGreaterThanCompletionSession (ctx);
}
return null;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolatedStringCompletionSession.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolatedStringCompletionSession.cs
index b8cf580995..dce0e37d1d 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolatedStringCompletionSession.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolatedStringCompletionSession.cs
@@ -30,10 +30,8 @@ using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
using MonoDevelop.Ide.Editor;
-using ICSharpCode.NRefactory6.CSharp;
-using MonoDevelop.Ide;
+using Roslyn.Utilities;
namespace MonoDevelop.CSharp.Features.AutoInsertBracket
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolationCompletionSession.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolationCompletionSession.cs
index 90d1cbff60..b39b9e42cd 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolationCompletionSession.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/InterpolationCompletionSession.cs
@@ -30,7 +30,6 @@ using ICSharpCode.NRefactory6.CSharp;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using MonoDevelop.Ide;
using MonoDevelop.Ide.Editor;
using Roslyn.Utilities;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/LessAndGreaterThanCompletionSession.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/LessAndGreaterThanCompletionSession.cs
index 5730f286be..042118399b 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/LessAndGreaterThanCompletionSession.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/AutoInsertBracket/Sessions/LessAndGreaterThanCompletionSession.cs
@@ -25,7 +25,6 @@
// THE SOFTWARE.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
using System.Linq;
using System.Threading;
using ICSharpCode.NRefactory6.CSharp;
@@ -34,8 +33,6 @@ using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.Ide;
using MonoDevelop.Ide.Editor;
using Roslyn.Utilities;
@@ -43,73 +40,69 @@ namespace MonoDevelop.CSharp.Features.AutoInsertBracket
{
internal class LessAndGreaterThanCompletionSession : AbstractTokenBraceCompletionSession, ICheckPointEditSession
{
- public LessAndGreaterThanCompletionSession(DocumentContext ctx)
- : base(ctx, (int)SyntaxKind.LessThanToken, (int)SyntaxKind.GreaterThanToken, '>')
+ public LessAndGreaterThanCompletionSession (DocumentContext ctx)
+ : base (ctx, (int)SyntaxKind.LessThanToken, (int)SyntaxKind.GreaterThanToken, '>')
{
}
- public override bool CheckOpeningPoint(TextEditor editor, DocumentContext ctx, CancellationToken cancellationToken)
+ public override bool CheckOpeningPoint (TextEditor editor, DocumentContext ctx, CancellationToken cancellationToken)
{
var snapshot = CurrentSnapshot;
var position = StartOffset;
- var token = FindToken(snapshot, position, cancellationToken);
+ var token = FindToken (snapshot, position, cancellationToken);
// check what parser thinks about the newly typed "<" and only proceed if parser thinks it is "<" of
// type argument or parameter list
- if (!token.CheckParent<TypeParameterListSyntax>(n => n.LessThanToken == token) &&
- !token.CheckParent<TypeArgumentListSyntax>(n => n.LessThanToken == token) &&
- !PossibleTypeArgument(token, cancellationToken))
- {
+ if (!token.CheckParent<TypeParameterListSyntax> (n => n.LessThanToken == token) &&
+ !token.CheckParent<TypeArgumentListSyntax> (n => n.LessThanToken == token) &&
+ !PossibleTypeArgument (token, cancellationToken)) {
return false;
}
return true;
}
- private bool PossibleTypeArgument(SyntaxToken token, CancellationToken cancellationToken)
+ private bool PossibleTypeArgument (SyntaxToken token, CancellationToken cancellationToken)
{
var node = token.Parent as BinaryExpressionSyntax;
// type argument can be easily ambiguous with normal < operations
- if (node == null || node.Kind() != SyntaxKind.LessThanExpression || node.OperatorToken != token)
- {
+ if (node == null || node.Kind () != SyntaxKind.LessThanExpression || node.OperatorToken != token) {
return false;
}
// use binding to see whether it is actually generic type or method
var document = Document;
- if (document == null)
- {
+ if (document == null) {
return false;
}
- var model = document.GetSemanticModelAsync(cancellationToken).WaitAndGetResult(cancellationToken);
+ var model = document.GetSemanticModelAsync (cancellationToken).WaitAndGetResult (cancellationToken);
// Analyze node on the left of < operator to verify if it is a generic type or method.
var leftNode = node.Left;
- if (leftNode is ConditionalAccessExpressionSyntax)
- {
+ if (leftNode is ConditionalAccessExpressionSyntax) {
// If node on the left is a conditional access expression, get the member binding expression
// from the innermost conditional access expression, which is the left of < operator.
// e.g: Case a?.b?.c< : we need to get the conditional access expression .b?.c and analyze its
// member binding expression (the .c) to see if it is a generic type/method.
// Case a?.b?.c.d< : we need to analyze .c.d
// Case a?.M(x => x?.P)?.M2< : We need to analyze .M2
- leftNode = leftNode.GetInnerMostConditionalAccessExpression().WhenNotNull;
+ leftNode = leftNode.GetInnerMostConditionalAccessExpression ().WhenNotNull;
}
- var info = model.GetSymbolInfo(leftNode, cancellationToken);
- return info.CandidateSymbols.Any(IsGenericTypeOrMethod);
+ var info = model.GetSymbolInfo (leftNode, cancellationToken);
+ return info.CandidateSymbols.Any (IsGenericTypeOrMethod);
}
- private static bool IsGenericTypeOrMethod(ISymbol symbol)
+ private static bool IsGenericTypeOrMethod (ISymbol symbol)
{
- return symbol.GetArity() > 0;
+ return symbol.GetArity () > 0;
}
- public override bool AllowOverType(CancellationToken cancellationToken)
+ public override bool AllowOverType (CancellationToken cancellationToken)
{
- return CheckCurrentPosition(cancellationToken);
+ return CheckCurrentPosition (cancellationToken);
}
}
} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CSharpCodeGenerationService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CSharpCodeGenerationService.cs
deleted file mode 100644
index e12162dfa5..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CSharpCodeGenerationService.cs
+++ /dev/null
@@ -1,330 +0,0 @@
-//
-// CSharpCodeGenerationService.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Linq;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis;
-using System.Threading;
-using System.Reflection;
-using System.Threading.Tasks;
-using System.Collections.Generic;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeGeneration
-{
- class CSharpCodeGenerationService
- {
- readonly static Type typeInfo;
- readonly object instance;
-
- readonly static MethodInfo createEventDeclarationMethod;
- readonly static MethodInfo createFieldDeclaration;
- readonly static MethodInfo createMethodDeclaration;
- readonly static MethodInfo createPropertyDeclaration;
- readonly static MethodInfo createNamedTypeDeclaration;
- readonly static MethodInfo createNamespaceDeclaration;
- readonly static MethodInfo addMethodAsync;
- readonly static MethodInfo addMembersAsync;
-
- readonly static MethodInfo canAddTo1, canAddTo2;
-
- static CSharpCodeGenerationService ()
- {
- var abstractServiceType = Type.GetType ("Microsoft.CodeAnalysis.CodeGeneration.AbstractCodeGenerationService" + ReflectionNamespaces.WorkspacesAsmName, true);
- var codeGenerationDestinationType = Type.GetType ("Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationDestination" + ReflectionNamespaces.WorkspacesAsmName, true);
- var codeGenerationOptionsType = Type.GetType ("Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationOptions" + ReflectionNamespaces.WorkspacesAsmName, true);
-
-
-
-
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CSharp.CodeGeneration.CSharpCodeGenerationService" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- //TDeclarationNode destination, IMethodSymbol method, CodeGenerationOptions options = null, CancellationToken cancellationToken = default(CancellationToken)
-
-
- addMethod = typeInfo.GetMethods ().Single (m =>
- m.Name == "AddMethod" &&
- m.GetParameters ().Count () == 4);
- if (addMethod == null)
- throw new InvalidOperationException ("AddMethod not found.");
-
- createEventDeclarationMethod = typeInfo.GetMethod ("CreateEventDeclaration", BindingFlags.Instance | BindingFlags.Public, null, new [] { typeof(IEventSymbol), codeGenerationDestinationType, codeGenerationOptionsType }, null);
- if (createEventDeclarationMethod == null)
- throw new InvalidOperationException ("CreateEventDeclaration not found.");
-
- createFieldDeclaration = typeInfo.GetMethod ("CreateFieldDeclaration", BindingFlags.Instance | BindingFlags.Public, null, new [] { typeof(IFieldSymbol), codeGenerationDestinationType, codeGenerationOptionsType }, null);
- if (createFieldDeclaration == null)
- throw new InvalidOperationException ("CreateFieldDeclaration not found.");
-
- createMethodDeclaration = typeInfo.GetMethod ("CreateMethodDeclaration", BindingFlags.Instance | BindingFlags.Public, null, new [] { typeof(IMethodSymbol), codeGenerationDestinationType, codeGenerationOptionsType }, null);
- if (createMethodDeclaration == null)
- throw new InvalidOperationException ("CreateMethodDeclaration not found.");
-
- createPropertyDeclaration = typeInfo.GetMethod ("CreatePropertyDeclaration", BindingFlags.Instance | BindingFlags.Public, null, new [] { typeof(IPropertySymbol), codeGenerationDestinationType, codeGenerationOptionsType }, null);
- if (createPropertyDeclaration == null)
- throw new InvalidOperationException ("CreatePropertyDeclaration not found.");
-
- createNamedTypeDeclaration = typeInfo.GetMethod ("CreateNamedTypeDeclaration", BindingFlags.Instance | BindingFlags.Public, null, new [] { typeof(INamedTypeSymbol), codeGenerationDestinationType, codeGenerationOptionsType, typeof(CancellationToken) }, null);
- if (createNamedTypeDeclaration == null)
- throw new InvalidOperationException ("CreateNamedTypeDeclaration not found.");
-
- createNamespaceDeclaration = typeInfo.GetMethod ("CreateNamespaceDeclaration", BindingFlags.Instance | BindingFlags.Public, null, new [] { typeof(INamespaceSymbol), codeGenerationDestinationType, codeGenerationOptionsType, typeof(CancellationToken) }, null);
- if (createNamespaceDeclaration == null)
- throw new InvalidOperationException ("CreateNamespaceDeclaration not found.");
-
- addMethodAsync = abstractServiceType.GetMethod ("AddMethodAsync", BindingFlags.Instance | BindingFlags.Public);
- if (addMethodAsync == null)
- throw new InvalidOperationException ("AddMethodAsync not found.");
- addPropertyAsync = abstractServiceType.GetMethod ("AddPropertyAsync", BindingFlags.Instance | BindingFlags.Public);
- if (addPropertyAsync == null)
- throw new InvalidOperationException ("AddPropertyAsync not found.");
-
-
-
- addMembersAsync = abstractServiceType.GetMethod ("AddMembersAsync", BindingFlags.Instance | BindingFlags.Public, null, new [] { typeof(Solution), typeof(INamedTypeSymbol), typeof(IEnumerable<ISymbol>), CodeGenerationOptions.typeInfo, typeof(CancellationToken) }, null);
- if (addMembersAsync == null)
- throw new InvalidOperationException ("AddMembersAsync not found.");
-
- canAddTo1 = typeInfo.GetMethod ("CanAddTo", new [] {typeof(ISymbol), typeof(Solution), typeof(CancellationToken) });
- if (canAddTo1 == null)
- throw new InvalidOperationException ("CanAddTo1 not found.");
-
- canAddTo2 = typeInfo.GetMethod ("CanAddTo", new [] {typeof(SyntaxNode), typeof(Solution), typeof(CancellationToken) });
- if (canAddTo2 == null)
- throw new InvalidOperationException ("CanAddTo1 not found.");
-
- addFieldAsync = abstractServiceType.GetMethod ("AddFieldAsync", BindingFlags.Instance | BindingFlags.Public, null, new [] { typeof(Solution), typeof(INamedTypeSymbol), typeof(IFieldSymbol), CodeGenerationOptions.typeInfo, typeof(CancellationToken) }, null);
- if (addFieldAsync == null)
- throw new InvalidOperationException ("AddFieldAsync not found.");
-
- addStatements = typeInfo.GetMethod ("AddStatements", BindingFlags.Instance | BindingFlags.Public);
- if (addStatements == null)
- throw new InvalidOperationException ("AddStatements not found.");
-
- }
-
- public CSharpCodeGenerationService(HostLanguageServices languageServices)
- {
- instance = Activator.CreateInstance (typeInfo, new object[] {
- languageServices
- });
- }
-
- public CSharpCodeGenerationService (Workspace workspace, string language)
- {
- var languageService = workspace.Services.GetLanguageServices (language);
-
- this.instance = Activator.CreateInstance (typeInfo, new [] { languageService });
- }
-
- public CSharpCodeGenerationService (Workspace workspace) : this (workspace, LanguageNames.CSharp)
- {
- }
-
- static MethodInfo addStatements;
- public TDeclarationNode AddStatements<TDeclarationNode>(
- TDeclarationNode destinationMember,
- IEnumerable<SyntaxNode> statements,
- CodeGenerationOptions options,
- CancellationToken cancellationToken)
- {
- try {
- return (TDeclarationNode)addStatements.MakeGenericMethod (typeof (TDeclarationNode)).Invoke (instance, new object[] { destinationMember, statements, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return default(TDeclarationNode);
- }
- }
-
- static MethodInfo addMethod;
-
- /// <summary>
- /// Adds a method into destination.
- /// </summary>
- public TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) where TDeclarationNode : SyntaxNode
- {
- try {
- return (TDeclarationNode)addMethod.MakeGenericMethod (typeof (TDeclarationNode)).Invoke (instance, new object[] { destination, method, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return default (TDeclarationNode);
- }
- }
-
-
- /// <summary>
- /// Returns a newly created event declaration node from the provided event.
- /// </summary>
- public SyntaxNode CreateEventDeclaration(IEventSymbol @event, CodeGenerationDestination destination = CodeGenerationDestination.Unspecified)
- {
- try {
- return (SyntaxNode)createEventDeclarationMethod.Invoke (instance, new object[] { @event, (int)destination, null });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- /// <summary>
- /// Returns a newly created field declaration node from the provided field.
- /// </summary>
- public SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination = CodeGenerationDestination.Unspecified)
- {
- try {
- return (SyntaxNode)createFieldDeclaration.Invoke (instance, new object[] { @field, (int)destination, null });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- /// <summary>
- /// Returns a newly created method declaration node from the provided method.
- /// </summary>
- public SyntaxNode CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination = CodeGenerationDestination.Unspecified)
- {
- try {
- return (SyntaxNode)createMethodDeclaration.Invoke (instance, new object[] { @method, (int)destination, null });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- /// <summary>
- /// Returns a newly created property declaration node from the provided property.
- /// </summary>
- public SyntaxNode CreatePropertyDeclaration(IPropertySymbol property, CodeGenerationDestination destination = CodeGenerationDestination.Unspecified)
- {
- try {
- return (SyntaxNode)createPropertyDeclaration.Invoke (instance, new object[] { @property, (int)destination, null });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- /// <summary>
- /// Returns a newly created named type declaration node from the provided named type.
- /// </summary>
- public SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationOptions options, CancellationToken cancellationToken)
- {
- try {
- return (SyntaxNode)createNamedTypeDeclaration.Invoke (instance, new object[] { @namedType, destination, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- /// <summary>
- /// Returns a newly created namespace declaration node from the provided namespace.
- /// </summary>
- public SyntaxNode CreateNamespaceDeclaration(INamespaceSymbol @namespace, CodeGenerationDestination destination, CodeGenerationOptions options, CancellationToken cancellationToken)
- {
- try {
- return (SyntaxNode)createNamespaceDeclaration.Invoke (instance, new object[] { @namespace, (int)destination, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public Task<Document> AddMethodAsync(Solution solution, INamedTypeSymbol destination, IMethodSymbol method, CodeGenerationOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<Document>)addMethodAsync.Invoke (instance, new object[] { solution, destination, method, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public Task<Document> AddPropertyAsync(Solution solution, INamedTypeSymbol destination, IPropertySymbol property, CodeGenerationOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<Document>)addPropertyAsync.Invoke (instance, new object[] { solution, destination, property, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- /// <summary>
- /// Adds all the provided members into destination.
- /// </summary>
- public Task<Document> AddMembersAsync(Solution solution, INamedTypeSymbol destination, IEnumerable<ISymbol> members, CodeGenerationOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<Document>)addMembersAsync.Invoke (instance, new object[] { solution, destination, members, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo addFieldAsync;
- static MethodInfo addPropertyAsync;
-
- public Task<Document> AddFieldAsync(Solution solution, INamedTypeSymbol destination, IFieldSymbol field, CodeGenerationOptions options, CancellationToken cancellationToken)
- {
- try {
- return (Task<Document>)addFieldAsync.Invoke (instance, new object[] { solution, destination, field, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- /// <summary>
- /// <c>true</c> if destination is a location where other symbols can be added to.
- /// </summary>
- public bool CanAddTo(ISymbol destination, Solution solution, CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (bool)canAddTo1.Invoke (instance, new object[] { destination, solution, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- /// <summary>
- /// <c>true</c> if destination is a location where other symbols can be added to.
- /// </summary>
- public bool CanAddTo(SyntaxNode destination, Solution solution, CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (bool)canAddTo2.Invoke (instance, new object[] { destination, solution, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationDestination.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationDestination.cs
deleted file mode 100644
index 95d22e070f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationDestination.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// CodeGenerationDestination.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis;
-using System.Threading;
-using System.Reflection;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeGeneration
-{
- enum CodeGenerationDestination
- {
- Unspecified = 0,
- CompilationUnit = 1,
- Namespace = 2,
- ClassType = 3,
- EnumType = 4,
- InterfaceType = 5,
- ModuleType = 6,
- StructType = 7,
- }
-
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationHelpers.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationHelpers.cs
deleted file mode 100644
index 8e0673457f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationHelpers.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.Formatting;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeGeneration
-{
- static class CodeGenerationHelpers
- {
- public static SyntaxNode GenerateThrowStatement(
- SyntaxGenerator factory,
- SemanticDocument document,
- string exceptionMetadataName,
- CancellationToken cancellationToken)
- {
- var compilation = document.SemanticModel.Compilation;
- var exceptionType = compilation.GetTypeByMetadataName(exceptionMetadataName);
-
- // If we can't find the Exception, we obviously can't generate anything.
- if (exceptionType == null)
- {
- return null;
- }
-
- var exceptionCreationExpression = factory.ObjectCreationExpression(
- exceptionType,
- SpecializedCollections.EmptyList<SyntaxNode>());
-
- return factory.ThrowStatement(exceptionCreationExpression);
- }
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationOptions.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationOptions.cs
deleted file mode 100644
index e534a4e64b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationOptions.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeGeneration
-{
- class CodeGenerationOptions
- {
- internal readonly static Type typeInfo;
- readonly object instance;
-
- internal object Instance {
- get {
- return instance;
- }
- }
-
- static CodeGenerationOptions ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationOptions" + ReflectionNamespaces.WorkspacesAsmName, true);
- }
-
- public CodeGenerationOptions(
- Location contextLocation = null,
- Location afterThisLocation = null,
- Location beforeThisLocation = null,
- bool addImports = true,
- bool placeSystemNamespaceFirst = true,
- IEnumerable<INamespaceSymbol> additionalImports = null,
- bool generateMembers = true,
- bool mergeNestedNamespaces = true,
- bool mergeAttributes = true,
- bool generateDefaultAccessibility = true,
- bool generateMethodBodies = true,
- bool generateDocumentationComments = false,
- bool autoInsertionLocation = true,
- bool reuseSyntax = false)
- {
- instance = Activator.CreateInstance (typeInfo, new object[] {
- contextLocation,
- afterThisLocation,
- beforeThisLocation,
- addImports,
- placeSystemNamespaceFirst,
- additionalImports,
- generateMembers,
- mergeNestedNamespaces,
- mergeAttributes,
- generateDefaultAccessibility,
- generateMethodBodies,
- generateDocumentationComments,
- autoInsertionLocation,
- reuseSyntax
- });
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationTypeParameterSymbol.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationTypeParameterSymbol.cs
deleted file mode 100644
index bc61fce570..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerationTypeParameterSymbol.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-// CodeGenerationTypeParameterSymbol.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class CodeGenerationTypeParameterSymbol
- {
- readonly static Type typeInfo;
- readonly object instance;
-
- internal object Instance {
- get {
- return instance;
- }
- }
-
- readonly static System.Reflection.PropertyInfo constraintTypesProperty;
- public ImmutableArray<ITypeSymbol> ConstraintTypes {
- get {
- return (ImmutableArray<ITypeSymbol>)constraintTypesProperty.GetValue (instance);
- }
- internal set {
- constraintTypesProperty.SetValue (instance, value);
- }
- }
-
-
- static CodeGenerationTypeParameterSymbol ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationTypeParameterSymbol" + ReflectionNamespaces.WorkspacesAsmName, true);
- constraintTypesProperty = typeInfo.GetProperty ("ConstraintTypes");
- }
-
- public CodeGenerationTypeParameterSymbol(
- INamedTypeSymbol containingType,
- IList<AttributeData> attributes,
- VarianceKind varianceKind,
- string name,
- ImmutableArray<ITypeSymbol> constraintTypes,
- bool hasConstructorConstraint,
- bool hasReferenceConstraint,
- bool hasValueConstraint,
- int ordinal)
- {
- instance = Activator.CreateInstance (typeInfo, new object[] {
- containingType,
- attributes,
- varianceKind,
- name,
- constraintTypes,
- hasConstructorConstraint,
- hasReferenceConstraint,
- hasValueConstraint,
- ordinal
- });
- }
-
-
-
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerator.cs
deleted file mode 100644
index 0c31f9024a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/CodeGenerator.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-//
-// CodeGenerator.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using System.Reflection;
-using System.Threading;
-using System.Collections.Generic;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- #if NR6
- public
- #endif
- static class CodeGenerator
- {
- readonly static Type typeInfo;
-
- static CodeGenerator ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CodeGeneration.CodeGenerator" + ReflectionNamespaces.WorkspacesAsmName, true);
- addPropertyDeclarationAsyncMethod = typeInfo.GetMethod ("AddPropertyDeclarationAsync", BindingFlags.Static | BindingFlags.Public);
- addMethodDeclarationAsyncMethod = typeInfo.GetMethod ("AddMethodDeclarationAsync", BindingFlags.Static | BindingFlags.Public);
- addFieldDeclarationAsyncMethod = typeInfo.GetMethod ("AddFieldDeclarationAsync", BindingFlags.Static | BindingFlags.Public);
- addNamespaceOrTypeDeclarationAsyncMethod = typeInfo.GetMethod ("AddNamespaceOrTypeDeclarationAsync", BindingFlags.Static | BindingFlags.Public);
- addNamedTypeDeclarationAsyncMethod1 = typeInfo.GetMethod ("AddNamedTypeDeclarationAsync", new [] { typeof(Solution), typeof(INamedTypeSymbol), typeof(INamedTypeSymbol), CodeGenerationOptions.typeInfo, typeof(CancellationToken) });
- addNamedTypeDeclarationAsyncMethod2 = typeInfo.GetMethod ("AddNamedTypeDeclarationAsync", new [] { typeof(Solution), typeof(INamespaceSymbol), typeof(INamedTypeSymbol), CodeGenerationOptions.typeInfo, typeof(CancellationToken) });
- }
-
- static MethodInfo addNamedTypeDeclarationAsyncMethod1;
-
- public static Task<Document> AddNamedTypeDeclarationAsync(Solution solution, INamedTypeSymbol destination, INamedTypeSymbol namedType, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<Document>)addNamedTypeDeclarationAsyncMethod1.Invoke (null, new object[] { solution, destination, namedType, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo addNamedTypeDeclarationAsyncMethod2;
- public static Task<Document> AddNamedTypeDeclarationAsync(Solution solution, INamespaceSymbol destination, INamedTypeSymbol namedType, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<Document>)addNamedTypeDeclarationAsyncMethod2.Invoke (null, new object[] { solution, destination, namedType, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo addNamespaceOrTypeDeclarationAsyncMethod;
-
- public static Task<Document> AddNamespaceOrTypeDeclarationAsync(Solution solution, INamespaceSymbol destination, INamespaceOrTypeSymbol namespaceOrType, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<Document>)addNamespaceOrTypeDeclarationAsyncMethod.Invoke (null, new object[] { solution, destination, namespaceOrType, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- readonly static MethodInfo addFieldDeclarationAsyncMethod;
-
- public static Task<Document> AddFieldDeclarationAsync(Solution solution, INamedTypeSymbol destination, IFieldSymbol field, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<Document>)addFieldDeclarationAsyncMethod.Invoke (null, new object[] { solution, destination, field, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- readonly static MethodInfo addPropertyDeclarationAsyncMethod;
- public static Task<Document> AddPropertyDeclarationAsync(Solution solution, INamedTypeSymbol destination, IPropertySymbol property, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<Document>)addPropertyDeclarationAsyncMethod.Invoke (null, new object[] { solution, destination, property, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- readonly static MethodInfo addMethodDeclarationAsyncMethod;
- public static Task<Document> AddMethodDeclarationAsync(Solution solution, INamedTypeSymbol destination, IMethodSymbol method, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<Document>)addMethodDeclarationAsyncMethod.Invoke (null, new object[] { solution, destination, method, options != null ? options.Instance : null, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public static Task<Document> AddMemberDeclarationsAsync(Solution solution, INamedTypeSymbol destination, IEnumerable<ISymbol> members, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
- {
- return new CSharpCodeGenerationService(solution.Workspace, destination.Language).AddMembersAsync(solution, destination, members, options, cancellationToken);
- }
-
- public static bool CanAdd(Solution solution, ISymbol destination, CancellationToken cancellationToken = default(CancellationToken))
- {
- return new CSharpCodeGenerationService(solution.Workspace, destination.Language).CanAddTo(destination, solution, cancellationToken);
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/SyntaxAnnotationExtensions.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/SyntaxAnnotationExtensions.cs
deleted file mode 100644
index edfd190b22..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/CodeGeneration/SyntaxAnnotationExtensions.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// SyntaxAnnotationExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeGeneration
-{
- static class SyntaxAnnotationExtensions
- {
- readonly static Type typeInfo;
-
- static SyntaxAnnotationExtensions ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CodeGeneration.SyntaxAnnotationExtensions" + ReflectionNamespaces.WorkspacesAsmName, true);
- addAnnotationToSymbolMethod = typeInfo.GetMethod ("AddAnnotationToSymbol", BindingFlags.Public | BindingFlags.Static);
- }
-
- readonly static MethodInfo addAnnotationToSymbolMethod;
-
- public static TSymbol AddAnnotationToSymbol<TSymbol>(
- this SyntaxAnnotation annotation,
- TSymbol symbol)
- where TSymbol : ISymbol
- {
- try {
- return (TSymbol)addAnnotationToSymbolMethod.MakeGenericMethod (typeof(TSymbol)).Invoke (null, new object[] { annotation, symbol });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return default (TSymbol);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/CompletionEngine.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/CompletionEngine.cs
index 8940a237ee..ff5de56ea1 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/CompletionEngine.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/CompletionEngine.cs
@@ -26,22 +26,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.CodeAnalysis;
using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
-
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Text;
-using Microsoft.CodeAnalysis.Recommendations;
-using System.Threading.Tasks;
using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.CSharp.Completion;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
- partial class CompletionEngine
+ partial class CompletionEngine
{
- static CompletionContextHandler[] handlers = {
+ static CompletionContextHandler [] handlers = {
new RoslynRecommendationsCompletionContextHandler (),
new OverrideContextHandler(),
new PartialContextHandler(),
@@ -59,7 +57,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
new ObjectCreationContextHandler(),
new SenderCompletionContextHandler(),
new CastCompletionContextHandler(),
- new PreProcessorExpressionContextHandler(),
+ new PreProcessorExpressionContextHandler(),
new RegexContextHandler(),
new KeywordContextHandler(),
};
@@ -79,23 +77,23 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
}
}
- public CompletionEngine(Workspace workspace, ICompletionDataFactory factory)
+ public CompletionEngine (Workspace workspace, ICompletionDataFactory factory)
{
if (workspace == null)
- throw new ArgumentNullException("workspace");
+ throw new ArgumentNullException ("workspace");
if (factory == null)
- throw new ArgumentNullException("factory");
+ throw new ArgumentNullException ("factory");
this.workspace = workspace;
this.factory = factory;
}
- public async Task<CompletionResult> GetCompletionDataAsync(CompletionContext completionContext, CompletionTriggerInfo info, CancellationToken cancellationToken = default(CancellationToken))
+ public async Task<CompletionResult> GetCompletionDataAsync (CompletionContext completionContext, CompletionTriggerInfo info, CancellationToken cancellationToken = default (CancellationToken))
{
if (completionContext == null)
throw new ArgumentNullException ("completionContext");
var document = completionContext.Document;
- var semanticModel = await completionContext.GetSemanticModelAsync (cancellationToken).ConfigureAwait(false);
+ var semanticModel = await completionContext.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
var position = completionContext.Position;
var text = await document.GetTextAsync (cancellationToken).ConfigureAwait (false);
var ctx = await completionContext.GetSyntaxContextAsync (workspace, cancellationToken);
@@ -104,7 +102,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
// case lambda parameter (n1, $
if (ctx.TargetToken.IsKind (SyntaxKind.CommaToken) &&
ctx.TargetToken.Parent != null && ctx.TargetToken.Parent.Parent != null &&
- ctx.TargetToken.Parent.Parent.IsKind(SyntaxKind.ParenthesizedLambdaExpression))
+ ctx.TargetToken.Parent.Parent.IsKind (SyntaxKind.ParenthesizedLambdaExpression))
return CompletionResult.Empty;
var result = new CompletionResult { SyntaxContext = ctx };
@@ -176,19 +174,19 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
}
// prevent auto selection for "<number>." case
- if (ctx.TargetToken.IsKind(SyntaxKind.DotToken)) {
+ if (ctx.TargetToken.IsKind (SyntaxKind.DotToken)) {
var accessExpr = ctx.TargetToken.Parent as MemberAccessExpressionSyntax;
if (accessExpr != null &&
accessExpr.Expression != null &&
- accessExpr.Expression.IsKind(SyntaxKind.NumericLiteralExpression)) {
+ accessExpr.Expression.IsKind (SyntaxKind.NumericLiteralExpression)) {
result.AutoSelect = false;
}
}
if (ctx.LeftToken.Parent != null &&
ctx.LeftToken.Parent.Parent != null &&
- ctx.TargetToken.Parent != null && !ctx.TargetToken.Parent.IsKind(SyntaxKind.NameEquals) &&
- ctx.LeftToken.Parent.Parent.IsKind(SyntaxKind.AnonymousObjectMemberDeclarator))
+ ctx.TargetToken.Parent != null && !ctx.TargetToken.Parent.IsKind (SyntaxKind.NameEquals) &&
+ ctx.LeftToken.Parent.Parent.IsKind (SyntaxKind.AnonymousObjectMemberDeclarator))
result.AutoSelect = false;
if (ctx.TargetToken.IsKind (SyntaxKind.OpenParenToken) && ctx.TargetToken.GetPreviousToken ().IsKind (SyntaxKind.OpenParenToken)) {
@@ -202,7 +200,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
break;
}
}
-
+
return result;
}
@@ -210,10 +208,10 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
{
if (type == null)
yield break;
- foreach (var member in type.GetMembers()) {
+ foreach (var member in type.GetMembers ()) {
yield return member;
}
- foreach (var baseMember in GetAllMembers(type.BaseType))
+ foreach (var baseMember in GetAllMembers (type.BaseType))
yield return baseMember;
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/AttributeNamedParameterContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/AttributeNamedParameterContextHandler.cs
index 5cd4140eff..b4610ce4f2 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/AttributeNamedParameterContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/AttributeNamedParameterContextHandler.cs
@@ -30,10 +30,13 @@ using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using System.Linq;
using System.Collections.Immutable;
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Ide.TypeSystem;
+using Roslyn.Utilities;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/CastCompletionContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/CastCompletionContextHandler.cs
index 122f405bf9..4a8c7801bf 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/CastCompletionContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/CastCompletionContextHandler.cs
@@ -24,17 +24,17 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Threading.Tasks;
using System.Collections.Generic;
-using System.Threading;
using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.Ide.TypeSystem;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
@@ -68,7 +68,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
// check parent if for direct type check
var ifStmSyntax = ancestor as IfStatementSyntax;
if (ifStmSyntax != null) {
- var condition = ifStmSyntax.Condition.SkipParens ();
+ var condition = SkipParens (ifStmSyntax.Condition);
if (condition != null && condition.IsKind (SyntaxKind.IsExpression)) {
var isExpr = ((BinaryExpressionSyntax)condition);
var leftSymbol = model.GetSymbolInfo (isExpr.Left);
@@ -95,10 +95,10 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
foreach (var ifStmt in blockSyntax.Statements.OfType<IfStatementSyntax> ()) {
if (ifStmt.Span.End >= ma.Span.Start)
break;
- var condition = ifStmt.Condition.SkipParens ();
+ var condition = SkipParens (ifStmt.Condition);
bool wasNegated = false;
if (condition.IsKind (SyntaxKind.LogicalNotExpression)) {
- condition = ((PrefixUnaryExpressionSyntax)condition).Operand.SkipParens ();
+ condition = SkipParens(((PrefixUnaryExpressionSyntax)condition).Operand);
wasNegated = true;
}
if (condition == null || !condition.IsKind (SyntaxKind.IsExpression))
@@ -125,8 +125,8 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
var binOp = ancestor as BinaryExpressionSyntax;
if (binOp != null && binOp.IsKind (SyntaxKind.LogicalAndExpression)) {
- if (binOp.Left.SkipParens ().IsKind (SyntaxKind.IsExpression)) {
- var isExpr = ((BinaryExpressionSyntax)binOp.Left.SkipParens ());
+ if (SkipParens(binOp.Left).IsKind (SyntaxKind.IsExpression)) {
+ var isExpr = (BinaryExpressionSyntax)SkipParens (binOp.Left);
var leftSymbol = model.GetSymbolInfo (isExpr.Left);
if (leftSymbol.Symbol == symbolInfo.Symbol) {
@@ -144,6 +144,16 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
return Task.FromResult ((IEnumerable<CompletionData>)list);
}
+ static ExpressionSyntax SkipParens (ExpressionSyntax expression)
+ {
+ if (expression == null)
+ return null;
+ while (expression != null && expression.IsKind (SyntaxKind.ParenthesizedExpression)) {
+ expression = ((ParenthesizedExpressionSyntax)expression).Expression;
+ }
+ return expression;
+ }
+
void Analyze (CompletionEngine engine, SyntaxNode node, ITypeSymbol type, ITypeSymbol stopAt, ISymbol within, List<CompletionData> list, HashSet<string> addedSymbols, CancellationToken cancellationToken)
{
var startType = type;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/DelegateCreationContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/DelegateCreationContextHandler.cs
index 8978980df5..6a5229f5be 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/DelegateCreationContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/DelegateCreationContextHandler.cs
@@ -23,21 +23,22 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Threading.Tasks;
+
using System.Collections.Generic;
-using System.Threading;
using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using System.Text;
+using Microsoft.CodeAnalysis.ExtractMethod;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using ICSharpCode.NRefactory6.CSharp.ExtractMethod;
-using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.CSharp.Completion;
using MonoDevelop.Core;
+using MonoDevelop.CSharp.Completion;
+using MonoDevelop.Ide.CodeCompletion;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/EnumMemberContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/EnumMemberContextHandler.cs
index 02aa7bcb17..765306e223 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/EnumMemberContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/EnumMemberContextHandler.cs
@@ -27,18 +27,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.CodeAnalysis.Recommendations;
-using Microsoft.CodeAnalysis;
using System.Threading;
-using Microsoft.CodeAnalysis.CSharp;
-
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Text;
using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis.Options;
-using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.CSharp.Completion;
+using MonoDevelop.Ide.CodeCompletion;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExplicitInterfaceContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExplicitInterfaceContextHandler.cs
index ddda1d8dd5..5613a78f5b 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExplicitInterfaceContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExplicitInterfaceContextHandler.cs
@@ -24,15 +24,17 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Threading.Tasks;
using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.Text;
using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
+using Microsoft.CodeAnalysis.Text;
using MonoDevelop.Ide.CodeCompletion;
namespace ICSharpCode.NRefactory6.CSharp.Completion
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExternAliasContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExternAliasContextHandler.cs
index abb5d17e6c..8484b24fb6 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExternAliasContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ExternAliasContextHandler.cs
@@ -25,15 +25,17 @@
// THE SOFTWARE.
-using System;
-using System.Threading.Tasks;
using System.Collections.Generic;
-using System.Threading;
using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Ide.CodeCompletion;
+using Roslyn.Utilities;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
@@ -53,7 +55,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
if (targetToken.IsKind(SyntaxKind.AliasKeyword) && targetToken.Parent.IsKind(SyntaxKind.ExternAliasDirective))
{
var compilation = await document.GetCSharpCompilationAsync(cancellationToken).ConfigureAwait(false);
- var aliases = compilation.ExternalReferences.Where(r => r.Properties.Aliases != null).SelectMany(r => r.Properties.Aliases).ToSet();
+ var aliases = compilation.ExternalReferences.SelectMany(r => r.Properties.Aliases).ToSet();
if (aliases.Any())
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/KeywordContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/KeywordContextHandler.cs
index 13b0a61863..456eb297ae 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/KeywordContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/KeywordContextHandler.cs
@@ -24,49 +24,24 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.CodeAnalysis.Recommendations;
-using Microsoft.CodeAnalysis;
using System.Threading;
-using Microsoft.CodeAnalysis.CSharp;
-
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Text;
using System.Threading.Tasks;
-using ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders;
-using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
+using Microsoft.CodeAnalysis.CSharp.Completion.KeywordRecommenders;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Ide.CodeCompletion;
+using Microsoft.CodeAnalysis.Completion.Providers;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
- internal sealed class RecommendedKeyword
- {
- public SyntaxKind Kind { get; private set; }
- public string Keyword { get; private set; }
- public bool IsIntrinsic { get; private set; }
- public bool ShouldFormatOnCommit { get; private set; }
-
-
- public RecommendedKeyword (string keyword, SyntaxKind kind, bool isIntrinsic = false, bool shouldFormatOnCommit = false)
- {
- this.Kind = kind;
- this.Keyword = keyword;
- this.IsIntrinsic = isIntrinsic;
- this.ShouldFormatOnCommit = shouldFormatOnCommit;
- }
-
- }
-
- internal interface IKeywordRecommender<TContext>
- {
- IEnumerable<RecommendedKeyword> RecommendKeywords(int position, TContext context, CancellationToken cancellationToken);
- }
-
class KeywordContextHandler : CompletionContextHandler
{
- static readonly IKeywordRecommender<CSharpSyntaxContext>[] recommender = {
+ static readonly IKeywordRecommender<CSharpSyntaxContext> [] recommenders = {
new AbstractKeywordRecommender(),
new AddKeywordRecommender(),
new AliasKeywordRecommender(),
@@ -131,6 +106,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
new JoinKeywordRecommender(),
new LetKeywordRecommender(),
new LineKeywordRecommender(),
+ new LoadKeywordRecommender(),
new LockKeywordRecommender(),
new LongKeywordRecommender(),
new MethodKeywordRecommender(),
@@ -190,10 +166,10 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
new VoidKeywordRecommender(),
new VolatileKeywordRecommender(),
new WarningKeywordRecommender(),
-// new WhenKeywordRecommender(),
+ new WhenKeywordRecommender(),
new WhereKeywordRecommender(),
new WhileKeywordRecommender(),
- new YieldKeywordRecommender()
+ new YieldKeywordRecommender(),
};
public override bool IsTriggerCharacter (Microsoft.CodeAnalysis.Text.SourceText text, int position)
@@ -204,30 +180,30 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
IsStartingNewWord (text, position);
}
- protected override Task<IEnumerable<CompletionData>> GetItemsWorkerAsync (CompletionResult completionResult, CompletionEngine engine, CompletionContext completionContext, CompletionTriggerInfo info, SyntaxContext ctx, CancellationToken cancellationToken)
+ protected override async Task<IEnumerable<CompletionData>> GetItemsWorkerAsync (CompletionResult completionResult, CompletionEngine engine, CompletionContext completionContext, CompletionTriggerInfo info, SyntaxContext ctx, CancellationToken cancellationToken)
{
var model = ctx.SemanticModel;
if (ctx.CSharpSyntaxContext.IsInNonUserCode) {
- return Task.FromResult (Enumerable.Empty<CompletionData> ());
+ return Enumerable.Empty<CompletionData> ();
}
if (ctx.TargetToken.IsKind (SyntaxKind.OverrideKeyword))
- return Task.FromResult (Enumerable.Empty<CompletionData> ());
+ return Enumerable.Empty<CompletionData> ();
if (info.CompletionTriggerReason == CompletionTriggerReason.CharTyped && info.TriggerCharacter == ' ') {
if (!ctx.CSharpSyntaxContext.IsEnumBaseListContext && !ctx.LeftToken.IsKind (SyntaxKind.EqualsToken) && !ctx.LeftToken.IsKind (SyntaxKind.EqualsEqualsToken))
- return Task.FromResult (Enumerable.Empty<CompletionData> ());
+ return Enumerable.Empty<CompletionData> ();
// completionResult.AutoCompleteEmptyMatch = false;
}
var result = new List<CompletionData> ();
- foreach (var r in recommender) {
- var recommended = r.RecommendKeywords (completionContext.Position, ctx.CSharpSyntaxContext, cancellationToken);
+ foreach (var r in recommenders) {
+ var recommended = await r.RecommendKeywordsAsync (completionContext.Position, ctx.CSharpSyntaxContext, cancellationToken).ConfigureAwait (false);
if (recommended == null)
continue;
foreach (var kw in recommended) {
- result.Add (engine.Factory.CreateKeywordCompletion (this, kw.Keyword, kw.Kind));
+ result.Add (engine.Factory.CreateKeywordCompletion (this, kw.Keyword));
}
}
@@ -240,7 +216,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
// if (parent.IsKind(SyntaxKind.TypeParameterConstraintClause)) {
// result.Add(factory.CreateGenericData (this, "new()", GenericDataType.PreprocessorKeyword));
// }
- return Task.FromResult ((IEnumerable<CompletionData>)result);
+ return result;
}
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/NamedParameterContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/NamedParameterContextHandler.cs
index 4d607424e5..45387c25bb 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/NamedParameterContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/NamedParameterContextHandler.cs
@@ -31,9 +31,11 @@ using Microsoft.CodeAnalysis;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using System.Linq;
+using Roslyn.Utilities;
using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.Ide.TypeSystem;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectCreationContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectCreationContextHandler.cs
index 82860d247a..f87e12097f 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectCreationContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectCreationContextHandler.cs
@@ -32,6 +32,10 @@ using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Roslyn.Utilities;
using System.Linq;
using MonoDevelop.Ide.CodeCompletion;
@@ -142,7 +146,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
for (int i = 0; i < primitiveTypesKeywords.Length; i++) {
var keyword = primitiveTypesKeywords [i];
- list.Add (engine.Factory.CreateKeywordCompletion (this, keyword, primitiveTypesKeywordKinds[i]));
+ list.Add (engine.Factory.CreateKeywordCompletion (this, keyword));
}
return list;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectInitializerContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectInitializerContextHandler.cs
index d1d0cc6ab6..675320e347 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectInitializerContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/ObjectInitializerContextHandler.cs
@@ -25,16 +25,17 @@
// THE SOFTWARE.
using System;
-using System.Linq;
-using System.Threading.Tasks;
using System.Collections.Generic;
+using System.Linq;
using System.Threading;
+using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.Ide.TypeSystem;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
@@ -94,8 +95,9 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
return false;
}
+ var enclosingSymbol = semanticModel.GetEnclosingNamedTypeOrAssembly (position, cancellationToken);
// Non-exclusive if initializedType can be initialized as a collection.
- if (initializedType.CanSupportCollectionInitializer ()) {
+ if (initializedType.CanSupportCollectionInitializer (enclosingSymbol)) {
return false;
}
@@ -123,18 +125,20 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
if (initializedType == null)
return Enumerable.Empty<CompletionData> ();
+ var enclosing = semanticModel.GetEnclosingNamedType (position, cancellationToken);
+
// Find the members that can be initialized. If we have a NamedTypeSymbol, also get the overridden members.
IEnumerable<ISymbol> members = semanticModel.LookupSymbols (position, initializedType);
members = members.Where (m => IsInitializable (m, initializedType) &&
- m.CanBeReferencedByName &&
- IsLegalFieldOrProperty (m) &&
- !m.IsImplicitlyDeclared);
+ m.CanBeReferencedByName &&
+ IsLegalFieldOrProperty (m, enclosing) &&
+ !m.IsImplicitlyDeclared);
// Filter out those members that have already been typed
var alreadyTypedMembers = GetInitializedMembers (semanticModel.SyntaxTree, position, cancellationToken);
var uninitializedMembers = members.Where (m => !alreadyTypedMembers.Contains (m.Name));
- uninitializedMembers = uninitializedMembers.Where (SymbolExtensions.IsEditorBrowsable);
+ uninitializedMembers = uninitializedMembers.Where (PortingExtensions.IsEditorBrowsable);
// var text = await semanticModel.SyntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
// var changes = GetTextChangeSpan(text, position);
@@ -147,10 +151,10 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
return list;
}
- static bool IsLegalFieldOrProperty (ISymbol symbol)
+ private bool IsLegalFieldOrProperty (ISymbol symbol, ISymbol within)
{
var type = symbol.GetMemberType ();
- if (type != null && type.CanSupportCollectionInitializer ()) {
+ if (type != null && type.CanSupportCollectionInitializer (within)) {
return true;
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/OverrideContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/OverrideContextHandler.cs
index 3ac1b29bc6..cbd93b859f 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/OverrideContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/OverrideContextHandler.cs
@@ -25,16 +25,16 @@
// THE SOFTWARE.
-using System.Linq;
-using System.Threading.Tasks;
using System.Collections.Generic;
+using System.Linq;
using System.Threading;
-using Microsoft.CodeAnalysis.CodeGeneration;
+using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis.CSharp;
-using System;
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Ide.TypeSystem;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/PartialContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/PartialContextHandler.cs
index 8f656edf60..ad38563295 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/PartialContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/PartialContextHandler.cs
@@ -24,16 +24,16 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System.Linq;
-using System.Threading.Tasks;
using System.Collections.Generic;
+using System.Linq;
using System.Threading;
-using Microsoft.CodeAnalysis.CodeGeneration;
+using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis.CSharp;
-using System;
using MonoDevelop.Ide.CodeCompletion;
namespace ICSharpCode.NRefactory6.CSharp.Completion
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/RoslynRecommendationsCompletionContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/RoslynRecommendationsCompletionContextHandler.cs
index ba0e749494..b176c2dba1 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/RoslynRecommendationsCompletionContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/RoslynRecommendationsCompletionContextHandler.cs
@@ -27,14 +27,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.CodeAnalysis.Recommendations;
-using Microsoft.CodeAnalysis;
using System.Threading;
-using Microsoft.CodeAnalysis.CSharp;
-
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Text;
using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.Recommendations;
using Microsoft.CodeAnalysis.Text;
using MonoDevelop.Ide.CodeCompletion;
@@ -69,14 +68,14 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
return IsException (type.BaseType);
}
- protected override Task<IEnumerable<CompletionData>> GetItemsWorkerAsync (CompletionResult completionResult, CompletionEngine engine, CompletionContext completionContext, CompletionTriggerInfo info, SyntaxContext ctx, CancellationToken cancellationToken)
+ protected override async Task<IEnumerable<CompletionData>> GetItemsWorkerAsync (CompletionResult completionResult, CompletionEngine engine, CompletionContext completionContext, CompletionTriggerInfo info, SyntaxContext ctx, CancellationToken cancellationToken)
{
var semanticModel = ctx.SemanticModel;
var result = new List<CompletionData> ();
if (info.TriggerCharacter == ' ') {
var newExpression = ObjectCreationContextHandler.GetObjectCreationNewExpression (ctx.SyntaxTree, completionContext.Position, cancellationToken);
if (newExpression == null && info.CompletionTriggerReason == CompletionTriggerReason.CharTyped && !ctx.LeftToken.IsKind (SyntaxKind.EqualsToken) && !ctx.LeftToken.IsKind (SyntaxKind.EqualsEqualsToken))
- return Task.FromResult (Enumerable.Empty<CompletionData> ());
+ return Enumerable.Empty<CompletionData> ();
completionResult.AutoCompleteEmptyMatch = false;
}
@@ -101,7 +100,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
};
var completionCategoryLookup = new Dictionary<string, CompletionCategory> ();
- foreach (var symbol in Recommender.GetRecommendedSymbolsAtPosition (semanticModel, completionContext.Position, engine.Workspace, null, cancellationToken)) {
+ foreach (var symbol in await Recommender.GetRecommendedSymbolsAtPositionAsync (semanticModel, completionContext.Position, engine.Workspace, null, cancellationToken)) {
if (symbol.Kind == SymbolKind.NamedType) {
if (isInAttribute) {
var type = (ITypeSymbol)symbol;
@@ -152,7 +151,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
}
addData (newData);
}
- return Task.FromResult ((IEnumerable<CompletionData>)result);
+ return (IEnumerable<CompletionData>)result;
}
protected override async Task<bool> IsSemanticTriggerCharacterAsync(Document document, int characterPosition, CancellationToken cancellationToken)
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SenderCompletionContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SenderCompletionContextHandler.cs
index 8d1ff8733a..c360be7411 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SenderCompletionContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SenderCompletionContextHandler.cs
@@ -23,17 +23,17 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Threading.Tasks;
using System.Collections.Generic;
-using System.Threading;
using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.Ide.TypeSystem;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
@@ -44,10 +44,10 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
var position = completionContext.Position;
var document = completionContext.Document;
var syntaxTree = ctx.SyntaxTree;
- if (syntaxTree.IsInNonUserCode(position, cancellationToken) ||
- syntaxTree.IsPreProcessorDirectiveContext(position, cancellationToken))
+ if (syntaxTree.IsInNonUserCode (position, cancellationToken) ||
+ syntaxTree.IsPreProcessorDirectiveContext (position, cancellationToken))
return Task.FromResult (Enumerable.Empty<CompletionData> ());
- if (!syntaxTree.IsRightOfDotOrArrowOrColonColon(position, cancellationToken))
+ if (!syntaxTree.IsRightOfDotOrArrowOrColonColon (position, cancellationToken))
return Task.FromResult (Enumerable.Empty<CompletionData> ());
var ma = ctx.LeftToken.Parent as MemberAccessExpressionSyntax;
if (ma == null)
@@ -59,7 +59,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
if (symbolInfo.Symbol == null || symbolInfo.Symbol.Kind != SymbolKind.Parameter)
return Task.FromResult (Enumerable.Empty<CompletionData> ());
var list = new List<CompletionData> ();
- var within = model.GetEnclosingNamedTypeOrAssembly(position, cancellationToken);
+ var within = model.GetEnclosingNamedTypeOrAssembly (position, cancellationToken);
var addedSymbols = new HashSet<string> ();
foreach (var ano in ma.AncestorsAndSelf ().OfType<AnonymousMethodExpressionSyntax> ()) {
@@ -73,7 +73,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
return Task.FromResult ((IEnumerable<CompletionData>)list);
}
- void Analyze (CompletionEngine engine,SemanticModel model, SyntaxNode node, ISymbol within, List<CompletionData> list, ParameterListSyntax parameterList, ISymbol symbol, HashSet<string> addedSymbols, CancellationToken cancellationToken)
+ void Analyze (CompletionEngine engine, SemanticModel model, SyntaxNode node, ISymbol within, List<CompletionData> list, ParameterListSyntax parameterList, ISymbol symbol, HashSet<string> addedSymbols, CancellationToken cancellationToken)
{
var type = CheckParameterList (model, parameterList, symbol, cancellationToken);
if (type == null)
@@ -86,7 +86,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
continue;
if (member.IsOrdinaryMethod () || member.Kind == SymbolKind.Field || member.Kind == SymbolKind.Property) {
if (member.IsAccessibleWithin (within)) {
- var completionData = engine.Factory.CreateCastCompletionData(this, member, node, startType);
+ var completionData = engine.Factory.CreateCastCompletionData (this, member, node, startType);
if (addedSymbols.Contains (completionData.DisplayText))
continue;
addedSymbols.Add (completionData.DisplayText);
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SnippetContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SnippetContextHandler.cs
index a37fef24e8..b12af36f4b 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SnippetContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SnippetContextHandler.cs
@@ -25,13 +25,15 @@
// THE SOFTWARE.
-using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using System.Linq;
using MonoDevelop.Ide.CodeCompletion;
@@ -44,21 +46,19 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
var document = completionContext.Document;
var position = completionContext.Position;
- var syntaxTree = await document.GetCSharpSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
+ var syntaxTree = await document.GetCSharpSyntaxTreeAsync (cancellationToken).ConfigureAwait (false);
- if (syntaxTree.IsInNonUserCode(position, cancellationToken) ||
- syntaxTree.IsRightOfDotOrArrowOrColonColon(position, cancellationToken) ||
- syntaxTree.GetContainingTypeOrEnumDeclaration(position, cancellationToken) is EnumDeclarationSyntax)
- {
- return Enumerable.Empty<CompletionData>();
+ if (syntaxTree.IsInNonUserCode (position, cancellationToken) ||
+ syntaxTree.IsRightOfDotOrArrowOrColonColon (position, cancellationToken) ||
+ syntaxTree.GetContainingTypeOrEnumDeclaration (position, cancellationToken) is EnumDeclarationSyntax) {
+ return Enumerable.Empty<CompletionData> ();
}
// var span = new TextSpan(position, 0);
-// var semanticModel = await document.GetCSharpSemanticModelForSpanAsync(span, cancellationToken).ConfigureAwait(false);
- if (syntaxTree.IsPreProcessorDirectiveContext(position, cancellationToken))
- {
- var directive = syntaxTree.GetRoot(cancellationToken).FindTokenOnLeftOfPosition(position, includeDirectives: true).GetAncestor<DirectiveTriviaSyntax>();
- if (directive.DirectiveNameToken.IsKind(
+ // var semanticModel = await document.GetCSharpSemanticModelForSpanAsync(span, cancellationToken).ConfigureAwait(false);
+ if (syntaxTree.IsPreProcessorDirectiveContext (position, cancellationToken)) {
+ var directive = syntaxTree.GetRoot (cancellationToken).FindTokenOnLeftOfPosition (position, includeDirectives: true).GetAncestor<DirectiveTriviaSyntax> ();
+ if (directive.DirectiveNameToken.IsKind (
SyntaxKind.IfKeyword,
SyntaxKind.RegionKeyword,
SyntaxKind.ElseKeyword,
@@ -69,34 +69,32 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
SyntaxKind.EndIfKeyword,
SyntaxKind.UndefKeyword,
SyntaxKind.EndRegionKeyword,
- SyntaxKind.WarningKeyword))
- {
- return Enumerable.Empty<CompletionData>();
+ SyntaxKind.WarningKeyword)) {
+ return Enumerable.Empty<CompletionData> ();
}
- return await GetSnippetCompletionItemsAsync(cancellationToken).ConfigureAwait(false);
+ return await GetSnippetCompletionItemsAsync (cancellationToken).ConfigureAwait (false);
}
var tokenLeftOfPosition = syntaxTree.FindTokenOnLeftOfPosition (position, cancellationToken);
- if (syntaxTree.IsGlobalStatementContext(position, cancellationToken) ||
- syntaxTree.IsExpressionContext(position, tokenLeftOfPosition, true, cancellationToken) ||
- syntaxTree.IsStatementContext(position, tokenLeftOfPosition, cancellationToken) ||
- syntaxTree.IsTypeContext(position, cancellationToken) ||
- syntaxTree.IsTypeDeclarationContext(position, tokenLeftOfPosition, cancellationToken) ||
- syntaxTree.IsNamespaceContext(position, cancellationToken) ||
- syntaxTree.IsMemberDeclarationContext(position, tokenLeftOfPosition, cancellationToken) ||
- syntaxTree.IsLabelContext(position, cancellationToken))
- {
- return await GetSnippetCompletionItemsAsync(cancellationToken).ConfigureAwait(false);
+ if (syntaxTree.IsGlobalStatementContext (position, cancellationToken) ||
+ syntaxTree.IsExpressionContext (position, tokenLeftOfPosition, true, cancellationToken) ||
+ syntaxTree.IsStatementContext (position, tokenLeftOfPosition, cancellationToken) ||
+ syntaxTree.IsTypeContext (position, cancellationToken) ||
+ syntaxTree.IsTypeDeclarationContext (position, tokenLeftOfPosition, cancellationToken) ||
+ syntaxTree.IsNamespaceContext (position, cancellationToken) ||
+ syntaxTree.IsMemberDeclarationContext (position, tokenLeftOfPosition, cancellationToken) ||
+ syntaxTree.IsLabelContext (position, cancellationToken)) {
+ return await GetSnippetCompletionItemsAsync (cancellationToken).ConfigureAwait (false);
}
- return Enumerable.Empty<CompletionData>();
+ return Enumerable.Empty<CompletionData> ();
}
- Task<IEnumerable<CompletionData>> GetSnippetCompletionItemsAsync(CancellationToken cancellationToken)
+ Task<IEnumerable<CompletionData>> GetSnippetCompletionItemsAsync (CancellationToken cancellationToken)
{
if (CompletionEngine.SnippetCallback == null)
- return Task.FromResult (Enumerable.Empty<CompletionData>());
+ return Task.FromResult (Enumerable.Empty<CompletionData> ());
return CompletionEngine.SnippetCallback (cancellationToken);
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeNameContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeNameContextHandler.cs
index a7692ddde8..9a0e55628b 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeNameContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeNameContextHandler.cs
@@ -25,14 +25,17 @@
// THE SOFTWARE.
using System;
-using System.Threading.Tasks;
using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp;
using System.Linq;
-using Microsoft.CodeAnalysis;
using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Ide.CodeCompletion;
namespace ICSharpCode.NRefactory6.CSharp.Completion
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeTContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeTContextHandler.cs
index 9c972e7a5f..346d9a1cde 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeTContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/SpeculativeTContextHandler.cs
@@ -32,6 +32,9 @@ using System.Threading;
using Microsoft.CodeAnalysis;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp;
using MonoDevelop.Ide.CodeCompletion;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/XmlDocCommentContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/XmlDocCommentContextHandler.cs
index f60ac12781..a7aedc555a 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/XmlDocCommentContextHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/XmlDocCommentContextHandler.cs
@@ -26,15 +26,18 @@
using System;
-using System.Threading.Tasks;
using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.Text;
using System.Linq;
-using Microsoft.CodeAnalysis.CSharp;
+using System.Threading;
+using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.Text;
using MonoDevelop.Ide.CodeCompletion;
+using Roslyn.Utilities;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ICompletionDataFactory.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ICompletionDataFactory.cs
index f1f5516f2a..bc173863c4 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ICompletionDataFactory.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ICompletionDataFactory.cs
@@ -42,7 +42,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
public interface ICompletionDataFactory
{
- CompletionData CreateKeywordCompletion (ICompletionDataKeyHandler keyHandler, string data, SyntaxKind syntaxKind);
+ CompletionData CreateKeywordCompletion (ICompletionDataKeyHandler keyHandler, string keyword);
CompletionData CreateGenericData (ICompletionDataKeyHandler keyHandler, string data, GenericDataType genericDataType = GenericDataType.Undefined);
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AbstractKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AbstractKeywordRecommender.cs
deleted file mode 100644
index 1cf1e8e40a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AbstractKeywordRecommender.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class AbstractKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.ExternKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword,
- SyntaxKind.OverrideKeyword,
- };
-
- private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword
- };
-
- public AbstractKeywordRecommender()
- : base(SyntaxKind.AbstractKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken) ||
- context.IsTypeDeclarationContext(
- validModifiers: s_validTypeModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AbstractSyntacticSingleKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AbstractSyntacticSingleKeywordRecommender.cs
deleted file mode 100644
index bdb9c6f847..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AbstractSyntacticSingleKeywordRecommender.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal abstract partial class AbstractSyntacticSingleKeywordRecommender : IKeywordRecommender<CSharpSyntaxContext>
- {
- private readonly bool _isValidInPreprocessorContext;
-
- protected internal SyntaxKind KeywordKind { get; private set; }
-
- internal bool ShouldFormatOnCommit { get; private set; }
-
- protected AbstractSyntacticSingleKeywordRecommender(
- SyntaxKind keywordKind,
- bool isValidInPreprocessorContext = false,
- bool shouldFormatOnCommit = false)
- {
- this.KeywordKind = keywordKind;
- _isValidInPreprocessorContext = isValidInPreprocessorContext;
- this.ShouldFormatOnCommit = shouldFormatOnCommit;
- }
-
- protected abstract bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken);
-
- public IEnumerable<RecommendedKeyword> RecommendKeywords(
- int position,
- CSharpSyntaxContext context,
- CancellationToken cancellationToken)
- {
- var syntaxKind = this.RecommendKeyword(position, context, cancellationToken);
- if (syntaxKind.HasValue)
- {
- return new [] {
- new RecommendedKeyword(SyntaxFacts.GetText(syntaxKind.Value), syntaxKind.Value, shouldFormatOnCommit: this.ShouldFormatOnCommit)
- };
- }
-
- return null;
- }
-
- internal IEnumerable<RecommendedKeyword> RecommendKeywords_Test(int position, CSharpSyntaxContext context)
- {
- var syntaxKind = this.RecommendKeyword(position, context, CancellationToken.None);
- if (syntaxKind.HasValue)
- {
- return new [] {
- new RecommendedKeyword(SyntaxFacts.GetText(syntaxKind.Value), syntaxKind.Value)
- };
- }
-
- return null;
- }
-
- private SyntaxKind? RecommendKeyword(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // NOTE: The collector ensures that we're not in "NonUserCode" like comments, strings, inactive code
- // for perf reasons.
- var syntaxTree = context.SemanticModel.SyntaxTree;
- if (!_isValidInPreprocessorContext &&
- context.IsPreProcessorDirectiveContext)
- {
- return null;
- }
-
- if (!IsValidContext(position, context, cancellationToken))
- {
- return null;
- }
-
- return this.KeywordKind;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AddKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AddKeywordRecommender.cs
deleted file mode 100644
index 672e0502a2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AddKeywordRecommender.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class AddKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public AddKeywordRecommender()
- : base(SyntaxKind.AddKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.TargetToken.IsAccessorDeclarationContext<EventDeclarationSyntax>(position, SyntaxKind.AddKeyword);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AliasKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AliasKeywordRecommender.cs
deleted file mode 100644
index 3d6b87302a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AliasKeywordRecommender.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class AliasKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public AliasKeywordRecommender()
- : base(SyntaxKind.AliasKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // extern |
- // extern a|
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.ExternKeyword)
- {
- // members can be 'extern' but we don't want
- // 'alias' to show up in a 'type'.
- return token.GetAncestor<TypeDeclarationSyntax>() == null;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AsKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AsKeywordRecommender.cs
deleted file mode 100644
index 3d667239aa..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AsKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class AsKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public AsKeywordRecommender()
- : base(SyntaxKind.AsKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return !context.IsInNonUserCode && context.IsIsOrAsContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AscendingKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AscendingKeywordRecommender.cs
deleted file mode 100644
index ec3e54f007..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AscendingKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class AscendingKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public AscendingKeywordRecommender()
- : base(SyntaxKind.AscendingKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.TargetToken.IsOrderByDirectionContext();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AssemblyKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AssemblyKeywordRecommender.cs
deleted file mode 100644
index 31cb8b3a47..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AssemblyKeywordRecommender.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class AssemblyKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public AssemblyKeywordRecommender()
- : base(SyntaxKind.AssemblyKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsTypeAttributeContext(cancellationToken))
- {
- var token = context.LeftToken;
- var type = token.GetAncestor<MemberDeclarationSyntax>();
-
- return type == null || type.IsParentKind(SyntaxKind.CompilationUnit);
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AsyncKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AsyncKeywordRecommender.cs
deleted file mode 100644
index 49abcb325d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AsyncKeywordRecommender.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class AsyncKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public AsyncKeywordRecommender() :
- base(SyntaxKind.AsyncKeyword, isValidInPreprocessorContext: false)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsAnyExpressionContext)
- {
- return true;
- }
-
- return !context.TargetToken.IsKindOrHasMatchingText(SyntaxKind.PartialKeyword)
- && InMemberDeclarationContext(position, context, cancellationToken);
- }
-
- private static bool InMemberDeclarationContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.SyntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken)
- || context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: true,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AwaitKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AwaitKeywordRecommender.cs
deleted file mode 100644
index c2604eaad6..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/AwaitKeywordRecommender.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class AwaitKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public AwaitKeywordRecommender()
- : base(SyntaxKind.AwaitKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsAnyExpressionContext || context.IsStatementContext)
- {
- foreach (var node in context.LeftToken.GetAncestors<SyntaxNode>())
- {
- if (node.IsAnyLambdaOrAnonymousMethod())
- {
- return true;
- }
-
- if (node.IsKind(SyntaxKind.QueryExpression))
- {
- return false;
- }
-
- if (node.IsKind(SyntaxKind.LockStatement))
- {
- var lockStatement = (LockStatementSyntax)node;
- if (lockStatement.Statement != null &&
- !lockStatement.Statement.IsMissing &&
- lockStatement.Statement.Span.Contains(position))
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BaseKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BaseKeywordRecommender.cs
deleted file mode 100644
index 68206249d8..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BaseKeywordRecommender.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class BaseKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public BaseKeywordRecommender()
- : base(SyntaxKind.BaseKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // We need to at least be in a type declaration context. This prevents us from showing
- // calls to 'base' in things like top level repl statements and whatnot.
- if (context.ContainingTypeDeclaration != null)
- {
- return
- IsConstructorInitializerContext(position, context, cancellationToken) ||
- IsInstanceExpressionOrStatement(context);
- }
-
- return false;
- }
-
- private static bool IsInstanceExpressionOrStatement(CSharpSyntaxContext context)
- {
- if (context.IsInstanceContext)
- {
- return context.IsNonAttributeExpressionContext || context.IsStatementContext;
- }
-
- return false;
- }
-
- private bool IsConstructorInitializerContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // Foo() : |
-
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.ColonToken &&
- token.Parent is ConstructorInitializerSyntax &&
- token.Parent.IsParentKind(SyntaxKind.ConstructorDeclaration) &&
- token.Parent.GetParent().IsParentKind(SyntaxKind.ClassDeclaration))
- {
- var constructor = token.GetAncestor<ConstructorDeclarationSyntax>();
- if (constructor.Modifiers.Any(t => t.Kind () == SyntaxKind.StaticKeyword))
- {
- return false;
- }
-
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BoolKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BoolKeywordRecommender.cs
deleted file mode 100644
index 44c5b2322f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BoolKeywordRecommender.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class BoolKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public BoolKeywordRecommender()
- : base(SyntaxKind.BoolKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BreakKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BreakKeywordRecommender.cs
deleted file mode 100644
index 8275ac1434..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/BreakKeywordRecommender.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class BreakKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public BreakKeywordRecommender()
- : base(SyntaxKind.BreakKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsInBreakableConstructContext(context) ||
- context.TargetToken.IsAfterYieldKeyword();
- }
-
- private static bool IsInBreakableConstructContext(CSharpSyntaxContext context)
- {
- if (!context.IsStatementContext)
- {
- return false;
- }
-
- // allowed if we're inside a loop/switch construct.
-
- var token = context.LeftToken;
- foreach (var v in token.GetAncestors<SyntaxNode>())
- {
- if (v.IsAnyLambdaOrAnonymousMethod())
- {
- // if we hit a lambda while walking up, then we can't
- // 'continue' any outer loops.
- return false;
- }
-
- if (v.IsBreakableConstruct())
- {
- return true;
- }
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ByKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ByKeywordRecommender.cs
deleted file mode 100644
index 07d5db338e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ByKeywordRecommender.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ByKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ByKeywordRecommender()
- : base(SyntaxKind.ByKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // group e |
- // group e b|
-
- var token = context.LeftToken;
- var group = token.GetAncestor<GroupClauseSyntax>();
-
- if (group == null)
- {
- return false;
- }
-
- var lastToken = group.GroupExpression.GetLastToken(includeSkipped: true);
-
- // group e |
- if (!token.IntersectsWith(position) &&
- token == lastToken)
- {
- return true;
- }
-
- // group e b|
- if (token.IntersectsWith(position) &&
- token.Kind() == SyntaxKind.IdentifierToken &&
- token.GetPreviousToken(includeSkipped: true) == lastToken)
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ByteKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ByteKeywordRecommender.cs
deleted file mode 100644
index c40eb00cd7..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ByteKeywordRecommender.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ByteKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ByteKeywordRecommender()
- : base(SyntaxKind.ByteKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
-
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsEnumBaseListContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CaseKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CaseKeywordRecommender.cs
deleted file mode 100644
index c8e9c0f1db..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CaseKeywordRecommender.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class CaseKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public CaseKeywordRecommender()
- : base(SyntaxKind.CaseKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.TargetToken.IsSwitchLabelContext() ||
- IsAfterGotoInSwitchContext(context);
- }
-
- internal static bool IsAfterGotoInSwitchContext(CSharpSyntaxContext context)
- {
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.GotoKeyword &&
- token.GetAncestor<SwitchStatementSyntax>() != null)
- {
- // todo: what if we're in a lambda... or a try/finally or
- // something? Might want to filter this out.
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CatchKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CatchKeywordRecommender.cs
deleted file mode 100644
index 26433adf28..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CatchKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class CatchKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public CatchKeywordRecommender()
- : base(SyntaxKind.CatchKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.SyntaxTree.IsCatchOrFinallyContext(position, context.LeftToken, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CharKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CharKeywordRecommender.cs
deleted file mode 100644
index a0d530742c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CharKeywordRecommender.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class CharKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public CharKeywordRecommender()
- : base(SyntaxKind.CharKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CheckedKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CheckedKeywordRecommender.cs
deleted file mode 100644
index bdcb72853d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/CheckedKeywordRecommender.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class CheckedKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public CheckedKeywordRecommender()
- : base(SyntaxKind.CheckedKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsNonAttributeExpressionContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ChecksumKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ChecksumKeywordRecommender.cs
deleted file mode 100644
index 14aceee892..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ChecksumKeywordRecommender.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ChecksumKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ChecksumKeywordRecommender()
- : base(SyntaxKind.ChecksumKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // # pragma |
- // # pragma w|
- var previousToken1 = context.TargetToken;
- var previousToken2 = previousToken1.GetPreviousToken(includeSkipped: true);
-
- return
- previousToken1.Kind() == SyntaxKind.PragmaKeyword &&
- previousToken2.Kind() == SyntaxKind.HashToken;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ClassKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ClassKeywordRecommender.cs
deleted file mode 100644
index 47a255c363..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ClassKeywordRecommender.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ClassKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.AbstractKeyword,
- SyntaxKind.SealedKeyword,
- SyntaxKind.StaticKeyword,
- SyntaxKind.UnsafeKeyword
- };
-
- public ClassKeywordRecommender()
- : base(SyntaxKind.ClassKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsGlobalStatementContext ||
- context.IsTypeDeclarationContext(
- validModifiers: s_validModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: true,
- cancellationToken: cancellationToken) ||
- syntaxTree.IsTypeParameterConstraintStartContext(position, context.LeftToken, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ConstKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ConstKeywordRecommender.cs
deleted file mode 100644
index 49710fe6ed..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ConstKeywordRecommender.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ConstKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PrivateKeyword,
- };
-
- private static readonly ISet<SyntaxKind> s_validGlobalModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PrivateKeyword,
- };
-
- public ConstKeywordRecommender()
- : base(SyntaxKind.ConstKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsMemberDeclarationContext(context, cancellationToken) ||
- IsLocalVariableDeclaration(context);
- }
-
- private bool IsMemberDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, s_validGlobalModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
-
- private bool IsLocalVariableDeclaration(CSharpSyntaxContext context)
- {
- // cases:
- // void Foo() {
- // |
- //
- // |
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ContinueKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ContinueKeywordRecommender.cs
deleted file mode 100644
index e2f1aeb73b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ContinueKeywordRecommender.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ContinueKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ContinueKeywordRecommender()
- : base(SyntaxKind.ContinueKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (!context.IsStatementContext)
- {
- return false;
- }
-
- // allowed if we're inside a loop construct.
-
- var leaf = context.LeftToken;
- foreach (var v in leaf.GetAncestors<SyntaxNode>())
- {
- if (v.IsAnyLambdaOrAnonymousMethod())
- {
- // if we hit a lambda while walking up, then we can't
- // 'continue' any outer loops.
- return false;
- }
-
- if (v.IsContinuableConstruct())
- {
- return true;
- }
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DecimalKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DecimalKeywordRecommender.cs
deleted file mode 100644
index e0280702fb..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DecimalKeywordRecommender.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class DecimalKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public DecimalKeywordRecommender()
- : base(SyntaxKind.DecimalKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DefaultKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DefaultKeywordRecommender.cs
deleted file mode 100644
index 935b5b62eb..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DefaultKeywordRecommender.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class DefaultKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public DefaultKeywordRecommender()
- : base(SyntaxKind.DefaultKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsValidPreProcessorContext(context) ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsAnyExpressionContext ||
- context.TargetToken.IsSwitchLabelContext();
- }
-
- private static bool IsValidPreProcessorContext(CSharpSyntaxContext context)
- {
- // cases:
- // #line |
- // #line d|
- // # line |
- // # line d|
-
- var previousToken1 = context.TargetToken;
- var previousToken2 = previousToken1.GetPreviousToken(includeSkipped: true);
-
- return
- previousToken1.Kind() == SyntaxKind.LineKeyword &&
- previousToken2.Kind() == SyntaxKind.HashToken;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DefineKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DefineKeywordRecommender.cs
deleted file mode 100644
index 5ff0f4412a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DefineKeywordRecommender.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class DefineKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public DefineKeywordRecommender()
- : base(SyntaxKind.DefineKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- syntaxTree.IsBeforeFirstToken(position, cancellationToken) &&
- context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DelegateKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DelegateKeywordRecommender.cs
deleted file mode 100644
index 42049a0b93..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DelegateKeywordRecommender.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class DelegateKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.InternalKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword
- };
-
- public DelegateKeywordRecommender()
- : base(SyntaxKind.DelegateKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- (context.IsNonAttributeExpressionContext && !context.IsConstantExpressionContext) ||
- IsAfterAsyncKeywordInExpressionContext(context, cancellationToken) ||
- context.IsTypeDeclarationContext(
- validModifiers: s_validModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
-
- private static bool IsAfterAsyncKeywordInExpressionContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.TargetToken.IsKindOrHasMatchingText(SyntaxKind.AsyncKeyword) &&
- context.SyntaxTree.IsExpressionContext(
- context.TargetToken.SpanStart,
- context.TargetToken,
- attributes: false,
- cancellationToken: cancellationToken,
- semanticModelOpt: context.SemanticModel);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DescendingKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DescendingKeywordRecommender.cs
deleted file mode 100644
index 0c62897af0..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DescendingKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class DescendingKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public DescendingKeywordRecommender()
- : base(SyntaxKind.DescendingKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.TargetToken.IsOrderByDirectionContext();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DisableKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DisableKeywordRecommender.cs
deleted file mode 100644
index 87e5166b5d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DisableKeywordRecommender.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class DisableKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public DisableKeywordRecommender()
- : base(SyntaxKind.DisableKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // # pragma warning |
- // # pragma warning d|
- var previousToken1 = context.TargetToken;
- var previousToken2 = previousToken1.GetPreviousToken(includeSkipped: true);
- var previousToken3 = previousToken2.GetPreviousToken(includeSkipped: true);
-
- return
- previousToken1.Kind() == SyntaxKind.WarningKeyword &&
- previousToken2.Kind() == SyntaxKind.PragmaKeyword &&
- previousToken3.Kind() == SyntaxKind.HashToken;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DoKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DoKeywordRecommender.cs
deleted file mode 100644
index ca525b4868..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DoKeywordRecommender.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class DoKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public DoKeywordRecommender()
- : base(SyntaxKind.DoKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DoubleKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DoubleKeywordRecommender.cs
deleted file mode 100644
index 51330c929c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DoubleKeywordRecommender.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class DoubleKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public DoubleKeywordRecommender()
- : base(SyntaxKind.DoubleKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DynamicKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DynamicKeywordRecommender.cs
deleted file mode 100644
index 6f45d48507..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/DynamicKeywordRecommender.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class DynamicKeywordRecommender : IKeywordRecommender<CSharpSyntaxContext>
- {
- private bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- if (context.IsPreProcessorDirectiveContext)
- {
- return false;
- }
-
- return IsDynamicTypeContext(position, context, cancellationToken);
- }
-
- public IEnumerable<RecommendedKeyword> RecommendKeywords(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (IsValidContext(position, context, cancellationToken))
- {
- yield return new RecommendedKeyword("dynamic", SyntaxKind.IdentifierToken);
- }
- }
-
- protected static bool IsDynamicTypeContext(
- int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
-
- // first do quick exit check
- if (syntaxTree.IsDefinitelyNotTypeContext(position, cancellationToken))
- {
- return false;
- }
-
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsDefiniteCastTypeContext ||
- syntaxTree.IsPossibleCastTypeContext(position, context.LeftToken, cancellationToken) ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsIsOrAsTypeContext ||
- syntaxTree.IsDefaultExpressionContext(position, context.LeftToken, cancellationToken) ||
- context.IsLocalVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ElifKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ElifKeywordRecommender.cs
deleted file mode 100644
index 0d2b5d21b9..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ElifKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ElifKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ElifKeywordRecommender()
- : base(SyntaxKind.ElifKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ElseKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ElseKeywordRecommender.cs
deleted file mode 100644
index 9c6acbd43d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ElseKeywordRecommender.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ElseKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ElseKeywordRecommender()
- : base(SyntaxKind.ElseKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsPreProcessorKeywordContext)
- {
- return true;
- }
-
- var token = context.TargetToken;
-
- var statement = token.GetAncestor<StatementSyntax>();
- var ifStatement = statement.GetAncestorOrThis<IfStatementSyntax>();
-
- if (statement == null || ifStatement == null)
- {
- return false;
- }
-
- // cases:
- // if (foo)
- // Console.WriteLine();
- // |
- // if (foo)
- // Console.WriteLine();
- // e|
- if (token.IsKind(SyntaxKind.SemicolonToken) && ifStatement.Statement.GetLastToken(includeSkipped: true) == token)
- {
- return true;
- }
-
- // if (foo) {
- // Console.WriteLine();
- // } |
- // if (foo) {
- // Console.WriteLine();
- // } e|
- if (token.IsKind(SyntaxKind.CloseBraceToken) && ifStatement.Statement is BlockSyntax && token == ((BlockSyntax)ifStatement.Statement).CloseBraceToken)
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EndIfKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EndIfKeywordRecommender.cs
deleted file mode 100644
index 0042a43660..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EndIfKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class EndIfKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public EndIfKeywordRecommender()
- : base(SyntaxKind.EndIfKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EndRegionKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EndRegionKeywordRecommender.cs
deleted file mode 100644
index 741c814181..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EndRegionKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class EndRegionKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public EndRegionKeywordRecommender()
- : base(SyntaxKind.EndRegionKeyword, isValidInPreprocessorContext: true, shouldFormatOnCommit: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EnumKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EnumKeywordRecommender.cs
deleted file mode 100644
index 69d31fad97..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EnumKeywordRecommender.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class EnumKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.InternalKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- };
-
- public EnumKeywordRecommender()
- : base(SyntaxKind.EnumKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- context.IsTypeDeclarationContext(
- validModifiers: s_validModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EqualsKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EqualsKeywordRecommender.cs
deleted file mode 100644
index e2f4bd912a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EqualsKeywordRecommender.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class EqualsKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public EqualsKeywordRecommender()
- : base(SyntaxKind.EqualsKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // join a in expr o1 |
- // join a in expr o1 e|
-
- var token = context.TargetToken;
-
- var join = token.GetAncestor<JoinClauseSyntax>();
- if (join == null)
- {
- return false;
- }
-
- var lastToken = join.LeftExpression.GetLastToken(includeSkipped: true);
-
- // join a in expr |
- if (join.LeftExpression.Width() > 0 &&
- token == lastToken)
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ErrorKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ErrorKeywordRecommender.cs
deleted file mode 100644
index 5e21f268ae..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ErrorKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ErrorKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ErrorKeywordRecommender()
- : base(SyntaxKind.ErrorKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EventKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EventKeywordRecommender.cs
deleted file mode 100644
index 04c955265e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EventKeywordRecommender.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class EventKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.StaticKeyword,
- SyntaxKind.VirtualKeyword,
- SyntaxKind.SealedKeyword,
- SyntaxKind.OverrideKeyword,
- SyntaxKind.AbstractKeyword,
- SyntaxKind.ExternKeyword,
- SyntaxKind.UnsafeKeyword
- };
-
- public EventKeywordRecommender()
- : base(SyntaxKind.EventKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsGlobalStatementContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(validModifiers: s_validModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken) ||
- context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ExplicitKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ExplicitKeywordRecommender.cs
deleted file mode 100644
index 7931912b56..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ExplicitKeywordRecommender.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ExplicitKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.StaticKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ExternKeyword,
- SyntaxKind.UnsafeKeyword,
- };
-
- public ExplicitKeywordRecommender()
- : base(SyntaxKind.ExplicitKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsMemberDeclarationContext(validModifiers: s_validMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- // operators must be both public and static
- var modifiers = context.PrecedingModifiers;
-
- return
- modifiers.Contains(SyntaxKind.PublicKeyword) &&
- modifiers.Contains(SyntaxKind.StaticKeyword);
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ExternKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ExternKeywordRecommender.cs
deleted file mode 100644
index 7c6f740ab9..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ExternKeywordRecommender.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ExternKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.OverrideKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.SealedKeyword,
- SyntaxKind.StaticKeyword,
- SyntaxKind.UnsafeKeyword,
- SyntaxKind.VirtualKeyword,
- };
-
- private static readonly ISet<SyntaxKind> s_validGlobalModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.StaticKeyword,
- SyntaxKind.UnsafeKeyword,
- };
-
- public ExternKeywordRecommender()
- : base(SyntaxKind.ExternKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- IsExternAliasContext(context) ||
- context.IsGlobalStatementContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, s_validGlobalModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
-
- private static bool IsExternAliasContext(CSharpSyntaxContext context)
- {
- // cases:
- // root: |
-
- // root: e|
-
- // extern alias a;
- // |
-
- // extern alias a;
- // e|
-
- // all the above, but inside a namespace.
- // usings and other constructs *cannot* precede.
-
- var token = context.TargetToken;
-
- // root: |
- if (token.Kind() == SyntaxKind.None)
- {
- // root namespace
- return true;
- }
-
- if (token.Kind() == SyntaxKind.OpenBraceToken &&
- token.Parent.IsKind(SyntaxKind.NamespaceDeclaration))
- {
- return true;
- }
-
- // extern alias a;
- // |
- if (token.Kind() == SyntaxKind.SemicolonToken &&
- token.Parent.IsKind(SyntaxKind.ExternAliasDirective))
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FalseKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FalseKeywordRecommender.cs
deleted file mode 100644
index 1fa404a42b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FalseKeywordRecommender.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class FalseKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public FalseKeywordRecommender()
- : base(SyntaxKind.FalseKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsAnyExpressionContext ||
- context.IsPreProcessorExpressionContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.TargetToken.IsUnaryOperatorContext();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FieldKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FieldKeywordRecommender.cs
deleted file mode 100644
index cb50cf176b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FieldKeywordRecommender.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class FieldKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- // interfaces don't have members that you can put a [field:] attribute on
- private static readonly ISet<SyntaxKind> s_validTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.StructDeclaration,
- SyntaxKind.ClassDeclaration,
- SyntaxKind.EnumDeclaration,
- };
-
- public FieldKeywordRecommender()
- : base(SyntaxKind.FieldKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsMemberAttributeContext(s_validTypeDeclarations, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FinallyKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FinallyKeywordRecommender.cs
deleted file mode 100644
index 0ac6a78e75..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FinallyKeywordRecommender.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class FinallyKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public FinallyKeywordRecommender()
- : base(SyntaxKind.FinallyKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return syntaxTree.IsCatchOrFinallyContext(position, context.LeftToken, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FixedKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FixedKeywordRecommender.cs
deleted file mode 100644
index 371916e0a6..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FixedKeywordRecommender.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class FixedKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.UnsafeKeyword,
- };
-
- public FixedKeywordRecommender()
- : base(SyntaxKind.FixedKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsUnsafeStatementContext(context) ||
- IsMemberDeclarationContext(context, cancellationToken);
- }
-
- private static bool IsMemberDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.TargetToken.IsUnsafeContext() &&
- (context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(validModifiers: s_validModifiers, validTypeDeclarations: SyntaxKindSet.StructOnlyTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken));
- }
-
- private static bool IsUnsafeStatementContext(CSharpSyntaxContext context)
- {
- return
- context.TargetToken.IsUnsafeContext() &&
- context.IsStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FloatKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FloatKeywordRecommender.cs
deleted file mode 100644
index e5759bfcd8..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FloatKeywordRecommender.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class FloatKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public FloatKeywordRecommender()
- : base(SyntaxKind.FloatKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ForEachKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ForEachKeywordRecommender.cs
deleted file mode 100644
index f39dc09669..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ForEachKeywordRecommender.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ForEachKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ForEachKeywordRecommender()
- : base(SyntaxKind.ForEachKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ForKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ForKeywordRecommender.cs
deleted file mode 100644
index 6013d73f54..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ForKeywordRecommender.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ForKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ForKeywordRecommender()
- : base(SyntaxKind.ForKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FromKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FromKeywordRecommender.cs
deleted file mode 100644
index c9db4eda7f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/FromKeywordRecommender.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class FromKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public FromKeywordRecommender()
- : base(SyntaxKind.FromKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsGlobalStatementContext ||
- syntaxTree.IsValidContextForFromClause(position, context.LeftToken, cancellationToken, semanticModelOpt: context.SemanticModel);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GetKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GetKeywordRecommender.cs
deleted file mode 100644
index 22fe43af57..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GetKeywordRecommender.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class GetKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public GetKeywordRecommender()
- : base(SyntaxKind.GetKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.TargetToken.IsAccessorDeclarationContext<PropertyDeclarationSyntax>(position, SyntaxKind.GetKeyword) ||
- context.TargetToken.IsAccessorDeclarationContext<IndexerDeclarationSyntax>(position, SyntaxKind.GetKeyword);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GlobalKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GlobalKeywordRecommender.cs
deleted file mode 100644
index 7cb8df670e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GlobalKeywordRecommender.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class GlobalKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public GlobalKeywordRecommender()
- : base(SyntaxKind.GlobalKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
-
- if (syntaxTree.IsMemberDeclarationContext(position, context.LeftToken, cancellationToken))
- {
- var token = context.TargetToken;
-
- if (token.GetAncestor<EnumDeclarationSyntax>() == null)
- {
- return true;
- }
- }
-
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsAnyExpressionContext ||
- context.IsObjectCreationTypeContext ||
- context.IsIsOrAsTypeContext ||
- syntaxTree.IsUsingAliasContext(position, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GotoKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GotoKeywordRecommender.cs
deleted file mode 100644
index e252d97856..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GotoKeywordRecommender.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class GotoKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public GotoKeywordRecommender()
- : base(SyntaxKind.GotoKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GroupKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GroupKeywordRecommender.cs
deleted file mode 100644
index 401c5825d6..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/GroupKeywordRecommender.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class GroupKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public GroupKeywordRecommender()
- : base(SyntaxKind.GroupKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var token = context.TargetToken;
-
- // var q = from x in y
- // |
- if (!token.IntersectsWith(position) &&
- token.IsLastTokenOfQueryClause())
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/HiddenKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/HiddenKeywordRecommender.cs
deleted file mode 100644
index f7047a9dcf..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/HiddenKeywordRecommender.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class HiddenKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public HiddenKeywordRecommender()
- : base(SyntaxKind.HiddenKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // #line |
- // #line h|
- // # line |
- // # line h|
-
- var previousToken1 = context.TargetToken;
- var previousToken2 = previousToken1.GetPreviousToken(includeSkipped: true);
-
- return
- previousToken1.Kind() == SyntaxKind.LineKeyword &&
- previousToken2.Kind() == SyntaxKind.HashToken;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IfKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IfKeywordRecommender.cs
deleted file mode 100644
index dd5839e814..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IfKeywordRecommender.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class IfKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public IfKeywordRecommender()
- : base(SyntaxKind.IfKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsPreProcessorKeywordContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ImplicitKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ImplicitKeywordRecommender.cs
deleted file mode 100644
index ba32b643c0..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ImplicitKeywordRecommender.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ImplicitKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.StaticKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ExternKeyword,
- SyntaxKind.UnsafeKeyword,
- };
-
- public ImplicitKeywordRecommender()
- : base(SyntaxKind.ImplicitKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsMemberDeclarationContext(validModifiers: s_validMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- // operators must be both public and static
- var modifiers = context.PrecedingModifiers;
-
- return
- modifiers.Contains(SyntaxKind.PublicKeyword) &&
- modifiers.Contains(SyntaxKind.StaticKeyword);
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InKeywordRecommender.cs
deleted file mode 100644
index f8c14fef53..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InKeywordRecommender.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class InKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public InKeywordRecommender()
- : base(SyntaxKind.InKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsValidContextInForEachClause(context) ||
- IsValidContextInFromClause(context, cancellationToken) ||
- IsValidContextInJoinClause(context, cancellationToken) ||
- context.TargetToken.IsTypeParameterVarianceContext();
- }
-
- private bool IsValidContextInForEachClause(CSharpSyntaxContext context)
- {
- // cases:
- // foreach (var v |
- // foreach (var v i|
-
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.IdentifierToken)
- {
- var statement = token.GetAncestor<ForEachStatementSyntax>();
- if (statement != null && token == statement.Identifier)
- {
- return true;
- }
- }
-
- return false;
- }
-
- private bool IsValidContextInFromClause(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.IdentifierToken)
- {
- // case:
- // from x |
- if (token.GetPreviousToken(includeSkipped: true).IsKindOrHasMatchingText(SyntaxKind.FromKeyword))
- {
- var typeSyntax = token.Parent as TypeSyntax;
- if (!typeSyntax.IsPotentialTypeName(context.SemanticModel, cancellationToken))
- {
- return true;
- }
- }
-
- var fromClause = token.Parent as FromClauseSyntax;
- if (fromClause != null)
- {
- // case:
- // from int x |
- if (token == fromClause.Identifier && fromClause.Type != null)
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- private bool IsValidContextInJoinClause(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.IdentifierToken)
- {
- var joinClause = token.Parent.FirstAncestorOrSelf<JoinClauseSyntax>();
- if (joinClause != null)
- {
- // case:
- // join int x |
- if (token == joinClause.Identifier && joinClause.Type != null)
- {
- return true;
- }
-
- // case:
- // join x |
- if (joinClause.Type != null &&
- joinClause.Type.IsKind(SyntaxKind.IdentifierName) &&
- token == ((IdentifierNameSyntax)joinClause.Type).Identifier &&
- !joinClause.Type.IsPotentialTypeName(context.SemanticModel, cancellationToken))
- {
- return true;
- }
- }
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IntKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IntKeywordRecommender.cs
deleted file mode 100644
index 91dc5e0fe8..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IntKeywordRecommender.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class IntKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public IntKeywordRecommender()
- : base(SyntaxKind.IntKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsEnumBaseListContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InterfaceKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InterfaceKeywordRecommender.cs
deleted file mode 100644
index 56107f6ff0..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InterfaceKeywordRecommender.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class InterfaceKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.InternalKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword
- };
-
- public InterfaceKeywordRecommender()
- : base(SyntaxKind.InterfaceKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- context.IsTypeDeclarationContext(
- validModifiers: s_validModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: true,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InternalKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InternalKeywordRecommender.cs
deleted file mode 100644
index 9e975f2735..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/InternalKeywordRecommender.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class InternalKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public InternalKeywordRecommender()
- : base(SyntaxKind.InternalKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- IsValidContextForAccessor(context) ||
- IsValidContextForType(context, cancellationToken) ||
- IsValidContextForMember(context, cancellationToken);
- }
-
- private static bool IsValidContextForAccessor(CSharpSyntaxContext context)
- {
- if (context.TargetToken.IsAccessorDeclarationContext<PropertyDeclarationSyntax>(context.Position) ||
- context.TargetToken.IsAccessorDeclarationContext<IndexerDeclarationSyntax>(context.Position))
- {
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool CheckPreviousAccessibilityModifiers(CSharpSyntaxContext context)
- {
- // internal things can be protected.
- var precedingModifiers = context.PrecedingModifiers;
- return
- !precedingModifiers.Contains(SyntaxKind.PublicKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.InternalKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.PrivateKeyword);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IntoKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IntoKeywordRecommender.cs
deleted file mode 100644
index d19d8dcf64..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IntoKeywordRecommender.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class IntoKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public IntoKeywordRecommender()
- : base(SyntaxKind.IntoKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsValidContextForJoin(context) ||
- IsValidContextForSelect(context) ||
- IsValidContextForGroup(context);
- }
-
- private bool IsValidContextForSelect(CSharpSyntaxContext context)
- {
- var token = context.TargetToken;
-
- var select = token.GetAncestor<SelectClauseSyntax>();
- if (select == null)
- {
- return false;
- }
-
- if (select.Expression.Width() == 0)
- {
- return false;
- }
-
- var lastToken = select.Expression.GetLastToken(includeSkipped: true);
-
- if (lastToken == token)
- {
- return true;
- }
-
- return false;
- }
-
- private bool IsValidContextForGroup(CSharpSyntaxContext context)
- {
- var token = context.TargetToken;
-
- var group = token.GetAncestor<GroupClauseSyntax>();
- if (group == null)
- {
- return false;
- }
-
- if (group.ByExpression.Width() == 0 ||
- group.GroupExpression.Width() == 0)
- {
- return false;
- }
-
- var lastToken = group.ByExpression.GetLastToken(includeSkipped: true);
-
- if (lastToken == token)
- {
- return true;
- }
-
- return false;
- }
-
- private static bool IsValidContextForJoin(CSharpSyntaxContext context)
- {
- // cases:
- // join a in expr o1 equals o2 |
- // join a in expr o1 equals o2 i|
-
- var token = context.TargetToken;
- var join = token.GetAncestor<JoinClauseSyntax>();
-
- if (join == null)
- {
- // happens for:
- // join a in expr on o1 equals o2 e|
- if (!token.IntersectsWith(context.Position))
- {
- return false;
- }
-
- token = token.GetPreviousToken(includeSkipped: true);
- join = token.GetAncestor<JoinClauseSyntax>();
-
- if (join == null)
- {
- return false;
- }
- }
-
- var lastToken = join.RightExpression.GetLastToken(includeSkipped: true);
-
- // join a in expr on o1 equals o2 |
- if (token == lastToken &&
- !lastToken.IntersectsWith(context.Position))
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IsKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IsKeywordRecommender.cs
deleted file mode 100644
index e9359aae81..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/IsKeywordRecommender.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class IsKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public IsKeywordRecommender()
- : base(SyntaxKind.IsKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // expr |
- return !context.IsInNonUserCode && context.IsIsOrAsContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/JoinKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/JoinKeywordRecommender.cs
deleted file mode 100644
index d61b937922..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/JoinKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class JoinKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public JoinKeywordRecommender()
- : base(SyntaxKind.JoinKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.SyntaxTree.IsValidContextForJoinClause(position, context.LeftToken, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LetKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LetKeywordRecommender.cs
deleted file mode 100644
index f76d9b97ca..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LetKeywordRecommender.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class LetKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public LetKeywordRecommender()
- : base(SyntaxKind.LetKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var token = context.TargetToken;
-
- // var q = from x in y
- // |
- if (!token.IntersectsWith(position) &&
- token.IsLastTokenOfQueryClause())
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LineKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LineKeywordRecommender.cs
deleted file mode 100644
index f481ef3436..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LineKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class LineKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public LineKeywordRecommender()
- : base(SyntaxKind.LineKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LockKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LockKeywordRecommender.cs
deleted file mode 100644
index 0ce70f2edb..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LockKeywordRecommender.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class LockKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public LockKeywordRecommender()
- : base(SyntaxKind.LockKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LongKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LongKeywordRecommender.cs
deleted file mode 100644
index c2e8ce8963..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/LongKeywordRecommender.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class LongKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public LongKeywordRecommender()
- : base(SyntaxKind.LongKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsEnumBaseListContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/MethodKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/MethodKeywordRecommender.cs
deleted file mode 100644
index e9e61a1240..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/MethodKeywordRecommender.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class MethodKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public MethodKeywordRecommender()
- : base(SyntaxKind.MethodKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken))
- {
- return true;
- }
-
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.OpenBracketToken &&
- token.Parent.IsKind(SyntaxKind.AttributeList))
- {
- if (token.GetAncestor<PropertyDeclarationSyntax>() != null ||
- token.GetAncestor<EventDeclarationSyntax>() != null)
- {
- return true;
- }
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ModuleKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ModuleKeywordRecommender.cs
deleted file mode 100644
index f86d6d6a11..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ModuleKeywordRecommender.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ModuleKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ModuleKeywordRecommender()
- : base(SyntaxKind.ModuleKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsTypeAttributeContext(cancellationToken))
- {
- var token = context.LeftToken;
- var type = token.GetAncestor<MemberDeclarationSyntax>();
-
- return type == null || type.IsParentKind(SyntaxKind.CompilationUnit);
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NameOfKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NameOfKeywordRecommender.cs
deleted file mode 100644
index dc6589997f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NameOfKeywordRecommender.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class NameOfKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public NameOfKeywordRecommender()
- : base(SyntaxKind.NameOfKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsAnyExpressionContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- IsAttributeArgumentContext(context);
- }
-
- private bool IsAttributeArgumentContext(CSharpSyntaxContext context)
- {
- return
- context.IsAnyExpressionContext &&
- context.LeftToken.GetAncestor<AttributeSyntax>() != null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NamespaceKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NamespaceKeywordRecommender.cs
deleted file mode 100644
index f2cd4ef2fc..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NamespaceKeywordRecommender.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class NamespaceKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public NamespaceKeywordRecommender()
- : base(SyntaxKind.NamespaceKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
-
- // namespaces are illegal in interactive code:
- if (syntaxTree.IsInteractiveOrScript())
- {
- return false;
- }
-
- // cases:
- // root: |
-
- // root: n|
-
- // extern alias a;
- // |
-
- // extern alias a;
- // n|
-
- // using Foo;
- // |
-
- // using Foo;
- // n|
-
- // using Foo = Bar;
- // |
-
- // using Foo = Bar;
- // n|
-
- // namespace N {}
- // |
-
- // namespace N {}
- // n|
-
- // class C {}
- // |
-
- // class C {}
- // n|
-
- var leftToken = context.LeftToken;
- var token = context.TargetToken;
-
- // root: n|
-
- // ns Foo { n|
-
- // extern alias a;
- // n|
-
- // using Foo;
- // n|
-
- // using Foo = Bar;
- // n|
-
- // a namespace can't come before usings/externs
- // a child namespace can't come before usings/externs
- if (leftToken.GetNextToken(includeSkipped: true).IsUsingOrExternKeyword())
- {
- return false;
- }
-
- // root: |
- if (token.Kind() == SyntaxKind.None)
- {
- // root namespace
- var root = syntaxTree.GetRoot(cancellationToken) as CompilationUnitSyntax;
- if (root.Externs.Count > 0 ||
- root.Usings.Count > 0)
- {
- return false;
- }
-
- return true;
- }
-
- if (token.Kind() == SyntaxKind.OpenBraceToken &&
- token.Parent.IsKind(SyntaxKind.NamespaceDeclaration))
- {
- return true;
- }
-
- // extern alias a;
- // |
-
- // using Foo;
- // |
- if (token.Kind() == SyntaxKind.SemicolonToken)
- {
- if (token.Parent.IsKind(SyntaxKind.ExternAliasDirective, SyntaxKind.UsingDirective))
- {
- return true;
- }
- }
-
- // class C {}
- // |
- if (token.Kind() == SyntaxKind.CloseBraceToken)
- {
- if (token.Parent is TypeDeclarationSyntax &&
- !(token.Parent.GetParent() is TypeDeclarationSyntax))
- {
- return true;
- }
- else if (token.Parent.IsKind(SyntaxKind.NamespaceDeclaration))
- {
- return true;
- }
- }
-
- // delegate void D();
- // |
-
- if (token.Kind() == SyntaxKind.SemicolonToken)
- {
- if (token.Parent.IsKind(SyntaxKind.DelegateDeclaration) &&
- !(token.Parent.GetParent() is TypeDeclarationSyntax))
- {
- return true;
- }
- }
-
- // [assembly: foo]
- // |
-
- if (token.Kind() == SyntaxKind.CloseBracketToken &&
- token.Parent.IsKind(SyntaxKind.AttributeList) &&
- token.Parent.IsParentKind(SyntaxKind.CompilationUnit))
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NewKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NewKeywordRecommender.cs
deleted file mode 100644
index f5c8c5742f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NewKeywordRecommender.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class NewKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.AbstractKeyword,
- SyntaxKind.ExternKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.ReadOnlyKeyword,
- SyntaxKind.SealedKeyword,
- SyntaxKind.StaticKeyword,
- SyntaxKind.UnsafeKeyword,
- SyntaxKind.VirtualKeyword,
- SyntaxKind.VolatileKeyword,
- };
-
- protected static readonly ISet<SyntaxKind> ValidTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.AbstractKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.SealedKeyword,
- SyntaxKind.StaticKeyword,
- SyntaxKind.UnsafeKeyword
- };
-
- public NewKeywordRecommender()
- : base(SyntaxKind.NewKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return IsValid (position, context, cancellationToken);
- }
-
- public bool IsValid(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsNewConstraintContext(context, cancellationToken) ||
- context.IsAnyExpressionContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- IsMemberDeclarationContext(context, cancellationToken) ||
- IsTypeDeclarationContext(context, cancellationToken);
- }
-
- private bool IsTypeDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsTypeDeclarationContext(validModifiers: ValidTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- // we must be on a nested type.
- var token = context.LeftToken;
- return token.GetAncestors<TypeDeclarationSyntax>()
- .Any(t => token.SpanStart > t.OpenBraceToken.Span.End &&
- token.Span.End < t.CloseBraceToken.SpanStart);
- }
-
- return false;
- }
-
- private bool IsMemberDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
-
- private static bool IsNewConstraintContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // where T : |
- // where T : class, |
- // where T : Foo, |
- // note: 'new()' can't come after a 'struct' constraint.
-
- if (context.SyntaxTree.IsTypeParameterConstraintStartContext(context.Position, context.LeftToken, cancellationToken))
- {
- return true;
- }
-
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.CommaToken &&
- token.Parent.IsKind(SyntaxKind.TypeParameterConstraintClause))
- {
- var constraintClause = token.Parent as TypeParameterConstraintClauseSyntax;
- if (!constraintClause.Constraints
- .OfType<ClassOrStructConstraintSyntax>()
- .Any(c => c.ClassOrStructKeyword.Kind() == SyntaxKind.StructKeyword))
- {
- return true;
- }
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NullKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NullKeywordRecommender.cs
deleted file mode 100644
index 3200470fb2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/NullKeywordRecommender.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class NullKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public NullKeywordRecommender()
- : base(SyntaxKind.NullKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
-
- return
- context.IsAnyExpressionContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- IsInSelectCaseContext(context, cancellationToken);
- }
-
- private bool IsInSelectCaseContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var token = context.TargetToken;
- if (token.Kind() != SyntaxKind.CaseKeyword)
- {
- return false;
- }
-
- var switchStatement = token.GetAncestor<SwitchStatementSyntax>();
- if (switchStatement != null)
- {
- var info = context.SemanticModel.GetTypeInfo(switchStatement.Expression, cancellationToken);
- if (info.Type != null &&
- info.Type.IsValueType)
- {
- return false;
- }
- }
-
- return true;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ObjectKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ObjectKeywordRecommender.cs
deleted file mode 100644
index 15293d61e3..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ObjectKeywordRecommender.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ObjectKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ObjectKeywordRecommender()
- : base(SyntaxKind.ObjectKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsNonAttributeExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsTypeOfExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsDefaultExpressionContext(position, context.LeftToken, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OnKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OnKeywordRecommender.cs
deleted file mode 100644
index 0665f64786..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OnKeywordRecommender.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class OnKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public OnKeywordRecommender()
- : base(SyntaxKind.OnKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // join a in expr |
- // join a in expr o|
- // join a.b c in expr |
- // join a.b c in expr o|
-
- var token = context.TargetToken;
-
- var join = token.GetAncestor<JoinClauseSyntax>();
- if (join == null)
- {
- return false;
- }
-
- // join a in expr |
- // join a.b c in expr |
-
- var lastToken = join.InExpression.GetLastToken(includeSkipped: true);
-
- if (join.InExpression.Width() > 0 &&
- token == lastToken)
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OperatorKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OperatorKeywordRecommender.cs
deleted file mode 100644
index 2cc67a5057..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OperatorKeywordRecommender.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class OperatorKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
-// private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
-// {
-// SyntaxKind.StaticKeyword,
-// SyntaxKind.PublicKeyword,
-// SyntaxKind.ExternKeyword,
-// };
-
- public OperatorKeywordRecommender()
- : base(SyntaxKind.OperatorKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // public static implicit |
- // public static explicit |
- var token = context.TargetToken;
-
- return
- token.Kind() == SyntaxKind.ImplicitKeyword ||
- token.Kind() == SyntaxKind.ExplicitKeyword;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OrderByKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OrderByKeywordRecommender.cs
deleted file mode 100644
index 7bc71ac08c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OrderByKeywordRecommender.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class OrderByKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public OrderByKeywordRecommender()
- : base(SyntaxKind.OrderByKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var token = context.TargetToken;
-
- // var q = from x in y
- // |
- if (!token.IntersectsWith(position) &&
- token.IsLastTokenOfQueryClause())
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OutKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OutKeywordRecommender.cs
deleted file mode 100644
index 8b81204b29..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OutKeywordRecommender.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class OutKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public OutKeywordRecommender()
- : base(SyntaxKind.OutKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
-
- // TODO(cyrusn): lambda/anon methods can have out/ref parameters
- return
- context.TargetToken.IsTypeParameterVarianceContext() ||
- syntaxTree.IsParameterModifierContext(position, context.LeftToken, cancellationToken) ||
- syntaxTree.IsAnonymousMethodParameterModifierContext(position, context.LeftToken, cancellationToken) ||
- syntaxTree.IsPossibleLambdaParameterModifierContext(position, context.LeftToken, cancellationToken) ||
- context.TargetToken.IsConstructorOrMethodParameterArgumentContext() ||
- context.TargetToken.IsXmlCrefParameterModifierContext();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OverrideKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OverrideKeywordRecommender.cs
deleted file mode 100644
index d01a356317..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/OverrideKeywordRecommender.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class OverrideKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.ExternKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword,
- SyntaxKind.SealedKeyword,
- SyntaxKind.AbstractKeyword,
- };
-
- public OverrideKeywordRecommender()
- : base(SyntaxKind.OverrideKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsMemberDeclarationContext(
- validModifiers: s_validMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ParamKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ParamKeywordRecommender.cs
deleted file mode 100644
index 6d4cd307f1..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ParamKeywordRecommender.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ParamKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ParamKeywordRecommender()
- : base(SyntaxKind.ParamKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.OpenBracketToken &&
- token.Parent.IsKind(SyntaxKind.AttributeList))
- {
- if (token.GetAncestor<PropertyDeclarationSyntax>() != null ||
- token.GetAncestor<EventDeclarationSyntax>() != null)
- {
- return true;
- }
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ParamsKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ParamsKeywordRecommender.cs
deleted file mode 100644
index dbb7434508..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ParamsKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ParamsKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ParamsKeywordRecommender()
- : base(SyntaxKind.ParamsKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.SyntaxTree.IsParameterModifierContext(context.Position, context.LeftToken, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PartialKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PartialKeywordRecommender.cs
deleted file mode 100644
index e9105b4619..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PartialKeywordRecommender.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class PartialKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.AsyncKeyword,
- SyntaxKind.StaticKeyword
- };
-
- public PartialKeywordRecommender()
- : base(SyntaxKind.PartialKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- IsMemberDeclarationContext(context, cancellationToken) ||
- IsTypeDeclarationContext(context, cancellationToken);
- }
-
- private bool IsMemberDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsMemberDeclarationContext(validModifiers: s_validMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- var token = context.LeftToken;
- var decl = token.GetAncestor<TypeDeclarationSyntax>();
-
- // partial methods must be in partial types
- if (!decl.Modifiers.Any(t => t.IsKindOrHasMatchingText(SyntaxKind.PartialKeyword)))
- {
- return false;
- }
-
- return true;
- }
-
- return false;
- }
-
- private bool IsTypeDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsTypeDeclarationContext(
- validModifiers: SyntaxKindSet.AllTypeModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PragmaKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PragmaKeywordRecommender.cs
deleted file mode 100644
index 556d2ee144..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PragmaKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class PragmaKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public PragmaKeywordRecommender()
- : base(SyntaxKind.PragmaKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PrivateKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PrivateKeywordRecommender.cs
deleted file mode 100644
index 26a1f1d8f2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PrivateKeywordRecommender.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class PrivateKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public PrivateKeywordRecommender()
- : base(SyntaxKind.PrivateKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- IsValidContextForAccessor(context) ||
- IsValidContextForType(context, cancellationToken) ||
- IsValidContextForMember(context, cancellationToken);
- }
-
- private static bool IsValidContextForAccessor(CSharpSyntaxContext context)
- {
- if (context.TargetToken.IsAccessorDeclarationContext<PropertyDeclarationSyntax>(context.Position) ||
- context.TargetToken.IsAccessorDeclarationContext<IndexerDeclarationSyntax>(context.Position))
- {
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- var modifiers = context.PrecedingModifiers;
-
- // can't have private + abstract/virtual/override/sealed
- if (modifiers.Contains(SyntaxKind.AbstractKeyword) ||
- modifiers.Contains(SyntaxKind.VirtualKeyword) ||
- modifiers.Contains(SyntaxKind.OverrideKeyword) ||
- modifiers.Contains(SyntaxKind.SealedKeyword))
- {
- return false;
- }
-
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- // private things can't be in namespaces.
- var typeDecl = context.ContainingTypeDeclaration;
- if (typeDecl == null)
- {
- return false;
- }
-
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool CheckPreviousAccessibilityModifiers(CSharpSyntaxContext context)
- {
- var precedingModifiers = context.PrecedingModifiers;
- return
- !precedingModifiers.Contains(SyntaxKind.PublicKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.InternalKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.ProtectedKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.PrivateKeyword);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PropertyKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PropertyKeywordRecommender.cs
deleted file mode 100644
index 6be63e7031..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PropertyKeywordRecommender.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class PropertyKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public PropertyKeywordRecommender()
- : base(SyntaxKind.PropertyKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ProtectedKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ProtectedKeywordRecommender.cs
deleted file mode 100644
index 3c7d897e22..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ProtectedKeywordRecommender.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ProtectedKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ProtectedKeywordRecommender()
- : base(SyntaxKind.ProtectedKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsValidContextForAccessor(context) ||
- IsValidContextForType(context, cancellationToken) ||
- IsValidContextForMember(context, cancellationToken);
- }
-
- private static bool IsValidContextForAccessor(CSharpSyntaxContext context)
- {
- if (context.TargetToken.IsAccessorDeclarationContext<PropertyDeclarationSyntax>(context.Position) ||
- context.TargetToken.IsAccessorDeclarationContext<IndexerDeclarationSyntax>(context.Position))
- {
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- // protected things can't be in namespaces.
- var typeDecl = context.ContainingTypeDeclaration;
- if (typeDecl == null)
- {
- return false;
- }
-
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool CheckPreviousAccessibilityModifiers(CSharpSyntaxContext context)
- {
- // We can show up after 'internal'.
- var precedingModifiers = context.PrecedingModifiers;
- return
- !precedingModifiers.Contains(SyntaxKind.PublicKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.ProtectedKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.PrivateKeyword);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PublicKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PublicKeywordRecommender.cs
deleted file mode 100644
index 21debc6f36..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/PublicKeywordRecommender.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class PublicKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public PublicKeywordRecommender()
- : base(SyntaxKind.PublicKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- IsValidContextForType(context, cancellationToken) ||
- IsValidContextForMember(context, cancellationToken);
- }
-
- private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken))
- {
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
- {
- return CheckPreviousAccessibilityModifiers(context);
- }
-
- return false;
- }
-
- private static bool CheckPreviousAccessibilityModifiers(CSharpSyntaxContext context)
- {
- var precedingModifiers = context.PrecedingModifiers;
- return
- !precedingModifiers.Contains(SyntaxKind.PublicKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.InternalKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.ProtectedKeyword) &&
- !precedingModifiers.Contains(SyntaxKind.PrivateKeyword);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReadOnlyKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReadOnlyKeywordRecommender.cs
deleted file mode 100644
index 0e845ed6e9..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReadOnlyKeywordRecommender.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ReadOnlyKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.StaticKeyword,
- };
-
- public ReadOnlyKeywordRecommender()
- : base(SyntaxKind.ReadOnlyKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RefKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RefKeywordRecommender.cs
deleted file mode 100644
index 83081f1ebd..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RefKeywordRecommender.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class RefKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public RefKeywordRecommender()
- : base(SyntaxKind.RefKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- syntaxTree.IsParameterModifierContext(position, context.LeftToken, cancellationToken) ||
- syntaxTree.IsAnonymousMethodParameterModifierContext(position, context.LeftToken, cancellationToken) ||
- syntaxTree.IsPossibleLambdaParameterModifierContext(position, context.LeftToken, cancellationToken) ||
- context.TargetToken.IsConstructorOrMethodParameterArgumentContext() ||
- context.TargetToken.IsXmlCrefParameterModifierContext();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReferenceKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReferenceKeywordRecommender.cs
deleted file mode 100644
index 5fb24646fe..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReferenceKeywordRecommender.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ReferenceKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ReferenceKeywordRecommender()
- : base(SyntaxKind.ReferenceKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- syntaxTree.IsInteractiveOrScript() &&
- syntaxTree.IsBeforeFirstToken(position, cancellationToken) &&
- context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RegionKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RegionKeywordRecommender.cs
deleted file mode 100644
index 67fffd3948..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RegionKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class RegionKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public RegionKeywordRecommender()
- : base(SyntaxKind.RegionKeyword, isValidInPreprocessorContext: true, shouldFormatOnCommit: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RemoveKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RemoveKeywordRecommender.cs
deleted file mode 100644
index e9abae057c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RemoveKeywordRecommender.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class RemoveKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public RemoveKeywordRecommender()
- : base(SyntaxKind.RemoveKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.TargetToken.IsAccessorDeclarationContext<EventDeclarationSyntax>(position, SyntaxKind.RemoveKeyword);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RestoreKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RestoreKeywordRecommender.cs
deleted file mode 100644
index 715edd7c22..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/RestoreKeywordRecommender.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class RestoreKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public RestoreKeywordRecommender()
- : base(SyntaxKind.RestoreKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // # pragma warning |
- // # pragma warning r|
- var previousToken1 = context.TargetToken;
- var previousToken2 = previousToken1.GetPreviousToken(includeSkipped: true);
- var previousToken3 = previousToken2.GetPreviousToken(includeSkipped: true);
-
- return
- previousToken1.Kind() == SyntaxKind.WarningKeyword &&
- previousToken2.Kind() == SyntaxKind.PragmaKeyword &&
- previousToken3.Kind() == SyntaxKind.HashToken;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReturnKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReturnKeywordRecommender.cs
deleted file mode 100644
index da927d71be..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ReturnKeywordRecommender.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ReturnKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ReturnKeywordRecommender()
- : base(SyntaxKind.ReturnKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.TargetToken.IsAfterYieldKeyword() ||
- IsAttributeContext(context, cancellationToken);
- }
-
- private static bool IsAttributeContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken) ||
- (context.SyntaxTree.IsInteractiveOrScript() && context.IsTypeAttributeContext(cancellationToken));
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SByteKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SByteKeywordRecommender.cs
deleted file mode 100644
index c8edd8e150..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SByteKeywordRecommender.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class SByteKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public SByteKeywordRecommender()
- : base(SyntaxKind.SByteKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsNonAttributeExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsEnumBaseListContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SealedKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SealedKeywordRecommender.cs
deleted file mode 100644
index ac89445eee..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SealedKeywordRecommender.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class SealedKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.ExternKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.OverrideKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword,
- };
-
- private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword
- };
-
- public SealedKeywordRecommender()
- : base(SyntaxKind.SealedKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken) ||
- context.IsTypeDeclarationContext(
- validModifiers: s_validTypeModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SelectKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SelectKeywordRecommender.cs
deleted file mode 100644
index 76afd5cc48..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SelectKeywordRecommender.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class SelectKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public SelectKeywordRecommender()
- : base(SyntaxKind.SelectKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var token = context.TargetToken;
-
- // for orderby, ascending is the default so select should be available in the orderby direction context
- if (token.IsOrderByDirectionContext())
- {
- return true;
- }
-
- // var q = from x in y
- // |
- if (!token.IntersectsWith(position) &&
- token.IsLastTokenOfQueryClause())
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SetKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SetKeywordRecommender.cs
deleted file mode 100644
index bd37ed26a0..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SetKeywordRecommender.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class SetKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public SetKeywordRecommender()
- : base(SyntaxKind.SetKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.TargetToken.IsAccessorDeclarationContext<PropertyDeclarationSyntax>(position, SyntaxKind.SetKeyword) ||
- context.TargetToken.IsAccessorDeclarationContext<IndexerDeclarationSyntax>(position, SyntaxKind.SetKeyword);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ShortKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ShortKeywordRecommender.cs
deleted file mode 100644
index e017ee200c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ShortKeywordRecommender.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ShortKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ShortKeywordRecommender()
- : base(SyntaxKind.ShortKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsEnumBaseListContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SizeOfKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SizeOfKeywordRecommender.cs
deleted file mode 100644
index b789d84171..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SizeOfKeywordRecommender.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class SizeOfKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public SizeOfKeywordRecommender()
- : base(SyntaxKind.SizeOfKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsNonAttributeExpressionContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StackAllocKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StackAllocKeywordRecommender.cs
deleted file mode 100644
index eb66b49210..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StackAllocKeywordRecommender.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class StackAllocKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public StackAllocKeywordRecommender()
- : base(SyntaxKind.StackAllocKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // type t = |
- var token = context.TargetToken;
- if (token.IsUnsafeContext())
- {
- if (token.Kind() == SyntaxKind.EqualsToken &&
- token.Parent.IsKind(SyntaxKind.EqualsValueClause) &&
- token.Parent.IsParentKind(SyntaxKind.VariableDeclarator) &&
- token.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclaration))
- {
- var variableDeclaration = (VariableDeclarationSyntax)token.Parent.Parent.Parent;
- if (variableDeclaration.IsParentKind(SyntaxKind.LocalDeclarationStatement) ||
- variableDeclaration.IsParentKind(SyntaxKind.ForStatement))
- {
- return variableDeclaration.Type.IsVar || variableDeclaration.Type.IsKind(SyntaxKind.PointerType);
- }
- }
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StaticKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StaticKeywordRecommender.cs
deleted file mode 100644
index 8daf3e29b5..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StaticKeywordRecommender.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class StaticKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword,
- };
-
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.AsyncKeyword,
- SyntaxKind.ExternKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.ReadOnlyKeyword,
- SyntaxKind.UnsafeKeyword,
- SyntaxKind.VolatileKeyword,
- };
-
- private static readonly ISet<SyntaxKind> s_validGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.ExternKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ReadOnlyKeyword,
- SyntaxKind.UnsafeKeyword,
- SyntaxKind.VolatileKeyword,
- };
-
- public StaticKeywordRecommender()
- : base(SyntaxKind.StaticKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- context.TargetToken.IsUsingKeywordInUsingDirective() ||
- IsValidContextForType(context, cancellationToken) ||
- IsValidContextForMember(context, cancellationToken);
- }
-
- private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, s_validGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
-
- private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsTypeDeclarationContext(
- validModifiers: s_validTypeModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StringKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StringKeywordRecommender.cs
deleted file mode 100644
index a064a15360..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StringKeywordRecommender.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class StringKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public StringKeywordRecommender()
- : base(SyntaxKind.StringKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsTypeOfExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsDefaultExpressionContext(position, context.LeftToken, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StructKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StructKeywordRecommender.cs
deleted file mode 100644
index ad11333782..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/StructKeywordRecommender.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class StructKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.InternalKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword
- };
-
- public StructKeywordRecommender()
- : base(SyntaxKind.StructKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsGlobalStatementContext ||
- context.IsTypeDeclarationContext(
- validModifiers: s_validModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: true,
- cancellationToken: cancellationToken) ||
- syntaxTree.IsTypeParameterConstraintStartContext(position, context.LeftToken, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SwitchKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SwitchKeywordRecommender.cs
deleted file mode 100644
index 628463284a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/SwitchKeywordRecommender.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class SwitchKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public SwitchKeywordRecommender()
- : base(SyntaxKind.SwitchKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ThisKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ThisKeywordRecommender.cs
deleted file mode 100644
index ded002dfd5..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ThisKeywordRecommender.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ThisKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ThisKeywordRecommender()
- : base(SyntaxKind.ThisKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsInstanceExpressionOrStatement(context) ||
- IsExtensionMethodParameterContext(context, cancellationToken) ||
- IsConstructorInitializerContext(context);
- }
-
- private static bool IsInstanceExpressionOrStatement(CSharpSyntaxContext context)
- {
- if (context.IsInstanceContext)
- {
- return context.IsNonAttributeExpressionContext || context.IsStatementContext;
- }
-
- return false;
- }
-
- private bool IsConstructorInitializerContext(CSharpSyntaxContext context)
- {
- // cases:
- // Foo() : |
-
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.ColonToken &&
- token.Parent is ConstructorInitializerSyntax &&
- token.Parent.IsParentKind(SyntaxKind.ConstructorDeclaration))
- {
- var constructor = token.GetAncestor<ConstructorDeclarationSyntax>();
- if (constructor.Modifiers.Any(m => m.IsKind (SyntaxKind.StaticKeyword)))
- {
- return false;
- }
-
- return true;
- }
-
- return false;
- }
-
- private static bool IsExtensionMethodParameterContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // TODO(cyrusn): lambda/anon methods can have out/ref parameters
- if (!context.SyntaxTree.IsParameterModifierContext(context.Position, context.LeftToken, cancellationToken, allowableIndex: 0))
- {
- return false;
- }
-
- var token = context.LeftToken;
- var method = token.GetAncestor<MethodDeclarationSyntax>();
- var typeDecl = method.GetAncestorOrThis<TypeDeclarationSyntax>();
-
- if (method == null || typeDecl == null)
- {
- return false;
- }
-
- if (typeDecl.Kind() != SyntaxKind.ClassDeclaration)
- {
- return false;
- }
-
- if (!method.Modifiers.Any(t => t.Kind() == SyntaxKind.StaticKeyword))
- {
- return false;
- }
-
- if (!typeDecl.Modifiers.Any(t => t.Kind() == SyntaxKind.StaticKeyword))
- {
- return false;
- }
-
- return true;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ThrowKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ThrowKeywordRecommender.cs
deleted file mode 100644
index 9572ebe9ab..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ThrowKeywordRecommender.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ThrowKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ThrowKeywordRecommender()
- : base(SyntaxKind.ThrowKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TrueKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TrueKeywordRecommender.cs
deleted file mode 100644
index a190aae0b8..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TrueKeywordRecommender.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class TrueKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public TrueKeywordRecommender()
- : base(SyntaxKind.TrueKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsAnyExpressionContext ||
- context.IsPreProcessorExpressionContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.TargetToken.IsUnaryOperatorContext();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TryKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TryKeywordRecommender.cs
deleted file mode 100644
index 27945aa024..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TryKeywordRecommender.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class TryKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public TryKeywordRecommender()
- : base(SyntaxKind.TryKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeKeywordRecommender.cs
deleted file mode 100644
index 4d9bf61e9d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class TypeKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public TypeKeywordRecommender()
- : base(SyntaxKind.TypeKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsTypeAttributeContext(cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeOfKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeOfKeywordRecommender.cs
deleted file mode 100644
index c68e66d8e5..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeOfKeywordRecommender.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class TypeOfKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public TypeOfKeywordRecommender()
- : base(SyntaxKind.TypeOfKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- (context.IsAnyExpressionContext && !context.IsConstantExpressionContext) ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- IsAttributeArgumentContext(context);
- }
-
- private bool IsAttributeArgumentContext(CSharpSyntaxContext context)
- {
- return
- context.IsAnyExpressionContext &&
- context.LeftToken.GetAncestor<AttributeSyntax>() != null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeVarKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeVarKeywordRecommender.cs
deleted file mode 100644
index cac63dd97a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/TypeVarKeywordRecommender.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class TypeVarKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public TypeVarKeywordRecommender()
- : base(SyntaxKind.TypeVarKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.OpenBracketToken &&
- token.Parent.IsKind(SyntaxKind.AttributeList))
- {
- var typeParameters = token.GetAncestor<TypeParameterListSyntax>();
- var type = typeParameters.GetAncestorOrThis<TypeDeclarationSyntax>();
-
- if (type != null && type.TypeParameterList == typeParameters)
- {
- return true;
- }
-
- var @delegate = typeParameters.GetAncestorOrThis<DelegateDeclarationSyntax>();
- if (@delegate != null && @delegate.TypeParameterList == typeParameters)
- {
- return true;
- }
-
- var method = typeParameters.GetAncestorOrThis<MethodDeclarationSyntax>();
- if (method != null && method.TypeParameterList == typeParameters)
- {
- return true;
- }
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UIntKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UIntKeywordRecommender.cs
deleted file mode 100644
index 282af54e04..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UIntKeywordRecommender.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class UIntKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public UIntKeywordRecommender()
- : base(SyntaxKind.UIntKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsEnumBaseListContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ULongKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ULongKeywordRecommender.cs
deleted file mode 100644
index 08c52123d8..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/ULongKeywordRecommender.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class ULongKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public ULongKeywordRecommender()
- : base(SyntaxKind.ULongKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsEnumBaseListContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UShortKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UShortKeywordRecommender.cs
deleted file mode 100644
index 42406d6d2a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UShortKeywordRecommender.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class UShortKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public UShortKeywordRecommender()
- : base(SyntaxKind.UShortKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsAnyExpressionContext ||
- context.IsDefiniteCastTypeContext ||
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsObjectCreationTypeContext ||
- context.IsGenericTypeArgumentContext ||
- context.IsEnumBaseListContext ||
- context.IsIsOrAsTypeContext ||
- context.IsLocalVariableDeclarationContext ||
- context.IsFixedVariableDeclarationContext ||
- context.IsParameterTypeContext ||
- context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
- context.IsImplicitOrExplicitOperatorTypeContext ||
- context.IsPrimaryFunctionExpressionContext ||
- context.IsCrefContext ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UncheckedKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UncheckedKeywordRecommender.cs
deleted file mode 100644
index 118703f82e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UncheckedKeywordRecommender.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class UncheckedKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public UncheckedKeywordRecommender()
- : base(SyntaxKind.UncheckedKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsNonAttributeExpressionContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UndefKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UndefKeywordRecommender.cs
deleted file mode 100644
index e887b40db7..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UndefKeywordRecommender.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class UndefKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public UndefKeywordRecommender()
- : base(SyntaxKind.UndefKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- syntaxTree.IsBeforeFirstToken(position, cancellationToken) &&
- context.IsPreProcessorKeywordContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UnsafeKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UnsafeKeywordRecommender.cs
deleted file mode 100644
index 1a1accb611..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UnsafeKeywordRecommender.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class UnsafeKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.AbstractKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.SealedKeyword,
- SyntaxKind.StaticKeyword,
- };
-
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.AbstractKeyword,
- SyntaxKind.ExternKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.OverrideKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.ReadOnlyKeyword,
- SyntaxKind.SealedKeyword,
- SyntaxKind.StaticKeyword,
- SyntaxKind.VirtualKeyword,
- SyntaxKind.VolatileKeyword,
- };
-
- private static readonly ISet<SyntaxKind> s_validGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.ExternKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.ReadOnlyKeyword,
- SyntaxKind.StaticKeyword,
- SyntaxKind.VolatileKeyword,
- };
-
- public UnsafeKeywordRecommender()
- : base(SyntaxKind.UnsafeKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- context.IsTypeDeclarationContext(validModifiers: s_validTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken) ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, s_validGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UsingKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UsingKeywordRecommender.cs
deleted file mode 100644
index f1dc791e6f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/UsingKeywordRecommender.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class UsingKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public UsingKeywordRecommender()
- : base(SyntaxKind.UsingKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // using (foo) { }
- // using Foo;
- // using Foo = Bar;
- return
- context.IsStatementContext ||
- context.IsGlobalStatementContext ||
- IsUsingDirectiveContext(context, cancellationToken);
- }
-
- private static bool IsUsingDirectiveContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // cases:
- // root: |
-
- // root: u|
-
- // extern alias a;
- // |
-
- // extern alias a;
- // u|
-
- // using Foo;
- // |
-
- // using Foo;
- // u|
-
- // using Foo = Bar;
- // |
-
- // using Foo = Bar;
- // u|
-
- // t valid:
- // namespace N {}
- // |
-
- // namespace N {}
- // u|
-
- // class C {}
- // |
-
- // class C {}
- // u|
-
- // |
- // extern alias a;
-
- // u|
- // extern alias a;
-
- var originalToken = context.LeftToken;
- var token = context.TargetToken;
-
- // root: u|
-
- // ns Foo { u|
-
- // extern alias a;
- // u|
-
- // using Foo;
- // u|
-
- // using Foo = Bar;
- // u|
-
- // root: |
- if (token.Kind() == SyntaxKind.None)
- {
- // root namespace
-
- // a using can't come before externs
- var nextToken = originalToken.GetNextToken(includeSkipped: true);
- if (nextToken.Kind() == SyntaxKind.ExternKeyword ||
- ((CompilationUnitSyntax)context.SyntaxTree.GetRoot(cancellationToken)).Externs.Count > 0)
- {
- return false;
- }
-
- return true;
- }
-
- if (token.Kind() == SyntaxKind.OpenBraceToken &&
- token.Parent.IsKind(SyntaxKind.NamespaceDeclaration))
- {
- var ns = (NamespaceDeclarationSyntax)token.Parent;
-
- // a child using can't come before externs
- var nextToken = originalToken.GetNextToken(includeSkipped: true);
- if (nextToken.Kind() == SyntaxKind.ExternKeyword)
- {
- return false;
- }
-
- return true;
- }
-
- // extern alias a;
- // |
-
- // using Foo;
- // |
- if (token.Kind() == SyntaxKind.SemicolonToken)
- {
- if (token.Parent.IsKind(SyntaxKind.ExternAliasDirective) ||
- token.Parent.IsKind(SyntaxKind.UsingDirective))
- {
- return true;
- }
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VarKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VarKeywordRecommender.cs
deleted file mode 100644
index 6627a049e9..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VarKeywordRecommender.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class VarKeywordRecommender : IKeywordRecommender<CSharpSyntaxContext>
- {
- public VarKeywordRecommender()
- {
- }
-
- private bool IsValidContext(CSharpSyntaxContext context)
- {
- if (context.IsStatementContext ||
- context.IsGlobalStatementContext)
- {
- return true;
- }
-
- return context.IsLocalVariableDeclarationContext;
- }
-
- public IEnumerable<RecommendedKeyword> RecommendKeywords(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (IsValidContext(context))
- {
- yield return new RecommendedKeyword("var", SyntaxKind.TypeVarKeyword);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VirtualKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VirtualKeywordRecommender.cs
deleted file mode 100644
index d98e7b1616..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VirtualKeywordRecommender.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class VirtualKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.ExternKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.UnsafeKeyword,
- };
-
- public VirtualKeywordRecommender()
- : base(SyntaxKind.VirtualKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsMemberDeclarationContext(
- validModifiers: s_validMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VoidKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VoidKeywordRecommender.cs
deleted file mode 100644
index 4228baa2ea..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VoidKeywordRecommender.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class VoidKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.StaticKeyword,
- SyntaxKind.VirtualKeyword,
- SyntaxKind.SealedKeyword,
- SyntaxKind.OverrideKeyword,
- SyntaxKind.AbstractKeyword,
- SyntaxKind.ExternKeyword,
- SyntaxKind.UnsafeKeyword,
- SyntaxKind.AsyncKeyword
- };
-
- public VoidKeywordRecommender()
- : base(SyntaxKind.VoidKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- IsMemberReturnTypeContext(position, context, cancellationToken) ||
- context.IsGlobalStatementContext ||
- context.IsTypeOfExpressionContext ||
- syntaxTree.IsSizeOfExpressionContext(position, context.LeftToken, cancellationToken) ||
- context.IsDelegateReturnTypeContext ||
- IsUnsafeLocalVariableDeclarationContext(context) ||
- IsUnsafeParameterTypeContext(context) ||
- IsUnsafeCastTypeContext(context) ||
- IsUnsafeDefaultExpressionContext(context, cancellationToken) ||
- context.IsFixedVariableDeclarationContext;
- }
-
- private bool IsUnsafeDefaultExpressionContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.TargetToken.IsUnsafeContext() &&
- context.SyntaxTree.IsDefaultExpressionContext(context.Position, context.LeftToken, cancellationToken);
- }
-
- private bool IsUnsafeCastTypeContext(CSharpSyntaxContext context)
- {
- if (context.TargetToken.IsUnsafeContext())
- {
- if (context.IsDefiniteCastTypeContext)
- {
- return true;
- }
-
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.Parent.IsKind(SyntaxKind.ParenthesizedExpression))
- {
- return true;
- }
- }
-
- return false;
- }
-
- private bool IsUnsafeParameterTypeContext(CSharpSyntaxContext context)
- {
- return
- context.TargetToken.IsUnsafeContext() &&
- context.IsParameterTypeContext;
- }
-
- private bool IsUnsafeLocalVariableDeclarationContext(CSharpSyntaxContext context)
- {
- if (context.TargetToken.IsUnsafeContext())
- {
- return
- context.IsLocalVariableDeclarationContext ||
- context.IsStatementContext;
- }
-
- return false;
- }
-
- private bool IsMemberReturnTypeContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- var syntaxTree = context.SyntaxTree;
- return
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: true,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VolatileKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VolatileKeywordRecommender.cs
deleted file mode 100644
index c23381f2a2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/VolatileKeywordRecommender.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class VolatileKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
- {
- SyntaxKind.NewKeyword,
- SyntaxKind.PublicKeyword,
- SyntaxKind.ProtectedKeyword,
- SyntaxKind.InternalKeyword,
- SyntaxKind.PrivateKeyword,
- SyntaxKind.StaticKeyword,
- };
-
- public VolatileKeywordRecommender()
- : base(SyntaxKind.VolatileKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- context.IsGlobalStatementContext ||
- context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- context.IsMemberDeclarationContext(
- validModifiers: s_validMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WarningKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WarningKeywordRecommender.cs
deleted file mode 100644
index 60cfc7c5c2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WarningKeywordRecommender.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class WarningKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public WarningKeywordRecommender()
- : base(SyntaxKind.WarningKeyword, isValidInPreprocessorContext: true)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- // # warning
- if (context.IsPreProcessorKeywordContext)
- {
- return true;
- }
-
- // # pragma |
- // # pragma w|
- var previousToken1 = context.TargetToken;
- var previousToken2 = previousToken1.GetPreviousToken(includeSkipped: true);
-
- return
- previousToken1.Kind() == SyntaxKind.PragmaKeyword &&
- previousToken2.Kind() == SyntaxKind.HashToken;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhenKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhenKeywordRecommender.cs
deleted file mode 100644
index bccfe04c80..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhenKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-//// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-//
-//using System.Threading;
-//using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-//using Microsoft.CodeAnalysis.CSharp;
-//
-//namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-//{
-// internal class WhenKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
-// {
-// public WhenKeywordRecommender()
-// : base(SyntaxKind.WhenKeyword, isValidInPreprocessorContext: true)
-// {
-// }
-//
-// protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
-// {
-// return context.IsCatchFilterContext;
-// }
-// }
-//}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhereKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhereKeywordRecommender.cs
deleted file mode 100644
index e0ba199c16..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhereKeywordRecommender.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class WhereKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public WhereKeywordRecommender()
- : base(SyntaxKind.WhereKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return
- IsQueryContext(context) ||
- IsTypeParameterConstraintContext(context);
- }
-
- private bool IsTypeParameterConstraintContext(CSharpSyntaxContext context)
- {
- // cases:
- // class C<T> |
- // class C<T> : IFoo |
- // class C<T> where T : IFoo |
- // delegate void D<T> |
- // delegate void D<T> where T : IFoo |
- // void Foo<T>() |
- // void Foo<T>() where T : IFoo |
-
- var token = context.TargetToken;
-
- // class C<T> |
-
- if (token.Kind() == SyntaxKind.GreaterThanToken)
- {
- var typeParameters = token.GetAncestor<TypeParameterListSyntax>();
- if (typeParameters != null && token == typeParameters.GetLastToken(includeSkipped: true))
- {
- var decl = typeParameters.GetAncestorOrThis<TypeDeclarationSyntax>();
- if (decl != null && decl.TypeParameterList == typeParameters)
- {
- return true;
- }
- }
- }
-
- // delegate void D<T>() |
- if (token.Kind() == SyntaxKind.CloseParenToken &&
- token.Parent.IsKind(SyntaxKind.ParameterList) &&
- token.Parent.IsParentKind(SyntaxKind.DelegateDeclaration))
- {
- var decl = token.GetAncestor<DelegateDeclarationSyntax>();
- if (decl != null && decl.TypeParameterList != null)
- {
- return true;
- }
- }
-
- // void Foo<T>() |
-
- if (token.Kind() == SyntaxKind.CloseParenToken &&
- token.Parent.IsKind(SyntaxKind.ParameterList) &&
- token.Parent.IsParentKind(SyntaxKind.MethodDeclaration))
- {
- var decl = token.GetAncestor<MethodDeclarationSyntax>();
- if (decl != null && decl.Arity > 0)
- {
- return true;
- }
- }
-
- // class C<T> : IFoo |
- var baseList = token.GetAncestor<BaseListSyntax>();
- if (baseList.GetParent() is TypeDeclarationSyntax)
- {
- var typeDecl = baseList.GetParent() as TypeDeclarationSyntax;
- if (typeDecl.TypeParameterList != null &&
- typeDecl.BaseList.Types.Any(t => token == t.GetLastToken(includeSkipped: true)))
- {
- // token is IdentifierName "where"
- // only suggest "where" if token's previous token is also "where"
- if (token.Parent is IdentifierNameSyntax && token.HasMatchingText(SyntaxKind.WhereKeyword))
- {
- // Check for zero-width tokens in case there is a missing comma in the base list.
- // For example: class C<T> : Foo where where |
- return token
- .GetPreviousToken(includeZeroWidth: true)
- .IsKindOrHasMatchingText(SyntaxKind.WhereKeyword);
- }
-
- // System.|
- // Not done typing the qualified name
- if (token.IsKind(SyntaxKind.DotToken))
- {
- return false;
- }
-
- return true;
- }
- }
-
- // class C<T> where T : IFoo |
- // delegate void D<T> where T : IFoo |
- var constraintClause = token.GetAncestor<TypeParameterConstraintClauseSyntax>();
-
- if (constraintClause != null)
- {
- if (constraintClause.Constraints.Any(c => token == c.GetLastToken(includeSkipped: true)))
- {
- return true;
- }
- }
-
- return false;
- }
-
- private static bool IsQueryContext(CSharpSyntaxContext context)
- {
- var token = context.TargetToken;
-
- // var q = from x in y
- // |
- if (!token.IntersectsWith(context.Position) &&
- token.IsLastTokenOfQueryClause())
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhileKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhileKeywordRecommender.cs
deleted file mode 100644
index 8185dc4a93..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/WhileKeywordRecommender.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class WhileKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public WhileKeywordRecommender()
- : base(SyntaxKind.WhileKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- if (context.IsStatementContext ||
- context.IsGlobalStatementContext)
- {
- return true;
- }
-
- // do {
- // } |
-
- // do {
- // } w|
-
- // Note: the case of
- // do
- // Foo();
- // |
- // is taken care of in the IsStatementContext case.
-
- var token = context.TargetToken;
-
- if (token.Kind() == SyntaxKind.CloseBraceToken &&
- token.Parent.IsKind(SyntaxKind.Block) &&
- token.Parent.IsParentKind(SyntaxKind.DoStatement))
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/YieldKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/YieldKeywordRecommender.cs
deleted file mode 100644
index cf875303bd..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/YieldKeywordRecommender.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
-{
- internal class YieldKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
- {
- public YieldKeywordRecommender()
- : base(SyntaxKind.YieldKeyword)
- {
- }
-
- protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
- {
- return context.IsStatementContext;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/AbstractEncapsulateFieldRefactoringProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/AbstractEncapsulateFieldRefactoringProvider.cs
deleted file mode 100644
index 2d25415e66..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/AbstractEncapsulateFieldRefactoringProvider.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using ICSharpCode.NRefactory.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeRefactorings.EncapsulateField
-{
- abstract class AbstractEncapsulateFieldRefactoringProvider : CodeRefactoringProvider
- {
- CSharpEncapsulateFieldService service = new CSharpEncapsulateFieldService ();
-
- public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
- {
- var actions = await service.GetEncapsulateFieldCodeActionsAsync(context.Document, context.Span, context.CancellationToken).ConfigureAwait(false);
-
- context.RegisterRefactorings(actions);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/AbstractEncapsulateFieldService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/AbstractEncapsulateFieldService.cs
deleted file mode 100644
index 48dd1db1d3..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/AbstractEncapsulateFieldService.cs
+++ /dev/null
@@ -1,426 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Rename;
-using Microsoft.CodeAnalysis.Rename.ConflictEngine;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using System.Globalization;
-using System.Reflection;
-using Microsoft.CodeAnalysis.Options;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeRefactorings.EncapsulateField
-{
- internal abstract class AbstractEncapsulateFieldService : ILanguageService
- {
- static AbstractEncapsulateFieldService()
- {
- renameSymbolMethod = typeof (Renamer).GetMethod ("RenameSymbolAsync", BindingFlags.Static | BindingFlags.NonPublic, null, new Type [] { typeof(Solution), typeof(ISymbol), typeof(string), typeof(OptionSet), typeof(Func<Location, bool>), typeof(Func<IEnumerable<ISymbol>, bool?>), typeof(CancellationToken) }, null);
- if (renameSymbolMethod == null)
- throw new Exception ("Can't find RenameSymbolAsync method.");
- }
-
- public async Task<EncapsulateFieldResult> EncapsulateFieldAsync(Document document, TextSpan span, bool useDefaultBehavior, CancellationToken cancellationToken)
- {
- var fields = await GetFieldsAsync(document, span, cancellationToken).ConfigureAwait(false);
- if (fields == null || !fields.Any())
- {
- return null;
- }
-
- return new EncapsulateFieldResult(c => EncapsulateFieldResultAsync(document, span, useDefaultBehavior, c));
- }
-
- public async Task<IEnumerable<EncapsulateFieldCodeAction>> GetEncapsulateFieldCodeActionsAsync(Document document, TextSpan span, CancellationToken cancellationToken)
- {
- var fields = (await GetFieldsAsync(document, span, cancellationToken).ConfigureAwait(false)).ToImmutableArrayOrEmpty();
- if (fields.Length == 0)
- {
- return SpecializedCollections.EmptyEnumerable<EncapsulateFieldCodeAction>();
- }
-
- if (fields.Length == 1)
- {
- // there is only one field
- return EncapsulateOneField(document, span, fields[0], index: 0);
- }
- else
- {
- // there are multiple fields.
- var current = SpecializedCollections.EmptyEnumerable<EncapsulateFieldCodeAction>();
-
- if (span.IsEmpty)
- {
- // if there is no selection, get action for each field + all of them.
- for (var i = 0; i < fields.Length; i++)
- {
- current = current.Concat(EncapsulateOneField(document, span, fields[i], i));
- }
- }
-
- return current.Concat(EncapsulateAllFields(document, span));
- }
- }
-
- private IEnumerable<EncapsulateFieldCodeAction> EncapsulateAllFields(Document document, TextSpan span)
- {
- var action1Text = Resources.EncapsulateFieldsUsages;
- var action2Text = Resources.EncapsulateFields;
-
- return new[]
- {
- new EncapsulateFieldCodeAction(new EncapsulateFieldResult(c => EncapsulateFieldResultAsync(document, span, true, c)), action1Text),
- new EncapsulateFieldCodeAction(new EncapsulateFieldResult(c => EncapsulateFieldResultAsync(document, span, false, c)), action2Text)
- };
- }
-
- private IEnumerable<EncapsulateFieldCodeAction> EncapsulateOneField(Document document, TextSpan span, IFieldSymbol field, int index)
- {
- var action1Text = string.Format(Resources.EncapsulateFieldUsages, field.Name);
- var action2Text = string.Format(Resources.EncapsulateField, field.Name);
-
- return new[]
- {
- new EncapsulateFieldCodeAction(new EncapsulateFieldResult(c => SingleEncapsulateFieldResultAsync(document, span, index, true, c)), action1Text),
- new EncapsulateFieldCodeAction(new EncapsulateFieldResult(c => SingleEncapsulateFieldResultAsync(document, span, index, false, c)), action2Text)
- };
- }
-
- private async Task<Result> SingleEncapsulateFieldResultAsync(Document document, TextSpan span, int index, bool updateReferences, CancellationToken cancellationToken)
- {
- var fields = (await GetFieldsAsync(document, span, cancellationToken).ConfigureAwait(false)).ToImmutableArrayOrEmpty();
- //Contract.Requires(fields.Length > index);
-
- var field = fields[index];
- var result = await EncapsulateFieldAsync(field, document, updateReferences, cancellationToken).ConfigureAwait(false);
- if (result == null)
- {
- return new Result(document.Project.Solution, field);
- }
-
- return result;
- }
-
- private async Task<Result> EncapsulateFieldResultAsync(Document document, TextSpan span, bool updateReferences, CancellationToken cancellationToken)
- {
- // probably later we want to add field and reason why it failed.
- var failedFieldSymbols = new List<IFieldSymbol>();
-
- var fields = await GetFieldsAsync(document, span, cancellationToken).ConfigureAwait(false);
- //Contract.Requires(fields.Any());
-
- // For now, build up the multiple field case by encapsulating one at a time.
- Result result = null;
- foreach (var field in fields)
- {
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var compilation = semanticModel.Compilation;
- var currentField = field.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as IFieldSymbol;
-
- // We couldn't resolve this field. skip it
- if (currentField == null)
- {
- failedFieldSymbols.Add(field);
- continue;
- }
-
- result = await EncapsulateFieldAsync(currentField, document, updateReferences, cancellationToken).ConfigureAwait(false);
- if (result == null)
- {
- failedFieldSymbols.Add(field);
- continue;
- }
-
- document = result.Solution.GetDocument(document.Id);
- }
-
- if (result == null)
- {
- return new Result(document.Project.Solution, fields.ToArray());
- }
-
- // add failed field symbol info
- return result.WithFailedFields(failedFieldSymbols);
- }
-
- private async Task<Result> EncapsulateFieldAsync(IFieldSymbol field, Document document, bool updateReferences, CancellationToken cancellationToken)
- {
- var originalField = field;
- var finalNames = GeneratePropertyAndFieldNames(field);
- var finalFieldName = finalNames.Item1;
- var generatedPropertyName = finalNames.Item2;
-
- // Annotate the field declarations so we can find it after rename.
- var fieldDeclaration = field.DeclaringSyntaxReferences.First();
- var declarationAnnotation = new SyntaxAnnotation();
- document = document.WithSyntaxRoot(fieldDeclaration.SyntaxTree.GetRoot(cancellationToken).ReplaceNode(fieldDeclaration.GetSyntax(cancellationToken),
- fieldDeclaration.GetSyntax(cancellationToken).WithAdditionalAnnotations(declarationAnnotation)));
-
- var solution = document.Project.Solution;
-
- foreach (var linkedDocumentId in document.GetLinkedDocumentIds())
- {
- var linkedDocument = solution.GetDocument(linkedDocumentId);
- var linkedRoot = await linkedDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var linkedFieldNode = linkedRoot.FindNode(fieldDeclaration.Span);
- if (linkedFieldNode.Span != fieldDeclaration.Span)
- {
- continue;
- }
-
- var updatedRoot = linkedRoot.ReplaceNode(linkedFieldNode, linkedFieldNode.WithAdditionalAnnotations(declarationAnnotation));
- solution = solution.WithDocumentSyntaxRoot(linkedDocumentId, updatedRoot);
- }
-
- document = solution.GetDocument(document.Id);
-
- // Resolve the annotated symbol and prepare for rename.
-
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var compilation = semanticModel.Compilation;
- field = field.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as IFieldSymbol;
-
- var solutionNeedingProperty = solution;
-
- // We couldn't resolve field after annotating its declaration. Bail
- if (field == null)
- {
- return null;
- }
-
- solutionNeedingProperty = await UpdateReferencesAsync(
- updateReferences, solution, document, field, finalFieldName, generatedPropertyName, cancellationToken).ConfigureAwait(false);
- document = solutionNeedingProperty.GetDocument(document.Id);
-
- var markFieldPrivate = field.DeclaredAccessibility != Accessibility.Private;
- var rewrittenFieldDeclaration = await RewriteFieldNameAndAccessibility(finalFieldName, markFieldPrivate, document, declarationAnnotation, cancellationToken).ConfigureAwait(false);
-
- document = await Formatter.FormatAsync(document.WithSyntaxRoot(rewrittenFieldDeclaration), Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false);
-
- solution = document.Project.Solution;
- foreach (var linkedDocumentId in document.GetLinkedDocumentIds())
- {
- var linkedDocument = solution.GetDocument(linkedDocumentId);
- var updatedLinkedRoot = await RewriteFieldNameAndAccessibility(finalFieldName, markFieldPrivate, linkedDocument, declarationAnnotation, cancellationToken).ConfigureAwait(false);
- var updatedLinkedDocument = await Formatter.FormatAsync(linkedDocument.WithSyntaxRoot(updatedLinkedRoot), Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false);
- solution = updatedLinkedDocument.Project.Solution;
- }
-
- document = solution.GetDocument(document.Id);
-
- semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- compilation = semanticModel.Compilation;
-
- var newRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var newDeclaration = newRoot.GetAnnotatedNodes<SyntaxNode>(declarationAnnotation).First();
- field = semanticModel.GetDeclaredSymbol(newDeclaration, cancellationToken) as IFieldSymbol;
-
- var generatedProperty = GenerateProperty(generatedPropertyName, finalFieldName, originalField.DeclaredAccessibility, originalField, field.ContainingType, new SyntaxAnnotation(), document, cancellationToken);
-
- var solutionWithProperty = await AddPropertyAsync(document, document.Project.Solution, field, generatedProperty, cancellationToken).ConfigureAwait(false);
-
- return new Result(solutionWithProperty, originalField.ToDisplayString(), Glyph.FieldPublic);
- }
-
- static Task<Solution> RenameSymbolAsync (Solution solution, ISymbol symbol, string newName, OptionSet options, Func<Location, bool> filter, Func<IEnumerable<ISymbol>, bool?> hasConflict = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- return (Task<Solution>)renameSymbolMethod.Invoke (null, new object [] { solution, symbol, newName, options, filter, hasConflict, cancellationToken });
- }
-
- private async Task<Solution> UpdateReferencesAsync(
- bool updateReferences, Solution solution, Document document, IFieldSymbol field, string finalFieldName, string generatedPropertyName, CancellationToken cancellationToken)
- {
- if (!updateReferences)
- {
- return solution;
- }
-
- if (field.IsReadOnly)
- {
- // Inside the constructor we want to rename references the field to the final field name.
- var constructorSyntaxes = GetConstructorNodes(field.ContainingType).ToSet();
- if (finalFieldName != field.Name && constructorSyntaxes.Count > 0)
- {
- solution = await RenameSymbolAsync(solution, field, finalFieldName, solution.Workspace.Options,
- location => constructorSyntaxes.Any(c => c.Span.IntersectsWith(location.SourceSpan)), cancellationToken: cancellationToken).ConfigureAwait(false);
- document = solution.GetDocument(document.Id);
-
- var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
-
- field = field.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as IFieldSymbol;
- }
-
- // Outside the constructor we want to rename references to the field to final property name.
- return await RenameSymbolAsync(solution, field, generatedPropertyName, solution.Workspace.Options,
- location => !constructorSyntaxes.Any(c => c.Span.IntersectsWith(location.SourceSpan)), cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- else
- {
- // Just rename everything.
- return await Renamer.RenameSymbolAsync(solution, field, generatedPropertyName, solution.Workspace.Options, cancellationToken).ConfigureAwait(false);
- }
- }
-
- internal abstract IEnumerable<SyntaxNode> GetConstructorNodes(INamedTypeSymbol containingType);
-
- protected async Task<Solution> AddPropertyAsync(Document document, Solution destinationSolution, IFieldSymbol field, IPropertySymbol property, CancellationToken cancellationToken)
- {
- var codeGenerationService = new CSharpCodeGenerationService (document.Project.Solution.Workspace);
-
- var fieldDeclaration = field.DeclaringSyntaxReferences.First();
- var options = new CodeGenerationOptions(contextLocation: fieldDeclaration.SyntaxTree.GetLocation(fieldDeclaration.Span));
-
- var destination = field.ContainingType;
- var updatedDocument = await codeGenerationService.AddPropertyAsync(destinationSolution, destination, property, options, cancellationToken)
- .ConfigureAwait(false);
-
- updatedDocument = await Formatter.FormatAsync(updatedDocument, Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false);
- updatedDocument = await Simplifier.ReduceAsync(updatedDocument, cancellationToken: cancellationToken).ConfigureAwait(false);
-
- return updatedDocument.Project.Solution;
- }
-
- protected IPropertySymbol GenerateProperty(string propertyName, string fieldName, Accessibility accessibility, IFieldSymbol field, INamedTypeSymbol containingSymbol, SyntaxAnnotation annotation, Document document, CancellationToken cancellationToken)
- {
- var factory = document.GetLanguageService<SyntaxGenerator>();
-
- var propertySymbol = annotation.AddAnnotationToSymbol(CodeGenerationSymbolFactory.CreatePropertySymbol(containingType: containingSymbol,
- attributes: SpecializedCollections.EmptyList<AttributeData>(),
- accessibility: ComputeAccessibility(accessibility, field.Type),
- modifiers: new DeclarationModifiers().WithIsStatic (field.IsStatic).WithIsReadOnly (field.IsReadOnly).WithIsUnsafe (field.IsUnsafe()),
- type: field.Type,
- explicitInterfaceSymbol: null,
- name: propertyName,
- parameters: SpecializedCollections.EmptyList<IParameterSymbol>(),
- getMethod: CreateGet(fieldName, field, factory),
- setMethod: field.IsReadOnly || field.IsConst ? null : CreateSet(fieldName, field, factory)));
-
- return Simplifier.Annotation.AddAnnotationToSymbol(
- Formatter.Annotation.AddAnnotationToSymbol(propertySymbol));
- }
-
- protected abstract Tuple<string, string> GeneratePropertyAndFieldNames(IFieldSymbol field);
-
- protected Accessibility ComputeAccessibility(Accessibility accessibility, ITypeSymbol type)
- {
- var computedAccessibility = accessibility;
- if (accessibility == Accessibility.NotApplicable || accessibility == Accessibility.Private)
- {
- computedAccessibility = Accessibility.Public;
- }
-
- var returnTypeAccessibility = type.DetermineMinimalAccessibility();
-
- return AccessibilityUtilities.Minimum(computedAccessibility, returnTypeAccessibility);
- }
-
- protected IMethodSymbol CreateSet(string originalFieldName, IFieldSymbol field, SyntaxGenerator factory)
- {
- var assigned = !field.IsStatic
- ? factory.MemberAccessExpression(
- factory.ThisExpression(),
- factory.IdentifierName(originalFieldName))
- : factory.IdentifierName(originalFieldName);
-
- var body = factory.ExpressionStatement(
- factory.AssignmentStatement(
- assigned.WithAdditionalAnnotations(Simplifier.Annotation),
- factory.IdentifierName("value")));
-
- return CodeGenerationSymbolFactory.CreateAccessorSymbol(SpecializedCollections.EmptyList<AttributeData>(),
- Accessibility.NotApplicable,
- new[] { body }.ToList());
- }
-
- protected IMethodSymbol CreateGet(string originalFieldName, IFieldSymbol field, SyntaxGenerator factory)
- {
- var body = factory.ReturnStatement(
- factory.IdentifierName(originalFieldName));
-
- return CodeGenerationSymbolFactory.CreateAccessorSymbol(SpecializedCollections.EmptyList<AttributeData>(),
- Accessibility.NotApplicable,
- new[] { body }.ToList());
- }
-
- private static readonly char[] s_underscoreCharArray = new[] { '_' };
-
- protected string GeneratePropertyName(string fieldName)
- {
- // Trim leading underscores
- var baseName = fieldName.TrimStart(s_underscoreCharArray);
-
- // Trim leading "m_"
- if (baseName.Length >= 2 && baseName[0] == 'm' && baseName[1] == '_')
- {
- baseName = baseName.Substring(2);
- }
-
- // Take original name if no characters left
- if (baseName.Length == 0)
- {
- baseName = fieldName;
- }
-
- // Make the first character upper case using the "en-US" culture. See discussion at
- // https://github.com/dotnet/roslyn/issues/5524.
- var firstCharacter = EnUSCultureInfo.TextInfo.ToUpper(baseName[0]);
- return firstCharacter.ToString() + baseName.Substring(1);
- }
-
- internal static readonly CultureInfo EnUSCultureInfo = new CultureInfo("en-US");
- static MethodInfo renameSymbolMethod;
-
- protected abstract Task<SyntaxNode> RewriteFieldNameAndAccessibility(string originalFieldName, bool makePrivate, Document document, SyntaxAnnotation declarationAnnotation, CancellationToken cancellationToken);
- protected abstract Task<IEnumerable<IFieldSymbol>> GetFieldsAsync(Document document, TextSpan span, CancellationToken cancellationToken);
-
- internal class Result
- {
- public Result(Solution solutionWithProperty, string name, Glyph glyph)
- {
- this.Solution = solutionWithProperty;
- this.Name = name;
- this.Glyph = glyph;
- }
-
- public Result(Solution solutionWithProperty, string name, Glyph glyph, List<IFieldSymbol> failedFieldSymbols) :
- this(solutionWithProperty, name, glyph)
- {
- this.FailedFields = failedFieldSymbols.ToImmutableArrayOrEmpty();
- }
-
- public Result(Solution originalSolution, params IFieldSymbol[] fields) :
- this(originalSolution, string.Empty, Glyph.Error)
- {
- this.FailedFields = fields.ToImmutableArrayOrEmpty();
- }
-
- public Solution Solution { get; }
- public string Name { get; }
- public Glyph Glyph { get; }
- public ImmutableArray<IFieldSymbol> FailedFields { get; }
-
- public Result WithFailedFields(List<IFieldSymbol> failedFieldSymbols)
- {
- if (failedFieldSymbols.Count == 0)
- {
- return this;
- }
-
- return new Result(Solution, Name, Glyph, failedFieldSymbols);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/CSharpEncapsulateFieldService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/CSharpEncapsulateFieldService.cs
deleted file mode 100644
index 7d11fd3d2c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/CSharpEncapsulateFieldService.cs
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using System.Collections.Immutable;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeRefactorings.EncapsulateField
-{
- internal class CSharpEncapsulateFieldService : AbstractEncapsulateFieldService
- {
- protected async override Task<SyntaxNode> RewriteFieldNameAndAccessibility(string originalFieldName, bool makePrivate, Document document, SyntaxAnnotation declarationAnnotation, CancellationToken cancellationToken)
- {
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
-
- var declarator = root.GetAnnotatedNodes<VariableDeclaratorSyntax>(declarationAnnotation).FirstOrDefault();
-
- // There may be no field to rewrite if this document is part of a set of linked files
- // and the declaration is not conditionally compiled in this document's project.
- if (declarator == null)
- {
- return root;
- }
-
- var tempAnnotation = new SyntaxAnnotation();
- var newIdentifier = SyntaxFactory.Identifier(originalFieldName)
- .WithTrailingTrivia(declarator.Identifier.TrailingTrivia)
- .WithLeadingTrivia(declarator.Identifier.LeadingTrivia);
-
- var updatedDeclarator = declarator.WithIdentifier(newIdentifier).WithAdditionalAnnotations(tempAnnotation);
-
- root = root.ReplaceNode(declarator, updatedDeclarator);
- document = document.WithSyntaxRoot(root);
-
- var declaration = root.GetAnnotatedNodes<SyntaxNode>(tempAnnotation).First().Parent as VariableDeclarationSyntax;
-
- if (declaration.Variables.Count == 1)
- {
- var fieldSyntax = declaration.Parent as FieldDeclarationSyntax;
-
- var modifierKinds = new[] { SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.InternalKeyword, SyntaxKind.PublicKeyword };
-
- if (makePrivate)
- {
- var modifiers = SpecializedCollections.SingletonEnumerable(SyntaxFactory.Token(SyntaxKind.PrivateKeyword))
- .Concat(fieldSyntax.Modifiers.Where(m => !modifierKinds.Contains(m.Kind())));
-
- root = root.ReplaceNode(fieldSyntax, fieldSyntax.WithModifiers(
- SyntaxFactory.TokenList(modifiers))
- .WithAdditionalAnnotations(Formatter.Annotation)
- .WithLeadingTrivia(fieldSyntax.GetLeadingTrivia())
- .WithTrailingTrivia(fieldSyntax.GetTrailingTrivia()));
- }
- }
- else if (declaration.Variables.Count > 1 && makePrivate)
- {
- document = document.WithSyntaxRoot(root);
- var codeGenService = new CSharpCodeGenerationService (document.Project.Solution.Workspace.Services.GetLanguageServices (LanguageNames.CSharp));
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
-
- root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
-
- declarator = root.GetAnnotatedNodes<VariableDeclaratorSyntax>(tempAnnotation).First();
- declaration = declarator.Parent as VariableDeclarationSyntax;
-
- var field = semanticModel.GetDeclaredSymbol(declarator, cancellationToken) as IFieldSymbol;
-
- var fieldToAdd = declarationAnnotation.AddAnnotationToSymbol(CodeGenerationSymbolFactory.CreateFieldSymbol(
- field.GetAttributes(),
- Accessibility.Private,
- new DeclarationModifiers().WithIsStatic (field.IsStatic).WithIsReadOnly(field.IsReadOnly).WithIsConst(field.IsConst),
- field.Type,
- field.Name,
- field.HasConstantValue,
- field.ConstantValue,
- declarator.Initializer));
-
- var withField = await codeGenService.AddFieldAsync(document.Project.Solution, field.ContainingType, fieldToAdd, new CodeGenerationOptions(), cancellationToken).ConfigureAwait(false);
- root = await withField.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
-
- declarator = root.GetAnnotatedNodes<VariableDeclaratorSyntax>(tempAnnotation).First();
- declaration = declarator.Parent as VariableDeclarationSyntax;
-
- return root.RemoveNode(declarator, SyntaxRemoveOptions.KeepNoTrivia);
- }
-
- return root;
- }
-
- protected override async Task<IEnumerable<IFieldSymbol>> GetFieldsAsync(Document document, TextSpan span, CancellationToken cancellationToken)
- {
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
-
- var fields = root.DescendantNodes(d => d.Span.IntersectsWith(span))
- .OfType<FieldDeclarationSyntax>()
- .Where(n => n.Span.IntersectsWith(span));
-
- var declarations = fields.Where(CanEncapsulate).Select(f => f.Declaration);
-
- IEnumerable<VariableDeclaratorSyntax> declarators;
- if (span.IsEmpty)
- {
- // no selection, get all variables
- declarators = declarations.SelectMany(d => d.Variables);
- }
- else
- {
- // has selection, get only the ones that are included in the selection
- declarators = declarations.SelectMany(d => d.Variables.Where(v => v.Span.IntersectsWith(span)));
- }
-
- return declarators.Select(d => semanticModel.GetDeclaredSymbol(d, cancellationToken) as IFieldSymbol)
- .WhereNotNull()
- .Where(f => f.Name.Length != 0);
- }
-
- private bool CanEncapsulate(FieldDeclarationSyntax field)
- {
- return field.Parent is TypeDeclarationSyntax;
- }
-
- protected override Tuple<string, string> GeneratePropertyAndFieldNames(IFieldSymbol field)
- {
- // Special case: if the field is "new", we will preserve its original name and the new keyword.
- if (field.DeclaredAccessibility == Accessibility.Private || IsNew(field))
- {
- // Create some capitalized version of the field name for the property
- return Tuple.Create(field.Name, MakeUnique(GeneratePropertyName(field.Name), field.ContainingType));
- }
- else
- {
- // Generate the new property name using the rules from 695042
- var newPropertyName = GeneratePropertyName(field.Name);
-
- if (newPropertyName == field.Name)
- {
- // If we wind up with the field's old name, give the field the unique version of its current name.
- return Tuple.Create(MakeUnique(GenerateFieldName(field, field.Name), field.ContainingType), newPropertyName);
- }
-
- // Otherwise, ensure the property's name is unique.
- newPropertyName = MakeUnique(newPropertyName, field.ContainingType);
- var newFieldName = GenerateFieldName(field, newPropertyName);
-
- // If converting the new property's name into a field name results in the old field name, we're done.
- if (newFieldName == field.Name)
- {
- return Tuple.Create(newFieldName, newPropertyName);
- }
-
- // Otherwise, ensure the new field name is unique.
- return Tuple.Create(MakeUnique(newFieldName, field.ContainingType), newPropertyName);
- }
- }
-
- private bool IsNew(IFieldSymbol field)
- {
- return field.DeclaringSyntaxReferences.Any(d => d.GetSyntax().GetAncestor<FieldDeclarationSyntax>().Modifiers.Any(SyntaxKind.NewKeyword));
- }
-
- private string GenerateFieldName(IFieldSymbol field, string correspondingPropertyName)
- {
- return char.ToLower(correspondingPropertyName[0]).ToString() + correspondingPropertyName.Substring(1);
- }
-
- protected string MakeUnique(string baseName, INamedTypeSymbol containingType, bool considerBaseMembers = true)
- {
- var containingTypeMemberNames = containingType.GetAccessibleMembersInThisAndBaseTypes<ISymbol>(containingType).Select(m => m.Name);
- return NameGenerator.GenerateUniqueName(baseName, containingTypeMemberNames.ToSet(), StringComparer.Ordinal);
- }
-
- internal override IEnumerable<SyntaxNode> GetConstructorNodes(INamedTypeSymbol containingType)
- {
- return containingType.Constructors.SelectMany(c => c.DeclaringSyntaxReferences.Select(d => d.GetSyntax()));
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/EncapsulateFieldCodeAction.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/EncapsulateFieldCodeAction.cs
deleted file mode 100644
index 84c0c5123e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/EncapsulateFieldCodeAction.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeRefactorings.EncapsulateField
-{
- class EncapsulateFieldCodeAction : CodeAction
- {
- private EncapsulateFieldResult _result;
- private string _title;
-
- public EncapsulateFieldCodeAction(EncapsulateFieldResult result, string title)
- {
- _result = result;
- _title = title;
- }
-
- public override string Title
- {
- get { return _title; }
- }
-
- protected override Task<Solution> GetChangedSolutionAsync(CancellationToken cancellationToken)
- {
- return _result.GetSolutionAsync(cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/EncapsulateFieldResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/EncapsulateFieldResult.cs
deleted file mode 100644
index dac9827496..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/EncapsulateField/EncapsulateFieldResult.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.CodeRefactorings.EncapsulateField
-{
- class EncapsulateFieldResult
- {
- private readonly Func<CancellationToken, Task<AbstractEncapsulateFieldService.Result>> _resultGetter;
-
- public EncapsulateFieldResult(Func<CancellationToken, Task<AbstractEncapsulateFieldService.Result>> resultGetter)
- {
- _resultGetter = resultGetter;
- }
-
- public async Task<string> GetNameAsync(CancellationToken cancellationToken)
- {
- var result = await _resultGetter(cancellationToken).ConfigureAwait(false);
- return result.Name;
- }
-
- public async Task<Glyph> GetGlyphAsync(CancellationToken cancellationToken)
- {
- var result = await _resultGetter(cancellationToken).ConfigureAwait(false);
- return result.Glyph;
- }
-
- public async Task<Solution> GetSolutionAsync(CancellationToken cancellationToken)
- {
- var result = await _resultGetter(cancellationToken).ConfigureAwait(false);
- return result.Solution;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractExtractMethodService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractExtractMethodService.cs
deleted file mode 100644
index dafbe228da..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractExtractMethodService.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract class AbstractExtractMethodService<TValidator, TExtractor, TResult> : IExtractMethodService
- where TValidator : SelectionValidator
- where TExtractor : MethodExtractor
- where TResult : SelectionResult
- {
- protected abstract TValidator CreateSelectionValidator(SemanticDocument document, TextSpan textSpan, OptionSet options);
- protected abstract TExtractor CreateMethodExtractor(TResult selectionResult);
-
- public async Task<ExtractMethodResult> ExtractMethodAsync(
- Document document,
- TextSpan textSpan,
- OptionSet options,
- CancellationToken cancellationToken)
- {
- options = options ?? document.Project.Solution.Workspace.Options;
-
- var semanticDocument = await SemanticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);
-
- var validator = this.CreateSelectionValidator(semanticDocument, textSpan, options);
-
- var selectionResult = await validator.GetValidSelectionAsync(cancellationToken).ConfigureAwait(false);
- if (!selectionResult.ContainsValidContext)
- {
- return new FailedExtractMethodResult(selectionResult.Status);
- }
-
- cancellationToken.ThrowIfCancellationRequested();
-
- // extract method
- var extractor = this.CreateMethodExtractor((TResult)selectionResult);
-
- return await extractor.ExtractMethodAsync(cancellationToken).ConfigureAwait(false);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractSyntaxTriviaService.Result.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractSyntaxTriviaService.Result.cs
deleted file mode 100644
index e15e7edff1..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractSyntaxTriviaService.Result.cs
+++ /dev/null
@@ -1,296 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Roslyn.Utilities;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class AbstractSyntaxTriviaService
- {
- private class Result : ITriviaSavedResult
- {
- private static readonly AnnotationResolver s_defaultAnnotationResolver = ResolveAnnotation;
- private static readonly TriviaResolver s_defaultTriviaResolver = ResolveTrivia;
-
- private readonly SyntaxNode _root;
- private readonly int _endOfLineKind;
-
- private readonly Dictionary<TriviaLocation, SyntaxAnnotation> _annotations;
- private readonly Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> _triviaList;
-
- public Result(
- SyntaxNode root,
- int endOfLineKind,
- Dictionary<TriviaLocation, SyntaxAnnotation> annotations,
- Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> triviaList)
- {
- //Contract.ThrowIfNull(root);
- //Contract.ThrowIfNull(annotations);
- //Contract.ThrowIfNull(triviaList);
-
- _root = root;
- _endOfLineKind = endOfLineKind;
-
- _annotations = annotations;
- _triviaList = triviaList;
- }
-
- public SyntaxNode Root
- {
- get { return _root; }
- }
-
- public SyntaxNode RestoreTrivia(
- SyntaxNode root,
- AnnotationResolver annotationResolver = null,
- TriviaResolver triviaResolver = null)
- {
- var tokens = RecoverTokensAtEdges(root, annotationResolver);
- var map = CreateOldToNewTokensMap(tokens, triviaResolver);
-
- return root.ReplaceTokens(map.Keys, (o, n) => map[o]);
- }
-
- private Dictionary<SyntaxToken, SyntaxToken> CreateOldToNewTokensMap(
- Dictionary<TriviaLocation, PreviousNextTokenPair> tokenPairs,
- Dictionary<TriviaLocation, LeadingTrailingTriviaPair> triviaPairs)
- {
- var map = new Dictionary<SyntaxToken, SyntaxToken>();
- foreach (var pair in CreateUniqueTokenTriviaPairs(tokenPairs, triviaPairs))
- {
- var localCopy = pair;
- var previousToken = map.GetOrAdd(localCopy.Item1.PreviousToken, _ => localCopy.Item1.PreviousToken);
- map[localCopy.Item1.PreviousToken] = previousToken.WithTrailingTrivia(localCopy.Item2.TrailingTrivia);
-
- var nextToken = map.GetOrAdd(localCopy.Item1.NextToken, _ => localCopy.Item1.NextToken);
- map[localCopy.Item1.NextToken] = nextToken.WithLeadingTrivia(localCopy.Item2.LeadingTrivia);
- }
-
- return map;
- }
-
- private LeadingTrailingTriviaPair GetTrailingAndLeadingTrivia(TriviaLocation locationKind, PreviousNextTokenPair tokenPair, IEnumerable<SyntaxTrivia> trivia)
- {
- var list = trivia.ToList();
-
- // there are some noisy trivia
- var index = GetFirstEndOfLineIndex(list);
-
- return new LeadingTrailingTriviaPair
- {
- TrailingTrivia = CreateTriviaListFromTo(list, 0, index),
- LeadingTrivia = CreateTriviaListFromTo(list, index + 1, list.Count - 1)
- };
- }
-
- private int GetFirstEndOfLineIndex(List<SyntaxTrivia> list)
- {
- for (int i = 0; i < list.Count; i++)
- {
- if (list[i].RawKind == _endOfLineKind)
- {
- return i;
- }
- }
-
- return list.Count - 1;
- }
-
- private Dictionary<TriviaLocation, SyntaxToken> RecoverTokensAtEdges(
- SyntaxNode root,
- AnnotationResolver annotationResolver)
- {
- var resolver = annotationResolver ?? s_defaultAnnotationResolver;
-
- var tokens = Enumerable.Range((int)TriviaLocation.BeforeBeginningOfSpan, TriviaLocationsCount)
- .Cast<TriviaLocation>()
- .ToDictionary(
- location => location,
- location => resolver(root, location, _annotations[location]));
-
- // check variable assumption. ordering of two pairs can't be changed
- //Contract.ThrowIfFalse(
- // (tokens[TriviaLocation.BeforeBeginningOfSpan].RawKind == 0 && tokens[TriviaLocation.AfterEndOfSpan].RawKind == 0) ||
- // (tokens[TriviaLocation.BeforeBeginningOfSpan].RawKind == 0 /* && don't care */) ||
- // (/* don't care && */ tokens[TriviaLocation.AfterEndOfSpan].RawKind == 0) ||
- // (tokens[TriviaLocation.BeforeBeginningOfSpan].Span.End <= tokens[TriviaLocation.AfterEndOfSpan].SpanStart));
-
- //Contract.ThrowIfFalse(
- // (tokens[TriviaLocation.AfterBeginningOfSpan].RawKind == 0 && tokens[TriviaLocation.BeforeEndOfSpan].RawKind == 0) ||
- // (tokens[TriviaLocation.AfterBeginningOfSpan].RawKind == 0 /* && don't care */) ||
- // (/* don't care && */ tokens[TriviaLocation.BeforeEndOfSpan].RawKind == 0) ||
- // (tokens[TriviaLocation.AfterBeginningOfSpan] == tokens[TriviaLocation.BeforeEndOfSpan]) ||
- // (tokens[TriviaLocation.AfterBeginningOfSpan].GetPreviousToken(includeZeroWidth: true) == tokens[TriviaLocation.BeforeEndOfSpan]) ||
- // (tokens[TriviaLocation.AfterBeginningOfSpan].Span.End <= tokens[TriviaLocation.BeforeEndOfSpan].SpanStart));
-
- return tokens;
- }
-
- private Dictionary<SyntaxToken, SyntaxToken> CreateOldToNewTokensMap(
- Dictionary<TriviaLocation, SyntaxToken> tokens,
- TriviaResolver triviaResolver)
- {
- var tokenPairs = CreatePreviousNextTokenPairs(tokens);
- var tokenToLeadingTrailingTriviaMap = CreateTokenLeadingTrailingTriviaMap(tokens);
-
- var resolver = triviaResolver ?? s_defaultTriviaResolver;
-
- var triviaPairs = Enumerable.Range((int)TriviaLocation.BeforeBeginningOfSpan, TriviaLocationsCount)
- .Cast<TriviaLocation>()
- .ToDictionary(
- location => location,
- location => CreateTriviaPairs(
- location,
- tokenPairs[location],
- resolver(location, tokenPairs[location], tokenToLeadingTrailingTriviaMap)));
-
- return CreateOldToNewTokensMap(tokenPairs, triviaPairs);
- }
-
- private LeadingTrailingTriviaPair CreateTriviaPairs(
- TriviaLocation locationKind,
- PreviousNextTokenPair tokenPair,
- IEnumerable<SyntaxTrivia> trivia)
- {
- // beginning of the tree
- if (tokenPair.PreviousToken.RawKind == 0)
- {
- return new LeadingTrailingTriviaPair { TrailingTrivia = SpecializedCollections.EmptyEnumerable<SyntaxTrivia>(), LeadingTrivia = trivia };
- }
-
- return GetTrailingAndLeadingTrivia(locationKind, tokenPair, trivia);
- }
-
- private IEnumerable<Tuple<PreviousNextTokenPair, LeadingTrailingTriviaPair>> CreateUniqueTokenTriviaPairs(
- Dictionary<TriviaLocation, PreviousNextTokenPair> tokenPairs,
- Dictionary<TriviaLocation, LeadingTrailingTriviaPair> triviaPairs)
- {
- // if there are dup, duplicated one will be ignored.
- var set = new HashSet<PreviousNextTokenPair>();
- for (int i = (int)TriviaLocation.BeforeBeginningOfSpan; i <= (int)TriviaLocation.AfterEndOfSpan; i++)
- {
- var location = (TriviaLocation)i;
- var key = tokenPairs[location];
- if (set.Contains(key))
- {
- continue;
- }
-
- yield return Tuple.Create(key, triviaPairs[location]);
- set.Add(key);
- }
- }
-
- private Dictionary<SyntaxToken, LeadingTrailingTriviaPair> CreateTokenLeadingTrailingTriviaMap(
- Dictionary<TriviaLocation, SyntaxToken> tokens)
- {
- var tuple = default(LeadingTrailingTriviaPair);
- var map = new Dictionary<SyntaxToken, LeadingTrailingTriviaPair>();
-
- tuple = map.GetOrAdd(tokens[TriviaLocation.BeforeBeginningOfSpan], _ => default(LeadingTrailingTriviaPair));
- map[tokens[TriviaLocation.BeforeBeginningOfSpan]] = new LeadingTrailingTriviaPair
- {
- LeadingTrivia = tuple.LeadingTrivia,
- TrailingTrivia = _triviaList[TriviaLocation.BeforeBeginningOfSpan]
- };
-
- tuple = map.GetOrAdd(tokens[TriviaLocation.AfterBeginningOfSpan], _ => default(LeadingTrailingTriviaPair));
- map[tokens[TriviaLocation.AfterBeginningOfSpan]] = new LeadingTrailingTriviaPair
- {
- LeadingTrivia = _triviaList[TriviaLocation.AfterBeginningOfSpan],
- TrailingTrivia = tuple.TrailingTrivia
- };
-
- tuple = map.GetOrAdd(tokens[TriviaLocation.BeforeEndOfSpan], _ => default(LeadingTrailingTriviaPair));
- map[tokens[TriviaLocation.BeforeEndOfSpan]] = new LeadingTrailingTriviaPair
- {
- LeadingTrivia = tuple.LeadingTrivia,
- TrailingTrivia = _triviaList[TriviaLocation.BeforeEndOfSpan]
- };
-
- tuple = map.GetOrAdd(tokens[TriviaLocation.AfterEndOfSpan], _ => default(LeadingTrailingTriviaPair));
- map[tokens[TriviaLocation.AfterEndOfSpan]] = new LeadingTrailingTriviaPair
- {
- LeadingTrivia = _triviaList[TriviaLocation.AfterEndOfSpan],
- TrailingTrivia = tuple.TrailingTrivia
- };
-
- return map;
- }
-
- private Dictionary<TriviaLocation, PreviousNextTokenPair> CreatePreviousNextTokenPairs(
- Dictionary<TriviaLocation, SyntaxToken> tokens)
- {
- var tokenPairs = new Dictionary<TriviaLocation, PreviousNextTokenPair>();
-
- tokenPairs[TriviaLocation.BeforeBeginningOfSpan] = new PreviousNextTokenPair
- {
- PreviousToken = tokens[TriviaLocation.BeforeBeginningOfSpan],
- NextToken = tokens[TriviaLocation.BeforeBeginningOfSpan].GetNextToken(includeZeroWidth: true)
- };
-
- tokenPairs[TriviaLocation.AfterBeginningOfSpan] = new PreviousNextTokenPair
- {
- PreviousToken = tokens[TriviaLocation.AfterBeginningOfSpan].GetPreviousToken(includeZeroWidth: true),
- NextToken = tokens[TriviaLocation.AfterBeginningOfSpan]
- };
-
- tokenPairs[TriviaLocation.BeforeEndOfSpan] = new PreviousNextTokenPair
- {
- PreviousToken = tokens[TriviaLocation.BeforeEndOfSpan],
- NextToken = tokens[TriviaLocation.BeforeEndOfSpan].GetNextToken(includeZeroWidth: true)
- };
-
- tokenPairs[TriviaLocation.AfterEndOfSpan] = new PreviousNextTokenPair
- {
- PreviousToken = tokens[TriviaLocation.AfterEndOfSpan].GetPreviousToken(includeZeroWidth: true),
- NextToken = tokens[TriviaLocation.AfterEndOfSpan]
- };
-
- return tokenPairs;
- }
-
- private IEnumerable<SyntaxTrivia> CreateTriviaListFromTo(
- List<SyntaxTrivia> list,
- int startIndex,
- int endIndex)
- {
- if (startIndex > endIndex)
- {
- yield break;
- }
-
- for (int i = startIndex; i <= endIndex; i++)
- {
- yield return list[i];
- }
- }
-
- private static SyntaxToken ResolveAnnotation(
- SyntaxNode root,
- TriviaLocation location,
- SyntaxAnnotation annotation)
- {
- return root.GetAnnotatedNodesAndTokens(annotation).FirstOrDefault().AsToken();
- }
-
- private static IEnumerable<SyntaxTrivia> ResolveTrivia(
- TriviaLocation location,
- PreviousNextTokenPair tokenPair,
- Dictionary<SyntaxToken, LeadingTrailingTriviaPair> triviaMap)
- {
- var previousTriviaPair = triviaMap.ContainsKey(tokenPair.PreviousToken) ? triviaMap[tokenPair.PreviousToken] : default(LeadingTrailingTriviaPair);
- var nextTriviaPair = triviaMap.ContainsKey(tokenPair.NextToken) ? triviaMap[tokenPair.NextToken] : default(LeadingTrailingTriviaPair);
-
- var trailingTrivia = previousTriviaPair.TrailingTrivia ?? SpecializedCollections.EmptyEnumerable<SyntaxTrivia>();
- var leadingTrivia = nextTriviaPair.LeadingTrivia ?? SpecializedCollections.EmptyEnumerable<SyntaxTrivia>();
-
- return tokenPair.PreviousToken.TrailingTrivia.Concat(trailingTrivia).Concat(leadingTrivia).Concat(tokenPair.NextToken.LeadingTrivia);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractSyntaxTriviaService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractSyntaxTriviaService.cs
deleted file mode 100644
index 451ed6c336..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/AbstractSyntaxTriviaService.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using ICSharpCode.NRefactory6.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class AbstractSyntaxTriviaService : ISyntaxTriviaService
- {
- private const int TriviaLocationsCount = 4;
-
- //private readonly ISyntaxFactsService _syntaxFactsService;
- private readonly int _endOfLineKind;
-
- protected AbstractSyntaxTriviaService(/*ISyntaxFactsService syntaxFactsService, */int endOfLineKind)
- {
-// _syntaxFactsService = syntaxFactsService;
- _endOfLineKind = endOfLineKind;
- }
-
- public ITriviaSavedResult SaveTriviaAroundSelection(SyntaxNode root, TextSpan textSpan)
- {
- var tokens = GetTokensAtEdges(root, textSpan);
-
- // span must contain after and before spans at the both edges
-
- var triviaList = GetTriviaAtEdges(tokens, textSpan);
-
- var annotations = Enumerable.Range((int)TriviaLocation.BeforeBeginningOfSpan, TriviaLocationsCount)
- .Cast<TriviaLocation>()
- .ToDictionary(location => location, _ => new SyntaxAnnotation());
-
- var map = CreateOldToNewTokensMap(tokens, annotations);
- var rootWithAnnotation = ReplaceTokens(root, map.Keys, (o, n) => map[o]);
-
- return CreateResult(rootWithAnnotation, annotations, triviaList);
- }
-
- private SyntaxNode ReplaceTokens(
- SyntaxNode root,
- IEnumerable<SyntaxToken> oldTokens,
- Func<SyntaxToken, SyntaxToken, SyntaxToken> computeReplacementToken)
- {
- return root.ReplaceTokens(oldTokens, (o, n) => computeReplacementToken(o, n));
- }
-
- private ITriviaSavedResult CreateResult(
- SyntaxNode root,
- Dictionary<TriviaLocation, SyntaxAnnotation> annotations,
- Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> triviaList)
- {
- return new Result(root, _endOfLineKind, annotations, triviaList);
- }
-
- private Dictionary<SyntaxToken, SyntaxToken> CreateOldToNewTokensMap(
- Dictionary<TriviaLocation, SyntaxToken> tokens,
- Dictionary<TriviaLocation, SyntaxAnnotation> annotations)
- {
- var token = default(SyntaxToken);
- var map = new Dictionary<SyntaxToken, SyntaxToken>();
- var emptyList = SpecializedCollections.EmptyEnumerable<SyntaxTrivia>();
-
- token = map.GetOrAdd(tokens[TriviaLocation.BeforeBeginningOfSpan], _ => tokens[TriviaLocation.BeforeBeginningOfSpan]);
- map[tokens[TriviaLocation.BeforeBeginningOfSpan]] = token.WithTrailingTrivia(emptyList).WithAdditionalAnnotations(annotations[TriviaLocation.BeforeBeginningOfSpan]);
-
- token = map.GetOrAdd(tokens[TriviaLocation.AfterBeginningOfSpan], _ => tokens[TriviaLocation.AfterBeginningOfSpan]);
- map[tokens[TriviaLocation.AfterBeginningOfSpan]] = token.WithLeadingTrivia(emptyList).WithAdditionalAnnotations(annotations[TriviaLocation.AfterBeginningOfSpan]);
-
- token = map.GetOrAdd(tokens[TriviaLocation.BeforeEndOfSpan], _ => tokens[TriviaLocation.BeforeEndOfSpan]);
- map[tokens[TriviaLocation.BeforeEndOfSpan]] = token.WithTrailingTrivia(emptyList).WithAdditionalAnnotations(annotations[TriviaLocation.BeforeEndOfSpan]);
-
- token = map.GetOrAdd(tokens[TriviaLocation.AfterEndOfSpan], _ => tokens[TriviaLocation.AfterEndOfSpan]);
- map[tokens[TriviaLocation.AfterEndOfSpan]] = token.WithLeadingTrivia(emptyList).WithAdditionalAnnotations(annotations[TriviaLocation.AfterEndOfSpan]);
-
- return map;
- }
-
- private Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> GetTriviaAtEdges(Dictionary<TriviaLocation, SyntaxToken> tokens, TextSpan textSpan)
- {
- var triviaAtBeginning = SplitTrivia(tokens[TriviaLocation.BeforeBeginningOfSpan], tokens[TriviaLocation.AfterBeginningOfSpan], t => t.FullSpan.End <= textSpan.Start);
- var triviaAtEnd = SplitTrivia(tokens[TriviaLocation.BeforeEndOfSpan], tokens[TriviaLocation.AfterEndOfSpan], t => t.FullSpan.Start < textSpan.End);
-
- var triviaList = new Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>>();
- triviaList[TriviaLocation.BeforeBeginningOfSpan] = triviaAtBeginning.Item1;
- triviaList[TriviaLocation.AfterBeginningOfSpan] = triviaAtBeginning.Item2;
-
- triviaList[TriviaLocation.BeforeEndOfSpan] = triviaAtEnd.Item1;
- triviaList[TriviaLocation.AfterEndOfSpan] = triviaAtEnd.Item2;
- return triviaList;
- }
-
- private Dictionary<TriviaLocation, SyntaxToken> GetTokensAtEdges(SyntaxNode root, TextSpan textSpan)
- {
- var tokens = new Dictionary<TriviaLocation, SyntaxToken>();
- tokens[TriviaLocation.AfterBeginningOfSpan] = root.FindTokenOnRightOfPosition(textSpan.Start, includeSkipped: false);
- tokens[TriviaLocation.BeforeBeginningOfSpan] = tokens[TriviaLocation.AfterBeginningOfSpan].GetPreviousToken(includeZeroWidth: true);
- tokens[TriviaLocation.BeforeEndOfSpan] = root.FindTokenOnLeftOfPosition(textSpan.End, includeSkipped: false);
- tokens[TriviaLocation.AfterEndOfSpan] = tokens[TriviaLocation.BeforeEndOfSpan].GetNextToken(includeZeroWidth: true);
- return tokens;
- }
-
- private static Tuple<List<SyntaxTrivia>, List<SyntaxTrivia>> SplitTrivia(
- SyntaxToken token1,
- SyntaxToken token2,
- Func<SyntaxTrivia, bool> conditionToLeftAtCallSite)
- {
- var triviaLeftAtCallSite = new List<SyntaxTrivia>();
- var triviaMovedToDefinition = new List<SyntaxTrivia>();
-
- foreach (var trivia in token1.TrailingTrivia.Concat(token2.LeadingTrivia))
- {
- if (conditionToLeftAtCallSite(trivia))
- {
- triviaLeftAtCallSite.Add(trivia);
- }
- else
- {
- triviaMovedToDefinition.Add(trivia);
- }
- }
-
- return Tuple.Create(triviaLeftAtCallSite, triviaMovedToDefinition);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpExtractMethodService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpExtractMethodService.cs
deleted file mode 100644
index 128de150a4..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpExtractMethodService.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Text;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class CSharpExtractMethodService : AbstractExtractMethodService<CSharpSelectionValidator, CSharpMethodExtractor, CSharpSelectionResult>
- {
- [ImportingConstructor]
- public CSharpExtractMethodService()
- {
- }
-
- protected override CSharpSelectionValidator CreateSelectionValidator(SemanticDocument document, TextSpan textSpan, OptionSet options)
- {
- return new CSharpSelectionValidator(document, textSpan, options);
- }
-
- protected override CSharpMethodExtractor CreateMethodExtractor(CSharpSelectionResult selectionResult)
- {
- return new CSharpMethodExtractor(selectionResult);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.Analyzer.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.Analyzer.cs
deleted file mode 100644
index 5ba6f8bcc3..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.Analyzer.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor : MethodExtractor
- {
- private class CSharpAnalyzer : Analyzer
- {
- private static readonly HashSet<int> s_nonNoisySyntaxKindSet = new HashSet<int>(new int[] { (int)SyntaxKind.WhitespaceTrivia, (int)SyntaxKind.EndOfLineTrivia });
-
- public static Task<AnalyzerResult> AnalyzeAsync(SelectionResult selectionResult, CancellationToken cancellationToken)
- {
- var analyzer = new CSharpAnalyzer(selectionResult, cancellationToken);
- return analyzer.AnalyzeAsync();
- }
-
- public CSharpAnalyzer(SelectionResult selectionResult, CancellationToken cancellationToken) :
- base(selectionResult, cancellationToken)
- {
- }
-
- protected override VariableInfo CreateFromSymbol(
- Compilation compilation,
- ISymbol symbol,
- ITypeSymbol type,
- VariableStyle style,
- bool variableDeclared)
- {
- return CreateFromSymbolCommon<LocalDeclarationStatementSyntax>(compilation, symbol, type, style, s_nonNoisySyntaxKindSet);
- }
-
- protected override int GetIndexOfVariableInfoToUseAsReturnValue(IList<VariableInfo> variableInfo)
- {
- var numberOfOutParameters = 0;
- var numberOfRefParameters = 0;
-
- int outSymbolIndex = -1;
- int refSymbolIndex = -1;
-
- for (int i = 0; i < variableInfo.Count; i++)
- {
- var variable = variableInfo[i];
-
- // there should be no one set as return value yet
- //Contract.ThrowIfTrue(variable.UseAsReturnValue);
-
- if (!variable.CanBeUsedAsReturnValue)
- {
- continue;
- }
-
- // check modifier
- if (variable.ParameterModifier == ParameterBehavior.Ref)
- {
- numberOfRefParameters++;
- refSymbolIndex = i;
- }
- else if (variable.ParameterModifier == ParameterBehavior.Out)
- {
- numberOfOutParameters++;
- outSymbolIndex = i;
- }
- }
-
- // if there is only one "out" or "ref", that will be converted to return statement.
- if (numberOfOutParameters == 1)
- {
- return outSymbolIndex;
- }
-
- if (numberOfRefParameters == 1)
- {
- return refSymbolIndex;
- }
-
- return -1;
- }
-
- protected override ITypeSymbol GetRangeVariableType(SemanticModel model, IRangeVariableSymbol symbol)
- {
- var info = model.GetSpeculativeTypeInfo(this.SelectionResult.FinalSpan.Start, SyntaxFactory.ParseName(symbol.Name), SpeculativeBindingOption.BindAsExpression);
- if (info.Type.IsErrorType())
- {
- return null;
- }
-
- return info.Type == null || info.Type.SpecialType == Microsoft.CodeAnalysis.SpecialType.System_Object
- ? info.Type
- : info.ConvertedType;
- }
-
- protected override Tuple<SyntaxNode, SyntaxNode> GetFlowAnalysisNodeRange()
- {
- var csharpSelectionResult = this.SelectionResult as CSharpSelectionResult;
-
- var first = csharpSelectionResult.GetFirstStatement();
- var last = csharpSelectionResult.GetLastStatement();
-
- // single statement case
- if (first == last ||
- first.Span.Contains(last.Span))
- {
- return new Tuple<SyntaxNode, SyntaxNode>(first, first);
- }
-
- // multiple statement case
- var firstUnderContainer = csharpSelectionResult.GetFirstStatementUnderContainer();
- var lastUnderContainer = csharpSelectionResult.GetLastStatementUnderContainer();
- return new Tuple<SyntaxNode, SyntaxNode>(firstUnderContainer, lastUnderContainer);
- }
-
- protected override bool ContainsReturnStatementInSelectedCode(IEnumerable<SyntaxNode> jumpOutOfRegionStatements)
- {
- return jumpOutOfRegionStatements.Any (n => n is ReturnStatementSyntax);
- }
-
- protected override bool ReadOnlyFieldAllowed()
- {
- var scope = this.SelectionResult.GetContainingScopeOf<ConstructorDeclarationSyntax>();
- return scope == null;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs
deleted file mode 100644
index 8231f1d2ad..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs
+++ /dev/null
@@ -1,392 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor
- {
- private abstract partial class CSharpCodeGenerator
- {
- private class CallSiteContainerRewriter : CSharpSyntaxRewriter
- {
- private readonly SyntaxNode _outmostCallSiteContainer;
- private readonly IEnumerable<SyntaxNode> _statementsOrFieldToInsert;
- private readonly HashSet<SyntaxAnnotation> _variableToRemoveMap;
- private readonly SyntaxNode _firstStatementOrFieldToReplace;
- private readonly SyntaxNode _lastStatementOrFieldToReplace;
-
- public CallSiteContainerRewriter(
- SyntaxNode outmostCallSiteContainer,
- HashSet<SyntaxAnnotation> variableToRemoveMap,
- SyntaxNode firstStatementOrFieldToReplace,
- SyntaxNode lastStatementOrFieldToReplace,
- IEnumerable<SyntaxNode> statementsOrFieldToInsert)
- {
-// Contract.ThrowIfNull(outmostCallSiteContainer);
-// Contract.ThrowIfNull(variableToRemoveMap);
-// Contract.ThrowIfNull(firstStatementOrFieldToReplace);
-// Contract.ThrowIfNull(lastStatementOrFieldToReplace);
-// Contract.ThrowIfNull(statementsOrFieldToInsert);
-// Contract.ThrowIfTrue(statementsOrFieldToInsert.IsEmpty());
-
- _outmostCallSiteContainer = outmostCallSiteContainer;
-
- _variableToRemoveMap = variableToRemoveMap;
- _statementsOrFieldToInsert = statementsOrFieldToInsert;
-
- _firstStatementOrFieldToReplace = firstStatementOrFieldToReplace;
- _lastStatementOrFieldToReplace = lastStatementOrFieldToReplace;
-
- //Contract.ThrowIfFalse(_firstStatementOrFieldToReplace.Parent == _lastStatementOrFieldToReplace.Parent);
- }
-
- public SyntaxNode Generate()
- {
- return Visit(_outmostCallSiteContainer);
- }
-
- private SyntaxNode ContainerOfStatementsOrFieldToReplace
- {
- get { return _firstStatementOrFieldToReplace.Parent; }
- }
-
- public override SyntaxNode VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node)
- {
- node = (LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node);
-
- var list = new List<VariableDeclaratorSyntax>();
- var triviaList = new List<SyntaxTrivia>();
-
- // go through each var decls in decl statement
- foreach (var variable in node.Declaration.Variables)
- {
- if (_variableToRemoveMap.HasSyntaxAnnotation(variable))
- {
- // if it had initialization, it shouldn't reach here.
- //Contract.ThrowIfFalse(variable.Initializer == null);
-
- // we don't remove trivia around tokens we remove
- triviaList.AddRange(variable.GetLeadingTrivia());
- triviaList.AddRange(variable.GetTrailingTrivia());
- continue;
- }
-
- if (triviaList.Count > 0)
- {
- list.Add(variable.WithPrependedLeadingTrivia(triviaList));
- triviaList.Clear();
- continue;
- }
-
- list.Add(variable);
- }
-
- if (list.Count == 0)
- {
- // nothing has survived. remove this from the list
- if (triviaList.Count == 0)
- {
- return null;
- }
-
- // well, there are trivia associated with the node.
- // we can't just delete the node since then, we will lose
- // the trivia. unfortunately, it is not easy to attach the trivia
- // to next token. for now, create an empty statement and associate the
- // trivia to the statement
-
- // TODO : think about a way to move the trivia to next token.
- return SyntaxFactory.EmptyStatement(SyntaxFactory.Token(SyntaxFactory.TriviaList(triviaList), SyntaxKind.SemicolonToken, SyntaxTriviaList.Create(SyntaxFactory.ElasticMarker)));
- }
-
- if (list.Count == node.Declaration.Variables.Count)
- {
- // nothing has changed, return as it is
- return node;
- }
-
- // TODO : fix how it manipulate trivia later
-
- // if there is left over syntax trivia, it will be attached to leading trivia
- // of semicolon
- return
- SyntaxFactory.LocalDeclarationStatement(
- node.Modifiers,
- SyntaxFactory.VariableDeclaration(
- node.Declaration.Type,
- SyntaxFactory.SeparatedList(list)),
- node.SemicolonToken.WithPrependedLeadingTrivia(triviaList));
- }
-
- // for every kind of extract methods
- public override SyntaxNode VisitBlock(BlockSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- // make sure we visit nodes under the block
- return base.VisitBlock(node);
- }
-
- return node.WithStatements(VisitList(ReplaceStatements(node.Statements)).ToSyntaxList());
- }
-
- public override SyntaxNode VisitSwitchSection(SwitchSectionSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- // make sure we visit nodes under the switch section
- return base.VisitSwitchSection(node);
- }
-
- return node.WithStatements(VisitList(ReplaceStatements(node.Statements)).ToSyntaxList());
- }
-
- // only for single statement or expression
- public override SyntaxNode VisitLabeledStatement(LabeledStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitLabeledStatement(node);
- }
-
- return node.WithStatement(ReplaceStatementIfNeeded(node.Statement));
- }
-
- public override SyntaxNode VisitElseClause(ElseClauseSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitElseClause(node);
- }
-
- return node.WithStatement(ReplaceStatementIfNeeded(node.Statement));
- }
-
- public override SyntaxNode VisitIfStatement(IfStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitIfStatement(node);
- }
-
- return node.WithCondition(VisitNode(node.Condition))
- .WithStatement(ReplaceStatementIfNeeded(node.Statement))
- .WithElse(VisitNode(node.Else));
- }
-
- public override SyntaxNode VisitLockStatement(LockStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitLockStatement(node);
- }
-
- return node.WithExpression(VisitNode(node.Expression))
- .WithStatement(ReplaceStatementIfNeeded(node.Statement));
- }
-
- public override SyntaxNode VisitFixedStatement(FixedStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitFixedStatement(node);
- }
-
- return node.WithDeclaration(VisitNode(node.Declaration))
- .WithStatement(ReplaceStatementIfNeeded(node.Statement));
- }
-
- public override SyntaxNode VisitUsingStatement(UsingStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitUsingStatement(node);
- }
-
- return node.WithDeclaration(VisitNode(node.Declaration))
- .WithExpression(VisitNode(node.Expression))
- .WithStatement(ReplaceStatementIfNeeded(node.Statement));
- }
-
- public override SyntaxNode VisitForEachStatement(ForEachStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitForEachStatement(node);
- }
-
- return node.WithExpression(VisitNode(node.Expression))
- .WithStatement(ReplaceStatementIfNeeded(node.Statement));
- }
-
- public override SyntaxNode VisitForStatement(ForStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitForStatement(node);
- }
-
- return node.WithDeclaration(VisitNode(node.Declaration))
- .WithInitializers(VisitList(node.Initializers))
- .WithCondition(VisitNode(node.Condition))
- .WithIncrementors(VisitList(node.Incrementors))
- .WithStatement(ReplaceStatementIfNeeded(node.Statement));
- }
-
- public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitDoStatement(node);
- }
-
- return node.WithStatement(ReplaceStatementIfNeeded(node.Statement))
- .WithCondition(VisitNode(node.Condition));
- }
-
- public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitWhileStatement(node);
- }
-
- return node.WithCondition(VisitNode(node.Condition))
- .WithStatement(ReplaceStatementIfNeeded(node.Statement));
- }
-
- private TNode VisitNode<TNode>(TNode node) where TNode : SyntaxNode
- {
- return (TNode)Visit(node);
- }
-
- private StatementSyntax ReplaceStatementIfNeeded(StatementSyntax statement)
- {
- //Contract.ThrowIfNull(statement);
-
- // if all three same
- if ((statement != _firstStatementOrFieldToReplace) || (_firstStatementOrFieldToReplace != _lastStatementOrFieldToReplace))
- {
- return statement;
- }
-
- // replace one statement with another
- if (_statementsOrFieldToInsert.Count() == 1)
- {
- return _statementsOrFieldToInsert.Cast<StatementSyntax>().Single();
- }
-
- // replace one statement with multiple statements (see bug # 6310)
- return SyntaxFactory.Block(SyntaxFactory.List(_statementsOrFieldToInsert.Cast<StatementSyntax>()));
- }
-
- private SyntaxList<StatementSyntax> ReplaceStatements(SyntaxList<StatementSyntax> statements)
- {
- // okay, this visit contains the statement
- var newStatements = new List<StatementSyntax>(statements);
-
- var firstStatementIndex = newStatements.FindIndex(s => s == _firstStatementOrFieldToReplace);
- //Contract.ThrowIfFalse(firstStatementIndex >= 0);
-
- var lastStatementIndex = newStatements.FindIndex(s => s == _lastStatementOrFieldToReplace);
- //Contract.ThrowIfFalse(lastStatementIndex >= 0);
-
- //Contract.ThrowIfFalse(firstStatementIndex <= lastStatementIndex);
-
- // remove statement that must be removed
- newStatements.RemoveRange(firstStatementIndex, lastStatementIndex - firstStatementIndex + 1);
-
- // add new statements to replace
- newStatements.InsertRange(firstStatementIndex, _statementsOrFieldToInsert.Cast<StatementSyntax>());
-
- return newStatements.ToSyntaxList();
- }
-
- private SyntaxList<MemberDeclarationSyntax> ReplaceMembers(SyntaxList<MemberDeclarationSyntax> members, bool global)
- {
- // okay, this visit contains the statement
- var newMembers = new List<MemberDeclarationSyntax>(members);
-
- var firstMemberIndex = newMembers.FindIndex(s => s == (global ? _firstStatementOrFieldToReplace.Parent : _firstStatementOrFieldToReplace));
- //Contract.ThrowIfFalse(firstMemberIndex >= 0);
-
- var lastMemberIndex = newMembers.FindIndex(s => s == (global ? _lastStatementOrFieldToReplace.Parent : _lastStatementOrFieldToReplace));
- //Contract.ThrowIfFalse(lastMemberIndex >= 0);
-
- //Contract.ThrowIfFalse(firstMemberIndex <= lastMemberIndex);
-
- // remove statement that must be removed
- newMembers.RemoveRange(firstMemberIndex, lastMemberIndex - firstMemberIndex + 1);
-
- // add new statements to replace
- newMembers.InsertRange(firstMemberIndex,
- _statementsOrFieldToInsert.Select(s => global ? SyntaxFactory.GlobalStatement((StatementSyntax)s) : (MemberDeclarationSyntax)s));
-
- return newMembers.ToSyntaxList();
- }
-
- public override SyntaxNode VisitGlobalStatement(GlobalStatementSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitGlobalStatement(node);
- }
-
- return node.WithStatement(ReplaceStatementIfNeeded(node.Statement));
- }
-
- public override SyntaxNode VisitConstructorDeclaration(ConstructorDeclarationSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitConstructorDeclaration(node);
- }
-
- //Contract.ThrowIfFalse(_firstStatementOrFieldToReplace == _lastStatementOrFieldToReplace);
- return node.WithInitializer((ConstructorInitializerSyntax)_statementsOrFieldToInsert.Single());
- }
-
- public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitClassDeclaration(node);
- }
-
- var newMembers = VisitList(ReplaceMembers(node.Members, global: false));
- return node.WithMembers(newMembers);
- }
-
- public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace)
- {
- return base.VisitStructDeclaration(node);
- }
-
- var newMembers = VisitList(ReplaceMembers(node.Members, global: false));
- return node.WithMembers(newMembers);
- }
-
- public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
- {
- if (node != this.ContainerOfStatementsOrFieldToReplace.Parent)
- {
- // make sure we visit nodes under the block
- return base.VisitCompilationUnit(node);
- }
-
- var newMembers = VisitList(ReplaceMembers(node.Members, global: true));
- return node.WithMembers(newMembers);
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs
deleted file mode 100644
index f9cb3772dc..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor
- {
- private partial class CSharpCodeGenerator
- {
- private class ExpressionCodeGenerator : CSharpCodeGenerator
- {
- public ExpressionCodeGenerator(
- InsertionPoint insertionPoint,
- SelectionResult selectionResult,
- AnalyzerResult analyzerResult) :
- base(insertionPoint, selectionResult, analyzerResult)
- {
- }
-
- public static bool IsExtractMethodOnExpression(SelectionResult code)
- {
- return code.SelectionInExpression;
- }
-
- protected override SyntaxToken CreateMethodName()
- {
- var methodName = "NewMethod";
- var containingScope = this.CSharpSelectionResult.GetContainingScope();
-
- methodName = GetMethodNameBasedOnExpression(methodName, containingScope);
-
- var semanticModel = this.SemanticDocument.SemanticModel;
- var nameGenerator = new UniqueNameGenerator(semanticModel);
- return SyntaxFactory.Identifier(nameGenerator.CreateUniqueMethodName(containingScope, methodName));
- }
-
- private static string GetMethodNameBasedOnExpression(string methodName, SyntaxNode expression)
- {
- if (expression.Parent != null &&
- expression.Parent.Kind() == SyntaxKind.EqualsValueClause &&
- expression.Parent.Parent != null &&
- expression.Parent.Parent.Kind() == SyntaxKind.VariableDeclarator)
- {
- var name = ((VariableDeclaratorSyntax)expression.Parent.Parent).Identifier.ValueText;
- return (name != null && name.Length > 0) ? MakeMethodName("Get", name) : methodName;
- }
-
- if (expression is MemberAccessExpressionSyntax)
- {
- expression = ((MemberAccessExpressionSyntax)expression).Name;
- }
-
- if (expression is NameSyntax)
- {
- SimpleNameSyntax unqualifiedName;
-
- switch (expression.Kind())
- {
- case SyntaxKind.IdentifierName:
- case SyntaxKind.GenericName:
- unqualifiedName = (SimpleNameSyntax)expression;
- break;
- case SyntaxKind.QualifiedName:
- unqualifiedName = ((QualifiedNameSyntax)expression).Right;
- break;
- case SyntaxKind.AliasQualifiedName:
- unqualifiedName = ((AliasQualifiedNameSyntax)expression).Name;
- break;
- default:
- throw new System.NotSupportedException("Unexpected name kind: " + expression.Kind().ToString());
- }
-
- var unqualifiedNameIdentifierValueText = unqualifiedName.Identifier.ValueText;
- return (unqualifiedNameIdentifierValueText != null && unqualifiedNameIdentifierValueText.Length > 0) ? MakeMethodName("Get", unqualifiedNameIdentifierValueText) : methodName;
- }
-
- return methodName;
- }
-
- protected override IEnumerable<StatementSyntax> GetInitialStatementsForMethodDefinitions()
- {
- //Contract.ThrowIfFalse(IsExtractMethodOnExpression(this.CSharpSelectionResult));
-
- ExpressionSyntax expression = null;
-
- // special case for array initializer
- var returnType = (ITypeSymbol)this.AnalyzerResult.ReturnType;
- var containingScope = this.CSharpSelectionResult.GetContainingScope();
-
- if (returnType.TypeKind == TypeKind.Array && containingScope is InitializerExpressionSyntax)
- {
- var typeSyntax = returnType.GenerateTypeSyntax();
-
- expression = SyntaxFactory.ArrayCreationExpression(typeSyntax as ArrayTypeSyntax, containingScope as InitializerExpressionSyntax);
- }
- else
- {
- expression = containingScope as ExpressionSyntax;
- }
-
- if (this.AnalyzerResult.HasReturnType)
- {
- return SpecializedCollections.SingletonEnumerable<StatementSyntax>(
- SyntaxFactory.ReturnStatement(
- WrapInCheckedExpressionIfNeeded(expression)));
- }
- else
- {
- return SpecializedCollections.SingletonEnumerable<StatementSyntax>(
- SyntaxFactory.ExpressionStatement(
- WrapInCheckedExpressionIfNeeded(expression)));
- }
- }
-
- private ExpressionSyntax WrapInCheckedExpressionIfNeeded(ExpressionSyntax expression)
- {
- var kind = this.CSharpSelectionResult.UnderCheckedExpressionContext();
- if (kind == SyntaxKind.None)
- {
- return expression;
- }
-
- return SyntaxFactory.CheckedExpression(kind, expression);
- }
-
- protected override SyntaxNode GetOutermostCallSiteContainerToProcess(CancellationToken cancellationToken)
- {
- var callSiteContainer = GetCallSiteContainerFromOutermostMoveInVariable(cancellationToken);
- if (callSiteContainer != null)
- {
- return callSiteContainer;
- }
- else
- {
- return GetCallSiteContainerFromExpression();
- }
- }
-
- private SyntaxNode GetCallSiteContainerFromExpression()
- {
- var container = this.CSharpSelectionResult.GetInnermostStatementContainer();
-
-// Contract.ThrowIfNull(container);
-// Contract.ThrowIfFalse(container.IsStatementContainerNode() ||
-// container is TypeDeclarationSyntax ||
-// container is ConstructorDeclarationSyntax ||
-// container is CompilationUnitSyntax);
-
- return container;
- }
-
- protected override SyntaxNode GetFirstStatementOrInitializerSelectedAtCallSite()
- {
- var scope = (SyntaxNode)this.CSharpSelectionResult.GetContainingScopeOf<StatementSyntax>();
- if (scope == null)
- {
- scope = this.CSharpSelectionResult.GetContainingScopeOf<FieldDeclarationSyntax>();
- }
-
- if (scope == null)
- {
- scope = this.CSharpSelectionResult.GetContainingScopeOf<ConstructorInitializerSyntax>();
- }
-
- return scope;
- }
-
- protected override SyntaxNode GetLastStatementOrInitializerSelectedAtCallSite()
- {
- return GetFirstStatementOrInitializerSelectedAtCallSite();
- }
-
- protected override async Task<SyntaxNode> GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(
- SyntaxAnnotation callSiteAnnotation, CancellationToken cancellationToken)
- {
- var enclosingStatement = GetFirstStatementOrInitializerSelectedAtCallSite();
- var callSignature = CreateCallSignature().WithAdditionalAnnotations(callSiteAnnotation);
- var invocation = callSignature.IsKind(SyntaxKind.AwaitExpression) ? ((AwaitExpressionSyntax)callSignature).Expression : callSignature;
-
- var sourceNode = this.CSharpSelectionResult.GetContainingScope();
-// Contract.ThrowIfTrue(
-// sourceNode.Parent is MemberAccessExpressionSyntax && ((MemberAccessExpressionSyntax)sourceNode.Parent).Name == sourceNode,
-// "invalid scope. given scope is not an expression");
-
- // To lower the chances that replacing sourceNode with callSignature will break the user's
- // code, we make the enclosing statement semantically explicit. This ends up being a little
- // bit more work because we need to annotate the sourceNode so that we can get back to it
- // after rewriting the enclosing statement.
- var updatedDocument = this.SemanticDocument.Document;
- var sourceNodeAnnotation = new SyntaxAnnotation();
- var enclosingStatementAnnotation = new SyntaxAnnotation();
- var newEnclosingStatement = enclosingStatement
- .ReplaceNode(sourceNode, sourceNode.WithAdditionalAnnotations(sourceNodeAnnotation))
- .WithAdditionalAnnotations(enclosingStatementAnnotation);
-
- updatedDocument = await updatedDocument.ReplaceNodeAsync(enclosingStatement, newEnclosingStatement, cancellationToken).ConfigureAwait(false);
-
- var updatedRoot = await updatedDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- newEnclosingStatement = updatedRoot.GetAnnotatedNodesAndTokens(enclosingStatementAnnotation).Single().AsNode();
-
- // because of the complexifiction we cannot guarantee that there is only one annotation.
- // however complexification of names is prepended, so the last annotation should be the original one.
- sourceNode = updatedRoot.GetAnnotatedNodesAndTokens(sourceNodeAnnotation).Last().AsNode();
-
- // we want to replace the old identifier with a invocation expression, but because of MakeExplicit we might have
- // a member access now instead of the identifer. So more syntax fiddling is needed.
- if (sourceNode.Parent.Kind() == SyntaxKind.SimpleMemberAccessExpression &&
- ((ExpressionSyntax)sourceNode).IsRightSideOfDot())
- {
- var explicitMemberAccess = (MemberAccessExpressionSyntax)sourceNode.Parent;
- var replacementMemberAccess = explicitMemberAccess.CopyAnnotationsTo(
- SyntaxFactory.MemberAccessExpression(
- sourceNode.Parent.Kind(),
- explicitMemberAccess.Expression,
- (SimpleNameSyntax)((InvocationExpressionSyntax)invocation).Expression));
- var newInvocation = SyntaxFactory.InvocationExpression(
- replacementMemberAccess,
- ((InvocationExpressionSyntax)invocation).ArgumentList);
-
- var newCallSignature = callSignature != invocation ?
- callSignature.ReplaceNode(invocation, newInvocation) : invocation.CopyAnnotationsTo(newInvocation);
-
- sourceNode = sourceNode.Parent;
- callSignature = newCallSignature;
- }
-
- return newEnclosingStatement.ReplaceNode(sourceNode, callSignature);
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.MultipleStatementsCodeGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.MultipleStatementsCodeGenerator.cs
deleted file mode 100644
index 4da57f7be2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.MultipleStatementsCodeGenerator.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor
- {
- private partial class CSharpCodeGenerator
- {
- class MultipleStatementsCodeGenerator : CSharpCodeGenerator
- {
- public MultipleStatementsCodeGenerator(
- InsertionPoint insertionPoint,
- SelectionResult selectionResult,
- AnalyzerResult analyzerResult) :
- base(insertionPoint, selectionResult, analyzerResult)
- {
- }
-
- public static bool IsExtractMethodOnMultipleStatements(SelectionResult code)
- {
- var result = (CSharpSelectionResult)code;
- var first = result.GetFirstStatement();
- var last = result.GetLastStatement();
-
- if (first != last)
- {
- //var firstUnderContainer = result.GetFirstStatementUnderContainer();
- //var lastUnderContainer = result.GetLastStatementUnderContainer();
- //Contract.ThrowIfFalse(firstUnderContainer.Parent == lastUnderContainer.Parent);
- return true;
- }
-
- return false;
- }
-
- protected override SyntaxToken CreateMethodName()
- {
- // change this to more smarter one.
- var semanticModel = this.SemanticDocument.SemanticModel;
- var nameGenerator = new UniqueNameGenerator(semanticModel);
- var scope = this.CSharpSelectionResult.GetContainingScope();
- return SyntaxFactory.Identifier(nameGenerator.CreateUniqueMethodName(scope, "NewMethod"));
- }
-
- protected override IEnumerable<StatementSyntax> GetInitialStatementsForMethodDefinitions()
- {
- var firstSeen = false;
- var firstStatementUnderContainer = this.CSharpSelectionResult.GetFirstStatementUnderContainer();
- var lastStatementUnderContainer = this.CSharpSelectionResult.GetLastStatementUnderContainer();
-
- var list = new List<StatementSyntax>();
- foreach (var statement in GetStatementsFromContainer(firstStatementUnderContainer.Parent))
- {
- // reset first seen
- if (!firstSeen)
- {
- firstSeen = statement == firstStatementUnderContainer;
- }
-
- // continue until we see the first statement
- if (!firstSeen)
- {
- continue;
- }
-
- list.Add(statement);
-
- // exit if we see last statement
- if (statement == lastStatementUnderContainer)
- {
- break;
- }
- }
-
- return list;
- }
-
- protected override SyntaxNode GetOutermostCallSiteContainerToProcess(CancellationToken cancellationToken)
- {
- var callSiteContainer = GetCallSiteContainerFromOutermostMoveInVariable(cancellationToken);
- if (callSiteContainer != null)
- {
- return callSiteContainer;
- }
- else
- {
- var firstStatement = this.CSharpSelectionResult.GetFirstStatementUnderContainer();
- return firstStatement.Parent;
- }
- }
-
- private SyntaxList<StatementSyntax> GetStatementsFromContainer(SyntaxNode node)
- {
-// Contract.ThrowIfNull(node);
-// Contract.ThrowIfFalse(node.IsStatementContainerNode());
-
- var blockNode = node as BlockSyntax;
- if (blockNode != null)
- {
- return blockNode.Statements;
- }
-
- var switchSecionNode = node as SwitchSectionSyntax;
- if (switchSecionNode != null)
- {
- return switchSecionNode.Statements;
- }
-
- return new SyntaxList<StatementSyntax> ();//Contract.FailWithReturn<SyntaxList<StatementSyntax>>("unknown statements container!");
- }
-
- protected override SyntaxNode GetFirstStatementOrInitializerSelectedAtCallSite()
- {
- return this.CSharpSelectionResult.GetFirstStatementUnderContainer();
- }
-
- protected override SyntaxNode GetLastStatementOrInitializerSelectedAtCallSite()
- {
- return this.CSharpSelectionResult.GetLastStatementUnderContainer();
- }
-
- protected override Task<SyntaxNode> GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(
- SyntaxAnnotation callSiteAnnotation, CancellationToken cancellationToken)
- {
- var statement = GetStatementContainingInvocationToExtractedMethodWorker();
- return Task.FromResult<SyntaxNode>(statement.WithAdditionalAnnotations(callSiteAnnotation));
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.SingleStatementCodeGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.SingleStatementCodeGenerator.cs
deleted file mode 100644
index 1d42d4b3db..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.SingleStatementCodeGenerator.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor
- {
- private partial class CSharpCodeGenerator
- {
- class SingleStatementCodeGenerator : CSharpCodeGenerator
- {
- public SingleStatementCodeGenerator(
- InsertionPoint insertionPoint,
- SelectionResult selectionResult,
- AnalyzerResult analyzerResult) :
- base(insertionPoint, selectionResult, analyzerResult)
- {
- }
-
- public static bool IsExtractMethodOnSingleStatement(SelectionResult code)
- {
- var result = (CSharpSelectionResult)code;
- var firstStatement = result.GetFirstStatement();
- var lastStatement = result.GetLastStatement();
-
- return firstStatement == lastStatement || firstStatement.Span.Contains(lastStatement.Span);
- }
-
- protected override SyntaxToken CreateMethodName()
- {
- // change this to more smarter one.
- var semanticModel = this.SemanticDocument.SemanticModel;
- var nameGenerator = new UniqueNameGenerator(semanticModel);
- var scope = this.CSharpSelectionResult.GetContainingScope();
- return SyntaxFactory.Identifier(nameGenerator.CreateUniqueMethodName(scope, "NewMethod"));
- }
-
- protected override IEnumerable<StatementSyntax> GetInitialStatementsForMethodDefinitions()
- {
- // Contract.ThrowIfFalse(IsExtractMethodOnSingleStatement(this.CSharpSelectionResult));
-
- return SpecializedCollections.SingletonEnumerable<StatementSyntax>(this.CSharpSelectionResult.GetFirstStatement());
- }
-
- protected override SyntaxNode GetOutermostCallSiteContainerToProcess(CancellationToken cancellationToken)
- {
- var callSiteContainer = GetCallSiteContainerFromOutermostMoveInVariable(cancellationToken);
- if (callSiteContainer != null)
- {
- return callSiteContainer;
- }
- else
- {
- var firstStatement = this.CSharpSelectionResult.GetFirstStatement();
- return firstStatement.Parent;
- }
- }
-
- protected override SyntaxNode GetFirstStatementOrInitializerSelectedAtCallSite()
- {
- return this.CSharpSelectionResult.GetFirstStatement();
- }
-
- protected override SyntaxNode GetLastStatementOrInitializerSelectedAtCallSite()
- {
- // it is a single statement case. either first statement is same as last statement or
- // last statement belongs (embedded statement) to the first statement.
- return this.CSharpSelectionResult.GetFirstStatement();
- }
-
- protected override Task<SyntaxNode> GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(
- SyntaxAnnotation callSiteAnnotation, CancellationToken cancellationToken)
- {
- var statement = GetStatementContainingInvocationToExtractedMethodWorker();
- return Task.FromResult<SyntaxNode>(statement.WithAdditionalAnnotations(callSiteAnnotation));
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.cs
deleted file mode 100644
index 6fbdfa5f52..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.CSharpCodeGenerator.cs
+++ /dev/null
@@ -1,583 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor
- {
- private abstract partial class CSharpCodeGenerator : CodeGenerator<StatementSyntax, ExpressionSyntax, SyntaxNode>
- {
- private SyntaxToken _methodName;
-
- public static async Task<GeneratedCode> GenerateAsync(
- InsertionPoint insertionPoint,
- SelectionResult selectionResult,
- AnalyzerResult analyzerResult,
- CancellationToken cancellationToken)
- {
- var codeGenerator = Create(insertionPoint, selectionResult, analyzerResult);
- return await codeGenerator.GenerateAsync(cancellationToken).ConfigureAwait(false);
- }
-
- private static CSharpCodeGenerator Create(
- InsertionPoint insertionPoint,
- SelectionResult selectionResult,
- AnalyzerResult analyzerResult)
- {
- if (ExpressionCodeGenerator.IsExtractMethodOnExpression(selectionResult))
- {
- return new ExpressionCodeGenerator(insertionPoint, selectionResult, analyzerResult);
- }
-
- if (SingleStatementCodeGenerator.IsExtractMethodOnSingleStatement(selectionResult))
- {
- return new SingleStatementCodeGenerator(insertionPoint, selectionResult, analyzerResult);
- }
-
- if (MultipleStatementsCodeGenerator.IsExtractMethodOnMultipleStatements(selectionResult))
- {
- return new MultipleStatementsCodeGenerator(insertionPoint, selectionResult, analyzerResult);
- }
-
- return null;//Contract.FailWithReturn<CSharpCodeGenerator>("Unknown selection");
- }
-
- protected CSharpCodeGenerator(
- InsertionPoint insertionPoint,
- SelectionResult selectionResult,
- AnalyzerResult analyzerResult) :
- base(insertionPoint, selectionResult, analyzerResult)
- {
- //Contract.ThrowIfFalse(this.SemanticDocument == selectionResult.SemanticDocument);
-
- var nameToken = (SyntaxToken)CreateMethodName();
- _methodName = nameToken.WithAdditionalAnnotations(this.MethodNameAnnotation);
- }
-
- private CSharpSelectionResult CSharpSelectionResult
- {
- get { return (CSharpSelectionResult)this.SelectionResult; }
- }
-
- protected override SyntaxNode GetPreviousMember(SemanticDocument document)
- {
- var node = this.InsertionPoint.With(document).GetContext();
- return (node.Parent is GlobalStatementSyntax) ? node.Parent : node;
- }
-
- protected override OperationStatus<IMethodSymbol> GenerateMethodDefinition(CancellationToken cancellationToken)
- {
- var result = CreateMethodBody(cancellationToken);
-
- var methodSymbol = CodeGenerationSymbolFactory.CreateMethodSymbol(
- attributes: SpecializedCollections.EmptyList<AttributeData>(),
- accessibility: Accessibility.Private,
- modifiers: CreateMethodModifiers(),
- returnType: this.AnalyzerResult.ReturnType,
- explicitInterfaceSymbol: null,
- name: _methodName.ToString(),
- typeParameters: CreateMethodTypeParameters(cancellationToken),
- parameters: CreateMethodParameters(),
- statements: result.Data);
-
- return result.With(
- this.MethodDefinitionAnnotation.AddAnnotationToSymbol(
- Formatter.Annotation.AddAnnotationToSymbol(methodSymbol)));
- }
-
- protected override async Task<SyntaxNode> GenerateBodyForCallSiteContainerAsync(CancellationToken cancellationToken)
- {
- var container = this.GetOutermostCallSiteContainerToProcess(cancellationToken);
- var variableMapToRemove = CreateVariableDeclarationToRemoveMap(
- this.AnalyzerResult.GetVariablesToMoveIntoMethodDefinition(cancellationToken), cancellationToken);
- var firstStatementToRemove = GetFirstStatementOrInitializerSelectedAtCallSite();
- var lastStatementToRemove = GetLastStatementOrInitializerSelectedAtCallSite();
-
- //Contract.ThrowIfFalse(firstStatementToRemove.Parent == lastStatementToRemove.Parent);
-
- var statementsToInsert = await CreateStatementsOrInitializerToInsertAtCallSiteAsync(cancellationToken).ConfigureAwait(false);
-
- var callSiteGenerator =
- new CallSiteContainerRewriter(
- container,
- variableMapToRemove,
- firstStatementToRemove,
- lastStatementToRemove,
- statementsToInsert);
-
- return container.CopyAnnotationsTo(callSiteGenerator.Generate()).WithAdditionalAnnotations(Formatter.Annotation);
- }
-
- private async Task<IEnumerable<SyntaxNode>> CreateStatementsOrInitializerToInsertAtCallSiteAsync(CancellationToken cancellationToken)
- {
- var selectedNode = this.GetFirstStatementOrInitializerSelectedAtCallSite();
-
- // field initializer and constructor initializer case
- if (selectedNode is ConstructorInitializerSyntax ||
- selectedNode is FieldDeclarationSyntax)
- {
- var statement = await GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(this.CallSiteAnnotation, cancellationToken).ConfigureAwait(false);
- return SpecializedCollections.SingletonEnumerable(statement);
- }
-
- // regular case
- var semanticModel = this.SemanticDocument.SemanticModel;
- var context = this.InsertionPoint.GetContext();
- var postProcessor = new PostProcessor(semanticModel, context.SpanStart);
- var statements = SpecializedCollections.EmptyEnumerable<StatementSyntax>();
-
- statements = AddSplitOrMoveDeclarationOutStatementsToCallSite(statements, cancellationToken);
- statements = postProcessor.MergeDeclarationStatements(statements);
- statements = AddAssignmentStatementToCallSite(statements, cancellationToken);
- statements = await AddInvocationAtCallSiteAsync(statements, cancellationToken).ConfigureAwait(false);
- statements = AddReturnIfUnreachable(statements, cancellationToken);
-
- return statements;
- }
-
- private SimpleNameSyntax CreateMethodNameForInvocation()
- {
- return this.AnalyzerResult.MethodTypeParametersInDeclaration.Count == 0
- ? (SimpleNameSyntax)SyntaxFactory.IdentifierName(_methodName)
- : SyntaxFactory.GenericName(_methodName, SyntaxFactory.TypeArgumentList(CreateMethodCallTypeVariables()));
- }
-
- private SeparatedSyntaxList<TypeSyntax> CreateMethodCallTypeVariables()
- {
- //Contract.ThrowIfTrue(this.AnalyzerResult.MethodTypeParametersInDeclaration.Count == 0);
-
- // propagate any type variable used in extracted code
- var typeVariables = new List<TypeSyntax>();
- foreach (var methodTypeParameter in this.AnalyzerResult.MethodTypeParametersInDeclaration)
- {
- typeVariables.Add(SyntaxFactory.ParseTypeName(methodTypeParameter.Name));
- }
-
- return SyntaxFactory.SeparatedList(typeVariables);
- }
-
- protected SyntaxNode GetCallSiteContainerFromOutermostMoveInVariable(CancellationToken cancellationToken)
- {
- var outmostVariable = GetOutermostVariableToMoveIntoMethodDefinition(cancellationToken);
- if (outmostVariable == null)
- {
- return null;
- }
-
- var idToken = outmostVariable.GetIdentifierTokenAtDeclaration(this.SemanticDocument);
- var declStatement = idToken.GetAncestor<LocalDeclarationStatementSyntax>();
-// Contract.ThrowIfNull(declStatement);
-// Contract.ThrowIfFalse(declStatement.Parent.IsStatementContainerNode());
-
- return declStatement.Parent;
- }
-
- private DeclarationModifiers CreateMethodModifiers()
- {
- var isUnsafe = this.CSharpSelectionResult.ShouldPutUnsafeModifier();
- var isAsync = this.CSharpSelectionResult.ShouldPutAsyncModifier();
- var result = DeclarationModifiers.None;
- if (isUnsafe)
- result = result.WithIsUnsafe (true);
- if (isAsync)
- result = result.WithAsync (true);
- if (!this.AnalyzerResult.UseInstanceMember)
- result = result.WithIsStatic (true);
- return result;
- }
-
- private static SyntaxKind GetParameterRefSyntaxKind(ParameterBehavior parameterBehavior)
- {
- return parameterBehavior == ParameterBehavior.Ref ?
- SyntaxKind.RefKeyword :
- parameterBehavior == ParameterBehavior.Out ?
- SyntaxKind.OutKeyword : SyntaxKind.None;
- }
-
- private OperationStatus<List<SyntaxNode>> CreateMethodBody(CancellationToken cancellationToken)
- {
- var statements = GetInitialStatementsForMethodDefinitions();
-
- statements = SplitOrMoveDeclarationIntoMethodDefinition(statements, cancellationToken);
- statements = MoveDeclarationOutFromMethodDefinition(statements, cancellationToken);
- statements = AppendReturnStatementIfNeeded(statements);
- statements = CleanupCode(statements);
-
- // set output so that we can use it in negative preview
- var wrapped = WrapInCheckStatementIfNeeded(statements);
- return CheckActiveStatements(statements).With(wrapped.ToList<SyntaxNode>());
- }
-
- private IEnumerable<StatementSyntax> WrapInCheckStatementIfNeeded(IEnumerable<StatementSyntax> statements)
- {
- var kind = this.CSharpSelectionResult.UnderCheckedStatementContext();
- if (kind == SyntaxKind.None)
- {
- return statements;
- }
-
- if (statements.Skip(1).Any())
- {
- return SpecializedCollections.SingletonEnumerable<StatementSyntax>(SyntaxFactory.CheckedStatement(kind, SyntaxFactory.Block(statements)));
- }
-
- var block = statements.Single() as BlockSyntax;
- if (block != null)
- {
- return SpecializedCollections.SingletonEnumerable<StatementSyntax>(SyntaxFactory.CheckedStatement(kind, block));
- }
-
- return SpecializedCollections.SingletonEnumerable<StatementSyntax>(SyntaxFactory.CheckedStatement(kind, SyntaxFactory.Block(statements)));
- }
-
- private IEnumerable<StatementSyntax> CleanupCode(IEnumerable<StatementSyntax> statements)
- {
- var semanticModel = this.SemanticDocument.SemanticModel;
- var context = this.InsertionPoint.GetContext();
- var postProcessor = new PostProcessor(semanticModel, context.SpanStart);
-
- statements = postProcessor.RemoveRedundantBlock(statements);
- statements = postProcessor.RemoveDeclarationAssignmentPattern(statements);
- statements = postProcessor.RemoveInitializedDeclarationAndReturnPattern(statements);
-
- return statements;
- }
-
- private OperationStatus CheckActiveStatements(IEnumerable<StatementSyntax> statements)
- {
- var count = statements.Count();
- if (count == 0)
- {
- return OperationStatus.NoActiveStatement;
- }
-
- if (count == 1)
- {
- var returnStatement = statements.Single() as ReturnStatementSyntax;
- if (returnStatement != null && returnStatement.Expression == null)
- {
- return OperationStatus.NoActiveStatement;
- }
- }
-
- foreach (var statement in statements)
- {
- var declStatement = statement as LocalDeclarationStatementSyntax;
- if (declStatement == null)
- {
- // found one
- return OperationStatus.Succeeded;
- }
-
- foreach (var variable in declStatement.Declaration.Variables)
- {
- if (variable.Initializer != null)
- {
- // found one
- return OperationStatus.Succeeded;
- }
- }
- }
-
- return OperationStatus.NoActiveStatement;
- }
-
- private IEnumerable<StatementSyntax> MoveDeclarationOutFromMethodDefinition(
- IEnumerable<StatementSyntax> statements, CancellationToken cancellationToken)
- {
- var variableToRemoveMap = CreateVariableDeclarationToRemoveMap(
- this.AnalyzerResult.GetVariablesToMoveOutToCallSiteOrDelete(cancellationToken), cancellationToken);
-
- foreach (var statement in statements)
- {
- var declarationStatement = statement as LocalDeclarationStatementSyntax;
- if (declarationStatement == null)
- {
- // if given statement is not decl statement, do nothing.
- yield return statement;
- continue;
- }
-
- var expressionStatements = new List<StatementSyntax>();
- var list = new List<VariableDeclaratorSyntax>();
- var triviaList = new List<SyntaxTrivia>();
-
- // When we modify the declaration to an initialization we have to preserve the leading trivia
- var firstVariableToAttachTrivia = true;
-
- // go through each var decls in decl statement, and create new assignment if
- // variable is initialized at decl.
- foreach (var variableDeclaration in declarationStatement.Declaration.Variables)
- {
- if (variableToRemoveMap.HasSyntaxAnnotation(variableDeclaration))
- {
- if (variableDeclaration.Initializer != null)
- {
- SyntaxToken identifier = ApplyTriviaFromDeclarationToAssignmentIdentifier(declarationStatement, firstVariableToAttachTrivia, variableDeclaration);
-
- // move comments with the variable here
- expressionStatements.Add(CreateAssignmentExpressionStatement(identifier, variableDeclaration.Initializer.Value));
- }
- else
- {
- // we don't remove trivia around tokens we remove
- triviaList.AddRange(variableDeclaration.GetLeadingTrivia());
- triviaList.AddRange(variableDeclaration.GetTrailingTrivia());
- }
-
- firstVariableToAttachTrivia = false;
- continue;
- }
-
- // Prepend the trivia from the declarations without initialization to the next persisting variable declaration
- if (triviaList.Count > 0)
- {
- list.Add(variableDeclaration.WithPrependedLeadingTrivia(triviaList));
- triviaList.Clear();
- firstVariableToAttachTrivia = false;
- continue;
- }
-
- firstVariableToAttachTrivia = false;
- list.Add(variableDeclaration);
- }
-
- if (list.Count == 0 && triviaList.Count > 0)
- {
- // well, there are trivia associated with the node.
- // we can't just delete the node since then, we will lose
- // the trivia. unfortunately, it is not easy to attach the trivia
- // to next token. for now, create an empty statement and associate the
- // trivia to the statement
-
- // TODO : think about a way to trivia attached to next token
- yield return SyntaxFactory.EmptyStatement(SyntaxFactory.Token(SyntaxFactory.TriviaList(triviaList), SyntaxKind.SemicolonToken, SyntaxTriviaList.Create(SyntaxFactory.ElasticMarker)));
- triviaList.Clear();
- }
-
- // return survived var decls
- if (list.Count > 0)
- {
- yield return
- SyntaxFactory.LocalDeclarationStatement(
- declarationStatement.Modifiers,
- SyntaxFactory.VariableDeclaration(
- declarationStatement.Declaration.Type,
- SyntaxFactory.SeparatedList(list)),
- declarationStatement.SemicolonToken.WithPrependedLeadingTrivia(triviaList));
- triviaList.Clear();
- }
-
- // return any expression statement if there was any
- foreach (var expressionStatement in expressionStatements)
- {
- yield return expressionStatement;
- }
- }
- }
-
- private static SyntaxToken ApplyTriviaFromDeclarationToAssignmentIdentifier(LocalDeclarationStatementSyntax declarationStatement, bool firstVariableToAttachTrivia, VariableDeclaratorSyntax variable)
- {
- var identifier = variable.Identifier;
- var typeSyntax = declarationStatement.Declaration.Type;
- if (firstVariableToAttachTrivia && typeSyntax != null)
- {
- var identifierLeadingTrivia = new SyntaxTriviaList();
-
- if (typeSyntax.HasLeadingTrivia)
- {
- identifierLeadingTrivia = identifierLeadingTrivia.AddRange(typeSyntax.GetLeadingTrivia());
- }
-
- identifierLeadingTrivia = identifierLeadingTrivia.AddRange(identifier.LeadingTrivia);
- identifier = identifier.WithLeadingTrivia(identifierLeadingTrivia);
- }
-
- return identifier;
- }
-
- private static SyntaxToken GetIdentifierTokenAndTrivia(SyntaxToken identifier, TypeSyntax typeSyntax)
- {
- if (typeSyntax != null)
- {
- var identifierLeadingTrivia = new SyntaxTriviaList();
- var identifierTrailingTrivia = new SyntaxTriviaList();
- if (typeSyntax.HasLeadingTrivia)
- {
- identifierLeadingTrivia = identifierLeadingTrivia.AddRange(typeSyntax.GetLeadingTrivia());
- }
-
- if (typeSyntax.HasTrailingTrivia)
- {
- identifierLeadingTrivia = identifierLeadingTrivia.AddRange(typeSyntax.GetTrailingTrivia());
- }
-
- identifierLeadingTrivia = identifierLeadingTrivia.AddRange(identifier.LeadingTrivia);
- identifierTrailingTrivia = identifierTrailingTrivia.AddRange(identifier.TrailingTrivia);
- identifier = identifier.WithLeadingTrivia(identifierLeadingTrivia)
- .WithTrailingTrivia(identifierTrailingTrivia);
- }
-
- return identifier;
- }
-
- private IEnumerable<StatementSyntax> SplitOrMoveDeclarationIntoMethodDefinition(
- IEnumerable<StatementSyntax> statements,
- CancellationToken cancellationToken)
- {
- var semanticModel = this.SemanticDocument.SemanticModel;
- var context = this.InsertionPoint.GetContext();
- var postProcessor = new PostProcessor(semanticModel, context.SpanStart);
-
- var declStatements = CreateDeclarationStatements(AnalyzerResult.GetVariablesToSplitOrMoveIntoMethodDefinition(cancellationToken), cancellationToken);
- declStatements = postProcessor.MergeDeclarationStatements(declStatements);
-
- return declStatements.Concat(statements);
- }
-
- private ExpressionSyntax CreateAssignmentExpression(SyntaxToken identifier, ExpressionSyntax rvalue)
- {
- return SyntaxFactory.AssignmentExpression(
- SyntaxKind.SimpleAssignmentExpression,
- SyntaxFactory.IdentifierName(identifier),
- rvalue);
- }
-
- protected override bool LastStatementOrHasReturnStatementInReturnableConstruct()
- {
- var lastStatement = this.GetLastStatementOrInitializerSelectedAtCallSite();
- var container = lastStatement.GetAncestorsOrThis<SyntaxNode>().FirstOrDefault(n => n.IsReturnableConstruct());
- if (container == null)
- {
- // case such as field initializer
- return false;
- }
-
- var blockBody = container.GetBlockBody();
- if (blockBody == null)
- {
- // such as expression lambda. there is no statement
- return false;
- }
-
- // check whether it is last statement except return statement
- var statements = blockBody.Statements;
- if (statements.Last() == lastStatement)
- {
- return true;
- }
-
- var index = statements.IndexOf((StatementSyntax)lastStatement);
- return statements[index + 1].Kind() == SyntaxKind.ReturnStatement;
- }
-
- protected override SyntaxToken CreateIdentifier(string name)
- {
- return SyntaxFactory.Identifier(name);
- }
-
- protected override StatementSyntax CreateReturnStatement(string identifierName = null)
- {
- return string.IsNullOrEmpty(identifierName)
- ? SyntaxFactory.ReturnStatement()
- : SyntaxFactory.ReturnStatement(SyntaxFactory.IdentifierName(identifierName));
- }
-
- protected override ExpressionSyntax CreateCallSignature()
- {
- var methodName = CreateMethodNameForInvocation().WithAdditionalAnnotations(Simplifier.Annotation);
-
- var arguments = new List<ArgumentSyntax>();
- foreach (var argument in this.AnalyzerResult.MethodParameters)
- {
- var modifier = GetParameterRefSyntaxKind(argument.ParameterModifier);
- var refOrOut = modifier == SyntaxKind.None ? default(SyntaxToken) : SyntaxFactory.Token(modifier);
-
- arguments.Add(SyntaxFactory.Argument(SyntaxFactory.IdentifierName(argument.Name)).WithRefOrOutKeyword(refOrOut));
- }
-
- var invocation = SyntaxFactory.InvocationExpression(methodName,
- SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(arguments)));
-
- var shouldPutAsyncModifier = this.CSharpSelectionResult.ShouldPutAsyncModifier();
- if (!shouldPutAsyncModifier)
- {
- return invocation;
- }
-
- return SyntaxFactory.AwaitExpression(invocation);
- }
-
- protected override StatementSyntax CreateAssignmentExpressionStatement(SyntaxToken identifier, ExpressionSyntax rvalue)
- {
- return SyntaxFactory.ExpressionStatement(CreateAssignmentExpression((SyntaxToken)identifier, rvalue));
- }
-
- protected override StatementSyntax CreateDeclarationStatement(
- VariableInfo variable,
- CancellationToken cancellationToken,
- ExpressionSyntax initialValue = null)
- {
- var type = variable.GetVariableType(this.SemanticDocument);
- var typeNode = type.GenerateTypeSyntax();
-
- var equalsValueClause = initialValue == null ? null : SyntaxFactory.EqualsValueClause(value: initialValue);
-
- return SyntaxFactory.LocalDeclarationStatement(
- SyntaxFactory.VariableDeclaration(typeNode)
- .AddVariables(SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier(variable.Name)).WithInitializer(equalsValueClause)));
- }
-
- protected override async Task<GeneratedCode> CreateGeneratedCodeAsync(OperationStatus status, SemanticDocument newDocument, CancellationToken cancellationToken)
- {
- if (status.Succeeded())
- {
- // in hybrid code cases such as extract method, formatter will have some difficulties on where it breaks lines in two.
- // here, we explicitly insert newline at the end of "{" of auto generated method decl so that anchor knows how to find out
- // indentation of inserted statements (from users code) with user code style preserved
- var root = newDocument.Root;
- var methodDefinition = root.GetAnnotatedNodes<MethodDeclarationSyntax>(this.MethodDefinitionAnnotation).First();
-
- var newMethodDefinition =
- methodDefinition.ReplaceToken(
- methodDefinition.Body.OpenBraceToken,
- methodDefinition.Body.OpenBraceToken.WithAppendedTrailingTrivia(
- SpecializedCollections.SingletonEnumerable(SyntaxFactory.CarriageReturnLineFeed)));
-
- newDocument = await newDocument.WithSyntaxRootAsync(root.ReplaceNode(methodDefinition, newMethodDefinition), cancellationToken).ConfigureAwait(false);
- }
-
- return await base.CreateGeneratedCodeAsync(status, newDocument, cancellationToken).ConfigureAwait(false);
- }
-
- protected StatementSyntax GetStatementContainingInvocationToExtractedMethodWorker()
- {
- var callSignature = CreateCallSignature();
-
- if (this.AnalyzerResult.HasReturnType)
- {
- //Contract.ThrowIfTrue(this.AnalyzerResult.HasVariableToUseAsReturnValue);
- return SyntaxFactory.ReturnStatement(callSignature);
- }
-
- return SyntaxFactory.ExpressionStatement(callSignature);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.FormattingProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.FormattingProvider.cs
deleted file mode 100644
index 34cc3caa41..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.FormattingProvider.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.Formatting.Rules;
-using Microsoft.CodeAnalysis.Options;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor : MethodExtractor
- {
-// private class FormattingRule : AbstractFormattingRule
-// {
-// public FormattingRule()
-// {
-// }
-//
-// public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken previousToken, SyntaxToken currentToken, OptionSet optionSet, NextOperation<AdjustNewLinesOperation> nextOperation)
-// {
-// // for extract method case, for a hybrid case, don't force rule, but preserve user style
-// var operation = base.GetAdjustNewLinesOperation(previousToken, currentToken, optionSet, nextOperation);
-// if (operation == null)
-// {
-// return null;
-// }
-//
-// if (operation.Option == AdjustNewLinesOption.ForceLinesIfOnSingleLine)
-// {
-// return FormattingOperations.CreateAdjustNewLinesOperation(operation.Line, AdjustNewLinesOption.PreserveLines);
-// }
-//
-// if (operation.Option != AdjustNewLinesOption.ForceLines)
-// {
-// return operation;
-// }
-//
-// if (previousToken.RawKind == (int)SyntaxKind.OpenBraceToken)
-// {
-// return operation;
-// }
-//
-// if (previousToken.BetweenFieldAndNonFieldMember(currentToken))
-// {
-// // make sure to have at least 2 line breaks between field and other members except field
-// return FormattingOperations.CreateAdjustNewLinesOperation(2, AdjustNewLinesOption.PreserveLines);
-// }
-//
-// if (previousToken.HasHybridTriviaBetween(currentToken))
-// {
-// return FormattingOperations.CreateAdjustNewLinesOperation(operation.Line, AdjustNewLinesOption.PreserveLines);
-// }
-//
-// return operation;
-// }
-//
-// public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<AnchorIndentationOperation> nextOperation)
-// {
-// if (node.IsKind(SyntaxKind.SimpleLambdaExpression) || node.IsKind(SyntaxKind.ParenthesizedLambdaExpression) || node.IsKind(SyntaxKind.AnonymousMethodExpression))
-// {
-// return;
-// }
-//
-// nextOperation.Invoke(list);
-// }
-// }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.PostProcessor.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.PostProcessor.cs
deleted file mode 100644
index 4c4a49d088..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.PostProcessor.cs
+++ /dev/null
@@ -1,314 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor
- {
- private class PostProcessor
- {
- private readonly SemanticModel _semanticModel;
- private readonly int _contextPosition;
-
- public PostProcessor(SemanticModel semanticModel, int contextPosition)
- {
- //Contract.ThrowIfNull(semanticModel);
-
- _semanticModel = semanticModel;
- _contextPosition = contextPosition;
- }
-
- public IEnumerable<StatementSyntax> RemoveRedundantBlock(IEnumerable<StatementSyntax> statements)
- {
- // it must have only one statement
- if (statements.Count() != 1)
- {
- return statements;
- }
-
- // that statement must be a block
- var block = statements.Single() as BlockSyntax;
- if (block == null)
- {
- return statements;
- }
-
- // we have a block, remove them
- return RemoveRedundantBlock(block);
- }
-
- private IEnumerable<StatementSyntax> RemoveRedundantBlock(BlockSyntax block)
- {
- // if block doesn't have any statement
- if (block.Statements.Count == 0)
- {
- // either remove the block if it doesn't have any trivia, or return as it is if
- // there are trivia attached to block
- return (block.OpenBraceToken.GetAllTrivia().IsEmpty() && block.CloseBraceToken.GetAllTrivia().IsEmpty()) ?
- SpecializedCollections.EmptyEnumerable<StatementSyntax>() : SpecializedCollections.SingletonEnumerable<StatementSyntax>(block);
- }
-
- // okay transfer asset attached to block to statements
- var firstStatement = block.Statements.First();
- var firstToken = firstStatement.GetFirstToken(includeZeroWidth: true);
- var firstTokenWithAsset = block.OpenBraceToken.CopyAnnotationsTo(firstToken).WithPrependedLeadingTrivia(block.OpenBraceToken.GetAllTrivia());
-
- var lastStatement = block.Statements.Last();
- var lastToken = lastStatement.GetLastToken(includeZeroWidth: true);
- var lastTokenWithAsset = block.CloseBraceToken.CopyAnnotationsTo(lastToken).WithAppendedTrailingTrivia(block.CloseBraceToken.GetAllTrivia());
-
- // create new block with new tokens
- block = block.ReplaceTokens(new[] { firstToken, lastToken }, (o, c) => (o == firstToken) ? firstTokenWithAsset : lastTokenWithAsset);
-
- // return only statements without the wrapping block
- return block.Statements;
- }
-
- public IEnumerable<StatementSyntax> MergeDeclarationStatements(IEnumerable<StatementSyntax> statements)
- {
- if (statements.FirstOrDefault() == null)
- {
- return statements;
- }
-
- return MergeDeclarationStatementsWorker(statements);
- }
-
- private IEnumerable<StatementSyntax> MergeDeclarationStatementsWorker(IEnumerable<StatementSyntax> statements)
- {
- var map = new Dictionary<ITypeSymbol, List<LocalDeclarationStatementSyntax>>();
- foreach (var statement in statements)
- {
- if (!IsDeclarationMergable(statement))
- {
- foreach (var declStatement in GetMergedDeclarationStatements(map))
- {
- yield return declStatement;
- }
-
- yield return statement;
- continue;
- }
-
- AppendDeclarationStatementToMap(statement as LocalDeclarationStatementSyntax, map);
- }
-
- // merge leftover
- if (map.Count <= 0)
- {
- yield break;
- }
-
- foreach (var declStatement in GetMergedDeclarationStatements(map))
- {
- yield return declStatement;
- }
- }
-
- private void AppendDeclarationStatementToMap(
- LocalDeclarationStatementSyntax statement,
- Dictionary<ITypeSymbol, List<LocalDeclarationStatementSyntax>> map)
- {
- // Contract.ThrowIfNull(statement);
-
- var type = _semanticModel.GetSpeculativeTypeInfo(_contextPosition, statement.Declaration.Type, SpeculativeBindingOption.BindAsTypeOrNamespace).Type;
- //Contract.ThrowIfNull(type);
-
- map.GetOrAdd(type, _ => new List<LocalDeclarationStatementSyntax>()).Add(statement);
- }
-
- private IEnumerable<LocalDeclarationStatementSyntax> GetMergedDeclarationStatements(
- Dictionary<ITypeSymbol, List<LocalDeclarationStatementSyntax>> map)
- {
- foreach (var keyValuePair in map)
- {
- //Contract.ThrowIfFalse(keyValuePair.Value.Count > 0);
-
- // merge all variable decl for current type
- var variables = new List<VariableDeclaratorSyntax>();
- foreach (var statement in keyValuePair.Value)
- {
- foreach (var variable in statement.Declaration.Variables)
- {
- variables.Add(variable);
- }
- }
-
- // and create one decl statement
- // use type name from the first decl statement
- yield return
- SyntaxFactory.LocalDeclarationStatement(
- SyntaxFactory.VariableDeclaration(keyValuePair.Value.First().Declaration.Type, SyntaxFactory.SeparatedList(variables)));
- }
-
- map.Clear();
- }
-
- private bool IsDeclarationMergable(StatementSyntax statement)
- {
- //Contract.ThrowIfNull(statement);
-
- // to be mergable, statement must be
- // 1. decl statement without any extra info
- // 2. no initialization on any of its decls
- // 3. no trivia except whitespace
- // 4. type must be known
-
- var declarationStatement = statement as LocalDeclarationStatementSyntax;
- if (declarationStatement == null)
- {
- return false;
- }
-
- if (declarationStatement.Modifiers.Count > 0 ||
- declarationStatement.IsConst ||
- declarationStatement.IsMissing)
- {
- return false;
- }
-
- if (ContainsAnyInitialization(declarationStatement))
- {
- return false;
- }
-
- if (!ContainsOnlyWhitespaceTrivia(declarationStatement))
- {
- return false;
- }
-
- var semanticInfo = _semanticModel.GetSpeculativeTypeInfo(_contextPosition, declarationStatement.Declaration.Type, SpeculativeBindingOption.BindAsTypeOrNamespace).Type;
- if (semanticInfo == null ||
- semanticInfo.TypeKind == TypeKind.Error ||
- semanticInfo.TypeKind == TypeKind.Unknown)
- {
- return false;
- }
-
- return true;
- }
-
- private bool ContainsAnyInitialization(LocalDeclarationStatementSyntax statement)
- {
- foreach (var variable in statement.Declaration.Variables)
- {
- if (variable.Initializer != null)
- {
- return true;
- }
- }
-
- return false;
- }
-
- private static bool ContainsOnlyWhitespaceTrivia(StatementSyntax statement)
- {
- foreach (var token in statement.DescendantTokens())
- {
- foreach (var trivia in token.LeadingTrivia.Concat(token.TrailingTrivia))
- {
- if (trivia.Kind() != SyntaxKind.WhitespaceTrivia &&
- trivia.Kind() != SyntaxKind.EndOfLineTrivia)
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- public IEnumerable<StatementSyntax> RemoveInitializedDeclarationAndReturnPattern(IEnumerable<StatementSyntax> statements)
- {
- // if we have inline temp variable as service, we could just use that service here.
- // since it is not a service right now, do very simple clean up
- if (statements.ElementAtOrDefault(2) != null)
- {
- return statements;
- }
-
- var declaration = statements.ElementAtOrDefault(0) as LocalDeclarationStatementSyntax;
- var returnStatement = statements.ElementAtOrDefault(1) as ReturnStatementSyntax;
- if (declaration == null || returnStatement == null)
- {
- return statements;
- }
-
- if (declaration.Declaration == null ||
- declaration.Declaration.Variables.Count != 1 ||
- declaration.Declaration.Variables[0].Initializer == null ||
- declaration.Declaration.Variables[0].Initializer.Value == null ||
- declaration.Declaration.Variables[0].Initializer.Value is StackAllocArrayCreationExpressionSyntax ||
- returnStatement.Expression == null)
- {
- return statements;
- }
-
- if (!ContainsOnlyWhitespaceTrivia(declaration) ||
- !ContainsOnlyWhitespaceTrivia(returnStatement))
- {
- return statements;
- }
-
- var variableName = declaration.Declaration.Variables[0].Identifier.ToString();
- if (returnStatement.Expression.ToString() != variableName)
- {
- return statements;
- }
-
- return SpecializedCollections.SingletonEnumerable<StatementSyntax>(SyntaxFactory.ReturnStatement(declaration.Declaration.Variables[0].Initializer.Value));
- }
-
- public IEnumerable<StatementSyntax> RemoveDeclarationAssignmentPattern(IEnumerable<StatementSyntax> statements)
- {
- // if we have inline temp variable as service, we could just use that service here.
- // since it is not a service right now, do very simple clean up
- var declaration = statements.ElementAtOrDefault(0) as LocalDeclarationStatementSyntax;
- var assignment = statements.ElementAtOrDefault(1) as ExpressionStatementSyntax;
- if (declaration == null || assignment == null)
- {
- return statements;
- }
-
- if (ContainsAnyInitialization(declaration) ||
- declaration.Declaration == null ||
- declaration.Declaration.Variables.Count != 1 ||
- assignment.Expression == null ||
- assignment.Expression.Kind() != SyntaxKind.SimpleAssignmentExpression)
- {
- return statements;
- }
-
- if (!ContainsOnlyWhitespaceTrivia(declaration) ||
- !ContainsOnlyWhitespaceTrivia(assignment))
- {
- return statements;
- }
-
- var variableName = declaration.Declaration.Variables[0].Identifier.ToString();
-
- var assignmentExpression = assignment.Expression as AssignmentExpressionSyntax;
- if (assignmentExpression.Left == null ||
- assignmentExpression.Right == null ||
- assignmentExpression.Left.ToString() != variableName)
- {
- return statements;
- }
-
- var variable = declaration.Declaration.Variables[0].WithInitializer(SyntaxFactory.EqualsValueClause(assignmentExpression.Right));
- return SpecializedCollections.SingletonEnumerable<StatementSyntax>(
- declaration.WithDeclaration(
- declaration.Declaration.WithVariables(
- SyntaxFactory.SingletonSeparatedList(variable)))).Concat(statements.Skip(2));
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.TriviaResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.TriviaResult.cs
deleted file mode 100644
index 524acb5fb2..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.TriviaResult.cs
+++ /dev/null
@@ -1,161 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor
- {
- private class CSharpTriviaResult : TriviaResult
- {
- public static async Task<CSharpTriviaResult> ProcessAsync(SelectionResult selectionResult, CancellationToken cancellationToken)
- {
- var preservationService = new CSharpSyntaxTriviaService ();
- var root = selectionResult.SemanticDocument.Root;
- var result = preservationService.SaveTriviaAroundSelection(root, selectionResult.FinalSpan);
- return new CSharpTriviaResult(
- await selectionResult.SemanticDocument.WithSyntaxRootAsync(result.Root, cancellationToken).ConfigureAwait(false),
- result);
- }
-
- private CSharpTriviaResult(SemanticDocument document, ITriviaSavedResult result) :
- base(document, result, (int)SyntaxKind.EndOfLineTrivia, (int)SyntaxKind.WhitespaceTrivia)
- {
- }
-
- protected override AnnotationResolver GetAnnotationResolver(SyntaxNode callsite, SyntaxNode method)
- {
- var methodDefinition = method as MethodDeclarationSyntax;
- if (callsite == null || methodDefinition == null)
- {
- return null;
- }
-
- return (node, location, annotation) => AnnotationResolver(node, location, annotation, callsite, methodDefinition);
- }
-
- protected override TriviaResolver GetTriviaResolver(SyntaxNode method)
- {
- var methodDefinition = method as MethodDeclarationSyntax;
- if (methodDefinition == null)
- {
- return null;
- }
-
- return (location, tokenPair, triviaMap) => TriviaResolver(location, tokenPair, triviaMap, methodDefinition);
- }
-
- private SyntaxToken AnnotationResolver(
- SyntaxNode node,
- TriviaLocation location,
- SyntaxAnnotation annotation,
- SyntaxNode callsite,
- MethodDeclarationSyntax method)
- {
- var token = node.GetAnnotatedNodesAndTokens(annotation).FirstOrDefault().AsToken();
- if (token.RawKind != 0)
- {
- return token;
- }
-
- switch (location)
- {
- case TriviaLocation.BeforeBeginningOfSpan:
- return callsite.GetFirstToken(includeZeroWidth: true).GetPreviousToken(includeZeroWidth: true);
- case TriviaLocation.AfterEndOfSpan:
- return callsite.GetLastToken(includeZeroWidth: true).GetNextToken(includeZeroWidth: true);
- case TriviaLocation.AfterBeginningOfSpan:
- return method.Body.OpenBraceToken.GetNextToken(includeZeroWidth: true);
- case TriviaLocation.BeforeEndOfSpan:
- return method.Body.CloseBraceToken.GetPreviousToken(includeZeroWidth: true);
- }
-
- return token; //Contract.FailWithReturn<SyntaxToken>("can't happen");
- }
-
- private IEnumerable<SyntaxTrivia> TriviaResolver(
- TriviaLocation location,
- PreviousNextTokenPair tokenPair,
- Dictionary<SyntaxToken, LeadingTrailingTriviaPair> triviaMap,
- MethodDeclarationSyntax method)
- {
- // Resolve trivia at the edge of the selection. simple case is easy to deal with, but complex cases where
- // elastic trivia and user trivia are mixed (hybrid case) and we want to preserve some part of user coding style
- // but not others can be dealt with here.
-
- // method has no statement in them. so basically two trivia list now pointing to same thing. "{" and "}"
- if (tokenPair.PreviousToken == method.Body.OpenBraceToken &&
- tokenPair.NextToken == method.Body.CloseBraceToken)
- {
- return (location == TriviaLocation.AfterBeginningOfSpan) ?
- SpecializedCollections.SingletonEnumerable<SyntaxTrivia>(SyntaxFactory.ElasticMarker) :
- SpecializedCollections.EmptyEnumerable<SyntaxTrivia>();
- }
-
- var previousTriviaPair = triviaMap.ContainsKey(tokenPair.PreviousToken) ? triviaMap[tokenPair.PreviousToken] : default(LeadingTrailingTriviaPair);
- var nextTriviaPair = triviaMap.ContainsKey(tokenPair.NextToken) ? triviaMap[tokenPair.NextToken] : default(LeadingTrailingTriviaPair);
-
- var trailingTrivia = previousTriviaPair.TrailingTrivia ?? SpecializedCollections.EmptyEnumerable<SyntaxTrivia>();
- var leadingTrivia = nextTriviaPair.LeadingTrivia ?? SpecializedCollections.EmptyEnumerable<SyntaxTrivia>();
-
- var list = trailingTrivia.Concat(leadingTrivia);
-
- switch (location)
- {
- case TriviaLocation.BeforeBeginningOfSpan:
- return FilterBeforeBeginningOfSpan(tokenPair, list);
- case TriviaLocation.AfterEndOfSpan:
- return FilterTriviaList(list.Concat(tokenPair.NextToken.LeadingTrivia));
- case TriviaLocation.AfterBeginningOfSpan:
- return FilterTriviaList(AppendTrailingTrivia(tokenPair).Concat(list).Concat(tokenPair.NextToken.LeadingTrivia));
- case TriviaLocation.BeforeEndOfSpan:
- return FilterTriviaList(tokenPair.PreviousToken.TrailingTrivia.Concat(list).Concat(tokenPair.NextToken.LeadingTrivia));
- }
-
- return null;//Contract.FailWithReturn<IEnumerable<SyntaxTrivia>>("Shouldn't reach here");
- }
-
- private IEnumerable<SyntaxTrivia> FilterBeforeBeginningOfSpan(PreviousNextTokenPair tokenPair, IEnumerable<SyntaxTrivia> list)
- {
- var allList = FilterTriviaList(tokenPair.PreviousToken.TrailingTrivia.Concat(list).Concat(AppendLeadingTrivia(tokenPair)));
-
- if (tokenPair.PreviousToken.RawKind == (int)SyntaxKind.OpenBraceToken)
- {
- return RemoveBlankLines(allList);
- }
-
- return allList;
- }
-
- private IEnumerable<SyntaxTrivia> AppendLeadingTrivia(PreviousNextTokenPair tokenPair)
- {
- if (tokenPair.PreviousToken.RawKind == (int)SyntaxKind.OpenBraceToken ||
- tokenPair.PreviousToken.RawKind == (int)SyntaxKind.SemicolonToken)
- {
- return tokenPair.NextToken.LeadingTrivia;
- }
-
- return SpecializedCollections.EmptyEnumerable<SyntaxTrivia>();
- }
-
- private IEnumerable<SyntaxTrivia> AppendTrailingTrivia(PreviousNextTokenPair tokenPair)
- {
- if (tokenPair.PreviousToken.RawKind == (int)SyntaxKind.OpenBraceToken ||
- tokenPair.PreviousToken.RawKind == (int)SyntaxKind.SemicolonToken)
- {
- return tokenPair.PreviousToken.TrailingTrivia;
- }
-
- return SpecializedCollections.EmptyEnumerable<SyntaxTrivia>();
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.cs
deleted file mode 100644
index 216915c21d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpMethodExtractor.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Formatting.Rules;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpMethodExtractor : MethodExtractor
- {
- public CSharpMethodExtractor(CSharpSelectionResult result) :
- base(result)
- {
- }
-
- protected override Task<AnalyzerResult> AnalyzeAsync(SelectionResult selectionResult, CancellationToken cancellationToken)
- {
- return CSharpAnalyzer.AnalyzeAsync(selectionResult, cancellationToken);
- }
-
- protected override async Task<InsertionPoint> GetInsertionPointAsync(SemanticDocument document, int position, CancellationToken cancellationToken)
- {
- //Contract.ThrowIfFalse(position >= 0);
-
- var root = await document.Document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var basePosition = root.FindToken(position);
-
- var memberNode = basePosition.GetAncestor<MemberDeclarationSyntax>();
-// Contract.ThrowIfNull(memberNode);
-// Contract.ThrowIfTrue(memberNode.Kind() == SyntaxKind.NamespaceDeclaration);
-
- var globalStatement = memberNode as GlobalStatementSyntax;
- if (globalStatement != null)
- {
- // check whether we are extracting whole global statement out
- if (this.OriginalSelectionResult.FinalSpan.Contains(memberNode.Span))
- {
- return await InsertionPoint.CreateAsync(document, globalStatement.Parent, cancellationToken).ConfigureAwait(false);
- }
-
- return await InsertionPoint.CreateAsync(document, globalStatement.Statement, cancellationToken).ConfigureAwait(false);
- }
-
- return await InsertionPoint.CreateAsync(document, memberNode, cancellationToken).ConfigureAwait(false);
- }
-
- protected override async Task<TriviaResult> PreserveTriviaAsync(SelectionResult selectionResult, CancellationToken cancellationToken)
- {
- return await CSharpTriviaResult.ProcessAsync(selectionResult, cancellationToken).ConfigureAwait(false);
- }
-
- protected override async Task<SemanticDocument> ExpandAsync(SelectionResult selection, CancellationToken cancellationToken)
- {
- var lastExpression = selection.GetFirstTokenInSelection().GetCommonRoot(selection.GetLastTokenInSelection()).GetAncestors<ExpressionSyntax>().LastOrDefault();
- if (lastExpression == null)
- {
- return selection.SemanticDocument;
- }
-
- var newExpression = await Simplifier.ExpandAsync(lastExpression, selection.SemanticDocument.Document, n => n != selection.GetContainingScope(), expandParameter: false, cancellationToken: cancellationToken).ConfigureAwait(false);
- return await selection.SemanticDocument.WithSyntaxRootAsync(selection.SemanticDocument.Root.ReplaceNode(lastExpression, newExpression), cancellationToken).ConfigureAwait(false);
- }
-
- protected override Task<MethodExtractor.GeneratedCode> GenerateCodeAsync(InsertionPoint insertionPoint, SelectionResult selectionResult, AnalyzerResult analyzeResult, CancellationToken cancellationToken)
- {
- return CSharpCodeGenerator.GenerateAsync(insertionPoint, selectionResult, analyzeResult, cancellationToken);
- }
-
-// protected override IEnumerable<IFormattingRule> GetFormattingRules(Document document)
-// {
-// return SpecializedCollections.SingletonEnumerable(new FormattingRule()).Concat(Formatter.GetDefaultFormattingRules(document));
-// }
-
- protected override SyntaxToken GetMethodNameAtInvocation(IEnumerable<SyntaxNodeOrToken> methodNames)
- {
- return (SyntaxToken)methodNames.FirstOrDefault(t => !t.Parent.IsKind(SyntaxKind.MethodDeclaration));
- }
-
- protected override async Task<OperationStatus> CheckTypeAsync(
- Document document,
- SyntaxNode contextNode,
- Location location,
- ITypeSymbol type,
- CancellationToken cancellationToken)
- {
- //Contract.ThrowIfNull(type);
-
- // this happens when there is no return type
- if (type.SpecialType == SpecialType.System_Void)
- {
- return OperationStatus.Succeeded;
- }
-
- if (type.TypeKind == TypeKind.Error ||
- type.TypeKind == TypeKind.Unknown)
- {
- return OperationStatus.ErrorOrUnknownType;
- }
-
- // if it is type parameter, make sure we are getting same type parameter
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
-
- foreach (var typeParameter in TypeParameterCollector.Collect(type))
- {
- var typeName = SyntaxFactory.ParseTypeName(typeParameter.Name);
- var currentType = semanticModel.GetSpeculativeTypeInfo(contextNode.SpanStart, typeName, SpeculativeBindingOption.BindAsTypeOrNamespace).Type;
- if (currentType == null || !currentType.Equals(typeParameter))
- {
- return new OperationStatus(OperationStatusFlag.BestEffort,
- string.Format("FeaturesResources.TypeParameterIsHiddenByAnother",
- typeParameter.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat),
- currentType == null ? string.Empty : currentType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)));
- }
- }
-
- return OperationStatus.Succeeded;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.ExpressionResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.ExpressionResult.cs
deleted file mode 100644
index 20c6abc55c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.ExpressionResult.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Linq;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpSelectionResult
- {
- private class ExpressionResult : CSharpSelectionResult
- {
- public ExpressionResult(
- OperationStatus status,
- TextSpan originalSpan,
- TextSpan finalSpan,
- OptionSet options,
- bool selectionInExpression,
- SemanticDocument document,
- SyntaxAnnotation firstTokenAnnotation,
- SyntaxAnnotation lastTokenAnnotation) :
- base(status, originalSpan, finalSpan, options, selectionInExpression, document, firstTokenAnnotation, lastTokenAnnotation)
- {
- }
-
- public override bool ContainingScopeHasAsyncKeyword()
- {
- return false;
- }
-
- public override SyntaxNode GetContainingScope()
- {
-// Contract.ThrowIfNull(this.SemanticDocument);
-// Contract.ThrowIfFalse(this.SelectionInExpression);
-
- var firstToken = this.GetFirstTokenInSelection();
- var lastToken = this.GetLastTokenInSelection();
- return firstToken.GetCommonRoot(lastToken).GetAncestorOrThis<ExpressionSyntax>();
- }
-
- public override ITypeSymbol GetContainingScopeType()
- {
- var node = this.GetContainingScope();
- var model = this.SemanticDocument.SemanticModel;
-
- if (!node.IsExpression())
- {
- // Contract.Fail("this shouldn't happen");
- return null;
- }
-
- // special case for array initializer and explict cast
- if (node.IsArrayInitializer())
- {
- var variableDeclExpression = node.GetAncestorOrThis<VariableDeclarationSyntax>();
- if (variableDeclExpression != null)
- {
- return model.GetTypeInfo(variableDeclExpression.Type).Type;
- }
- }
-
- if (node.IsExpressionInCast())
- {
- // bug # 12774 and # 4780
- // if the expression is under cast, we use the heuristic below
- // 1. if regular binding returns a meaningful type, we use it as it is
- // 2. if it doesn't, even if the cast itself wasn't included in the selection, we will treat it
- // as it was in the selection
- var regularType = GetRegularExpressionType(model, node);
- if (regularType != null && !regularType.IsObjectType())
- {
- return regularType;
- }
-
- var castExpression = node.Parent as CastExpressionSyntax;
- if (castExpression != null)
- {
- return model.GetTypeInfo(castExpression.Type).Type;
- }
- }
-
- return GetRegularExpressionType(model, node);
- }
-
- private static ITypeSymbol GetRegularExpressionType(SemanticModel semanticModel, SyntaxNode node)
- {
- // regular case. always use ConvertedType to get implicit conversion right.
- var expression = node.GetUnparenthesizedExpression();
-
- var info = semanticModel.GetTypeInfo(expression);
- var conv = semanticModel.GetConversion(expression);
-
- if (info.ConvertedType == null || info.ConvertedType.IsErrorType())
- {
- // there is no implicit conversion involved. no need to go further
- return info.Type;
- }
-
- // always use converted type if method group
- if ((!node.IsKind(SyntaxKind.ObjectCreationExpression) && semanticModel.GetMemberGroup(expression).Length > 0) ||
- IsCoClassImplicitConversion(info, conv, semanticModel.Compilation.CoClassType()))
- {
- return info.ConvertedType;
- }
-
- // check implicit conversion
- if (conv.IsImplicit && (conv.IsConstantExpression || conv.IsEnumeration))
- {
- return info.ConvertedType;
- }
-
- // always try to use type that is more specific than object type if possible.
- return !info.Type.IsObjectType() ? info.Type : info.ConvertedType;
- }
- }
-
- private static bool IsCoClassImplicitConversion(TypeInfo info, Conversion conversion, ISymbol coclassSymbol)
- {
- if (!conversion.IsImplicit ||
- info.ConvertedType == null ||
- info.ConvertedType.TypeKind != TypeKind.Interface)
- {
- return false;
- }
-
- // let's see whether this interface has coclass attribute
- return info.ConvertedType.GetAttributes().Any(c => c.AttributeClass.Equals(coclassSymbol));
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.StatementResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.StatementResult.cs
deleted file mode 100644
index 3f22c7c35d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.StatementResult.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpSelectionResult
- {
- private class StatementResult : CSharpSelectionResult
- {
- public StatementResult(
- OperationStatus status,
- TextSpan originalSpan,
- TextSpan finalSpan,
- OptionSet options,
- bool selectionInExpression,
- SemanticDocument document,
- SyntaxAnnotation firstTokenAnnotation,
- SyntaxAnnotation lastTokenAnnotation) :
- base(status, originalSpan, finalSpan, options, selectionInExpression, document, firstTokenAnnotation, lastTokenAnnotation)
- {
- }
-
- public override bool ContainingScopeHasAsyncKeyword()
- {
- var node = this.GetContainingScope();
- //var semanticModel = this.SemanticDocument.SemanticModel;
-
- return node.TypeSwitch(
- (AccessorDeclarationSyntax access) => false,
- (MethodDeclarationSyntax method) => method.Modifiers.Any(SyntaxKind.AsyncKeyword),
- (ParenthesizedLambdaExpressionSyntax lambda) => lambda.AsyncKeyword.Kind() == SyntaxKind.AsyncKeyword,
- (SimpleLambdaExpressionSyntax lambda) => lambda.AsyncKeyword.Kind() == SyntaxKind.AsyncKeyword,
- (AnonymousMethodExpressionSyntax anonymous) => anonymous.AsyncKeyword.Kind() == SyntaxKind.AsyncKeyword);
- }
-
- public override SyntaxNode GetContainingScope()
- {
-// Contract.ThrowIfNull(this.SemanticDocument);
-// Contract.ThrowIfTrue(this.SelectionInExpression);
-
- // it contains statements
- var firstToken = this.GetFirstTokenInSelection();
- return firstToken.GetAncestors<SyntaxNode>().FirstOrDefault(n =>
- {
- return n is BaseMethodDeclarationSyntax ||
- n is AccessorDeclarationSyntax ||
- n is ParenthesizedLambdaExpressionSyntax ||
- n is SimpleLambdaExpressionSyntax ||
- n is AnonymousMethodExpressionSyntax ||
- n is CompilationUnitSyntax;
- });
- }
-
- public override ITypeSymbol GetContainingScopeType()
- {
- //Contract.ThrowIfTrue(this.SelectionInExpression);
-
- var node = this.GetContainingScope();
- var semanticModel = this.SemanticDocument.SemanticModel;
-
- return node.TypeSwitch(
- (AccessorDeclarationSyntax access) =>
- {
- // property case
- if (access.Parent == null || access.Parent.Parent == null)
- {
- return null;
- }
-
- return ((IPropertySymbol)semanticModel.GetDeclaredSymbol(access.Parent.Parent)).Type;
- },
- (MethodDeclarationSyntax method) => ((IMethodSymbol)semanticModel.GetDeclaredSymbol(method)).ReturnType,
- (ParenthesizedLambdaExpressionSyntax lambda) => semanticModel.GetLambdaOrAnonymousMethodReturnType(lambda),
- (SimpleLambdaExpressionSyntax lambda) => semanticModel.GetLambdaOrAnonymousMethodReturnType(lambda),
- (AnonymousMethodExpressionSyntax anonymous) => semanticModel.GetLambdaOrAnonymousMethodReturnType(anonymous));
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.cs
deleted file mode 100644
index 5709e1b139..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionResult.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class CSharpSelectionResult : SelectionResult
- {
- public static async Task<CSharpSelectionResult> CreateAsync(
- OperationStatus status,
- TextSpan originalSpan,
- TextSpan finalSpan,
- OptionSet options,
- bool selectionInExpression,
- SemanticDocument document,
- SyntaxToken firstToken,
- SyntaxToken lastToken,
- CancellationToken cancellationToken)
- {
-// Contract.ThrowIfNull(status);
-// Contract.ThrowIfNull(document);
-
- var firstTokenAnnotation = new SyntaxAnnotation();
- var lastTokenAnnotation = new SyntaxAnnotation();
-
- var root = await document.Document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var newDocument = await SemanticDocument.CreateAsync(document.Document.WithSyntaxRoot(root.AddAnnotations(
- new[]
- {
- Tuple.Create<SyntaxToken, SyntaxAnnotation>(firstToken, firstTokenAnnotation),
- Tuple.Create<SyntaxToken, SyntaxAnnotation>(lastToken, lastTokenAnnotation)
- })), cancellationToken).ConfigureAwait(false);
-
- if (selectionInExpression)
- {
- return new ExpressionResult(
- status, originalSpan, finalSpan, options, selectionInExpression,
- newDocument, firstTokenAnnotation, lastTokenAnnotation);
- }
- else
- {
- return new StatementResult(
- status, originalSpan, finalSpan, options, selectionInExpression,
- newDocument, firstTokenAnnotation, lastTokenAnnotation);
- }
- }
-
- protected CSharpSelectionResult(
- OperationStatus status,
- TextSpan originalSpan,
- TextSpan finalSpan,
- OptionSet options,
- bool selectionInExpression,
- SemanticDocument document,
- SyntaxAnnotation firstTokenAnnotation,
- SyntaxAnnotation lastTokenAnnotation) :
- base(status, originalSpan, finalSpan, options, selectionInExpression,
- document, firstTokenAnnotation, lastTokenAnnotation)
- {
- }
-
- protected override bool UnderAsyncAnonymousMethod(SyntaxToken token, SyntaxToken firstToken, SyntaxToken lastToken)
- {
- var current = token.Parent;
- for (; current != null; current = current.Parent)
- {
- if (current is MemberDeclarationSyntax ||
- current is SimpleLambdaExpressionSyntax ||
- current is ParenthesizedLambdaExpressionSyntax ||
- current is AnonymousMethodExpressionSyntax)
- {
- break;
- }
- }
-
- if (current == null || current is MemberDeclarationSyntax)
- {
- return false;
- }
-
- // make sure the selection contains the lambda
- return firstToken.SpanStart <= current.GetFirstToken().SpanStart &&
- current.GetLastToken().Span.End <= lastToken.Span.End;
- }
-
- public StatementSyntax GetFirstStatement()
- {
- return GetFirstStatement<StatementSyntax>();
- }
-
- public StatementSyntax GetLastStatement()
- {
- return GetLastStatement<StatementSyntax>();
- }
-
- public StatementSyntax GetFirstStatementUnderContainer()
- {
- //Contract.ThrowIfTrue(this.SelectionInExpression);
-
- var firstToken = this.GetFirstTokenInSelection();
- var statement = firstToken.Parent.GetStatementUnderContainer();
- //Contract.ThrowIfNull(statement);
-
- return statement;
- }
-
- public StatementSyntax GetLastStatementUnderContainer()
- {
- //Contract.ThrowIfTrue(this.SelectionInExpression);
-
- var lastToken = this.GetLastTokenInSelection();
- var statement = lastToken.Parent.GetStatementUnderContainer();
-
- //Contract.ThrowIfNull(statement);
- //var firstStatementUnderContainer = this.GetFirstStatementUnderContainer();
- //Contract.ThrowIfFalse(statement.Parent == firstStatementUnderContainer.Parent);
-
- return statement;
- }
-
- public SyntaxNode GetInnermostStatementContainer()
- {
- //Contract.ThrowIfFalse(this.SelectionInExpression);
- var containingScope = this.GetContainingScope();
- var statements = containingScope.GetAncestorsOrThis<StatementSyntax>();
- StatementSyntax last = null;
-
- foreach (var statement in statements)
- {
- if (statement.IsStatementContainerNode())
- {
- return statement;
- }
-
- last = statement;
- }
-
- // constructor initializer case
- var constructorInitializer = this.GetContainingScopeOf<ConstructorInitializerSyntax>();
- if (constructorInitializer != null)
- {
- return constructorInitializer.Parent;
- }
-
- // field initializer case
- var field = this.GetContainingScopeOf<FieldDeclarationSyntax>();
- if (field != null)
- {
- return field.Parent;
- }
-
-// Contract.ThrowIfFalse(last.IsParentKind(SyntaxKind.GlobalStatement));
-// Contract.ThrowIfFalse(last.Parent.IsParentKind(SyntaxKind.CompilationUnit));
- return last.Parent.Parent;
- }
-
- public bool ShouldPutUnsafeModifier()
- {
- var token = this.GetFirstTokenInSelection();
- var ancestors = token.GetAncestors<SyntaxNode>();
-
- // if enclosing type contains unsafe keyword, we don't need to put it again
- if (ancestors.Where(a => SyntaxFacts.IsTypeDeclaration(a.Kind()))
- .Cast<MemberDeclarationSyntax>()
- .Any(m => m.GetModifiers().Any(SyntaxKind.UnsafeKeyword)))
- {
- return false;
- }
-
- return token.Parent.IsUnsafeContext();
- }
-
- public SyntaxKind UnderCheckedExpressionContext()
- {
- return UnderCheckedContext<CheckedExpressionSyntax>();
- }
-
- public SyntaxKind UnderCheckedStatementContext()
- {
- return UnderCheckedContext<CheckedStatementSyntax>();
- }
-
- private SyntaxKind UnderCheckedContext<T>() where T : SyntaxNode
- {
- var token = this.GetFirstTokenInSelection();
- var contextNode = token.Parent.GetAncestor<T>();
- if (contextNode == null)
- {
- return SyntaxKind.None;
- }
-
- return contextNode.Kind();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionValidator.Validator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionValidator.Validator.cs
deleted file mode 100644
index ab18e973c8..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionValidator.Validator.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpSelectionValidator
- {
- public bool Check(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
- {
- return node.TypeSwitch(
- (ExpressionSyntax expression) => CheckExpression(semanticModel, expression, cancellationToken),
- (BlockSyntax block) => CheckBlock(semanticModel, block, cancellationToken),
- (StatementSyntax statement) => CheckStatement(semanticModel, statement, cancellationToken),
- (GlobalStatementSyntax globalStatement) => CheckGlobalStatement(semanticModel, globalStatement, cancellationToken));
- }
-
- private bool CheckGlobalStatement(SemanticModel semanticModel, GlobalStatementSyntax globalStatement, CancellationToken cancellationToken)
- {
- return true;
- }
-
- private bool CheckBlock(SemanticModel semanticModel, BlockSyntax block, CancellationToken cancellationToken)
- {
- // TODO(cyrusn): Is it intentional that fixed statement is not in this list?
- if (block.Parent is BlockSyntax ||
- block.Parent is DoStatementSyntax ||
- block.Parent is ElseClauseSyntax ||
- block.Parent is ForEachStatementSyntax ||
- block.Parent is ForStatementSyntax ||
- block.Parent is IfStatementSyntax ||
- block.Parent is LockStatementSyntax ||
- block.Parent is UsingStatementSyntax ||
- block.Parent is WhileStatementSyntax)
- {
- return true;
- }
-
- return false;
- }
-
- private bool CheckExpression(SemanticModel semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- // TODO(cyrusn): This is probably unnecessary. What we should be doing is binding
- // the type of the expression and seeing if it contains an anonymous type.
- if (expression is AnonymousObjectCreationExpressionSyntax)
- {
- return false;
- }
-
- return expression.CanReplaceWithRValue(semanticModel, cancellationToken);
- }
-
- private bool CheckStatement(SemanticModel semanticModel, StatementSyntax statement, CancellationToken cancellationToken)
- {
- if (statement is CheckedStatementSyntax ||
- statement is DoStatementSyntax ||
- statement is EmptyStatementSyntax ||
- statement is ExpressionStatementSyntax ||
- statement is FixedStatementSyntax ||
- statement is ForEachStatementSyntax ||
- statement is ForStatementSyntax ||
- statement is IfStatementSyntax ||
- statement is LocalDeclarationStatementSyntax ||
- statement is LockStatementSyntax ||
- statement is ReturnStatementSyntax ||
- statement is SwitchStatementSyntax ||
- statement is ThrowStatementSyntax ||
- statement is TryStatementSyntax ||
- statement is UnsafeStatementSyntax ||
- statement is UsingStatementSyntax ||
- statement is WhileStatementSyntax)
- {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionValidator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionValidator.cs
deleted file mode 100644
index 66b06bfa96..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSelectionValidator.cs
+++ /dev/null
@@ -1,486 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class CSharpSelectionValidator : SelectionValidator
- {
- public CSharpSelectionValidator(
- SemanticDocument document,
- TextSpan textSpan,
- OptionSet options) :
- base(document, textSpan, options)
- {
- }
-
- public override async Task<SelectionResult> GetValidSelectionAsync(CancellationToken cancellationToken)
- {
- if (!this.ContainsValidSelection)
- {
- return NullSelection;
- }
-
- var text = this.SemanticDocument.Text;
- var root = this.SemanticDocument.Root;
- var model = this.SemanticDocument.SemanticModel;
-
- // go through pipe line and calculate information about the user selection
- var selectionInfo = GetInitialSelectionInfo(root, text, cancellationToken);
- selectionInfo = AssignInitialFinalTokens(selectionInfo, root, cancellationToken);
- selectionInfo = AdjustFinalTokensBasedOnContext(selectionInfo, model, cancellationToken);
- selectionInfo = AssignFinalSpan(selectionInfo, text, cancellationToken);
- selectionInfo = ApplySpecialCases(selectionInfo, text, cancellationToken);
- selectionInfo = CheckErrorCasesAndAppendDescriptions(selectionInfo, root, cancellationToken);
-
- // there was a fatal error that we couldn't even do negative preview, return error result
- if (selectionInfo.Status.FailedWithNoBestEffortSuggestion())
- {
- return new ErrorSelectionResult(selectionInfo.Status);
- }
-
- var controlFlowSpan = GetControlFlowSpan(selectionInfo);
- if (!selectionInfo.SelectionInExpression)
- {
- var statementRange = GetStatementRangeContainedInSpan<StatementSyntax>(root, controlFlowSpan, cancellationToken);
- if (statementRange == null)
- {
- selectionInfo = selectionInfo.WithStatus(s => s.With(OperationStatusFlag.None, "CSharpFeaturesResources.CantDetermineValidRangeOfStatements"));
- return new ErrorSelectionResult(selectionInfo.Status);
- }
-
- var isFinalSpanSemanticallyValid = IsFinalSpanSemanticallyValidSpan(model, controlFlowSpan, statementRange, cancellationToken);
- if (!isFinalSpanSemanticallyValid)
- {
- // check control flow only if we are extracting statement level, not expression
- // level. you can not have goto that moves control out of scope in expression level
- // (even in lambda)
- selectionInfo = selectionInfo.WithStatus(s => s.With(OperationStatusFlag.BestEffort, "CSharpFeaturesResources.NotAllCodePathReturns"));
- }
- }
-
- return await CSharpSelectionResult.CreateAsync(
- selectionInfo.Status,
- selectionInfo.OriginalSpan,
- selectionInfo.FinalSpan,
- this.Options,
- selectionInfo.SelectionInExpression,
- this.SemanticDocument,
- selectionInfo.FirstTokenInFinalSpan,
- selectionInfo.LastTokenInFinalSpan,
- cancellationToken).ConfigureAwait(false);
- }
-
- private SelectionInfo ApplySpecialCases(SelectionInfo selectionInfo, SourceText text, CancellationToken cancellationToken)
- {
- if (selectionInfo.Status.FailedWithNoBestEffortSuggestion() || !selectionInfo.SelectionInExpression)
- {
- return selectionInfo;
- }
-
- var expressionNode = selectionInfo.FirstTokenInFinalSpan.GetCommonRoot(selectionInfo.LastTokenInFinalSpan);
- if (!expressionNode.IsAnyAssignExpression())
- {
- return selectionInfo;
- }
-
- var assign = (AssignmentExpressionSyntax)expressionNode;
-
- // make sure there is a visible token at right side expression
- if (assign.Right.GetLastToken().Kind() == SyntaxKind.None)
- {
- return selectionInfo;
- }
-
- return AssignFinalSpan(selectionInfo.With(s => s.FirstTokenInFinalSpan = assign.Right.GetFirstToken(includeZeroWidth: true))
- .With(s => s.LastTokenInFinalSpan = assign.Right.GetLastToken(includeZeroWidth: true)),
- text, cancellationToken);
- }
-
- private TextSpan GetControlFlowSpan(SelectionInfo selectionInfo)
- {
- return TextSpan.FromBounds(selectionInfo.FirstTokenInFinalSpan.SpanStart, selectionInfo.LastTokenInFinalSpan.Span.End);
- }
-
- private SelectionInfo AdjustFinalTokensBasedOnContext(
- SelectionInfo selectionInfo,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- if (selectionInfo.Status.FailedWithNoBestEffortSuggestion())
- {
- return selectionInfo;
- }
-
- // don't need to adjust anything if it is multi-statements case
- if (!selectionInfo.SelectionInExpression && !selectionInfo.SelectionInSingleStatement)
- {
- return selectionInfo;
- }
-
- // get the node that covers the selection
- var node = selectionInfo.FirstTokenInFinalSpan.GetCommonRoot(selectionInfo.LastTokenInFinalSpan);
-
- var validNode = Check(semanticModel, node, cancellationToken);
- if (validNode)
- {
- return selectionInfo;
- }
-
- var firstValidNode = node.GetAncestors<SyntaxNode>().FirstOrDefault(n => Check(semanticModel, n, cancellationToken));
- if (firstValidNode == null)
- {
- // couldn't find any valid node
- return selectionInfo.WithStatus(s => new OperationStatus(OperationStatusFlag.None, "CSharpFeaturesResources.SelectionDoesNotContainAValidNode"))
- .With(s => s.FirstTokenInFinalSpan = default(SyntaxToken))
- .With(s => s.LastTokenInFinalSpan = default(SyntaxToken));
- }
-
- firstValidNode = (firstValidNode.Parent is ExpressionStatementSyntax) ? firstValidNode.Parent : firstValidNode;
-
- return selectionInfo.With(s => s.SelectionInExpression = firstValidNode is ExpressionSyntax)
- .With(s => s.SelectionInSingleStatement = firstValidNode is StatementSyntax)
- .With(s => s.FirstTokenInFinalSpan = firstValidNode.GetFirstToken(includeZeroWidth: true))
- .With(s => s.LastTokenInFinalSpan = firstValidNode.GetLastToken(includeZeroWidth: true));
- }
-
- private SelectionInfo GetInitialSelectionInfo(SyntaxNode root, SourceText text, CancellationToken cancellationToken)
- {
- var adjustedSpan = GetAdjustedSpan(text, this.OriginalSpan);
-
- var firstTokenInSelection = root.FindTokenOnRightOfPosition(adjustedSpan.Start, includeSkipped: false);
- var lastTokenInSelection = root.FindTokenOnLeftOfPosition(adjustedSpan.End, includeSkipped: false);
-
- if (firstTokenInSelection.Kind() == SyntaxKind.None || lastTokenInSelection.Kind() == SyntaxKind.None)
- {
- return new SelectionInfo { Status = new OperationStatus(OperationStatusFlag.None, "CSharpFeaturesResources.InvalidSelection"), OriginalSpan = adjustedSpan };
- }
-
- if (!adjustedSpan.Contains(firstTokenInSelection.Span) && !adjustedSpan.Contains(lastTokenInSelection.Span))
- {
- return new SelectionInfo
- {
- Status = new OperationStatus(OperationStatusFlag.None, "CSharpFeaturesResources.SelectionDoesNotContainAValidToken"),
- OriginalSpan = adjustedSpan,
- FirstTokenInOriginalSpan = firstTokenInSelection,
- LastTokenInOriginalSpan = lastTokenInSelection
- };
- }
-
- if (!firstTokenInSelection.UnderValidContext() || !lastTokenInSelection.UnderValidContext())
- {
- return new SelectionInfo
- {
- Status = new OperationStatus(OperationStatusFlag.None, "CSharpFeaturesResources.InvalidContext"),
- OriginalSpan = adjustedSpan,
- FirstTokenInOriginalSpan = firstTokenInSelection,
- LastTokenInOriginalSpan = lastTokenInSelection
- };
- }
-
- var commonRoot = firstTokenInSelection.GetCommonRoot(lastTokenInSelection);
- if (commonRoot == null)
- {
- return new SelectionInfo
- {
- Status = new OperationStatus(OperationStatusFlag.None, "CSharpFeaturesResources.NoCommonRootNodeForExtraction"),
- OriginalSpan = adjustedSpan,
- FirstTokenInOriginalSpan = firstTokenInSelection,
- LastTokenInOriginalSpan = lastTokenInSelection
- };
- }
-
- var selectionInExpression = commonRoot is ExpressionSyntax;
- if (!selectionInExpression && !commonRoot.UnderValidContext())
- {
- return new SelectionInfo
- {
- Status = new OperationStatus(OperationStatusFlag.None, "CSharpFeaturesResources.NoValidSelectionToPerformExtraction"),
- OriginalSpan = adjustedSpan,
- FirstTokenInOriginalSpan = firstTokenInSelection,
- LastTokenInOriginalSpan = lastTokenInSelection
- };
- }
-
- return new SelectionInfo
- {
- Status = OperationStatus.Succeeded,
- OriginalSpan = adjustedSpan,
- CommonRootFromOriginalSpan = commonRoot,
- SelectionInExpression = selectionInExpression,
- FirstTokenInOriginalSpan = firstTokenInSelection,
- LastTokenInOriginalSpan = lastTokenInSelection
- };
- }
-
- private SelectionInfo CheckErrorCasesAndAppendDescriptions(SelectionInfo selectionInfo, SyntaxNode root, CancellationToken cancellationToken)
- {
- if (selectionInfo.Status.FailedWithNoBestEffortSuggestion())
- {
- return selectionInfo;
- }
-
- if (selectionInfo.FirstTokenInFinalSpan.IsMissing || selectionInfo.LastTokenInFinalSpan.IsMissing)
- {
- selectionInfo = selectionInfo.WithStatus(s => s.With(OperationStatusFlag.None, "CSharpFeaturesResources.ContainsInvalidSelection"));
- }
-
- // get the node that covers the selection
- var commonNode = selectionInfo.FirstTokenInFinalSpan.GetCommonRoot(selectionInfo.LastTokenInFinalSpan);
-
- if ((selectionInfo.SelectionInExpression || selectionInfo.SelectionInSingleStatement) && commonNode.HasDiagnostics())
- {
- selectionInfo = selectionInfo.WithStatus(s => s.With(OperationStatusFlag.None, "CSharpFeaturesResources.TheSelectionContainsSyntacticErrors"));
- }
-
- var tokens = root.DescendantTokens(selectionInfo.FinalSpan);
- if (tokens.ContainPreprocessorCrossOver(selectionInfo.FinalSpan))
- {
- selectionInfo = selectionInfo.WithStatus(s => s.With(OperationStatusFlag.BestEffort, "CSharpFeaturesResources.SelectionCanNotCrossOverPreprocessorDirectives"));
- }
-
- // TODO : check whether this can be handled by control flow analysis engine
- if (tokens.Any(t => t.Kind() == SyntaxKind.YieldKeyword))
- {
- selectionInfo = selectionInfo.WithStatus(s => s.With(OperationStatusFlag.BestEffort, "CSharpFeaturesResources.SelectionCanNotContainAYieldStatement"));
- }
-
- // TODO : check behavior of control flow analysis engine around exception and exception handling.
- if (tokens.ContainArgumentlessThrowWithoutEnclosingCatch(selectionInfo.FinalSpan))
- {
- selectionInfo = selectionInfo.WithStatus(s => s.With(OperationStatusFlag.BestEffort, "CSharpFeaturesResources.SelectionCanNotContainThrowStatement"));
- }
-
- if (selectionInfo.SelectionInExpression && commonNode.PartOfConstantInitializerExpression())
- {
- selectionInfo = selectionInfo.WithStatus(s => s.With(OperationStatusFlag.None, "CSharpFeaturesResources.SelectionCanNotBePartOfConstInitializerExpr"));
- }
-
- if (commonNode.IsUnsafeContext())
- {
- selectionInfo = selectionInfo.WithStatus(s => s.With(s.Flag, "CSharpFeaturesResources.TheSelectedCodeIsInsideAnUnsafeContext"));
- }
-
- var selectionChanged = selectionInfo.FirstTokenInOriginalSpan != selectionInfo.FirstTokenInFinalSpan || selectionInfo.LastTokenInOriginalSpan != selectionInfo.LastTokenInFinalSpan;
- if (selectionChanged)
- {
- selectionInfo = selectionInfo.WithStatus(s => s.MarkSuggestion());
- }
-
- return selectionInfo;
- }
-
- private SelectionInfo AssignInitialFinalTokens(SelectionInfo selectionInfo, SyntaxNode root, CancellationToken cancellationToken)
- {
- if (selectionInfo.Status.FailedWithNoBestEffortSuggestion())
- {
- return selectionInfo;
- }
-
- if (selectionInfo.SelectionInExpression)
- {
- // simple expression case
- return selectionInfo.With(s => s.FirstTokenInFinalSpan = s.CommonRootFromOriginalSpan.GetFirstToken(includeZeroWidth: true))
- .With(s => s.LastTokenInFinalSpan = s.CommonRootFromOriginalSpan.GetLastToken(includeZeroWidth: true));
- }
-
- var range = GetStatementRangeContainingSpan<StatementSyntax>(
- root, TextSpan.FromBounds(selectionInfo.FirstTokenInOriginalSpan.SpanStart, selectionInfo.LastTokenInOriginalSpan.Span.End),
- cancellationToken);
-
- if (range == null)
- {
- return selectionInfo.WithStatus(s => s.With(OperationStatusFlag.None, "CSharpFeaturesResources.NoValidStatementRangeToExtractOut"));
- }
-
- var statement1 = (StatementSyntax)range.Item1;
- var statement2 = (StatementSyntax)range.Item2;
-
- if (statement1 == statement2)
- {
- // check one more time to see whether it is an expression case
- var expression = selectionInfo.CommonRootFromOriginalSpan.GetAncestor<ExpressionSyntax>();
- if (expression != null && statement1.Span.Contains(expression.Span))
- {
- return selectionInfo.With(s => s.SelectionInExpression = true)
- .With(s => s.FirstTokenInFinalSpan = expression.GetFirstToken(includeZeroWidth: true))
- .With(s => s.LastTokenInFinalSpan = expression.GetLastToken(includeZeroWidth: true));
- }
-
- // single statement case
- return selectionInfo.With(s => s.SelectionInSingleStatement = true)
- .With(s => s.FirstTokenInFinalSpan = statement1.GetFirstToken(includeZeroWidth: true))
- .With(s => s.LastTokenInFinalSpan = statement1.GetLastToken(includeZeroWidth: true));
- }
-
- // move only statements inside of the block
- return selectionInfo.With(s => s.FirstTokenInFinalSpan = statement1.GetFirstToken(includeZeroWidth: true))
- .With(s => s.LastTokenInFinalSpan = statement2.GetLastToken(includeZeroWidth: true));
- }
-
- private SelectionInfo AssignFinalSpan(SelectionInfo selectionInfo, SourceText text, CancellationToken cancellationToken)
- {
- if (selectionInfo.Status.FailedWithNoBestEffortSuggestion())
- {
- return selectionInfo;
- }
-
- // set final span
- var start = (selectionInfo.FirstTokenInOriginalSpan == selectionInfo.FirstTokenInFinalSpan) ?
- Math.Min(selectionInfo.FirstTokenInOriginalSpan.SpanStart, selectionInfo.OriginalSpan.Start) :
- selectionInfo.FirstTokenInFinalSpan.FullSpan.Start;
-
- var end = (selectionInfo.LastTokenInOriginalSpan == selectionInfo.LastTokenInFinalSpan) ?
- Math.Max(selectionInfo.LastTokenInOriginalSpan.Span.End, selectionInfo.OriginalSpan.End) :
- selectionInfo.LastTokenInFinalSpan.FullSpan.End;
-
- return selectionInfo.With(s => s.FinalSpan = GetAdjustedSpan(text, TextSpan.FromBounds(start, end)));
- }
-
- public override bool ContainsNonReturnExitPointsStatements(IEnumerable<SyntaxNode> jumpsOutOfRegion)
- {
- return jumpsOutOfRegion.Any (n => !(n is ReturnStatementSyntax));
- }
-
- public override IEnumerable<SyntaxNode> GetOuterReturnStatements(SyntaxNode commonRoot, IEnumerable<SyntaxNode> jumpsOutOfRegion)
- {
- var returnStatements = jumpsOutOfRegion.Where(s => s is ReturnStatementSyntax);
-
- var container = commonRoot.GetAncestorsOrThis<SyntaxNode> ().FirstOrDefault (SyntaxNodeExtensions.IsReturnableConstruct);
- if (container == null)
- {
- return SpecializedCollections.EmptyEnumerable<SyntaxNode>();
- }
-
- var returnableConstructPairs = returnStatements.Select(r => Tuple.Create(r, r.GetAncestors<SyntaxNode> ().FirstOrDefault (SyntaxNodeExtensions.IsReturnableConstruct)))
- .Where(p => p.Item2 != null);
-
- // now filter return statements to only include the one under outmost container
- return returnableConstructPairs.Where(p => p.Item2 == container).Select(p => p.Item1);
- }
-
- public override bool IsFinalSpanSemanticallyValidSpan(
- SyntaxNode root, TextSpan textSpan,
- IEnumerable<SyntaxNode> returnStatements, CancellationToken cancellationToken)
- {
- // return statement shouldn't contain any return value
- if (returnStatements.Cast<ReturnStatementSyntax>().Any(r => r.Expression != null))
- {
- return false;
- }
-
- var lastToken = (SyntaxToken)root.FindToken(textSpan.End);
- if (lastToken.Kind() == SyntaxKind.None)
- {
- return false;
- }
-
- var container = lastToken.GetAncestors<SyntaxNode>().FirstOrDefault(SyntaxNodeExtensions.IsReturnableConstruct);
- if (container == null)
- {
- return false;
- }
-
- var body = container.GetBlockBody();
- if (body == null)
- {
- return false;
- }
-
- // make sure that next token of the last token in the selection is the close braces of containing block
- if (body.CloseBraceToken != lastToken.GetNextToken(includeZeroWidth: true))
- {
- return false;
- }
-
- // alright, for these construcuts, it must be okay to be extracted
- switch (container.Kind())
- {
- case SyntaxKind.AnonymousMethodExpression:
- case SyntaxKind.SimpleLambdaExpression:
- case SyntaxKind.ParenthesizedLambdaExpression:
- return true;
- }
-
- // now, only method is okay to be extracted out
- var method = body.Parent as MethodDeclarationSyntax;
- if (method == null)
- {
- return false;
- }
-
- // make sure this method doesn't have return type.
- return method.ReturnType.TypeSwitch((PredefinedTypeSyntax p) => p.Keyword.Kind() == SyntaxKind.VoidKeyword);
- }
-
- private static TextSpan GetAdjustedSpan(SourceText text, TextSpan textSpan)
- {
- // beginning of a file
- if (textSpan.IsEmpty || textSpan.End == 0)
- {
- return textSpan;
- }
-
- // if it is a start of new line, make it belong to previous line
- var line = text.Lines.GetLineFromPosition(textSpan.End);
- if (line.Start != textSpan.End)
- {
- return textSpan;
- }
-
- // get previous line
- //Contract.ThrowIfFalse(line.LineNumber > 0);
- var previousLine = text.Lines[line.LineNumber - 1];
- return TextSpan.FromBounds(textSpan.Start, previousLine.End);
- }
-
- private class SelectionInfo
- {
- public OperationStatus Status { get; set; }
-
- public TextSpan OriginalSpan { get; set; }
- public TextSpan FinalSpan { get; set; }
-
- public SyntaxNode CommonRootFromOriginalSpan { get; set; }
-
- public SyntaxToken FirstTokenInOriginalSpan { get; set; }
- public SyntaxToken LastTokenInOriginalSpan { get; set; }
-
- public SyntaxToken FirstTokenInFinalSpan { get; set; }
- public SyntaxToken LastTokenInFinalSpan { get; set; }
-
- public bool SelectionInExpression { get; set; }
- public bool SelectionInSingleStatement { get; set; }
-
- public SelectionInfo WithStatus(Func<OperationStatus, OperationStatus> statusGetter)
- {
- return With(s => s.Status = statusGetter(s.Status));
- }
-
- public SelectionInfo With(Action<SelectionInfo> valueSetter)
- {
- var newInfo = this.Clone();
- valueSetter(newInfo);
- return newInfo;
- }
-
- public SelectionInfo Clone()
- {
- return (SelectionInfo)this.MemberwiseClone();
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSyntaxTriviaService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSyntaxTriviaService.cs
deleted file mode 100644
index a8107c2c14..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSyntaxTriviaService.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class CSharpSyntaxTriviaService : AbstractSyntaxTriviaService
- {
- public CSharpSyntaxTriviaService()
- : base((int)SyntaxKind.EndOfLineTrivia)
- {
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSyntaxTriviaServiceFactory.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSyntaxTriviaServiceFactory.cs
deleted file mode 100644
index 3fcd67d257..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/CSharpSyntaxTriviaServiceFactory.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-
-using Microsoft.CodeAnalysis;
-
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
-// [ExportLanguageServiceFactory(typeof(ISyntaxTriviaService), LanguageNames.CSharp), Shared]
-// class CSharpSyntaxTriviaServiceFactory : ILanguageServiceFactory
-// {
-// public ILanguageService CreateLanguageService(HostLanguageServices provider)
-// {
-// return new CSharpSyntaxTriviaService(provider);
-// }
-// }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/Extensions.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/Extensions.cs
deleted file mode 100644
index 61825c5c53..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/CSharp/Extensions.cs
+++ /dev/null
@@ -1,285 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- static partial class Extensions
- {
- public static ExpressionSyntax GetUnparenthesizedExpression(this SyntaxNode node)
- {
- var parenthesizedExpression = node as ParenthesizedExpressionSyntax;
- if (parenthesizedExpression == null)
- {
- return node as ExpressionSyntax;
- }
-
- return GetUnparenthesizedExpression(parenthesizedExpression.Expression);
- }
-
- public static StatementSyntax GetStatementUnderContainer(this SyntaxNode node)
- {
- //Contract.ThrowIfNull(node);
-
- while (node != null)
- {
- if (node.Parent != null &&
- node.Parent.IsStatementContainerNode())
- {
- return node as StatementSyntax;
- }
-
- node = node.Parent;
- }
-
- return null;
- }
-
- public static StatementSyntax GetParentLabeledStatementIfPossible(this SyntaxNode node)
- {
- return (StatementSyntax)((node.Parent is LabeledStatementSyntax) ? node.Parent : node);
- }
-
- public static bool IsStatementContainerNode(this SyntaxNode node)
- {
- return node is BlockSyntax || node is SwitchSectionSyntax;
- }
-
- public static BlockSyntax GetBlockBody(this SyntaxNode node)
- {
- return node.TypeSwitch(
- (BaseMethodDeclarationSyntax m) => m.Body,
- (AccessorDeclarationSyntax a) => a.Body,
- (SimpleLambdaExpressionSyntax s) => s.Body as BlockSyntax,
- (ParenthesizedLambdaExpressionSyntax p) => p.Body as BlockSyntax,
- (AnonymousMethodExpressionSyntax a) => a.Block);
- }
-
- public static bool UnderValidContext(this SyntaxNode node)
- {
- //Contract.ThrowIfNull(node);
-
- Func<SyntaxNode, bool> predicate = n =>
- {
- if (n is BaseMethodDeclarationSyntax ||
- n is AccessorDeclarationSyntax ||
- n is BlockSyntax ||
- n is GlobalStatementSyntax)
- {
- return true;
- }
-
- var constructorInitializer = n as ConstructorInitializerSyntax;
- if (constructorInitializer != null)
- {
- return constructorInitializer.ContainsInArgument(node.Span);
- }
-
- return false;
- };
-
- if (!node.GetAncestorsOrThis<SyntaxNode>().Any(predicate))
- {
- return false;
- }
-
- if (node.FromScript() || node.GetAncestor<TypeDeclarationSyntax>() != null)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool UnderValidContext(this SyntaxToken token)
- {
- return token.GetAncestors<SyntaxNode>().Any(n => n.CheckTopLevel(token.Span));
- }
-
- public static bool PartOfConstantInitializerExpression(this SyntaxNode node)
- {
- return node.PartOfConstantInitializerExpression<FieldDeclarationSyntax>(n => n.Modifiers) ||
- node.PartOfConstantInitializerExpression<LocalDeclarationStatementSyntax>(n => n.Modifiers);
- }
-
- private static bool PartOfConstantInitializerExpression<T>(this SyntaxNode node, Func<T, SyntaxTokenList> modifiersGetter) where T : SyntaxNode
- {
- var decl = node.GetAncestor<T>();
- if (decl == null)
- {
- return false;
- }
-
- if (!modifiersGetter(decl).Any(t => t.Kind() == SyntaxKind.ConstKeyword))
- {
- return false;
- }
-
- // we are under decl with const modifier, check we are part of initializer expression
- var equal = node.GetAncestor<EqualsValueClauseSyntax>();
- if (equal == null)
- {
- return false;
- }
-
- return equal.Value != null && equal.Value.Span.Contains(node.Span);
- }
-
- public static bool ContainArgumentlessThrowWithoutEnclosingCatch(this IEnumerable<SyntaxToken> tokens, TextSpan textSpan)
- {
- foreach (var token in tokens)
- {
- if (token.Kind() != SyntaxKind.ThrowKeyword)
- {
- continue;
- }
-
- var throwStatement = token.Parent as ThrowStatementSyntax;
- if (throwStatement == null || throwStatement.Expression != null)
- {
- continue;
- }
-
- var catchClause = token.GetAncestor<CatchClauseSyntax>();
- if (catchClause == null || !textSpan.Contains(catchClause.Span))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool ContainPreprocessorCrossOver(this IEnumerable<SyntaxToken> tokens, TextSpan textSpan)
- {
- int activeRegions = 0;
- int activeIfs = 0;
-
- foreach (var trivia in tokens.GetAllTrivia())
- {
- if (!textSpan.Contains(trivia.Span))
- {
- continue;
- }
-
- switch (trivia.Kind())
- {
- case SyntaxKind.RegionDirectiveTrivia:
- activeRegions++;
- break;
- case SyntaxKind.EndRegionDirectiveTrivia:
- if (activeRegions <= 0)
- {
- return true;
- }
-
- activeRegions--;
- break;
- case SyntaxKind.IfDirectiveTrivia:
- activeIfs++;
- break;
- case SyntaxKind.EndIfDirectiveTrivia:
- if (activeIfs <= 0)
- {
- return true;
- }
-
- activeIfs--;
- break;
- case SyntaxKind.ElseDirectiveTrivia:
- case SyntaxKind.ElifDirectiveTrivia:
- if (activeIfs <= 0)
- {
- return true;
- }
-
- break;
- }
- }
-
- return activeIfs != 0 || activeRegions != 0;
- }
-
- public static IEnumerable<SyntaxTrivia> GetAllTrivia(this IEnumerable<SyntaxToken> tokens)
- {
- foreach (var token in tokens)
- {
- foreach (var trivia in token.LeadingTrivia)
- {
- yield return trivia;
- }
-
- foreach (var trivia in token.TrailingTrivia)
- {
- yield return trivia;
- }
- }
- }
-
- public static bool HasSyntaxAnnotation(this HashSet<SyntaxAnnotation> set, SyntaxNode node)
- {
- return set.Any(a => node.GetAnnotatedNodesAndTokens(a).Any());
- }
-
- public static bool HasHybridTriviaBetween(this SyntaxToken token1, SyntaxToken token2)
- {
- if (token1.TrailingTrivia.Any(t => !t.IsElastic()))
- {
- return true;
- }
-
- if (token2.LeadingTrivia.Any(t => !t.IsElastic()))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsArrayInitializer(this SyntaxNode node)
- {
- return node is InitializerExpressionSyntax && node.Parent is EqualsValueClauseSyntax;
- }
-
- public static bool IsExpressionInCast(this SyntaxNode node)
- {
- return node is ExpressionSyntax && node.Parent is CastExpressionSyntax;
- }
-
- public static bool IsExpression(this SyntaxNode node)
- {
- return node is ExpressionSyntax;
- }
-
- public static bool IsErrorType(this ITypeSymbol type)
- {
- return type == null || type.Kind == SymbolKind.ErrorType;
- }
-
- public static bool IsObjectType(this ITypeSymbol type)
- {
- return type == null || type.SpecialType == SpecialType.System_Object;
- }
-
- public static bool BetweenFieldAndNonFieldMember(this SyntaxToken token1, SyntaxToken token2)
- {
- if (token1.RawKind != (int)SyntaxKind.SemicolonToken || !(token1.Parent is FieldDeclarationSyntax))
- {
- return false;
- }
-
- var field = token2.GetAncestor<FieldDeclarationSyntax>();
- return field == null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/Enums.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/Enums.cs
deleted file mode 100644
index 36b85e5578..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/Enums.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- public enum DeclarationBehavior
- {
- None,
- Delete,
- MoveIn,
- MoveOut,
- SplitIn,
- SplitOut
- }
-
- public enum ReturnBehavior
- {
- None,
- Initialization,
- Assignment
- }
-
- public enum ParameterBehavior
- {
- None,
- Input,
- Out,
- Ref
- }
-
- /// <summary>
- /// status code for extract method operations
- /// </summary>
- [Flags]
- public enum OperationStatusFlag
- {
- None = 0x0,
-
- /// <summary>
- /// operation has succeeded
- /// </summary>
- Succeeded = 0x1,
-
- /// <summary>
- /// operation has succeeded with a span that is different than original span
- /// </summary>
- Suggestion = 0x2,
-
- /// <summary>
- /// operation has failed but can provide some best effort result
- /// </summary>
- BestEffort = 0x4,
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/Extensions.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/Extensions.cs
deleted file mode 100644
index 5a4f85d696..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/Extensions.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- static partial class Extensions
- {
- public static bool Succeeded(this OperationStatus status)
- {
- return status.Flag.Succeeded();
- }
-
- public static bool FailedWithNoBestEffortSuggestion(this OperationStatus status)
- {
- return status.Flag.Failed() && !status.Flag.HasBestEffort();
- }
-
- public static bool Failed(this OperationStatus status)
- {
- return status.Flag.Failed();
- }
-
- public static bool Succeeded(this OperationStatusFlag flag)
- {
- return (flag & OperationStatusFlag.Succeeded) != 0;
- }
-
- public static bool Failed(this OperationStatusFlag flag)
- {
- return !flag.Succeeded();
- }
-
- public static bool HasBestEffort(this OperationStatusFlag flag)
- {
- return (flag & OperationStatusFlag.BestEffort) != 0;
- }
-
- public static bool HasSuggestion(this OperationStatusFlag flag)
- {
- return (flag & OperationStatusFlag.Suggestion) != 0;
- }
-
- public static bool HasMask(this OperationStatusFlag flag, OperationStatusFlag mask)
- {
- return (flag & mask) != 0x0;
- }
-
- public static OperationStatusFlag RemoveFlag(this OperationStatusFlag baseFlag, OperationStatusFlag flagToRemove)
- {
- return baseFlag & ~flagToRemove;
- }
-
- public static ITypeSymbol GetLambdaOrAnonymousMethodReturnType(this SemanticModel binding, SyntaxNode node)
- {
- var info = binding.GetSymbolInfo(node);
- if (info.Symbol == null)
- {
- return null;
- }
-
- var methodSymbol = info.Symbol as IMethodSymbol;
- if (methodSymbol.MethodKind != MethodKind.AnonymousFunction)
- {
- return null;
- }
-
- return methodSymbol.ReturnType;
- }
-
- public static Task<SemanticDocument> WithSyntaxRootAsync(this SemanticDocument semanticDocument, SyntaxNode root, CancellationToken cancellationToken)
- {
- return SemanticDocument.CreateAsync(semanticDocument.Document.WithSyntaxRoot(root), cancellationToken);
- }
-
- /// <summary>
- /// get tokens with given annotation in current document
- /// </summary>
- public static SyntaxToken GetTokenWithAnnotaton(this SemanticDocument document, SyntaxAnnotation annotation)
- {
- return document.Root.GetAnnotatedNodesAndTokens(annotation).Single().AsToken();
- }
-
- /// <summary>
- /// resolve the given symbol against compilation this snapshot has
- /// </summary>
- public static T ResolveType<T>(this SemanticModel semanticModel, T symbol) where T : class, ITypeSymbol
- {
- return (T)symbol.GetSymbolKey().Resolve(semanticModel.Compilation).GetAnySymbol();
- }
-
- /// <summary>
- /// check whether node contains error for itself but not from its child node
- /// </summary>
- public static bool HasDiagnostics(this SyntaxNode node)
- {
- var set = new HashSet<Diagnostic>(node.GetDiagnostics());
-
- foreach (var child in node.ChildNodes())
- {
- set.ExceptWith(child.GetDiagnostics());
- }
-
- return set.Count > 0;
- }
-
- public static bool FromScript(this SyntaxNode node)
- {
- if (node.SyntaxTree == null)
- {
- return false;
- }
-
- return node.SyntaxTree.Options.Kind != SourceCodeKind.Regular;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodMatrix.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodMatrix.cs
deleted file mode 100644
index 972a936f74..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodMatrix.cs
+++ /dev/null
@@ -1,229 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class ExtractMethodMatrix
- {
- private static readonly Dictionary<Key, VariableStyle> s_matrix;
-
- static ExtractMethodMatrix()
- {
- s_matrix = new Dictionary<Key, VariableStyle>();
- BuildMatrix();
- }
-
- public static VariableStyle GetVariableStyle(
- bool captured,
- bool dataFlowIn,
- bool dataFlowOut,
- bool alwaysAssigned,
- bool variableDeclared,
- bool readInside,
- bool writtenInside,
- bool readOutside,
- bool writtenOutside,
- bool unsafeAddressTaken)
- {
-#if false
- // decide not to treat capture variable special
- if (captured)
- {
- // if a variable is captured, it can only be passed as ref parameter.
- return VariableStyle.OnlyAsRefParam;
- }
-#endif
- // bug # 12258, 12114
- // use "out" if "&" is taken for the variable
- if (unsafeAddressTaken)
- {
- return VariableStyle.Out;
- }
-
- var key = new Key(
- dataFlowIn,
- dataFlowOut,
- alwaysAssigned,
- variableDeclared,
- readInside,
- writtenInside,
- readOutside,
- writtenOutside);
-
- // special cases
- if (!s_matrix.ContainsKey(key))
- {
- // Interesting case. Due to things like constant analysis there can be regions that
- // the compiler considers data not to flow in (because analysis proves that that
- // path will never be taken). However, the variable can still be read/written inside
- // the region. For purposes of extract method, we check for this case, and we
- // pretend it's as if data flowed into the region.
- if (!dataFlowIn && (readInside || writtenInside))
- {
- key = new Key(true, dataFlowOut, alwaysAssigned, variableDeclared, readInside, writtenInside, readOutside, writtenOutside);
- }
-
- // another interesting case (bug # 10875)
- // basically, it can happen in malformed code where a variable is not properly assigned but used outside of the selection + unreachable code region
- // for such cases, treat it like "MoveOut"
- if (!dataFlowOut && !alwaysAssigned && variableDeclared && !writtenInside && readOutside)
- {
- key = new Key(dataFlowIn, /*dataFlowOut*/ true, alwaysAssigned, variableDeclared, readInside, writtenInside, readOutside, writtenOutside);
- }
- }
-
- // Contract.ThrowIfFalse(s_matrix.ContainsKey(key));
-
- return s_matrix[key];
- }
-
- private static void BuildMatrix()
- {
- // meaning of each boolean values (total of 69 different cases)
- // data flowin/data flow out/always assigned/variable declared/ read inside/written inside/read outside/written outside
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: false, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: false, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: false, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: false, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.MoveIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.SplitIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: false, writtenInside: false, readOutside: false, writtenOutside: true), VariableStyle.MoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: false, writtenInside: false, readOutside: true, writtenOutside: true), VariableStyle.MoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: false, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.None);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: false, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: false, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: false, readOutside: false, writtenOutside: false), VariableStyle.None);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: false, readOutside: false, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: false, readOutside: true, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.None);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: false, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.MoveIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: false, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.SplitIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: false, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.SplitIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: false, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.SplitIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.MoveIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.SplitIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.SplitIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.SplitIn);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: true, readInside: false, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.None);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: true, readInside: false, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: true, readInside: false, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: true, readInside: true, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.None);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: true, readInside: true, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: false, alwaysAssigned: true, variableDeclared: true, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.SplitOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: false, readInside: false, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.Ref);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: false, readInside: false, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.Ref);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.Ref);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.Ref);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: true, readInside: false, writtenInside: false, readOutside: true, writtenOutside: false), VariableStyle.NotUsed);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: true, readInside: false, writtenInside: false, readOutside: true, writtenOutside: true), VariableStyle.NotUsed);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: true, readInside: false, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: true, readInside: false, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: false, readOutside: true, writtenOutside: false), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: false, readOutside: true, writtenOutside: true), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: false, variableDeclared: true, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: true, variableDeclared: false, readInside: false, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.Out);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: true, variableDeclared: false, readInside: false, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.Out);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.Out);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.Out);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: true, variableDeclared: true, readInside: false, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: true, variableDeclared: true, readInside: false, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: true, variableDeclared: true, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: false, dataFlowOut: true, alwaysAssigned: true, variableDeclared: true, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.OutWithMoveOut);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: false, readOutside: false, writtenOutside: false), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: false, readOutside: false, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: false, readOutside: true, writtenOutside: false), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: false, readOutside: true, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: false, writtenOutside: false), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: false, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: false, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.InputOnly);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: true, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.OutWithErrorInput);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: true, alwaysAssigned: false, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.Ref);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: true, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: false), VariableStyle.OutWithErrorInput);
- s_matrix.Add(new Key(dataFlowIn: true, dataFlowOut: true, alwaysAssigned: true, variableDeclared: false, readInside: true, writtenInside: true, readOutside: true, writtenOutside: true), VariableStyle.Ref);
- }
-
- private struct Key : IEquatable<Key>
- {
- public bool DataFlowIn { get; }
- public bool DataFlowOut { get; }
- public bool AlwaysAssigned { get; }
- public bool VariableDeclared { get; }
- public bool ReadInside { get; }
- public bool WrittenInside { get; }
- public bool ReadOutside { get; }
- public bool WrittenOutside { get; }
-
- public Key(
- bool dataFlowIn,
- bool dataFlowOut,
- bool alwaysAssigned,
- bool variableDeclared,
- bool readInside,
- bool writtenInside,
- bool readOutside,
- bool writtenOutside) :
- this()
- {
- this.DataFlowIn = dataFlowIn;
- this.DataFlowOut = dataFlowOut;
- this.AlwaysAssigned = alwaysAssigned;
- this.VariableDeclared = variableDeclared;
- this.ReadInside = readInside;
- this.WrittenInside = writtenInside;
- this.ReadOutside = readOutside;
- this.WrittenOutside = writtenOutside;
- }
-
- public bool Equals(Key key)
- {
- return this.DataFlowIn == key.DataFlowIn &&
- this.DataFlowOut == key.DataFlowOut &&
- this.AlwaysAssigned == key.AlwaysAssigned &&
- this.VariableDeclared == key.VariableDeclared &&
- this.ReadInside == key.ReadInside &&
- this.WrittenInside == key.WrittenInside &&
- this.ReadOutside == key.ReadOutside &&
- this.WrittenOutside == key.WrittenOutside;
- }
-
- public override bool Equals(object obj)
- {
- if (obj is Key)
- {
- return Equals((Key)obj);
- }
-
- return false;
- }
-
- public override int GetHashCode()
- {
- var hashCode = 0;
-
- hashCode = this.DataFlowIn ? 1 << 7 | hashCode : hashCode;
- hashCode = this.DataFlowOut ? 1 << 6 | hashCode : hashCode;
- hashCode = this.AlwaysAssigned ? 1 << 5 | hashCode : hashCode;
- hashCode = this.VariableDeclared ? 1 << 4 | hashCode : hashCode;
- hashCode = this.ReadInside ? 1 << 3 | hashCode : hashCode;
- hashCode = this.WrittenInside ? 1 << 2 | hashCode : hashCode;
- hashCode = this.ReadOutside ? 1 << 1 | hashCode : hashCode;
- hashCode = this.WrittenOutside ? 1 << 0 | hashCode : hashCode;
-
- return hashCode;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodOptions.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodOptions.cs
deleted file mode 100644
index 9bb3dec0af..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodOptions.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.CodeAnalysis.Options;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- static class ExtractMethodOptions
- {
- public const string FeatureName = "ExtractMethod";
-
- public static readonly PerLanguageOption<bool> AllowBestEffort = new PerLanguageOption<bool>(FeatureName, "Allow Best Effort", defaultValue: false);
-
- public static readonly PerLanguageOption<bool> DontPutOutOrRefOnStruct = new PerLanguageOption<bool>(FeatureName, "Don't Put Out Or Ref On Strcut", defaultValue: true);
-
- public static readonly PerLanguageOption<bool> AllowMovingDeclaration = new PerLanguageOption<bool>(FeatureName, "Allow Moving Declaration", defaultValue: false);
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodResult.cs
deleted file mode 100644
index 16a49ae80d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodResult.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using Roslyn.Utilities;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class ExtractMethodResult
- {
- /// <summary>
- /// True if the extract method operation succeeded.
- /// </summary>
- public bool Succeeded { get; }
-
- /// <summary>
- /// True if the extract method operation is possible if the original span is adjusted.
- /// </summary>
- public bool SucceededWithSuggestion { get; }
-
- /// <summary>
- /// The transformed document that was produced as a result of the extract method operation.
- /// </summary>
- public Document Document { get; }
-
- /// <summary>
- /// The reasons why the extract method operation did not succeed.
- /// </summary>
- public IEnumerable<string> Reasons { get; }
-
- /// <summary>
- /// the generated method node that contains the extracted code.
- /// </summary>
- public SyntaxNode MethodDeclarationNode { get; }
-
- /// <summary>
- /// The name token for the invocation node that replaces the extracted code.
- /// </summary>
- public SyntaxToken InvocationNameToken { get; }
-
- public ExtractMethodResult(
- OperationStatusFlag status,
- IEnumerable<string> reasons,
- Document document,
- SyntaxToken invocationNameToken,
- SyntaxNode methodDeclarationNode)
- {
- this.Status = status;
-
- this.Succeeded = status.Succeeded() && !status.HasSuggestion();
- this.SucceededWithSuggestion = status.Succeeded() && status.HasSuggestion();
-
- this.Reasons = (reasons ?? SpecializedCollections.EmptyEnumerable<string>()).ToReadOnlyCollection();
-
- this.Document = document;
- this.InvocationNameToken = invocationNameToken;
- this.MethodDeclarationNode = methodDeclarationNode;
- }
-
- /// <summary>
- /// public status of result. more fine grained reason why it is failed.
- /// </summary>
- public OperationStatusFlag Status { get; }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodService.cs
deleted file mode 100644
index db42f1dc3a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ExtractMethodService.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- static class ExtractMethodService
- {
- readonly static CSharpExtractMethodService service = new CSharpExtractMethodService ();
-
- public static Task<ExtractMethodResult> ExtractMethodAsync(Document document, TextSpan textSpan, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- return service.ExtractMethodAsync(document, textSpan, options, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/FailedExtractMethodResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/FailedExtractMethodResult.cs
deleted file mode 100644
index eeeea1b54e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/FailedExtractMethodResult.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class FailedExtractMethodResult : ExtractMethodResult
- {
- public FailedExtractMethodResult(OperationStatus status)
- : base(status.Flag, status.Reasons, null, default(SyntaxToken), default(SyntaxNode))
- {
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/IExtractMethodService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/IExtractMethodService.cs
deleted file mode 100644
index 4422c18b45..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/IExtractMethodService.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- interface IExtractMethodService : ILanguageService
- {
- Task<ExtractMethodResult> ExtractMethodAsync(Document document, TextSpan textSpan, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken));
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ISyntaxTriviaService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ISyntaxTriviaService.cs
deleted file mode 100644
index f75f66ce20..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ISyntaxTriviaService.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- public enum TriviaLocation
- {
- BeforeBeginningOfSpan = 0,
- AfterBeginningOfSpan,
- BeforeEndOfSpan,
- AfterEndOfSpan
- }
-
- public struct PreviousNextTokenPair
- {
- public SyntaxToken PreviousToken { get; set; }
- public SyntaxToken NextToken { get; set; }
- }
-
- public struct LeadingTrailingTriviaPair
- {
- public IEnumerable<SyntaxTrivia> LeadingTrivia { get; set; }
- public IEnumerable<SyntaxTrivia> TrailingTrivia { get; set; }
- }
-
- public delegate SyntaxToken AnnotationResolver(SyntaxNode root, TriviaLocation location, SyntaxAnnotation annotation);
- public delegate IEnumerable<SyntaxTrivia> TriviaResolver(TriviaLocation location, PreviousNextTokenPair tokenPair, Dictionary<SyntaxToken, LeadingTrailingTriviaPair> triviaMap);
-
- /// <summary>
- /// contains information to restore trivia later on to the annotated tree
- /// </summary>
- public interface ITriviaSavedResult
- {
- /// <summary>
- /// root node of the annotated tree.
- /// </summary>
- SyntaxNode Root { get; }
-
- /// <summary>
- /// restore saved trivia to given tree
- /// </summary>
- /// <param name="root">root node to the annotated tree</param>
- /// <param name="annotationResolver">it provides a custom way of resolving annotations to retrieve right tokens to attach trivia</param>
- /// <param name="triviaResolver">it provides a custom way of creating trivia list between two tokens</param>
- /// <returns>root node to a trivia restored tree</returns>
- SyntaxNode RestoreTrivia(SyntaxNode root, AnnotationResolver annotationResolver = null, TriviaResolver triviaResolver = null);
- }
-
- /// <summary>
- /// syntax trivia related services
- /// </summary>
- public interface ISyntaxTriviaService : ILanguageService
- {
- /// <summary>
- /// save trivia around span and let user restore trivia later
- /// </summary>
- /// <param name="root">root node of a tree</param>
- /// <param name="textSpan">selection whose trivia around its edges will be saved</param>
- /// <returns>object that holds onto enough information to restore trivia later</returns>
- ITriviaSavedResult SaveTriviaAroundSelection(SyntaxNode root, TextSpan textSpan);
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/InsertionPoint.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/InsertionPoint.cs
deleted file mode 100644
index 51bbb415e0..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/InsertionPoint.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class InsertionPoint
- {
- private readonly SyntaxAnnotation _annotation;
- private readonly Lazy<SyntaxNode> _context;
-
- public static async Task<InsertionPoint> CreateAsync(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
- {
- var root = document.Root;
- var annotation = new SyntaxAnnotation();
- var newRoot = root.AddAnnotations(SpecializedCollections.SingletonEnumerable(Tuple.Create(node, annotation)));
- return new InsertionPoint(await document.WithSyntaxRootAsync(newRoot, cancellationToken).ConfigureAwait(false), annotation);
- }
-
- private InsertionPoint(SemanticDocument document, SyntaxAnnotation annotation)
- {
- //Contract.ThrowIfNull(document);
- //Contract.ThrowIfNull(annotation);
-
- this.SemanticDocument = document;
- _annotation = annotation;
- _context = CreateLazyContextNode();
- }
-
- public SemanticDocument SemanticDocument { get; }
-
- public SyntaxNode GetRoot()
- {
- return this.SemanticDocument.Root;
- }
-
- public SyntaxNode GetContext()
- {
- return _context.Value;
- }
-
- public InsertionPoint With(SemanticDocument document)
- {
- return new InsertionPoint(document, _annotation);
- }
-
- private Lazy<SyntaxNode> CreateLazyContextNode()
- {
- return new Lazy<SyntaxNode>(ComputeContextNode, isThreadSafe: true);
- }
-
- private SyntaxNode ComputeContextNode()
- {
- var root = this.SemanticDocument.Root;
- return root.GetAnnotatedNodesAndTokens(_annotation).Single().AsNode();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.Analyzer.SymbolMapBuilder.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.Analyzer.SymbolMapBuilder.cs
deleted file mode 100644
index f0d01b4629..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.Analyzer.SymbolMapBuilder.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- protected abstract partial class Analyzer
- {
- private class SymbolMapBuilder : SyntaxWalker
- {
- private readonly SemanticModel _semanticModel;
- //private readonly ISyntaxFactsService _service;
- private readonly TextSpan _span;
- private readonly Dictionary<ISymbol, List<SyntaxToken>> _symbolMap;
- private readonly CancellationToken _cancellationToken;
-
- public static Dictionary<ISymbol, List<SyntaxToken>> Build(
- // ISyntaxFactsService service,
- SemanticModel semanticModel,
- SyntaxNode root,
- TextSpan span,
- CancellationToken cancellationToken)
- {
- //Contract.ThrowIfNull(semanticModel);
-// Contract.ThrowIfNull(service);
- //Contract.ThrowIfNull(root);
-
- var builder = new SymbolMapBuilder(/*service, */semanticModel, span, cancellationToken);
- builder.Visit(root);
-
- return builder._symbolMap;
- }
-
- private SymbolMapBuilder(
- // ISyntaxFactsService service,
- SemanticModel semanticModel,
- TextSpan span,
- CancellationToken cancellationToken)
- : base(SyntaxWalkerDepth.Token)
- {
- _semanticModel = semanticModel;
- // _service = service;
- _span = span;
- _symbolMap = new Dictionary<ISymbol, List<SyntaxToken>>();
- _cancellationToken = cancellationToken;
- }
-
- protected override void VisitToken(SyntaxToken token)
- {
- if (token.IsMissing ||
- token.Width() <= 0 ||
- !token.IsIdentifier() ||
- !_span.Contains(token.Span) ||
- token.Parent.IsNamedParameter())
- {
- return;
- }
-
- var symbolInfo = _semanticModel.GetSymbolInfo(token, _cancellationToken);
- foreach (var sym in symbolInfo.GetAllSymbols())
- {
- // add binding result to map
- var list = _symbolMap.GetOrAdd(sym, _ => new List<SyntaxToken>());
- list.Add(token);
- }
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.Analyzer.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.Analyzer.cs
deleted file mode 100644
index c2826dae1d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.Analyzer.cs
+++ /dev/null
@@ -1,957 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- protected abstract partial class Analyzer
- {
- private readonly SemanticDocument _semanticDocument;
-
- protected readonly CancellationToken CancellationToken;
- protected readonly SelectionResult SelectionResult;
-
- protected Analyzer(SelectionResult selectionResult, CancellationToken cancellationToken)
- {
- //Contract.ThrowIfNull(selectionResult);
-
- this.SelectionResult = selectionResult;
- _semanticDocument = selectionResult.SemanticDocument;
- this.CancellationToken = cancellationToken;
- }
-
- /// <summary>
- /// convert text span to node range for the flow analysis API
- /// </summary>
- protected abstract Tuple<SyntaxNode, SyntaxNode> GetFlowAnalysisNodeRange();
-
- /// <summary>
- /// check whether selection contains return statement or not
- /// </summary>
- protected abstract bool ContainsReturnStatementInSelectedCode(IEnumerable<SyntaxNode> jumpOutOfRegionStatements);
-
- /// <summary>
- /// create VariableInfo type
- /// </summary>
- protected abstract VariableInfo CreateFromSymbol(Compilation compilation, ISymbol symbol, ITypeSymbol type, VariableStyle variableStyle, bool variableDeclared);
-
- /// <summary>
- /// among variables that will be used as parameters at the extracted method, check whether one of the parameter can be used as return
- /// </summary>
- protected abstract int GetIndexOfVariableInfoToUseAsReturnValue(IList<VariableInfo> variableInfo);
-
- /// <summary>
- /// get type of the range variable symbol
- /// </summary>
- protected abstract ITypeSymbol GetRangeVariableType(SemanticModel model, IRangeVariableSymbol symbol);
-
- /// <summary>
- /// check whether the selection is at the placed where read-only field is allowed to be extracted out
- /// </summary>
- /// <returns></returns>
- protected abstract bool ReadOnlyFieldAllowed();
-
- public async Task<AnalyzerResult> AnalyzeAsync()
- {
- // do data flow analysis
- var model = _semanticDocument.SemanticModel;
- var dataFlowAnalysisData = GetDataFlowAnalysisData(model);
-
- // build symbol map for the identifiers used inside of the selection
- var symbolMap = GetSymbolMap(model);
-
- // gather initial local or parameter variable info
- var variableInfoMap = GenerateVariableInfoMap(model, dataFlowAnalysisData, symbolMap);
-
- // check whether instance member is used inside of the selection
- var instanceMemberIsUsed = IsInstanceMemberUsedInSelectedCode(dataFlowAnalysisData);
-
- // check whether end of selection is reachable
- var endOfSelectionReachable = IsEndOfSelectionReachable(model);
-
- // collects various variable informations
- // extracted code contains return value
- var isInExpressionOrHasReturnStatement = IsInExpressionOrHasReturnStatement(model);
- var signatureTuple = GetSignatureInformation(model, dataFlowAnalysisData, variableInfoMap, isInExpressionOrHasReturnStatement);
-
- var parameters = signatureTuple.Item1;
- var returnType = signatureTuple.Item2;
- var variableToUseAsReturnValue = signatureTuple.Item3;
- var unsafeAddressTakenUsed = signatureTuple.Item4;
-
- var returnTypeTuple = AdjustReturnType(model, returnType);
-
- returnType = returnTypeTuple.Item1;
- bool returnTypeHasAnonymousType = returnTypeTuple.Item2;
- bool awaitTaskReturn = returnTypeTuple.Item3;
-
- // create new document
- var newDocument = await CreateDocumentWithAnnotationsAsync(_semanticDocument, parameters, CancellationToken).ConfigureAwait(false);
-
- // collect method type variable used in selected code
- var sortedMap = new SortedDictionary<int, ITypeParameterSymbol>();
- var typeParametersInConstraintList = GetMethodTypeParametersInConstraintList(model, variableInfoMap, symbolMap, sortedMap);
- var typeParametersInDeclaration = GetMethodTypeParametersInDeclaration(returnType, sortedMap);
-
- // check various error cases
- var operationStatus = GetOperationStatus(model, symbolMap, parameters, unsafeAddressTakenUsed, returnTypeHasAnonymousType);
-
- return new AnalyzerResult(
- newDocument,
- typeParametersInDeclaration, typeParametersInConstraintList,
- parameters, variableToUseAsReturnValue, returnType, awaitTaskReturn,
- instanceMemberIsUsed, endOfSelectionReachable, operationStatus);
- }
-
- private Tuple<ITypeSymbol, bool, bool> AdjustReturnType(SemanticModel model, ITypeSymbol returnType)
- {
- // check whether return type contains anonymous type and if it does, fix it up by making it object
- var returnTypeHasAnonymousType = returnType.ContainsAnonymousType();
- returnType = returnTypeHasAnonymousType ? returnType.RemoveAnonymousTypes(model.Compilation) : returnType;
-
- // if selection contains await which is not under async lambda or anonymous delegate,
- // change return type to be wrapped in Task
- var shouldPutAsyncModifier = this.SelectionResult.ShouldPutAsyncModifier();
- if (shouldPutAsyncModifier)
- {
- bool awaitTaskReturn;
- WrapReturnTypeInTask(model, ref returnType, out awaitTaskReturn);
-
- return Tuple.Create(returnType, returnTypeHasAnonymousType, awaitTaskReturn);
- }
-
- // unwrap task if needed
- UnwrapTaskIfNeeded(model, ref returnType);
- return Tuple.Create(returnType, returnTypeHasAnonymousType, false);
- }
-
- private void UnwrapTaskIfNeeded(SemanticModel model, ref ITypeSymbol returnType)
- {
- // nothing to unwrap
- if (!this.SelectionResult.ContainingScopeHasAsyncKeyword() ||
- !this.ContainsReturnStatementInSelectedCode(model))
- {
- return;
- }
-
- var originalDefinition = returnType.OriginalDefinition;
-
- // see whether it needs to be unwrapped
- var taskType = model.Compilation.TaskType();
- if (originalDefinition.Equals(taskType))
- {
- returnType = model.Compilation.GetSpecialType(SpecialType.System_Void);
- return;
- }
-
- var genericTaskType = model.Compilation.TaskOfTType();
- if (originalDefinition.Equals(genericTaskType))
- {
- returnType = ((INamedTypeSymbol)returnType).TypeArguments[0];
- return;
- }
-
- // nothing to unwrap
- return;
- }
-
- private void WrapReturnTypeInTask(SemanticModel model, ref ITypeSymbol returnType, out bool awaitTaskReturn)
- {
- awaitTaskReturn = false;
-
- var genericTaskType = model.Compilation.TaskOfTType();
- var taskType = model.Compilation.TaskType();
-
- if (returnType.Equals(model.Compilation.GetSpecialType(SpecialType.System_Void)))
- {
- // convert void to Task type
- awaitTaskReturn = true;
- returnType = taskType;
- return;
- }
-
- if (this.SelectionResult.SelectionInExpression)
- {
- returnType = genericTaskType.Construct(returnType);
- return;
- }
-
- if (ContainsReturnStatementInSelectedCode(model))
- {
- // check whether we will use return type as it is or not.
- awaitTaskReturn = returnType.Equals(taskType);
- return;
- }
-
- // okay, wrap the return type in Task<T>
- returnType = genericTaskType.Construct(returnType);
- }
-
- private Tuple<IList<VariableInfo>, ITypeSymbol, VariableInfo, bool> GetSignatureInformation(
- SemanticModel model,
- DataFlowAnalysis dataFlowAnalysisData,
- IDictionary<ISymbol, VariableInfo> variableInfoMap,
- bool isInExpressionOrHasReturnStatement)
- {
- if (isInExpressionOrHasReturnStatement)
- {
- // check whether current selection contains return statement
- var parameters = GetMethodParameters(variableInfoMap.Values);
- var returnType = this.SelectionResult.GetContainingScopeType();
- if (returnType == null)
- {
- returnType = model.Compilation.GetSpecialType(SpecialType.System_Object);
- }
-
- var unsafeAddressTakenUsed = ContainsVariableUnsafeAddressTaken(dataFlowAnalysisData, variableInfoMap.Keys);
- return Tuple.Create(parameters, returnType, default(VariableInfo), unsafeAddressTakenUsed);
- }
- else
- {
- // no return statement
- var parameters = MarkVariableInfoToUseAsReturnValueIfPossible(GetMethodParameters(variableInfoMap.Values));
- var variableToUseAsReturnValue = parameters.FirstOrDefault(v => v.UseAsReturnValue);
- var returnType = default(ITypeSymbol);
- if (variableToUseAsReturnValue != null)
- {
- returnType = variableToUseAsReturnValue.GetVariableType(_semanticDocument);
- }
- else
- {
- returnType = model.Compilation.GetSpecialType(SpecialType.System_Void);
- }
-
- var unsafeAddressTakenUsed = ContainsVariableUnsafeAddressTaken(dataFlowAnalysisData, variableInfoMap.Keys);
- return Tuple.Create(parameters, returnType, variableToUseAsReturnValue, unsafeAddressTakenUsed);
- }
- }
-
- private bool IsInExpressionOrHasReturnStatement(SemanticModel model)
- {
- var isInExpressionOrHasReturnStatement = this.SelectionResult.SelectionInExpression;
- if (!isInExpressionOrHasReturnStatement)
- {
- var containsReturnStatement = ContainsReturnStatementInSelectedCode(model);
- isInExpressionOrHasReturnStatement |= containsReturnStatement;
- }
-
- return isInExpressionOrHasReturnStatement;
- }
-
- private OperationStatus GetOperationStatus(
- SemanticModel model, Dictionary<ISymbol, List<SyntaxToken>> symbolMap, IList<VariableInfo> parameters,
- bool unsafeAddressTakenUsed, bool returnTypeHasAnonymousType)
- {
- var readonlyFieldStatus = CheckReadOnlyFields(model, symbolMap);
-
- var namesWithAnonymousTypes = parameters.Where(v => v.OriginalTypeHadAnonymousTypeOrDelegate).Select(v => v.Name ?? string.Empty);
- if (returnTypeHasAnonymousType)
- {
- namesWithAnonymousTypes = namesWithAnonymousTypes.Concat("return type");
- }
-
- var anonymousTypeStatus = namesWithAnonymousTypes.Any() ?
- new OperationStatus(OperationStatusFlag.BestEffort, string.Format("FeaturesResources.ContainsAnonymousType", string.Join(", ", namesWithAnonymousTypes))) :
- OperationStatus.Succeeded;
-
- var unsafeAddressStatus = unsafeAddressTakenUsed ? OperationStatus.UnsafeAddressTaken : OperationStatus.Succeeded;
-
- var asyncRefOutParameterStatue = CheckAsyncMethodRefOutParameters(parameters);
-
- return readonlyFieldStatus.With(anonymousTypeStatus).With(unsafeAddressStatus).With(asyncRefOutParameterStatue);
- }
-
- private OperationStatus CheckAsyncMethodRefOutParameters(IList<VariableInfo> parameters)
- {
- if (this.SelectionResult.ShouldPutAsyncModifier())
- {
- var names = parameters.Where(v => !v.UseAsReturnValue && (v.ParameterModifier == ParameterBehavior.Out || v.ParameterModifier == ParameterBehavior.Ref))
- .Select(p => p.Name ?? string.Empty);
-
- if (names.Any())
- {
- return new OperationStatus(OperationStatusFlag.BestEffort, string.Format("FeaturesResources.AsyncMethodWithRefOutParameters", string.Join(", ", names)));
- }
- }
-
- return OperationStatus.Succeeded;
- }
-
- private Task<SemanticDocument> CreateDocumentWithAnnotationsAsync(SemanticDocument document, IList<VariableInfo> variables, CancellationToken cancellationToken)
- {
- var annotations = new List<Tuple<SyntaxToken, SyntaxAnnotation>>(variables.Count);
- variables.Do(v => v.AddIdentifierTokenAnnotationPair(annotations, cancellationToken));
-
- if (annotations.Count == 0)
- {
- return Task.FromResult(document);
- }
-
- return document.WithSyntaxRootAsync(document.Root.AddAnnotations(annotations), cancellationToken);
- }
-
- private Dictionary<ISymbol, List<SyntaxToken>> GetSymbolMap(SemanticModel model)
- {
- var context = this.SelectionResult.GetContainingScope();
- var symbolMap = SymbolMapBuilder.Build(model, context, this.SelectionResult.FinalSpan, CancellationToken);
-
- return symbolMap;
- }
-
- private bool ContainsVariableUnsafeAddressTaken(DataFlowAnalysis dataFlowAnalysisData, IEnumerable<ISymbol> symbols)
- {
- // check whether the selection contains "&" over a symbol exist
- var map = new HashSet<ISymbol>(dataFlowAnalysisData.UnsafeAddressTaken);
- return symbols.Any(s => map.Contains(s));
- }
-
- private DataFlowAnalysis GetDataFlowAnalysisData(SemanticModel model)
- {
- if (this.SelectionResult.SelectionInExpression)
- {
- return model.AnalyzeDataFlow(this.SelectionResult.GetContainingScope());
- }
-
- var pair = GetFlowAnalysisNodeRange();
- return model.AnalyzeDataFlow(pair.Item1, pair.Item2);
- }
-
- private bool IsEndOfSelectionReachable(SemanticModel model)
- {
- if (this.SelectionResult.SelectionInExpression)
- {
- return true;
- }
-
- var pair = GetFlowAnalysisNodeRange();
- var analysis = model.AnalyzeControlFlow(pair.Item1, pair.Item2);
- return analysis.EndPointIsReachable;
- }
-
- private IList<VariableInfo> MarkVariableInfoToUseAsReturnValueIfPossible(IList<VariableInfo> variableInfo)
- {
- var variableToUseAsReturnValueIndex = GetIndexOfVariableInfoToUseAsReturnValue(variableInfo);
- if (variableToUseAsReturnValueIndex >= 0)
- {
- variableInfo[variableToUseAsReturnValueIndex] = VariableInfo.CreateReturnValue(variableInfo[variableToUseAsReturnValueIndex]);
- }
-
- return variableInfo;
- }
-
- private IList<VariableInfo> GetMethodParameters(ICollection<VariableInfo> variableInfo)
- {
- var list = new List<VariableInfo>(variableInfo);
-
- list.Sort(VariableInfo.Compare);
-
- return list;
- }
-
- private IDictionary<ISymbol, VariableInfo> GenerateVariableInfoMap(
- SemanticModel model, DataFlowAnalysis dataFlowAnalysisData, Dictionary<ISymbol, List<SyntaxToken>> symbolMap)
- {
-// Contract.ThrowIfNull(model);
-// Contract.ThrowIfNull(dataFlowAnalysisData);
-
- var variableInfoMap = new Dictionary<ISymbol, VariableInfo>();
-
- // create map of each data
- var capturedMap = new HashSet<ISymbol>(dataFlowAnalysisData.Captured);
- var dataFlowInMap = new HashSet<ISymbol>(dataFlowAnalysisData.DataFlowsIn);
- var dataFlowOutMap = new HashSet<ISymbol>(dataFlowAnalysisData.DataFlowsOut);
- var alwaysAssignedMap = new HashSet<ISymbol>(dataFlowAnalysisData.AlwaysAssigned);
- var variableDeclaredMap = new HashSet<ISymbol>(dataFlowAnalysisData.VariablesDeclared);
- var readInsideMap = new HashSet<ISymbol>(dataFlowAnalysisData.ReadInside);
- var writtenInsideMap = new HashSet<ISymbol>(dataFlowAnalysisData.WrittenInside);
- var readOutsideMap = new HashSet<ISymbol>(dataFlowAnalysisData.ReadOutside);
- var writtenOutsideMap = new HashSet<ISymbol>(dataFlowAnalysisData.WrittenOutside);
- var unsafeAddressTakenMap = new HashSet<ISymbol>(dataFlowAnalysisData.UnsafeAddressTaken);
-
- // gather all meaningful symbols for the span.
- var candidates = new HashSet<ISymbol>(readInsideMap);
- candidates.UnionWith(writtenInsideMap);
- candidates.UnionWith(variableDeclaredMap);
-
- foreach (var symbol in candidates)
- {
- if (IsThisParameter(symbol) ||
- IsInteractiveSynthesizedParameter(symbol))
- {
- continue;
- }
-
- var captured = capturedMap.Contains(symbol);
- var dataFlowIn = dataFlowInMap.Contains(symbol);
- var dataFlowOut = dataFlowOutMap.Contains(symbol);
- var alwaysAssigned = alwaysAssignedMap.Contains(symbol);
- var variableDeclared = variableDeclaredMap.Contains(symbol);
- var readInside = readInsideMap.Contains(symbol);
- var writtenInside = writtenInsideMap.Contains(symbol);
- var readOutside = readOutsideMap.Contains(symbol);
- var writtenOutside = writtenOutsideMap.Contains(symbol);
- var unsafeAddressTaken = unsafeAddressTakenMap.Contains(symbol);
-
- // if it is static local, make sure it is not defined inside
- if (symbol.IsStatic)
- {
- dataFlowIn = dataFlowIn && !variableDeclared;
- }
-
- // make sure readoutside is true when dataflowout is true (bug #3790)
- // when a variable is only used inside of loop, a situation where dataflowout == true and readOutside == false
- // can happen. but for extract method's point of view, this is not an information that would affect output.
- // so, here we adjust flags to follow predefined assumption.
- readOutside = readOutside || dataFlowOut;
-
- // make sure data flow out is true when declared inside/written inside/read outside/not written outside are true (bug #6277)
- dataFlowOut = dataFlowOut || (variableDeclared && writtenInside && readOutside && !writtenOutside);
-
- // variable that is declared inside but never referenced outside. just ignore it and move to next one.
- if (variableDeclared && !dataFlowOut && !readOutside && !writtenOutside)
- {
- continue;
- }
-
- // parameter defined inside of the selection (such as lambda parameter) will be ignored (bug # 10964)
- if (symbol is IParameterSymbol && variableDeclared)
- {
- continue;
- }
-
- var type = GetSymbolType(model, symbol);
- if (type == null)
- {
- continue;
- }
-
- var variableStyle = GetVariableStyle(symbolMap, symbol, model, type,
- captured, dataFlowIn, dataFlowOut, alwaysAssigned, variableDeclared,
- readInside, writtenInside, readOutside, writtenOutside, unsafeAddressTaken);
-
- AddVariableToMap(variableInfoMap, symbol, CreateFromSymbol(model.Compilation, symbol, type, variableStyle, variableDeclared));
- }
-
- return variableInfoMap;
- }
-
- private void AddVariableToMap(IDictionary<ISymbol, VariableInfo> variableInfoMap, ISymbol localOrParameter, VariableInfo variableInfo)
- {
- variableInfoMap.Add(localOrParameter, variableInfo);
- }
-
- private VariableStyle GetVariableStyle(
- Dictionary<ISymbol, List<SyntaxToken>> symbolMap,
- ISymbol symbol,
- SemanticModel model,
- ITypeSymbol type,
- bool captured,
- bool dataFlowIn,
- bool dataFlowOut,
- bool alwaysAssigned,
- bool variableDeclared,
- bool readInside,
- bool writtenInside,
- bool readOutside,
- bool writtenOutside,
- bool unsafeAddressTaken)
- {
-// Contract.ThrowIfNull(model);
-// Contract.ThrowIfNull(type);
-
- var style = ExtractMethodMatrix.GetVariableStyle(captured, dataFlowIn, dataFlowOut, alwaysAssigned, variableDeclared,
- readInside, writtenInside, readOutside, writtenOutside, unsafeAddressTaken);
-
- if (SelectionContainsOnlyIdentifierWithSameType(type))
- {
- return style;
- }
-
- if (UserDefinedValueType(model.Compilation, type) && !this.SelectionResult.DontPutOutOrRefOnStruct)
- {
- return AlwaysReturn(style);
- }
-
- // for captured variable, never try to move the decl into extracted method
- if (captured && (style == VariableStyle.MoveIn))
- {
- return VariableStyle.Out;
- }
-
- // check special value type cases
- if (type.IsValueType && !IsWrittenInsideForFrameworkValueType(symbolMap, model, symbol, writtenInside))
- {
- return style;
- }
-
- // don't blindly always return. make sure there is a write inside of the selection
- if (this.SelectionResult.AllowMovingDeclaration || !writtenInside)
- {
- return style;
- }
-
- return AlwaysReturn(style);
- }
-
- private bool IsWrittenInsideForFrameworkValueType(
- Dictionary<ISymbol, List<SyntaxToken>> symbolMap, SemanticModel model, ISymbol symbol, bool writtenInside)
- {
- List<SyntaxToken> tokens;
- if (!symbolMap.TryGetValue(symbol, out tokens))
- {
- return writtenInside;
- }
-
- // this relies on the fact that our IsWrittenTo only cares about syntax to figure out whether
- // something is written to or not. but not semantic.
- // we probably need to move the API to syntaxFact service not semanticFact.
- //
- // if one wants to get result that also considers semantic, he should use data control flow analysis API.
- return tokens.Any(t => t.Parent is ExpressionSyntax && ((ExpressionSyntax)t.Parent).IsWrittenTo());
- }
-
- private bool SelectionContainsOnlyIdentifierWithSameType(ITypeSymbol type)
- {
- if (!this.SelectionResult.SelectionInExpression)
- {
- return false;
- }
-
- var firstToken = this.SelectionResult.GetFirstTokenInSelection();
- var lastToken = this.SelectionResult.GetLastTokenInSelection();
-
- if (!firstToken.Equals(lastToken))
- {
- return false;
- }
-
- return type.Equals(this.SelectionResult.GetContainingScopeType());
- }
-
- private bool UserDefinedValueType(Compilation compilation, ITypeSymbol type)
- {
- if (!type.IsValueType || type.IsPointerType() || type.IsEnumType())
- {
- return false;
- }
-
- return type.OriginalDefinition.SpecialType == SpecialType.None && !WellKnownFrameworkValueType(compilation, type);
- }
-
- private bool WellKnownFrameworkValueType(Compilation compilation, ITypeSymbol type)
- {
- if (!type.IsValueType)
- {
- return false;
- }
-
- var cancellationTokenType = compilation.GetTypeByMetadataName("System.Threading.CancellationToken");
- if (cancellationTokenType != null && cancellationTokenType.Equals(type))
- {
- return true;
- }
-
- return false;
- }
-
- private ITypeSymbol GetSymbolType(SemanticModel model, ISymbol symbol)
- {
- var local = symbol as ILocalSymbol;
- if (local != null)
- {
- return local.Type;
- }
-
- var parameter = symbol as IParameterSymbol;
- if (parameter != null)
- {
- return parameter.Type;
- }
-
- var rangeVariable = symbol as IRangeVariableSymbol;
- if (rangeVariable != null)
- {
- return GetRangeVariableType(model, rangeVariable);
- }
-
- return null;
- }
-
- protected VariableStyle AlwaysReturn(VariableStyle style)
- {
- if (style == VariableStyle.InputOnly)
- {
- return VariableStyle.Ref;
- }
-
- if (style == VariableStyle.MoveIn)
- {
- return VariableStyle.Out;
- }
-
- if (style == VariableStyle.SplitIn)
- {
- return VariableStyle.Out;
- }
-
- if (style == VariableStyle.SplitOut)
- {
- return VariableStyle.OutWithMoveOut;
- }
-
- return style;
- }
-
- private bool IsParameterUsedOutside(ISymbol localOrParameter)
- {
- var parameter = localOrParameter as IParameterSymbol;
- if (parameter == null)
- {
- return false;
- }
-
- return parameter.RefKind != RefKind.None;
- }
-
- private bool IsParameterAssigned(ISymbol localOrParameter)
- {
- // hack for now.
- var parameter = localOrParameter as IParameterSymbol;
- if (parameter == null)
- {
- return false;
- }
-
- return parameter.RefKind != RefKind.Out;
- }
-
- private bool IsThisParameter(ISymbol localOrParameter)
- {
- var parameter = localOrParameter as IParameterSymbol;
- if (parameter == null)
- {
- return false;
- }
-
- return parameter.IsThis;
- }
-
- private bool IsInteractiveSynthesizedParameter(ISymbol localOrParameter)
- {
- var parameter = localOrParameter as IParameterSymbol;
- if (parameter == null)
- {
- return false;
- }
-
- return parameter.IsImplicitlyDeclared &&
- parameter.ContainingAssembly.IsInteractive &&
- parameter.ContainingSymbol != null &&
- parameter.ContainingSymbol.ContainingType != null &&
- parameter.ContainingSymbol.ContainingType.IsScriptClass;
- }
-
- private bool ContainsReturnStatementInSelectedCode(SemanticModel model)
- {
- //Contract.ThrowIfTrue(this.SelectionResult.SelectionInExpression);
-
- var pair = GetFlowAnalysisNodeRange();
- var controlFlowAnalysisData = model.AnalyzeControlFlow(pair.Item1, pair.Item2);
-
- return ContainsReturnStatementInSelectedCode(controlFlowAnalysisData.ExitPoints);
- }
-
- private void AddTypeParametersToMap(IEnumerable<ITypeParameterSymbol> typeParameters, IDictionary<int, ITypeParameterSymbol> sortedMap)
- {
- foreach (var typeParameter in typeParameters)
- {
- AddTypeParameterToMap(typeParameter, sortedMap);
- }
- }
-
- private void AddTypeParameterToMap(ITypeParameterSymbol typeParameter, IDictionary<int, ITypeParameterSymbol> sortedMap)
- {
- if (typeParameter == null ||
- typeParameter.DeclaringMethod == null ||
- sortedMap.ContainsKey(typeParameter.Ordinal))
- {
- return;
- }
-
- sortedMap[typeParameter.Ordinal] = typeParameter;
- }
-
- private void AppendMethodTypeVariableFromDataFlowAnalysis(
- SemanticModel model,
- IDictionary<ISymbol, VariableInfo> variableInfoMap,
- IDictionary<int, ITypeParameterSymbol> sortedMap)
- {
- foreach (var symbol in variableInfoMap.Keys)
- {
- var parameter = symbol as IParameterSymbol;
- if (parameter != null)
- {
- AddTypeParametersToMap(TypeParameterCollector.Collect(parameter.Type), sortedMap);
- continue;
- }
-
- var local = symbol as ILocalSymbol;
- if (local != null)
- {
- AddTypeParametersToMap(TypeParameterCollector.Collect(local.Type), sortedMap);
- continue;
- }
-
- var rangeVariable = symbol as IRangeVariableSymbol;
- if (rangeVariable != null)
- {
- var type = GetRangeVariableType(model, rangeVariable);
- AddTypeParametersToMap(TypeParameterCollector.Collect(type), sortedMap);
- continue;
- }
-
- //Contract.Fail(FeaturesResources.UnknownSymbolKind);
- }
- }
-
- private void AppendMethodTypeParameterFromConstraint(SortedDictionary<int, ITypeParameterSymbol> sortedMap)
- {
- var typeParametersInConstraint = new List<ITypeParameterSymbol>();
-
- // collect all type parameter appears in constraint
- foreach (var typeParameter in sortedMap.Values)
- {
- var constraintTypes = typeParameter.ConstraintTypes;
- if (constraintTypes.IsDefaultOrEmpty)
- {
- continue;
- }
-
- foreach (var type in constraintTypes)
- {
- // constraint itself is type parameter
- typeParametersInConstraint.AddRange(TypeParameterCollector.Collect(type));
- }
- }
-
- // pick up only valid type parameter and add them to the map
- foreach (var typeParameter in typeParametersInConstraint)
- {
- AddTypeParameterToMap(typeParameter, sortedMap);
- }
- }
-
- private void AppendMethodTypeParameterUsedDirectly(IDictionary<ISymbol, List<SyntaxToken>> symbolMap, IDictionary<int, ITypeParameterSymbol> sortedMap)
- {
- foreach (var pair in symbolMap.Where(p => p.Key.Kind == SymbolKind.TypeParameter))
- {
- var typeParameter = pair.Key as ITypeParameterSymbol;
- if (typeParameter.DeclaringMethod == null ||
- sortedMap.ContainsKey(typeParameter.Ordinal))
- {
- continue;
- }
-
- sortedMap[typeParameter.Ordinal] = typeParameter;
- }
- }
-
- private IEnumerable<ITypeParameterSymbol> GetMethodTypeParametersInConstraintList(
- SemanticModel model,
- IDictionary<ISymbol, VariableInfo> variableInfoMap,
- IDictionary<ISymbol, List<SyntaxToken>> symbolMap,
- SortedDictionary<int, ITypeParameterSymbol> sortedMap)
- {
- // find starting points
- AppendMethodTypeVariableFromDataFlowAnalysis(model, variableInfoMap, sortedMap);
- AppendMethodTypeParameterUsedDirectly(symbolMap, sortedMap);
-
- // recursively dive into constraints to find all constraints needed
- AppendTypeParametersInConstraintsUsedByConstructedTypeWithItsOwnConstraints(sortedMap);
-
- return sortedMap.Values.ToList();
- }
-
- private void AppendTypeParametersInConstraintsUsedByConstructedTypeWithItsOwnConstraints(SortedDictionary<int, ITypeParameterSymbol> sortedMap)
- {
- var visited = new HashSet<ITypeSymbol>();
- var candidates = SpecializedCollections.EmptyEnumerable<ITypeParameterSymbol>();
-
- // collect all type parameter appears in constraint
- foreach (var typeParameter in sortedMap.Values)
- {
- var constraintTypes = typeParameter.ConstraintTypes;
- if (constraintTypes.IsDefaultOrEmpty)
- {
- continue;
- }
-
- foreach (var type in constraintTypes)
- {
- candidates = candidates.Concat(AppendTypeParametersInConstraintsUsedByConstructedTypeWithItsOwnConstraints(type, visited));
- }
- }
-
- // pick up only valid type parameter and add them to the map
- foreach (var typeParameter in candidates)
- {
- AddTypeParameterToMap(typeParameter, sortedMap);
- }
- }
-
- private IEnumerable<ITypeParameterSymbol> AppendTypeParametersInConstraintsUsedByConstructedTypeWithItsOwnConstraints(
- ITypeSymbol type, HashSet<ITypeSymbol> visited)
- {
- if (visited.Contains(type))
- {
- return SpecializedCollections.EmptyEnumerable<ITypeParameterSymbol>();
- }
-
- visited.Add(type);
-
- if (type.OriginalDefinition.Equals(type))
- {
- return SpecializedCollections.EmptyEnumerable<ITypeParameterSymbol>();
- }
-
- var constructedType = type as INamedTypeSymbol;
- if (constructedType == null)
- {
- return SpecializedCollections.EmptyEnumerable<ITypeParameterSymbol>();
- }
-
- var parameters = constructedType.GetAllTypeParameters().ToList();
- var arguments = constructedType.GetAllTypeArguments().ToList();
-
- //Contract.ThrowIfFalse(parameters.Count == arguments.Count);
-
- var typeParameters = new List<ITypeParameterSymbol>();
- for (int i = 0; i < parameters.Count; i++)
- {
- var parameter = parameters[i];
-
- var argument = arguments[i] as ITypeParameterSymbol;
- if (argument != null)
- {
- // no constraint, nothing to do
- if (!parameter.HasConstructorConstraint &&
- !parameter.HasReferenceTypeConstraint &&
- !parameter.HasValueTypeConstraint &&
- parameter.ConstraintTypes.IsDefaultOrEmpty)
- {
- continue;
- }
-
- typeParameters.Add(argument);
- continue;
- }
-
- var candidate = arguments[i] as INamedTypeSymbol;
- if (candidate == null)
- {
- continue;
- }
-
- typeParameters.AddRange(AppendTypeParametersInConstraintsUsedByConstructedTypeWithItsOwnConstraints(candidate, visited));
- }
-
- return typeParameters;
- }
-
- private IEnumerable<ITypeParameterSymbol> GetMethodTypeParametersInDeclaration(ITypeSymbol returnType, SortedDictionary<int, ITypeParameterSymbol> sortedMap)
- {
- // add return type to the map
- AddTypeParametersToMap(TypeParameterCollector.Collect(returnType), sortedMap);
-
- AppendMethodTypeParameterFromConstraint(sortedMap);
-
- return sortedMap.Values.ToList();
- }
-
- private OperationStatus CheckReadOnlyFields(SemanticModel semanticModel, Dictionary<ISymbol, List<SyntaxToken>> symbolMap)
- {
- if (ReadOnlyFieldAllowed())
- {
- return OperationStatus.Succeeded;
- }
-
- List<string> names = null;
-
- foreach (var pair in symbolMap.Where(p => p.Key.Kind == SymbolKind.Field))
- {
- var field = (IFieldSymbol)pair.Key;
- if (!field.IsReadOnly)
- {
- continue;
- }
-
- var tokens = pair.Value;
- if (tokens.All(t => !((ExpressionSyntax)t.Parent).IsWrittenTo()))
- {
- continue;
- }
-
- names = names ?? new List<string>();
- names.Add(field.Name ?? string.Empty);
- }
-
- if (names != null)
- {
- return new OperationStatus(OperationStatusFlag.BestEffort, string.Format("FeaturesResources.AssingingToReadonlyFields", string.Join(", ", names)));
- }
-
- return OperationStatus.Succeeded;
- }
-
- private bool IsInstanceMemberUsedInSelectedCode(DataFlowAnalysis dataFlowAnalysisData)
- {
- //Contract.ThrowIfNull(dataFlowAnalysisData);
-
- // "this" can be used as a lvalue in a struct, check WrittenInside as well
- return dataFlowAnalysisData.ReadInside.Any(s => IsThisParameter(s)) ||
- dataFlowAnalysisData.WrittenInside.Any(s => IsThisParameter(s));
- }
-
- protected VariableInfo CreateFromSymbolCommon<T>(
- Compilation compilation,
- ISymbol symbol,
- ITypeSymbol type,
- VariableStyle style,
- HashSet<int> nonNoisySyntaxKindSet) where T : SyntaxNode
- {
- var local = symbol as ILocalSymbol;
- if (local != null)
- {
- return new VariableInfo(
- new LocalVariableSymbol<T>(compilation, local, type, nonNoisySyntaxKindSet),
- style);
- }
-
- var parameter = symbol as IParameterSymbol;
- if (parameter != null)
- {
- return new VariableInfo(new ParameterVariableSymbol(compilation, parameter, type), style);
- }
-
- var rangeVariable = symbol as IRangeVariableSymbol;
- if (rangeVariable != null)
- {
- return new VariableInfo(new QueryVariableSymbol(compilation, rangeVariable, type), style);
- }
-
- return null;//Contract.FailWithReturn<VariableInfo>(FeaturesResources.Unknown);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.AnalyzerResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.AnalyzerResult.cs
deleted file mode 100644
index ea3e5af836..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.AnalyzerResult.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Threading;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- protected class AnalyzerResult
- {
- private readonly IList<ITypeParameterSymbol> _typeParametersInDeclaration;
- private readonly IList<ITypeParameterSymbol> _typeParametersInConstraintList;
- private readonly IList<VariableInfo> _variables;
- private readonly VariableInfo _variableToUseAsReturnValue;
-
- public AnalyzerResult(
- SemanticDocument document,
- IEnumerable<ITypeParameterSymbol> typeParametersInDeclaration,
- IEnumerable<ITypeParameterSymbol> typeParametersInConstraintList,
- IList<VariableInfo> variables,
- VariableInfo variableToUseAsReturnValue,
- ITypeSymbol returnType,
- bool awaitTaskReturn,
- bool instanceMemberIsUsed,
- bool endOfSelectionReachable,
- OperationStatus status)
- {
- var semanticModel = document.SemanticModel;
-
- this.UseInstanceMember = instanceMemberIsUsed;
- this.EndOfSelectionReachable = endOfSelectionReachable;
- this.AwaitTaskReturn = awaitTaskReturn;
- this.SemanticDocument = document;
- _typeParametersInDeclaration = typeParametersInDeclaration.Select(s => semanticModel.ResolveType(s)).ToList();
- _typeParametersInConstraintList = typeParametersInConstraintList.Select(s => semanticModel.ResolveType(s)).ToList();
- _variables = variables;
- this.ReturnType = semanticModel.ResolveType(returnType);
- _variableToUseAsReturnValue = variableToUseAsReturnValue;
- this.Status = status;
- }
-
- public AnalyzerResult With(SemanticDocument document)
- {
- if (this.SemanticDocument == document)
- {
- return this;
- }
-
- return new AnalyzerResult(
- document,
- _typeParametersInDeclaration,
- _typeParametersInConstraintList,
- _variables,
- _variableToUseAsReturnValue,
- this.ReturnType,
- this.AwaitTaskReturn,
- this.UseInstanceMember,
- this.EndOfSelectionReachable,
- this.Status);
- }
-
- /// <summary>
- /// used to determine whether static can be used
- /// </summary>
- public bool UseInstanceMember { get; }
-
- /// <summary>
- /// used to determine whether "return" statement needs to be inserted
- /// </summary>
- public bool EndOfSelectionReachable { get; }
-
- /// <summary>
- /// document this result is based on
- /// </summary>
- public SemanticDocument SemanticDocument { get; }
-
- /// <summary>
- /// flag to show whether task return type is due to await
- /// </summary>
- public bool AwaitTaskReturn { get; }
-
- /// <summary>
- /// return type
- /// </summary>
- public ITypeSymbol ReturnType { get; }
-
- /// <summary>
- /// analyzer result operation status
- /// </summary>
- public OperationStatus Status { get; }
-
- public ReadOnlyCollection<ITypeParameterSymbol> MethodTypeParametersInDeclaration
- {
- get
- {
- return new ReadOnlyCollection<ITypeParameterSymbol>(_typeParametersInDeclaration);
- }
- }
-
- public ReadOnlyCollection<ITypeParameterSymbol> MethodTypeParametersInConstraintList
- {
- get
- {
- return new ReadOnlyCollection<ITypeParameterSymbol>(_typeParametersInConstraintList);
- }
- }
-
- public bool HasVariableToUseAsReturnValue
- {
- get
- {
- return _variableToUseAsReturnValue != null;
- }
- }
-
- public VariableInfo VariableToUseAsReturnValue
- {
- get
- {
- //Contract.ThrowIfNull(_variableToUseAsReturnValue);
- return _variableToUseAsReturnValue;
- }
- }
-
- public bool HasReturnType
- {
- get
- {
- return this.ReturnType.SpecialType != SpecialType.System_Void && !this.AwaitTaskReturn;
- }
- }
-
- public IEnumerable<VariableInfo> MethodParameters
- {
- get
- {
- return _variables.Where(v => v.UseAsParameter);
- }
- }
-
- public IEnumerable<VariableInfo> GetVariablesToSplitOrMoveIntoMethodDefinition(CancellationToken cancellationToken)
- {
- return _variables
- .Where(v => v.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.SplitIn ||
- v.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.MoveIn);
- }
-
- public IEnumerable<VariableInfo> GetVariablesToMoveIntoMethodDefinition(CancellationToken cancellationToken)
- {
- return _variables.Where(v => v.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.MoveIn);
- }
-
- public IEnumerable<VariableInfo> GetVariablesToMoveOutToCallSite(CancellationToken cancellationToken)
- {
- return _variables.Where(v => v.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.MoveOut);
- }
-
- public IEnumerable<VariableInfo> GetVariablesToMoveOutToCallSiteOrDelete(CancellationToken cancellationToken)
- {
- return _variables.Where(v => v.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.MoveOut ||
- v.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.Delete);
- }
-
- public IEnumerable<VariableInfo> GetVariablesToSplitOrMoveOutToCallSite(CancellationToken cancellationToken)
- {
- return _variables.Where(v => v.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.SplitOut ||
- v.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.MoveOut);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.CodeGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.CodeGenerator.cs
deleted file mode 100644
index 06a9faec87..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.CodeGenerator.cs
+++ /dev/null
@@ -1,316 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- protected abstract partial class CodeGenerator<TStatement, TExpression, TNodeUnderContainer>
- where TStatement : SyntaxNode
- where TExpression : SyntaxNode
- where TNodeUnderContainer : SyntaxNode
- {
- protected readonly SyntaxAnnotation MethodNameAnnotation;
- protected readonly SyntaxAnnotation MethodDefinitionAnnotation;
- protected readonly SyntaxAnnotation CallSiteAnnotation;
-
- protected readonly InsertionPoint InsertionPoint;
- protected readonly SemanticDocument SemanticDocument;
- protected readonly SelectionResult SelectionResult;
- protected readonly AnalyzerResult AnalyzerResult;
-
- protected CodeGenerator(InsertionPoint insertionPoint, SelectionResult selectionResult, AnalyzerResult analyzerResult)
- {
- //Contract.ThrowIfFalse(insertionPoint.SemanticDocument == analyzerResult.SemanticDocument);
-
- this.InsertionPoint = insertionPoint;
- this.SemanticDocument = insertionPoint.SemanticDocument;
-
- this.SelectionResult = selectionResult;
- this.AnalyzerResult = analyzerResult;
-
- this.MethodNameAnnotation = new SyntaxAnnotation();
- this.CallSiteAnnotation = new SyntaxAnnotation();
- this.MethodDefinitionAnnotation = MonoDevelop.Ide.TypeSystem.TypeSystemService.InsertionModeAnnotation;
- }
-
- #region method to be implemented in sub classes
-
- protected abstract SyntaxNode GetOutermostCallSiteContainerToProcess(CancellationToken cancellationToken);
- protected abstract Task<SyntaxNode> GenerateBodyForCallSiteContainerAsync(CancellationToken cancellationToken);
- protected abstract SyntaxNode GetPreviousMember(SemanticDocument document);
- protected abstract OperationStatus<IMethodSymbol> GenerateMethodDefinition(CancellationToken cancellationToken);
-
- protected abstract SyntaxToken CreateIdentifier(string name);
- protected abstract SyntaxToken CreateMethodName();
- protected abstract bool LastStatementOrHasReturnStatementInReturnableConstruct();
-
- protected abstract TNodeUnderContainer GetFirstStatementOrInitializerSelectedAtCallSite();
- protected abstract TNodeUnderContainer GetLastStatementOrInitializerSelectedAtCallSite();
- protected abstract Task<TNodeUnderContainer> GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(SyntaxAnnotation callsiteAnnotation, CancellationToken cancellationToken);
-
- protected abstract TExpression CreateCallSignature();
- protected abstract TStatement CreateDeclarationStatement(VariableInfo variable, CancellationToken cancellationToken, TExpression initialValue = null);
- protected abstract TStatement CreateAssignmentExpressionStatement(SyntaxToken identifier, TExpression rvalue);
- protected abstract TStatement CreateReturnStatement(string identifierName = null);
-
- protected abstract IEnumerable<TStatement> GetInitialStatementsForMethodDefinitions();
- #endregion
-
- public async Task<GeneratedCode> GenerateAsync(CancellationToken cancellationToken)
- {
- var root = this.SemanticDocument.Root;
-
- // should I check venus hidden position check here as well?
- root = root.ReplaceNode(this.GetOutermostCallSiteContainerToProcess(cancellationToken), await this.GenerateBodyForCallSiteContainerAsync(cancellationToken).ConfigureAwait(false));
- var callSiteDocument = await this.SemanticDocument.WithSyntaxRootAsync(root, cancellationToken).ConfigureAwait(false);
-
- var newCallSiteRoot = callSiteDocument.Root;
- var previousMemberNode = GetPreviousMember(callSiteDocument);
-
- // it is possible in a script file case where there is no previous member. in that case, insert new text into top level script
- var destination = (previousMemberNode.Parent == null) ? previousMemberNode : previousMemberNode.Parent;
-
- var codeGenerationService = new CSharpCodeGenerationService (this.SemanticDocument.Document.Project.Solution.Workspace.Services.GetLanguageServices (LanguageNames.CSharp));
- var result = this.GenerateMethodDefinition(cancellationToken);
- var newContainer = codeGenerationService.AddMethod(
- destination, result.Data,
- new CodeGenerationOptions(afterThisLocation: previousMemberNode.GetLocation(), generateDefaultAccessibility: false, generateMethodBodies: true),
- cancellationToken);
-
- var newDocument = callSiteDocument.Document.WithSyntaxRoot(newCallSiteRoot.ReplaceNode(destination, newContainer));
- newDocument = await Simplifier.ReduceAsync(newDocument, Simplifier.Annotation, null, cancellationToken).ConfigureAwait(false);
-
- var finalDocument = await SemanticDocument.CreateAsync(newDocument, cancellationToken).ConfigureAwait(false);
- var finalRoot = finalDocument.Root;
-
- var methodDefinition = finalRoot.GetAnnotatedNodesAndTokens(this.MethodDefinitionAnnotation).FirstOrDefault();
- if (!methodDefinition.IsNode || methodDefinition.AsNode() == null)
- {
- return await CreateGeneratedCodeAsync(
- result.Status.With(OperationStatus.FailedWithUnknownReason), finalDocument, cancellationToken).ConfigureAwait(false);
- }
-
- if (methodDefinition.SyntaxTree.IsHiddenPosition(methodDefinition.AsNode().SpanStart, cancellationToken) ||
- methodDefinition.SyntaxTree.IsHiddenPosition(methodDefinition.AsNode().Span.End, cancellationToken))
- {
- return await CreateGeneratedCodeAsync(
- result.Status.With(OperationStatus.OverlapsHiddenPosition), finalDocument, cancellationToken).ConfigureAwait(false);
- }
-
- return await CreateGeneratedCodeAsync(result.Status, finalDocument, cancellationToken).ConfigureAwait(false);
- }
-
- protected virtual Task<GeneratedCode> CreateGeneratedCodeAsync(OperationStatus status, SemanticDocument newDocument, CancellationToken cancellationToken)
- {
- return Task.FromResult(new GeneratedCode(
- status,
- newDocument,
- this.MethodNameAnnotation,
- this.CallSiteAnnotation,
- this.MethodDefinitionAnnotation));
- }
-
- protected VariableInfo GetOutermostVariableToMoveIntoMethodDefinition(CancellationToken cancellationToken)
- {
- var variables = new List<VariableInfo>(this.AnalyzerResult.GetVariablesToMoveIntoMethodDefinition(cancellationToken));
- if (variables.Count <= 0)
- {
- return null;
- }
-
- variables.Sort(VariableInfo.Compare);
- return variables[0];
- }
-
- protected IEnumerable<TStatement> AddReturnIfUnreachable(
- IEnumerable<TStatement> statements, CancellationToken cancellationToken)
- {
- if (this.AnalyzerResult.EndOfSelectionReachable)
- {
- return statements;
- }
-
- var type = this.SelectionResult.GetContainingScopeType();
- if (type != null && type.SpecialType != SpecialType.System_Void)
- {
- return statements;
- }
-
- // no return type + end of selection not reachable
- if (LastStatementOrHasReturnStatementInReturnableConstruct())
- {
- return statements;
- }
-
- return statements.Concat(CreateReturnStatement());
- }
-
- protected async Task<IEnumerable<TStatement>> AddInvocationAtCallSiteAsync(
- IEnumerable<TStatement> statements, CancellationToken cancellationToken)
- {
- if (this.AnalyzerResult.HasVariableToUseAsReturnValue)
- {
- return statements;
- }
-
- //Contract.ThrowIfTrue(this.AnalyzerResult.GetVariablesToSplitOrMoveOutToCallSite(cancellationToken).Any(v => v.UseAsReturnValue));
-
- // add invocation expression
- return statements.Concat(
- (TStatement)(SyntaxNode)await GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(this.CallSiteAnnotation, cancellationToken).ConfigureAwait(false));
- }
-
- protected IEnumerable<TStatement> AddAssignmentStatementToCallSite(
- IEnumerable<TStatement> statements,
- CancellationToken cancellationToken)
- {
- if (!this.AnalyzerResult.HasVariableToUseAsReturnValue)
- {
- return statements;
- }
-
- var variable = this.AnalyzerResult.VariableToUseAsReturnValue;
- if (variable.ReturnBehavior == ReturnBehavior.Initialization)
- {
- // there must be one decl behavior when there is "return value and initialize" variable
- //Contract.ThrowIfFalse(this.AnalyzerResult.GetVariablesToSplitOrMoveOutToCallSite(cancellationToken).Single(v => v.ReturnBehavior == ReturnBehavior.Initialization) != null);
-
- return statements.Concat(
- CreateDeclarationStatement(variable, cancellationToken, CreateCallSignature()).WithAdditionalAnnotations(this.CallSiteAnnotation));
- }
-
- //Contract.ThrowIfFalse(variable.ReturnBehavior == ReturnBehavior.Assignment);
- return statements.Concat(
- CreateAssignmentExpressionStatement(CreateIdentifier(variable.Name), CreateCallSignature()).WithAdditionalAnnotations(this.CallSiteAnnotation));
- }
-
- protected IEnumerable<TStatement> CreateDeclarationStatements(IEnumerable<VariableInfo> variables, CancellationToken cancellationToken)
- {
- var list = new List<TStatement>();
-
- foreach (var variable in variables)
- {
- list.Add(CreateDeclarationStatement(variable, cancellationToken));
- }
-
- return list;
- }
-
- protected IEnumerable<TStatement> AddSplitOrMoveDeclarationOutStatementsToCallSite(IEnumerable<TStatement> statements, CancellationToken cancellationToken)
- {
- var list = new List<TStatement>();
-
- foreach (var variable in this.AnalyzerResult.GetVariablesToSplitOrMoveOutToCallSite(cancellationToken))
- {
- if (variable.UseAsReturnValue)
- {
- continue;
- }
-
- list.Add(CreateDeclarationStatement(variable, cancellationToken));
- }
-
- return list;
- }
-
- protected IEnumerable<TStatement> AppendReturnStatementIfNeeded(IEnumerable<TStatement> statements)
- {
- if (!this.AnalyzerResult.HasVariableToUseAsReturnValue)
- {
- return statements;
- }
-
- var variableToUseAsReturnValue = this.AnalyzerResult.VariableToUseAsReturnValue;
-
- //Contract.ThrowIfFalse(variableToUseAsReturnValue.ReturnBehavior == ReturnBehavior.Assignment ||
- // variableToUseAsReturnValue.ReturnBehavior == ReturnBehavior.Initialization);
-
- return statements.Concat(CreateReturnStatement(this.AnalyzerResult.VariableToUseAsReturnValue.Name));
- }
-
- protected HashSet<SyntaxAnnotation> CreateVariableDeclarationToRemoveMap(
- IEnumerable<VariableInfo> variables, CancellationToken cancellationToken)
- {
- var annotations = new List<Tuple<SyntaxToken, SyntaxAnnotation>>();
-
- foreach (var variable in variables)
- {
-// Contract.ThrowIfFalse(variable.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.MoveOut ||
-// variable.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.MoveIn ||
-// variable.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.Delete);
-
- variable.AddIdentifierTokenAnnotationPair(annotations, cancellationToken);
- }
-
- return new HashSet<SyntaxAnnotation>(annotations.Select(t => t.Item2));
- }
-
- protected IList<ITypeParameterSymbol> CreateMethodTypeParameters(CancellationToken cancellationToken)
- {
- if (this.AnalyzerResult.MethodTypeParametersInDeclaration.Count == 0)
- {
- return SpecializedCollections.EmptyList<ITypeParameterSymbol>();
- }
-
- var set = new HashSet<ITypeParameterSymbol>(this.AnalyzerResult.MethodTypeParametersInConstraintList);
-
- var typeParameters = new List<ITypeParameterSymbol>();
- foreach (var parameter in this.AnalyzerResult.MethodTypeParametersInDeclaration)
- {
- if (parameter != null && set.Contains(parameter))
- {
- typeParameters.Add(parameter);
- continue;
- }
-
- typeParameters.Add(CodeGenerationSymbolFactory.CreateTypeParameter(
- parameter.GetAttributes(), parameter.Variance, parameter.Name, ImmutableArray.Create<ITypeSymbol>(),
- parameter.HasConstructorConstraint, parameter.HasReferenceTypeConstraint, parameter.HasValueTypeConstraint, parameter.Ordinal));
- }
-
- return typeParameters;
- }
-
- protected IList<IParameterSymbol> CreateMethodParameters()
- {
- var parameters = new List<IParameterSymbol>();
-
- foreach (var parameter in this.AnalyzerResult.MethodParameters)
- {
- var refKind = GetRefKind(parameter.ParameterModifier);
- var type = parameter.GetVariableType(this.SemanticDocument);
-
- parameters.Add(
- CodeGenerationSymbolFactory.CreateParameterSymbol(
- attributes: SpecializedCollections.EmptyList<AttributeData>(),
- refKind: refKind,
- isParams: false,
- type: type,
- name: parameter.Name));
- }
-
- return parameters;
- }
-
- private static RefKind GetRefKind(ParameterBehavior parameterBehavior)
- {
- return parameterBehavior == ParameterBehavior.Ref ? RefKind.Ref :
- parameterBehavior == ParameterBehavior.Out ? RefKind.Out : RefKind.None;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.GeneratedCode.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.GeneratedCode.cs
deleted file mode 100644
index 5590199a6a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.GeneratedCode.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- internal class GeneratedCode
- {
- public GeneratedCode(
- OperationStatus status,
- SemanticDocument document,
- SyntaxAnnotation methodNameAnnotation,
- SyntaxAnnotation callsiteAnnotation,
- SyntaxAnnotation methodDefinitionAnnotation)
- {
- //Contract.ThrowIfNull(document);
- //Contract.ThrowIfNull(methodNameAnnotation);
- //Contract.ThrowIfNull(callsiteAnnotation);
- //Contract.ThrowIfNull(methodDefinitionAnnotation);
-
- this.Status = status;
- this.SemanticDocument = document;
- this.MethodNameAnnotation = methodNameAnnotation;
- this.CallSiteAnnotation = callsiteAnnotation;
- this.MethodDefinitionAnnotation = methodDefinitionAnnotation;
- }
-
- public OperationStatus Status { get; }
- public SemanticDocument SemanticDocument { get; }
-
- public SyntaxAnnotation MethodNameAnnotation { get; }
- public SyntaxAnnotation CallSiteAnnotation { get; }
- public SyntaxAnnotation MethodDefinitionAnnotation { get; }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.TriviaResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.TriviaResult.cs
deleted file mode 100644
index 9bbd32c02b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.TriviaResult.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- protected abstract class TriviaResult
- {
- private readonly int _endOfLineKind;
- private readonly int _whitespaceKind;
-
- private readonly ITriviaSavedResult _result;
-
- public TriviaResult(SemanticDocument document, ITriviaSavedResult result, int endOfLineKind, int whitespaceKind)
- {
- this.SemanticDocument = document;
-
- _result = result;
- _endOfLineKind = endOfLineKind;
- _whitespaceKind = whitespaceKind;
- }
-
- protected abstract AnnotationResolver GetAnnotationResolver(SyntaxNode callsite, SyntaxNode methodDefinition);
- protected abstract TriviaResolver GetTriviaResolver(SyntaxNode methodDefinition);
-
- public SemanticDocument SemanticDocument { get; }
-
- public async Task<OperationStatus<SemanticDocument>> ApplyAsync(GeneratedCode generatedCode, CancellationToken cancellationToken)
- {
- var document = generatedCode.SemanticDocument;
- var root = document.Root;
-
- var callsiteAnnotation = generatedCode.CallSiteAnnotation;
- var methodDefinitionAnnotation = generatedCode.MethodDefinitionAnnotation;
-
- var callsite = root.GetAnnotatedNodesAndTokens(callsiteAnnotation).SingleOrDefault().AsNode();
- var method = root.GetAnnotatedNodesAndTokens(methodDefinitionAnnotation).SingleOrDefault().AsNode();
-
- var annotationResolver = GetAnnotationResolver(callsite, method);
- var triviaResolver = GetTriviaResolver(method);
- if (annotationResolver == null || triviaResolver == null)
- {
- // bug # 6644
- // this could happen in malformed code. return as it was.
- var status = new OperationStatus(OperationStatusFlag.None, "FeaturesResources.CantNotConstructFinalTree");
- return status.With(document);
- }
-
- return OperationStatus.Succeeded.With(
- await document.WithSyntaxRootAsync(_result.RestoreTrivia(root, annotationResolver, triviaResolver), cancellationToken).ConfigureAwait(false));
- }
-
- protected IEnumerable<SyntaxTrivia> FilterTriviaList(IEnumerable<SyntaxTrivia> list)
- {
- // has noisy token
- if (list.Any(t => t.RawKind != _endOfLineKind && t.RawKind != _whitespaceKind))
- {
- return RemoveLeadingElasticBeforeEndOfLine(list);
- }
-
- // whitespace only
- return MergeLineBreaks(list);
- }
-
- protected IEnumerable<SyntaxTrivia> RemoveBlankLines(IEnumerable<SyntaxTrivia> list)
- {
- // remove any blank line at the beginging
- var currentLine = new List<SyntaxTrivia>();
- var result = new List<SyntaxTrivia>();
-
- var seenFirstEndOfLine = false;
- int i = 0;
-
- foreach (var trivia in list)
- {
- i++;
-
- if (trivia.RawKind == _endOfLineKind)
- {
- if (seenFirstEndOfLine)
- {
- // empty line. remove it
- if (currentLine.All(t => t.RawKind == _endOfLineKind || t.RawKind == _whitespaceKind))
- {
- continue;
- }
-
- // non empty line after the first end of line.
- // return now
- return result.Concat(currentLine).Concat(list.Skip(i - 1));
- }
- else
- {
- seenFirstEndOfLine = true;
-
- result.AddRange(currentLine);
- result.Add(trivia);
- currentLine.Clear();
-
- continue;
- }
- }
-
- currentLine.Add(trivia);
- }
-
- return result.Concat(currentLine);
- }
-
- protected IEnumerable<SyntaxTrivia> RemoveLeadingElasticBeforeEndOfLine(IEnumerable<SyntaxTrivia> list)
- {
- var trivia = list.FirstOrDefault();
- if (!trivia.IsElastic())
- {
- return list;
- }
-
- var listWithoutHead = list.Skip(1);
- trivia = listWithoutHead.FirstOrDefault();
- if (trivia.RawKind == _endOfLineKind)
- {
- return listWithoutHead;
- }
-
- if (trivia.IsElastic())
- {
- return RemoveLeadingElasticBeforeEndOfLine(listWithoutHead);
- }
-
- return list;
- }
-
- protected IEnumerable<SyntaxTrivia> MergeLineBreaks(IEnumerable<SyntaxTrivia> list)
- {
- // this will make sure that it doesn't have more than two subsequent end of line
- // trivia without any noisy trivia
- var stack = new Stack<SyntaxTrivia>();
- int numberOfEndOfLinesWithoutAnyNoisyTrivia = 0;
-
- foreach (var trivia in list)
- {
- if (trivia.IsElastic())
- {
- stack.Push(trivia);
- continue;
- }
-
- if (trivia.RawKind == _endOfLineKind)
- {
- numberOfEndOfLinesWithoutAnyNoisyTrivia++;
-
- if (numberOfEndOfLinesWithoutAnyNoisyTrivia > 2)
- {
- // get rid of any whitespace trivia from stack
- var top = stack.Peek();
- while (!top.IsElastic() && top.RawKind == _whitespaceKind)
- {
- stack.Pop();
- top = stack.Peek();
- }
-
- continue;
- }
- }
-
- stack.Push(trivia);
- }
-
- return stack.Reverse();
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.TypeParameterCollector.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.TypeParameterCollector.cs
deleted file mode 100644
index 3c2c401c60..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.TypeParameterCollector.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- protected class TypeParameterCollector : SymbolVisitor
- {
- private readonly List<ITypeParameterSymbol> _typeParameters = new List<ITypeParameterSymbol>();
-
- public static IEnumerable<ITypeParameterSymbol> Collect(ITypeSymbol typeSymbol)
- {
- var collector = new TypeParameterCollector();
- typeSymbol.Accept(collector);
-
- return collector._typeParameters;
- }
-
- public override void DefaultVisit(ISymbol node)
- {
- throw new NotImplementedException();
- }
-
- public override void VisitDynamicType(IDynamicTypeSymbol dynamicTypeSymbol)
- {
- }
-
- public override void VisitArrayType(IArrayTypeSymbol arrayTypeSymbol)
- {
- arrayTypeSymbol.ElementType.Accept(this);
- }
-
- public override void VisitPointerType(IPointerTypeSymbol pointerTypeSymbol)
- {
- pointerTypeSymbol.PointedAtType.Accept(this);
- }
-
- public override void VisitNamedType(INamedTypeSymbol namedTypeSymbol)
- {
- foreach (var argument in namedTypeSymbol.GetAllTypeArguments())
- {
- argument.Accept(this);
- }
- }
-
- public override void VisitTypeParameter(ITypeParameterSymbol typeParameterTypeSymbol)
- {
- _typeParameters.Add(typeParameterTypeSymbol);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.VariableInfo.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.VariableInfo.cs
deleted file mode 100644
index d624ffec4b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.VariableInfo.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- protected class VariableInfo
- {
- private readonly VariableSymbol _variableSymbol;
- private readonly VariableStyle _variableStyle;
- private readonly bool _useAsReturnValue;
-
- public VariableInfo(
- VariableSymbol variableSymbol,
- VariableStyle variableStyle,
- bool useAsReturnValue = false)
- {
- _variableSymbol = variableSymbol;
- _variableStyle = variableStyle;
- _useAsReturnValue = useAsReturnValue;
- }
-
- public bool UseAsReturnValue
- {
- get
- {
- //Contract.ThrowIfFalse(!_useAsReturnValue || _variableStyle.ReturnStyle.ReturnBehavior != ReturnBehavior.None);
- return _useAsReturnValue;
- }
- }
-
- public bool CanBeUsedAsReturnValue
- {
- get
- {
- return _variableStyle.ReturnStyle.ReturnBehavior != ReturnBehavior.None;
- }
- }
-
- public bool UseAsParameter
- {
- get
- {
- return (!_useAsReturnValue && _variableStyle.ParameterStyle.ParameterBehavior != ParameterBehavior.None) ||
- (_useAsReturnValue && _variableStyle.ReturnStyle.ParameterBehavior != ParameterBehavior.None);
- }
- }
-
- public ParameterBehavior ParameterModifier
- {
- get
- {
- return _useAsReturnValue ? _variableStyle.ReturnStyle.ParameterBehavior : _variableStyle.ParameterStyle.ParameterBehavior;
- }
- }
-
- public DeclarationBehavior GetDeclarationBehavior(CancellationToken cancellationToken)
- {
- if (_useAsReturnValue)
- {
- return _variableStyle.ReturnStyle.DeclarationBehavior;
- }
-
- if (_variableSymbol.GetUseSaferDeclarationBehavior(cancellationToken))
- {
- return _variableStyle.ParameterStyle.SaferDeclarationBehavior;
- }
-
- return _variableStyle.ParameterStyle.DeclarationBehavior;
- }
-
- public ReturnBehavior ReturnBehavior
- {
- get
- {
- if (_useAsReturnValue)
- {
- return _variableStyle.ReturnStyle.ReturnBehavior;
- }
-
- return ReturnBehavior.None;
- }
- }
-
- public static VariableInfo CreateReturnValue(VariableInfo variable)
- {
- //Contract.ThrowIfNull(variable);
- //Contract.ThrowIfFalse(variable.CanBeUsedAsReturnValue);
- //Contract.ThrowIfFalse(variable.ParameterModifier == ParameterBehavior.Out || variable.ParameterModifier == ParameterBehavior.Ref);
-
- return new VariableInfo(variable._variableSymbol, variable._variableStyle, useAsReturnValue: true);
- }
-
- public void AddIdentifierTokenAnnotationPair(
- List<Tuple<SyntaxToken, SyntaxAnnotation>> annotations, CancellationToken cancellationToken)
- {
- _variableSymbol.AddIdentifierTokenAnnotationPair(annotations, cancellationToken);
- }
-
- public string Name
- {
- get { return _variableSymbol.Name; }
- }
-
- public bool OriginalTypeHadAnonymousTypeOrDelegate
- {
- get { return _variableSymbol.OriginalTypeHadAnonymousTypeOrDelegate; }
- }
-
- public ITypeSymbol GetVariableType(SemanticDocument document)
- {
- return document.SemanticModel.ResolveType(_variableSymbol.OriginalType);
- }
-
- public SyntaxToken GetIdentifierTokenAtDeclaration(SemanticDocument document)
- {
- return document.GetTokenWithAnnotaton(_variableSymbol.IdentifierTokenAnnotation);
- }
-
- public SyntaxToken GetIdentifierTokenAtDeclaration(SyntaxNode node)
- {
- return node.GetAnnotatedTokens(_variableSymbol.IdentifierTokenAnnotation).SingleOrDefault();
- }
-
- public static int Compare(VariableInfo left, VariableInfo right)
- {
- return VariableSymbol.Compare(left._variableSymbol, right._variableSymbol);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.VariableSymbol.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.VariableSymbol.cs
deleted file mode 100644
index 8783713ead..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.VariableSymbol.cs
+++ /dev/null
@@ -1,357 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- /// <summary>
- /// temporary symbol until we have a symbol that can hold onto both local and parameter symbol
- /// </summary>
- protected abstract class VariableSymbol
- {
- protected VariableSymbol(Compilation compilation, ITypeSymbol type)
- {
- this.OriginalTypeHadAnonymousTypeOrDelegate = type.ContainsAnonymousType();
- this.OriginalType = this.OriginalTypeHadAnonymousTypeOrDelegate ? type.RemoveAnonymousTypes(compilation) : type;
- }
-
- public abstract int DisplayOrder { get; }
- public abstract string Name { get; }
-
- public abstract bool GetUseSaferDeclarationBehavior(CancellationToken cancellationToken);
- public abstract SyntaxAnnotation IdentifierTokenAnnotation { get; }
- public abstract SyntaxToken GetOriginalIdentifierToken(CancellationToken cancellationToken);
-
- public abstract void AddIdentifierTokenAnnotationPair(
- List<Tuple<SyntaxToken, SyntaxAnnotation>> annotations, CancellationToken cancellationToken);
-
- protected abstract int CompareTo(VariableSymbol right);
-
- /// <summary>
- /// return true if original type had anonymous type or delegate somewhere in the type
- /// </summary>
- public bool OriginalTypeHadAnonymousTypeOrDelegate { get; }
-
- /// <summary>
- /// get the original type with anonymous type removed
- /// </summary>
- public ITypeSymbol OriginalType { get; }
-
- public static int Compare(VariableSymbol left, VariableSymbol right)
- {
- if (left.DisplayOrder == right.DisplayOrder)
- {
- return left.CompareTo(right);
- }
-
- return left.DisplayOrder - right.DisplayOrder;
- }
- }
-
- protected abstract class NotMovableVariableSymbol : VariableSymbol
- {
- public NotMovableVariableSymbol(Compilation compilation, ITypeSymbol type) :
- base(compilation, type)
- {
- }
-
- public override bool GetUseSaferDeclarationBehavior(CancellationToken cancellationToken)
- {
- // decl never get moved
- return false;
- }
-
- [ExcludeFromCodeCoverage]
- public override SyntaxToken GetOriginalIdentifierToken(CancellationToken cancellationToken)
- {
- throw new InvalidOperationException();
- }
-
- [ExcludeFromCodeCoverage]
- public override SyntaxAnnotation IdentifierTokenAnnotation
- {
- get { throw new InvalidOperationException(); }
- }
-
- public override void AddIdentifierTokenAnnotationPair(
- List<Tuple<SyntaxToken, SyntaxAnnotation>> annotations, CancellationToken cancellationToken)
- {
- // do nothing for parameter
- }
- }
-
- protected class ParameterVariableSymbol : NotMovableVariableSymbol, IComparable<ParameterVariableSymbol>
- {
- private readonly IParameterSymbol _parameterSymbol;
-
- public ParameterVariableSymbol(Compilation compilation, IParameterSymbol parameterSymbol, ITypeSymbol type) :
- base(compilation, type)
- {
- //Contract.ThrowIfNull(parameterSymbol);
- _parameterSymbol = parameterSymbol;
- }
-
- public override int DisplayOrder
- {
- get { return 0; }
- }
-
- protected override int CompareTo(VariableSymbol right)
- {
- return this.CompareTo((ParameterVariableSymbol)right);
- }
-
- public int CompareTo(ParameterVariableSymbol other)
- {
- //Contract.ThrowIfNull(other);
-
- if (this == other)
- {
- return 0;
- }
-
- var compare = CompareTo((IMethodSymbol)_parameterSymbol.ContainingSymbol, (IMethodSymbol)other._parameterSymbol.ContainingSymbol);
- if (compare != 0)
- {
- return compare;
- }
-
- // Contract.ThrowIfFalse(_parameterSymbol.Ordinal != other._parameterSymbol.Ordinal);
- return (_parameterSymbol.Ordinal > other._parameterSymbol.Ordinal) ? 1 : -1;
- }
-
- private int CompareTo(IMethodSymbol left, IMethodSymbol right)
- {
- if (left == null && right == null)
- {
- return 0;
- }
-
- if (left.Equals(right))
- {
- return 0;
- }
-
- if (left.MethodKind == MethodKind.AnonymousFunction &&
- right.MethodKind != MethodKind.AnonymousFunction)
- {
- return 1;
- }
-
- if (left.MethodKind != MethodKind.AnonymousFunction &&
- right.MethodKind == MethodKind.AnonymousFunction)
- {
- return -1;
- }
-
- if (left.MethodKind == MethodKind.AnonymousFunction &&
- right.MethodKind == MethodKind.AnonymousFunction)
- {
- //Contract.ThrowIfFalse(left.Locations.Length == 1);
- //Contract.ThrowIfFalse(right.Locations.Length == 1);
-
- return left.Locations[0].SourceSpan.Start - right.Locations[0].SourceSpan.Start;
- }
-
- return 0;//Contract.FailWithReturn<int>("Shouldn't reach here");
- }
-
- public override string Name
- {
- get
- {
- return _parameterSymbol.ToDisplayString(
- new SymbolDisplayFormat(
- parameterOptions: SymbolDisplayParameterOptions.IncludeName,
- miscellaneousOptions: SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers));
- }
- }
- }
-
- protected class LocalVariableSymbol<T> : VariableSymbol, IComparable<LocalVariableSymbol<T>> where T : SyntaxNode
- {
- private readonly SyntaxAnnotation _annotation;
- private readonly ILocalSymbol _localSymbol;
- private readonly HashSet<int> _nonNoisySet;
-
- public LocalVariableSymbol(Compilation compilation, ILocalSymbol localSymbol, ITypeSymbol type, HashSet<int> nonNoisySet) :
- base(compilation, type)
- {
-// Contract.ThrowIfNull(localSymbol);
-// Contract.ThrowIfNull(nonNoisySet);
-
- _annotation = new SyntaxAnnotation();
- _localSymbol = localSymbol;
- _nonNoisySet = nonNoisySet;
- }
-
- public override int DisplayOrder
- {
- get { return 1; }
- }
-
- protected override int CompareTo(VariableSymbol right)
- {
- return this.CompareTo((LocalVariableSymbol<T>)right);
- }
-
- public int CompareTo(LocalVariableSymbol<T> other)
- {
- //Contract.ThrowIfNull(other);
-
- if (this == other)
- {
- return 0;
- }
-
- //Contract.ThrowIfFalse(_localSymbol.Locations.Length == 1);
- //Contract.ThrowIfFalse(other._localSymbol.Locations.Length == 1);
- //Contract.ThrowIfFalse(_localSymbol.Locations[0].IsInSource);
- //Contract.ThrowIfFalse(other._localSymbol.Locations[0].IsInSource);
- //Contract.ThrowIfFalse(_localSymbol.Locations[0].SourceTree == other._localSymbol.Locations[0].SourceTree);
- //Contract.ThrowIfFalse(_localSymbol.Locations[0].SourceSpan.Start != other._localSymbol.Locations[0].SourceSpan.Start);
-
- return _localSymbol.Locations[0].SourceSpan.Start - other._localSymbol.Locations[0].SourceSpan.Start;
- }
-
- public override string Name
- {
- get
- {
- return _localSymbol.ToDisplayString(
- new SymbolDisplayFormat(
- miscellaneousOptions: SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers));
- }
- }
-
- public override SyntaxToken GetOriginalIdentifierToken(CancellationToken cancellationToken)
- {
-// Contract.ThrowIfFalse(_localSymbol.Locations.Length == 1);
-// Contract.ThrowIfFalse(_localSymbol.Locations[0].IsInSource);
-// Contract.ThrowIfNull(_localSymbol.Locations[0].SourceTree);
-
- var tree = _localSymbol.Locations[0].SourceTree;
- var span = _localSymbol.Locations[0].SourceSpan;
-
- var token = tree.GetRoot(cancellationToken).FindToken(span.Start);
- //Contract.ThrowIfFalse(token.Span.Equals(span));
-
- return token;
- }
-
- public override SyntaxAnnotation IdentifierTokenAnnotation
- {
- get { return _annotation; }
- }
-
- public override void AddIdentifierTokenAnnotationPair(
- List<Tuple<SyntaxToken, SyntaxAnnotation>> annotations, CancellationToken cancellationToken)
- {
- annotations.Add(Tuple.Create(this.GetOriginalIdentifierToken(cancellationToken), _annotation));
- }
-
- public override bool GetUseSaferDeclarationBehavior(CancellationToken cancellationToken)
- {
- var identifier = this.GetOriginalIdentifierToken(cancellationToken);
-
- // check whether there is a noisy trivia around the token.
- if (ContainsNoisyTrivia(identifier.LeadingTrivia))
- {
- return true;
- }
-
- if (ContainsNoisyTrivia(identifier.TrailingTrivia))
- {
- return true;
- }
-
- var declStatement = identifier.Parent.FirstAncestorOrSelf<T>((n) => true);
- if (declStatement == null)
- {
- return true;
- }
-
- foreach (var token in declStatement.DescendantTokens())
- {
- if (ContainsNoisyTrivia(token.LeadingTrivia))
- {
- return true;
- }
-
- if (ContainsNoisyTrivia(token.TrailingTrivia))
- {
- return true;
- }
- }
-
- return false;
- }
-
- private bool ContainsNoisyTrivia(SyntaxTriviaList list)
- {
- return list.Any(t => !_nonNoisySet.Contains(t.RawKind));
- }
- }
-
- protected class QueryVariableSymbol : NotMovableVariableSymbol, IComparable<QueryVariableSymbol>
- {
- private readonly IRangeVariableSymbol _symbol;
-
- public QueryVariableSymbol(Compilation compilation, IRangeVariableSymbol symbol, ITypeSymbol type) :
- base(compilation, type)
- {
- //Contract.ThrowIfNull(symbol);
- _symbol = symbol;
- }
-
- public override int DisplayOrder
- {
- get { return 2; }
- }
-
- protected override int CompareTo(VariableSymbol right)
- {
- return this.CompareTo((QueryVariableSymbol)right);
- }
-
- public int CompareTo(QueryVariableSymbol other)
- {
- //Contract.ThrowIfNull(other);
-
- if (this == other)
- {
- return 0;
- }
-
- var locationLeft = _symbol.Locations.First();
- var locationRight = other._symbol.Locations.First();
-
-// Contract.ThrowIfFalse(locationLeft.IsInSource);
-// Contract.ThrowIfFalse(locationRight.IsInSource);
-// Contract.ThrowIfFalse(locationLeft.SourceTree == locationRight.SourceTree);
-// Contract.ThrowIfFalse(locationLeft.SourceSpan.Start != locationRight.SourceSpan.Start);
-
- return locationLeft.SourceSpan.Start - locationRight.SourceSpan.Start;
- }
-
- public override string Name
- {
- get
- {
- return _symbol.ToDisplayString(
- new SymbolDisplayFormat(
- miscellaneousOptions: SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers));
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.cs
deleted file mode 100644
index 98cba2afd5..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/MethodExtractor.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Formatting.Rules;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class MethodExtractor
- {
- protected readonly SelectionResult OriginalSelectionResult;
-
- public MethodExtractor(SelectionResult selectionResult)
- {
- //Contract.ThrowIfNull(selectionResult);
- this.OriginalSelectionResult = selectionResult;
- }
-
- protected abstract Task<AnalyzerResult> AnalyzeAsync(SelectionResult selectionResult, CancellationToken cancellationToken);
- protected abstract Task<InsertionPoint> GetInsertionPointAsync(SemanticDocument document, int position, CancellationToken cancellationToken);
- protected abstract Task<TriviaResult> PreserveTriviaAsync(SelectionResult selectionResult, CancellationToken cancellationToken);
- protected abstract Task<SemanticDocument> ExpandAsync(SelectionResult selection, CancellationToken cancellationToken);
-
- protected abstract Task<GeneratedCode> GenerateCodeAsync(InsertionPoint insertionPoint, SelectionResult selectionResult, AnalyzerResult analyzeResult, CancellationToken cancellationToken);
-
- protected abstract SyntaxToken GetMethodNameAtInvocation(IEnumerable<SyntaxNodeOrToken> methodNames);
- // protected abstract IEnumerable<IFormattingRule> GetFormattingRules(Document document);
-
- protected abstract Task<OperationStatus> CheckTypeAsync(Document document, SyntaxNode contextNode, Location location, ITypeSymbol type, CancellationToken cancellationToken);
-
- public async Task<ExtractMethodResult> ExtractMethodAsync(CancellationToken cancellationToken)
- {
- var operationStatus = this.OriginalSelectionResult.Status;
-
- var analyzeResult = await AnalyzeAsync(this.OriginalSelectionResult, cancellationToken).ConfigureAwait(false);
- cancellationToken.ThrowIfCancellationRequested();
-
- operationStatus = await CheckVariableTypesAsync(analyzeResult.Status.With(operationStatus), analyzeResult, cancellationToken).ConfigureAwait(false);
- if (operationStatus.FailedWithNoBestEffortSuggestion())
- {
- return new FailedExtractMethodResult(operationStatus);
- }
-
- var insertionPoint = await GetInsertionPointAsync(analyzeResult.SemanticDocument, this.OriginalSelectionResult.OriginalSpan.Start, cancellationToken).ConfigureAwait(false);
- cancellationToken.ThrowIfCancellationRequested();
-
- var triviaResult = await PreserveTriviaAsync(this.OriginalSelectionResult.With(insertionPoint.SemanticDocument), cancellationToken).ConfigureAwait(false);
- cancellationToken.ThrowIfCancellationRequested();
-
- var expandedDocument = await ExpandAsync(this.OriginalSelectionResult.With(triviaResult.SemanticDocument), cancellationToken).ConfigureAwait(false);
-
- var generatedCode = await GenerateCodeAsync(
- insertionPoint.With(expandedDocument),
- this.OriginalSelectionResult.With(expandedDocument),
- analyzeResult.With(expandedDocument),
- cancellationToken).ConfigureAwait(false);
-
- var applied = await triviaResult.ApplyAsync(generatedCode, cancellationToken).ConfigureAwait(false);
- var afterTriviaRestored = applied.With(operationStatus);
- cancellationToken.ThrowIfCancellationRequested();
-
- if (afterTriviaRestored.Status.FailedWithNoBestEffortSuggestion())
- {
- return CreateExtractMethodResult(
- operationStatus, generatedCode.SemanticDocument, generatedCode.MethodNameAnnotation, generatedCode.MethodDefinitionAnnotation);
- }
-
- var finalDocument = afterTriviaRestored.Data.Document;
- finalDocument = await Formatter.FormatAsync(finalDocument, Formatter.Annotation, options: null,/* rules: GetFormattingRules(finalDocument), */cancellationToken: cancellationToken).ConfigureAwait(false);
-
- cancellationToken.ThrowIfCancellationRequested();
- return CreateExtractMethodResult(
- operationStatus.With(generatedCode.Status),
- await SemanticDocument.CreateAsync(finalDocument, cancellationToken).ConfigureAwait(false),
- generatedCode.MethodNameAnnotation,
- generatedCode.MethodDefinitionAnnotation);
- }
-
- private ExtractMethodResult CreateExtractMethodResult(
- OperationStatus status, SemanticDocument semanticDocument,
- SyntaxAnnotation invocationAnnotation, SyntaxAnnotation methodAnnotation)
- {
- var newRoot = semanticDocument.Root;
- var annotatedTokens = newRoot.GetAnnotatedNodesAndTokens(invocationAnnotation);
- var methodDefinition = newRoot.GetAnnotatedNodesAndTokens(methodAnnotation).FirstOrDefault().AsNode();
-
- return new SimpleExtractMethodResult(status, semanticDocument.Document, GetMethodNameAtInvocation(annotatedTokens), methodDefinition);
- }
-
- private async Task<OperationStatus> CheckVariableTypesAsync(
- OperationStatus status,
- AnalyzerResult analyzeResult,
- CancellationToken cancellationToken)
- {
- var document = analyzeResult.SemanticDocument;
-
- // sync selection result to same semantic data as analyzeResult
- var firstToken = this.OriginalSelectionResult.With(document).GetFirstTokenInSelection();
- var context = firstToken.Parent;
-
- var result = await TryCheckVariableTypeAsync(document, context, analyzeResult.GetVariablesToMoveIntoMethodDefinition(cancellationToken), status, cancellationToken).ConfigureAwait(false);
- if (!result.Item1)
- {
- result = await TryCheckVariableTypeAsync(document, context, analyzeResult.GetVariablesToSplitOrMoveIntoMethodDefinition(cancellationToken), result.Item2, cancellationToken).ConfigureAwait(false);
- if (!result.Item1)
- {
- result = await TryCheckVariableTypeAsync(document, context, analyzeResult.MethodParameters, result.Item2, cancellationToken).ConfigureAwait(false);
- if (!result.Item1)
- {
- result = await TryCheckVariableTypeAsync(document, context, analyzeResult.GetVariablesToMoveOutToCallSite(cancellationToken), result.Item2, cancellationToken).ConfigureAwait(false);
- if (!result.Item1)
- {
- result = await TryCheckVariableTypeAsync(document, context, analyzeResult.GetVariablesToSplitOrMoveOutToCallSite(cancellationToken), result.Item2, cancellationToken).ConfigureAwait(false);
- if (!result.Item1)
- {
- return result.Item2;
- }
- }
- }
- }
- }
-
- status = result.Item2;
-
- var checkedStatus = await CheckTypeAsync(document.Document, context, context.GetLocation(), analyzeResult.ReturnType, cancellationToken).ConfigureAwait(false);
- return checkedStatus.With(status);
- }
-
- private async Task<Tuple<bool, OperationStatus>> TryCheckVariableTypeAsync(
- SemanticDocument document, SyntaxNode contextNode, IEnumerable<VariableInfo> variables,
- OperationStatus status, CancellationToken cancellationToken)
- {
- if (status.FailedWithNoBestEffortSuggestion())
- {
- return Tuple.Create(false, status);
- }
-
- var location = contextNode.GetLocation();
-
- foreach (var variable in variables)
- {
- var originalType = variable.GetVariableType(document);
- var result = await CheckTypeAsync(document.Document, contextNode, location, originalType, cancellationToken).ConfigureAwait(false);
- if (result.FailedWithNoBestEffortSuggestion())
- {
- status = status.With(result);
- return Tuple.Create(false, status);
- }
- }
-
- return Tuple.Create(true, status);
- }
-
- public static string MakeMethodName(string prefix, string originalName)
- {
- var startingWithLetter = originalName.SkipWhile(c => !char.IsLetter(c)).ToArray();
- var name = startingWithLetter.Length == 0 ? originalName : new string(startingWithLetter);
-
- return char.IsUpper(name[0]) ?
- prefix + name :
- prefix + char.ToUpper(name[0]).ToString() + name.Substring(1);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus.cs
deleted file mode 100644
index 8c762ed461..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class OperationStatus
- {
- public OperationStatus(OperationStatusFlag flag, string reason)
- {
- //Contract.ThrowIfTrue(flag.Succeeded() && flag.HasBestEffort());
-
- this.Flag = flag;
- this.Reasons = reason == null ? SpecializedCollections.EmptyEnumerable<string>() : SpecializedCollections.SingletonEnumerable(reason);
- }
-
- private OperationStatus(OperationStatusFlag flag, IEnumerable<string> reasons)
- {
- //Contract.ThrowIfNull(reasons);
- //Contract.ThrowIfTrue(flag.Succeeded() && flag.HasBestEffort());
-
- this.Flag = flag;
- this.Reasons = reasons;
- }
-
- public OperationStatus With(OperationStatusFlag flag, string reason)
- {
- var newFlag = this.Flag | flag;
-
- newFlag = (this.Failed() || flag.Failed()) ? newFlag.RemoveFlag(OperationStatusFlag.Succeeded) : newFlag;
- newFlag = newFlag.Succeeded() ? newFlag.RemoveFlag(OperationStatusFlag.BestEffort) : newFlag;
-
- var reasons = reason == null ? this.Reasons : this.Reasons.Concat(reason);
- return new OperationStatus(newFlag, reasons);
- }
-
- public OperationStatus With(OperationStatus operationStatus)
- {
- var newFlag = this.Flag | operationStatus.Flag;
-
- newFlag = (this.Failed() || operationStatus.Failed()) ? newFlag.RemoveFlag(OperationStatusFlag.Succeeded) : newFlag;
- newFlag = newFlag.Succeeded() ? newFlag.RemoveFlag(OperationStatusFlag.BestEffort) : newFlag;
-
- var reasons = this.Reasons.Concat(operationStatus.Reasons);
- return new OperationStatus(newFlag, reasons);
- }
-
- public OperationStatus MakeFail()
- {
- return new OperationStatus(OperationStatusFlag.None, this.Reasons);
- }
-
- public OperationStatus MarkSuggestion()
- {
- return new OperationStatus(this.Flag | OperationStatusFlag.Suggestion, this.Reasons);
- }
-
- public OperationStatus<T> With<T>(T data)
- {
- return Create(this, data);
- }
-
- public OperationStatusFlag Flag { get; }
- public IEnumerable<string> Reasons { get; }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus_Statics.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus_Statics.cs
deleted file mode 100644
index 3768600158..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus_Statics.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class OperationStatus
- {
- public static readonly OperationStatus Succeeded = new OperationStatus(OperationStatusFlag.Succeeded, reason: null);
- public static readonly OperationStatus FailedWithUnknownReason = new OperationStatus(OperationStatusFlag.None, reason: "FeaturesResources.ExtractMethodFailedWithUnknownReasons");
- public static readonly OperationStatus OverlapsHiddenPosition = new OperationStatus(OperationStatusFlag.None, "FeaturesResources.GeneratedCodeIsOverlapping");
-
- public static readonly OperationStatus NoActiveStatement = new OperationStatus(OperationStatusFlag.BestEffort, "FeaturesResources.NoActiveStatement");
- public static readonly OperationStatus ErrorOrUnknownType = new OperationStatus(OperationStatusFlag.BestEffort, "FeaturesResources.ErrorOrUnknownType");
- public static readonly OperationStatus UnsafeAddressTaken = new OperationStatus(OperationStatusFlag.BestEffort, "FeaturesResources.TheAddressOfAVariableIsUsed");
-
- /// <summary>
- /// create operation status with the given data
- /// </summary>
- public static OperationStatus<T> Create<T>(OperationStatus status, T data)
- {
- return new OperationStatus<T>(status, data);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus`1.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus`1.cs
deleted file mode 100644
index 48301d7ed5..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/OperationStatus`1.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- /// <summary>
- /// operation status paired with data
- /// </summary>
- class OperationStatus<T>
- {
- public OperationStatus(OperationStatus status, T data)
- {
- this.Status = status;
- this.Data = data;
- }
-
- public OperationStatus Status { get; }
- public T Data { get; }
-
- public OperationStatus<T> With(OperationStatus status)
- {
- return new OperationStatus<T>(status, this.Data);
- }
-
- public OperationStatus<TNew> With<TNew>(TNew data)
- {
- return new OperationStatus<TNew>(this.Status, data);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ParameterStyle.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ParameterStyle.cs
deleted file mode 100644
index ad012fdc4a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ParameterStyle.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class ParameterStyle
- {
- public ParameterBehavior ParameterBehavior { get; private set; }
- public DeclarationBehavior DeclarationBehavior { get; private set; }
- public DeclarationBehavior SaferDeclarationBehavior { get; private set; }
-
- public static readonly ParameterStyle None =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.None, DeclarationBehavior = DeclarationBehavior.None, SaferDeclarationBehavior = DeclarationBehavior.None };
-
- public static readonly ParameterStyle InputOnly =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.Input, DeclarationBehavior = DeclarationBehavior.None, SaferDeclarationBehavior = DeclarationBehavior.None };
-
- public static readonly ParameterStyle Delete =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.None, DeclarationBehavior = DeclarationBehavior.Delete, SaferDeclarationBehavior = DeclarationBehavior.None };
-
- public static readonly ParameterStyle MoveOut =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.None, DeclarationBehavior = DeclarationBehavior.MoveOut, SaferDeclarationBehavior = DeclarationBehavior.SplitOut };
-
- public static readonly ParameterStyle SplitOut =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.None, DeclarationBehavior = DeclarationBehavior.SplitOut, SaferDeclarationBehavior = DeclarationBehavior.SplitOut };
-
- public static readonly ParameterStyle MoveIn =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.None, DeclarationBehavior = DeclarationBehavior.MoveIn, SaferDeclarationBehavior = DeclarationBehavior.SplitIn };
-
- public static readonly ParameterStyle SplitIn =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.None, DeclarationBehavior = DeclarationBehavior.SplitIn, SaferDeclarationBehavior = DeclarationBehavior.SplitIn };
-
- public static readonly ParameterStyle Out =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.Out, DeclarationBehavior = DeclarationBehavior.None, SaferDeclarationBehavior = DeclarationBehavior.None };
-
- public static readonly ParameterStyle Ref =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.Ref, DeclarationBehavior = DeclarationBehavior.None, SaferDeclarationBehavior = DeclarationBehavior.None };
-
- public static readonly ParameterStyle OutWithMoveOut =
- new ParameterStyle() { ParameterBehavior = ParameterBehavior.Out, DeclarationBehavior = DeclarationBehavior.MoveOut, SaferDeclarationBehavior = DeclarationBehavior.MoveOut };
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ReturnStyle.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ReturnStyle.cs
deleted file mode 100644
index 9f7d8625c4..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/ReturnStyle.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class ReturnStyle
- {
- public ParameterBehavior ParameterBehavior { get; private set; }
- public ReturnBehavior ReturnBehavior { get; private set; }
- public DeclarationBehavior DeclarationBehavior { get; private set; }
-
- public static readonly ReturnStyle None =
- new ReturnStyle() { ParameterBehavior = ParameterBehavior.None, ReturnBehavior = ReturnBehavior.None, DeclarationBehavior = DeclarationBehavior.None };
-
- public static readonly ReturnStyle AssignmentWithInput =
- new ReturnStyle() { ParameterBehavior = ParameterBehavior.Input, ReturnBehavior = ReturnBehavior.Assignment, DeclarationBehavior = DeclarationBehavior.None };
-
- public static readonly ReturnStyle AssignmentWithNoInput =
- new ReturnStyle() { ParameterBehavior = ParameterBehavior.None, ReturnBehavior = ReturnBehavior.Assignment, DeclarationBehavior = DeclarationBehavior.SplitIn };
-
- public static readonly ReturnStyle Initialization =
- new ReturnStyle() { ParameterBehavior = ParameterBehavior.None, ReturnBehavior = ReturnBehavior.Initialization, DeclarationBehavior = DeclarationBehavior.SplitOut };
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionResult.cs
deleted file mode 100644
index df2ff4ec47..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionResult.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- /// <summary>
- /// clean up this code when we do selection validator work.
- /// </summary>
- abstract class SelectionResult
- {
- protected SelectionResult(OperationStatus status)
- {
- // Contract.ThrowIfNull(status);
-
- this.Status = status;
- }
-
- protected SelectionResult(
- OperationStatus status,
- TextSpan originalSpan,
- TextSpan finalSpan,
- OptionSet options,
- bool selectionInExpression,
- SemanticDocument document,
- SyntaxAnnotation firstTokenAnnotation,
- SyntaxAnnotation lastTokenAnnotation)
- {
- this.Status = status;
-
- this.OriginalSpan = originalSpan;
- this.FinalSpan = finalSpan;
-
- this.SelectionInExpression = selectionInExpression;
- this.Options = options;
-
- this.FirstTokenAnnotation = firstTokenAnnotation;
- this.LastTokenAnnotation = lastTokenAnnotation;
-
- this.SemanticDocument = document;
- }
-
- protected abstract bool UnderAsyncAnonymousMethod(SyntaxToken token, SyntaxToken firstToken, SyntaxToken lastToken);
-
- public abstract bool ContainingScopeHasAsyncKeyword();
-
- public abstract SyntaxNode GetContainingScope();
- public abstract ITypeSymbol GetContainingScopeType();
-
- public OperationStatus Status { get; }
- public TextSpan OriginalSpan { get; }
- public TextSpan FinalSpan { get; }
- public OptionSet Options { get; }
- public bool SelectionInExpression { get; }
- public SemanticDocument SemanticDocument { get; private set; }
- public SyntaxAnnotation FirstTokenAnnotation { get; }
- public SyntaxAnnotation LastTokenAnnotation { get; }
-
- public SelectionResult With(SemanticDocument document)
- {
- if (this.SemanticDocument == document)
- {
- return this;
- }
-
- var clone = (SelectionResult)this.MemberwiseClone();
- clone.SemanticDocument = document;
-
- return clone;
- }
-
- public bool ContainsValidContext
- {
- get
- {
- return this.SemanticDocument != null;
- }
- }
-
- public SyntaxToken GetFirstTokenInSelection()
- {
- return this.SemanticDocument.GetTokenWithAnnotaton(this.FirstTokenAnnotation);
- }
-
- public SyntaxToken GetLastTokenInSelection()
- {
- return this.SemanticDocument.GetTokenWithAnnotaton(this.LastTokenAnnotation);
- }
-
- public TNode GetContainingScopeOf<TNode>() where TNode : SyntaxNode
- {
- var containingScope = this.GetContainingScope();
- return containingScope.GetAncestorOrThis<TNode>();
- }
-
- protected T GetFirstStatement<T>() where T : SyntaxNode
- {
- //Contract.ThrowIfTrue(this.SelectionInExpression);
-
- var token = this.GetFirstTokenInSelection();
- return token.GetAncestor<T>();
- }
-
- protected T GetLastStatement<T>() where T : SyntaxNode
- {
- //Contract.ThrowIfTrue(this.SelectionInExpression);
-
- var token = this.GetLastTokenInSelection();
- return token.GetAncestor<T>();
- }
-
- public bool ShouldPutAsyncModifier()
- {
- var firstToken = this.GetFirstTokenInSelection();
- var lastToken = this.GetLastTokenInSelection();
-
- for (var currentToken = firstToken;
- currentToken.Span.End < lastToken.SpanStart;
- currentToken = currentToken.GetNextToken())
- {
- // [|
- // async () => await ....
- // |]
- //
- // for the case above, even if the selection contains "await", it doesn't belong to the enclosing block
- // which extract method is applied to
- if (currentToken.IsAwaitKeyword()
- && !UnderAsyncAnonymousMethod(currentToken, firstToken, lastToken))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public bool AllowMovingDeclaration
- {
- get
- {
- return this.Options.GetOption(ExtractMethodOptions.AllowMovingDeclaration, this.SemanticDocument.Project.Language);
- }
- }
-
- public bool DontPutOutOrRefOnStruct
- {
- get
- {
- return this.Options.GetOption(ExtractMethodOptions.DontPutOutOrRefOnStruct, this.SemanticDocument.Project.Language);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionValidator.NullSelectionResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionValidator.NullSelectionResult.cs
deleted file mode 100644
index 3a957d7222..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionValidator.NullSelectionResult.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- partial class SelectionValidator
- {
- // null object
- protected class NullSelectionResult : SelectionResult
- {
- public NullSelectionResult() :
- this(OperationStatus.FailedWithUnknownReason)
- {
- }
-
- protected NullSelectionResult(OperationStatus status) :
- base(status)
- {
- }
-
- protected override bool UnderAsyncAnonymousMethod(SyntaxToken token, SyntaxToken firstToken, SyntaxToken lastToken)
- {
- throw new InvalidOperationException();
- }
-
- public override bool ContainingScopeHasAsyncKeyword()
- {
- throw new InvalidOperationException();
- }
-
- public override SyntaxNode GetContainingScope()
- {
- throw new InvalidOperationException();
- }
-
- public override ITypeSymbol GetContainingScopeType()
- {
- throw new InvalidOperationException();
- }
- }
-
- protected class ErrorSelectionResult : NullSelectionResult
- {
- public ErrorSelectionResult(OperationStatus status) :
- base(status.MakeFail())
- {
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionValidator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionValidator.cs
deleted file mode 100644
index 4067dfe48d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SelectionValidator.cs
+++ /dev/null
@@ -1,185 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- abstract partial class SelectionValidator
- {
- protected static readonly SelectionResult NullSelection = new NullSelectionResult();
-
- protected readonly SemanticDocument SemanticDocument;
- protected readonly TextSpan OriginalSpan;
- protected readonly OptionSet Options;
-
- protected SelectionValidator(
- SemanticDocument document,
- TextSpan textSpan,
- OptionSet options)
- {
- //Contract.ThrowIfNull(document);
-
- this.SemanticDocument = document;
- this.OriginalSpan = textSpan;
- this.Options = options;
- }
-
- public bool ContainsValidSelection
- {
- get
- {
- return !this.OriginalSpan.IsEmpty;
- }
- }
-
- public abstract Task<SelectionResult> GetValidSelectionAsync(CancellationToken cancellationToken);
- public abstract IEnumerable<SyntaxNode> GetOuterReturnStatements(SyntaxNode commonRoot, IEnumerable<SyntaxNode> jumpsOutOfRegion);
- public abstract bool IsFinalSpanSemanticallyValidSpan(SyntaxNode node, TextSpan textSpan, IEnumerable<SyntaxNode> returnStatements, CancellationToken cancellationToken);
- public abstract bool ContainsNonReturnExitPointsStatements(IEnumerable<SyntaxNode> jumpsOutOfRegion);
-
- protected bool IsFinalSpanSemanticallyValidSpan(
- SemanticModel semanticModel, TextSpan textSpan, Tuple<SyntaxNode, SyntaxNode> range, CancellationToken cancellationToken)
- {
- //Contract.ThrowIfNull(range);
-
- var controlFlowAnalysisData = semanticModel.AnalyzeControlFlow(range.Item1, range.Item2);
-
- // there must be no control in and out of given span
- if (controlFlowAnalysisData.EntryPoints.Any())
- {
- return false;
- }
-
- // check something like continue, break, yield break, yield return, and etc
- if (ContainsNonReturnExitPointsStatements(controlFlowAnalysisData.ExitPoints))
- {
- return false;
- }
-
- // okay, there is no branch out, check whether next statement can be executed normally
- var returnStatements = GetOuterReturnStatements(range.Item1.GetCommonRoot(range.Item2), controlFlowAnalysisData.ExitPoints);
- if (!returnStatements.Any())
- {
- if (!controlFlowAnalysisData.EndPointIsReachable)
- {
- // REVIEW: should we just do extract method regardless or show some warning to user?
- // in dev10, looks like we went ahead and did the extract method even if selection contains
- // unreachable code.
- }
-
- return true;
- }
-
- // okay, only branch was return. make sure we have all return in the selection. (?)
- if (!controlFlowAnalysisData.EndPointIsReachable)
- {
- return true;
- }
-
- // there is a return statement, and current position is reachable. let's check whether this is a case where that is okay
- return IsFinalSpanSemanticallyValidSpan(semanticModel.SyntaxTree.GetRoot(cancellationToken), textSpan, returnStatements, cancellationToken);
- }
-
- protected Tuple<SyntaxNode, SyntaxNode> GetStatementRangeContainingSpan<T>(
- SyntaxNode root, TextSpan textSpan, CancellationToken cancellationToken) where T : SyntaxNode
- {
- // use top-down approach to find smallest statement range that contains given span.
- // this approach is more expansive than bottom-up approach I used before but way simpler and easy to understand
- var token1 = root.FindToken(textSpan.Start);
- var token2 = root.FindTokenFromEnd(textSpan.End);
-
- var commonRoot = token1.GetCommonRoot(token2).GetAncestorOrThis<T>() ?? root;
-
- var firstStatement = default(T);
- var lastStatement = default(T);
-
- var spine = new List<T>();
-
- foreach (var stmt in commonRoot.DescendantNodesAndSelf().OfType<T>())
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- // quick skip check.
- // - not containing at all
- if (stmt.Span.End < textSpan.Start)
- {
- continue;
- }
-
- // quick exit check
- // - passed candidate statements
- if (textSpan.End < stmt.SpanStart)
- {
- break;
- }
-
- if (stmt.SpanStart <= textSpan.Start)
- {
- // keep track spine
- spine.Add(stmt);
- }
-
- if (textSpan.End <= stmt.Span.End && spine.Any(s => s.Parent == stmt.Parent))
- {
- // malformed code or selection can make spine to have more than an elements
- firstStatement = spine.First(s => s.Parent == stmt.Parent);
- lastStatement = stmt;
-
- spine.Clear();
- }
- }
-
- if (firstStatement == null || lastStatement == null)
- {
- return null;
- }
-
- return new Tuple<SyntaxNode, SyntaxNode>(firstStatement, lastStatement);
- }
-
- protected Tuple<SyntaxNode, SyntaxNode> GetStatementRangeContainedInSpan<T>(
- SyntaxNode root, TextSpan textSpan, CancellationToken cancellationToken) where T : SyntaxNode
- {
- // use top-down approach to find largest statement range contained in the given span
- // this method is a bit more expensive than bottom-up approach, but way more simpler than the other approach.
- var token1 = root.FindToken(textSpan.Start);
- var token2 = root.FindTokenFromEnd(textSpan.End);
-
- var commonRoot = token1.GetCommonRoot(token2).GetAncestorOrThis<T>() ?? root;
-
- T firstStatement = null;
- T lastStatement = null;
-
- foreach (var stmt in commonRoot.DescendantNodesAndSelf().OfType<T>())
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- if (firstStatement == null && stmt.SpanStart >= textSpan.Start)
- {
- firstStatement = stmt;
- }
-
- if (firstStatement != null && stmt.Span.End <= textSpan.End && stmt.Parent == firstStatement.Parent)
- {
- lastStatement = stmt;
- }
- }
-
- if (firstStatement == null || lastStatement == null)
- {
- return null;
- }
-
- return new Tuple<SyntaxNode, SyntaxNode>(firstStatement, lastStatement);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SimpleExtractMethodResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SimpleExtractMethodResult.cs
deleted file mode 100644
index ccdc5aaac6..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/SimpleExtractMethodResult.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class SimpleExtractMethodResult : ExtractMethodResult
- {
- public SimpleExtractMethodResult(
- OperationStatus status,
- Document document,
- SyntaxToken invocationNameToken,
- SyntaxNode methodDefinition)
- : base(status.Flag, status.Reasons, document, invocationNameToken, methodDefinition)
- {
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/UniqueNameGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/UniqueNameGenerator.cs
deleted file mode 100644
index ed5ac2b4f0..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/UniqueNameGenerator.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class UniqueNameGenerator
- {
- private readonly SemanticModel _semanticModel;
-
- public UniqueNameGenerator(SemanticModel semanticModel)
- {
- //Contract.ThrowIfNull(semanticModel);
- _semanticModel = semanticModel;
- }
-
- public string CreateUniqueMethodName(SyntaxNode contextNode, string baseName)
- {
- //Contract.ThrowIfNull(contextNode);
- //Contract.ThrowIfNull(baseName);
-
- return NameGenerator.GenerateUniqueName(baseName, string.Empty,
- n => _semanticModel.LookupSymbols(contextNode.SpanStart, /*container*/null, n).Length == 0);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/VariableStyle.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/VariableStyle.cs
deleted file mode 100644
index 3eb25eebf0..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ExtractMethod/VariableStyle.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace ICSharpCode.NRefactory6.CSharp.ExtractMethod
-{
- class VariableStyle
- {
- public ParameterStyle ParameterStyle { get; private set; }
- public ReturnStyle ReturnStyle { get; private set; }
-
- public static readonly VariableStyle None =
- new VariableStyle() { ParameterStyle = ParameterStyle.None, ReturnStyle = ReturnStyle.None };
-
- public static readonly VariableStyle InputOnly =
- new VariableStyle() { ParameterStyle = ParameterStyle.InputOnly, ReturnStyle = ReturnStyle.None };
-
- public static readonly VariableStyle Delete =
- new VariableStyle() { ParameterStyle = ParameterStyle.Delete, ReturnStyle = ReturnStyle.None };
-
- public static readonly VariableStyle MoveOut =
- new VariableStyle() { ParameterStyle = ParameterStyle.MoveOut, ReturnStyle = ReturnStyle.None };
-
- public static readonly VariableStyle SplitOut =
- new VariableStyle() { ParameterStyle = ParameterStyle.SplitOut, ReturnStyle = ReturnStyle.None };
-
- public static readonly VariableStyle MoveIn =
- new VariableStyle() { ParameterStyle = ParameterStyle.MoveIn, ReturnStyle = ReturnStyle.None };
-
- public static readonly VariableStyle SplitIn =
- new VariableStyle() { ParameterStyle = ParameterStyle.SplitIn, ReturnStyle = ReturnStyle.None };
-
- public static readonly VariableStyle NotUsed =
- new VariableStyle() { ParameterStyle = ParameterStyle.MoveOut, ReturnStyle = ReturnStyle.Initialization };
-
- public static readonly VariableStyle Ref =
- new VariableStyle() { ParameterStyle = ParameterStyle.Ref, ReturnStyle = ReturnStyle.AssignmentWithInput };
-
- public static readonly VariableStyle OnlyAsRefParam =
- new VariableStyle() { ParameterStyle = ParameterStyle.Ref, ReturnStyle = ReturnStyle.None };
-
- public static readonly VariableStyle Out =
- new VariableStyle() { ParameterStyle = ParameterStyle.Out, ReturnStyle = ReturnStyle.AssignmentWithNoInput };
-
- public static readonly VariableStyle OutWithErrorInput =
- new VariableStyle() { ParameterStyle = ParameterStyle.Out, ReturnStyle = ReturnStyle.AssignmentWithInput };
-
- public static readonly VariableStyle OutWithMoveOut =
- new VariableStyle() { ParameterStyle = ParameterStyle.OutWithMoveOut, ReturnStyle = ReturnStyle.Initialization };
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/CommonFormattingHelpers.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/CommonFormattingHelpers.cs
deleted file mode 100644
index 673f64030b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/CommonFormattingHelpers.cs
+++ /dev/null
@@ -1,372 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Formatting.Rules;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CommonFormattingHelpers
- {
-// public static readonly Comparison<SuppressOperation> SuppressOperationComparer = (o1, o2) =>
-// {
-// return o1.TextSpan.Start - o2.TextSpan.Start;
-// };
-//
-// public static readonly Comparison<IndentBlockOperation> IndentBlockOperationComparer = (o1, o2) =>
-// {
-// // smaller one goes left
-// var s = o1.TextSpan.Start - o2.TextSpan.Start;
-// if (s != 0)
-// {
-// return s;
-// }
-//
-// // bigger one goes left
-// var e = o2.TextSpan.End - o1.TextSpan.End;
-// if (e != 0)
-// {
-// return e;
-// }
-//
-// return 0;
-// };
-//
-// public static IEnumerable<ValueTuple<SyntaxToken, SyntaxToken>> ConvertToTokenPairs(this SyntaxNode root, IList<TextSpan> spans)
-// {
-// Contract.ThrowIfNull(root);
-// Contract.ThrowIfFalse(spans.Count > 0);
-//
-// if (spans.Count == 1)
-// {
-// // special case, if there is only one span, return right away
-// yield return root.ConvertToTokenPair(spans[0]);
-// yield break;
-// }
-//
-// var pairs = new List<ValueTuple<SyntaxToken, SyntaxToken>>();
-// var previousOne = root.ConvertToTokenPair(spans[0]);
-//
-// // iterate through each spans and make sure each one doesn't overlap each other
-// for (int i = 1; i < spans.Count; i++)
-// {
-// var currentOne = root.ConvertToTokenPair(spans[i]);
-// if (currentOne.Item1.SpanStart <= previousOne.Item2.Span.End)
-// {
-// // oops, looks like two spans are overlapping each other. merge them
-// previousOne = ValueTuple.Create(previousOne.Item1, previousOne.Item2.Span.End < currentOne.Item2.Span.End ? currentOne.Item2 : previousOne.Item2);
-// continue;
-// }
-//
-// // okay, looks like things are in good shape
-// yield return previousOne;
-//
-// // move to next one
-// previousOne = currentOne;
-// }
-//
-// // give out the last one
-// yield return previousOne;
-// }
-//
-// public static ValueTuple<SyntaxToken, SyntaxToken> ConvertToTokenPair(this SyntaxNode root, TextSpan textSpan)
-// {
-// Contract.ThrowIfNull(root);
-// Contract.ThrowIfTrue(textSpan.IsEmpty);
-//
-// var startToken = root.FindToken(textSpan.Start);
-//
-// // empty token, get previous non-zero length token
-// if (startToken.IsMissing)
-// {
-// // if there is no previous token, startToken will be set to SyntaxKind.None
-// startToken = startToken.GetPreviousToken();
-// }
-//
-// // span is on leading trivia
-// if (textSpan.Start < startToken.SpanStart)
-// {
-// // if there is no previous token, startToken will be set to SyntaxKind.None
-// startToken = startToken.GetPreviousToken();
-// }
-//
-// // adjust position where we try to search end token
-// var endToken = (root.FullSpan.End <= textSpan.End) ?
-// root.GetLastToken(includeZeroWidth: true) : root.FindToken(textSpan.End);
-//
-// // empty token, get next token
-// if (endToken.IsMissing)
-// {
-// endToken = endToken.GetNextToken();
-// }
-//
-// // span is on trailing trivia
-// if (endToken.Span.End < textSpan.End)
-// {
-// endToken = endToken.GetNextToken();
-// }
-//
-// // make sure tokens are not SyntaxKind.None
-// startToken = (startToken.RawKind != 0) ? startToken : root.GetFirstToken(includeZeroWidth: true);
-// endToken = (endToken.RawKind != 0) ? endToken : root.GetLastToken(includeZeroWidth: true);
-//
-// // token is in right order
-// Contract.ThrowIfFalse(startToken.Equals(endToken) || startToken.Span.End <= endToken.SpanStart);
-// return ValueTuple.Create(startToken, endToken);
-// }
-//
-// public static bool IsInvalidTokenRange(this SyntaxNode root, SyntaxToken startToken, SyntaxToken endToken)
-// {
-// // given token must be token exist excluding EndOfFile token.
-// if (startToken.RawKind == 0 || endToken.RawKind == 0)
-// {
-// return true;
-// }
-//
-// if (startToken.Equals(endToken))
-// {
-// return false;
-// }
-//
-// // regular case.
-// // start token can't be end of file token and start token must be before end token if it's not the same token.
-// return root.FullSpan.End == startToken.SpanStart || startToken.FullSpan.End > endToken.FullSpan.Start;
-// }
-//
-// public static int GetTokenColumn(this SyntaxTree tree, SyntaxToken token, int tabSize)
-// {
-// Contract.ThrowIfNull(tree);
-// Contract.ThrowIfTrue(token.RawKind == 0);
-//
-// var startPosition = token.SpanStart;
-// var line = tree.GetText().Lines.GetLineFromPosition(startPosition);
-//
-// return line.GetColumnFromLineOffset(startPosition - line.Start, tabSize);
-// }
-//
-// public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
-// {
-// return (token1.RawKind == 0) ? text.ToString(TextSpan.FromBounds(0, token2.SpanStart)) : text.ToString(TextSpan.FromBounds(token1.Span.End, token2.SpanStart));
-// }
-//
- public static string GetTextBetween(SyntaxToken token1, SyntaxToken token2)
- {
- var builder = new StringBuilder();
- AppendTextBetween(token1, token2, builder);
-
- return builder.ToString();
- }
-
- public static void AppendTextBetween(SyntaxToken token1, SyntaxToken token2, StringBuilder builder)
- {
-// Contract.ThrowIfTrue(token1.RawKind == 0 && token2.RawKind == 0);
-// Contract.ThrowIfTrue(token1.Equals(token2));
-//
- if (token1.RawKind == 0)
- {
- AppendLeadingTriviaText(token2, builder);
- return;
- }
-
- if (token2.RawKind == 0)
- {
- AppendTrailingTriviaText(token1, builder);
- return;
- }
-
- //var token1PartOftoken2LeadingTrivia = token1.FullSpan.Start > token2.FullSpan.Start;
-
- if (token1.FullSpan.End == token2.FullSpan.Start)
- {
- AppendTextBetweenTwoAdjacentTokens(token1, token2, builder);
- return;
- }
-
- AppendTrailingTriviaText(token1, builder);
-
- for (var token = token1.GetNextToken(includeZeroWidth: true); token.FullSpan.End <= token2.FullSpan.Start; token = token.GetNextToken(includeZeroWidth: true))
- {
- builder.Append(token.ToFullString());
- }
-
- AppendPartialLeadingTriviaText(token2, builder, token1.TrailingTrivia.FullSpan.End);
- }
-
- private static void AppendTextBetweenTwoAdjacentTokens(SyntaxToken token1, SyntaxToken token2, StringBuilder builder)
- {
- AppendTrailingTriviaText(token1, builder);
- AppendLeadingTriviaText(token2, builder);
- }
-
- private static void AppendLeadingTriviaText(SyntaxToken token, StringBuilder builder)
- {
- if (!token.HasLeadingTrivia)
- {
- return;
- }
-
- foreach (var trivia in token.LeadingTrivia)
- {
- builder.Append(trivia.ToFullString());
- }
- }
-
- /// <summary>
- /// If the token1 is expected to be part of the leading trivia of the token2 then the trivia
- /// before the token1FullSpanEnd, which the fullspan end of the token1 should be ignored
- /// </summary>
- private static void AppendPartialLeadingTriviaText(SyntaxToken token, StringBuilder builder, int token1FullSpanEnd)
- {
- if (!token.HasLeadingTrivia)
- {
- return;
- }
-
- foreach (var trivia in token.LeadingTrivia)
- {
- if (trivia.FullSpan.End <= token1FullSpanEnd)
- {
- continue;
- }
-
- builder.Append(trivia.ToFullString());
- }
- }
-
- private static void AppendTrailingTriviaText(SyntaxToken token, StringBuilder builder)
- {
- if (!token.HasTrailingTrivia)
- {
- return;
- }
-
- foreach (var trivia in token.TrailingTrivia)
- {
- builder.Append(trivia.ToFullString());
- }
- }
-
-// /// <summary>
-// /// this will create a span that includes its trailing trivia of its previous token and leading trivia of its next token
-// /// for example, for code such as "class A { int ...", if given tokens are "A" and "{", this will return span [] of "class[ A { ]int ..."
-// /// which included trailing trivia of "class" which is previous token of "A", and leading trivia of "int" which is next token of "{"
-// /// </summary>
-// public static TextSpan GetSpanIncludingTrailingAndLeadingTriviaOfAdjacentTokens(SyntaxToken startToken, SyntaxToken endToken)
-// {
-// // most of cases we can just ask previous and next token to create the span, but in some corner cases such as omitted token case,
-// // those navigation function doesn't work, so we have to explore the tree ourselves to create rigth span
-// var startPosition = GetStartPositionOfSpan(startToken);
-// var endPosition = GetEndPositionOfSpan(endToken);
-//
-// return TextSpan.FromBounds(startPosition, endPosition);
-// }
-//
-// private static int GetEndPositionOfSpan(SyntaxToken token)
-// {
-// var nextToken = token.GetNextToken();
-// if (nextToken.RawKind != 0)
-// {
-// return nextToken.SpanStart;
-// }
-//
-// var backwardPosition = token.FullSpan.End;
-// var parentNode = GetParentThatContainsGivenSpan(token.Parent, backwardPosition, forward: false);
-// if (parentNode == null)
-// {
-// // reached the end of tree
-// return token.FullSpan.End;
-// }
-//
-// Contract.ThrowIfFalse(backwardPosition < parentNode.FullSpan.End);
-//
-// nextToken = parentNode.FindToken(backwardPosition + 1);
-//
-// Contract.ThrowIfTrue(nextToken.RawKind == 0);
-//
-// return nextToken.SpanStart;
-// }
-//
-// public static int GetStartPositionOfSpan(SyntaxToken token)
-// {
-// var previousToken = token.GetPreviousToken();
-// if (previousToken.RawKind != 0)
-// {
-// return previousToken.Span.End;
-// }
-//
-// // first token in the tree
-// var forwardPosition = token.FullSpan.Start;
-// if (forwardPosition <= 0)
-// {
-// return 0;
-// }
-//
-// var parentNode = GetParentThatContainsGivenSpan(token.Parent, forwardPosition, forward: true);
-// if (parentNode == null)
-// {
-// return Contract.FailWithReturn<int>("This can't happen");
-// }
-//
-// Contract.ThrowIfFalse(parentNode.FullSpan.Start < forwardPosition);
-//
-// previousToken = parentNode.FindToken(forwardPosition + 1);
-//
-// Contract.ThrowIfTrue(previousToken.RawKind == 0);
-//
-// return previousToken.Span.End;
-// }
-//
-// private static SyntaxNode GetParentThatContainsGivenSpan(SyntaxNode node, int position, bool forward)
-// {
-// while (node != null)
-// {
-// var fullSpan = node.FullSpan;
-// if (forward)
-// {
-// if (fullSpan.Start < position)
-// {
-// return node;
-// }
-// }
-// else
-// {
-// if (position > fullSpan.End)
-// {
-// return node;
-// }
-// }
-//
-// node = node.Parent;
-// }
-//
-// return null;
-// }
-//
-// public static bool HasAnyWhitespaceElasticTrivia(SyntaxToken previousToken, SyntaxToken currentToken)
-// {
-// if ((!previousToken.ContainsAnnotations && !currentToken.ContainsAnnotations) ||
-// (!previousToken.HasTrailingTrivia && !currentToken.HasLeadingTrivia))
-// {
-// return false;
-// }
-//
-// return previousToken.TrailingTrivia.HasAnyWhitespaceElasticTrivia() || currentToken.LeadingTrivia.HasAnyWhitespaceElasticTrivia();
-// }
-//
-// public static bool IsNull<T>(T t) where T : class
-// {
-// return t == null;
-// }
-//
-// public static bool IsNotNull<T>(T t) where T : class
-// {
-// return !IsNull(t);
-// }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/FormattingHelpers.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/FormattingHelpers.cs
deleted file mode 100644
index 210aec33e9..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/FormattingHelpers.cs
+++ /dev/null
@@ -1,552 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class FormattingHelpers
- {
- // TODO: Need to determine correct way to handle newlines
- public const string NewLine = "\r\n";
-
- public static string GetIndent(this SyntaxToken token)
- {
- var precedingTrivia = token.GetAllPrecedingTriviaToPreviousToken();
-
- // indent is the spaces/tabs between last new line (if there is one) and end of trivia
- var indent = precedingTrivia.AsString();
- int lastNewLinePos = indent.LastIndexOf(NewLine);
- if (lastNewLinePos != -1)
- {
- int start = lastNewLinePos + NewLine.Length;
- indent = indent.Substring(start, indent.Length - start);
- }
-
- return indent;
- }
-
- public static string ContentBeforeLastNewLine(this IEnumerable<SyntaxTrivia> trivia)
- {
- var leading = trivia.AsString();
- int lastNewLinePos = leading.LastIndexOf(NewLine);
- if (lastNewLinePos == -1)
- {
- return string.Empty;
- }
- else
- {
- return leading.Substring(0, lastNewLinePos);
- }
- }
-
- public static ValueTuple<SyntaxToken, SyntaxToken> GetBracePair(this SyntaxNode node)
- {
- return node.GetBraces();
- }
-
- public static bool IsValidBracePair(this ValueTuple<SyntaxToken, SyntaxToken> bracePair)
- {
- if (bracePair.Item1.IsKind(SyntaxKind.None) ||
- bracePair.Item1.IsMissing ||
- bracePair.Item2.IsKind(SyntaxKind.None))
- {
- return false;
- }
-
- // don't check whether token is actually braces as long as it is not none.
- return true;
- }
-
- public static bool IsOpenParenInParameterList(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.OpenParenToken && token.Parent.Kind() == SyntaxKind.ParameterList;
- }
-
- public static bool IsCloseParenInParameterList(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.CloseParenToken && token.Parent.Kind() == SyntaxKind.ParameterList;
- }
-
- public static bool IsOpenParenInArgumentList(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.OpenParenToken && token.Parent.Kind() == SyntaxKind.ArgumentList;
- }
-
- public static bool IsCloseParenInArgumentList(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.CloseParenToken && token.Parent.Kind() == SyntaxKind.ArgumentList;
- }
-
- public static bool IsColonInTypeBaseList(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.ColonToken && token.Parent.Kind() == SyntaxKind.BaseList;
- }
-
- public static bool IsCommaInArgumentOrParameterList(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.CommaToken && (token.Parent.IsAnyArgumentList() || token.Parent.Kind() == SyntaxKind.ParameterList);
- }
-
- public static bool IsLambdaBodyBlock(this SyntaxNode node)
- {
- if (node.Kind() != SyntaxKind.Block)
- {
- return false;
- }
-
- return node.Parent.Kind() == SyntaxKind.SimpleLambdaExpression ||
- node.Parent.Kind() == SyntaxKind.ParenthesizedLambdaExpression;
- }
-
- public static bool IsAnonymousMethodBlock(this SyntaxNode node)
- {
- if (node.Kind() != SyntaxKind.Block)
- {
- return false;
- }
-
- return node.Parent.Kind() == SyntaxKind.AnonymousMethodExpression;
- }
-
- public static bool IsSemicolonInForStatement(this SyntaxToken token)
- {
- var forStatement = token.Parent as ForStatementSyntax;
- return
- token.Kind() == SyntaxKind.SemicolonToken &&
- forStatement != null &&
- (forStatement.FirstSemicolonToken == token || forStatement.SecondSemicolonToken == token);
- }
-
- public static bool IsSemicolonOfEmbeddedStatement(this SyntaxToken token)
- {
- if (token.Kind() != SyntaxKind.SemicolonToken)
- {
- return false;
- }
-
- var statement = token.Parent as StatementSyntax;
- if (statement == null ||
- statement.GetLastToken() != token)
- {
- return false;
- }
-
- return IsEmbeddedStatement(statement);
- }
-
- public static bool IsCloseBraceOfExpression(this SyntaxToken token)
- {
- if (token.Kind() != SyntaxKind.CloseBraceToken)
- {
- return false;
- }
-
- return token.Parent is ExpressionSyntax;
- }
-
- public static bool IsCloseBraceOfEmbeddedBlock(this SyntaxToken token)
- {
- if (token.Kind() != SyntaxKind.CloseBraceToken)
- {
- return false;
- }
-
- var block = token.Parent as BlockSyntax;
- if (block == null ||
- block.CloseBraceToken != token)
- {
- return false;
- }
-
- return IsEmbeddedStatement(block);
- }
-
- public static bool IsEmbeddedStatement(this SyntaxNode node)
- {
- SyntaxNode statementOrElse = node as StatementSyntax;
- if (statementOrElse == null)
- {
- statementOrElse = node as ElseClauseSyntax;
- }
-
- return statementOrElse != null
- && statementOrElse.Parent != null
- && statementOrElse.Parent.IsEmbeddedStatementOwner();
- }
-
- public static bool IsCommaInEnumDeclaration(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.CommaToken &&
- token.Parent.IsKind(SyntaxKind.EnumDeclaration);
- }
-
- public static bool IsCommaInAnyArgumentsList(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.CommaToken &&
- token.Parent.IsAnyArgumentList();
- }
-
- public static bool IsParenInParenthesizedExpression(this SyntaxToken token)
- {
- var parenthesizedExpression = token.Parent as ParenthesizedExpressionSyntax;
- if (parenthesizedExpression == null)
- {
- return false;
- }
-
- return parenthesizedExpression.OpenParenToken.Equals(token) || parenthesizedExpression.CloseParenToken.Equals(token);
- }
-
- public static bool IsParenInArgumentList(this SyntaxToken token)
- {
- var parent = token.Parent;
- switch (parent.Kind())
- {
- case SyntaxKind.SizeOfExpression:
- var sizeOfExpression = (SizeOfExpressionSyntax)parent;
- return sizeOfExpression.OpenParenToken == token || sizeOfExpression.CloseParenToken == token;
-
- case SyntaxKind.TypeOfExpression:
- var typeOfExpression = (TypeOfExpressionSyntax)parent;
- return typeOfExpression.OpenParenToken == token || typeOfExpression.CloseParenToken == token;
-
- case SyntaxKind.CheckedExpression:
- case SyntaxKind.UncheckedExpression:
- var checkedOfExpression = (CheckedExpressionSyntax)parent;
- return checkedOfExpression.OpenParenToken == token || checkedOfExpression.CloseParenToken == token;
-
- case SyntaxKind.DefaultExpression:
- var defaultExpression = (DefaultExpressionSyntax)parent;
- return defaultExpression.OpenParenToken == token || defaultExpression.CloseParenToken == token;
-
- case SyntaxKind.MakeRefExpression:
- var makeRefExpression = (MakeRefExpressionSyntax)parent;
- return makeRefExpression.OpenParenToken == token || makeRefExpression.CloseParenToken == token;
-
- case SyntaxKind.RefTypeExpression:
- var refTypeOfExpression = (RefTypeExpressionSyntax)parent;
- return refTypeOfExpression.OpenParenToken == token || refTypeOfExpression.CloseParenToken == token;
-
- case SyntaxKind.RefValueExpression:
- var refValueExpression = (RefValueExpressionSyntax)parent;
- return refValueExpression.OpenParenToken == token || refValueExpression.CloseParenToken == token;
-
- case SyntaxKind.ArgumentList:
- var argumentList = (ArgumentListSyntax)parent;
- return argumentList.OpenParenToken == token || argumentList.CloseParenToken == token;
-
- case SyntaxKind.AttributeArgumentList:
- var attributeArgumentList = (AttributeArgumentListSyntax)parent;
- return attributeArgumentList.OpenParenToken == token || attributeArgumentList.CloseParenToken == token;
- }
-
- return false;
- }
-
- public static bool IsCloseParenInStatement(this SyntaxToken token)
- {
- var statement = token.Parent as StatementSyntax;
- if (statement == null)
- {
- return false;
- }
-
- var ifStatement = statement as IfStatementSyntax;
- if (ifStatement != null)
- {
- return ifStatement.CloseParenToken.Equals(token);
- }
-
- var switchStatement = statement as SwitchStatementSyntax;
- if (switchStatement != null)
- {
- return switchStatement.CloseParenToken.Equals(token);
- }
-
- var whileStatement = statement as WhileStatementSyntax;
- if (whileStatement != null)
- {
- return whileStatement.CloseParenToken.Equals(token);
- }
-
- var doStatement = statement as DoStatementSyntax;
- if (doStatement != null)
- {
- return doStatement.CloseParenToken.Equals(token);
- }
-
- var forStatement = statement as ForStatementSyntax;
- if (forStatement != null)
- {
- return forStatement.CloseParenToken.Equals(token);
- }
-
- var foreachStatement = statement as ForEachStatementSyntax;
- if (foreachStatement != null)
- {
- return foreachStatement.CloseParenToken.Equals(token);
- }
-
- var lockStatement = statement as LockStatementSyntax;
- if (lockStatement != null)
- {
- return lockStatement.CloseParenToken.Equals(token);
- }
-
- var usingStatement = statement as UsingStatementSyntax;
- if (usingStatement != null)
- {
- return usingStatement.CloseParenToken.Equals(token);
- }
-
- return false;
- }
-
- public static bool IsDotInMemberAccessOrQualifiedName(this SyntaxToken token)
- {
- return token.IsDotInMemberAccess() || (token.Kind() == SyntaxKind.DotToken && token.Parent.Kind() == SyntaxKind.QualifiedName);
- }
-
- public static bool IsDotInMemberAccess(this SyntaxToken token)
- {
- var memberAccess = token.Parent as MemberAccessExpressionSyntax;
- if (memberAccess == null)
- {
- return false;
- }
-
- return token.Kind() == SyntaxKind.DotToken
- && memberAccess.OperatorToken.Equals(token);
- }
-
- public static bool IsGenericGreaterThanToken(this SyntaxToken token)
- {
- if (token.Kind() == SyntaxKind.GreaterThanToken)
- {
- return token.Parent.IsKind(SyntaxKind.TypeParameterList, SyntaxKind.TypeArgumentList);
- }
-
- return false;
- }
-
- public static bool IsCommaInInitializerExpression(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.CommaToken &&
- ((token.Parent is InitializerExpressionSyntax) ||
- (token.Parent is AnonymousObjectCreationExpressionSyntax));
- }
-
- public static bool IsIdentiferInLabeledStatement(this SyntaxToken token)
- {
- var labeledStatement = token.Parent as LabeledStatementSyntax;
- return token.Kind() == SyntaxKind.IdentifierToken &&
- labeledStatement != null &&
- labeledStatement.Identifier == token;
- }
-
- public static bool IsColonInSwitchLabel(this SyntaxToken token)
- {
- return FormattingRangeHelper.IsColonInSwitchLabel(token);
- }
-
- public static bool IsColonInLabeledStatement(this SyntaxToken token)
- {
- var labeledStatement = token.Parent as LabeledStatementSyntax;
- return token.Kind() == SyntaxKind.ColonToken &&
- labeledStatement != null &&
- labeledStatement.ColonToken == token;
- }
-
- public static bool IsEmbeddedStatementOwnerWithCloseParen(this SyntaxNode node)
- {
- return node is IfStatementSyntax ||
- node is WhileStatementSyntax ||
- node is ForStatementSyntax ||
- node is ForEachStatementSyntax ||
- node is UsingStatementSyntax;
- }
-
- public static bool IsNestedQueryExpression(this SyntaxToken token)
- {
- var fromClause = token.Parent as FromClauseSyntax;
- return token.Kind() == SyntaxKind.InKeyword &&
- fromClause != null &&
- fromClause.Expression is QueryExpressionSyntax;
- }
-
- public static bool IsFirstFromKeywordInExpression(this SyntaxToken token)
- {
- var queryExpression = token.Parent.Parent as QueryExpressionSyntax;
- return token.Kind() == SyntaxKind.FromKeyword &&
- queryExpression != null &&
- queryExpression.GetFirstToken().Equals(token);
- }
-
- public static bool IsInitializerForObjectOrAnonymousObjectCreationExpression(this SyntaxNode node)
- {
- var initializer = node as InitializerExpressionSyntax;
- AnonymousObjectMemberDeclaratorSyntax anonymousObjectInitializer = null;
- if (initializer == null)
- {
- anonymousObjectInitializer = node as AnonymousObjectMemberDeclaratorSyntax;
- if (anonymousObjectInitializer == null)
- {
- return false;
- }
- }
-
- var parent = initializer != null ? initializer.Parent : anonymousObjectInitializer.Parent;
- if (parent is AnonymousObjectCreationExpressionSyntax)
- {
- return true;
- }
-
- if (parent is ObjectCreationExpressionSyntax)
- {
- if (initializer.Expressions.Count <= 0)
- {
- return true;
- }
-
- var expression = initializer.Expressions[0];
- if (expression.Kind() == SyntaxKind.SimpleAssignmentExpression)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsInitializerForArrayOrCollectionCreationExpression(this SyntaxNode node)
- {
- var initializer = node as InitializerExpressionSyntax;
- AnonymousObjectMemberDeclaratorSyntax anonymousObjectInitializer = null;
- if (initializer == null)
- {
- anonymousObjectInitializer = node as AnonymousObjectMemberDeclaratorSyntax;
- if (anonymousObjectInitializer == null)
- {
- return false;
- }
- }
-
- var parent = initializer != null ? initializer.Parent : anonymousObjectInitializer.Parent;
- if (parent is ArrayCreationExpressionSyntax ||
- parent is ImplicitArrayCreationExpressionSyntax ||
- parent is EqualsValueClauseSyntax ||
- parent.Kind() == SyntaxKind.SimpleAssignmentExpression)
- {
- return true;
- }
-
- if (parent is ObjectCreationExpressionSyntax)
- {
- return !IsInitializerForObjectOrAnonymousObjectCreationExpression(initializer);
- }
-
- return false;
- }
-
- public static bool ParenOrBracketContainsNothing(this SyntaxToken token1, SyntaxToken token2)
- {
- return (token1.Kind() == SyntaxKind.OpenParenToken && token2.Kind() == SyntaxKind.CloseParenToken) ||
- (token1.Kind() == SyntaxKind.OpenBracketToken && token2.Kind() == SyntaxKind.CloseBracketToken);
- }
-
- public static bool IsLastTokenInLabelStatement(this SyntaxToken token)
- {
- if (token.Kind() != SyntaxKind.SemicolonToken && token.Kind() != SyntaxKind.CloseBraceToken)
- {
- return false;
- }
-
- if (token.Parent == null)
- {
- return false;
- }
-
- return token.Parent.Parent is LabeledStatementSyntax;
- }
-
- public static ValueTuple<SyntaxToken, SyntaxToken> GetFirstAndLastMemberDeclarationTokensAfterAttributes(this MemberDeclarationSyntax node)
- {
- // Contract.ThrowIfNull(node);
-
- // there are no attributes associated with the node. return back first and last token of the node.
- var attributes = node.GetAttributes();
- if (attributes.Count == 0)
- {
- return ValueTuple.Create(node.GetFirstToken(includeZeroWidth: true), node.GetLastToken(includeZeroWidth: true));
- }
-
- var lastToken = node.GetLastToken(includeZeroWidth: true);
- var lastAttributeToken = attributes.Last().GetLastToken(includeZeroWidth: true);
- if (lastAttributeToken.Equals(lastToken))
- {
- return ValueTuple.Create(default(SyntaxToken), default(SyntaxToken));
- }
-
- var firstTokenAfterAttribute = lastAttributeToken.GetNextToken(includeZeroWidth: true);
-
- // there are attributes, get first token after the tokens belong to attributes
- return ValueTuple.Create(firstTokenAfterAttribute, lastToken);
- }
-
- public static bool IsBlockBody(this SyntaxNode node)
- {
- // Contract.ThrowIfNull(node);
-
- var blockNode = node as BlockSyntax;
- if (blockNode == null)
- {
- return false;
- }
-
- switch (blockNode.Parent.Kind())
- {
- case SyntaxKind.AnonymousMethodExpression:
- case SyntaxKind.CheckedStatement:
- case SyntaxKind.UncheckedStatement:
- case SyntaxKind.UnsafeStatement:
- case SyntaxKind.TryStatement:
- case SyntaxKind.CatchClause:
- case SyntaxKind.FinallyClause:
- case SyntaxKind.MethodDeclaration:
- case SyntaxKind.OperatorDeclaration:
- case SyntaxKind.ConversionOperatorDeclaration:
- case SyntaxKind.ConstructorDeclaration:
- case SyntaxKind.DestructorDeclaration:
- case SyntaxKind.AddAccessorDeclaration:
- case SyntaxKind.GetAccessorDeclaration:
- case SyntaxKind.SetAccessorDeclaration:
- case SyntaxKind.RemoveAccessorDeclaration:
- case SyntaxKind.UnknownAccessorDeclaration:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsPlusOrMinusExpression(this SyntaxToken token)
- {
- if (token.Kind() != SyntaxKind.PlusToken && token.Kind() != SyntaxKind.MinusToken)
- {
- return false;
- }
-
- return token.Parent is PrefixUnaryExpressionSyntax;
- }
-
- public static bool IsInterpolation(this SyntaxToken currentToken)
- {
- return currentToken.Parent.IsKind(SyntaxKind.Interpolation);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/FormattingRangeHelper.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/FormattingRangeHelper.cs
deleted file mode 100644
index 492868b050..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/FormattingRangeHelper.cs
+++ /dev/null
@@ -1,434 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Formatting;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- /// <summary>
- /// this help finding a range of tokens to format based on given ending token
- /// </summary>
- static class FormattingRangeHelper
- {
- public static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRange(SyntaxToken endToken, bool useDefaultRange = true)
- {
- // Contract.ThrowIfTrue(endToken.Kind() == SyntaxKind.None);
-
- return FixupOpenBrace(FindAppropriateRangeWorker(endToken, useDefaultRange));
- }
-
- private static ValueTuple<SyntaxToken, SyntaxToken>? FixupOpenBrace(ValueTuple<SyntaxToken, SyntaxToken>? tokenRange)
- {
- if (!tokenRange.HasValue)
- {
- return tokenRange;
- }
-
- // with a auto brace completion which will do auto formatting when a user types "{", it is quite common that we will automatically put a space
- // between "{" and "}". but user might blindly type without knowing that " " has automatically inserted for him. and ends up have two spaces.
- // for those cases, whenever we see previous token of the range is "{", we expand the range to include preceeding "{"
- var currentToken = tokenRange.Value.Item1;
- var previousToken = currentToken.GetPreviousToken();
-
- while (currentToken.Kind() != SyntaxKind.CloseBraceToken && previousToken.Kind() == SyntaxKind.OpenBraceToken)
- {
- var pair = previousToken.Parent.GetBracePair();
- if (pair.Item2.Kind() == SyntaxKind.None || !AreTwoTokensOnSameLine(previousToken, pair.Item2))
- {
- return ValueTuple.Create(currentToken, tokenRange.Value.Item2);
- }
-
- currentToken = previousToken;
- previousToken = currentToken.GetPreviousToken();
- }
-
- return ValueTuple.Create(currentToken, tokenRange.Value.Item2);
- }
-
- private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeWorker(SyntaxToken endToken, bool useDefaultRange)
- {
- // special token that we know how to find proper starting token
- switch (endToken.Kind())
- {
- case SyntaxKind.CloseBraceToken:
- {
- return FindAppropriateRangeForCloseBrace(endToken);
- }
-
- case SyntaxKind.SemicolonToken:
- {
- return FindAppropriateRangeForSemicolon(endToken);
- }
-
- case SyntaxKind.ColonToken:
- {
- return FindAppropriateRangeForColon(endToken);
- }
-
- default:
- {
- // default case
- if (!useDefaultRange)
- {
- return null;
- }
-
- // if given token is skipped token, don't bother to find appropriate
- // starting point
- if (endToken.Kind() == SyntaxKind.SkippedTokensTrivia)
- {
- return null;
- }
-
- var parent = endToken.Parent;
- if (parent == null)
- {
- // if there is no parent setup yet, nothing we can do here.
- return null;
- }
-
- // if we are called due to things in trivia or literals, don't bother
- // finding a starting token
- if (parent.Kind() == SyntaxKind.StringLiteralExpression ||
- parent.Kind() == SyntaxKind.CharacterLiteralExpression)
- {
- return null;
- }
-
- // format whole node that containing the end token + its previous one
- // to do indentation
- return ValueTuple.Create(GetAppropriatePreviousToken(parent.GetFirstToken()), parent.GetLastToken());
- }
- }
- }
-
- private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeForSemicolon(SyntaxToken endToken)
- {
- var parent = endToken.Parent;
- if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia)
- {
- return null;
- }
-
- if ((parent is UsingDirectiveSyntax) ||
- (parent is DelegateDeclarationSyntax) ||
- (parent is FieldDeclarationSyntax) ||
- (parent is EventFieldDeclarationSyntax) ||
- (parent is MethodDeclarationSyntax))
- {
- return ValueTuple.Create(GetAppropriatePreviousToken(parent.GetFirstToken(), canTokenBeFirstInABlock: true), parent.GetLastToken());
- }
-
- if (parent is AccessorDeclarationSyntax)
- {
- // if both accessors are on the same line, format the accessor list
- // { get; set; }
- var propertyDeclaration = GetEnclosingMember(endToken) as PropertyDeclarationSyntax;
- if (propertyDeclaration != null &&
- AreTwoTokensOnSameLine(propertyDeclaration.AccessorList.OpenBraceToken, propertyDeclaration.AccessorList.CloseBraceToken))
- {
- return ValueTuple.Create(propertyDeclaration.AccessorList.OpenBraceToken, propertyDeclaration.AccessorList.CloseBraceToken);
- }
-
- // otherwise, just format the accessor
- return ValueTuple.Create(GetAppropriatePreviousToken(parent.GetFirstToken(), canTokenBeFirstInABlock: true), parent.GetLastToken());
- }
-
- if (parent is StatementSyntax && !endToken.IsSemicolonInForStatement())
- {
- var container = GetTopContainingNode(parent);
- if (container == null)
- {
- return ValueTuple.Create(GetAppropriatePreviousToken(parent.GetFirstToken()), parent.GetLastToken());
- }
-
- if (IsSpecialContainingNode(container))
- {
- return ValueTuple.Create(GetAppropriatePreviousToken(container.GetFirstToken()), container.GetLastToken());
- }
-
- return ValueTuple.Create(GetAppropriatePreviousToken(parent.GetFirstToken(), canTokenBeFirstInABlock: true), parent.GetLastToken());
- }
-
- // don't do anything
- return null;
- }
-
- private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeForCloseBrace(SyntaxToken endToken)
- {
- // don't do anything if there is no proper parent
- var parent = endToken.Parent;
- if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia)
- {
- return null;
- }
-
- // cases such as namespace, type, enum, method almost any top level elements
- if (parent is MemberDeclarationSyntax ||
- parent is SwitchStatementSyntax)
- {
- return ValueTuple.Create(GetAppropriatePreviousToken(parent.GetFirstToken()), parent.GetLastToken());
- }
-
- // property decl body or initializer
- if (parent is AccessorListSyntax)
- {
- // include property decl
- var containerOfList = parent.Parent;
- if (containerOfList == null)
- {
- return ValueTuple.Create(GetAppropriatePreviousToken(parent.GetFirstToken()), parent.GetLastToken());
- }
-
- return ValueTuple.Create(containerOfList.GetFirstToken(), containerOfList.GetLastToken());
- }
-
- if (parent is AnonymousObjectCreationExpressionSyntax)
- {
- return ValueTuple.Create(parent.GetFirstToken(), parent.GetLastToken());
- }
-
- if (parent is InitializerExpressionSyntax)
- {
- var parentOfParent = parent.Parent;
- if (parentOfParent == null)
- {
- return ValueTuple.Create(GetAppropriatePreviousToken(parent.GetFirstToken()), parent.GetLastToken());
- }
-
- // double initializer case such as
- // { { }
- var doubleInitializer = parentOfParent as InitializerExpressionSyntax;
- if (doubleInitializer != null)
- {
- // if parent block has a missing brace, and current block is on same line, then
- // don't try to indent inner block.
- var firstTokenOfInnerBlock = parent.GetFirstToken();
- var lastTokenOfInnerBlock = parent.GetLastToken();
-
- var twoTokensOnSameLine = AreTwoTokensOnSameLine(firstTokenOfInnerBlock, lastTokenOfInnerBlock);
- if (twoTokensOnSameLine)
- {
- return ValueTuple.Create(firstTokenOfInnerBlock, lastTokenOfInnerBlock);
- }
- }
-
- // include owner of the initializer node such as creation node
- return ValueTuple.Create(parentOfParent.GetFirstToken(), parentOfParent.GetLastToken());
- }
-
- if (parent is BlockSyntax)
- {
- var containerOfBlock = GetTopContainingNode(parent);
- if (containerOfBlock == null)
- {
- return ValueTuple.Create(GetAppropriatePreviousToken(parent.GetFirstToken()), parent.GetLastToken());
- }
-
- // things like method, constructor, etc and special cases
- if (containerOfBlock is MemberDeclarationSyntax ||
- IsSpecialContainingNode(containerOfBlock))
- {
- return ValueTuple.Create(GetAppropriatePreviousToken(containerOfBlock.GetFirstToken()), containerOfBlock.GetLastToken());
- }
-
- // double block case on single line case
- // { { }
- if (containerOfBlock is BlockSyntax)
- {
- // if parent block has a missing brace, and current block is on same line, then
- // don't try to indent inner block.
- var firstTokenOfInnerBlock = parent.GetFirstToken();
- var lastTokenOfInnerBlock = parent.GetLastToken();
-
- var twoTokensOnSameLine = AreTwoTokensOnSameLine(firstTokenOfInnerBlock, lastTokenOfInnerBlock);
- if (twoTokensOnSameLine)
- {
- return ValueTuple.Create(firstTokenOfInnerBlock, lastTokenOfInnerBlock);
- }
- }
-
- // okay, for block, indent regardless whether it is first one on the line
- return ValueTuple.Create(GetPreviousTokenIfNotFirstTokenInTree(parent.GetFirstToken()), parent.GetLastToken());
- }
-
- // don't do anything
- return null;
- }
-
- private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeForColon(SyntaxToken endToken)
- {
- // don't do anything if there is no proper parent
- var parent = endToken.Parent;
- if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia)
- {
- return null;
- }
-
- // cases such as namespace, type, enum, method almost any top level elements
- if (IsColonInSwitchLabel(endToken))
- {
- return ValueTuple.Create(GetPreviousTokenIfNotFirstTokenInTree(parent.GetFirstToken()), parent.GetLastToken());
- }
-
- return null;
- }
-
- private static SyntaxToken GetPreviousTokenIfNotFirstTokenInTree(SyntaxToken token)
- {
- var previousToken = token.GetPreviousToken();
- return previousToken.Kind() == SyntaxKind.None ? token : previousToken;
- }
-
- private static bool AreTwoTokensOnSameLine(SyntaxToken token1, SyntaxToken token2)
- {
- var tree = token1.SyntaxTree;
- var text = default(SourceText);
- if (tree != null && tree.TryGetText(out text))
- {
- var line1 = text.Lines.IndexOf(token1.Span.End);
- var line2 = text.Lines.IndexOf(token2.SpanStart);
-
- return line1 == line2;
- }
-
- return CommonFormattingHelpers.GetTextBetween(token1, token2).ContainsLineBreak();
- }
-
- private static SyntaxToken GetAppropriatePreviousToken(SyntaxToken startToken, bool canTokenBeFirstInABlock = false)
- {
- var previousToken = startToken.GetPreviousToken();
- if (previousToken.Kind() == SyntaxKind.None)
- {
- // no previous token, return as it is
- return startToken;
- }
-
- if (AreTwoTokensOnSameLine(previousToken, startToken))
- {
- // The previous token can be '{' of a block and type declaration
- // { int s = 0;
- if (canTokenBeFirstInABlock)
- {
- if (IsOpenBraceTokenOfABlockOrTypeOrNamespace(previousToken))
- {
- return previousToken;
- }
- }
-
- // there is another token on same line.
- return startToken;
- }
-
- // start token is the first token on line
-
- // now check a special case where previous token belongs to a label.
- if (previousToken.IsLastTokenInLabelStatement())
- {
- var labelNode = previousToken.Parent.Parent;
- return GetAppropriatePreviousToken(labelNode.GetFirstToken());
- }
-
- return previousToken;
- }
-
- private static bool IsOpenBraceTokenOfABlockOrTypeOrNamespace(SyntaxToken previousToken)
- {
- return previousToken.IsKind(SyntaxKind.OpenBraceToken) &&
- (previousToken.Parent.IsKind(SyntaxKind.Block) ||
- previousToken.Parent is TypeDeclarationSyntax ||
- previousToken.Parent is NamespaceDeclarationSyntax);
- }
-
- private static bool IsSpecialContainingNode(SyntaxNode node)
- {
- return
- node.Kind() == SyntaxKind.IfStatement ||
- node.Kind() == SyntaxKind.ElseClause ||
- node.Kind() == SyntaxKind.WhileStatement ||
- node.Kind() == SyntaxKind.ForStatement ||
- node.Kind() == SyntaxKind.ForEachStatement ||
- node.Kind() == SyntaxKind.UsingStatement ||
- node.Kind() == SyntaxKind.DoStatement ||
- node.Kind() == SyntaxKind.TryStatement ||
- node.Kind() == SyntaxKind.CatchClause ||
- node.Kind() == SyntaxKind.FinallyClause ||
- node.Kind() == SyntaxKind.LabeledStatement;
- }
-
- private static SyntaxNode GetTopContainingNode(SyntaxNode node)
- {
- node = node.Parent;
- if (!IsSpecialContainingNode(node))
- {
- return node;
- }
-
- var lastSpecialContainingNode = node;
- node = node.Parent;
-
- while (node != null)
- {
- if (!IsSpecialContainingNode(node))
- {
- return lastSpecialContainingNode;
- }
-
- lastSpecialContainingNode = node;
- node = node.Parent;
- }
-
- return null;
- }
-
- public static bool IsColonInSwitchLabel(SyntaxToken token)
- {
- var switchLabel = token.Parent as SwitchLabelSyntax;
- return token.Kind() == SyntaxKind.ColonToken &&
- switchLabel != null &&
- switchLabel.ColonToken == token;
- }
-
- public static bool InBetweenTwoMembers(SyntaxToken previousToken, SyntaxToken currentToken)
- {
- if (previousToken.Kind() != SyntaxKind.SemicolonToken && previousToken.Kind() != SyntaxKind.CloseBraceToken)
- {
- return false;
- }
-
- if (currentToken.Kind() == SyntaxKind.CloseBraceToken)
- {
- return false;
- }
-
- var previousMember = GetEnclosingMember(previousToken);
- var nextMember = GetEnclosingMember(currentToken);
-
- return previousMember != null
- && nextMember != null
- && previousMember != nextMember;
- }
-
- public static MemberDeclarationSyntax GetEnclosingMember(SyntaxToken token)
- {
- if (token.Kind() == SyntaxKind.CloseBraceToken)
- {
- if (token.Parent.Kind() == SyntaxKind.Block ||
- token.Parent.Kind() == SyntaxKind.AccessorList)
- {
- return token.Parent.Parent as MemberDeclarationSyntax;
- }
- }
-
- return token.Parent.FirstAncestorOrSelf<MemberDeclarationSyntax>();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/AbstractCodeRefactoringResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/AbstractCodeRefactoringResult.cs
deleted file mode 100644
index 3e6736f98b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/AbstractCodeRefactoringResult.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using RefactoringEssentials;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateFromMembers
-{
- abstract class AbstractCodeRefactoringResult
- {
- private readonly CodeRefactoring _codeRefactoring;
-
- protected AbstractCodeRefactoringResult(CodeRefactoring codeRefactoring)
- {
- _codeRefactoring = codeRefactoring;
- }
-
- public bool ContainsChanges
- {
- get
- {
- return _codeRefactoring != null;
- }
- }
-
- public CodeRefactoring GetCodeRefactoring(CancellationToken cancellationToken)
- {
- return _codeRefactoring;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/AbstractGenerateFromMembersService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/AbstractGenerateFromMembersService.cs
deleted file mode 100644
index 05087c3b7a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/AbstractGenerateFromMembersService.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using RefactoringEssentials;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateFromMembers
-{
- abstract class AbstractGenerateFromMembersService<TMemberDeclarationSyntax>
- where TMemberDeclarationSyntax : SyntaxNode
- {
- protected AbstractGenerateFromMembersService()
- {
- }
-
- protected abstract Task<IList<TMemberDeclarationSyntax>> GetSelectedMembersAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken);
- protected abstract IEnumerable<ISymbol> GetDeclaredSymbols(SemanticModel semanticModel, TMemberDeclarationSyntax memberDeclaration, CancellationToken cancellationToken);
-
- protected class SelectedMemberInfo
- {
- public INamedTypeSymbol ContainingType;
- public IList<TMemberDeclarationSyntax> SelectedDeclarations;
- public IList<ISymbol> SelectedMembers;
- }
-
- protected async Task<SelectedMemberInfo> GetSelectedMemberInfoAsync(
- Document document, TextSpan textSpan, CancellationToken cancellationToken)
- {
- var selectedDeclarations = await this.GetSelectedMembersAsync(document, textSpan, cancellationToken).ConfigureAwait(false);
-
- if (selectedDeclarations.Count > 0)
- {
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var selectedMembers = selectedDeclarations.SelectMany(
- d => this.GetDeclaredSymbols(semanticModel, d, cancellationToken)).WhereNotNull().ToList();
- if (selectedMembers.Count > 0)
- {
- var containingType = selectedMembers.First().ContainingType;
- if (containingType != null)
- {
- return new SelectedMemberInfo { ContainingType = containingType, SelectedDeclarations = selectedDeclarations, SelectedMembers = selectedMembers };
- }
- }
- }
-
- return null;
- }
-
- protected static bool IsWritableInstanceFieldOrProperty(ISymbol symbol)
- {
- // Can use non const fields and properties with setters in them.
- return
- IsInstanceFieldOrProperty(symbol) &&
- IsWritableFieldOrProperty(symbol);
- }
-
- private static bool IsWritableFieldOrProperty(ISymbol symbol)
- {
- return symbol.TypeSwitch(
- (IFieldSymbol field) => !field.IsConst,
- (IPropertySymbol property) => property.SetMethod != null);
- }
-
- protected static bool IsInstanceFieldOrProperty(ISymbol symbol)
- {
- return !symbol.IsStatic && (IsField(symbol) || IsProperty(symbol));
- }
-
- private static bool IsProperty(ISymbol symbol)
- {
- return symbol.Kind == SymbolKind.Property;
- }
-
- private static bool IsField(ISymbol symbol)
- {
- return symbol.Kind == SymbolKind.Field;
- }
-
- protected CodeRefactoring CreateCodeRefactoring(
- IList<TMemberDeclarationSyntax> selectedDeclarations,
- IEnumerable<CodeAction> actions)
- {
- #if false
- var lastDeclaration = selectedDeclarations.Last();
- var endSpan = new TextSpan(lastDeclaration.Span.End - 1, 1);
- return new CodeRefactoring(actions, endSpan);
- #endif
- return new CodeRefactoring(null, actions);
- }
-
- protected List<IParameterSymbol> DetermineParameters(
- IList<ISymbol> selectedMembers)
- {
- var parameters = new List<IParameterSymbol>();
-
- foreach (var symbol in selectedMembers)
- {
- var type = symbol is IFieldSymbol
- ? ((IFieldSymbol)symbol).Type
- : ((IPropertySymbol)symbol).Type;
-
- parameters.Add(CodeGenerationSymbolFactory.CreateParameterSymbol(
- attributes: null,
- refKind: RefKind.None,
- isParams: false,
- type: type,
- name: symbol.Name.ToCamelCase()));
- }
-
- return parameters;
- }
-
- protected IMethodSymbol GetDelegatedConstructor(
- INamedTypeSymbol containingType,
- List<IParameterSymbol> parameters)
- {
- var q =
- from c in containingType.InstanceConstructors
- orderby c.Parameters.Length descending
- where c.Parameters.Length > 0 && c.Parameters.Length < parameters.Count
- where c.Parameters.All(p => p.RefKind == RefKind.None) && !c.Parameters.Any(p => p.IsParams)
- let constructorTypes = c.Parameters.Select(p => p.Type)
- let symbolTypes = parameters.Take(c.Parameters.Length).Select(p => p.Type)
- where constructorTypes.SequenceEqual(symbolTypes)
- select c;
-
- return q.FirstOrDefault();
- }
-
- protected bool HasMatchingConstructor(
- INamedTypeSymbol containingType,
- List<IParameterSymbol> parameters)
- {
- return containingType.InstanceConstructors.Any(c => MatchesConstructor(c, parameters));
- }
-
- private bool MatchesConstructor(
- IMethodSymbol constructor,
- List<IParameterSymbol> parameters)
- {
- return parameters.Select(p => p.Type).SequenceEqual(constructor.Parameters.Select(p => p.Type));
- }
-
- protected static readonly SymbolDisplayFormat SimpleFormat =
- new SymbolDisplayFormat(
- typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly,
- genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
- parameterOptions: SymbolDisplayParameterOptions.IncludeParamsRefOut | SymbolDisplayParameterOptions.IncludeType,
- miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes);
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/AbstractGenerateConstructorService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/AbstractGenerateConstructorService.cs
deleted file mode 100644
index a40512e2bd..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/AbstractGenerateConstructorService.cs
+++ /dev/null
@@ -1,263 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Editing;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using System.Linq;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateFromMembers.GenerateConstructor
-{
- abstract partial class AbstractGenerateConstructorService<TService, TMemberDeclarationSyntax> :
- AbstractGenerateFromMembersService<TMemberDeclarationSyntax>
- where TService : AbstractGenerateConstructorService<TService, TMemberDeclarationSyntax>
- where TMemberDeclarationSyntax : SyntaxNode
- {
- protected AbstractGenerateConstructorService()
- {
- }
-
- public async Task<GenerateConstructorResult> GenerateConstructorAsync(
- Document document, TextSpan textSpan, CancellationToken cancellationToken)
- {
-// using (Logger.LogBlock(FunctionId.Refactoring_GenerateFromMembers_GenerateConstructor, cancellationToken))
-// {
- var info = await GetSelectedMemberInfoAsync(document, textSpan, cancellationToken).ConfigureAwait(false);
- if (info != null)
- {
- var state = State.Generate((TService)this, document, textSpan, info.ContainingType, info.SelectedMembers, cancellationToken);
- if (state != null)
- {
- return new GenerateConstructorResult(
- CreateCodeRefactoring(info.SelectedDeclarations, GetCodeActions(document, state)));
- }
- }
-
- return GenerateConstructorResult.Failure;
-// }
- }
-
- private IEnumerable<CodeAction> GetCodeActions(Document document, State state)
- {
- yield return new FieldDelegatingCodeAction((TService)this, document, state);
- if (state.DelegatedConstructor != null)
- {
- yield return new ConstructorDelegatingCodeAction((TService)this, document, state);
- }
- }
-
- private class ConstructorDelegatingCodeAction : CodeAction
- {
- private readonly Document _document;
- private readonly State _state;
-
- public ConstructorDelegatingCodeAction(
- TService service,
- Document document,
- State state)
- {
- _document = document;
- _state = state;
- }
-
- protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- // First, see if there are any constructors that would take the first 'n' arguments
- // we've provided. If so, delegate to those, and then create a field for any
- // remaining arguments. Try to match from largest to smallest.
- //
- // Otherwise, just generate a normal constructor that assigns any provided
- // parameters into fields.
- var provider = _document.Project.Solution.Workspace.Services.GetLanguageServices(_state.ContainingType.Language);
- var factory = provider.GetService<SyntaxGenerator>();
-
- var thisConstructorArguments = _state.DelegatedConstructor.Parameters.Select (par => factory.Argument (par.RefKind, SyntaxFactory.IdentifierName (par.Name))).ToList ();
- var statements = new List<SyntaxNode>();
-
- for (var i = _state.DelegatedConstructor.Parameters.Length; i < _state.Parameters.Count; i++)
- {
- var symbolName = _state.SelectedMembers[i].Name;
- var parameterName = _state.Parameters[i].Name;
- var assignExpression = factory.AssignmentStatement(
- factory.MemberAccessExpression(
- factory.ThisExpression(),
- factory.IdentifierName(symbolName)),
- factory.IdentifierName(parameterName));
-
- var expressionStatement = factory.ExpressionStatement(assignExpression);
- statements.Add(expressionStatement);
- }
-
- var syntaxTree = await _document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
- var codeGenerationService = new CSharpCodeGenerationService (_document.Project.Solution.Workspace.Services.GetLanguageServices (LanguageNames.CSharp));
- var result = await codeGenerationService.AddMethodAsync(
- _document.Project.Solution,
- _state.ContainingType,
- CodeGenerationSymbolFactory.CreateConstructorSymbol(
- attributes: null,
- accessibility: Accessibility.Public,
- modifiers: new DeclarationModifiers(),
- typeName: _state.ContainingType.Name,
- parameters: _state.Parameters,
- statements: statements,
- thisConstructorArguments: thisConstructorArguments),
- new CodeGenerationOptions(contextLocation: syntaxTree.GetLocation(_state.TextSpan), generateDefaultAccessibility: false),
- cancellationToken: cancellationToken)
- .ConfigureAwait(false);
-
- return result;
- }
-
- public override string Title
- {
- get
- {
- // var symbolDisplayService = _document.GetLanguageService<ISymbolDisplayService>();
- var parameters = _state.Parameters.Select(p => p.ToDisplayString(SimpleFormat));
- var parameterString = string.Join(", ", parameters);
-
- return string.Format(Resources.GenerateDelegatingConstructor,
- _state.ContainingType.Name, parameterString);
- }
- }
- }
-
- private class FieldDelegatingCodeAction : CodeAction
- {
- private readonly Document _document;
- private readonly State _state;
-
- public FieldDelegatingCodeAction(
- TService service,
- Document document,
- State state)
- {
- _document = document;
- _state = state;
- }
-
- protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- // First, see if there are any constructors that would take the first 'n' arguments
- // we've provided. If so, delegate to those, and then create a field for any
- // remaining arguments. Try to match from largest to smallest.
- //
- // Otherwise, just generate a normal constructor that assigns any provided
- // parameters into fields.
- var parameterToExistingFieldMap = new Dictionary<string, ISymbol>();
- for (int i = 0; i < _state.Parameters.Count; i++)
- {
- parameterToExistingFieldMap[_state.Parameters[i].Name] = _state.SelectedMembers[i];
- }
-
- var factory = _document.GetLanguageService<SyntaxGenerator>();
-
- var syntaxTree = await _document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
- var members = factory.CreateFieldDelegatingConstructor(
- _state.ContainingType.Name,
- _state.ContainingType,
- _state.Parameters,
- parameterToExistingFieldMap,
- parameterToNewFieldMap: null,
- cancellationToken: cancellationToken);
- var codeGenerationService = new CSharpCodeGenerationService (_document.Project.Solution.Workspace.Services.GetLanguageServices (LanguageNames.CSharp));
-
- var result = await codeGenerationService.AddMembersAsync(
- _document.Project.Solution,
- _state.ContainingType,
- members,
- new CodeGenerationOptions(contextLocation: syntaxTree.GetLocation(_state.TextSpan), generateDefaultAccessibility: false),
- cancellationToken)
- .ConfigureAwait(false);
-
- return result;
- }
-
-
- public override string Title
- {
- get
- {
- var parameters = _state.Parameters.Select(p => p.ToDisplayString(SimpleFormat));
- var parameterString = string.Join(", ", parameters);
-
- if (_state.DelegatedConstructor == null)
- {
- return string.Format(Resources.GenerateConstructor,
- _state.ContainingType.Name, parameterString);
- }
- else
- {
- return string.Format(Resources.GenerateFieldAssigningConstructor,
- _state.ContainingType.Name, parameterString);
- }
- }
- }
- }
-
-
- private class State
- {
- public TextSpan TextSpan { get; private set; }
- public IMethodSymbol DelegatedConstructor { get; private set; }
- public INamedTypeSymbol ContainingType { get; private set; }
- public IList<ISymbol> SelectedMembers { get; private set; }
- public List<IParameterSymbol> Parameters { get; private set; }
-
- public static State Generate(
- TService service,
- Document document,
- TextSpan textSpan,
- INamedTypeSymbol containingType,
- IList<ISymbol> selectedMembers,
- CancellationToken cancellationToken)
- {
- var state = new State();
- if (!state.TryInitialize(service, document, textSpan, containingType, selectedMembers, cancellationToken))
- {
- return null;
- }
-
- return state;
- }
-
- private bool TryInitialize(
- TService service,
- Document document,
- TextSpan textSpan,
- INamedTypeSymbol containingType,
- IList<ISymbol> selectedMembers,
- CancellationToken cancellationToken)
- {
- if (!selectedMembers.All(IsWritableInstanceFieldOrProperty))
- {
- return false;
- }
-
- this.SelectedMembers = selectedMembers;
- this.ContainingType = containingType;
- this.TextSpan = textSpan;
- if (this.ContainingType == null || this.ContainingType.TypeKind == TypeKind.Interface)
- {
- return false;
- }
-
- this.Parameters = service.DetermineParameters(selectedMembers);
-
- if (service.HasMatchingConstructor(this.ContainingType, this.Parameters))
- {
- return false;
- }
-
- this.DelegatedConstructor = service.GetDelegatedConstructor(this.ContainingType, this.Parameters);
- return true;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/CSharpGenerateConstructorService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/CSharpGenerateConstructorService.cs
deleted file mode 100644
index 28815e3687..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/CSharpGenerateConstructorService.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// CSharpGenerateConstructorService.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-using System.Threading;
-using System.Collections.Generic;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateFromMembers.GenerateConstructor
-{
- class CSharpGenerateConstructorService :
- AbstractGenerateConstructorService<CSharpGenerateConstructorService, MemberDeclarationSyntax>
- {
- protected override Task<IList<MemberDeclarationSyntax>> GetSelectedMembersAsync(
- Document document, TextSpan textSpan, CancellationToken cancellationToken)
- {
- return GenerateFromMembersHelpers.GetSelectedMembersAsync(document, textSpan, cancellationToken);
- }
-
- protected override IEnumerable<ISymbol> GetDeclaredSymbols(
- SemanticModel semanticModel, MemberDeclarationSyntax memberDeclaration, CancellationToken cancellationToken)
- {
- return GenerateFromMembersHelpers.GetDeclaredSymbols(semanticModel, memberDeclaration, cancellationToken);
- }
- }
-
-}
-
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/GenerateConstructorResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/GenerateConstructorResult.cs
deleted file mode 100644
index 04be848d30..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateConstructor/GenerateConstructorResult.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using RefactoringEssentials;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateFromMembers.GenerateConstructor
-{
- class GenerateConstructorResult : AbstractCodeRefactoringResult
- {
- public static readonly GenerateConstructorResult Failure = new GenerateConstructorResult(null);
-
- public GenerateConstructorResult(CodeRefactoring codeRefactoring)
- : base(codeRefactoring)
- {
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateFromMembersHelpers.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateFromMembersHelpers.cs
deleted file mode 100644
index 233b242c45..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateFromMembers/GenerateFromMembersHelpers.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateFromMembers
-{
- internal static class GenerateFromMembersHelpers
- {
- internal static async Task<IList<MemberDeclarationSyntax>> GetSelectedMembersAsync(
- Document document, TextSpan textSpan, CancellationToken cancellationToken)
- {
- var tree = await document.GetCSharpSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
- return tree.GetMembersInSpan(textSpan, cancellationToken);
- }
-
- internal static IEnumerable<ISymbol> GetDeclaredSymbols(SemanticModel semanticModel, MemberDeclarationSyntax memberDeclaration, CancellationToken cancellationToken)
- {
- if (memberDeclaration is FieldDeclarationSyntax)
- {
- return ((FieldDeclarationSyntax)memberDeclaration).Declaration.Variables.Select(
- v => semanticModel.GetDeclaredSymbol(v, cancellationToken));
- }
-
- return SpecializedCollections.SingletonEnumerable(
- semanticModel.GetDeclaredSymbol(memberDeclaration, cancellationToken));
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/AbstractCodeRefactoringResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/AbstractCodeRefactoringResult.cs
deleted file mode 100644
index 243b58e7ca..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/AbstractCodeRefactoringResult.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using RefactoringEssentials;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember
-{
- abstract class AbstractCodeRefactoringResult
- {
- private readonly CodeRefactoring _codeRefactoring;
-
- protected AbstractCodeRefactoringResult(CodeRefactoring codeRefactoring)
- {
- _codeRefactoring = codeRefactoring;
- }
-
- public bool ContainsChanges
- {
- get
- {
- return _codeRefactoring != null;
- }
- }
-
- public CodeRefactoring GetCodeRefactoring(CancellationToken cancellationToken)
- {
- return _codeRefactoring;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/AbstractGenerateMemberService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/AbstractGenerateMemberService.cs
deleted file mode 100644
index bd6f9685c0..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/AbstractGenerateMemberService.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember
-{
- abstract partial class AbstractGenerateMemberService<TSimpleNameSyntax, TExpressionSyntax>
- where TSimpleNameSyntax : TExpressionSyntax
- where TExpressionSyntax : SyntaxNode
- {
- protected AbstractGenerateMemberService()
- {
- }
-
- protected static readonly ISet<TypeKind> EnumType = new HashSet<TypeKind> { TypeKind.Enum };
- protected static readonly ISet<TypeKind> ClassInterfaceModuleStructTypes = new HashSet<TypeKind>
- {
- TypeKind.Class,
- TypeKind.Module,
- TypeKind.Struct,
- TypeKind.Interface
- };
-
- protected bool ValidateTypeToGenerateIn(
- Solution solution,
- INamedTypeSymbol typeToGenerateIn,
- bool isStatic,
- ISet<TypeKind> typeKinds,
- CancellationToken cancellationToken)
- {
- if (typeToGenerateIn == null)
- {
- return false;
- }
-
- if (typeToGenerateIn.IsAnonymousType)
- {
- return false;
- }
-
- if (!typeKinds.Contains(typeToGenerateIn.TypeKind))
- {
- return false;
- }
-
- if (typeToGenerateIn.TypeKind == TypeKind.Interface && isStatic)
- {
- return false;
- }
-
- // TODO(cyrusn): Make sure that there is a totally visible part somewhere (i.e.
- // venus) that we can generate into.
- var locations = typeToGenerateIn.Locations;
- return locations.Any(loc => loc.IsInSource);
- }
-
- protected bool TryDetermineTypeToGenerateIn(
- SemanticDocument document,
- INamedTypeSymbol containingType,
- TExpressionSyntax simpleNameOrMemberAccessExpression,
- CancellationToken cancellationToken,
- out INamedTypeSymbol typeToGenerateIn,
- out bool isStatic)
- {
- typeToGenerateIn = null;
- isStatic = false;
-
- var semanticModel = document.SemanticModel;
- var isMemberAccessExpression = simpleNameOrMemberAccessExpression.IsMemberAccessExpression();
- if (isMemberAccessExpression ||
- simpleNameOrMemberAccessExpression.IsConditionalMemberAccessExpression())
- {
- var beforeDotExpression = isMemberAccessExpression ?
- simpleNameOrMemberAccessExpression.GetExpressionOfMemberAccessExpression() :
- simpleNameOrMemberAccessExpression.GetExpressionOfConditionalMemberAccessExpression();
- if (beforeDotExpression != null)
- {
- var typeInfo = semanticModel.GetTypeInfo(beforeDotExpression, cancellationToken);
- var semanticInfo = semanticModel.GetSymbolInfo(beforeDotExpression, cancellationToken);
-
- typeToGenerateIn = typeInfo.Type is ITypeParameterSymbol
- ? ((ITypeParameterSymbol)typeInfo.Type).GetNamedTypeSymbolConstraint()
- : typeInfo.Type as INamedTypeSymbol;
-
- isStatic = semanticInfo.Symbol is INamedTypeSymbol;
- }
- }
- else if (simpleNameOrMemberAccessExpression.IsPointerMemberAccessExpression())
- {
- var beforeArrowExpression = simpleNameOrMemberAccessExpression.GetExpressionOfMemberAccessExpression();
- if (beforeArrowExpression != null)
- {
- var typeInfo = semanticModel.GetTypeInfo(beforeArrowExpression, cancellationToken);
-
- if (typeInfo.Type.IsPointerType())
- {
- typeToGenerateIn = ((IPointerTypeSymbol)typeInfo.Type).PointedAtType as INamedTypeSymbol;
- isStatic = false;
- }
- }
- }
- else if (simpleNameOrMemberAccessExpression.IsAttributeNamedArgumentIdentifier())
- {
- var attributeNode = simpleNameOrMemberAccessExpression.GetAncestors().FirstOrDefault(CSharpSyntaxFactsService.IsAttribute);
- var attributeName = attributeNode.GetNameOfAttribute();
- var attributeType = semanticModel.GetTypeInfo(attributeName, cancellationToken);
-
- typeToGenerateIn = attributeType.Type as INamedTypeSymbol;
- isStatic = false;
- }
- else if (simpleNameOrMemberAccessExpression.IsObjectInitializerNamedAssignmentIdentifier())
- {
- var objectCreationNode = simpleNameOrMemberAccessExpression.GetAncestors().FirstOrDefault(CSharpSyntaxFactsService.IsObjectCreationExpression);
- typeToGenerateIn = semanticModel.GetTypeInfo(objectCreationNode, cancellationToken).Type as INamedTypeSymbol;
- isStatic = false;
- }
- else
- {
- // Generating into the containing type.
- typeToGenerateIn = containingType;
- isStatic = simpleNameOrMemberAccessExpression.IsInStaticContext();
- }
-
- if (typeToGenerateIn != null)
- {
- typeToGenerateIn = typeToGenerateIn.OriginalDefinition;
- }
-
- return typeToGenerateIn != null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/AbstractGenerateConstructorService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/AbstractGenerateConstructorService.cs
deleted file mode 100644
index e35be8230c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/AbstractGenerateConstructorService.cs
+++ /dev/null
@@ -1,701 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using System.Linq;
-using Microsoft.CodeAnalysis.Editing;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using System;
-using Microsoft.CodeAnalysis.FindSymbols;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateConstructor
-{
- abstract partial class AbstractGenerateConstructorService<TService, TArgumentSyntax, TAttributeArgumentSyntax>
- where TService : AbstractGenerateConstructorService<TService, TArgumentSyntax, TAttributeArgumentSyntax>
- where TArgumentSyntax : SyntaxNode
- where TAttributeArgumentSyntax : SyntaxNode
- {
-
- protected AbstractGenerateConstructorService()
- {
- }
-
- protected abstract bool IsSimpleNameGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken);
- protected abstract bool IsConstructorInitializerGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken);
-
- protected abstract bool TryInitializeConstructorInitializerGeneration(SemanticDocument document, SyntaxNode constructorInitializer, CancellationToken cancellationToken, out SyntaxToken token, out IList<TArgumentSyntax> arguments, out INamedTypeSymbol typeToGenerateIn);
- protected abstract bool TryInitializeSimpleNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out IList<TArgumentSyntax> arguments, out INamedTypeSymbol typeToGenerateIn);
- protected abstract bool TryInitializeSimpleAttributeNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out IList<TArgumentSyntax> arguments, out IList<TAttributeArgumentSyntax> attributeArguments, out INamedTypeSymbol typeToGenerateIn);
-
- protected abstract IList<string> GenerateParameterNames(SemanticModel semanticModel, IEnumerable<TArgumentSyntax> arguments, IList<string> reservedNames = null);
- protected virtual IList<string> GenerateParameterNames(SemanticModel semanticModel, IEnumerable<TAttributeArgumentSyntax> arguments, IList<string> reservedNames = null) { return null; }
- protected abstract string GenerateNameForArgument(SemanticModel semanticModel, TArgumentSyntax argument);
- protected virtual string GenerateNameForArgument(SemanticModel semanticModel, TAttributeArgumentSyntax argument) { return null; }
- protected abstract RefKind GetRefKind(TArgumentSyntax argument);
- protected abstract bool IsNamedArgument(TArgumentSyntax argument);
- protected abstract ITypeSymbol GetArgumentType(SemanticModel semanticModel, TArgumentSyntax argument, CancellationToken cancellationToken);
- protected virtual ITypeSymbol GetAttributeArgumentType(SemanticModel semanticModel, TAttributeArgumentSyntax argument, CancellationToken cancellationToken) { return null; }
-
- public async Task<IEnumerable<CodeAction>> GenerateConstructorAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- var semanticDocument = await SemanticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);
-
- var state = await State.GenerateAsync((TService)this, semanticDocument, node, cancellationToken).ConfigureAwait(false);
- if (state == null)
- {
- return SpecializedCollections.EmptyEnumerable<CodeAction>();
- }
-
- return GetActions(document, state);
- }
-
- private IEnumerable<CodeAction> GetActions(Document document, State state)
- {
- yield return new GenerateConstructorCodeAction((TService)this, document, state);
- }
-
- private class GenerateConstructorCodeAction : CodeAction
- {
- private readonly State _state;
- private readonly Document _document;
- private readonly TService _service;
-
- public GenerateConstructorCodeAction(
- TService service,
- Document document,
- State state)
- {
- _service = service;
- _document = document;
- _state = state;
- }
-
- protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- var semanticDocument = await SemanticDocument.CreateAsync(_document, cancellationToken).ConfigureAwait(false);
- var editor = new Editor(_service, semanticDocument, _state, cancellationToken);
- return await editor.GetEditAsync().ConfigureAwait(false);
- }
-
- public override string Title
- {
- get
- {
- return string.Format(Resources.GenerateNewConstructorIn,
- _state.TypeToGenerateIn.Name);
- }
- }
- }
-
- protected abstract bool IsConversionImplicit(Compilation compilation, ITypeSymbol sourceType, ITypeSymbol targetType);
-
- internal abstract IMethodSymbol GetDelegatingConstructor(State state, SemanticDocument document, int argumentCount, INamedTypeSymbol namedType, ISet<IMethodSymbol> candidates, CancellationToken cancellationToken);
-
- private partial class Editor
- {
- private readonly TService _service;
- private readonly SemanticDocument _document;
- private readonly State _state;
- private readonly CancellationToken _cancellationToken;
-
- public Editor(
- TService service,
- SemanticDocument document,
- State state,
- CancellationToken cancellationToken)
- {
- _service = service;
- _document = document;
- _state = state;
- _cancellationToken = cancellationToken;
- }
-
- internal async Task<Document> GetEditAsync()
- {
- // First, see if there's an accessible base constructor that would accept these
- // types, then just call into that instead of generating fields.
- //
- // then, see if there are any constructors that would take the first 'n' arguments
- // we've provided. If so, delegate to those, and then create a field for any
- // remaining arguments. Try to match from largest to smallest.
- //
- // Otherwise, just generate a normal constructor that assigns any provided
- // parameters into fields.
-
- var edit = await GenerateThisOrBaseDelegatingConstructorAsync().ConfigureAwait(false);
- if (edit != null)
- {
- return edit;
- }
-
- return await GenerateFieldDelegatingConstructorAsync().ConfigureAwait(false);
- }
-
- private async Task<Document> GenerateThisOrBaseDelegatingConstructorAsync()
- {
- // We don't have to deal with the zero length case, since there's nothing to
- // delegate. It will fall out of the GenerateFieldDelegatingConstructor above.
- for (int i = _state.Arguments.Count; i >= 1; i--)
- {
- var edit = await GenerateThisOrBaseDelegatingConstructorAsync(i).ConfigureAwait(false);
- if (edit != null)
- {
- return edit;
- }
- }
-
- return null;
- }
-
- private async Task<Document> GenerateThisOrBaseDelegatingConstructorAsync(int argumentCount)
- {
- Document edit;
- if ((edit = await GenerateDelegatingConstructorAsync(argumentCount, _state.TypeToGenerateIn).ConfigureAwait(false)) != null ||
- (edit = await GenerateDelegatingConstructorAsync(argumentCount, _state.TypeToGenerateIn.BaseType).ConfigureAwait(false)) != null)
- {
- return edit;
- }
-
- return null;
- }
-
- private async Task<Document> GenerateDelegatingConstructorAsync(
- int argumentCount,
- INamedTypeSymbol namedType)
- {
- if (namedType == null)
- {
- return null;
- }
-
- // We can't resolve overloads across language.
- if (_document.Project.Language != namedType.Language)
- {
- return null;
- }
-
- // var arguments = _state.Arguments.Take(argumentCount).ToList();
- var remainingArguments = _state.Arguments.Skip(argumentCount).ToList();
- var remainingAttributeArguments = _state.AttributeArguments != null ? _state.AttributeArguments.Skip(argumentCount).ToList() : null;
- var remainingParameterTypes = _state.ParameterTypes.Skip(argumentCount).ToList();
-
- var instanceConstructors = namedType.InstanceConstructors.Where(IsSymbolAccessible).ToSet();
- if (instanceConstructors.IsEmpty())
- {
- return null;
- }
-
- var delegatedConstructor = _service.GetDelegatingConstructor(_state, _document, argumentCount, namedType, instanceConstructors, _cancellationToken);
- if (delegatedConstructor == null)
- {
- return null;
- }
-
- // There was a best match. Call it directly.
- var provider = _document.Project.Solution.Workspace.Services.GetLanguageServices(_state.TypeToGenerateIn.Language);
- var syntaxFactory = provider.GetService<SyntaxGenerator>();
- var codeGenerationService = new CSharpCodeGenerationService (_document.Project.Solution.Workspace);
-
- // Map the first N parameters to the other constructor in this type. Then
- // try to map any further parameters to existing fields. Finally, generate
- // new fields if no such parameters exist.
-
- // Find the names of the parameters that will follow the parameters we're
- // delegating.
- var remainingParameterNames = _service.GenerateParameterNames(
- _document.SemanticModel, remainingArguments, delegatedConstructor.Parameters.Select(p => p.Name).ToList());
-
- // Can't generate the constructor if the parameter names we're copying over forcibly
- // conflict with any names we generated.
- if (delegatedConstructor.Parameters.Select(p => p.Name).Intersect(remainingParameterNames).Any())
- {
- return null;
- }
-
- // Try to map those parameters to fields.
- Dictionary<string, ISymbol> parameterToExistingFieldMap;
- Dictionary<string, string> parameterToNewFieldMap;
- List<IParameterSymbol> remainingParameters;
- this.GetParameters(remainingArguments, remainingAttributeArguments, remainingParameterTypes, remainingParameterNames, out parameterToExistingFieldMap, out parameterToNewFieldMap, out remainingParameters);
-
- var fields = syntaxFactory.CreateFieldsForParameters(remainingParameters, parameterToNewFieldMap);
- var assignStatements = syntaxFactory.CreateAssignmentStatements(remainingParameters, parameterToExistingFieldMap, parameterToNewFieldMap);
-
- var allParameters = delegatedConstructor.Parameters.Concat(remainingParameters).ToList();
-
- var isThis = namedType.Equals(_state.TypeToGenerateIn);
- var delegatingArguments = syntaxFactory.CreateArguments(delegatedConstructor.Parameters);
- var baseConstructorArguments = isThis ? null : delegatingArguments;
- var thisConstructorArguments = isThis ? delegatingArguments : null;
-
- var constructor = CodeGenerationSymbolFactory.CreateConstructorSymbol(
- attributes: null,
- accessibility: Accessibility.Public,
- modifiers: default(DeclarationModifiers),
- typeName: _state.TypeToGenerateIn.Name,
- parameters: allParameters,
- statements: assignStatements.ToList(),
- baseConstructorArguments: baseConstructorArguments,
- thisConstructorArguments: thisConstructorArguments);
-
- var members = new List<ISymbol>(fields) { constructor };
- var result = await codeGenerationService.AddMembersAsync(
- _document.Project.Solution,
- _state.TypeToGenerateIn,
- members,
- new CodeGenerationOptions(_state.Token.GetLocation(), generateDefaultAccessibility: false),
- _cancellationToken)
- .ConfigureAwait(false);
-
- return result;
- }
-
- private async Task<Document> GenerateFieldDelegatingConstructorAsync()
- {
- var arguments = _state.Arguments.ToList();
- var parameterTypes = _state.ParameterTypes;
-
- var typeParametersNames = _state.TypeToGenerateIn.GetAllTypeParameters().Select(t => t.Name).ToList();
- var parameterNames = _state.AttributeArguments != null
- ? _service.GenerateParameterNames(_document.SemanticModel, _state.AttributeArguments, typeParametersNames)
- : _service.GenerateParameterNames(_document.SemanticModel, arguments, typeParametersNames);
-
- Dictionary<string, ISymbol> parameterToExistingFieldMap;
- Dictionary<string, string> parameterToNewFieldMap;
- List<IParameterSymbol> parameters;
- GetParameters(arguments, _state.AttributeArguments, parameterTypes, parameterNames, out parameterToExistingFieldMap, out parameterToNewFieldMap, out parameters);
-
- var provider = _document.Project.Solution.Workspace.Services.GetLanguageServices(_state.TypeToGenerateIn.Language);
- var syntaxFactory = provider.GetService<SyntaxGenerator>();
- var codeGenerationService = new CSharpCodeGenerationService (_document.Project.Solution.Workspace);
-
- var members = syntaxFactory.CreateFieldDelegatingConstructor(
- _state.TypeToGenerateIn.Name, _state.TypeToGenerateIn, parameters,
- parameterToExistingFieldMap, parameterToNewFieldMap, _cancellationToken);
-
- var result = await codeGenerationService.AddMembersAsync(
- _document.Project.Solution,
- _state.TypeToGenerateIn,
- members,
- new CodeGenerationOptions(_state.Token.GetLocation(), generateDefaultAccessibility: false),
- _cancellationToken)
- .ConfigureAwait(false);
-
- return result;
- }
-
- private void GetParameters(
- IList<TArgumentSyntax> arguments,
- IList<TAttributeArgumentSyntax> attributeArguments,
- IList<ITypeSymbol> parameterTypes,
- IList<string> parameterNames,
- out Dictionary<string, ISymbol> parameterToExistingFieldMap,
- out Dictionary<string, string> parameterToNewFieldMap,
- out List<IParameterSymbol> parameters)
- {
- parameterToExistingFieldMap = new Dictionary<string, ISymbol>();
- parameterToNewFieldMap = new Dictionary<string, string>();
- parameters = new List<IParameterSymbol>();
-
- for (var i = 0; i < parameterNames.Count; i++)
- {
- // See if there's a matching field we can use. First test in a case sensitive
- // manner, then case insensitively.
- if (!TryFindMatchingField(arguments, attributeArguments, parameterNames, parameterTypes, i, parameterToExistingFieldMap, parameterToNewFieldMap, caseSentitive: true))
- {
- if (!TryFindMatchingField(arguments, attributeArguments, parameterNames, parameterTypes, i, parameterToExistingFieldMap, parameterToNewFieldMap, caseSentitive: false))
- {
- parameterToNewFieldMap[parameterNames[i]] = parameterNames[i];
- }
- }
-
- parameters.Add(CodeGenerationSymbolFactory.CreateParameterSymbol(
- attributes: null,
- refKind: _service.GetRefKind(arguments[i]),
- isParams: false,
- type: parameterTypes[i],
- name: parameterNames[i]));
- }
- }
-
- private bool TryFindMatchingField(
- IList<TArgumentSyntax> arguments,
- IList<TAttributeArgumentSyntax> attributeArguments,
- IList<string> parameterNames,
- IList<ITypeSymbol> parameterTypes,
- int index,
- Dictionary<string, ISymbol> parameterToExistingFieldMap,
- Dictionary<string, string> parameterToNewFieldMap,
- bool caseSentitive)
- {
- var parameterName = parameterNames[index];
- var parameterType = parameterTypes[index];
- var isFixed = _service.IsNamedArgument(arguments[index]);
-
- // For non-out parameters, see if there's already a field there with the same name.
- // If so, and it has a compatible type, then we can just assign to that field.
- // Otherwise, we'll need to choose a different name for this member so that it
- // doesn't conflict with something already in the type. First check the current type
- // for a matching field. If so, defer to it.
- var comparison = caseSentitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
-
- foreach (var type in _state.TypeToGenerateIn.GetBaseTypesAndThis())
- {
- var ignoreAccessibility = type.Equals(_state.TypeToGenerateIn);
- var symbol = type.GetMembers()
- .FirstOrDefault(s => s.Name.Equals(parameterName, comparison));
-
- if (symbol != null)
- {
- if (ignoreAccessibility || IsSymbolAccessible(symbol))
- {
- if (IsViableFieldOrProperty(parameterType, symbol))
- {
- // Ok! We can just the existing field.
- parameterToExistingFieldMap[parameterName] = symbol;
- }
- else
- {
- // Uh-oh. Now we have a problem. We can't assign this parameter to
- // this field. So we need to create a new field. Find a name not in
- // use so we can assign to that.
- var newFieldName = NameGenerator.EnsureUniqueness(
- attributeArguments != null ?
- _service.GenerateNameForArgument(_document.SemanticModel, attributeArguments[index]) :
- _service.GenerateNameForArgument(_document.SemanticModel, arguments[index]),
- GetUnavailableMemberNames().Concat(parameterToNewFieldMap.Values));
-
- if (isFixed)
- {
- // Can't change the parameter name, so map the existing parameter
- // name to the new field name.
- parameterToNewFieldMap[parameterName] = newFieldName;
- }
- else
- {
- // Can change the parameter name, so do so.
- parameterNames[index] = newFieldName;
- parameterToNewFieldMap[newFieldName] = newFieldName;
- }
- }
-
- return true;
- }
- }
- }
-
- return false;
- }
-
- private IEnumerable<string> GetUnavailableMemberNames()
- {
- return _state.TypeToGenerateIn.MemberNames.Concat(
- from type in _state.TypeToGenerateIn.GetBaseTypes()
- from member in type.GetMembers()
- select member.Name);
- }
-
- private bool IsViableFieldOrProperty(
- ITypeSymbol parameterType,
- ISymbol symbol)
- {
- if (parameterType.Language != symbol.Language)
- {
- return false;
- }
-
- if (symbol != null && !symbol.IsStatic)
- {
- if (symbol is IFieldSymbol)
- {
- var field = (IFieldSymbol)symbol;
- return
- !field.IsConst &&
- _service.IsConversionImplicit(_document.SemanticModel.Compilation, parameterType, field.Type);
- }
- else if (symbol is IPropertySymbol)
- {
- var property = (IPropertySymbol)symbol;
- return
- property.Parameters.Length == 0 &&
- property.SetMethod != null &&
- _service.IsConversionImplicit(_document.SemanticModel.Compilation, parameterType, property.Type);
- }
- }
-
- return false;
- }
-
- private bool IsSymbolAccessible(
- ISymbol symbol)
- {
- if (symbol == null)
- {
- return false;
- }
-
- if (symbol.Kind == SymbolKind.Property)
- {
- if (!IsSymbolAccessible(((IPropertySymbol)symbol).SetMethod))
- {
- return false;
- }
- }
-
- // Public and protected constructors are accessible. Internal constructors are
- // accessible if we have friend access. We can't call the normal accessibility
- // checkers since they will think that a protected constructor isn't accessible
- // (since we don't have the destination type that would have access to them yet).
- switch (symbol.DeclaredAccessibility)
- {
- case Accessibility.ProtectedOrInternal:
- case Accessibility.Protected:
- case Accessibility.Public:
- return true;
- case Accessibility.ProtectedAndInternal:
- case Accessibility.Internal:
- return _document.SemanticModel.Compilation.Assembly.IsSameAssemblyOrHasFriendAccessTo(
- symbol.ContainingAssembly);
-
- default:
- return false;
- }
- }
- }
-
- protected internal class State
- {
- public IList<TArgumentSyntax> Arguments { get; private set; }
-
- public IList<TAttributeArgumentSyntax> AttributeArguments { get; private set; }
-
- // The type we're creating a constructor for. Will be a class or struct type.
- public INamedTypeSymbol TypeToGenerateIn { get; private set; }
-
- public IList<ITypeSymbol> ParameterTypes { get; private set; }
- public IList<RefKind> ParameterRefKinds { get; private set; }
-
- public SyntaxToken Token { get; private set; }
- public bool IsConstructorInitializerGeneration { get; private set; }
-
- private State()
- {
- this.IsConstructorInitializerGeneration = false;
- }
-
- public static async Task<State> GenerateAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- var state = new State();
- if (!await state.TryInitializeAsync(service, document, node, cancellationToken).ConfigureAwait(false))
- {
- return null;
- }
-
- return state;
- }
-
- private async Task<bool> TryInitializeAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- if (service.IsConstructorInitializerGeneration(document, node, cancellationToken))
- {
- if (!await TryInitializeConstructorInitializerGenerationAsync(service, document, node, cancellationToken).ConfigureAwait(false))
- {
- return false;
- }
- }
- else if (service.IsSimpleNameGeneration(document, node, cancellationToken))
- {
- if (!await TryInitializeSimpleNameGenerationAsync(service, document, node, cancellationToken).ConfigureAwait(false))
- {
- return false;
- }
- }
- else
- {
- return false;
- }
-
- if (!new CSharpCodeGenerationService (document.Project.Solution.Workspace).CanAddTo(this.TypeToGenerateIn, document.Project.Solution, cancellationToken))
- {
- return false;
- }
-
- this.ParameterTypes = this.ParameterTypes ?? GetParameterTypes(service, document, cancellationToken);
- this.ParameterRefKinds = this.Arguments.Select(service.GetRefKind).ToList();
-
- return !ClashesWithExistingConstructor(service, document, cancellationToken);
- }
-
- private bool ClashesWithExistingConstructor(TService service, SemanticDocument document, CancellationToken cancellationToken)
- {
- var parameters = this.ParameterTypes.Zip(this.ParameterRefKinds, (t, r) => CodeGenerationSymbolFactory.CreateParameterSymbol(
- attributes: null,
- refKind: r,
- isParams: false,
- type: t,
- name: string.Empty)).ToList();
-
- return this.TypeToGenerateIn.InstanceConstructors.Any(c => SignatureComparer.HaveSameSignature(parameters, c.Parameters, compareParameterName: true, isCaseSensitive: true));
- }
-
- internal List<ITypeSymbol> GetParameterTypes(
- TService service,
- SemanticDocument document,
- CancellationToken cancellationToken)
- {
- var allTypeParameters = this.TypeToGenerateIn.GetAllTypeParameters();
- var semanticModel = document.SemanticModel;
- var allTypes = this.AttributeArguments != null
- ? this.AttributeArguments.Select(a => service.GetAttributeArgumentType(semanticModel, a, cancellationToken))
- : this.Arguments.Select(a => service.GetArgumentType(semanticModel, a, cancellationToken));
-
- return allTypes.Select(t => FixType(t, semanticModel, allTypeParameters)).ToList();
- }
-
- private ITypeSymbol FixType(ITypeSymbol typeSymbol, SemanticModel semanticModel, IEnumerable<ITypeParameterSymbol> allTypeParameters)
- {
- var compilation = semanticModel.Compilation;
- return typeSymbol.RemoveAnonymousTypes(compilation)
- .RemoveUnavailableTypeParameters(compilation, allTypeParameters)
- .RemoveUnnamedErrorTypes(compilation);
- }
-
- private async Task<bool> TryInitializeConstructorInitializerGenerationAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode constructorInitializer,
- CancellationToken cancellationToken)
- {
- SyntaxToken token;
- IList<TArgumentSyntax> arguments;
- INamedTypeSymbol typeToGenerateIn;
- if (!service.TryInitializeConstructorInitializerGeneration(document, constructorInitializer, cancellationToken,
- out token, out arguments, out typeToGenerateIn))
- {
- return false;
- }
-
- this.Token = token;
- this.Arguments = arguments;
- this.IsConstructorInitializerGeneration = true;
-
- var semanticModel = document.SemanticModel;
- var semanticInfo = semanticModel.GetSymbolInfo(constructorInitializer, cancellationToken);
-
- cancellationToken.ThrowIfCancellationRequested();
- if (semanticInfo.Symbol != null)
- {
- return false;
- }
-
- return await TryDetermineTypeToGenerateInAsync(document, typeToGenerateIn, cancellationToken).ConfigureAwait(false);
- }
-
- private async Task<bool> TryInitializeSimpleNameGenerationAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode simpleName,
- CancellationToken cancellationToken)
- {
- SyntaxToken token;
- IList<TArgumentSyntax> arguments;
- IList<TAttributeArgumentSyntax> attributeArguments;
- INamedTypeSymbol typeToGenerateIn;
- if (service.TryInitializeSimpleNameGenerationState(document, simpleName, cancellationToken,
- out token, out arguments, out typeToGenerateIn))
- {
- this.Token = token;
- this.Arguments = arguments;
- }
- else if (service.TryInitializeSimpleAttributeNameGenerationState(document, simpleName, cancellationToken,
- out token, out arguments, out attributeArguments, out typeToGenerateIn))
- {
- this.Token = token;
- this.AttributeArguments = attributeArguments;
- this.Arguments = arguments;
-
- //// Attribute parameters are restricted to be constant values (simple types or string, etc).
- if (this.AttributeArguments != null && GetParameterTypes(service, document, cancellationToken).Any(t => !IsValidAttributeParameterType(t)))
- {
- return false;
- }
- else if (GetParameterTypes(service, document, cancellationToken).Any(t => !IsValidAttributeParameterType(t)))
- {
- return false;
- }
- }
- else
- {
- return false;
- }
-
- cancellationToken.ThrowIfCancellationRequested();
-
- return await TryDetermineTypeToGenerateInAsync(document, typeToGenerateIn, cancellationToken).ConfigureAwait(false);
- }
-
- private bool IsValidAttributeParameterType(ITypeSymbol type)
- {
- if (type.Kind == SymbolKind.ArrayType)
- {
- var arrayType = (IArrayTypeSymbol)type;
- if (arrayType.Rank != 1)
- {
- return false;
- }
-
- type = arrayType.ElementType;
- }
-
- if (type.IsEnumType())
- {
- return true;
- }
-
- switch (type.SpecialType)
- {
- case SpecialType.System_Boolean:
- case SpecialType.System_Byte:
- case SpecialType.System_Char:
- case SpecialType.System_Int16:
- case SpecialType.System_Int32:
- case SpecialType.System_Int64:
- case SpecialType.System_Double:
- case SpecialType.System_Single:
- case SpecialType.System_String:
- return true;
-
- default:
- return false;
- }
- }
-
- private async Task<bool> TryDetermineTypeToGenerateInAsync(
- SemanticDocument document,
- INamedTypeSymbol original,
- CancellationToken cancellationToken)
- {
- var definition = await SymbolFinder.FindSourceDefinitionAsync(original, document.Project.Solution, cancellationToken).ConfigureAwait(false);
- this.TypeToGenerateIn = definition as INamedTypeSymbol;
-
- return this.TypeToGenerateIn != null &&
- (this.TypeToGenerateIn.TypeKind == TypeKind.Class ||
- this.TypeToGenerateIn.TypeKind == TypeKind.Struct);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/CSharpGenerateConstructorService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/CSharpGenerateConstructorService.cs
deleted file mode 100644
index 4f876bfe6d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/CSharpGenerateConstructorService.cs
+++ /dev/null
@@ -1,278 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateConstructor
-{
- class CSharpGenerateConstructorService : AbstractGenerateConstructorService<CSharpGenerateConstructorService, ArgumentSyntax, AttributeArgumentSyntax>
- {
- private static readonly SyntaxAnnotation s_annotation = new SyntaxAnnotation();
-
- protected override bool IsSimpleNameGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
- {
- return node is SimpleNameSyntax;
- }
-
- protected override bool IsConstructorInitializerGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
- {
- return node is ConstructorInitializerSyntax;
- }
-
- protected override bool TryInitializeConstructorInitializerGeneration(
- SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken,
- out SyntaxToken token, out IList<ArgumentSyntax> arguments, out INamedTypeSymbol typeToGenerateIn)
- {
- var constructorInitializer = (ConstructorInitializerSyntax)node;
-
- if (!constructorInitializer.ArgumentList.CloseParenToken.IsMissing)
- {
- token = constructorInitializer.ThisOrBaseKeyword;
- arguments = constructorInitializer.ArgumentList.Arguments.ToList();
-
- var semanticModel = document.SemanticModel;
- var currentType = semanticModel.GetEnclosingNamedType(constructorInitializer.SpanStart, cancellationToken);
- typeToGenerateIn = constructorInitializer.IsKind(SyntaxKind.ThisConstructorInitializer)
- ? currentType
- : currentType.BaseType.OriginalDefinition;
- return typeToGenerateIn != null;
- }
-
- token = default(SyntaxToken);
- arguments = null;
- typeToGenerateIn = null;
- return false;
- }
-
- protected override bool TryInitializeSimpleNameGenerationState(
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken,
- out SyntaxToken token,
- out IList<ArgumentSyntax> arguments,
- out INamedTypeSymbol typeToGenerateIn)
- {
- var simpleName = (SimpleNameSyntax)node;
- var fullName = simpleName.IsRightSideOfQualifiedName()
- ? (NameSyntax)simpleName.Parent
- : simpleName;
-
- if (fullName.Parent is ObjectCreationExpressionSyntax)
- {
- var objectCreationExpression = (ObjectCreationExpressionSyntax)fullName.Parent;
- if (objectCreationExpression.ArgumentList != null &&
- !objectCreationExpression.ArgumentList.CloseParenToken.IsMissing)
- {
- var symbolInfo = document.SemanticModel.GetSymbolInfo(objectCreationExpression.Type, cancellationToken);
- token = simpleName.Identifier;
- arguments = objectCreationExpression.ArgumentList.Arguments.ToList();
- typeToGenerateIn = symbolInfo.GetAnySymbol() as INamedTypeSymbol;
- return typeToGenerateIn != null;
- }
- }
-
- token = default(SyntaxToken);
- arguments = null;
- typeToGenerateIn = null;
- return false;
- }
-
- protected override bool TryInitializeSimpleAttributeNameGenerationState(
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken,
- out SyntaxToken token,
- out IList<ArgumentSyntax> arguments,
- out IList<AttributeArgumentSyntax> attributeArguments,
- out INamedTypeSymbol typeToGenerateIn)
- {
- var simpleName = (SimpleNameSyntax)node;
- var fullName = simpleName.IsRightSideOfQualifiedName()
- ? (NameSyntax)simpleName.Parent
- : simpleName;
-
- if (fullName.Parent is AttributeSyntax)
- {
- var attribute = (AttributeSyntax)fullName.Parent;
- if (attribute.ArgumentList != null &&
- !attribute.ArgumentList.CloseParenToken.IsMissing)
- {
- var symbolInfo = document.SemanticModel.GetSymbolInfo(attribute, cancellationToken);
- if (symbolInfo.CandidateReason == CandidateReason.OverloadResolutionFailure && !symbolInfo.CandidateSymbols.IsEmpty)
- {
- token = simpleName.Identifier;
- attributeArguments = attribute.ArgumentList.Arguments.ToList();
- arguments = attributeArguments.Select(x => SyntaxFactory.Argument(x.NameColon ?? ((x.NameEquals != null) ? SyntaxFactory.NameColon(x.NameEquals.Name) : null), default(SyntaxToken), x.Expression)).ToList();
-
- typeToGenerateIn = symbolInfo.CandidateSymbols.FirstOrDefault().ContainingSymbol as INamedTypeSymbol;
- return typeToGenerateIn != null;
- }
- }
- }
-
- token = default(SyntaxToken);
- arguments = null;
- attributeArguments = null;
- typeToGenerateIn = null;
- return false;
- }
-
- protected override IList<string> GenerateParameterNames(
- SemanticModel semanticModel, IEnumerable<ArgumentSyntax> arguments, IList<string> reservedNames)
- {
- return semanticModel.GenerateParameterNames(arguments, reservedNames);
- }
-
- protected override IList<string> GenerateParameterNames(
- SemanticModel semanticModel, IEnumerable<AttributeArgumentSyntax> arguments, IList<string> reservedNames)
- {
- return semanticModel.GenerateParameterNames(arguments, reservedNames);
- }
-
- protected override string GenerateNameForArgument(
- SemanticModel semanticModel, ArgumentSyntax argument)
- {
- return semanticModel.GenerateNameForArgument(argument);
- }
-
- protected override string GenerateNameForArgument(
- SemanticModel semanticModel, AttributeArgumentSyntax argument)
- {
- return semanticModel.GenerateNameForArgument(argument);
- }
-
- protected override RefKind GetRefKind(ArgumentSyntax argument)
- {
- return argument.RefOrOutKeyword.Kind() == SyntaxKind.RefKeyword ? RefKind.Ref :
- argument.RefOrOutKeyword.Kind() == SyntaxKind.OutKeyword ? RefKind.Out : RefKind.None;
- }
-
- protected override bool IsNamedArgument(ArgumentSyntax argument)
- {
- return argument.NameColon != null;
- }
-
- protected override ITypeSymbol GetArgumentType(
- SemanticModel semanticModel, ArgumentSyntax argument, CancellationToken cancellationToken)
- {
- return semanticModel.GetType(argument.Expression, cancellationToken);
- }
-
- protected override ITypeSymbol GetAttributeArgumentType(
- SemanticModel semanticModel, AttributeArgumentSyntax argument, CancellationToken cancellationToken)
- {
- return semanticModel.GetType(argument.Expression, cancellationToken);
- }
-
- protected override bool IsConversionImplicit(Compilation compilation, ITypeSymbol sourceType, ITypeSymbol targetType)
- {
- return compilation.ClassifyConversion(sourceType, targetType).IsImplicit;
- }
-
- internal override IMethodSymbol GetDelegatingConstructor(State state, SemanticDocument document, int argumentCount, INamedTypeSymbol namedType, ISet<IMethodSymbol> candidates, CancellationToken cancellationToken)
- {
- var oldToken = state.Token;
- var tokenKind = oldToken.Kind();
-
- if (state.IsConstructorInitializerGeneration)
- {
- SyntaxToken thisOrBaseKeyword;
- SyntaxKind newCtorInitializerKind;
- if (tokenKind != SyntaxKind.BaseKeyword && state.TypeToGenerateIn == namedType)
- {
- thisOrBaseKeyword = SyntaxFactory.Token(SyntaxKind.ThisKeyword);
- newCtorInitializerKind = SyntaxKind.ThisConstructorInitializer;
- }
- else
- {
- thisOrBaseKeyword = SyntaxFactory.Token(SyntaxKind.BaseKeyword);
- newCtorInitializerKind = SyntaxKind.BaseConstructorInitializer;
- }
-
- var ctorInitializer = (ConstructorInitializerSyntax)oldToken.Parent;
- var oldArgumentList = ctorInitializer.ArgumentList;
- var newArgumentList = GetNewArgumentList(oldArgumentList, argumentCount);
-
- var newCtorInitializer = SyntaxFactory.ConstructorInitializer(newCtorInitializerKind, ctorInitializer.ColonToken, thisOrBaseKeyword, newArgumentList);
- SemanticModel speculativeModel;
- if (document.SemanticModel.TryGetSpeculativeSemanticModel(ctorInitializer.Span.Start, newCtorInitializer, out speculativeModel))
- {
- var symbolInfo = speculativeModel.GetSymbolInfo(newCtorInitializer, cancellationToken);
- return GenerateConstructorHelpers.GetDelegatingConstructor(symbolInfo, candidates, namedType);
- }
- }
- else
- {
- var oldNode = oldToken.Parent
- .AncestorsAndSelf (ascendOutOfTrivia: false)
- .LastOrDefault (SpeculationAnalyzer.CanSpeculateOnNode);
-
- var typeNameToReplace = (TypeSyntax)oldToken.Parent;
- TypeSyntax newTypeName;
- if (namedType != state.TypeToGenerateIn)
- {
- while (true)
- {
- var parentType = typeNameToReplace.Parent as TypeSyntax;
- if (parentType == null)
- {
- break;
- }
-
- typeNameToReplace = parentType;
- }
-
- newTypeName = namedType.GenerateTypeSyntax().WithAdditionalAnnotations(s_annotation);
- }
- else
- {
- newTypeName = typeNameToReplace.WithAdditionalAnnotations(s_annotation);
- }
-
- var newNode = oldNode.ReplaceNode(typeNameToReplace, newTypeName);
- newTypeName = (TypeSyntax)newNode.GetAnnotatedNodes(s_annotation).Single();
-
- var oldArgumentList = (ArgumentListSyntax)newTypeName.Parent.ChildNodes().FirstOrDefault(n => n is ArgumentListSyntax);
- if (oldArgumentList != null)
- {
- var newArgumentList = GetNewArgumentList(oldArgumentList, argumentCount);
- if (newArgumentList != oldArgumentList)
- {
- newNode = newNode.ReplaceNode(oldArgumentList, newArgumentList);
- newTypeName = (TypeSyntax)newNode.GetAnnotatedNodes(s_annotation).Single();
- }
- }
-
- var speculativeModel = SpeculationAnalyzer.CreateSpeculativeSemanticModelForNode(oldNode, newNode, document.SemanticModel);
- if (speculativeModel != null)
- {
- var symbolInfo = speculativeModel.GetSymbolInfo(newTypeName.Parent, cancellationToken);
- return GenerateConstructorHelpers.GetDelegatingConstructor(symbolInfo, candidates, namedType);
- }
- }
-
- return null;
- }
-
- private static ArgumentListSyntax GetNewArgumentList(ArgumentListSyntax oldArgumentList, int argumentCount)
- {
- if (oldArgumentList.IsMissing || oldArgumentList.Arguments.Count == argumentCount)
- {
- return oldArgumentList;
- }
-
- var newArguments = oldArgumentList.Arguments.Take(argumentCount);
- return SyntaxFactory.ArgumentList(new SeparatedSyntaxList<ArgumentSyntax>().AddRange(newArguments));
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/GenerateConstructorHelpers.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/GenerateConstructorHelpers.cs
deleted file mode 100644
index ce7fdf3c5d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateConstructor/GenerateConstructorHelpers.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateConstructor
-{
- internal static class GenerateConstructorHelpers
- {
- public static IMethodSymbol GetDelegatingConstructor(SymbolInfo symbolInfo, ISet<IMethodSymbol> candidateInstanceConstructors, INamedTypeSymbol containingType)
- {
- var symbol = symbolInfo.Symbol as IMethodSymbol;
- if (symbol == null && symbolInfo.CandidateSymbols.Count() == 1)
- {
- // Even though the symbol info has a non-viable candidate symbol, we are trying to speculate a base constructor
- // invocation from a different position then where the invocation to it would be generated.
- // Passed in candidateInstanceConstructors actually represent all accessible and invocable constructor symbols.
- // So, we allow candidate symbol for inaccessible OR not creatable candidate reason if it is in the given candidateInstanceConstructors.
- if (symbolInfo.CandidateReason == CandidateReason.Inaccessible ||
- (symbolInfo.CandidateReason == CandidateReason.NotCreatable && containingType.IsAbstract))
- {
- symbol = symbolInfo.CandidateSymbols.Single() as IMethodSymbol;
- }
- }
-
- if (symbol != null && candidateInstanceConstructors.Contains(symbol))
- {
- return symbol;
- }
-
- return null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/AbstractGenerateDefaultConstructorsService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/AbstractGenerateDefaultConstructorsService.cs
deleted file mode 100644
index e29c216a19..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/AbstractGenerateDefaultConstructorsService.cs
+++ /dev/null
@@ -1,239 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-using RefactoringEssentials;
-using Microsoft.CodeAnalysis.Editing;
-using System.Linq;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateDefaultConstructors
-{
- abstract partial class AbstractGenerateDefaultConstructorsService<TService>
- where TService : AbstractGenerateDefaultConstructorsService<TService>
- {
- protected AbstractGenerateDefaultConstructorsService()
- {
- }
-
- protected abstract bool TryInitializeState(SemanticDocument document, TextSpan textSpan, CancellationToken cancellationToken, out SyntaxNode baseTypeNode, out INamedTypeSymbol classType);
-
- public async Task<GenerateDefaultConstructorsResult> GenerateDefaultConstructorsAsync(
- Document document,
- TextSpan textSpan,
- CancellationToken cancellationToken)
- {
- var semanticDocument = await SemanticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);
-
- if (textSpan.IsEmpty)
- {
- var state = State.Generate((TService)this, semanticDocument, textSpan, cancellationToken);
- if (state != null)
- {
- return new GenerateDefaultConstructorsResult(new CodeRefactoring(null, GetActions(document, state)));
- }
- }
-
- return GenerateDefaultConstructorsResult.Failure;
- }
-
- private IEnumerable<CodeAction> GetActions(Document document, State state)
- {
- foreach (var constructor in state.UnimplementedConstructors)
- {
- yield return new GenerateDefaultConstructorCodeAction((TService)this, document, state, constructor);
- }
-
- if (state.UnimplementedConstructors.Count > 1)
- {
- yield return new CodeActionAll((TService)this, document, state, state.UnimplementedConstructors);
- }
- }
-
- private abstract class AbstractCodeAction : CodeAction
- {
- private readonly IList<IMethodSymbol> _constructors;
- private readonly Document _document;
- private readonly State _state;
- private readonly string _title;
-
- protected AbstractCodeAction(
- TService service,
- Document document,
- State state,
- IList<IMethodSymbol> constructors,
- string title)
- {
- _document = document;
- _state = state;
- _constructors = constructors;
- _title = title;
- }
-
- public override string Title
- {
- get { return _title; }
- }
-
- protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- var result = await CodeGenerator.AddMemberDeclarationsAsync(
- _document.Project.Solution,
- _state.ClassType,
- _constructors.Select(CreateConstructorDefinition),
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- return result;
- }
-
- private IMethodSymbol CreateConstructorDefinition(
- IMethodSymbol constructor)
- {
- var syntaxFactory = _document.GetLanguageService<SyntaxGenerator>();
- var baseConstructorArguments = constructor.Parameters.Length != 0
- ? syntaxFactory.CreateArguments(constructor.Parameters)
- : null;
-
- return CodeGenerationSymbolFactory.CreateConstructorSymbol(
- attributes: null,
- accessibility: constructor.DeclaredAccessibility,
- modifiers: new DeclarationModifiers(),
- typeName: _state.ClassType.Name,
- parameters: constructor.Parameters,
- statements: null,
- baseConstructorArguments: baseConstructorArguments);
- }
- }
-
-
- private class GenerateDefaultConstructorCodeAction : AbstractCodeAction
- {
- public GenerateDefaultConstructorCodeAction(
- TService service,
- Document document,
- State state,
- IMethodSymbol constructor)
- : base(service, document, state, new[] { constructor }, GetDisplayText(state, constructor))
- {
- }
-
- private static string GetDisplayText(State state, IMethodSymbol constructor)
- {
- var parameters = constructor.Parameters.Select(p => p.Name);
- var parameterString = string.Join(", ", parameters);
-
- return string.Format(Resources.GenerateConstructor + ".",
- state.ClassType.Name, parameterString);
- }
- }
-
- private class CodeActionAll : AbstractCodeAction
- {
- public CodeActionAll(
- TService service,
- Document document,
- State state,
- IList<IMethodSymbol> constructors)
- : base(service, document, state, GetConstructors(state, constructors), Resources.GenerateAll)
- {
- }
-
- private static IList<IMethodSymbol> GetConstructors(State state, IList<IMethodSymbol> constructors)
- {
- return state.UnimplementedDefaultConstructor != null
- ? new[] { state.UnimplementedDefaultConstructor }.Concat(constructors).ToList()
- : constructors;
- }
- }
- private class State
- {
- public INamedTypeSymbol ClassType { get; private set; }
-
- public IList<IMethodSymbol> UnimplementedConstructors { get; private set; }
- public IMethodSymbol UnimplementedDefaultConstructor { get; private set; }
-
- public SyntaxNode BaseTypeNode { get; private set; }
-
- private State()
- {
- }
-
- public static State Generate(
- TService service,
- SemanticDocument document,
- TextSpan textSpan,
- CancellationToken cancellationToken)
- {
- var state = new State();
- if (!state.TryInitialize(service, document, textSpan, cancellationToken))
- {
- return null;
- }
-
- return state;
- }
-
- private bool TryInitialize(
- TService service,
- SemanticDocument document,
- TextSpan textSpan,
- CancellationToken cancellationToken)
- {
- SyntaxNode baseTypeNode;
- INamedTypeSymbol classType;
- if (!service.TryInitializeState(document, textSpan, cancellationToken, out baseTypeNode, out classType))
- {
- return false;
- }
-
- if (!baseTypeNode.Span.IntersectsWith(textSpan.Start))
- {
- return false;
- }
-
- this.BaseTypeNode = baseTypeNode;
- this.ClassType = classType;
-
- var baseType = this.ClassType.BaseType;
-
- if (this.ClassType.TypeKind != TypeKind.Class ||
- this.ClassType.IsStatic ||
- baseType == null ||
- baseType.SpecialType == SpecialType.System_Object ||
- baseType.TypeKind == TypeKind.Error)
- {
- return false;
- }
-
- var classConstructors = this.ClassType.InstanceConstructors;
- var baseTypeConstructors =
- baseType.InstanceConstructors
- .Where(c => c.IsAccessibleWithin(this.ClassType));
-
- var missingConstructors =
- baseTypeConstructors.Where(c1 => !classConstructors.Any(
- c2 => SignatureComparer.HaveSameSignature(c1.Parameters, c2.Parameters, compareParameterName: true, isCaseSensitive: true))).ToList();
-
- this.UnimplementedConstructors = missingConstructors;
-
- this.UnimplementedDefaultConstructor = baseTypeConstructors.FirstOrDefault(c => c.Parameters.Length == 0);
- if (this.UnimplementedDefaultConstructor != null)
- {
- if (classConstructors.Any(c => c.Parameters.Length == 0 && !c.IsImplicitlyDeclared))
- {
- this.UnimplementedDefaultConstructor = null;
- }
- }
-
- return this.UnimplementedConstructors.Count > 0;
- }
- }
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs
deleted file mode 100644
index 39e6775830..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateDefaultConstructors
-{
- class CSharpGenerateDefaultConstructorsService : AbstractGenerateDefaultConstructorsService<CSharpGenerateDefaultConstructorsService>
- {
- protected override bool TryInitializeState(
- SemanticDocument document, TextSpan textSpan, CancellationToken cancellationToken,
- out SyntaxNode baseTypeNode, out INamedTypeSymbol classType)
- {
- if (!cancellationToken.IsCancellationRequested)
- {
- var node = document.Root.FindToken(textSpan.Start).GetAncestor<TypeSyntax>();
- if (node != null)
- {
- if (node.Parent is BaseTypeSyntax && node.Parent.IsParentKind(SyntaxKind.BaseList))
- {
- var baseList = (BaseListSyntax)node.Parent.Parent;
- if (baseList.Types.Count > 0 &&
- baseList.Types[0].Type == node &&
- baseList.IsParentKind(SyntaxKind.ClassDeclaration))
- {
- var semanticModel = document.SemanticModel;
- classType = semanticModel.GetDeclaredSymbol(baseList.Parent, cancellationToken) as INamedTypeSymbol;
- baseTypeNode = node;
- return classType != null;
- }
- }
- }
- }
-
- baseTypeNode = null;
- classType = null;
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/GenerateDefaultConstructorsResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/GenerateDefaultConstructorsResult.cs
deleted file mode 100644
index 7d4e474df1..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateDefaultConstructors/GenerateDefaultConstructorsResult.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using RefactoringEssentials;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateDefaultConstructors
-{
- class GenerateDefaultConstructorsResult : AbstractCodeRefactoringResult
- {
- public static readonly GenerateDefaultConstructorsResult Failure = new GenerateDefaultConstructorsResult(null);
-
- internal GenerateDefaultConstructorsResult(CodeRefactoring codeRefactoring)
- : base(codeRefactoring)
- {
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateEnumMember/AbstractGenerateEnumMemberService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateEnumMember/AbstractGenerateEnumMemberService.cs
deleted file mode 100644
index de1dbd97c7..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateEnumMember/AbstractGenerateEnumMemberService.cs
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateEnumMember
-{
- abstract class AbstractGenerateEnumMemberService<TService, TSimpleNameSyntax, TExpressionSyntax> :
- AbstractGenerateMemberService<TSimpleNameSyntax, TExpressionSyntax>
- where TService : AbstractGenerateEnumMemberService<TService, TSimpleNameSyntax, TExpressionSyntax>
- where TSimpleNameSyntax : TExpressionSyntax
- where TExpressionSyntax : SyntaxNode
- {
- protected AbstractGenerateEnumMemberService()
- {
- }
-
- protected abstract bool IsIdentifierNameGeneration(SyntaxNode node);
- protected abstract bool TryInitializeIdentifierNameState(SemanticDocument document, TSimpleNameSyntax identifierName, CancellationToken cancellationToken, out SyntaxToken identifierToken, out TExpressionSyntax simpleNameOrMemberAccessExpression);
-
- public async Task<IEnumerable<CodeAction>> GenerateEnumMemberAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- var semanticDocument = await SemanticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);
- var state = await State.GenerateAsync((TService)this, semanticDocument, node, cancellationToken).ConfigureAwait(false);
- if (state == null)
- {
- return SpecializedCollections.EmptyEnumerable<CodeAction>();
- }
-
- return GetActions(document, state);
- }
-
- private IEnumerable<CodeAction> GetActions(Document document, State state)
- {
- yield return new GenerateEnumMemberCodeAction((TService)this, document, state);
- }
-
- private partial class GenerateEnumMemberCodeAction : CodeAction
- {
- private readonly Document _document;
- private readonly State _state;
-
- public GenerateEnumMemberCodeAction(
- TService service,
- Document document,
- State state)
- {
- _document = document;
- _state = state;
- }
-
- protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
-
- var value = _state.TypeToGenerateIn.LastEnumValueHasInitializer()
- ? EnumValueUtilities.GetNextEnumValue(_state.TypeToGenerateIn, cancellationToken)
- : null;
-
- var result = await new CSharpCodeGenerationService (_document.Project.Solution.Workspace).AddFieldAsync(
- _document.Project.Solution,
- _state.TypeToGenerateIn,
- CodeGenerationSymbolFactory.CreateFieldSymbol(
- attributes: null,
- accessibility: Accessibility.Public,
- modifiers: default(DeclarationModifiers),
- type: _state.TypeToGenerateIn,
- name: _state.IdentifierToken.ValueText,
- hasConstantValue: value != null,
- constantValue: value),
- new CodeGenerationOptions(contextLocation: _state.IdentifierToken.GetLocation(), generateDefaultAccessibility: false),
- cancellationToken)
- .ConfigureAwait(false);
-
- return result;
- }
-
- public override string Title
- {
- get
- {
- var text = Resources.GenerateEnumMemberIn;
-
- return string.Format(
- text,
- _state.IdentifierToken.ValueText,
- _state.TypeToGenerateIn.Name);
- }
- }
- }
-
-
- private partial class State
- {
- // public TypeDeclarationSyntax ContainingTypeDeclaration { get; private set; }
- public INamedTypeSymbol TypeToGenerateIn { get; private set; }
-
- // Just the name of the method. i.e. "Foo" in "Foo" or "X.Foo"
- public SyntaxToken IdentifierToken { get; private set; }
- public TSimpleNameSyntax SimpleName { get; private set; }
- public TExpressionSyntax SimpleNameOrMemberAccessExpression { get; private set; }
-
- public static async Task<State> GenerateAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- var state = new State();
- if (!await state.TryInitializeAsync(service, document, node, cancellationToken).ConfigureAwait(false))
- {
- return null;
- }
-
- return state;
- }
-
- private async Task<bool> TryInitializeAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- if (service.IsIdentifierNameGeneration(node))
- {
- if (!TryInitializeIdentifierName(service, document, (TSimpleNameSyntax)node, cancellationToken))
- {
- return false;
- }
- }
- else
- {
- return false;
- }
-
- // Ok. It either didn't bind to any symbols, or it bound to a symbol but with
- // errors. In the former case we definitely want to offer to generate a field. In
- // the latter case, we want to generate a field *unless* there's an existing member
- // with the same name. Note: it's ok if there's an existing field with the same
- // name.
- var existingMembers = this.TypeToGenerateIn.GetMembers(this.IdentifierToken.ValueText);
- if (existingMembers.Any())
- {
- // TODO: Code coverage There was an existing member that the new member would
- // clash with.
- return false;
- }
-
- cancellationToken.ThrowIfCancellationRequested();
- this.TypeToGenerateIn = await SymbolFinder.FindSourceDefinitionAsync(this.TypeToGenerateIn, document.Project.Solution, cancellationToken).ConfigureAwait(false) as INamedTypeSymbol;
- if (!service.ValidateTypeToGenerateIn(
- document.Project.Solution, this.TypeToGenerateIn, true, EnumType, cancellationToken))
- {
- return false;
- }
-
- return CodeGenerator.CanAdd(document.Project.Solution, this.TypeToGenerateIn, cancellationToken);
- }
-
- private bool TryInitializeIdentifierName(
- TService service,
- SemanticDocument document,
- TSimpleNameSyntax identifierName,
- CancellationToken cancellationToken)
- {
- this.SimpleName = identifierName;
-
- SyntaxToken identifierToken;
- TExpressionSyntax simpleNameOrMemberAccessExpression;
- if (!service.TryInitializeIdentifierNameState(document, identifierName, cancellationToken,
- out identifierToken, out simpleNameOrMemberAccessExpression))
- {
- return false;
- }
-
- this.IdentifierToken = identifierToken;
- this.SimpleNameOrMemberAccessExpression = simpleNameOrMemberAccessExpression;
-
- var semanticModel = document.SemanticModel;
- if ((simpleNameOrMemberAccessExpression as ExpressionSyntax).IsWrittenTo() ||
- simpleNameOrMemberAccessExpression.IsInNamespaceOrTypeContext())
- {
- return false;
- }
-
- // Now, try to bind the invocation and see if it succeeds or not. if it succeeds and
- // binds uniquely, then we don't need to offer this quick fix.
- cancellationToken.ThrowIfCancellationRequested();
- var containingType = semanticModel.GetEnclosingNamedType(identifierToken.SpanStart, cancellationToken);
- if (containingType == null)
- {
- return false;
- }
-
- var semanticInfo = semanticModel.GetSymbolInfo(this.SimpleNameOrMemberAccessExpression, cancellationToken);
- if (cancellationToken.IsCancellationRequested)
- {
- return false;
- }
-
- if (semanticInfo.Symbol != null)
- {
- return false;
- }
-
- // Either we found no matches, or this was ambiguous. Either way, we might be able
- // to generate a method here. Determine where the user wants to generate the method
- // into, and if it's valid then proceed.
- INamedTypeSymbol typeToGenerateIn;
- bool isStatic;
- if (!service.TryDetermineTypeToGenerateIn(
- document, containingType, simpleNameOrMemberAccessExpression, cancellationToken,
- out typeToGenerateIn, out isStatic))
- {
- return false;
- }
-
- if (!isStatic)
- {
- return false;
- }
-
- this.TypeToGenerateIn = typeToGenerateIn;
- return true;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateEnumMember/CSharpGenerateEnumMemberService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateEnumMember/CSharpGenerateEnumMemberService.cs
deleted file mode 100644
index 61b2b19cf3..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateEnumMember/CSharpGenerateEnumMemberService.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateEnumMember
-{
- partial class CSharpGenerateEnumMemberService :
- AbstractGenerateEnumMemberService<CSharpGenerateEnumMemberService, SimpleNameSyntax, ExpressionSyntax>
- {
- protected override bool IsIdentifierNameGeneration(SyntaxNode node)
- {
- return node is IdentifierNameSyntax;
- }
-
- protected override bool TryInitializeIdentifierNameState(
- SemanticDocument document, SimpleNameSyntax identifierName, CancellationToken cancellationToken,
- out SyntaxToken identifierToken, out ExpressionSyntax simpleNameOrMemberAccessExpression)
- {
- identifierToken = identifierName.Identifier;
- if (identifierToken.ValueText != string.Empty &&
- !identifierName.IsVar)
- {
- var memberAccess = identifierName.Parent as MemberAccessExpressionSyntax;
- simpleNameOrMemberAccessExpression = memberAccess != null && memberAccess.Name == identifierName
- ? (ExpressionSyntax)memberAccess
- : identifierName;
-
- // If we're being invoked, then don't offer this, offer generate method instead.
- // Note: we could offer to generate a field with a delegate type. However, that's
- // very esoteric and probably not what most users want.
- if (simpleNameOrMemberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression) ||
- simpleNameOrMemberAccessExpression.IsParentKind(SyntaxKind.ObjectCreationExpression) ||
- simpleNameOrMemberAccessExpression.IsParentKind(SyntaxKind.GotoStatement) ||
- simpleNameOrMemberAccessExpression.IsParentKind(SyntaxKind.AliasQualifiedName))
- {
- return false;
- }
-
- return true;
- }
-
- identifierToken = default(SyntaxToken);
- simpleNameOrMemberAccessExpression = null;
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateConversionService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateConversionService.cs
deleted file mode 100644
index 85bb3d5ddb..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateConversionService.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember
-{
- abstract partial class AbstractGenerateConversionService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax> :
- AbstractGenerateParameterizedMemberService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax>
- where TService : AbstractGenerateConversionService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax>
- where TSimpleNameSyntax : TExpressionSyntax
- where TExpressionSyntax : SyntaxNode
- where TInvocationExpressionSyntax : TExpressionSyntax
- {
- protected abstract bool IsImplicitConversionGeneration(SyntaxNode node);
- protected abstract bool IsExplicitConversionGeneration(SyntaxNode node);
- protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
- protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
-
- public async Task<IEnumerable<CodeAction>> GenerateConversionAsync(
- Document document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- var semanticDocument = await SemanticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);
- var state = await State.GenerateConversionStateAsync((TService)this, semanticDocument, node, cancellationToken).ConfigureAwait(false);
- if (state == null)
- {
- return SpecializedCollections.EmptyEnumerable<CodeAction>();
- }
-
- return GetActions(document, state, cancellationToken);
- }
-
- protected new class State : AbstractGenerateParameterizedMemberService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax>.State
- {
- public static async Task<State> GenerateConversionStateAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode interfaceNode,
- CancellationToken cancellationToken)
- {
- var state = new State();
- if (!await state.TryInitializeConversionAsync(service, document, interfaceNode, cancellationToken).ConfigureAwait(false))
- {
- return null;
- }
-
- return state;
- }
-
- private Task<bool> TryInitializeConversionAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- if (service.IsImplicitConversionGeneration(node))
- {
- if (!TryInitializeImplicitConversion(service, document, node, cancellationToken))
- {
- return Task.FromResult (false);
- }
- }
- else if (service.IsExplicitConversionGeneration(node))
- {
- if (!TryInitializeExplicitConversion(service, document, node, cancellationToken))
- {
- return Task.FromResult (false);
- }
- }
-
- return TryFinishInitializingState(service, document, cancellationToken);
- }
-
- private bool TryInitializeExplicitConversion(TService service, SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
- {
- MethodKind = MethodKind.Conversion;
- SyntaxToken identifierToken;
- IMethodSymbol methodSymbol;
- INamedTypeSymbol typeToGenerateIn;
- if (!service.TryInitializeExplicitConversionState(
- document, node, ClassInterfaceModuleStructTypes, cancellationToken,
- out identifierToken, out methodSymbol, out typeToGenerateIn))
- {
- return false;
- }
-
- this.ContainingType = document.SemanticModel.GetEnclosingNamedType(node.SpanStart, cancellationToken);
- if (ContainingType == null)
- {
- return false;
- }
-
- this.IdentifierToken = identifierToken;
- this.TypeToGenerateIn = typeToGenerateIn;
- this.SignatureInfo = new MethodSignatureInfo(document, this, methodSymbol);
- this.location = node.GetLocation();
- this.MethodGenerationKind = MethodGenerationKind.ExplicitConversion;
- return true;
- }
-
- private bool TryInitializeImplicitConversion(TService service, SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
- {
- MethodKind = MethodKind.Conversion;
- SyntaxToken identifierToken;
- IMethodSymbol methodSymbol;
- INamedTypeSymbol typeToGenerateIn;
- if (!service.TryInitializeImplicitConversionState(
- document, node, ClassInterfaceModuleStructTypes, cancellationToken,
- out identifierToken, out methodSymbol, out typeToGenerateIn))
- {
- return false;
- }
-
- this.ContainingType = document.SemanticModel.GetEnclosingNamedType(node.SpanStart, cancellationToken);
- if (ContainingType == null)
- {
- return false;
- }
-
- this.IdentifierToken = identifierToken;
- this.TypeToGenerateIn = typeToGenerateIn;
- this.SignatureInfo = new MethodSignatureInfo(document, this, methodSymbol);
- this.MethodGenerationKind = MethodGenerationKind.ImplicitConversion;
- return true;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateMethodService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateMethodService.cs
deleted file mode 100644
index b3d945e969..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateMethodService.cs
+++ /dev/null
@@ -1,267 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember
-{
- abstract partial class AbstractGenerateMethodService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax> :
- AbstractGenerateParameterizedMemberService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax>
- where TService : AbstractGenerateMethodService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax>
- where TSimpleNameSyntax : TExpressionSyntax
- where TExpressionSyntax : SyntaxNode
- where TInvocationExpressionSyntax : TExpressionSyntax
- {
- protected abstract bool IsSimpleNameGeneration(SyntaxNode node);
- protected abstract bool IsExplicitInterfaceGeneration(SyntaxNode node);
- protected abstract bool TryInitializeExplicitInterfaceState(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
- protected abstract bool TryInitializeSimpleNameState(SemanticDocument document, TSimpleNameSyntax simpleName, CancellationToken cancellationToken, out SyntaxToken identifierToken, out TExpressionSyntax simpleNameOrMemberAccessExpression, out TInvocationExpressionSyntax invocationExpressionOpt, out bool isInConditionalExpression);
- protected abstract ITypeSymbol CanGenerateMethodForSimpleNameOrMemberAccessExpression(SemanticModel semanticModel, TExpressionSyntax expresion, CancellationToken cancellationToken);
-
- public async Task<IEnumerable<CodeAction>> GenerateMethodAsync(
- Document document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- var semanticDocument = await SemanticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);
- var state = await State.GenerateMethodStateAsync((TService)this, semanticDocument, node, cancellationToken).ConfigureAwait(false);
- if (state == null)
- {
- return SpecializedCollections.EmptyEnumerable<CodeAction>();
- }
-
- return GetActions(document, state, cancellationToken);
- }
-
- internal protected new class State : AbstractGenerateParameterizedMemberService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax>.State
- {
- public static async Task<State> GenerateMethodStateAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode interfaceNode,
- CancellationToken cancellationToken)
- {
- var state = new State();
- if (!await state.TryInitializeMethodAsync(service, document, interfaceNode, cancellationToken).ConfigureAwait(false))
- {
- return null;
- }
-
- return state;
- }
-
- private Task<bool> TryInitializeMethodAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- // Cases that we deal with currently:
- //
- // 1) expr.Foo
- // 2) expr->Foo
- // 3) Foo
- // 4) expr.Foo()
- // 5) expr->Foo()
- // 6) Foo()
- // 7) ReturnType Explicit.Interface.Foo()
- //
- // In the first 3 invocationExpressionOpt will be null and we'll have to infer a
- // delegate type in order to figure out the right method signature to generate. In
- // the next 3 invocationExpressionOpt will be non null and will be used to figure
- // out the types/name of the parameters to generate. In the last one, we're going to
- // generate into an interface.
- if (service.IsExplicitInterfaceGeneration(node))
- {
- if (!TryInitializeExplicitInterface(service, document, node, cancellationToken))
- {
- return Task.FromResult (false);
- }
- }
- else if (service.IsSimpleNameGeneration(node))
- {
- if (!TryInitializeSimpleName(service, document, (TSimpleNameSyntax)node, cancellationToken))
- {
- return Task.FromResult (false);
- }
- }
-
- return TryFinishInitializingState(service, document, cancellationToken);
- }
-
- private bool TryInitializeExplicitInterface(
- TService service,
- SemanticDocument document,
- SyntaxNode methodDeclaration,
- CancellationToken cancellationToken)
- {
- MethodKind = MethodKind.Ordinary;
- SyntaxToken identifierToken;
- IMethodSymbol methodSymbol;
- INamedTypeSymbol typeToGenerateIn;
- if (!service.TryInitializeExplicitInterfaceState(
- document, methodDeclaration, cancellationToken,
- out identifierToken, out methodSymbol, out typeToGenerateIn))
- {
- return false;
- }
-
- if (methodSymbol.ExplicitInterfaceImplementations.Any())
- {
- return false;
- }
-
- this.IdentifierToken = identifierToken;
- this.TypeToGenerateIn = typeToGenerateIn;
-
- cancellationToken.ThrowIfCancellationRequested();
- var semanticModel = document.SemanticModel;
- this.ContainingType = semanticModel.GetEnclosingNamedType(methodDeclaration.SpanStart, cancellationToken);
- if (this.ContainingType == null)
- {
- return false;
- }
-
- if (!this.ContainingType.Interfaces.Contains(this.TypeToGenerateIn))
- {
- return false;
- }
-
- this.SignatureInfo = new MethodSignatureInfo(document, this, methodSymbol);
- return true;
- }
-
- private bool TryInitializeSimpleName(
- TService service,
- SemanticDocument document,
- TSimpleNameSyntax simpleName,
- CancellationToken cancellationToken)
- {
- MethodKind = MethodKind.Ordinary;
- this.SimpleNameOpt = simpleName;
-
- SyntaxToken identifierToken;
- TExpressionSyntax simpleNameOrMemberAccessExpression;
- TInvocationExpressionSyntax invocationExpressionOpt;
- bool isInConditionalExpression;
- if (!service.TryInitializeSimpleNameState(
- document, simpleName, cancellationToken,
- out identifierToken, out simpleNameOrMemberAccessExpression, out invocationExpressionOpt, out isInConditionalExpression))
- {
- return false;
- }
-
- this.IdentifierToken = identifierToken;
- this.SimpleNameOrMemberAccessExpression = simpleNameOrMemberAccessExpression;
- this.InvocationExpressionOpt = invocationExpressionOpt;
- this.IsInConditionalAccessExpression = isInConditionalExpression;
-
- if (string.IsNullOrWhiteSpace(this.IdentifierToken.ValueText))
- {
- return false;
- }
-
- // If we're not in a type, don't even bother. NOTE(cyrusn): We'll have to rethink this
- // for C# Script.
- cancellationToken.ThrowIfCancellationRequested();
- var semanticModel = document.SemanticModel;
- this.ContainingType = semanticModel.GetEnclosingNamedType(this.SimpleNameOpt.SpanStart, cancellationToken);
- if (this.ContainingType == null)
- {
- return false;
- }
-
- if (this.InvocationExpressionOpt != null)
- {
- this.SignatureInfo = service.CreateInvocationMethodInfo(document, this);
- }
- else
- {
- var delegateType = TypeGuessing.typeInferenceService.InferDelegateType(semanticModel, this.SimpleNameOrMemberAccessExpression, cancellationToken);
- if (delegateType != null && delegateType.DelegateInvokeMethod != null)
- {
- this.SignatureInfo = new MethodSignatureInfo(document, this, delegateType.DelegateInvokeMethod);
- }
- else
- {
- // We don't have and invocation expression or a delegate, but we may have a special expression without parenthesis. Lets see
- // if the type inference service can directly infer the type for our expression.
- var expressionType = service.CanGenerateMethodForSimpleNameOrMemberAccessExpression(semanticModel, this.SimpleNameOrMemberAccessExpression, cancellationToken);
- if (expressionType == null)
- {
- return false;
- }
-
- this.SignatureInfo = new MethodSignatureInfo(document, this, CreateMethodSymbolWithReturnType(expressionType));
- }
- }
-
- // Now, try to bind the invocation and see if it succeeds or not. if it succeeds and
- // binds uniquely, then we don't need to offer this quick fix.
- cancellationToken.ThrowIfCancellationRequested();
-
- // If the name bound with errors, then this is a candidate for generate method.
- var semanticInfo = semanticModel.GetSymbolInfo(this.SimpleNameOrMemberAccessExpression, cancellationToken);
- if (semanticInfo.GetAllSymbols().Any(s => s.Kind == SymbolKind.Local || s.Kind == SymbolKind.Parameter) &&
- !service.AreSpecialOptionsActive(semanticModel))
- {
- // if the name bound to something in scope then we don't want to generate the
- // method because it will be shadowed by what's in scope. Unless we are in a
- // special state such as Option Strict On where we want to generate fixes even
- // if we shadow types.
- return false;
- }
-
- // Check if the symbol is on the list of valid symbols for this language.
- cancellationToken.ThrowIfCancellationRequested();
- if (semanticInfo.Symbol != null && !service.IsValidSymbol(semanticInfo.Symbol, semanticModel))
- {
- return false;
- }
-
- // Either we found no matches, or this was ambiguous. Either way, we might be able
- // to generate a method here. Determine where the user wants to generate the method
- // into, and if it's valid then proceed.
- cancellationToken.ThrowIfCancellationRequested();
- INamedTypeSymbol typeToGenerateIn;
- bool isStatic;
- if (!service.TryDetermineTypeToGenerateIn(
- document, this.ContainingType, this.SimpleNameOrMemberAccessExpression, cancellationToken,
- out typeToGenerateIn, out isStatic))
- {
- return false;
- }
-
- var expressionSyntax = (this.InvocationExpressionOpt ?? this.SimpleNameOrMemberAccessExpression) as ExpressionSyntax;
- this.IsWrittenTo = expressionSyntax.IsWrittenTo();
- this.TypeToGenerateIn = typeToGenerateIn;
- this.IsStatic = isStatic;
- this.MethodGenerationKind = MethodGenerationKind.Member;
- return true;
- }
-
- private static IMethodSymbol CreateMethodSymbolWithReturnType(ITypeSymbol expressionType)
- {
- return CodeGenerationSymbolFactory.CreateMethodSymbol(
- attributes: SpecializedCollections.EmptyList<AttributeData>(),
- accessibility: default(Accessibility),
- modifiers: default(DeclarationModifiers),
- returnType: expressionType,
- explicitInterfaceSymbol: null,
- name: null,
- typeParameters: SpecializedCollections.EmptyList<ITypeParameterSymbol>(),
- parameters: SpecializedCollections.EmptyList<IParameterSymbol>());
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.cs
deleted file mode 100644
index 02b8984131..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.cs
+++ /dev/null
@@ -1,595 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis;
-using System.Linq;
-using System;
-using System.Threading.Tasks;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using Microsoft.CodeAnalysis.Editing;
-using System.Collections.Immutable;
-using Microsoft.CodeAnalysis.FindSymbols;
-using MonoDevelop.Ide.TypeSystem;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember
-{
- abstract partial class AbstractGenerateParameterizedMemberService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax> :
- AbstractGenerateMemberService<TSimpleNameSyntax, TExpressionSyntax>
- where TService : AbstractGenerateParameterizedMemberService<TService, TSimpleNameSyntax, TExpressionSyntax, TInvocationExpressionSyntax>
- where TSimpleNameSyntax : TExpressionSyntax
- where TExpressionSyntax : SyntaxNode
- where TInvocationExpressionSyntax : TExpressionSyntax
- {
- protected AbstractGenerateParameterizedMemberService()
- {
- }
-
- protected abstract AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDocument document, State abstractState);
-
- protected abstract bool IsValidSymbol(ISymbol symbol, SemanticModel semanticModel);
- protected abstract bool AreSpecialOptionsActive(SemanticModel semanticModel);
-
- protected virtual bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol containingType)
- {
- return false;
- }
-
- protected virtual string GetImplicitConversionDisplayText(State state)
- {
- return string.Empty;
- }
-
- protected virtual string GetExplicitConversionDisplayText(State state)
- {
- return string.Empty;
- }
-
- protected IEnumerable<CodeAction> GetActions(Document document, State state, CancellationToken cancellationToken)
- {
- yield return new GenerateParameterizedMemberCodeAction((TService)this, document, state, isAbstract: false, generateProperty: false);
-
- // If we're trying to generate an instance method into an abstract class (but not a
- // static class or an interface), then offer to generate it abstractly.
- var canGenerateAbstractly = state.TypeToGenerateIn.IsAbstract &&
- !state.TypeToGenerateIn.IsStatic &&
- state.TypeToGenerateIn.TypeKind != TypeKind.Interface &&
- !state.IsStatic;
-
- if (canGenerateAbstractly)
- {
- yield return new GenerateParameterizedMemberCodeAction((TService)this, document, state, isAbstract: true, generateProperty: false);
- }
-
- if (true/*semanticFacts.SupportsParameterizedProperties*/ &&
- state.InvocationExpressionOpt != null)
- {
- var typeParameters = state.SignatureInfo.DetermineTypeParameters(cancellationToken);
- var returnType = state.SignatureInfo.DetermineReturnType(cancellationToken);
-
- if (typeParameters.Count == 0 && returnType.SpecialType != SpecialType.System_Void)
- {
- yield return new GenerateParameterizedMemberCodeAction((TService)this, document, state, isAbstract: false, generateProperty: true);
-
- if (canGenerateAbstractly)
- {
- yield return new GenerateParameterizedMemberCodeAction((TService)this, document, state, isAbstract: true, generateProperty: true);
- }
- }
- }
- }
- internal protected abstract class AbstractInvocationInfo : SignatureInfo
- {
- protected abstract bool IsIdentifierName();
-
- protected abstract IList<ITypeParameterSymbol> GetCapturedTypeParameters(CancellationToken cancellationToken);
- protected abstract IList<ITypeParameterSymbol> GenerateTypeParameters(CancellationToken cancellationToken);
-
- protected AbstractInvocationInfo(SemanticDocument document, State state)
- : base(document, state)
- {
- }
-
- public override IList<ITypeParameterSymbol> DetermineTypeParameters(CancellationToken cancellationToken)
- {
- var typeParameters = DetermineTypeParametersWorker(cancellationToken);
- return typeParameters.Select(tp => MassageTypeParameter(tp, cancellationToken)).ToList();
- }
-
- private IList<ITypeParameterSymbol> DetermineTypeParametersWorker(
- CancellationToken cancellationToken)
- {
- if (IsIdentifierName())
- {
- // If the user wrote something like Foo(x) then we still might want to generate
- // a generic method if the expression 'x' captured any method type variables.
- var capturedTypeParameters = GetCapturedTypeParameters(cancellationToken);
- var availableTypeParameters = this.State.TypeToGenerateIn.GetAllTypeParameters();
- var result = capturedTypeParameters.Except(availableTypeParameters).ToList();
- return result;
- }
- else
- {
- return GenerateTypeParameters(cancellationToken);
- }
- }
-
- private ITypeParameterSymbol MassageTypeParameter(
- ITypeParameterSymbol typeParameter,
- CancellationToken cancellationToken)
- {
- var constraints = typeParameter.ConstraintTypes.Where(ts => !ts.IsUnexpressableTypeParameterConstraint()).ToList();
- var classTypes = constraints.Where(ts => ts.TypeKind == TypeKind.Class).ToList();
- var nonClassTypes = constraints.Where(ts => ts.TypeKind != TypeKind.Class).ToList();
-
- classTypes = MergeClassTypes(classTypes, cancellationToken);
- constraints = classTypes.Concat(nonClassTypes).ToList();
- if (constraints.SequenceEqual(typeParameter.ConstraintTypes))
- {
- return typeParameter;
- }
-
- return CodeGenerationSymbolFactory.CreateTypeParameter(
- attributes: null,
- varianceKind: typeParameter.Variance,
- name: typeParameter.Name,
- constraintTypes: ImmutableArray.CreateRange<ITypeSymbol>(constraints),
- hasConstructorConstraint: typeParameter.HasConstructorConstraint,
- hasReferenceConstraint: typeParameter.HasReferenceTypeConstraint,
- hasValueConstraint: typeParameter.HasValueTypeConstraint);
- }
-
- private List<ITypeSymbol> MergeClassTypes(List<ITypeSymbol> classTypes, CancellationToken cancellationToken)
- {
- var compilation = this.Document.SemanticModel.Compilation;
- for (int i = classTypes.Count - 1; i >= 0; i--)
- {
- // For example, 'Attribute'.
- var type1 = classTypes[i];
-
- for (int j = 0; j < classTypes.Count; j++)
- {
- if (j != i)
- {
- // For example 'FooAttribute'.
- var type2 = classTypes[j];
-
- if (IsImplicitReferenceConversion(compilation, type2, type1))
- {
- // If there's an implicit reference conversion (i.e. from
- // FooAttribute to Attribute), then we don't need Attribute as it's
- // implied by the second attribute;
- classTypes.RemoveAt(i);
- break;
- }
- }
- }
- }
-
- return classTypes;
- }
-
- protected abstract bool IsImplicitReferenceConversion(Compilation compilation, ITypeSymbol sourceType, ITypeSymbol targetType);
- }
- private partial class GenerateParameterizedMemberCodeAction : CodeAction
- {
- private readonly TService _service;
- private readonly Document _document;
- private readonly State _state;
- private readonly bool _isAbstract;
- private readonly bool _generateProperty;
-
- public GenerateParameterizedMemberCodeAction(
- TService service,
- Document document,
- State state,
- bool isAbstract,
- bool generateProperty)
- {
- _service = service;
- _document = document;
- _state = state;
- _isAbstract = isAbstract;
- _generateProperty = generateProperty;
- }
-
- private string GetDisplayText(
- State state,
- bool isAbstract,
- bool generateProperty)
- {
- switch (state.MethodGenerationKind)
- {
- case MethodGenerationKind.Member:
- var text = generateProperty ?
- isAbstract ? Resources.GenerateAbstractProperty : Resources.GeneratePropertyIn :
- isAbstract ? Resources.GenerateAbstractMethod : Resources.GenerateMethodIn;
-
- var name = state.IdentifierToken.ValueText;
- var destination = state.TypeToGenerateIn.Name;
- return string.Format(text, name, destination);
- case MethodGenerationKind.ImplicitConversion:
- return _service.GetImplicitConversionDisplayText(_state);
- case MethodGenerationKind.ExplicitConversion:
- return _service.GetExplicitConversionDisplayText(_state);
- default:
- throw new InvalidOperationException();
- }
- }
-
- protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- //var syntaxTree = await _document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
- var syntaxFactory = _document.Project.Solution.Workspace.Services.GetLanguageServices(_state.TypeToGenerateIn.Language).GetService<SyntaxGenerator>();
-
- if (_generateProperty)
- {
- var property = _state.SignatureInfo.GenerateProperty(syntaxFactory, _isAbstract, _state.IsWrittenTo, cancellationToken);
-
- var result = await CodeGenerator.AddPropertyDeclarationAsync(
- _document.Project.Solution,
- _state.TypeToGenerateIn,
- property,
- new CodeGenerationOptions(afterThisLocation: _state.IdentifierToken.GetLocation(), generateDefaultAccessibility: false),
- cancellationToken)
- .ConfigureAwait(false);
-
- return await AnnotateInsertionMode(_document.Project.Solution.GetDocument(result.Id), result);
- }
- else
- {
- var method = _state.SignatureInfo.GenerateMethod(syntaxFactory, _isAbstract, cancellationToken);
-
- var result = await CodeGenerator.AddMethodDeclarationAsync(
- _document.Project.Solution,
- _state.TypeToGenerateIn,
- method,
- new CodeGenerationOptions(afterThisLocation: _state.Location, generateDefaultAccessibility: false),
- cancellationToken)
- .ConfigureAwait(false);
-
- return await AnnotateInsertionMode(_document.Project.Solution.GetDocument(result.Id), result);
- }
- }
-
- async Task<Document> AnnotateInsertionMode (Document oldDocument, Document result)
- {
- var newRoot = await result.GetSyntaxRootAsync ();
- var changes = await oldDocument.GetTextChangesAsync (result);
- foreach (var change in changes) {
-
- var parent = newRoot.FindNode (change.Span);
- if (parent == null || !(parent is MethodDeclarationSyntax || parent is PropertyDeclarationSyntax))
- continue;
- return result.WithSyntaxRoot (newRoot.ReplaceNode (parent, parent.WithAdditionalAnnotations (TypeSystemService.InsertionModeAnnotation)));
- }
- return result;
- }
-
- public override string Title
- {
- get
- {
- return GetDisplayText(_state, _isAbstract, _generateProperty);
- }
- }
- }
-
- protected class MethodSignatureInfo : SignatureInfo
- {
- private readonly IMethodSymbol _methodSymbol;
-
- public MethodSignatureInfo(
- SemanticDocument document,
- State state,
- IMethodSymbol methodSymbol)
- : base(document, state)
- {
- _methodSymbol = methodSymbol;
- }
-
- protected override ITypeSymbol DetermineReturnTypeWorker(CancellationToken cancellationToken)
- {
- if (State.IsInConditionalAccessExpression)
- {
- return _methodSymbol.ReturnType.RemoveNullableIfPresent();
- }
-
- return _methodSymbol.ReturnType;
- }
-
- public override IList<ITypeParameterSymbol> DetermineTypeParameters(CancellationToken cancellationToken)
- {
- return _methodSymbol.TypeParameters;
- }
-
- protected override IList<RefKind> DetermineParameterModifiers(CancellationToken cancellationToken)
- {
- return _methodSymbol.Parameters.Select(p => p.RefKind).ToList();
- }
-
- protected override IList<bool> DetermineParameterOptionality(CancellationToken cancellationToken)
- {
- return _methodSymbol.Parameters.Select(p => p.IsOptional).ToList();
- }
-
- protected override IList<ITypeSymbol> DetermineParameterTypes(CancellationToken cancellationToken)
- {
- return _methodSymbol.Parameters.Select(p => p.Type).ToList();
- }
-
- protected override IList<string> DetermineParameterNames(CancellationToken cancellationToken)
- {
- return _methodSymbol.Parameters.Select(p => p.Name).ToList();
- }
- }
-
- internal protected abstract class SignatureInfo
- {
- protected readonly SemanticDocument Document;
- protected readonly State State;
-
- public SignatureInfo(
- SemanticDocument document,
- State state)
- {
- this.Document = document;
- this.State = state;
- }
-
- public abstract IList<ITypeParameterSymbol> DetermineTypeParameters(CancellationToken cancellationToken);
- public ITypeSymbol DetermineReturnType(CancellationToken cancellationToken)
- {
- return FixType(DetermineReturnTypeWorker(cancellationToken), cancellationToken);
- }
-
- protected abstract ITypeSymbol DetermineReturnTypeWorker(CancellationToken cancellationToken);
- protected abstract IList<RefKind> DetermineParameterModifiers(CancellationToken cancellationToken);
- protected abstract IList<ITypeSymbol> DetermineParameterTypes(CancellationToken cancellationToken);
- protected abstract IList<bool> DetermineParameterOptionality(CancellationToken cancellationToken);
- protected abstract IList<string> DetermineParameterNames(CancellationToken cancellationToken);
-
- internal IPropertySymbol GenerateProperty(
- SyntaxGenerator factory,
- bool isAbstract, bool includeSetter,
- CancellationToken cancellationToken)
- {
- var accessibility = DetermineAccessibility(isAbstract);
- var getMethod = CodeGenerationSymbolFactory.CreateAccessorSymbol(
- attributes: null,
- accessibility: accessibility,
- statements: GenerateStatements(factory, isAbstract, cancellationToken));
-
- var setMethod = includeSetter ? getMethod : null;
-
- return CodeGenerationSymbolFactory.CreatePropertySymbol(
- attributes: null,
- accessibility: accessibility,
- modifiers: DeclarationModifiers.None.WithIsStatic(State.IsStatic).WithIsAbstract (isAbstract),
- type: DetermineReturnType(cancellationToken),
- explicitInterfaceSymbol: null,
- name: this.State.IdentifierToken.ValueText,
- parameters: DetermineParameters(cancellationToken),
- getMethod: getMethod,
- setMethod: setMethod);
- }
-
- public IMethodSymbol GenerateMethod(
- SyntaxGenerator factory,
- bool isAbstract,
- CancellationToken cancellationToken)
- {
- var parameters = DetermineParameters(cancellationToken);
- var returnType = DetermineReturnType(cancellationToken);
- var isUnsafe = (parameters
- .Any(p => p.Type.IsUnsafe()) || returnType.IsUnsafe()) &&
- !State.IsContainedInUnsafeType;
- var method = CodeGenerationSymbolFactory.CreateMethodSymbol(
- attributes: null,
- accessibility: DetermineAccessibility(isAbstract),
- modifiers: DeclarationModifiers.None.WithIsStatic(State.IsStatic).WithIsAbstract (isAbstract).WithIsUnsafe (isUnsafe),
- returnType: returnType,
- explicitInterfaceSymbol: null,
- name: this.State.IdentifierToken.ValueText,
- typeParameters: DetermineTypeParameters(cancellationToken),
- parameters: parameters,
- statements: GenerateStatements(factory, isAbstract, cancellationToken),
- handlesExpressions: null,
- returnTypeAttributes: null,
- methodKind: State.MethodKind);
-
- // Ensure no conflicts between type parameter names and parameter names.
- //var languageServiceProvider = this.Document.Project.Solution.Workspace.Services.GetLanguageServices(this.State.TypeToGenerateIn.Language);
-
- var equalityComparer = StringComparer.Ordinal;
- var reservedParameterNames = this.DetermineParameterNames(cancellationToken).ToSet(equalityComparer);
- var newTypeParameterNames = NameGenerator.EnsureUniqueness(
- method.TypeParameters.Select(t => t.Name).ToList(), n => !reservedParameterNames.Contains(n));
-
- return method.RenameTypeParameters(newTypeParameterNames);
- }
-
- private ITypeSymbol FixType(
- ITypeSymbol typeSymbol,
- CancellationToken cancellationToken)
- {
- // A type can't refer to a type parameter that isn't available in the type we're
- // eventually generating into.
- var availableMethodTypeParameters = this.DetermineTypeParameters(cancellationToken);
- var availableTypeParameters = this.State.TypeToGenerateIn.GetAllTypeParameters();
-
- var compilation = this.Document.SemanticModel.Compilation;
- var allTypeParameters = availableMethodTypeParameters.Concat(availableTypeParameters);
-
- return typeSymbol.RemoveAnonymousTypes(compilation)
- .ReplaceTypeParametersBasedOnTypeConstraints(compilation, allTypeParameters, this.Document.Document.Project.Solution, cancellationToken)
- .RemoveUnavailableTypeParameters(compilation, allTypeParameters)
- .RemoveUnnamedErrorTypes(compilation);
- }
-
- private IList<SyntaxNode> GenerateStatements(
- SyntaxGenerator factory,
- bool isAbstract,
- CancellationToken cancellationToken)
- {
- var throwStatement = CodeGenerationHelpers.GenerateThrowStatement(factory, this.Document, "System.NotImplementedException", cancellationToken);
-
- return isAbstract || State.TypeToGenerateIn.TypeKind == TypeKind.Interface || throwStatement == null
- ? null
- : new[] { throwStatement };
- }
-
- private IList<IParameterSymbol> DetermineParameters(CancellationToken cancellationToken)
- {
- var modifiers = DetermineParameterModifiers(cancellationToken);
- var types = DetermineParameterTypes(cancellationToken).Select(t => FixType(t, cancellationToken)).ToList();
- var optionality = DetermineParameterOptionality(cancellationToken);
- var names = DetermineParameterNames(cancellationToken);
-
- var result = new List<IParameterSymbol>();
- for (var i = 0; i < modifiers.Count; i++)
- {
- result.Add(CodeGenerationSymbolFactory.CreateParameterSymbol(
- attributes: null,
- refKind: modifiers[i],
- isParams: false,
- isOptional: optionality[i],
- type: types[i],
- name: names[i]));
- }
-
- return result;
- }
-
- private Accessibility DetermineAccessibility(bool isAbstract)
- {
- var containingType = this.State.ContainingType;
-
- // If we're generating into an interface, then we don't use any modifiers.
- if (State.TypeToGenerateIn.TypeKind != TypeKind.Interface)
- {
- // Otherwise, figure out what accessibility modifier to use and optionally
- // mark it as static.
- if (containingType.IsContainedWithin(State.TypeToGenerateIn) && !isAbstract)
- {
- return Accessibility.Private;
- }
- else if (DerivesFrom(containingType) && State.IsStatic)
- {
- // NOTE(cyrusn): We only generate protected in the case of statics. Consider
- // the case where we're generating into one of our base types. i.e.:
- //
- // class B : A { void Foo() { A a; a.Foo(); }
- //
- // In this case we can *not* mark the method as protected. 'B' can only
- // access protected members of 'A' through an instance of 'B' (or a subclass
- // of B). It can not access protected members through an instance of the
- // superclass. In this case we need to make the method public or internal.
- //
- // However, this does not apply if the method will be static. i.e.
- //
- // class B : A { void Foo() { A.Foo(); }
- //
- // B can access the protected statics of A, and so we generate 'Foo' as
- // protected.
-
- // TODO: Code coverage
- return Accessibility.Protected;
- }
- else if (containingType.ContainingAssembly.IsSameAssemblyOrHasFriendAccessTo(State.TypeToGenerateIn.ContainingAssembly))
- {
- return Accessibility.Internal;
- }
- else
- {
- // TODO: Code coverage
- return Accessibility.Public;
- }
- }
-
- return Accessibility.NotApplicable;
- }
-
- private bool DerivesFrom(INamedTypeSymbol containingType)
- {
- return containingType.GetBaseTypes().Select(t => t.OriginalDefinition)
- .OfType<INamedTypeSymbol>()
- .Contains(State.TypeToGenerateIn);
- }
- }
-
- internal protected abstract class State
- {
- public INamedTypeSymbol ContainingType { get; protected set; }
- public INamedTypeSymbol TypeToGenerateIn { get; protected set; }
- public bool IsStatic { get; protected set; }
- public bool IsContainedInUnsafeType { get; protected set; }
-
- // Just the name of the method. i.e. "Foo" in "X.Foo" or "X.Foo()"
- public SyntaxToken IdentifierToken { get; protected set; }
- public TSimpleNameSyntax SimpleNameOpt { get; protected set; }
-
- // The entire expression containing the name, not including the invocation. i.e. "X.Foo"
- // in "X.Foo()".
- public TExpressionSyntax SimpleNameOrMemberAccessExpression { get; protected set; }
- public TInvocationExpressionSyntax InvocationExpressionOpt { get; protected set; }
- public bool IsInConditionalAccessExpression { get; protected set; }
-
- public bool IsWrittenTo { get; protected set; }
-
- public SignatureInfo SignatureInfo { get; protected set; }
- public MethodKind MethodKind { get; internal set; }
- public MethodGenerationKind MethodGenerationKind { get; protected set; }
- protected Location location = null;
- public Location Location
- {
- get
- {
- if (IdentifierToken.SyntaxTree != null)
- {
- return IdentifierToken.GetLocation();
- }
-
- return location;
- }
- }
-
- protected async Task<bool> TryFinishInitializingState(TService service, SemanticDocument document, CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
- this.TypeToGenerateIn = await SymbolFinder.FindSourceDefinitionAsync(this.TypeToGenerateIn, document.Project.Solution, cancellationToken).ConfigureAwait(false) as INamedTypeSymbol;
- if (this.TypeToGenerateIn.IsErrorType())
- {
- return false;
- }
-
- if (!service.ValidateTypeToGenerateIn(document.Project.Solution, this.TypeToGenerateIn,
- this.IsStatic, ClassInterfaceModuleStructTypes, cancellationToken))
- {
- return false;
- }
-
- if (!new CSharpCodeGenerationService(document.Project.Solution.Workspace).CanAddTo(this.TypeToGenerateIn, document.Project.Solution, cancellationToken))
- {
- return false;
- }
-
- // Ok. It either didn't bind to any symbols, or it bound to a symbol but with
- // errors. In the former case we definitely want to offer to generate a method. In
- // the latter case, we want to generate a method *unless* there's an existing method
- // with the same signature.
- var existingMethods = this.TypeToGenerateIn.GetMembers(this.IdentifierToken.ValueText)
- .OfType<IMethodSymbol>();
-
- var destinationProvider = document.Project.Solution.Workspace.Services.GetLanguageServices(this.TypeToGenerateIn.Language);
- var syntaxFactory = destinationProvider.GetService<SyntaxGenerator>();
- this.IsContainedInUnsafeType = service.ContainingTypesOrSelfHasUnsafeKeyword(this.TypeToGenerateIn);
- var generatedMethod = this.SignatureInfo.GenerateMethod(syntaxFactory, false, cancellationToken);
- return !existingMethods.Any(m => SignatureComparer.HaveSameSignature(m, generatedMethod, caseSensitive: true, compareParameterName: true, isParameterCaseSensitive: true));
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs
deleted file mode 100644
index 1f9a4ae970..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember
-{
- internal static class CSharpCommonGenerationServiceMethods
- {
- public static bool AreSpecialOptionsActive(SemanticModel semanticModel)
- {
- return false;
- }
-
- public static bool IsValidSymbol(ISymbol symbol, SemanticModel semanticModel)
- {
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs
deleted file mode 100644
index ecf4076cea..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs
+++ /dev/null
@@ -1,233 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember
-{
- partial class CSharpGenerateConversionService :
- AbstractGenerateConversionService<CSharpGenerateConversionService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>
- {
- protected override bool IsImplicitConversionGeneration(SyntaxNode node)
- {
- return node is ExpressionSyntax &&
- (node.Parent is AssignmentExpressionSyntax || node.Parent is EqualsValueClauseSyntax) &&
- !(node is CastExpressionSyntax) &&
- !(node is MemberAccessExpressionSyntax);
- }
-
- protected override bool IsExplicitConversionGeneration(SyntaxNode node)
- {
- return node is CastExpressionSyntax;
- }
-
- protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol containingType)
- {
- return containingType.ContainingTypesOrSelfHasUnsafeKeyword();
- }
-
- protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDocument document, AbstractGenerateParameterizedMemberService<CSharpGenerateConversionService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>.State state)
- {
- return new CSharpGenerateParameterizedMemberService<CSharpGenerateConversionService>.InvocationExpressionInfo(document, state);
- }
-
- protected override bool AreSpecialOptionsActive(SemanticModel semanticModel)
- {
- return CSharpCommonGenerationServiceMethods.AreSpecialOptionsActive(semanticModel);
- }
-
- protected override bool IsValidSymbol(ISymbol symbol, SemanticModel semanticModel)
- {
- return CSharpCommonGenerationServiceMethods.IsValidSymbol(symbol, semanticModel);
- }
-
- protected override bool TryInitializeImplicitConversionState(
- SemanticDocument document,
- SyntaxNode expression,
- ISet<TypeKind> classInterfaceModuleStructTypes,
- CancellationToken cancellationToken,
- out SyntaxToken identifierToken,
- out IMethodSymbol methodSymbol,
- out INamedTypeSymbol typeToGenerateIn)
- {
- if (TryGetConversionMethodAndTypeToGenerateIn(document, expression, classInterfaceModuleStructTypes, cancellationToken, out methodSymbol, out typeToGenerateIn))
- {
- identifierToken = SyntaxFactory.Token(
- default(SyntaxTriviaList),
- SyntaxKind.ImplicitKeyword,
- WellKnownMemberNames.ImplicitConversionName,
- WellKnownMemberNames.ImplicitConversionName,
- default(SyntaxTriviaList));
- return true;
- }
-
- identifierToken = default(SyntaxToken);
- methodSymbol = null;
- typeToGenerateIn = null;
- return false;
- }
-
- protected override bool TryInitializeExplicitConversionState(
- SemanticDocument document,
- SyntaxNode expression,
- ISet<TypeKind> classInterfaceModuleStructTypes,
- CancellationToken cancellationToken,
- out SyntaxToken identifierToken,
- out IMethodSymbol methodSymbol,
- out INamedTypeSymbol typeToGenerateIn)
- {
- if (TryGetConversionMethodAndTypeToGenerateIn(document, expression, classInterfaceModuleStructTypes, cancellationToken, out methodSymbol, out typeToGenerateIn))
- {
- identifierToken = SyntaxFactory.Token(
- default(SyntaxTriviaList),
- SyntaxKind.ImplicitKeyword,
- WellKnownMemberNames.ExplicitConversionName,
- WellKnownMemberNames.ExplicitConversionName,
- default(SyntaxTriviaList));
- return true;
- }
-
- identifierToken = default(SyntaxToken);
- methodSymbol = null;
- typeToGenerateIn = null;
- return false;
- }
-
- private bool TryGetConversionMethodAndTypeToGenerateIn(
- SemanticDocument document,
- SyntaxNode expression,
- ISet<TypeKind> classInterfaceModuleStructTypes,
- CancellationToken cancellationToken,
- out IMethodSymbol methodSymbol,
- out INamedTypeSymbol typeToGenerateIn)
- {
- var castExpression = expression as CastExpressionSyntax;
- if (castExpression != null)
- {
- return TryGetExplicitConversionMethodAndTypeToGenerateIn(
- document,
- castExpression,
- classInterfaceModuleStructTypes,
- cancellationToken,
- out methodSymbol,
- out typeToGenerateIn);
- }
-
- return TryGetImplicitConversionMethodAndTypeToGenerateIn(
- document,
- expression,
- classInterfaceModuleStructTypes,
- cancellationToken,
- out methodSymbol,
- out typeToGenerateIn);
- }
-
- private bool TryGetExplicitConversionMethodAndTypeToGenerateIn(
- SemanticDocument document,
- CastExpressionSyntax castExpression,
- ISet<TypeKind> classInterfaceModuleStructTypes,
- CancellationToken cancellationToken,
- out IMethodSymbol methodSymbol,
- out INamedTypeSymbol typeToGenerateIn)
- {
- methodSymbol = null;
- typeToGenerateIn = document.SemanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type as INamedTypeSymbol;
- var parameterSymbol = document.SemanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type as INamedTypeSymbol;
- if (typeToGenerateIn == null || parameterSymbol == null || typeToGenerateIn.IsErrorType() || parameterSymbol.IsErrorType())
- {
- return false;
- }
-
- methodSymbol = GenerateMethodSymbol(typeToGenerateIn, parameterSymbol);
-
- if (!ValidateTypeToGenerateIn(
- document.Project.Solution,
- typeToGenerateIn,
- true,
- classInterfaceModuleStructTypes,
- cancellationToken))
- {
- typeToGenerateIn = parameterSymbol;
- }
-
- return true;
- }
-
- private bool TryGetImplicitConversionMethodAndTypeToGenerateIn(
- SemanticDocument document,
- SyntaxNode expression,
- ISet<TypeKind> classInterfaceModuleStructTypes,
- CancellationToken cancellationToken,
- out IMethodSymbol methodSymbol,
- out INamedTypeSymbol typeToGenerateIn)
- {
- methodSymbol = null;
- typeToGenerateIn = document.SemanticModel.GetTypeInfo(expression, cancellationToken).ConvertedType as INamedTypeSymbol;
- var parameterSymbol = document.SemanticModel.GetTypeInfo(expression, cancellationToken).Type as INamedTypeSymbol;
- if (typeToGenerateIn == null || parameterSymbol == null || typeToGenerateIn.IsErrorType() || parameterSymbol.IsErrorType())
- {
- return false;
- }
-
- methodSymbol = GenerateMethodSymbol(typeToGenerateIn, parameterSymbol);
-
- if (!ValidateTypeToGenerateIn(
- document.Project.Solution,
- typeToGenerateIn,
- true,
- classInterfaceModuleStructTypes,
- cancellationToken))
- {
- typeToGenerateIn = parameterSymbol;
- }
-
- return true;
- }
-
- private static IMethodSymbol GenerateMethodSymbol(INamedTypeSymbol typeToGenerateIn, INamedTypeSymbol parameterSymbol)
- {
- // Remove any generic parameters
- if (typeToGenerateIn.IsGenericType)
- {
- typeToGenerateIn = typeToGenerateIn.ConstructUnboundGenericType().ConstructedFrom;
- }
-
- return CodeGenerationSymbolFactory.CreateMethodSymbol(
- attributes: SpecializedCollections.EmptyList<AttributeData>(),
- accessibility: default(Accessibility),
- modifiers: default(DeclarationModifiers),
- returnType: typeToGenerateIn,
- explicitInterfaceSymbol: null,
- name: null,
- typeParameters: SpecializedCollections.EmptyList<ITypeParameterSymbol>(),
- parameters: new[] { CodeGenerationSymbolFactory.CreateParameterSymbol(parameterSymbol, "v") },
- methodKind: MethodKind.Conversion);
- }
-
- protected override string GetImplicitConversionDisplayText(AbstractGenerateParameterizedMemberService<CSharpGenerateConversionService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>.State state)
- {
- return string.Format(Resources.ImplicitConversionDisplayText, state.TypeToGenerateIn.Name);
- }
-
- protected override string GetExplicitConversionDisplayText(AbstractGenerateParameterizedMemberService<CSharpGenerateConversionService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>.State state)
- {
- return string.Format(Resources.ExplicitConversionDisplayText, state.TypeToGenerateIn.Name);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs
deleted file mode 100644
index be978c0823..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs
+++ /dev/null
@@ -1,173 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember
-{
- partial class CSharpGenerateMethodService :
- AbstractGenerateMethodService<CSharpGenerateMethodService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>
- {
- protected override bool IsExplicitInterfaceGeneration(SyntaxNode node)
- {
- return node is MethodDeclarationSyntax;
- }
-
- protected override bool IsSimpleNameGeneration(SyntaxNode node)
- {
- return node is SimpleNameSyntax;
- }
-
- protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol containingType)
- {
- return containingType.ContainingTypesOrSelfHasUnsafeKeyword();
- }
-
- protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDocument document, AbstractGenerateParameterizedMemberService<CSharpGenerateMethodService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>.State state)
- {
- return new CSharpGenerateParameterizedMemberService<CSharpGenerateMethodService>.InvocationExpressionInfo(document, state);
- }
-
- protected override bool AreSpecialOptionsActive(SemanticModel semanticModel)
- {
- return CSharpCommonGenerationServiceMethods.AreSpecialOptionsActive(semanticModel);
- }
-
- protected override bool IsValidSymbol(ISymbol symbol, SemanticModel semanticModel)
- {
- return CSharpCommonGenerationServiceMethods.IsValidSymbol(symbol, semanticModel);
- }
-
- protected override bool TryInitializeExplicitInterfaceState(
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken,
- out SyntaxToken identifierToken,
- out IMethodSymbol methodSymbol,
- out INamedTypeSymbol typeToGenerateIn)
- {
- var methodDeclaration = (MethodDeclarationSyntax)node;
- identifierToken = methodDeclaration.Identifier;
-
- if (methodDeclaration.ExplicitInterfaceSpecifier != null &&
- !methodDeclaration.ParameterList.OpenParenToken.IsMissing &&
- !methodDeclaration.ParameterList.CloseParenToken.IsMissing)
- {
- var semanticModel = document.SemanticModel;
- methodSymbol = semanticModel.GetDeclaredSymbol(methodDeclaration, cancellationToken) as IMethodSymbol;
- if (methodSymbol != null && !methodSymbol.ExplicitInterfaceImplementations.Any())
- {
- var semanticInfo = semanticModel.GetTypeInfo(methodDeclaration.ExplicitInterfaceSpecifier.Name, cancellationToken);
- typeToGenerateIn = semanticInfo.Type as INamedTypeSymbol;
- return typeToGenerateIn != null;
- }
- }
-
- identifierToken = default(SyntaxToken);
- methodSymbol = null;
- typeToGenerateIn = null;
- return false;
- }
-
- protected override bool TryInitializeSimpleNameState(
- SemanticDocument document,
- SimpleNameSyntax simpleName,
- CancellationToken cancellationToken,
- out SyntaxToken identifierToken,
- out ExpressionSyntax simpleNameOrMemberAccessExpression,
- out InvocationExpressionSyntax invocationExpressionOpt,
- out bool isInConditionalAccessExpression)
- {
- identifierToken = simpleName.Identifier;
-
- var memberAccess = simpleName?.Parent as MemberAccessExpressionSyntax;
- var conditionalMemberAccess = simpleName?.Parent?.Parent?.Parent as ConditionalAccessExpressionSyntax;
- var inConditionalMemberAccess = conditionalMemberAccess != null;
- if (memberAccess != null)
- {
- simpleNameOrMemberAccessExpression = (ExpressionSyntax)memberAccess;
- }
- else if (inConditionalMemberAccess)
- {
- simpleNameOrMemberAccessExpression = (ExpressionSyntax)conditionalMemberAccess;
- }
- else
- {
- simpleNameOrMemberAccessExpression = simpleName;
- }
-
- if (memberAccess == null || memberAccess.Name == simpleName)
- {
- if (simpleNameOrMemberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression))
- {
- invocationExpressionOpt = (InvocationExpressionSyntax)simpleNameOrMemberAccessExpression.Parent;
- isInConditionalAccessExpression = inConditionalMemberAccess;
- return !invocationExpressionOpt.ArgumentList.CloseParenToken.IsMissing;
- }
- // We need to check that the tree is structured like so:
- // ConditionalAccessExpressionSyntax
- // -> InvocationExpressionSyntax
- // -> MemberBindingExpressionSyntax
- // and that the name at the end of this expression matches the simple name we were given
- else if ((((simpleNameOrMemberAccessExpression as ConditionalAccessExpressionSyntax)
- ?.WhenNotNull as InvocationExpressionSyntax)
- ?.Expression as MemberBindingExpressionSyntax)
- ?.Name == simpleName)
- {
- invocationExpressionOpt = (InvocationExpressionSyntax)((ConditionalAccessExpressionSyntax)simpleNameOrMemberAccessExpression).WhenNotNull;
- isInConditionalAccessExpression = inConditionalMemberAccess;
- return !invocationExpressionOpt.ArgumentList.CloseParenToken.IsMissing;
- }
- else if (simpleName.IsKind(SyntaxKind.IdentifierName))
- {
- // If we don't have an invocation node, then see if we can infer a delegate in
- // this location. Check if this is a place where a delegate can go. Only do this
- // for identifier names. for now. It gets really funky if you have to deal with
- // a generic name here.
-
- // Can't assign into a method.
- if (!simpleNameOrMemberAccessExpression.IsLeftSideOfAnyAssignExpression())
- {
- invocationExpressionOpt = null;
- isInConditionalAccessExpression = inConditionalMemberAccess;
- return true;
- }
- }
- }
-
- identifierToken = default(SyntaxToken);
- simpleNameOrMemberAccessExpression = null;
- invocationExpressionOpt = null;
- isInConditionalAccessExpression = false;
- return false;
- }
-
- protected override ITypeSymbol CanGenerateMethodForSimpleNameOrMemberAccessExpression(
- SemanticModel semanticModel,
- ExpressionSyntax expresion,
- CancellationToken cancellationToken)
- {
- if (semanticModel.SyntaxTree.IsNameOfContext(expresion.SpanStart, semanticModel, cancellationToken))
- {
- return TypeGuessing.typeInferenceService.InferType(semanticModel, expresion, true, cancellationToken);
- }
-
- return null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
deleted file mode 100644
index ad3462c2ce..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember
-{
- internal abstract class CSharpGenerateParameterizedMemberService<TService> : AbstractGenerateParameterizedMemberService<TService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>
- where TService : AbstractGenerateParameterizedMemberService<TService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>
- {
- internal protected partial class InvocationExpressionInfo : AbstractInvocationInfo
- {
- private readonly InvocationExpressionSyntax _invocationExpression;
-
- public InvocationExpressionInfo(
- SemanticDocument document,
- AbstractGenerateParameterizedMemberService<TService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>.State state)
- : base(document, state)
- {
- _invocationExpression = state.InvocationExpressionOpt;
- }
-
- protected override IList<string> DetermineParameterNames(CancellationToken cancellationToken)
- {
- return this.Document.SemanticModel.GenerateParameterNames(
- _invocationExpression.ArgumentList);
- }
-
- protected override ITypeSymbol DetermineReturnTypeWorker(CancellationToken cancellationToken)
- {
- // Defer to the type inferrer to figure out what the return type of this new method
- // should be.
- var inferredType = TypeGuessing.typeInferenceService.InferType(this.Document.SemanticModel,
- _invocationExpression, objectAsDefault: true, cancellationToken: cancellationToken);
- if (State.IsInConditionalAccessExpression)
- {
- return inferredType.RemoveNullableIfPresent();
- }
-
- return inferredType;
- }
-
- protected override IList<ITypeParameterSymbol> GetCapturedTypeParameters(CancellationToken cancellationToken)
- {
- var result = new List<ITypeParameterSymbol>();
- var semanticModel = this.Document.SemanticModel;
- foreach (var argument in _invocationExpression.ArgumentList.Arguments)
- {
- var type = semanticModel.GetType(argument.Expression, cancellationToken);
- type.GetReferencedTypeParameters(result);
- }
-
- return result;
- }
-
- protected override IList<ITypeParameterSymbol> GenerateTypeParameters(CancellationToken cancellationToken)
- {
- // Generate dummy type parameter names for a generic method. If the user is inside a
- // generic method, and calls a generic method with type arguments from the outer
- // method, then use those same names for the generated type parameters.
- //
- // TODO(cyrusn): If we do capture method type variables, then we should probably
- // capture their constraints as well.
- var genericName = (GenericNameSyntax)this.State.SimpleNameOpt;
- //var semanticModel = this.Document.SemanticModel;
-
- if (genericName.TypeArgumentList.Arguments.Count == 1)
- {
- var typeParameter = GetUniqueTypeParameter(
- genericName.TypeArgumentList.Arguments.First(),
- s => !State.TypeToGenerateIn.GetAllTypeParameters().Any(t => t.Name == s),
- cancellationToken);
-
- return new List<ITypeParameterSymbol> { typeParameter };
- }
- else
- {
- var list = new List<ITypeParameterSymbol>();
-
- var usedIdentifiers = new HashSet<string> { "T" };
- foreach (var type in genericName.TypeArgumentList.Arguments)
- {
- var typeParameter = GetUniqueTypeParameter(
- type,
- s => !usedIdentifiers.Contains(s) && !State.TypeToGenerateIn.GetAllTypeParameters().Any(t => t.Name == s),
- cancellationToken);
-
- usedIdentifiers.Add(typeParameter.Name);
-
- list.Add(typeParameter);
- }
-
- return list;
- }
- }
-
- private ITypeParameterSymbol GetUniqueTypeParameter(
- TypeSyntax type,
- Func<string, bool> isUnique,
- CancellationToken cancellationToken)
- {
- var methodTypeParameter = GetMethodTypeParameter(type, cancellationToken);
- return methodTypeParameter != null
- ? methodTypeParameter
- : CodeGenerationSymbolFactory.CreateTypeParameterSymbol(NameGenerator.GenerateUniqueName("T", isUnique));
- }
-
- private ITypeParameterSymbol GetMethodTypeParameter(TypeSyntax type, CancellationToken cancellationToken)
- {
- if (type is IdentifierNameSyntax)
- {
- var info = this.Document.SemanticModel.GetTypeInfo(type, cancellationToken);
- if (info.Type is ITypeParameterSymbol &&
- ((ITypeParameterSymbol)info.Type).TypeParameterKind == TypeParameterKind.Method)
- {
- return (ITypeParameterSymbol)info.Type;
- }
- }
-
- return null;
- }
-
- protected override IList<RefKind> DetermineParameterModifiers(CancellationToken cancellationToken)
- {
- return
- _invocationExpression.ArgumentList.Arguments.Select(
- a => a.RefOrOutKeyword.Kind() == SyntaxKind.RefKeyword ? RefKind.Ref :
- a.RefOrOutKeyword.Kind() == SyntaxKind.OutKeyword ? RefKind.Out : RefKind.None).ToList();
- }
-
- protected override IList<ITypeSymbol> DetermineParameterTypes(CancellationToken cancellationToken)
- {
- return _invocationExpression.ArgumentList.Arguments.Select(a => DetermineParameterType(a, cancellationToken)).ToList();
- }
-
- private ITypeSymbol DetermineParameterType(
- ArgumentSyntax argument,
- CancellationToken cancellationToken)
- {
- return argument.DetermineParameterType(this.Document.SemanticModel, cancellationToken);
- }
-
- protected override IList<bool> DetermineParameterOptionality(CancellationToken cancellationToken)
- {
- return _invocationExpression.ArgumentList.Arguments.Select(a => false).ToList();
- }
-
- protected override bool IsIdentifierName()
- {
- return this.State.SimpleNameOpt.Kind() == SyntaxKind.IdentifierName;
- }
-
- protected override bool IsImplicitReferenceConversion(Compilation compilation, ITypeSymbol sourceType, ITypeSymbol targetType)
- {
- var conversion = compilation.ClassifyConversion(sourceType, targetType);
- return conversion.IsImplicit && conversion.IsReference;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/MethodGenerationKind.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/MethodGenerationKind.cs
deleted file mode 100644
index cbafecdebb..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateParameterizedMember/MethodGenerationKind.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateParameterizedMember
-{
- public enum MethodGenerationKind
- {
- Member,
- ImplicitConversion,
- ExplicitConversion
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateVariable/AbstractGenerateVariableService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateVariable/AbstractGenerateVariableService.cs
deleted file mode 100644
index 6bf6e3bd68..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateVariable/AbstractGenerateVariableService.cs
+++ /dev/null
@@ -1,710 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Microsoft.CodeAnalysis.Options;
-using Roslyn.Utilities;
-using ICSharpCode.NRefactory6.CSharp.GenerateMember;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.Editing;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace Microsoft.CodeAnalysis.GenerateMember.GenerateVariable
-{
- abstract partial class AbstractGenerateVariableService<TService, TSimpleNameSyntax, TExpressionSyntax> :
- AbstractGenerateMemberService<TSimpleNameSyntax, TExpressionSyntax>
- where TService : AbstractGenerateVariableService<TService, TSimpleNameSyntax, TExpressionSyntax>
- where TSimpleNameSyntax : TExpressionSyntax
- where TExpressionSyntax : SyntaxNode
- {
- protected AbstractGenerateVariableService()
- {
- }
-
- protected abstract bool IsExplicitInterfaceGeneration(SyntaxNode node);
- protected abstract bool IsIdentifierNameGeneration(SyntaxNode node);
-
- protected abstract bool TryInitializeExplicitInterfaceState(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IPropertySymbol propertySymbol, out INamedTypeSymbol typeToGenerateIn);
- protected abstract bool TryInitializeIdentifierNameState(SemanticDocument document, TSimpleNameSyntax identifierName, CancellationToken cancellationToken, out SyntaxToken identifierToken, out TExpressionSyntax simpleNameOrMemberAccessExpression, out bool isInExecutableBlock, out bool isinConditionalAccessExpression);
-
- protected abstract bool TryConvertToLocalDeclaration(ITypeSymbol type, SyntaxToken identifierToken, OptionSet options, out SyntaxNode newRoot);
-
- public async Task<IEnumerable<CodeAction>> GenerateVariableAsync(
- Document document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- var semanticDocument = await SemanticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);
-
- var state = await State.GenerateAsync((TService)this, semanticDocument, node, cancellationToken).ConfigureAwait(false);
- if (state == null)
- {
- return SpecializedCollections.EmptyEnumerable<CodeAction>();
- }
-
- var result = new List<CodeAction>();
-
- var canGenerateMember = ICSharpCode.NRefactory6.CSharp.CodeGenerator.CanAdd(document.Project.Solution, state.TypeToGenerateIn, cancellationToken);
-
- // prefer fields over properties (and vice versa) depending on the casing of the member.
- // lowercase -> fields. title case -> properties.
- var name = state.IdentifierToken.ValueText;
- if (char.IsUpper(name.FirstOrDefault()))
- {
- if (canGenerateMember)
- {
- AddPropertyCodeActions(result, document, state);
- AddFieldCodeActions(result, document, state);
- }
-
- AddLocalCodeActions(result, document, state);
- }
- else
- {
- if (canGenerateMember)
- {
- AddFieldCodeActions(result, document, state);
- AddPropertyCodeActions(result, document, state);
- }
-
- AddLocalCodeActions(result, document, state);
- }
-
- return result;
- }
-
- protected virtual bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol containingType)
- {
- return false;
- }
-
- private void AddPropertyCodeActions(List<CodeAction> result, Document document, State state)
- {
- if (state.IsInRefContext || state.IsInOutContext)
- {
- return;
- }
-
- if (state.IsConstant)
- {
- return;
- }
-
- if (state.TypeToGenerateIn.TypeKind == TypeKind.Interface && state.IsStatic)
- {
- return;
- }
-
- result.Add(new GenerateVariableCodeAction((TService)this, document, state, generateProperty: true, isReadonly: false, isConstant: false));
-
- if (state.TypeToGenerateIn.TypeKind == TypeKind.Interface && !state.IsWrittenTo)
- {
- result.Add(new GenerateVariableCodeAction((TService)this, document, state, generateProperty: true, isReadonly: true, isConstant: false));
- }
- }
-
- private void AddFieldCodeActions(List<CodeAction> result, Document document, State state)
- {
- if (state.TypeToGenerateIn.TypeKind != TypeKind.Interface)
- {
- if (state.IsConstant)
- {
- result.Add(new GenerateVariableCodeAction((TService)this, document, state, generateProperty: false, isReadonly: false, isConstant: true));
- }
- else
- {
- result.Add(new GenerateVariableCodeAction((TService)this, document, state, generateProperty: false, isReadonly: false, isConstant: false));
-
- // If we haven't written to the field, or we're in the constructor for the type
- // we're writing into, then we can generate this field read-only.
- if (!state.IsWrittenTo || state.IsInConstructor)
- {
- result.Add(new GenerateVariableCodeAction((TService)this, document, state, generateProperty: false, isReadonly: true, isConstant: false));
- }
- }
- }
- }
-
- private void AddLocalCodeActions(List<CodeAction> result, Document document, State state)
- {
- if (state.CanGenerateLocal())
- {
- result.Add(new GenerateLocalCodeAction((TService)this, document, state));
- }
- }
-
- private partial class GenerateVariableCodeAction : CodeAction
- {
- //private readonly TService _service;
- private readonly State _state;
- private readonly bool _generateProperty;
- private readonly bool _isReadonly;
- private readonly bool _isConstant;
- private readonly Document _document;
- private readonly string _equivalenceKey;
-
- public GenerateVariableCodeAction(
- TService service,
- Document document,
- State state,
- bool generateProperty,
- bool isReadonly,
- bool isConstant)
- {
- //_service = service;
- _document = document;
- _state = state;
- _generateProperty = generateProperty;
- _isReadonly = isReadonly;
- _isConstant = isConstant;
- _equivalenceKey = Title;
- }
-
- protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- var generateUnsafe = _state.TypeMemberType.IsUnsafe() &&
- !_state.IsContainedInUnsafeType;
-
- if (_generateProperty)
- {
- var getAccessor = CodeGenerationSymbolFactory.CreateAccessorSymbol(
- attributes: null,
- accessibility: DetermineMaximalAccessibility(_state),
- statements: null);
- var setAccessor = _isReadonly ? null : CodeGenerationSymbolFactory.CreateAccessorSymbol(
- attributes: null,
- accessibility: DetermineMinimalAccessibility(_state),
- statements: null);
-
- var result = await ICSharpCode.NRefactory6.CSharp.CodeGenerator.AddPropertyDeclarationAsync(
- _document.Project.Solution,
- _state.TypeToGenerateIn,
- CodeGenerationSymbolFactory.CreatePropertySymbol(
- attributes: null,
- accessibility: DetermineMaximalAccessibility(_state),
- modifiers: DeclarationModifiers.None.WithIsStatic(_state.IsStatic).WithIsUnsafe (generateUnsafe),
- type: _state.TypeMemberType,
- explicitInterfaceSymbol: null,
- name: _state.IdentifierToken.ValueText,
- isIndexer: _state.IsIndexer,
- parameters: _state.Parameters,
- getMethod: getAccessor,
- setMethod: setAccessor),
- new CodeGenerationOptions(contextLocation: _state.IdentifierToken.GetLocation(), generateDefaultAccessibility: false),
- cancellationToken: cancellationToken)
- .ConfigureAwait(false);
-
- return await AnnotateInsertionMode (_document.Project.Solution.GetDocument(result.Id), result);
- }
- else
- {
- var result = await ICSharpCode.NRefactory6.CSharp.CodeGenerator.AddFieldDeclarationAsync(
- _document.Project.Solution,
- _state.TypeToGenerateIn,
- CodeGenerationSymbolFactory.CreateFieldSymbol(
- attributes: null,
- accessibility: DetermineMinimalAccessibility(_state),
- modifiers: _isConstant ?
- DeclarationModifiers.None.WithIsConst(true).WithIsUnsafe(generateUnsafe) :
- DeclarationModifiers.None.WithIsStatic(_state.IsStatic).WithIsReadOnly (_isReadonly).WithIsUnsafe(generateUnsafe),
- type: _state.TypeMemberType,
- name: _state.IdentifierToken.ValueText),
- new CodeGenerationOptions(contextLocation: _state.IdentifierToken.GetLocation(), generateDefaultAccessibility: false),
- cancellationToken: cancellationToken)
- .ConfigureAwait(false);
-
- return await AnnotateInsertionMode (_document.Project.Solution.GetDocument (result.Id), result);
- }
- }
-
- async Task<Document> AnnotateInsertionMode (Document oldDocument, Document result)
- {
- var newRoot = await result.GetSyntaxRootAsync ();
- var changes = await oldDocument.GetTextChangesAsync (result);
- foreach (var change in changes) {
-
- var parent = newRoot.FindNode (change.Span);
- if (parent == null || !(parent is FieldDeclarationSyntax || parent is PropertyDeclarationSyntax))
- continue;
- return result.WithSyntaxRoot (newRoot.ReplaceNode (parent, parent.WithAdditionalAnnotations (TypeSystemService.InsertionModeAnnotation)));
- }
- return result;
- }
-
- private Accessibility DetermineMaximalAccessibility(State state)
- {
- if (state.TypeToGenerateIn.TypeKind == TypeKind.Interface)
- {
- return Accessibility.NotApplicable;
- }
-
- var accessibility = Accessibility.Public;
-
- // Ensure that we're not overly exposing a type.
- var containingTypeAccessibility = state.TypeToGenerateIn.DetermineMinimalAccessibility();
- var effectiveAccessibility = CommonAccessibilityUtilities.Minimum(
- containingTypeAccessibility, accessibility);
-
- var returnTypeAccessibility = state.TypeMemberType.DetermineMinimalAccessibility();
-
- if (CommonAccessibilityUtilities.Minimum(effectiveAccessibility, returnTypeAccessibility) !=
- effectiveAccessibility)
- {
- return returnTypeAccessibility;
- }
-
- return accessibility;
- }
-
- private Accessibility DetermineMinimalAccessibility(State state)
- {
- if (state.TypeToGenerateIn.TypeKind == TypeKind.Interface)
- {
- return Accessibility.NotApplicable;
- }
-
- // Otherwise, figure out what accessibility modifier to use and optionally mark
- // it as static.
- if (state.SimpleNameOrMemberAccessExpressionOpt.IsAttributeNamedArgumentIdentifier())
- {
- return Accessibility.Public;
- }
- else if (state.ContainingType.IsContainedWithin(state.TypeToGenerateIn))
- {
- return Accessibility.Private;
- }
- else if (DerivesFrom(state, state.ContainingType) && state.IsStatic)
- {
- // NOTE(cyrusn): We only generate protected in the case of statics. Consider
- // the case where we're generating into one of our base types. i.e.:
- //
- // class B : A { void Foo() { A a; a.Foo(); }
- //
- // In this case we can *not* mark the method as protected. 'B' can only
- // access protected members of 'A' through an instance of 'B' (or a subclass
- // of B). It can not access protected members through an instance of the
- // superclass. In this case we need to make the method public or internal.
- //
- // However, this does not apply if the method will be static. i.e.
- //
- // class B : A { void Foo() { A.Foo(); }
- //
- // B can access the protected statics of A, and so we generate 'Foo' as
- // protected.
- return Accessibility.Protected;
- }
- else if (state.ContainingType.ContainingAssembly.IsSameAssemblyOrHasFriendAccessTo(state.TypeToGenerateIn.ContainingAssembly))
- {
- return Accessibility.Internal;
- }
- else
- {
- // TODO: Code coverage - we need a unit-test that generates across projects
- return Accessibility.Public;
- }
- }
-
- private bool DerivesFrom(State state, INamedTypeSymbol containingType)
- {
- return containingType.GetBaseTypes().Select(t => t.OriginalDefinition)
- .Contains(state.TypeToGenerateIn);
- }
-
- public override string Title
- {
- get
- {
- var text = _isConstant
- ? Resources.GenerateConstantIn
- : _generateProperty
- ? _isReadonly ? Resources.GenerateReadonlyProperty : Resources.GeneratePropertyIn
- : _isReadonly ? Resources.GenerateReadonlyField : Resources.GenerateFieldIn;
-
- return string.Format(
- text,
- _state.IdentifierToken.ValueText,
- _state.TypeToGenerateIn.Name);
- }
- }
-
- public override string EquivalenceKey
- {
- get
- {
- return _equivalenceKey;
- }
- }
- }
-
- private class GenerateLocalCodeAction : CodeAction
- {
- private readonly TService _service;
- private readonly Document _document;
- private readonly State _state;
-
- public GenerateLocalCodeAction(TService service, Document document, State state)
- {
- _service = service;
- _document = document;
- _state = state;
- }
-
- public override string Title
- {
- get
- {
- var text = Resources.GenerateLocal;
-
- return string.Format(
- text,
- _state.IdentifierToken.ValueText);
- }
- }
-
- protected override Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- var newRoot = GetNewRoot(cancellationToken);
- var newDocument = _document.WithSyntaxRoot(newRoot);
-
- return Task.FromResult(newDocument);
- }
-
- private SyntaxNode GetNewRoot(CancellationToken cancellationToken)
- {
- SyntaxNode newRoot;
- if (_service.TryConvertToLocalDeclaration(_state.LocalType, _state.IdentifierToken, _document.Project.Solution.Workspace.Options, out newRoot))
- {
- return newRoot;
- }
-
- var syntaxFactory = _document.GetLanguageService<SyntaxGenerator>();
- var initializer = _state.IsOnlyWrittenTo
- ? null
- : syntaxFactory.DefaultExpression(_state.LocalType);
-
- var type = _state.LocalType;
- var localStatement = syntaxFactory.LocalDeclarationStatement(type, _state.IdentifierToken.ValueText, initializer);
- localStatement = localStatement.WithAdditionalAnnotations(Microsoft.CodeAnalysis.Formatting.Formatter.Annotation);
-
- var codeGenService = new CSharpCodeGenerationService (_document.Project.Solution.Workspace);
- var root = _state.IdentifierToken.GetAncestors<SyntaxNode>().Last();
-
- return codeGenService.AddStatements(
- root,
- SpecializedCollections.SingletonEnumerable(localStatement),
- options: new CodeGenerationOptions(beforeThisLocation: _state.IdentifierToken.GetLocation()),
- cancellationToken: cancellationToken);
- }
- }
-
- private partial class State
- {
- public INamedTypeSymbol ContainingType { get; private set; }
- public INamedTypeSymbol TypeToGenerateIn { get; private set; }
- public bool IsStatic { get; private set; }
- public bool IsConstant { get; private set; }
- public bool IsIndexer { get; private set; }
- public bool IsContainedInUnsafeType { get; private set; }
- public IList<IParameterSymbol> Parameters { get; private set; }
-
- // Just the name of the method. i.e. "Foo" in "Foo" or "X.Foo"
- public SyntaxToken IdentifierToken { get; private set; }
- public TSimpleNameSyntax SimpleNameOpt { get; private set; }
-
- // The entire expression containing the name. i.e. "X.Foo"
- public TExpressionSyntax SimpleNameOrMemberAccessExpressionOpt { get; private set; }
-
- public ITypeSymbol TypeMemberType { get; private set; }
- public ITypeSymbol LocalType { get; private set; }
-
- public bool IsWrittenTo { get; private set; }
- public bool IsOnlyWrittenTo { get; private set; }
-
- public bool IsInConstructor { get; private set; }
- public bool IsInRefContext { get; private set; }
- public bool IsInOutContext { get; private set; }
- public bool IsInMemberContext { get; private set; }
-
- public bool IsInExecutableBlock { get; private set; }
- public bool IsInConditionalAccessExpression { get; private set; }
-
- public static async Task<State> GenerateAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode interfaceNode,
- CancellationToken cancellationToken)
- {
- var state = new State();
- if (!await state.TryInitializeAsync(service, document, interfaceNode, cancellationToken).ConfigureAwait(false))
- {
- return null;
- }
-
- return state;
- }
-
- private async Task<bool> TryInitializeAsync(
- TService service,
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- if (service.IsIdentifierNameGeneration(node))
- {
- // Cases that we deal with currently:
- //
- // 1) expr.Foo
- // 2) expr->Foo
- // 3) Foo
- if (!TryInitializeSimpleName(service, document, (TSimpleNameSyntax)node, cancellationToken))
- {
- return false;
- }
- }
- else if (service.IsExplicitInterfaceGeneration(node))
- {
- // 4) bool IFoo.NewProp
- if (!TryInitializeExplicitInterface(service, document, node, cancellationToken))
- {
- return false;
- }
- }
- else
- {
- return false;
- }
-
- // Ok. It either didn't bind to any symbols, or it bound to a symbol but with
- // errors. In the former case we definitely want to offer to generate a field. In
- // the latter case, we want to generate a field *unless* there's an existing member
- // with the same name. Note: it's ok if there's a method with the same name.
- var existingMembers = this.TypeToGenerateIn.GetMembers(this.IdentifierToken.ValueText)
- .Where(m => m.Kind != SymbolKind.Method);
- if (existingMembers.Any())
- {
- // TODO: Code coverage
- // There was an existing method that the new method would clash with.
- return false;
- }
-
- if (cancellationToken.IsCancellationRequested)
- {
- return false;
- }
-
- this.TypeToGenerateIn = await SymbolFinder.FindSourceDefinitionAsync(this.TypeToGenerateIn, document.Project.Solution, cancellationToken).ConfigureAwait(false) as INamedTypeSymbol;
-
- if (!service.ValidateTypeToGenerateIn(
- document.Project.Solution, this.TypeToGenerateIn, this.IsStatic, ClassInterfaceModuleStructTypes, cancellationToken))
- {
- return false;
- }
-
- this.IsContainedInUnsafeType = service.ContainingTypesOrSelfHasUnsafeKeyword(this.TypeToGenerateIn);
-
- return CanGenerateLocal() || ICSharpCode.NRefactory6.CSharp.CodeGenerator.CanAdd(document.Project.Solution, this.TypeToGenerateIn, cancellationToken);
- }
-
- internal bool CanGenerateLocal()
- {
- return !this.IsInMemberContext && this.IsInExecutableBlock;
- }
-
- private bool TryInitializeExplicitInterface(
- TService service,
- SemanticDocument document,
- SyntaxNode propertyDeclaration,
- CancellationToken cancellationToken)
- {
- SyntaxToken identifierToken;
- IPropertySymbol propertySymbol;
- INamedTypeSymbol typeToGenerateIn;
- if (!service.TryInitializeExplicitInterfaceState(
- document, propertyDeclaration, cancellationToken,
- out identifierToken, out propertySymbol, out typeToGenerateIn))
- {
- return false;
- }
-
- this.IdentifierToken = identifierToken;
- this.TypeToGenerateIn = typeToGenerateIn;
-
- if (propertySymbol.ExplicitInterfaceImplementations.Any())
- {
- return false;
- }
-
- cancellationToken.ThrowIfCancellationRequested();
-
- var semanticModel = document.SemanticModel;
- this.ContainingType = semanticModel.GetEnclosingNamedType(this.IdentifierToken.SpanStart, cancellationToken);
- if (this.ContainingType == null)
- {
- return false;
- }
-
- if (!this.ContainingType.Interfaces.OfType<INamedTypeSymbol>().Contains(this.TypeToGenerateIn))
- {
- return false;
- }
-
- this.IsIndexer = propertySymbol.IsIndexer;
- this.Parameters = propertySymbol.Parameters;
- this.TypeMemberType = propertySymbol.Type;
-
- // By default, make it readonly, unless there's already an setter defined.
- this.IsWrittenTo = propertySymbol.SetMethod != null;
-
- return true;
- }
-
- private bool TryInitializeSimpleName(
- TService service,
- SemanticDocument document,
- TSimpleNameSyntax simpleName,
- CancellationToken cancellationToken)
- {
- SyntaxToken identifierToken;
- TExpressionSyntax simpleNameOrMemberAccessExpression;
- bool isInExecutableBlock;
- bool isInConditionalAccessExpression;
- if (!service.TryInitializeIdentifierNameState(
- document, simpleName, cancellationToken,
- out identifierToken, out simpleNameOrMemberAccessExpression, out isInExecutableBlock, out isInConditionalAccessExpression))
- {
- return false;
- }
-
- if (string.IsNullOrWhiteSpace(identifierToken.ValueText))
- {
- return false;
- }
-
- this.SimpleNameOpt = simpleName;
- this.IdentifierToken = identifierToken;
- this.SimpleNameOrMemberAccessExpressionOpt = simpleNameOrMemberAccessExpression;
- this.IsInExecutableBlock = isInExecutableBlock;
- this.IsInConditionalAccessExpression = isInConditionalAccessExpression;
-
- // If we're in a type context then we shouldn't offer to generate a field or
- // property.
- if (SimpleNameOrMemberAccessExpressionOpt.IsInNamespaceOrTypeContext())
- {
- return false;
- }
-
- var expr = SimpleNameOrMemberAccessExpressionOpt as ExpressionSyntax;
- this.IsConstant = expr.IsInConstantContext();
-
- // If we're not in a type, don't even bother. NOTE(cyrusn): We'll have to rethink this
- // for C# Script.
- cancellationToken.ThrowIfCancellationRequested();
- var semanticModel = document.SemanticModel;
- this.ContainingType = semanticModel.GetEnclosingNamedType(this.IdentifierToken.SpanStart, cancellationToken);
- if (this.ContainingType == null)
- {
- return false;
- }
-
- // Now, try to bind the invocation and see if it succeeds or not. if it succeeds and
- // binds uniquely, then we don't need to offer this quick fix.
- cancellationToken.ThrowIfCancellationRequested();
- var semanticInfo = semanticModel.GetSymbolInfo(this.SimpleNameOrMemberAccessExpressionOpt, cancellationToken);
-
- cancellationToken.ThrowIfCancellationRequested();
- if (semanticInfo.Symbol != null)
- {
- return false;
- }
-
- // Either we found no matches, or this was ambiguous. Either way, we might be able
- // to generate a method here. Determine where the user wants to generate the method
- // into, and if it's valid then proceed.
- cancellationToken.ThrowIfCancellationRequested();
- INamedTypeSymbol typeToGenerateIn;
- bool isStatic;
- if (!service.TryDetermineTypeToGenerateIn(document, this.ContainingType, this.SimpleNameOrMemberAccessExpressionOpt, cancellationToken,
- out typeToGenerateIn, out isStatic))
- {
- return false;
- }
-
- this.TypeToGenerateIn = typeToGenerateIn;
- this.IsStatic = isStatic;
-
- DetermineFieldType(document, cancellationToken);
-
- this.IsInRefContext = expr.IsInRefContext();
- this.IsInOutContext = expr.IsInOutContext();
- this.IsWrittenTo = expr.IsWrittenTo();
- this.IsOnlyWrittenTo = expr.IsOnlyWrittenTo();
- this.IsInConstructor = DetermineIsInConstructor(document);
- this.IsInMemberContext = this.SimpleNameOpt != this.SimpleNameOrMemberAccessExpressionOpt ||
- expr.IsObjectInitializerNamedAssignmentIdentifier();
- return true;
- }
-
- private void DetermineFieldType(
- SemanticDocument document,
- CancellationToken cancellationToken)
- {
- var inferredType = TypeGuessing.typeInferenceService.InferType(
- document.SemanticModel, this.SimpleNameOrMemberAccessExpressionOpt,
- objectAsDefault: true,
- cancellationToken: cancellationToken);
- inferredType = inferredType.SpecialType == SpecialType.System_Void
- ? document.SemanticModel.Compilation.ObjectType
- : inferredType;
-
- if (this.IsInConditionalAccessExpression)
- {
- inferredType = inferredType.RemoveNullableIfPresent();
- }
-
- // Substitute 'object' for all captured method type parameters. Note: we may need to
- // do this for things like anonymous types, as well as captured type parameters that
- // aren't in scope in the destination type.
- var capturedMethodTypeParameters = inferredType.GetReferencedMethodTypeParameters();
- var mapping = capturedMethodTypeParameters.ToDictionary(tp => tp,
- tp => document.SemanticModel.Compilation.ObjectType);
-
- this.TypeMemberType = inferredType.SubstituteTypes(mapping, document.SemanticModel.Compilation);
- var availableTypeParameters = this.TypeToGenerateIn.GetAllTypeParameters();
- this.TypeMemberType = TypeMemberType.RemoveUnavailableTypeParameters(
- document.SemanticModel.Compilation, availableTypeParameters);
-
- var enclosingMethodSymbol = document.SemanticModel.GetEnclosingSymbol<IMethodSymbol>(this.SimpleNameOrMemberAccessExpressionOpt.SpanStart, cancellationToken);
- if (enclosingMethodSymbol != null && enclosingMethodSymbol.TypeParameters != null && enclosingMethodSymbol.TypeParameters.Count() != 0)
- {
- var combinedTypeParameters = new List<ITypeParameterSymbol>();
- combinedTypeParameters.AddRange(availableTypeParameters);
- combinedTypeParameters.AddRange(enclosingMethodSymbol.TypeParameters);
- this.LocalType = inferredType.RemoveUnavailableTypeParameters(
- document.SemanticModel.Compilation, combinedTypeParameters);
- }
- else
- {
- this.LocalType = this.TypeMemberType;
- }
- }
-
- private bool DetermineIsInConstructor(SemanticDocument document)
- {
- if (!this.ContainingType.OriginalDefinition.Equals(this.TypeToGenerateIn.OriginalDefinition))
- {
- return false;
- }
-
- return SimpleNameOpt.IsInConstructor();
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateVariable/CSharpGenerateVariableService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateVariable/CSharpGenerateVariableService.cs
deleted file mode 100644
index 826b40dfe7..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateMember/GenerateVariable/CSharpGenerateVariableService.cs
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.GenerateMember.GenerateVariable;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace Microsoft.CodeAnalysis.GenerateMember.GenerateVariable
-{
- partial class CSharpGenerateVariableService :
- AbstractGenerateVariableService<CSharpGenerateVariableService, SimpleNameSyntax, ExpressionSyntax>
- {
- protected override bool IsExplicitInterfaceGeneration(SyntaxNode node)
- {
- return node is PropertyDeclarationSyntax;
- }
-
- protected override bool IsIdentifierNameGeneration(SyntaxNode node)
- {
- return node is IdentifierNameSyntax;
- }
-
- protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol containingType)
- {
- return containingType.ContainingTypesOrSelfHasUnsafeKeyword();
- }
-
- protected override bool TryInitializeExplicitInterfaceState(
- SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken,
- out SyntaxToken identifierToken, out IPropertySymbol propertySymbol, out INamedTypeSymbol typeToGenerateIn)
- {
- var propertyDeclaration = (PropertyDeclarationSyntax)node;
- identifierToken = propertyDeclaration.Identifier;
-
- if (propertyDeclaration.ExplicitInterfaceSpecifier != null)
- {
- var semanticModel = document.SemanticModel;
- propertySymbol = semanticModel.GetDeclaredSymbol(propertyDeclaration, cancellationToken) as IPropertySymbol;
- if (propertySymbol != null && !propertySymbol.ExplicitInterfaceImplementations.Any())
- {
- var info = semanticModel.GetTypeInfo(propertyDeclaration.ExplicitInterfaceSpecifier.Name, cancellationToken);
- typeToGenerateIn = info.Type as INamedTypeSymbol;
- return typeToGenerateIn != null;
- }
- }
-
- identifierToken = default(SyntaxToken);
- propertySymbol = null;
- typeToGenerateIn = null;
- return false;
- }
-
- protected override bool TryInitializeIdentifierNameState(
- SemanticDocument document, SimpleNameSyntax identifierName, CancellationToken cancellationToken,
- out SyntaxToken identifierToken, out ExpressionSyntax simpleNameOrMemberAccessExpression, out bool isInExecutableBlock, out bool isConditionalAccessExpression)
- {
- identifierToken = identifierName.Identifier;
- if (identifierToken.ValueText != string.Empty &&
- !identifierName.IsVar)
- {
- var memberAccess = identifierName.Parent as MemberAccessExpressionSyntax;
- var conditionalMemberAccess = identifierName.Parent.Parent as ConditionalAccessExpressionSyntax;
- if (memberAccess?.Name == identifierName)
- {
- simpleNameOrMemberAccessExpression = (ExpressionSyntax)memberAccess;
- }
- else if ((conditionalMemberAccess?.WhenNotNull as MemberBindingExpressionSyntax)?.Name == identifierName)
- {
- simpleNameOrMemberAccessExpression = conditionalMemberAccess;
- }
- else
- {
- simpleNameOrMemberAccessExpression = identifierName;
- }
-
- // If we're being invoked, then don't offer this, offer generate method instead.
- // Note: we could offer to generate a field with a delegate type. However, that's
- // very esoteric and probably not what most users want.
- if (!IsLegal(document, simpleNameOrMemberAccessExpression, cancellationToken))
- {
- isInExecutableBlock = false;
- isConditionalAccessExpression = false;
- return false;
- }
-
- var block = identifierName.GetAncestor<BlockSyntax>();
- isInExecutableBlock = block != null && !block.OverlapsHiddenPosition(cancellationToken);
- isConditionalAccessExpression = conditionalMemberAccess != null;
- return true;
- }
-
- identifierToken = default(SyntaxToken);
- simpleNameOrMemberAccessExpression = null;
- isInExecutableBlock = false;
- isConditionalAccessExpression = false;
- return false;
- }
-
- private bool IsLegal(
- SemanticDocument document,
- ExpressionSyntax expression,
- CancellationToken cancellationToken)
- {
- // TODO(cyrusn): Consider supporting this at some point. It is difficult because we'd
- // need to replace the identifier typed with the fully qualified name of the field we
- // were generating.
- if (expression.IsParentKind(SyntaxKind.AttributeArgument))
- {
- return false;
- }
-
- if (expression.IsParentKind(SyntaxKind.ConditionalAccessExpression))
- {
- return true;
- }
-
- return expression.CanReplaceWithLValue(document.SemanticModel, cancellationToken);
- }
-
- protected override bool TryConvertToLocalDeclaration(ITypeSymbol type, SyntaxToken identifierToken, OptionSet options, out SyntaxNode newRoot)
- {
- var token = (SyntaxToken)identifierToken;
- var node = identifierToken.Parent as IdentifierNameSyntax;
- if (node.IsLeftSideOfAssignExpression() && node.Parent.IsParentKind(SyntaxKind.ExpressionStatement))
- {
- var assignExpression = (AssignmentExpressionSyntax)node.Parent;
- var expressionStatement = (StatementSyntax)assignExpression.Parent;
-
- var declarationStatement = SyntaxFactory.LocalDeclarationStatement(
- SyntaxFactory.VariableDeclaration(
- GenerateTypeSyntax(type, options),
- SyntaxFactory.SingletonSeparatedList(
- SyntaxFactory.VariableDeclarator(token, null, SyntaxFactory.EqualsValueClause(
- assignExpression.OperatorToken, assignExpression.Right)))));
- declarationStatement = declarationStatement.WithAdditionalAnnotations(Formatter.Annotation);
-
- var root = token.GetAncestor<CompilationUnitSyntax>();
- newRoot = root.ReplaceNode(expressionStatement, declarationStatement);
-
- return true;
- }
-
- newRoot = null;
- return false;
- }
-
- private static TypeSyntax GenerateTypeSyntax(ITypeSymbol type, OptionSet options)
- {
- return type.ContainsAnonymousType() ||
- (true/*options.GetOption(CSharpCodeStyleOptions.UseVarWhenDeclaringLocals)*/ && type.TypeKind != TypeKind.Delegate)
- ? SyntaxFactory.IdentifierName("var")
- : type.GenerateTypeSyntax();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/AbstractGenerateTypeService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/AbstractGenerateTypeService.cs
deleted file mode 100644
index 4e3d96b73a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/AbstractGenerateTypeService.cs
+++ /dev/null
@@ -1,1814 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Roslyn.Utilities;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis.FindSymbols;
-using System.IO;
-using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.Ide;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateType
-{
- abstract partial class AbstractGenerateTypeService<TService, TSimpleNameSyntax, TObjectCreationExpressionSyntax, TExpressionSyntax, TTypeDeclarationSyntax, TArgumentSyntax>
- where TService : AbstractGenerateTypeService<TService, TSimpleNameSyntax, TObjectCreationExpressionSyntax, TExpressionSyntax, TTypeDeclarationSyntax, TArgumentSyntax>
- where TSimpleNameSyntax : TExpressionSyntax
- where TObjectCreationExpressionSyntax : TExpressionSyntax
- where TExpressionSyntax : SyntaxNode
- where TTypeDeclarationSyntax : SyntaxNode
- where TArgumentSyntax : SyntaxNode
- {
- protected AbstractGenerateTypeService ()
- {
- }
-
- protected abstract bool TryInitializeState (SemanticDocument document, TSimpleNameSyntax simpleName, CancellationToken cancellationToken, out GenerateTypeServiceStateOptions generateTypeServiceStateOptions);
-
- protected abstract TExpressionSyntax GetLeftSideOfDot (TSimpleNameSyntax simpleName);
-
- protected abstract bool TryGetArgumentList (TObjectCreationExpressionSyntax objectCreationExpression, out IList<TArgumentSyntax> argumentList);
-
- protected abstract string DefaultFileExtension { get; }
-
- protected abstract IList<ITypeParameterSymbol> GetTypeParameters (State state, SemanticModel semanticModel, CancellationToken cancellationToken);
-
- protected abstract Accessibility GetAccessibility (State state, SemanticModel semanticModel, bool intoNamespace, CancellationToken cancellationToken);
-
- protected abstract IList<string> GenerateParameterNames (SemanticModel semanticModel, IList<TArgumentSyntax> arguments);
-
- protected abstract INamedTypeSymbol DetermineTypeToGenerateIn (SemanticModel semanticModel, TSimpleNameSyntax simpleName, CancellationToken cancellationToken);
-
- protected abstract ITypeSymbol DetermineArgumentType (SemanticModel semanticModel, TArgumentSyntax argument, CancellationToken cancellationToken);
-
- protected abstract bool IsInCatchDeclaration (TExpressionSyntax expression);
-
- protected abstract bool IsArrayElementType (TExpressionSyntax expression);
-
- protected abstract bool IsInVariableTypeContext (TExpressionSyntax expression);
-
- protected abstract bool IsInValueTypeConstraintContext (SemanticModel semanticModel, TExpressionSyntax expression, CancellationToken cancellationToken);
-
- protected abstract bool IsInInterfaceList (TExpressionSyntax expression);
-
- internal abstract bool TryGetBaseList (TExpressionSyntax expression, out TypeKindOptions returnValue);
-
- internal abstract bool IsPublicOnlyAccessibility (TExpressionSyntax expression, Project project);
-
- internal abstract bool IsGenericName (TSimpleNameSyntax simpleName);
-
- internal abstract bool IsSimpleName (TExpressionSyntax expression);
-
- internal abstract Solution TryAddUsingsOrImportToDocument (Solution updatedSolution, SyntaxNode modifiedRoot, Document document, TSimpleNameSyntax simpleName, string includeUsingsOrImports, CancellationToken cancellationToken);
-
- protected abstract bool TryGetNameParts (TExpressionSyntax expression, out IList<string> nameParts);
-
- public abstract string GetRootNamespace (CompilationOptions options);
-
- public abstract Task<Tuple<INamespaceSymbol, INamespaceOrTypeSymbol, Location>> GetOrGenerateEnclosingNamespaceSymbol (INamedTypeSymbol namedTypeSymbol, string[] containers, Document selectedDocument, SyntaxNode selectedDocumentRoot, CancellationToken cancellationToken);
-
- public async Task<IEnumerable<CodeAction>> GenerateTypeAsync (
- Document document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- //using (Logger.LogBlock (FunctionId.Refactoring_GenerateType, cancellationToken)) {
- var semanticDocument = await SemanticDocument.CreateAsync (document, cancellationToken).ConfigureAwait (false);
-
- var state = State.Generate ((TService)this, semanticDocument, node, cancellationToken);
- if (state != null) {
- return GetActions (semanticDocument, node, state, cancellationToken);
- }
-
- return SpecializedCollections.EmptyEnumerable<CodeAction> ();
- //}
- }
-
- private IEnumerable<CodeAction> GetActions (
- SemanticDocument document,
- SyntaxNode node,
- State state,
- CancellationToken cancellationToken)
- {
- //var generateNewTypeInDialog = false;
- if (state.NamespaceToGenerateInOpt != null) {
- var workspace = document.Project.Solution.Workspace;
- if (workspace == null || workspace.CanApplyChange (ApplyChangesKind.AddDocument)) {
- //generateNewTypeInDialog = true;
- yield return new GenerateTypeCodeAction ((TService)this, document.Document, state, intoNamespace: true, inNewFile: true);
- }
-
- // If they just are generating "Foo" then we want to offer to generate it into the
- // namespace in the same file. However, if they are generating "SomeNS.Foo", then we
- // only want to allow them to generate if "SomeNS" is the namespace they are
- // currently in.
- var isSimpleName = state.SimpleName == state.NameOrMemberAccessExpression;
- var generateIntoContaining = IsGeneratingIntoContainingNamespace (document, node, state, cancellationToken);
-
- if ((isSimpleName || generateIntoContaining) &&
- CanGenerateIntoContainingNamespace (document, node, state, cancellationToken)) {
- yield return new GenerateTypeCodeAction ((TService)this, document.Document, state, intoNamespace: true, inNewFile: false);
- }
- }
-
- if (state.TypeToGenerateInOpt != null) {
- yield return new GenerateTypeCodeAction ((TService)this, document.Document, state, intoNamespace: false, inNewFile: false);
- }
-
- //if (generateNewTypeInDialog) {
- // yield return new GenerateTypeCodeActionWithOption ((TService)this, document.Document, state);
- //}
- }
-
- private bool CanGenerateIntoContainingNamespace (SemanticDocument document, SyntaxNode node, State state, CancellationToken cancellationToken)
- {
- var containingNamespace = document.SemanticModel.GetEnclosingNamespace (node.SpanStart, cancellationToken);
-
- // Only allow if the containing namespace is one that can be generated
- // into.
- var decl = containingNamespace.GetDeclarations ()
- .Where (r => r.SyntaxTree == node.SyntaxTree)
- .Select (r => r.GetSyntax (cancellationToken))
- .FirstOrDefault (node.GetAncestorsOrThis<SyntaxNode> ().Contains);
-
- return
- decl != null &&
- new CSharpCodeGenerationService (document.Project.Solution.Workspace).CanAddTo (decl, document.Project.Solution, cancellationToken);
- }
-
- private bool IsGeneratingIntoContainingNamespace (
- SemanticDocument document,
- SyntaxNode node,
- State state,
- CancellationToken cancellationToken)
- {
- var containingNamespace = document.SemanticModel.GetEnclosingNamespace (node.SpanStart, cancellationToken);
- if (containingNamespace != null) {
- var containingNamespaceName = containingNamespace.ToDisplayString ();
- return containingNamespaceName.Equals (state.NamespaceToGenerateInOpt);
- }
-
- return false;
- }
-
- protected static string GetTypeName (State state)
- {
- const string AttributeSuffix = "Attribute";
-
- return state.IsAttribute && !state.NameIsVerbatim && !state.Name.EndsWith (AttributeSuffix, StringComparison.Ordinal)
- ? state.Name + AttributeSuffix
- : state.Name;
- }
-
- protected IList<ITypeParameterSymbol> GetTypeParameters (
- State state,
- SemanticModel semanticModel,
- IEnumerable<SyntaxNode> typeArguments,
- CancellationToken cancellationToken)
- {
- var arguments = typeArguments.ToList ();
- var arity = arguments.Count;
- var typeParameters = new List<ITypeParameterSymbol> ();
-
- // For anything that was a type parameter, just use the name (if we haven't already
- // used it). Otherwise, synthesize new names for the parameters.
- var names = new string[arity];
- var isFixed = new bool[arity];
- for (var i = 0; i < arity; i++) {
- var argument = i < arguments.Count ? arguments [i] : null;
- var type = argument == null ? null : semanticModel.GetTypeInfo (argument, cancellationToken).Type;
- if (type is ITypeParameterSymbol) {
- var name = type.Name;
-
- // If we haven't seen this type parameter already, then we can use this name
- // and 'fix' it so that it doesn't change. Otherwise, use it, but allow it
- // to be changed if it collides with anything else.
- isFixed [i] = !names.Contains (name);
- names [i] = name;
- typeParameters.Add ((ITypeParameterSymbol)type);
- } else {
- names [i] = "T";
- typeParameters.Add (null);
- }
- }
-
- // We can use a type parameter as long as it hasn't been used in an outer type.
- var canUse = state.TypeToGenerateInOpt == null
- ? default(Func<string, bool>)
- : s => state.TypeToGenerateInOpt.GetAllTypeParameters ().All (t => t.Name != s);
-
- var uniqueNames = NameGenerator.EnsureUniqueness (names, isFixed, canUse: canUse);
- for (int i = 0; i < uniqueNames.Count; i++) {
- if (typeParameters [i] == null || typeParameters [i].Name != uniqueNames [i]) {
- typeParameters [i] = CodeGenerationSymbolFactory.CreateTypeParameterSymbol (uniqueNames [i]);
- }
- }
-
- return typeParameters;
- }
-
- protected Accessibility DetermineDefaultAccessibility (
- State state,
- SemanticModel semanticModel,
- bool intoNamespace,
- CancellationToken cancellationToken)
- {
- if (state.IsPublicAccessibilityForTypeGeneration) {
- return Accessibility.Public;
- }
-
- // If we're a nested type of the type being generated into, then the new type can be
- // private. otherwise, it needs to be internal.
- if (!intoNamespace && state.TypeToGenerateInOpt != null) {
- var outerTypeSymbol = semanticModel.GetEnclosingNamedType (state.SimpleName.SpanStart, cancellationToken);
-
- if (outerTypeSymbol != null && outerTypeSymbol.IsContainedWithin (state.TypeToGenerateInOpt)) {
- return Accessibility.Private;
- }
- }
-
- return Accessibility.Internal;
- }
-
- protected IList<ITypeParameterSymbol> GetAvailableTypeParameters (
- State state,
- SemanticModel semanticModel,
- bool intoNamespace,
- CancellationToken cancellationToken)
- {
- var availableInnerTypeParameters = GetTypeParameters (state, semanticModel, cancellationToken);
- var availableOuterTypeParameters = !intoNamespace && state.TypeToGenerateInOpt != null
- ? state.TypeToGenerateInOpt.GetAllTypeParameters ()
- : SpecializedCollections.EmptyEnumerable<ITypeParameterSymbol> ();
-
- return availableOuterTypeParameters.Concat (availableInnerTypeParameters).ToList ();
- }
-
- protected bool IsWithinTheImportingNamespace (Document document, int triggeringPosition, string includeUsingsOrImports, CancellationToken cancellationToken)
- {
- var semanticModel = document.GetSemanticModelAsync (cancellationToken).WaitAndGetResult (cancellationToken);
- if (semanticModel != null) {
- var namespaceSymbol = semanticModel.GetEnclosingNamespace (triggeringPosition, cancellationToken);
- if (namespaceSymbol != null && namespaceSymbol.ToDisplayString ().StartsWith (includeUsingsOrImports, StringComparison.Ordinal)) {
- return true;
- }
- }
-
- return false;
- }
-
- protected bool GeneratedTypesMustBePublic (Project project)
- {
-// var projectInfoService = project.Solution.Workspace.Services.GetService<IProjectInfoService> ();
-// if (projectInfoService != null) {
-// return projectInfoService.GeneratedTypesMustBePublic (project);
-// }
-
- return false;
- }
-
- private class GenerateTypeCodeAction : CodeAction
- {
- private readonly bool _intoNamespace;
- private readonly bool _inNewFile;
- private readonly TService _service;
- private readonly Document _document;
- private readonly State _state;
- private readonly string _equivalenceKey;
-
- public GenerateTypeCodeAction (
- TService service,
- Document document,
- State state,
- bool intoNamespace,
- bool inNewFile)
- {
- _service = service;
- _document = document;
- _state = state;
- _intoNamespace = intoNamespace;
- _inNewFile = inNewFile;
- _equivalenceKey = Title;
- }
-
- private static string FormatDisplayText (
- State state,
- bool inNewFile,
- string destination)
- {
- //var finalName = GetTypeName (state);
-
- if (inNewFile) {
- return string.Format (Resources.GenerateForInNewFile,
- state.IsStruct ? "struct" : state.IsInterface ? "interface" : "class",
- state.Name, destination);
- } else {
- return string.Format (Resources.GenerateForIn,
- state.IsStruct ? "struct" : state.IsInterface ? "interface" : "class",
- state.Name, destination);
- }
- }
-
- protected override async Task<IEnumerable<CodeActionOperation>> ComputeOperationsAsync (CancellationToken cancellationToken)
- {
- var semanticDocument = await SemanticDocument.CreateAsync (_document, cancellationToken).ConfigureAwait (false);
-
- var editor = new Editor ( _service, semanticDocument, _state, _intoNamespace, _inNewFile, cancellationToken: cancellationToken);
-
- return await editor.GetOperationsAsync ().ConfigureAwait (false);
- }
-
- public override string Title {
- get {
- if (_intoNamespace) {
- var namespaceToGenerateIn = string.IsNullOrEmpty (_state.NamespaceToGenerateInOpt) ? Resources.GlobalNamespace : _state.NamespaceToGenerateInOpt;
- return FormatDisplayText (_state, _inNewFile, namespaceToGenerateIn);
- } else {
- return FormatDisplayText (_state, inNewFile: false, destination: _state.TypeToGenerateInOpt.Name);
- }
- }
- }
-
- public override string EquivalenceKey {
- get {
- return _equivalenceKey;
- }
- }
- }
-
- private class GenerateTypeCodeActionWithOption : CodeActionWithOptions
- {
- private readonly TService _service;
- private readonly Document _document;
- private readonly State _state;
-
- internal GenerateTypeCodeActionWithOption (TService service, Document document, State state)
- {
- _service = service;
- _document = document;
- _state = state;
- }
-
- public override string Title {
- get {
- return Resources.GenerateNewType;
- }
- }
-
- public override string EquivalenceKey {
- get {
- return _state.Name;
- }
- }
-
- public override object GetOptions (CancellationToken cancellationToken)
- {
- //var typeKindValue = GetTypeKindOption (_state);
- var isPublicOnlyAccessibility = IsPublicOnlyAccessibility (_state, _document.Project);
-
- // TODO : Callback
- return new GenerateTypeOptionsResult (
- isPublicOnlyAccessibility ? Accessibility.Public : Accessibility.Internal,
- TypeKind.Class,
- _state.Name,
- _document.Project,
- true,
- _state.Name + ".cs",
- null,
- null,
- _document,
- false
- );
- /*
- // return generateTypeOptionsService.GetGenerateTypeOptions (
-// _state.Name,
- // new GenerateTypeDialogOptions (isPublicOnlyAccessibility, typeKindValue, _state.IsAttribute),
-// _document,
-// notificationService,
-// projectManagementService,
-// syntaxFactsService);
- private class VisualStudioGenerateTypeOptionsService : IGenerateTypeOptionsService
- {
- private bool _isNewFile = false;
- private string _accessSelectString = "";
- private string _typeKindSelectString = "";
-
- private IGeneratedCodeRecognitionService _generatedCodeService;
-
- public VisualStudioGenerateTypeOptionsService(IGeneratedCodeRecognitionService generatedCodeService)
- {
- _generatedCodeService = generatedCodeService;
- }
-
- public GenerateTypeOptionsResult GetGenerateTypeOptions(
- string typeName,
- GenerateTypeDialogOptions generateTypeDialogOptions,
- Document document,
- INotificationService notificationService,
- IProjectManagementService projectManagementService,
- ISyntaxFactsService syntaxFactsService)
- {
- var viewModel = new GenerateTypeDialogViewModel(
- document,
- notificationService,
- projectManagementService,
- syntaxFactsService,
- _generatedCodeService,
- generateTypeDialogOptions,
- typeName,
- document.Project.Language == LanguageNames.CSharp ? ".cs" : ".vb",
- _isNewFile,
- _accessSelectString,
- _typeKindSelectString);
-
- var dialog = new GenerateTypeDialog(viewModel);
- var result = dialog.ShowModal();
-
- if (result.HasValue && result.Value)
- {
- // Retain choice
- _isNewFile = viewModel.IsNewFile;
- _accessSelectString = viewModel.SelectedAccessibilityString;
- _typeKindSelectString = viewModel.SelectedTypeKindString;
-
- return new GenerateTypeOptionsResult(
- accessibility: viewModel.SelectedAccessibility,
- typeKind: viewModel.SelectedTypeKind,
- typeName: viewModel.TypeName,
- project: viewModel.SelectedProject,
- isNewFile: viewModel.IsNewFile,
- newFileName: viewModel.FileName.Trim(),
- folders: viewModel.Folders,
- fullFilePath: viewModel.FullFilePath,
- existingDocument: viewModel.SelectedDocument,
- areFoldersValidIdentifiers: viewModel.AreFoldersValidIdentifiers);
- }
- else
- {
- return GenerateTypeOptionsResult.Cancelled;
- }
- }
- }
-
- */
- }
-
- private bool IsPublicOnlyAccessibility (State state, Project project)
- {
- return _service.IsPublicOnlyAccessibility (state.NameOrMemberAccessExpression, project) || _service.IsPublicOnlyAccessibility (state.SimpleName, project);
- }
-
- private TypeKindOptions GetTypeKindOption (State state)
- {
- TypeKindOptions typeKindValue;
-
- var gotPreassignedTypeOptions = GetPredefinedTypeKindOption (state, out typeKindValue);
- if (!gotPreassignedTypeOptions) {
- typeKindValue = state.IsSimpleNameGeneric ? TypeKindOptionsHelper.RemoveOptions (typeKindValue, TypeKindOptions.GenericInCompatibleTypes) : typeKindValue;
- typeKindValue = state.IsMembersWithModule ? TypeKindOptionsHelper.AddOption (typeKindValue, TypeKindOptions.Module) : typeKindValue;
- typeKindValue = state.IsInterfaceOrEnumNotAllowedInTypeContext ? TypeKindOptionsHelper.RemoveOptions (typeKindValue, TypeKindOptions.Interface, TypeKindOptions.Enum) : typeKindValue;
- typeKindValue = state.IsDelegateAllowed ? typeKindValue : TypeKindOptionsHelper.RemoveOptions (typeKindValue, TypeKindOptions.Delegate);
- typeKindValue = state.IsEnumNotAllowed ? TypeKindOptionsHelper.RemoveOptions (typeKindValue, TypeKindOptions.Enum) : typeKindValue;
- }
-
- return typeKindValue;
- }
-
- private bool GetPredefinedTypeKindOption (State state, out TypeKindOptions typeKindValueFinal)
- {
- if (state.IsAttribute) {
- typeKindValueFinal = TypeKindOptions.Attribute;
- return true;
- }
-
- TypeKindOptions typeKindValue = TypeKindOptions.None;
- if (_service.TryGetBaseList (state.NameOrMemberAccessExpression, out typeKindValue) || _service.TryGetBaseList (state.SimpleName, out typeKindValue)) {
- typeKindValueFinal = typeKindValue;
- return true;
- }
-
- if (state.IsClassInterfaceTypes) {
- typeKindValueFinal = TypeKindOptions.BaseList;
- return true;
- }
-
- if (state.IsDelegateOnly) {
- typeKindValueFinal = TypeKindOptions.Delegate;
- return true;
- }
-
- if (state.IsTypeGeneratedIntoNamespaceFromMemberAccess) {
- typeKindValueFinal = state.IsSimpleNameGeneric ? TypeKindOptionsHelper.RemoveOptions (TypeKindOptions.MemberAccessWithNamespace, TypeKindOptions.GenericInCompatibleTypes) : TypeKindOptions.MemberAccessWithNamespace;
- typeKindValueFinal = state.IsEnumNotAllowed ? TypeKindOptionsHelper.RemoveOptions (typeKindValueFinal, TypeKindOptions.Enum) : typeKindValueFinal;
- return true;
- }
-
- typeKindValueFinal = TypeKindOptions.AllOptions;
- return false;
- }
-
- protected override async Task<IEnumerable<CodeActionOperation>> ComputeOperationsAsync (object options, CancellationToken cancellationToken)
- {
- IEnumerable<CodeActionOperation> operations = null;
-
- var generateTypeOptions = options as GenerateTypeOptionsResult;
- if (generateTypeOptions != null && !generateTypeOptions.IsCancelled) {
- var semanticDocument = SemanticDocument.CreateAsync (_document, cancellationToken).WaitAndGetResult (cancellationToken);
- var editor = new Editor (_service, semanticDocument, _state, true, generateTypeOptions, cancellationToken);
- operations = await editor.GetOperationsAsync ().ConfigureAwait (false);
- }
-
- return operations;
- }
- }
-
- protected abstract bool IsConversionImplicit (Compilation compilation, ITypeSymbol sourceType, ITypeSymbol targetType);
-
- private partial class Editor
- {
- private TService _service;
- private TargetProjectChangeInLanguage _targetProjectChangeInLanguage = TargetProjectChangeInLanguage.NoChange;
- AbstractGenerateTypeService<TService, TSimpleNameSyntax, TObjectCreationExpressionSyntax, TExpressionSyntax, TTypeDeclarationSyntax, TArgumentSyntax> _targetLanguageService;
-
- private readonly SemanticDocument _document;
- private readonly State _state;
- private readonly bool _intoNamespace;
- private readonly bool _inNewFile;
- private readonly bool _fromDialog;
- private readonly GenerateTypeOptionsResult _generateTypeOptionsResult;
- private readonly CancellationToken _cancellationToken;
-
-
- public Editor (
- TService service,
- SemanticDocument document,
- State state,
- bool intoNamespace,
- bool inNewFile,
- CancellationToken cancellationToken)
- {
- _service = service;
- _document = document;
- _state = state;
- _intoNamespace = intoNamespace;
- _inNewFile = inNewFile;
- _cancellationToken = cancellationToken;
- }
-
- public Editor (
- TService service,
- SemanticDocument document,
- State state,
- bool fromDialog,
- GenerateTypeOptionsResult generateTypeOptionsResult,
- CancellationToken cancellationToken)
- {
- _service = service;
- _document = document;
- _state = state;
- _fromDialog = fromDialog;
- _generateTypeOptionsResult = generateTypeOptionsResult;
- _cancellationToken = cancellationToken;
- }
-
- private enum TargetProjectChangeInLanguage
- {
- NoChange,
- CSharpToVisualBasic,
- VisualBasicToCSharp
- }
-
- internal async Task<IEnumerable<CodeActionOperation>> GetOperationsAsync ()
- {
- // Check to see if it is from GFU Dialog
- if (!_fromDialog) {
- // Generate the actual type declaration.
- var namedType = GenerateNamedType ();
-
- if (_intoNamespace) {
- if (_inNewFile) {
- // Generating into a new file is somewhat complicated.
- var documentName = GetTypeName (_state) + _service.DefaultFileExtension;
-
- return await GetGenerateInNewFileOperationsAsync (
- namedType,
- documentName,
- null,
- true,
- null,
- _document.Project,
- _document.Project,
- isDialog: false).ConfigureAwait (false);
- } else {
- return await GetGenerateIntoContainingNamespaceOperationsAsync (namedType).ConfigureAwait (false);
- }
- } else {
- return await GetGenerateIntoTypeOperationsAsync (namedType).ConfigureAwait (false);
- }
- } else {
- var namedType = GenerateNamedType (_generateTypeOptionsResult);
-
-// // Honor the options from the dialog
-// // Check to see if the type is requested to be generated in cross language Project
-// // e.g.: C# -> VB or VB -> C#
-// if (_document.Project.Language != _generateTypeOptionsResult.Project.Language) {
-// _targetProjectChangeInLanguage =
-// _generateTypeOptionsResult.Project.Language == LanguageNames.CSharp
-// ? TargetProjectChangeInLanguage.VisualBasicToCSharp
-// : TargetProjectChangeInLanguage.CSharpToVisualBasic;
-//
-// // Get the cross language service
-// _targetLanguageService = _generateTypeOptionsResult.Project.LanguageServices.GetService<IGenerateTypeService> ();
-// }
-
- if (_generateTypeOptionsResult.IsNewFile) {
- return await GetGenerateInNewFileOperationsAsync (
- namedType,
- _generateTypeOptionsResult.NewFileName,
- _generateTypeOptionsResult.Folders,
- _generateTypeOptionsResult.AreFoldersValidIdentifiers,
- _generateTypeOptionsResult.FullFilePath,
- _generateTypeOptionsResult.Project,
- _document.Project,
- isDialog: true).ConfigureAwait (false);
- } else {
- return await GetGenerateIntoExistingDocumentAsync (
- namedType,
- _document.Project,
- _generateTypeOptionsResult,
- isDialog: true).ConfigureAwait (false);
- }
- }
- }
-
- private string GetNamespaceToGenerateInto ()
- {
- var namespaceToGenerateInto = _state.NamespaceToGenerateInOpt.Trim ();
- var rootNamespace = _service.GetRootNamespace (_document.SemanticModel.Compilation.Options).Trim ();
- if (!string.IsNullOrWhiteSpace (rootNamespace)) {
- if (namespaceToGenerateInto == rootNamespace ||
- namespaceToGenerateInto.StartsWith (rootNamespace + ".", StringComparison.Ordinal)) {
- namespaceToGenerateInto = namespaceToGenerateInto.Substring (rootNamespace.Length);
- }
- }
-
- return namespaceToGenerateInto;
- }
-
- private string GetNamespaceToGenerateIntoForUsageWithNamespace (Project targetProject, Project triggeringProject)
- {
- var namespaceToGenerateInto = _state.NamespaceToGenerateInOpt.Trim ();
-
- if (targetProject.Language == LanguageNames.CSharp ||
- targetProject == triggeringProject) {
- // If the target project is C# project then we don't have to make any modification to the namespace
- // or
- // This is a VB project generation into itself which requires no change as well
- return namespaceToGenerateInto;
- }
-
- // If the target Project is VB then we have to check if the RootNamespace of the VB project is the parent most namespace of the type being generated
- // True, Remove the RootNamespace
- // False, Add Global to the Namespace
- //Contract.Assert (targetProject.Language == LanguageNames.VisualBasic);
- var targetLanguageService = _targetLanguageService;
-// if (_document.Project.Language == LanguageNames.VisualBasic) {
-// targetLanguageService = _service;
-// } else {
-// targetLanguageService = _targetLanguageService;
-// }
-
- var rootNamespace = targetLanguageService.GetRootNamespace (targetProject.CompilationOptions).Trim ();
- if (!string.IsNullOrWhiteSpace (rootNamespace)) {
- var rootNamespaceLength = CheckIfRootNamespacePresentInNamespace (namespaceToGenerateInto, rootNamespace);
- if (rootNamespaceLength > -1) {
- // True, Remove the RootNamespace
- namespaceToGenerateInto = namespaceToGenerateInto.Substring (rootNamespaceLength);
- } else {
- // False, Add Global to the Namespace
- namespaceToGenerateInto = AddGlobalDotToTheNamespace (namespaceToGenerateInto);
- }
- } else {
- // False, Add Global to the Namespace
- namespaceToGenerateInto = AddGlobalDotToTheNamespace (namespaceToGenerateInto);
- }
-
- return namespaceToGenerateInto;
- }
-
- private string AddGlobalDotToTheNamespace (string namespaceToBeGenerated)
- {
- return "Global." + namespaceToBeGenerated;
- }
-
- // Returns the length of the meaningful rootNamespace substring part of namespaceToGenerateInto
- private int CheckIfRootNamespacePresentInNamespace (string namespaceToGenerateInto, string rootNamespace)
- {
- if (namespaceToGenerateInto == rootNamespace) {
- return rootNamespace.Length;
- }
-
- if (namespaceToGenerateInto.StartsWith (rootNamespace + ".", StringComparison.Ordinal)) {
- return rootNamespace.Length + 1;
- }
-
- return -1;
- }
-
- private void AddFoldersToNamespaceContainers (List<string> container, IList<string> folders)
- {
- // Add the folder as part of the namespace if there are not empty
- if (folders != null && folders.Count != 0) {
- // Remove the empty entries and replace the spaces in the folder name to '_'
- var refinedFolders = folders.Where (n => n != null && !n.IsEmpty ()).Select (n => n.Replace (' ', '_')).ToArray ();
- container.AddRange (refinedFolders);
- }
- }
-
- private async Task<IEnumerable<CodeActionOperation>> GetGenerateInNewFileOperationsAsync (
- INamedTypeSymbol namedType,
- string documentName,
- IList<string> folders,
- bool areFoldersValidIdentifiers,
- string fullFilePath,
- Project projectToBeUpdated,
- Project triggeringProject,
- bool isDialog)
- {
- // First, we fork the solution with a new, empty, file in it.
- var newDocumentId = DocumentId.CreateNewId (projectToBeUpdated.Id, debugName: documentName);
- var newSolution = projectToBeUpdated.Solution.AddDocument (newDocumentId, documentName, string.Empty, folders, fullFilePath);
-
- // Now we get the semantic model for that file we just added. We do that to get the
- // root namespace in that new document, along with location for that new namespace.
- // That way, when we use the code gen service we can say "add this symbol to the
- // root namespace" and it will pick the one in the new file.
- var newDocument = newSolution.GetDocument (newDocumentId);
- var newSemanticModel = await newDocument.GetSemanticModelAsync (_cancellationToken).ConfigureAwait (false);
- var enclosingNamespace = newSemanticModel.GetEnclosingNamespace (0, _cancellationToken);
-
- var namespaceContainersAndUsings = GetNamespaceContainersAndAddUsingsOrImport (isDialog, folders, areFoldersValidIdentifiers, projectToBeUpdated, triggeringProject);
-
- var containers = namespaceContainersAndUsings.Item1;
- var includeUsingsOrImports = namespaceContainersAndUsings.Item2;
-
- var rootNamespaceOrType = namedType.GenerateRootNamespaceOrType (containers);
-
- // Now, actually ask the code gen service to add this namespace or type to the root
- // namespace in the new file. This will properly generate the code, and add any
- // additional niceties like imports/usings.
- var codeGenResult = await CodeGenerator.AddNamespaceOrTypeDeclarationAsync (
- newSolution,
- enclosingNamespace,
- rootNamespaceOrType,
- new CodeGenerationOptions (newSemanticModel.SyntaxTree.GetLocation (new TextSpan ()), generateDefaultAccessibility: false),
- _cancellationToken).ConfigureAwait (false);
-
- // containers is determined to be
- // 1: folders -> if triggered from Dialog
- // 2: containers -> if triggered not from a Dialog but from QualifiedName
- // 3: triggering document folder structure -> if triggered not from a Dialog and a SimpleName
- var adjustedContainer = isDialog ? folders :
- _state.SimpleName != _state.NameOrMemberAccessExpression ? containers.ToList () : _document.Document.Folders.ToList ();
-
- // Now, take the code that would be generated and actually create an edit that would
- // produce a document with that code in it.
-
- return CreateAddDocumentAndUpdateUsingsOrImportsOperations (
- projectToBeUpdated,
- triggeringProject,
- documentName,
- await codeGenResult.GetSyntaxRootAsync (_cancellationToken).ConfigureAwait (false),
- _document.Document,
- includeUsingsOrImports,
- adjustedContainer,
- SourceCodeKind.Regular,
- _cancellationToken);
- }
-
- private IEnumerable<CodeActionOperation> CreateAddDocumentAndUpdateUsingsOrImportsOperations (
- Project projectToBeUpdated,
- Project triggeringProject,
- string documentName,
- SyntaxNode root,
- Document generatingDocument,
- string includeUsingsOrImports,
- IList<string> containers,
- SourceCodeKind sourceCodeKind,
- CancellationToken cancellationToken)
- {
- // TODO(cyrusn): make sure documentId is unique.
- var documentId = DocumentId.CreateNewId (projectToBeUpdated.Id, documentName);
-
- var updatedSolution = projectToBeUpdated.Solution.AddDocument (DocumentInfo.Create (
- documentId,
- documentName,
- containers,
- sourceCodeKind,
- filePath: Path.Combine (Path.GetDirectoryName (generatingDocument.FilePath), documentName)
- ));
-
- updatedSolution = updatedSolution.WithDocumentSyntaxRoot (documentId, root, PreservationMode.PreserveIdentity);
-
- // Update the Generating Document with a using if required
- if (includeUsingsOrImports != null) {
- updatedSolution = _service.TryAddUsingsOrImportToDocument (updatedSolution, null, _document.Document, _state.SimpleName, includeUsingsOrImports, cancellationToken);
- }
-
- // Add reference of the updated project to the triggering Project if they are 2 different projects
- updatedSolution = AddProjectReference (projectToBeUpdated, triggeringProject, updatedSolution);
-
- return new CodeActionOperation[] {
- new ApplyChangesOperation (updatedSolution),
- new OpenDocumentOperation (documentId)
- };
- }
-
- private static Solution AddProjectReference (Project projectToBeUpdated, Project triggeringProject, Solution updatedSolution)
- {
- if (projectToBeUpdated != triggeringProject) {
- if (!triggeringProject.ProjectReferences.Any (pr => pr.ProjectId == projectToBeUpdated.Id)) {
- updatedSolution = updatedSolution.AddProjectReference (triggeringProject.Id, new ProjectReference (projectToBeUpdated.Id));
- }
- }
-
- return updatedSolution;
- }
-
- private async Task<IEnumerable<CodeActionOperation>> GetGenerateIntoContainingNamespaceOperationsAsync (INamedTypeSymbol namedType)
- {
- var enclosingNamespace = _document.SemanticModel.GetEnclosingNamespace (
- _state.SimpleName.SpanStart, _cancellationToken);
-
- var solution = _document.Project.Solution;
- var codeGenResult = await CodeGenerator.AddNamedTypeDeclarationAsync (
- solution,
- enclosingNamespace,
- namedType,
- new CodeGenerationOptions (afterThisLocation: _document.SyntaxTree.GetLocation (_state.SimpleName.Span), generateDefaultAccessibility: false),
- _cancellationToken)
- .ConfigureAwait (false);
-
- return new CodeActionOperation[] { new ApplyChangesOperation (codeGenResult.Project.Solution) };
- }
-
- private async Task<IEnumerable<CodeActionOperation>> GetGenerateIntoExistingDocumentAsync (
- INamedTypeSymbol namedType,
- Project triggeringProject,
- GenerateTypeOptionsResult generateTypeOptionsResult,
- bool isDialog)
- {
- var root = await generateTypeOptionsResult.ExistingDocument.GetSyntaxRootAsync (_cancellationToken).ConfigureAwait (false);
- var folders = generateTypeOptionsResult.ExistingDocument.Folders;
-
- var namespaceContainersAndUsings = GetNamespaceContainersAndAddUsingsOrImport (isDialog, new List<string> (folders), generateTypeOptionsResult.AreFoldersValidIdentifiers, generateTypeOptionsResult.Project, triggeringProject);
-
- var containers = namespaceContainersAndUsings.Item1;
- var includeUsingsOrImports = namespaceContainersAndUsings.Item2;
-
- Tuple<INamespaceSymbol, INamespaceOrTypeSymbol, Location> enclosingNamespaceGeneratedTypeToAddAndLocation = null;
- if (_targetProjectChangeInLanguage == TargetProjectChangeInLanguage.NoChange) {
- enclosingNamespaceGeneratedTypeToAddAndLocation = _service.GetOrGenerateEnclosingNamespaceSymbol (
- namedType,
- containers,
- generateTypeOptionsResult.ExistingDocument,
- root,
- _cancellationToken).WaitAndGetResult (_cancellationToken);
- } else {
- enclosingNamespaceGeneratedTypeToAddAndLocation = _targetLanguageService.GetOrGenerateEnclosingNamespaceSymbol (
- namedType,
- containers,
- generateTypeOptionsResult.ExistingDocument,
- root,
- _cancellationToken).WaitAndGetResult (_cancellationToken);
- }
-
- var solution = _document.Project.Solution;
- var codeGenResult = await CodeGenerator.AddNamespaceOrTypeDeclarationAsync (
- solution,
- enclosingNamespaceGeneratedTypeToAddAndLocation.Item1,
- enclosingNamespaceGeneratedTypeToAddAndLocation.Item2,
- new CodeGenerationOptions (afterThisLocation: enclosingNamespaceGeneratedTypeToAddAndLocation.Item3, generateDefaultAccessibility: false),
- _cancellationToken)
- .ConfigureAwait (false);
- var newRoot = await codeGenResult.GetSyntaxRootAsync (_cancellationToken).ConfigureAwait (false);
- var updatedSolution = solution.WithDocumentSyntaxRoot (generateTypeOptionsResult.ExistingDocument.Id, newRoot, PreservationMode.PreserveIdentity);
-
- // Update the Generating Document with a using if required
- if (includeUsingsOrImports != null) {
- updatedSolution = _service.TryAddUsingsOrImportToDocument (
- updatedSolution,
- generateTypeOptionsResult.ExistingDocument.Id == _document.Document.Id ? newRoot : null,
- _document.Document,
- _state.SimpleName,
- includeUsingsOrImports,
- _cancellationToken);
- }
-
- updatedSolution = AddProjectReference (generateTypeOptionsResult.Project, triggeringProject, updatedSolution);
-
- return new CodeActionOperation[] { new ApplyChangesOperation (updatedSolution) };
- }
-
- private Tuple<string[], string> GetNamespaceContainersAndAddUsingsOrImport (
- bool isDialog,
- IList<string> folders,
- bool areFoldersValidIdentifiers,
- Project targetProject,
- Project triggeringProject)
- {
- string includeUsingsOrImports = null;
- if (!areFoldersValidIdentifiers) {
- folders = SpecializedCollections.EmptyList<string> ();
- }
-
- // Now actually create the symbol that we want to add to the root namespace. The
- // symbol may either be a named type (if we're not generating into a namespace) or
- // it may be a namespace symbol.
- string[] containers = null;
- if (!isDialog) {
- // Not generated from the Dialog
- containers = GetNamespaceToGenerateInto ().Split (new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
- } else if (!_service.IsSimpleName (_state.NameOrMemberAccessExpression)) {
- // If the usage was with a namespace
- containers = GetNamespaceToGenerateIntoForUsageWithNamespace (targetProject, triggeringProject).Split (new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
- } else {
- // Generated from the Dialog
- List<string> containerList = new List<string> ();
-
- string rootNamespaceOfTheProjectGeneratedInto;
-
- if (_targetProjectChangeInLanguage == TargetProjectChangeInLanguage.NoChange) {
- rootNamespaceOfTheProjectGeneratedInto = _service.GetRootNamespace (_generateTypeOptionsResult.Project.CompilationOptions).Trim ();
- } else {
- rootNamespaceOfTheProjectGeneratedInto = _targetLanguageService.GetRootNamespace (_generateTypeOptionsResult.Project.CompilationOptions).Trim ();
- }
-
- // TODO : Default namespace support
- //var projectManagementService = _document.Project.Solution.Workspace.Services.GetService<IProjectManagementService> ();
- var defaultNamespace = "";// projectManagementService.GetDefaultNamespace (targetProject, targetProject.Solution.Workspace);
-
- // Case 1 : If the type is generated into the same C# project or
- // Case 2 : If the type is generated from a C# project to a C# Project
- // Case 3 : If the Type is generated from a VB Project to a C# Project
- // Using and Namespace will be the DefaultNamespace + Folder Structure
- if ((_document.Project == _generateTypeOptionsResult.Project && _document.Project.Language == LanguageNames.CSharp) ||
- (_targetProjectChangeInLanguage == TargetProjectChangeInLanguage.NoChange && _generateTypeOptionsResult.Project.Language == LanguageNames.CSharp) ||
- _targetProjectChangeInLanguage == TargetProjectChangeInLanguage.VisualBasicToCSharp) {
- if (!string.IsNullOrWhiteSpace (defaultNamespace)) {
- containerList.Add (defaultNamespace);
- }
-
- // Populate the ContainerList
- AddFoldersToNamespaceContainers (containerList, folders);
-
- containers = containerList.ToArray ();
- includeUsingsOrImports = string.Join (".", containerList.ToArray ());
- }
-
- // Case 4 : If the type is generated into the same VB project or
- // Case 5 : If Type is generated from a VB Project to VB Project
- // Case 6 : If Type is generated from a C# Project to VB Project
- // Namespace will be Folder Structure and Import will have the RootNamespace of the project generated into as part of the Imports
- if ((_document.Project == _generateTypeOptionsResult.Project && _document.Project.Language == LanguageNames.VisualBasic) ||
- (_document.Project != _generateTypeOptionsResult.Project && _targetProjectChangeInLanguage == TargetProjectChangeInLanguage.NoChange && _generateTypeOptionsResult.Project.Language == LanguageNames.VisualBasic) ||
- _targetProjectChangeInLanguage == TargetProjectChangeInLanguage.CSharpToVisualBasic) {
- // Populate the ContainerList
- AddFoldersToNamespaceContainers (containerList, folders);
- containers = containerList.ToArray ();
- includeUsingsOrImports = string.Join (".", containerList.ToArray ());
- if (!string.IsNullOrWhiteSpace (rootNamespaceOfTheProjectGeneratedInto)) {
- includeUsingsOrImports = string.IsNullOrEmpty (includeUsingsOrImports) ?
- rootNamespaceOfTheProjectGeneratedInto :
- rootNamespaceOfTheProjectGeneratedInto + "." + includeUsingsOrImports;
- }
- }
- }
-
- return Tuple.Create (containers, includeUsingsOrImports);
- }
-
- private async Task<IEnumerable<CodeActionOperation>> GetGenerateIntoTypeOperationsAsync (INamedTypeSymbol namedType)
- {
- //var codeGenService = GetCodeGenerationService ();
- var solution = _document.Project.Solution;
- var codeGenResult = await CodeGenerator.AddNamedTypeDeclarationAsync (
- solution,
- _state.TypeToGenerateInOpt,
- namedType,
- new CodeGenerationOptions (contextLocation: _state.SimpleName.GetLocation (), generateDefaultAccessibility: false),
- _cancellationToken)
- .ConfigureAwait (false);
-
- return new CodeActionOperation[] { new ApplyChangesOperation (codeGenResult.Project.Solution) };
- }
-
- private IList<ITypeSymbol> GetArgumentTypes (IList<TArgumentSyntax> argumentList)
- {
- var types = argumentList.Select (a => _service.DetermineArgumentType (_document.SemanticModel, a, _cancellationToken));
- return types.Select (FixType).ToList ();
- }
-
- private ITypeSymbol FixType (
- ITypeSymbol typeSymbol)
- {
- var compilation = _document.SemanticModel.Compilation;
- return typeSymbol.RemoveUnnamedErrorTypes (compilation);
- }
-
- private CSharpCodeGenerationService GetCodeGenerationService ()
- {
- var language = _state.TypeToGenerateInOpt == null
- ? _state.SimpleName.Language
- : _state.TypeToGenerateInOpt.Language;
- return new CSharpCodeGenerationService(_document.Project.Solution.Workspace, language);
- }
-
- private bool TryFindMatchingField (
- string parameterName,
- ITypeSymbol parameterType,
- Dictionary<string, ISymbol> parameterToFieldMap,
- bool caseSensitive)
- {
- // If the base types have an accessible field or property with the same name and
- // an acceptable type, then we should just defer to that.
- if (_state.BaseTypeOrInterfaceOpt != null) {
- var comparison = caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
- var query =
- _state.BaseTypeOrInterfaceOpt
- .GetBaseTypesAndThis ()
- .SelectMany (t => t.GetMembers ())
- .Where (s => s.Name.Equals (parameterName, comparison));
- var symbol = query.FirstOrDefault (IsSymbolAccessible);
-
- if (IsViableFieldOrProperty (parameterType, symbol)) {
- parameterToFieldMap [parameterName] = symbol;
- return true;
- }
- }
-
- return false;
- }
-
- private bool IsViableFieldOrProperty (
- ITypeSymbol parameterType,
- ISymbol symbol)
- {
- if (symbol != null && !symbol.IsStatic && parameterType.Language == symbol.Language) {
- if (symbol is IFieldSymbol) {
- var field = (IFieldSymbol)symbol;
- return
- !field.IsReadOnly &&
- _service.IsConversionImplicit (_document.SemanticModel.Compilation, parameterType, field.Type);
- } else if (symbol is IPropertySymbol) {
- var property = (IPropertySymbol)symbol;
- return
- property.Parameters.Length == 0 &&
- property.SetMethod != null &&
- IsSymbolAccessible (property.SetMethod) &&
- _service.IsConversionImplicit (_document.SemanticModel.Compilation, parameterType, property.Type);
- }
- }
-
- return false;
- }
-
- private bool IsSymbolAccessible (ISymbol symbol)
- {
- // Public and protected constructors are accessible. Internal constructors are
- // accessible if we have friend access. We can't call the normal accessibility
- // checkers since they will think that a protected constructor isn't accessible
- // (since we don't have the destination type that would have access to them yet).
- switch (symbol.DeclaredAccessibility) {
- case Accessibility.ProtectedOrInternal:
- case Accessibility.Protected:
- case Accessibility.Public:
- return true;
- case Accessibility.ProtectedAndInternal:
- case Accessibility.Internal:
- // TODO: Code coverage
- return _document.SemanticModel.Compilation.Assembly.IsSameAssemblyOrHasFriendAccessTo (
- symbol.ContainingAssembly);
-
- default:
- return false;
- }
- }
- }
-
- internal abstract IMethodSymbol GetDelegatingConstructor (TObjectCreationExpressionSyntax objectCreation, INamedTypeSymbol namedType, SemanticModel model, ISet<IMethodSymbol> candidates, CancellationToken cancellationToken);
-
- private partial class Editor
- {
- private INamedTypeSymbol GenerateNamedType ()
- {
- return CodeGenerationSymbolFactory.CreateNamedTypeSymbol (
- DetermineAttributes (),
- DetermineAccessibility (),
- DetermineModifiers (),
- DetermineTypeKind (),
- DetermineName (),
- DetermineTypeParameters (),
- DetermineBaseType (),
- DetermineInterfaces (),
- members: DetermineMembers ());
- }
-
- private INamedTypeSymbol GenerateNamedType (GenerateTypeOptionsResult options)
- {
- if (options.TypeKind == TypeKind.Delegate) {
- return CodeGenerationSymbolFactory.CreateDelegateTypeSymbol (
- DetermineAttributes (),
- options.Accessibility,
- DetermineModifiers (),
- DetermineReturnType (options),
- options.TypeName,
- DetermineTypeParameters (options),
- DetermineParameters (options));
- }
-
- return CodeGenerationSymbolFactory.CreateNamedTypeSymbol (
- DetermineAttributes (),
- options.Accessibility,
- DetermineModifiers (),
- options.TypeKind,
- options.TypeName,
- DetermineTypeParameters (),
- DetermineBaseType (),
- DetermineInterfaces (),
- members: DetermineMembers (options));
- }
-
- private ITypeSymbol DetermineReturnType (GenerateTypeOptionsResult options)
- {
- if (_state.DelegateMethodSymbol == null ||
- _state.DelegateMethodSymbol.ReturnType == null ||
- _state.DelegateMethodSymbol.ReturnType is IErrorTypeSymbol) {
- // Since we cannot determine the return type, we are returning void
- return _state.Compilation.GetSpecialType (SpecialType.System_Void);
- } else {
- return _state.DelegateMethodSymbol.ReturnType;
- }
- }
-
- private IList<ITypeParameterSymbol> DetermineTypeParameters (GenerateTypeOptionsResult options)
- {
- if (_state.DelegateMethodSymbol != null) {
- return _state.DelegateMethodSymbol.TypeParameters;
- }
-
- // If the delegate symbol cannot be determined then
- return DetermineTypeParameters ();
- }
-
- private IList<IParameterSymbol> DetermineParameters (GenerateTypeOptionsResult options)
- {
- if (_state.DelegateMethodSymbol != null) {
- return _state.DelegateMethodSymbol.Parameters;
- }
-
- return null;
- }
-
- private IList<ISymbol> DetermineMembers (GenerateTypeOptionsResult options = null)
- {
- var members = new List<ISymbol> ();
- AddMembers (members, options);
-
- if (_state.IsException) {
- AddExceptionConstructors (members);
- }
-
- return members;
- }
-
- private void AddMembers (IList<ISymbol> members, GenerateTypeOptionsResult options = null)
- {
- AddProperties (members);
-
- IList<TArgumentSyntax> argumentList;
- if (!_service.TryGetArgumentList (_state.ObjectCreationExpressionOpt, out argumentList)) {
- return;
- }
-
- var parameterTypes = GetArgumentTypes (argumentList);
-
- // Don't generate this constructor if it would conflict with a default exception
- // constructor. Default exception constructors will be added automatically by our
- // caller.
- if (_state.IsException &&
- _state.BaseTypeOrInterfaceOpt.InstanceConstructors.Any (
- c => c.Parameters.Select (p => p.Type).SequenceEqual (parameterTypes))) {
- return;
- }
-
- // If there's an accessible base constructor that would accept these types, then
- // just call into that instead of generating fields.
- if (_state.BaseTypeOrInterfaceOpt != null) {
- if (_state.BaseTypeOrInterfaceOpt.TypeKind == TypeKind.Interface && argumentList.Count == 0) {
- // No need to add the default constructor if our base type is going to be
- // 'object'. We get that constructor for free.
- return;
- }
-
- var accessibleInstanceConstructors = _state.BaseTypeOrInterfaceOpt.InstanceConstructors.Where (
- IsSymbolAccessible).ToSet ();
-
- if (accessibleInstanceConstructors.Any ()) {
- var delegatedConstructor = _service.GetDelegatingConstructor (_state.ObjectCreationExpressionOpt, _state.BaseTypeOrInterfaceOpt, _document.SemanticModel, accessibleInstanceConstructors, _cancellationToken);
- if (delegatedConstructor != null) {
- // There was a best match. Call it directly.
- AddBaseDelegatingConstructor (delegatedConstructor, members);
- return;
- }
- }
- }
-
- // Otherwise, just generate a normal constructor that assigns any provided
- // parameters into fields.
- AddFieldDelegatingConstructor (argumentList, members, options);
- }
-
- private void AddProperties (IList<ISymbol> members)
- {
- foreach (var property in _state.PropertiesToGenerate) {
- IPropertySymbol generatedProperty;
- if (_service.TryGenerateProperty (property, _document.SemanticModel, _cancellationToken, out generatedProperty)) {
- members.Add (generatedProperty);
- }
- }
- }
-
- private void AddBaseDelegatingConstructor (
- IMethodSymbol methodSymbol,
- IList<ISymbol> members)
- {
- // If we're generating a constructor to delegate into the no-param base constructor
- // then we can just elide the constructor entirely.
- if (methodSymbol.Parameters.Length == 0) {
- return;
- }
-
- var factory = _document.Project.LanguageServices.GetService<SyntaxGenerator> ();
- members.Add (factory.CreateBaseDelegatingConstructor (
- methodSymbol, DetermineName ()));
- }
-
- private void AddFieldDelegatingConstructor (
- IList<TArgumentSyntax> argumentList, IList<ISymbol> members, GenerateTypeOptionsResult options = null)
- {
- var factory = _document.Project.LanguageServices.GetService<SyntaxGenerator> ();
-
- var availableTypeParameters = _service.GetAvailableTypeParameters (_state, _document.SemanticModel, _intoNamespace, _cancellationToken);
- var parameterTypes = GetArgumentTypes (argumentList);
- var parameterNames = _service.GenerateParameterNames (_document.SemanticModel, argumentList);
- var parameters = new List<IParameterSymbol> ();
-
- var parameterToExistingFieldMap = new Dictionary<string, ISymbol> ();
- var parameterToNewFieldMap = new Dictionary<string, string> ();
-
- for (var i = 0; i < parameterNames.Count; i++) {
- var refKind = argumentList [i].GetRefKindOfArgument ();
-
- var parameterName = parameterNames [i];
- var parameterType = (ITypeSymbol)parameterTypes [i];
- parameterType = parameterType.RemoveUnavailableTypeParameters (
- _document.SemanticModel.Compilation, availableTypeParameters);
-
- if (!TryFindMatchingField (parameterName, parameterType, parameterToExistingFieldMap, caseSensitive: true)) {
- if (!TryFindMatchingField (parameterName, parameterType, parameterToExistingFieldMap, caseSensitive: false)) {
- parameterToNewFieldMap [parameterName] = parameterName;
- }
- }
-
- parameters.Add (CodeGenerationSymbolFactory.CreateParameterSymbol (
- attributes: null,
- refKind: refKind,
- isParams: false,
- type: parameterType,
- name: parameterName));
- }
-
- // Empty Constructor for Struct is not allowed
- if (!(parameters.Count == 0 && options != null && (options.TypeKind == TypeKind.Struct || options.TypeKind == TypeKind.Structure))) {
- var symbols = factory.CreateFieldDelegatingConstructor (DetermineName (), null, parameters, parameterToExistingFieldMap, parameterToNewFieldMap, _cancellationToken);
- foreach (var c in symbols)
- members.Add (c);
- }
- }
-
- private void AddExceptionConstructors (IList<ISymbol> members)
- {
- var factory = _document.Project.LanguageServices.GetService<SyntaxGenerator> ();
- var exceptionType = _document.SemanticModel.Compilation.ExceptionType ();
- var constructors =
- exceptionType.InstanceConstructors
- .Where (c => c.DeclaredAccessibility == Accessibility.Public || c.DeclaredAccessibility == Accessibility.Protected)
- .Select (c => CodeGenerationSymbolFactory.CreateConstructorSymbol (
- attributes: null,
- accessibility: c.DeclaredAccessibility,
- modifiers: default(DeclarationModifiers),
- typeName: DetermineName (),
- parameters: c.Parameters,
- statements: null,
- baseConstructorArguments: c.Parameters.Length == 0 ? null : factory.CreateArguments (c.Parameters)));
- foreach (var c in constructors)
- members.Add (c);
- }
-
- private IList<AttributeData> DetermineAttributes ()
- {
- if (_state.IsException) {
- var serializableType = _document.SemanticModel.Compilation.SerializableAttributeType ();
- if (serializableType != null) {
- var attribute = CodeGenerationSymbolFactory.CreateAttributeData (serializableType);
- return new[] { attribute };
- }
- }
-
- return null;
- }
-
- private Accessibility DetermineAccessibility ()
- {
- return _service.GetAccessibility (_state, _document.SemanticModel, _intoNamespace, _cancellationToken);
- }
-
- private DeclarationModifiers DetermineModifiers ()
- {
- return default(DeclarationModifiers);
- }
-
- private INamedTypeSymbol DetermineBaseType ()
- {
- if (_state.BaseTypeOrInterfaceOpt == null || _state.BaseTypeOrInterfaceOpt.TypeKind == TypeKind.Interface) {
- return null;
- }
-
- return RemoveUnavailableTypeParameters (_state.BaseTypeOrInterfaceOpt);
- }
-
- private IList<INamedTypeSymbol> DetermineInterfaces ()
- {
- if (_state.BaseTypeOrInterfaceOpt != null && _state.BaseTypeOrInterfaceOpt.TypeKind == TypeKind.Interface) {
- var type = RemoveUnavailableTypeParameters (_state.BaseTypeOrInterfaceOpt);
- if (type != null) {
- return new[] { type };
- }
- }
-
- return SpecializedCollections.EmptyList<INamedTypeSymbol> ();
- }
-
- private INamedTypeSymbol RemoveUnavailableTypeParameters (INamedTypeSymbol type)
- {
- return type.RemoveUnavailableTypeParameters (
- _document.SemanticModel.Compilation, GetAvailableTypeParameters ()) as INamedTypeSymbol;
- }
-
- private string DetermineName ()
- {
- return GetTypeName (_state);
- }
-
- private IList<ITypeParameterSymbol> DetermineTypeParameters ()
- {
- return _service.GetTypeParameters (_state, _document.SemanticModel, _cancellationToken);
- }
-
- private TypeKind DetermineTypeKind ()
- {
- return _state.IsStruct
- ? TypeKind.Struct
- : _state.IsInterface
- ? TypeKind.Interface
- : TypeKind.Class;
- }
-
- protected IList<ITypeParameterSymbol> GetAvailableTypeParameters ()
- {
- var availableInnerTypeParameters = _service.GetTypeParameters (_state, _document.SemanticModel, _cancellationToken);
- var availableOuterTypeParameters = !_intoNamespace && _state.TypeToGenerateInOpt != null
- ? _state.TypeToGenerateInOpt.GetAllTypeParameters ()
- : SpecializedCollections.EmptyEnumerable<ITypeParameterSymbol> ();
-
- return availableOuterTypeParameters.Concat (availableInnerTypeParameters).ToList ();
- }
- }
-
- internal abstract bool TryGenerateProperty (TSimpleNameSyntax propertyName, SemanticModel semanticModel, CancellationToken cancellationToken, out IPropertySymbol property);
-
- protected class State
- {
- public string Name { get; private set; }
-
- public bool NameIsVerbatim { get; private set; }
-
- // The name node that we're on. Will be used to the name the type if it's
- // generated.
- public TSimpleNameSyntax SimpleName { get; private set; }
-
- // The entire expression containing the name, not including the creation. i.e. "X.Foo"
- // in "new X.Foo()".
- public TExpressionSyntax NameOrMemberAccessExpression { get; private set; }
-
- // The object creation node if we have one. i.e. if we're on the 'Foo' in "new X.Foo()".
- public TObjectCreationExpressionSyntax ObjectCreationExpressionOpt { get; private set; }
-
- // One of these will be non null. It's also possible for both to be non null. For
- // example, if you have "class C { Foo f; }", then "Foo" can be generated inside C or
- // inside the global namespace. The namespace can be null or the type can be null if the
- // user has something like "ExistingType.NewType" or "ExistingNamespace.NewType". In
- // that case they're being explicit about what they want to generate into.
- public INamedTypeSymbol TypeToGenerateInOpt { get; private set; }
-
- public string NamespaceToGenerateInOpt { get; private set; }
-
- // If we can infer a base type or interface for this type.
- //
- // i.e.: "IList<int> foo = new MyList();"
- public INamedTypeSymbol BaseTypeOrInterfaceOpt { get; private set; }
-
- public bool IsInterface { get; private set; }
-
- public bool IsStruct { get; private set; }
-
- public bool IsAttribute { get; private set; }
-
- public bool IsException { get; private set; }
-
- public bool IsMembersWithModule { get; private set; }
-
- public bool IsTypeGeneratedIntoNamespaceFromMemberAccess { get; private set; }
-
- public bool IsSimpleNameGeneric { get; private set; }
-
- public bool IsPublicAccessibilityForTypeGeneration { get; private set; }
-
- public bool IsInterfaceOrEnumNotAllowedInTypeContext { get; private set; }
-
- public IMethodSymbol DelegateMethodSymbol { get; private set; }
-
- public bool IsDelegateAllowed { get; private set; }
-
- public bool IsEnumNotAllowed { get; private set; }
-
- public Compilation Compilation { get; }
-
- public bool IsDelegateOnly { get; private set; }
-
- public bool IsClassInterfaceTypes { get; private set; }
-
- public List<TSimpleNameSyntax> PropertiesToGenerate { get; private set; }
-
- private State (Compilation compilation)
- {
- this.Compilation = compilation;
- }
-
- public static State Generate (
- TService service,
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- var state = new State (document.SemanticModel.Compilation);
- if (!state.TryInitialize (service, document, node, cancellationToken)) {
- return null;
- }
-
- return state;
- }
-
- private bool TryInitialize (
- TService service,
- SemanticDocument document,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- if (!(node is TSimpleNameSyntax)) {
- return false;
- }
-
- this.SimpleName = (TSimpleNameSyntax)node;
- string name;
- int arity;
- this.SimpleName.GetNameAndArityOfSimpleName (out name, out arity);
-
- this.Name = name;
- this.NameIsVerbatim = this.SimpleName.GetFirstToken ().IsVerbatimIdentifier ();
- if (string.IsNullOrWhiteSpace (this.Name)) {
- return false;
- }
-
- // We only support simple names or dotted names. i.e. "(some + expr).Foo" is not a
- // valid place to generate a type for Foo.
- GenerateTypeServiceStateOptions generateTypeServiceStateOptions;
- if (!service.TryInitializeState (document, this.SimpleName, cancellationToken, out generateTypeServiceStateOptions)) {
- return false;
- }
-
- this.NameOrMemberAccessExpression = generateTypeServiceStateOptions.NameOrMemberAccessExpression;
- this.ObjectCreationExpressionOpt = generateTypeServiceStateOptions.ObjectCreationExpressionOpt;
-
- var semanticModel = document.SemanticModel;
- var info = semanticModel.GetSymbolInfo (this.SimpleName, cancellationToken);
- if (info.Symbol != null) {
- // This bound, so no need to generate anything.
- return false;
- }
-
- if (!semanticModel.IsTypeContext (this.NameOrMemberAccessExpression.SpanStart, cancellationToken) &&
- !semanticModel.IsExpressionContext (this.NameOrMemberAccessExpression.SpanStart, cancellationToken) &&
- !semanticModel.IsStatementContext (this.NameOrMemberAccessExpression.SpanStart, cancellationToken) &&
- !semanticModel.IsNameOfContext (this.NameOrMemberAccessExpression.SpanStart, cancellationToken) &&
- !semanticModel.IsNamespaceContext (this.NameOrMemberAccessExpression.SpanStart, cancellationToken)) {
- return false;
- }
-
- // If this isn't something that can be created, then don't bother offering to create
- // it.
- if (info.CandidateReason == CandidateReason.NotCreatable) {
- return false;
- }
-
- if (info.CandidateReason == CandidateReason.Inaccessible ||
- info.CandidateReason == CandidateReason.NotReferencable ||
- info.CandidateReason == CandidateReason.OverloadResolutionFailure) {
- // We bound to something inaccessible, or overload resolution on a
- // constructor call failed. Don't want to offer GenerateType here.
- return false;
- }
-
- if (this.ObjectCreationExpressionOpt != null) {
- // If we're new'ing up something illegal, then don't offer generate type.
- var typeInfo = semanticModel.GetTypeInfo (this.ObjectCreationExpressionOpt, cancellationToken);
- if (typeInfo.Type.IsModuleType ()) {
- return false;
- }
- }
-
- DetermineNamespaceOrTypeToGenerateIn (service, document, cancellationToken);
-
- // Now, try to infer a possible base type for this new class/interface.
- this.InferBaseType (service, document, cancellationToken);
- this.IsInterface = GenerateInterface (service, cancellationToken);
- this.IsStruct = GenerateStruct (service, semanticModel, cancellationToken);
- this.IsAttribute = this.BaseTypeOrInterfaceOpt != null && this.BaseTypeOrInterfaceOpt.Equals (semanticModel.Compilation.AttributeType ());
- this.IsException = this.BaseTypeOrInterfaceOpt != null && this.BaseTypeOrInterfaceOpt.Equals (semanticModel.Compilation.ExceptionType ());
- this.IsMembersWithModule = generateTypeServiceStateOptions.IsMembersWithModule;
- this.IsTypeGeneratedIntoNamespaceFromMemberAccess = generateTypeServiceStateOptions.IsTypeGeneratedIntoNamespaceFromMemberAccess;
- this.IsInterfaceOrEnumNotAllowedInTypeContext = generateTypeServiceStateOptions.IsInterfaceOrEnumNotAllowedInTypeContext;
- this.IsDelegateAllowed = generateTypeServiceStateOptions.IsDelegateAllowed;
- this.IsDelegateOnly = generateTypeServiceStateOptions.IsDelegateOnly;
- this.IsEnumNotAllowed = generateTypeServiceStateOptions.IsEnumNotAllowed;
- this.DelegateMethodSymbol = generateTypeServiceStateOptions.DelegateCreationMethodSymbol;
- this.IsClassInterfaceTypes = generateTypeServiceStateOptions.IsClassInterfaceTypes;
- this.IsSimpleNameGeneric = service.IsGenericName (this.SimpleName);
- this.PropertiesToGenerate = generateTypeServiceStateOptions.PropertiesToGenerate;
-
- if (this.IsAttribute && this.TypeToGenerateInOpt.GetAllTypeParameters ().Any ()) {
- this.TypeToGenerateInOpt = null;
- }
-
- return this.TypeToGenerateInOpt != null || this.NamespaceToGenerateInOpt != null;
- }
-
- private void InferBaseType (
- TService service,
- SemanticDocument document,
- CancellationToken cancellationToken)
- {
- // See if we can find a possible base type for the type being generated.
- // NOTE(cyrusn): I currently limit this to when we have an object creation node.
- // That's because that's when we would have an expression that could be conerted to
- // somethign else. i.e. if the user writes "IList<int> list = new Foo()" then we can
- // infer a base interface for 'Foo'. However, if they write "IList<int> list = Foo"
- // then we don't really want to infer a base type for 'Foo'.
-
- // However, there are a few other cases were we can infer a base type.
- if (service.IsInCatchDeclaration (this.NameOrMemberAccessExpression)) {
- this.BaseTypeOrInterfaceOpt = document.SemanticModel.Compilation.ExceptionType ();
- } else if (NameOrMemberAccessExpression.IsAttributeName ()) {
- this.BaseTypeOrInterfaceOpt = document.SemanticModel.Compilation.AttributeType ();
- } else if (
- service.IsArrayElementType (this.NameOrMemberAccessExpression) ||
- service.IsInVariableTypeContext (this.NameOrMemberAccessExpression) ||
- this.ObjectCreationExpressionOpt != null) {
- var expr = this.ObjectCreationExpressionOpt ?? this.NameOrMemberAccessExpression;
- var baseType = TypeGuessing.typeInferenceService.InferType (document.SemanticModel, expr, objectAsDefault: true, cancellationToken: cancellationToken) as INamedTypeSymbol;
- SetBaseType (baseType);
- }
- }
-
- private void SetBaseType (INamedTypeSymbol baseType)
- {
- if (baseType == null) {
- return;
- }
-
- // A base type need to be non class or interface type. Also, being 'object' is
- // redundant as the base type.
- if (baseType.IsSealed || baseType.IsStatic || baseType.SpecialType == SpecialType.System_Object) {
- return;
- }
-
- if (baseType.TypeKind != TypeKind.Class && baseType.TypeKind != TypeKind.Interface) {
- return;
- }
-
- this.BaseTypeOrInterfaceOpt = baseType;
- }
-
- private bool GenerateStruct (TService service, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- return service.IsInValueTypeConstraintContext (semanticModel, this.NameOrMemberAccessExpression, cancellationToken);
- }
-
- private bool GenerateInterface (
- TService service,
- CancellationToken cancellationToken)
- {
- if (!this.IsAttribute &&
- !this.IsException &&
- this.Name.LooksLikeInterfaceName () &&
- this.ObjectCreationExpressionOpt == null &&
- (this.BaseTypeOrInterfaceOpt == null || this.BaseTypeOrInterfaceOpt.TypeKind == TypeKind.Interface)) {
- return true;
- }
-
- return service.IsInInterfaceList (this.NameOrMemberAccessExpression);
- }
-
- private void DetermineNamespaceOrTypeToGenerateIn (
- TService service,
- SemanticDocument document,
- CancellationToken cancellationToken)
- {
- DetermineNamespaceOrTypeToGenerateInWorker (service, document.SemanticModel, cancellationToken);
-
- // Can only generate into a type if it's a class and it's from source.
- if (this.TypeToGenerateInOpt != null) {
- if (this.TypeToGenerateInOpt.TypeKind != TypeKind.Class &&
- this.TypeToGenerateInOpt.TypeKind != TypeKind.Module) {
- this.TypeToGenerateInOpt = null;
- } else {
- var symbol = SymbolFinder.FindSourceDefinitionAsync (this.TypeToGenerateInOpt, document.Project.Solution, cancellationToken).WaitAndGetResult (cancellationToken);
- if (symbol == null ||
- !symbol.IsKind (SymbolKind.NamedType) ||
- !symbol.Locations.Any (loc => loc.IsInSource)) {
- this.TypeToGenerateInOpt = null;
- return;
- }
-
- var sourceTreeToBeGeneratedIn = symbol.Locations.First (loc => loc.IsInSource).SourceTree;
- var documentToBeGeneratedIn = document.Project.Solution.GetDocument (sourceTreeToBeGeneratedIn);
-
- if (documentToBeGeneratedIn == null) {
- this.TypeToGenerateInOpt = null;
- return;
- }
-
- // If the 2 documents are in different project then we must have Public Accessibility.
- // If we are generating in a website project, we also want to type to be public so the
- // designer files can access the type.
- if (documentToBeGeneratedIn.Project != document.Project ||
- service.GeneratedTypesMustBePublic (documentToBeGeneratedIn.Project)) {
- this.IsPublicAccessibilityForTypeGeneration = true;
- }
-
- this.TypeToGenerateInOpt = (INamedTypeSymbol)symbol;
- }
- }
-
- if (this.TypeToGenerateInOpt != null) {
- if (!CodeGenerator.CanAdd (document.Project.Solution, this.TypeToGenerateInOpt, cancellationToken)) {
- this.TypeToGenerateInOpt = null;
- }
- }
- }
-
- private bool DetermineNamespaceOrTypeToGenerateInWorker (
- TService service,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- // If we're on the right of a dot, see if we can figure out what's on the left. If
- // it doesn't bind to a type or a namespace, then we can't proceed.
- if (this.SimpleName != this.NameOrMemberAccessExpression) {
- return DetermineNamespaceOrTypeToGenerateIn (
- service, semanticModel,
- service.GetLeftSideOfDot (this.SimpleName), cancellationToken);
- } else {
- // The name is standing alone. We can either generate the type into our
- // containing type, or into our containing namespace.
- //
- // TODO(cyrusn): We need to make this logic work if the type is in the
- // base/interface list of a type.
- var format = SymbolDisplayFormat.FullyQualifiedFormat.WithGlobalNamespaceStyle (SymbolDisplayGlobalNamespaceStyle.Omitted);
- this.TypeToGenerateInOpt = service.DetermineTypeToGenerateIn (semanticModel, this.SimpleName, cancellationToken);
- if (this.TypeToGenerateInOpt != null) {
- this.NamespaceToGenerateInOpt = this.TypeToGenerateInOpt.ContainingNamespace.ToDisplayString (format);
- } else {
- var namespaceSymbol = semanticModel.GetEnclosingNamespace (this.SimpleName.SpanStart, cancellationToken);
- if (namespaceSymbol != null) {
- this.NamespaceToGenerateInOpt = namespaceSymbol.ToDisplayString (format);
- }
- }
- }
-
- return true;
- }
-
- private bool DetermineNamespaceOrTypeToGenerateIn (
- TService service,
- SemanticModel semanticModel,
- TExpressionSyntax leftSide,
- CancellationToken cancellationToken)
- {
- var leftSideInfo = semanticModel.GetSymbolInfo (leftSide, cancellationToken);
-
- if (leftSideInfo.Symbol != null) {
- var symbol = leftSideInfo.Symbol;
-
- if (symbol is INamespaceSymbol) {
- this.NamespaceToGenerateInOpt = symbol.ToDisplayString (Ambience.NameFormat);
- return true;
- } else if (symbol is INamedTypeSymbol) {
- // TODO: Code coverage
- this.TypeToGenerateInOpt = (INamedTypeSymbol)symbol.OriginalDefinition;
- return true;
- }
-
- // We bound to something other than a namespace or named type. Can't generate a
- // type inside this.
- return false;
- } else {
- // If it's a dotted name, then perhaps it's a namespace. i.e. the user wrote
- // "new Foo.Bar.Baz()". In this case we want to generate a namespace for
- // "Foo.Bar".
- IList<string> nameParts;
- if (service.TryGetNameParts (leftSide, out nameParts)) {
- this.NamespaceToGenerateInOpt = string.Join (".", nameParts);
- return true;
- }
- }
-
- return false;
- }
- }
-
- protected class GenerateTypeServiceStateOptions
- {
- public TExpressionSyntax NameOrMemberAccessExpression { get; set; }
-
- public TObjectCreationExpressionSyntax ObjectCreationExpressionOpt { get; set; }
-
- public IMethodSymbol DelegateCreationMethodSymbol { get; set; }
-
- public List<TSimpleNameSyntax> PropertiesToGenerate { get; }
-
- public bool IsMembersWithModule { get; set; }
-
- public bool IsTypeGeneratedIntoNamespaceFromMemberAccess { get; set; }
-
- public bool IsInterfaceOrEnumNotAllowedInTypeContext { get; set; }
-
- public bool IsDelegateAllowed { get; set; }
-
- public bool IsEnumNotAllowed { get; set; }
-
- public bool IsDelegateOnly { get; internal set; }
-
- public bool IsClassInterfaceTypes { get; internal set; }
-
- public GenerateTypeServiceStateOptions ()
- {
- NameOrMemberAccessExpression = null;
- ObjectCreationExpressionOpt = null;
- DelegateCreationMethodSymbol = null;
- IsMembersWithModule = false;
- PropertiesToGenerate = new List<TSimpleNameSyntax> ();
- IsTypeGeneratedIntoNamespaceFromMemberAccess = false;
- IsInterfaceOrEnumNotAllowedInTypeContext = false;
- IsDelegateAllowed = true;
- IsEnumNotAllowed = false;
- IsDelegateOnly = false;
- }
- }
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/CSharpGenerateTypeService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/CSharpGenerateTypeService.cs
deleted file mode 100644
index 2459e2cf76..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/CSharpGenerateTypeService.cs
+++ /dev/null
@@ -1,943 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using ICSharpCode.NRefactory6.CSharp.GenerateMember.GenerateConstructor;
-using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.Ide;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateType
-{
- class CSharpGenerateTypeService :
- AbstractGenerateTypeService<CSharpGenerateTypeService, SimpleNameSyntax, ObjectCreationExpressionSyntax, ExpressionSyntax, TypeDeclarationSyntax, ArgumentSyntax>
- {
- private static readonly SyntaxAnnotation s_annotation = new SyntaxAnnotation();
-
- protected override string DefaultFileExtension
- {
- get
- {
- return ".cs";
- }
- }
-
- protected override ExpressionSyntax GetLeftSideOfDot(SimpleNameSyntax simpleName)
- {
- return simpleName.GetLeftSideOfDot();
- }
-
- protected override bool IsInCatchDeclaration(ExpressionSyntax expression)
- {
- return expression.IsParentKind(SyntaxKind.CatchDeclaration);
- }
-
- protected override bool IsArrayElementType(ExpressionSyntax expression)
- {
- return expression.IsParentKind(SyntaxKind.ArrayType) &&
- expression.Parent.IsParentKind(SyntaxKind.ArrayCreationExpression);
- }
-
- protected override bool IsInValueTypeConstraintContext(
- SemanticModel semanticModel,
- ExpressionSyntax expression,
- CancellationToken cancellationToken)
- {
- if (expression is TypeSyntax && expression.IsParentKind(SyntaxKind.TypeArgumentList))
- {
- var typeArgumentList = (TypeArgumentListSyntax)expression.Parent;
- var symbolInfo = semanticModel.GetSymbolInfo(typeArgumentList.Parent, cancellationToken);
- var symbol = symbolInfo.GetAnySymbol();
- if (symbol == null)
- return false;
- if (symbol.IsConstructor())
- {
- symbol = symbol.ContainingType;
- }
-
- var parameterIndex = typeArgumentList.Arguments.IndexOf((TypeSyntax)expression);
- var type = symbol as INamedTypeSymbol;
- if (type != null)
- {
- type = type.OriginalDefinition;
- var typeParameter = parameterIndex < type.TypeParameters.Length ? type.TypeParameters[parameterIndex] : null;
- return typeParameter != null && typeParameter.HasValueTypeConstraint;
- }
-
- var method = symbol as IMethodSymbol;
- if (method != null)
- {
- method = method.OriginalDefinition;
- var typeParameter = parameterIndex < method.TypeParameters.Length ? method.TypeParameters[parameterIndex] : null;
- return typeParameter != null && typeParameter.HasValueTypeConstraint;
- }
- }
-
- return false;
- }
-
- protected override bool IsInInterfaceList(ExpressionSyntax expression)
- {
- if (expression is TypeSyntax &&
- expression.Parent is BaseTypeSyntax &&
- expression.Parent.IsParentKind(SyntaxKind.BaseList) &&
- ((BaseTypeSyntax)expression.Parent).Type == expression)
- {
- var baseList = (BaseListSyntax)expression.Parent.Parent;
-
- // If it's after the first item, then it's definitely an interface.
- if (baseList.Types[0] != expression.Parent)
- {
- return true;
- }
-
- // If it's in the base list of an interface or struct, then it's definitely an
- // interface.
- return
- baseList.IsParentKind(SyntaxKind.InterfaceDeclaration) ||
- baseList.IsParentKind(SyntaxKind.StructDeclaration);
- }
-
- if (expression is TypeSyntax &&
- expression.IsParentKind(SyntaxKind.TypeConstraint) &&
- expression.Parent.IsParentKind(SyntaxKind.TypeParameterConstraintClause))
- {
- var typeConstraint = (TypeConstraintSyntax)expression.Parent;
- var constraintClause = (TypeParameterConstraintClauseSyntax)typeConstraint.Parent;
- var index = constraintClause.Constraints.IndexOf(typeConstraint);
-
- // If it's after the first item, then it's definitely an interface.
- return index > 0;
- }
-
- return false;
- }
-
- protected override bool TryGetNameParts(ExpressionSyntax expression, out IList<string> nameParts)
- {
- nameParts = new List<string>();
- return expression.TryGetNameParts(out nameParts);
- }
-
- protected override bool TryInitializeState(
- SemanticDocument document,
- SimpleNameSyntax simpleName,
- CancellationToken cancellationToken,
- out GenerateTypeServiceStateOptions generateTypeServiceStateOptions)
- {
- generateTypeServiceStateOptions = new GenerateTypeServiceStateOptions();
-
- if (simpleName.IsVar)
- {
- return false;
- }
-
- if (SyntaxFacts.IsAliasQualifier(simpleName))
- {
- return false;
- }
-
- // Never offer if we're in a using directive, unless its a static using. The feeling here is that it's highly
- // unlikely that this would be a location where a user would be wanting to generate
- // something. They're really just trying to reference something that exists but
- // isn't available for some reason (i.e. a missing reference).
- var usingDirectiveSyntax = simpleName.GetAncestorOrThis<UsingDirectiveSyntax>();
- if (usingDirectiveSyntax != null && usingDirectiveSyntax.StaticKeyword.Kind() != SyntaxKind.StaticKeyword)
- {
- return false;
- }
-
- ExpressionSyntax nameOrMemberAccessExpression = null;
- if (simpleName.IsRightSideOfDot())
- {
- // This simplename comes from the cref
- if (simpleName.IsParentKind(SyntaxKind.NameMemberCref))
- {
- return false;
- }
-
- nameOrMemberAccessExpression = generateTypeServiceStateOptions.NameOrMemberAccessExpression = (ExpressionSyntax)simpleName.Parent;
-
- // If we're on the right side of a dot, then the left side better be a name (and
- // not an arbitrary expression).
- var leftSideExpression = simpleName.GetLeftSideOfDot();
- if (!leftSideExpression.IsKind(
- SyntaxKind.QualifiedName,
- SyntaxKind.IdentifierName,
- SyntaxKind.AliasQualifiedName,
- SyntaxKind.GenericName,
- SyntaxKind.SimpleMemberAccessExpression))
- {
- return false;
- }
- }
- else
- {
- nameOrMemberAccessExpression = generateTypeServiceStateOptions.NameOrMemberAccessExpression = simpleName;
- }
-
- // BUG(5712): Don't offer generate type in an enum's base list.
- if (nameOrMemberAccessExpression.Parent is BaseTypeSyntax &&
- nameOrMemberAccessExpression.Parent.IsParentKind(SyntaxKind.BaseList) &&
- ((BaseTypeSyntax)nameOrMemberAccessExpression.Parent).Type == nameOrMemberAccessExpression &&
- nameOrMemberAccessExpression.Parent.Parent.IsParentKind(SyntaxKind.EnumDeclaration))
- {
- return false;
- }
-
- // If we can guarantee it's a type only context, great. Otherwise, we may not want to
- // provide this here.
- var semanticModel = document.SemanticModel;
- if (!SyntaxFacts.IsInNamespaceOrTypeContext(nameOrMemberAccessExpression))
- {
- // Don't offer Generate Type in an expression context *unless* we're on the left
- // side of a dot. In that case the user might be making a type that they're
- // accessing a static off of.
- var syntaxTree = semanticModel.SyntaxTree;
- var start = nameOrMemberAccessExpression.SpanStart;
- var tokenOnLeftOfStart = syntaxTree.FindTokenOnLeftOfPosition(start, cancellationToken);
- var isExpressionContext = syntaxTree.IsExpressionContext(start, tokenOnLeftOfStart, attributes: true, cancellationToken: cancellationToken, semanticModelOpt: semanticModel);
- var isStatementContext = syntaxTree.IsStatementContext(start, tokenOnLeftOfStart, cancellationToken);
- var isExpressionOrStatementContext = isExpressionContext || isStatementContext;
-
- // Delegate Type Creation is not allowed in Non Type Namespace Context
- generateTypeServiceStateOptions.IsDelegateAllowed = false;
-
- if (!isExpressionOrStatementContext)
- {
- return false;
- }
-
- if (!simpleName.IsLeftSideOfDot() && !simpleName.IsInsideNameOf())
- {
- if (nameOrMemberAccessExpression == null || !nameOrMemberAccessExpression.IsKind(SyntaxKind.SimpleMemberAccessExpression) || !simpleName.IsRightSideOfDot())
- {
- return false;
- }
-
- var leftSymbol = semanticModel.GetSymbolInfo(((MemberAccessExpressionSyntax)nameOrMemberAccessExpression).Expression, cancellationToken).Symbol;
- var token = simpleName.GetLastToken().GetNextToken();
-
- // We let only the Namespace to be left of the Dot
- if (leftSymbol == null ||
- !leftSymbol.IsKind(SymbolKind.Namespace) ||
- !token.IsKind(SyntaxKind.DotToken))
- {
- return false;
- }
- else
- {
- generateTypeServiceStateOptions.IsMembersWithModule = true;
- generateTypeServiceStateOptions.IsTypeGeneratedIntoNamespaceFromMemberAccess = true;
- }
- }
-
- // Global Namespace
- if (!generateTypeServiceStateOptions.IsTypeGeneratedIntoNamespaceFromMemberAccess &&
- !SyntaxFacts.IsInNamespaceOrTypeContext(simpleName))
- {
- var token = simpleName.GetLastToken().GetNextToken();
- if (token.IsKind(SyntaxKind.DotToken) &&
- simpleName.Parent == token.Parent)
- {
- generateTypeServiceStateOptions.IsMembersWithModule = true;
- generateTypeServiceStateOptions.IsTypeGeneratedIntoNamespaceFromMemberAccess = true;
- }
- }
- }
-
- var fieldDeclaration = simpleName.GetAncestor<FieldDeclarationSyntax>();
- if (fieldDeclaration != null &&
- fieldDeclaration.Parent is CompilationUnitSyntax &&
- document.Document.SourceCodeKind == SourceCodeKind.Regular)
- {
- return false;
- }
-
- // Check to see if Module could be an option in the Type Generation in Cross Language Generation
- var nextToken = simpleName.GetLastToken().GetNextToken();
- if (simpleName.IsLeftSideOfDot() ||
- nextToken.IsKind(SyntaxKind.DotToken))
- {
- if (simpleName.IsRightSideOfDot())
- {
- var parent = simpleName.Parent as QualifiedNameSyntax;
- if (parent != null)
- {
- var leftSymbol = semanticModel.GetSymbolInfo(parent.Left, cancellationToken).Symbol;
-
- if (leftSymbol != null && leftSymbol.IsKind(SymbolKind.Namespace))
- {
- generateTypeServiceStateOptions.IsMembersWithModule = true;
- }
- }
- }
- }
-
- if (SyntaxFacts.IsInNamespaceOrTypeContext(nameOrMemberAccessExpression))
- {
- if (nextToken.IsKind(SyntaxKind.DotToken))
- {
- // In Namespace or Type Context we cannot have Interface, Enum, Delegate as part of the Left Expression of a QualifiedName
- generateTypeServiceStateOptions.IsDelegateAllowed = false;
- generateTypeServiceStateOptions.IsInterfaceOrEnumNotAllowedInTypeContext = true;
- generateTypeServiceStateOptions.IsMembersWithModule = true;
- }
-
- // case: class Foo<T> where T: MyType
- if (nameOrMemberAccessExpression.GetAncestors<TypeConstraintSyntax>().Any())
- {
- generateTypeServiceStateOptions.IsClassInterfaceTypes = true;
- return true;
- }
-
- // Events
- if (nameOrMemberAccessExpression.GetAncestors<EventFieldDeclarationSyntax>().Any() ||
- nameOrMemberAccessExpression.GetAncestors<EventDeclarationSyntax>().Any())
- {
- // Case : event foo name11
- // Only Delegate
- if (simpleName.Parent != null && !(simpleName.Parent is QualifiedNameSyntax))
- {
- generateTypeServiceStateOptions.IsDelegateOnly = true;
- return true;
- }
-
- // Case : event SomeSymbol.foo name11
- if (nameOrMemberAccessExpression is QualifiedNameSyntax)
- {
- // Only Namespace, Class, Struct and Module are allowed to contain Delegate
- // Case : event Something.Mytype.<Delegate> Identifier
- if (nextToken.IsKind(SyntaxKind.DotToken))
- {
- if (nameOrMemberAccessExpression.Parent != null && nameOrMemberAccessExpression.Parent is QualifiedNameSyntax)
- {
- return true;
- }
- else
- {
- //Contract.Fail("Cannot reach this point");
- }
- }
- else
- {
- // Case : event Something.<Delegate> Identifier
- generateTypeServiceStateOptions.IsDelegateOnly = true;
- return true;
- }
- }
- }
- }
- else
- {
- // MemberAccessExpression
- if ((nameOrMemberAccessExpression.IsKind(SyntaxKind.SimpleMemberAccessExpression) || (nameOrMemberAccessExpression.Parent != null && nameOrMemberAccessExpression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression)))
- && nameOrMemberAccessExpression.IsLeftSideOfDot())
- {
- // Check to see if the expression is part of Invocation Expression
- ExpressionSyntax outerMostMemberAccessExpression = null;
- if (nameOrMemberAccessExpression.IsKind(SyntaxKind.SimpleMemberAccessExpression))
- {
- outerMostMemberAccessExpression = nameOrMemberAccessExpression;
- }
- else
- {
- Debug.Assert(nameOrMemberAccessExpression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression));
- outerMostMemberAccessExpression = (ExpressionSyntax)nameOrMemberAccessExpression.Parent;
- }
-
- outerMostMemberAccessExpression = outerMostMemberAccessExpression.GetAncestorsOrThis<ExpressionSyntax>().SkipWhile((n) => n != null && n.IsKind(SyntaxKind.SimpleMemberAccessExpression)).FirstOrDefault();
- if (outerMostMemberAccessExpression != null && outerMostMemberAccessExpression is InvocationExpressionSyntax)
- {
- generateTypeServiceStateOptions.IsEnumNotAllowed = true;
- }
- }
- }
-
- // Cases:
- // // 1 - Function Address
- // var s2 = new MyD2(foo);
-
- // // 2 - Delegate
- // MyD1 d = null;
- // var s1 = new MyD2(d);
-
- // // 3 - Action
- // Action action1 = null;
- // var s3 = new MyD2(action1);
-
- // // 4 - Func
- // Func<int> lambda = () => { return 0; };
- // var s4 = new MyD3(lambda);
-
- if (nameOrMemberAccessExpression.Parent is ObjectCreationExpressionSyntax)
- {
- var objectCreationExpressionOpt = generateTypeServiceStateOptions.ObjectCreationExpressionOpt = (ObjectCreationExpressionSyntax)nameOrMemberAccessExpression.Parent;
-
- // Enum and Interface not Allowed in Object Creation Expression
- generateTypeServiceStateOptions.IsInterfaceOrEnumNotAllowedInTypeContext = true;
-
- if (objectCreationExpressionOpt.ArgumentList != null)
- {
- if (objectCreationExpressionOpt.ArgumentList.CloseParenToken.IsMissing)
- {
- return false;
- }
-
- // Get the Method symbol for the Delegate to be created
- if (generateTypeServiceStateOptions.IsDelegateAllowed &&
- objectCreationExpressionOpt.ArgumentList.Arguments.Count == 1)
- {
- generateTypeServiceStateOptions.DelegateCreationMethodSymbol = GetMethodSymbolIfPresent(semanticModel, objectCreationExpressionOpt.ArgumentList.Arguments[0].Expression, cancellationToken);
- }
- else
- {
- generateTypeServiceStateOptions.IsDelegateAllowed = false;
- }
- }
-
- if (objectCreationExpressionOpt.Initializer != null)
- {
- foreach (var expression in objectCreationExpressionOpt.Initializer.Expressions)
- {
- var simpleAssignmentExpression = expression as AssignmentExpressionSyntax;
- if (simpleAssignmentExpression == null)
- {
- continue;
- }
-
- var name = simpleAssignmentExpression.Left as SimpleNameSyntax;
- if (name == null)
- {
- continue;
- }
-
- generateTypeServiceStateOptions.PropertiesToGenerate.Add(name);
- }
- }
- }
-
- if (generateTypeServiceStateOptions.IsDelegateAllowed)
- {
- // MyD1 z1 = foo;
- if (nameOrMemberAccessExpression.Parent.IsKind(SyntaxKind.VariableDeclaration))
- {
- var variableDeclaration = (VariableDeclarationSyntax)nameOrMemberAccessExpression.Parent;
- if (variableDeclaration.Variables.Count != 0)
- {
- var firstVarDeclWithInitializer = variableDeclaration.Variables.FirstOrDefault(var => var.Initializer != null && var.Initializer.Value != null);
- if (firstVarDeclWithInitializer != null && firstVarDeclWithInitializer.Initializer != null && firstVarDeclWithInitializer.Initializer.Value != null)
- {
- generateTypeServiceStateOptions.DelegateCreationMethodSymbol = GetMethodSymbolIfPresent(semanticModel, firstVarDeclWithInitializer.Initializer.Value, cancellationToken);
- }
- }
- }
-
- // var w1 = (MyD1)foo;
- if (nameOrMemberAccessExpression.Parent.IsKind(SyntaxKind.CastExpression))
- {
- var castExpression = (CastExpressionSyntax)nameOrMemberAccessExpression.Parent;
- if (castExpression.Expression != null)
- {
- generateTypeServiceStateOptions.DelegateCreationMethodSymbol = GetMethodSymbolIfPresent(semanticModel, castExpression.Expression, cancellationToken);
- }
- }
- }
-
- return true;
- }
-
- private IMethodSymbol GetMethodSymbolIfPresent(SemanticModel semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken)
- {
- if (expression == null)
- {
- return null;
- }
-
- var memberGroup = semanticModel.GetMemberGroup(expression, cancellationToken);
- if (memberGroup.Count() != 0)
- {
- return memberGroup.ElementAt(0).IsKind(SymbolKind.Method) ? (IMethodSymbol)memberGroup.ElementAt(0) : null;
- }
-
- var expressionType = semanticModel.GetTypeInfo(expression, cancellationToken).Type;
- if (expressionType.IsDelegateType())
- {
- return ((INamedTypeSymbol)expressionType).DelegateInvokeMethod;
- }
-
- var expressionSymbol = semanticModel.GetSymbolInfo(expression, cancellationToken).Symbol;
- if (expressionSymbol.IsKind(SymbolKind.Method))
- {
- return (IMethodSymbol)expressionSymbol;
- }
-
- return null;
- }
-
- private Accessibility DetermineAccessibilityConstraint(
- State state,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- return semanticModel.DetermineAccessibilityConstraint(
- state.NameOrMemberAccessExpression as TypeSyntax, cancellationToken);
- }
-
- protected override IList<ITypeParameterSymbol> GetTypeParameters(
- State state,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- if (state.SimpleName is GenericNameSyntax)
- {
- var genericName = (GenericNameSyntax)state.SimpleName;
- var typeArguments = state.SimpleName.Arity == genericName.TypeArgumentList.Arguments.Count
- ? genericName.TypeArgumentList.Arguments.OfType<SyntaxNode>().ToList()
- : Enumerable.Repeat<SyntaxNode>(null, state.SimpleName.Arity);
- return this.GetTypeParameters(state, semanticModel, typeArguments, cancellationToken);
- }
-
- return SpecializedCollections.EmptyList<ITypeParameterSymbol>();
- }
-
- protected override bool TryGetArgumentList(ObjectCreationExpressionSyntax objectCreationExpression, out IList<ArgumentSyntax> argumentList)
- {
- if (objectCreationExpression != null && objectCreationExpression.ArgumentList != null)
- {
- argumentList = objectCreationExpression.ArgumentList.Arguments.ToList();
- return true;
- }
-
- argumentList = null;
- return false;
- }
-
- protected override IList<string> GenerateParameterNames(
- SemanticModel semanticModel, IList<ArgumentSyntax> arguments)
- {
- return semanticModel.GenerateParameterNames(arguments);
- }
-
- public override string GetRootNamespace(CompilationOptions options)
- {
- return string.Empty;
- }
-
- protected override bool IsInVariableTypeContext(ExpressionSyntax expression)
- {
- return false;
- }
-
- protected override INamedTypeSymbol DetermineTypeToGenerateIn(SemanticModel semanticModel, SimpleNameSyntax simpleName, CancellationToken cancellationToken)
- {
- return semanticModel.GetEnclosingNamedType(simpleName.SpanStart, cancellationToken);
- }
-
- protected override Accessibility GetAccessibility(State state, SemanticModel semanticModel, bool intoNamespace, CancellationToken cancellationToken)
- {
- var accessibility = DetermineDefaultAccessibility(state, semanticModel, intoNamespace, cancellationToken);
- if (!state.IsTypeGeneratedIntoNamespaceFromMemberAccess)
- {
- var accessibilityConstraint = DetermineAccessibilityConstraint(state, semanticModel, cancellationToken);
-
- if (accessibilityConstraint == Accessibility.Public ||
- accessibilityConstraint == Accessibility.Internal)
- {
- accessibility = accessibilityConstraint;
- }
- }
-
- return accessibility;
- }
-
- protected override ITypeSymbol DetermineArgumentType(SemanticModel semanticModel, ArgumentSyntax argument, CancellationToken cancellationToken)
- {
- return argument.DetermineParameterType(semanticModel, cancellationToken);
- }
-
- protected override bool IsConversionImplicit(Compilation compilation, ITypeSymbol sourceType, ITypeSymbol targetType)
- {
- return compilation.ClassifyConversion(sourceType, targetType).IsImplicit;
- }
-
- public override async Task<Tuple<INamespaceSymbol, INamespaceOrTypeSymbol, Location>> GetOrGenerateEnclosingNamespaceSymbol(INamedTypeSymbol namedTypeSymbol, string[] containers, Document selectedDocument, SyntaxNode selectedDocumentRoot, CancellationToken cancellationToken)
- {
- var compilationUnit = (CompilationUnitSyntax)selectedDocumentRoot;
- var semanticModel = await selectedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- if (containers.Length != 0)
- {
- // Search the NS declaration in the root
- var containerList = new List<string>(containers);
- var enclosingNamespace = GetDeclaringNamespace(containerList, 0, compilationUnit);
- if (enclosingNamespace != null)
- {
- var enclosingNamespaceSymbol = semanticModel.GetSymbolInfo(enclosingNamespace.Name, cancellationToken);
- if (enclosingNamespaceSymbol.Symbol != null)
- {
- return Tuple.Create((INamespaceSymbol)enclosingNamespaceSymbol.Symbol,
- (INamespaceOrTypeSymbol)namedTypeSymbol,
- enclosingNamespace.CloseBraceToken.GetLocation());
- }
- }
- }
-
- var globalNamespace = semanticModel.GetEnclosingNamespace(0, cancellationToken);
- var rootNamespaceOrType = namedTypeSymbol.GenerateRootNamespaceOrType(containers);
- var lastMember = compilationUnit.Members.LastOrDefault();
- Location afterThisLocation = null;
- if (lastMember != null)
- {
- afterThisLocation = semanticModel.SyntaxTree.GetLocation(new TextSpan(lastMember.Span.End, 0));
- }
- else
- {
- afterThisLocation = semanticModel.SyntaxTree.GetLocation(new TextSpan());
- }
-
- return Tuple.Create(globalNamespace,
- rootNamespaceOrType,
- afterThisLocation);
- }
-
- private NamespaceDeclarationSyntax GetDeclaringNamespace(List<string> containers, int indexDone, CompilationUnitSyntax compilationUnit)
- {
- foreach (var member in compilationUnit.Members)
- {
- var namespaceDeclaration = GetDeclaringNamespace(containers, 0, member);
- if (namespaceDeclaration != null)
- {
- return namespaceDeclaration;
- }
- }
-
- return null;
- }
-
- private NamespaceDeclarationSyntax GetDeclaringNamespace(List<string> containers, int indexDone, SyntaxNode localRoot)
- {
- var namespaceDecl = localRoot as NamespaceDeclarationSyntax;
- if (namespaceDecl == null || namespaceDecl.Name is AliasQualifiedNameSyntax)
- {
- return null;
- }
-
- List<string> namespaceContainers = new List<string>();
- GetNamespaceContainers(namespaceDecl.Name, namespaceContainers);
-
- if (namespaceContainers.Count + indexDone > containers.Count ||
- !IdentifierMatches(indexDone, namespaceContainers, containers))
- {
- return null;
- }
-
- indexDone = indexDone + namespaceContainers.Count;
- if (indexDone == containers.Count)
- {
- return namespaceDecl;
- }
-
- foreach (var member in namespaceDecl.Members)
- {
- var resultant = GetDeclaringNamespace(containers, indexDone, member);
- if (resultant != null)
- {
- return resultant;
- }
- }
-
- return null;
- }
-
- private bool IdentifierMatches(int indexDone, List<string> namespaceContainers, List<string> containers)
- {
- for (int i = 0; i < namespaceContainers.Count; ++i)
- {
- if (namespaceContainers[i] != containers[indexDone + i])
- {
- return false;
- }
- }
-
- return true;
- }
-
- private void GetNamespaceContainers(NameSyntax name, List<string> namespaceContainers)
- {
- if (name is QualifiedNameSyntax)
- {
- GetNamespaceContainers(((QualifiedNameSyntax)name).Left, namespaceContainers);
- namespaceContainers.Add(((QualifiedNameSyntax)name).Right.Identifier.ValueText);
- }
- else
- {
- Debug.Assert(name is SimpleNameSyntax);
- namespaceContainers.Add(((SimpleNameSyntax)name).Identifier.ValueText);
- }
- }
-
- internal override bool TryGetBaseList(ExpressionSyntax expression, out TypeKindOptions typeKindValue)
- {
- typeKindValue = TypeKindOptions.AllOptions;
-
- if (expression == null)
- {
- return false;
- }
-
- var node = expression as SyntaxNode;
-
- while (node != null)
- {
- if (node is BaseListSyntax)
- {
- if (node.Parent != null && (node.Parent is InterfaceDeclarationSyntax || node.Parent is StructDeclarationSyntax))
- {
- typeKindValue = TypeKindOptions.Interface;
- return true;
- }
-
- typeKindValue = TypeKindOptions.BaseList;
- return true;
- }
-
- node = node.Parent;
- }
-
- return false;
- }
-
- internal override bool IsPublicOnlyAccessibility(ExpressionSyntax expression, Project project)
- {
- if (expression == null)
- {
- return false;
- }
-
- if (GeneratedTypesMustBePublic(project))
- {
- return true;
- }
-
- var node = expression as SyntaxNode;
- SyntaxNode previousNode = null;
-
- while (node != null)
- {
- // Types in BaseList, Type Constraint or Member Types cannot be of restricter accessibility than the declaring type
- if ((node is BaseListSyntax || node is TypeParameterConstraintClauseSyntax) &&
- node.Parent != null &&
- node.Parent is TypeDeclarationSyntax)
- {
- var typeDecl = node.Parent as TypeDeclarationSyntax;
- if (typeDecl != null)
- {
- if (typeDecl.GetModifiers().Any(m => m.Kind() == SyntaxKind.PublicKeyword))
- {
- return IsAllContainingTypeDeclsPublic(typeDecl);
- }
- else
- {
- // The Type Decl which contains the BaseList does not contain Public
- return false;
- }
- }
-
- //Contract.Fail("Cannot reach this point");
- }
-
- if ((node is EventDeclarationSyntax || node is EventFieldDeclarationSyntax) &&
- node.Parent != null &&
- node.Parent is TypeDeclarationSyntax)
- {
- // Make sure the GFU is not inside the Accessors
- if (previousNode != null && previousNode is AccessorListSyntax)
- {
- return false;
- }
-
- // Make sure that Event Declaration themselves are Public in the first place
- if (!node.GetModifiers().Any(m => m.Kind() == SyntaxKind.PublicKeyword))
- {
- return false;
- }
-
- return IsAllContainingTypeDeclsPublic(node);
- }
-
- previousNode = node;
- node = node.Parent;
- }
-
- return false;
- }
-
- private bool IsAllContainingTypeDeclsPublic(SyntaxNode node)
- {
- // Make sure that all the containing Type Declarations are also Public
- var containingTypeDeclarations = node.GetAncestors<TypeDeclarationSyntax>();
- if (containingTypeDeclarations.Count() == 0)
- {
- return true;
- }
- else
- {
- return containingTypeDeclarations.All(typedecl => typedecl.GetModifiers().Any(m => m.Kind() == SyntaxKind.PublicKeyword));
- }
- }
-
- internal override bool IsGenericName(SimpleNameSyntax simpleName)
- {
- if (simpleName == null)
- {
- return false;
- }
-
- var genericName = simpleName as GenericNameSyntax;
- return genericName != null;
- }
-
- internal override bool IsSimpleName(ExpressionSyntax expression)
- {
- return expression is SimpleNameSyntax;
- }
-
- internal override Solution TryAddUsingsOrImportToDocument(Solution updatedSolution, SyntaxNode modifiedRoot, Document document, SimpleNameSyntax simpleName, string includeUsingsOrImports, CancellationToken cancellationToken)
- {
- // Nothing to include
- if (string.IsNullOrWhiteSpace(includeUsingsOrImports))
- {
- return updatedSolution;
- }
-
- var placeSystemNamespaceFirst = true;//document.Project.Solution.Workspace.Options.GetOption(OrganizerOptions.PlaceSystemNamespaceFirst, document.Project.Language);
-
- SyntaxNode root = null;
- if (modifiedRoot == null)
- {
- root = document.GetSyntaxRootAsync(cancellationToken).WaitAndGetResult(cancellationToken);
- }
- else
- {
- root = modifiedRoot;
- }
-
- if (root is CompilationUnitSyntax)
- {
- var compilationRoot = (CompilationUnitSyntax)root;
- var usingDirective = SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(includeUsingsOrImports));
-
- // Check if the usings is already present
- if (compilationRoot.Usings.Where(n => n != null && n.Alias == null)
- .Select(n => n.Name.ToString())
- .Any(n => n.Equals(includeUsingsOrImports)))
- {
- return updatedSolution;
- }
-
- // Check if the GFU is triggered from the namespace same as the usings namespace
- if (IsWithinTheImportingNamespace(document, simpleName.SpanStart, includeUsingsOrImports, cancellationToken))
- {
- return updatedSolution;
- }
-
- var addedCompilationRoot = compilationRoot.AddUsingDirectives(new[] { usingDirective }, placeSystemNamespaceFirst, Formatter.Annotation);
- updatedSolution = updatedSolution.WithDocumentSyntaxRoot(document.Id, addedCompilationRoot, PreservationMode.PreserveIdentity);
- }
-
- return updatedSolution;
- }
-
- private ITypeSymbol GetPropertyType(
- SimpleNameSyntax property,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- var parent = property.Parent as AssignmentExpressionSyntax;
- if (parent != null)
- {
- return TypeGuessing.typeInferenceService.InferType(semanticModel, parent.Left, true, cancellationToken);
- }
-
- return null;
- }
-
- private IPropertySymbol CreatePropertySymbol(SimpleNameSyntax propertyName, ITypeSymbol propertyType)
- {
- return CodeGenerationSymbolFactory.CreatePropertySymbol(
- attributes: SpecializedCollections.EmptyList<AttributeData>(),
- accessibility: Accessibility.Public,
- modifiers: new DeclarationModifiers(),
- explicitInterfaceSymbol: null,
- name: propertyName.ToString(),
- type: propertyType,
- parameters: null,
- getMethod: s_accessor,
- setMethod: s_accessor,
- isIndexer: false);
- }
-
- private static readonly IMethodSymbol s_accessor = CodeGenerationSymbolFactory.CreateAccessorSymbol(
- attributes: null,
- accessibility: Accessibility.Public,
- statements: null);
-
- internal override bool TryGenerateProperty(
- SimpleNameSyntax propertyName,
- SemanticModel semanticModel,
- CancellationToken cancellationToken,
- out IPropertySymbol property)
- {
- property = null;
- var propertyType = GetPropertyType(propertyName, semanticModel, cancellationToken);
- if (propertyType == null || propertyType is IErrorTypeSymbol)
- {
- property = CreatePropertySymbol(propertyName, semanticModel.Compilation.ObjectType);
- return true;
- }
-
- property = CreatePropertySymbol(propertyName, propertyType);
- return true;
- }
-
- internal override IMethodSymbol GetDelegatingConstructor(ObjectCreationExpressionSyntax objectCreation, INamedTypeSymbol namedType, SemanticModel model, ISet<IMethodSymbol> candidates, CancellationToken cancellationToken)
- {
- var oldNode = objectCreation
- .AncestorsAndSelf (ascendOutOfTrivia: false)
- .LastOrDefault (SpeculationAnalyzer.CanSpeculateOnNode);
-
- var typeNameToReplace = objectCreation.Type;
- var newTypeName = namedType.GenerateTypeSyntax();
- var newObjectCreation = objectCreation.WithType(newTypeName).WithAdditionalAnnotations(s_annotation);
- var newNode = oldNode.ReplaceNode(objectCreation, newObjectCreation);
-
- var speculativeModel = SpeculationAnalyzer.CreateSpeculativeSemanticModelForNode(oldNode, newNode, model);
- if (speculativeModel != null)
- {
- newObjectCreation = (ObjectCreationExpressionSyntax)newNode.GetAnnotatedNodes(s_annotation).Single();
- var symbolInfo = speculativeModel.GetSymbolInfo(newObjectCreation, cancellationToken);
- return GenerateConstructorHelpers.GetDelegatingConstructor(symbolInfo, candidates, namedType);
- }
-
- return null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/GenerateTypeDialogOptions.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/GenerateTypeDialogOptions.cs
deleted file mode 100644
index d91da3dcb5..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/GenerateTypeDialogOptions.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateType
-{
- class GenerateTypeDialogOptions
- {
- public bool IsPublicOnlyAccessibility { get; }
- public TypeKindOptions TypeKindOptions { get; }
- public bool IsAttribute { get; }
-
- public GenerateTypeDialogOptions(
- bool isPublicOnlyAccessibility = false,
- TypeKindOptions typeKindOptions = TypeKindOptions.AllOptions,
- bool isAttribute = false)
- {
- IsPublicOnlyAccessibility = isPublicOnlyAccessibility;
- this.TypeKindOptions = typeKindOptions;
- IsAttribute = isAttribute;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/GenerateTypeOptionsResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/GenerateTypeOptionsResult.cs
deleted file mode 100644
index cd9c90856e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/GenerateTypeOptionsResult.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateType
-{
- class GenerateTypeOptionsResult
- {
- public static readonly GenerateTypeOptionsResult Cancelled = new GenerateTypeOptionsResult(isCancelled: true);
-
- public Accessibility Accessibility { get; }
- public Document ExistingDocument { get; }
- public bool IsCancelled { get; }
- public bool IsNewFile { get; }
- public IList<string> Folders { get; }
- public string NewFileName { get; }
- public Project Project { get; }
- public TypeKind TypeKind { get; }
- public string FullFilePath { get; }
- public string TypeName { get; }
- public bool AreFoldersValidIdentifiers { get; }
-
- public GenerateTypeOptionsResult(
- Accessibility accessibility,
- TypeKind typeKind,
- string typeName,
- Project project,
- bool isNewFile,
- string newFileName,
- IList<string> folders,
- string fullFilePath,
- Document existingDocument,
- bool areFoldersValidIdentifiers,
- bool isCancelled = false)
- {
- this.Accessibility = accessibility;
- this.TypeKind = typeKind;
- this.TypeName = typeName;
- this.Project = project;
- this.IsNewFile = isNewFile;
- this.NewFileName = newFileName;
- this.Folders = folders;
- this.FullFilePath = fullFilePath;
- this.ExistingDocument = existingDocument;
- this.AreFoldersValidIdentifiers = areFoldersValidIdentifiers;
- this.IsCancelled = isCancelled;
- }
-
- private GenerateTypeOptionsResult(bool isCancelled)
- {
- this.IsCancelled = isCancelled;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/TypeKindOptions.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/TypeKindOptions.cs
deleted file mode 100644
index 3bfdc96dfb..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/TypeKindOptions.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ICSharpCode.NRefactory6.CSharp.GenerateType
-{
- [Flags]
- public enum TypeKindOptions
- {
- None = 0x0,
-
- Class = 0x1,
- Structure = 0x2,
- Interface = 0x4,
- Enum = 0x8,
- Delegate = 0x10,
- Module = 0x20,
-
- // Enables class, struct, interface, enum and delegate
- AllOptions = Class | Structure | Interface | Enum | Delegate,
-
- // Only class is valid with Attribute
- Attribute = Class,
-
- // Only class, struct and interface are allowed. No Enums
- BaseList = Class | Interface,
-
- AllOptionsWithModule = AllOptions | Module,
-
- // Only Interface and Delegate cannot be part of the member access with Namespace as Left expression
- MemberAccessWithNamespace = Class | Structure | Enum | Module,
-
- // Enum and Modules are incompatible with Generics
- GenericInCompatibleTypes = Enum | Module
- }
-
- internal class TypeKindOptionsHelper
- {
- public static bool IsClass(TypeKindOptions option)
- {
- return (option & TypeKindOptions.Class) != 0 ? true : false;
- }
-
- public static bool IsStructure(TypeKindOptions option)
- {
- return (option & TypeKindOptions.Structure) != 0 ? true : false;
- }
-
- public static bool IsInterface(TypeKindOptions option)
- {
- return (option & TypeKindOptions.Interface) != 0 ? true : false;
- }
-
- public static bool IsEnum(TypeKindOptions option)
- {
- return (option & TypeKindOptions.Enum) != 0 ? true : false;
- }
-
- public static bool IsDelegate(TypeKindOptions option)
- {
- return (option & TypeKindOptions.Delegate) != 0 ? true : false;
- }
-
- public static bool IsModule(TypeKindOptions option)
- {
- return (option & TypeKindOptions.Module) != 0 ? true : false;
- }
-
- public static TypeKindOptions RemoveOptions(TypeKindOptions fromValue, params TypeKindOptions[] removeValues)
- {
- var tempReturnValue = fromValue;
- foreach (var removeValue in removeValues)
- {
- tempReturnValue = tempReturnValue & ~removeValue;
- }
-
- return tempReturnValue;
- }
-
- internal static TypeKindOptions AddOption(TypeKindOptions toValue, TypeKindOptions addValue)
- {
- return toValue | addValue;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GotoDefinition/GotoDefinitionService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GotoDefinition/GotoDefinitionService.cs
index f0cd820b45..8e5fd10ad2 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GotoDefinition/GotoDefinitionService.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GotoDefinition/GotoDefinitionService.cs
@@ -2,16 +2,12 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis.CSharp;
namespace ICSharpCode.NRefactory6.CSharp.Features.GotoDefinition
{
@@ -55,41 +51,39 @@ namespace ICSharpCode.NRefactory6.CSharp.Features.GotoDefinition
return false;
};
- static ISymbol FindRelatedExplicitlyDeclaredSymbol(ISymbol symbol, Compilation compilation)
+ static ISymbol FindRelatedExplicitlyDeclaredSymbol (ISymbol symbol, Compilation compilation)
{
return symbol;
}
- public static async Task<ISymbol> FindSymbolAsync(Document document, int position, CancellationToken cancellationToken)
+ public static async Task<ISymbol> FindSymbolAsync (Document document, int position, CancellationToken cancellationToken)
{
var workspace = document.Project.Solution.Workspace;
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
+ var semanticModel = await document.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
//var symbol = SymbolFinder.FindSymbolAtPosition(semanticModel, position, workspace, bindLiteralsToUnderlyingType: true, cancellationToken: cancellationToken);
- var symbol = SymbolFinder.FindSymbolAtPosition(semanticModel, position, workspace, cancellationToken: cancellationToken);
+ var symbol = SymbolFinder.FindSymbolAtPosition (semanticModel, position, workspace, cancellationToken: cancellationToken);
- return FindRelatedExplicitlyDeclaredSymbol(symbol, semanticModel.Compilation);
+ return FindRelatedExplicitlyDeclaredSymbol (symbol, semanticModel.Compilation);
}
-// public async Task<IEnumerable<INavigableItem>> FindDefinitionsAsync(Document document, int position, CancellationToken cancellationToken)
-// {
-// var symbol = await FindSymbolAsync(document, position, cancellationToken).ConfigureAwait(false);
-//
-// // realize the list here so that the consumer await'ing the result doesn't lazily cause
-// // them to be created on an inappropriate thread.
-// return NavigableItemFactory.GetItemsfromPreferredSourceLocations(document.Project.Solution, symbol).ToList();
-// }
+ // public async Task<IEnumerable<INavigableItem>> FindDefinitionsAsync(Document document, int position, CancellationToken cancellationToken)
+ // {
+ // var symbol = await FindSymbolAsync(document, position, cancellationToken).ConfigureAwait(false);
+ //
+ // // realize the list here so that the consumer await'ing the result doesn't lazily cause
+ // // them to be created on an inappropriate thread.
+ // return NavigableItemFactory.GetItemsfromPreferredSourceLocations(document.Project.Solution, symbol).ToList();
+ // }
- public static bool TryGoToDefinition(Document document, int position, CancellationToken cancellationToken)
+ public static bool TryGoToDefinition (Document document, int position, CancellationToken cancellationToken)
{
- var symbol = FindSymbolAsync(document, position, cancellationToken).Result;
+ var symbol = FindSymbolAsync (document, position, cancellationToken).Result;
- if (symbol != null)
- {
- var containingTypeSymbol = GetContainingTypeSymbol(position, document, cancellationToken);
+ if (symbol != null) {
+ var containingTypeSymbol = GetContainingTypeSymbol (position, document, cancellationToken);
- if (GoToDefinitionHelpers.TryGoToDefinition(symbol, document.Project, containingTypeSymbol, throwOnHiddenDefinition: true, cancellationToken: cancellationToken))
- {
+ if (GoToDefinitionHelpers.TryGoToDefinition (symbol, document.Project, containingTypeSymbol, throwOnHiddenDefinition: true, cancellationToken: cancellationToken)) {
return true;
}
}
@@ -97,15 +91,14 @@ namespace ICSharpCode.NRefactory6.CSharp.Features.GotoDefinition
return false;
}
- private static ITypeSymbol GetContainingTypeSymbol(int caretPosition, Document document, CancellationToken cancellationToken)
+ private static ITypeSymbol GetContainingTypeSymbol (int caretPosition, Document document, CancellationToken cancellationToken)
{
- var syntaxRoot = document.GetSyntaxRootAsync(cancellationToken).Result;
- var containingTypeDeclaration = syntaxRoot.GetContainingTypeDeclaration(caretPosition);
+ var syntaxRoot = document.GetSyntaxRootAsync (cancellationToken).Result;
+ var containingTypeDeclaration = CSharpSyntaxFactsService.Instance.GetContainingTypeDeclaration (syntaxRoot, caretPosition);
- if (containingTypeDeclaration != null)
- {
- var semanticModel = document.GetSemanticModelAsync(cancellationToken).Result;
- return semanticModel.GetDeclaredSymbol(containingTypeDeclaration, cancellationToken) as ITypeSymbol;
+ if (containingTypeDeclaration != null) {
+ var semanticModel = document.GetSemanticModelAsync (cancellationToken).Result;
+ return semanticModel.GetDeclaredSymbol (containingTypeDeclaration, cancellationToken) as ITypeSymbol;
}
return null;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.Editor.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.Editor.cs
deleted file mode 100644
index 6fa2da1dba..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.Editor.cs
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementAbstractClass
-{
- partial class AbstractImplementAbstractClassService
- {
- private partial class Editor
- {
- private readonly Document _document;
- private readonly SemanticModel _model;
- private readonly State _state;
-
- public Editor(
- Document document,
- SemanticModel model,
- State state)
- {
- _document = document;
- _model = model;
- _state = state;
- }
-
- public async Task<Document> GetEditAsync(CancellationToken cancellationToken)
- {
- var unimplementedMembers = _state.UnimplementedMembers;
-
- var memberDefinitions = GenerateMembers(
- unimplementedMembers,
- cancellationToken);
-
- var result = await CodeGenerator.AddMemberDeclarationsAsync(
- _document.Project.Solution,
- _state.ClassType,
- memberDefinitions,
- new CodeGenerationOptions(_state.Location.GetLocation(), generateDefaultAccessibility: false),
- cancellationToken)
- .ConfigureAwait(false);
-
- return result;
- }
-
- private IList<ISymbol> GenerateMembers(
- IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> unimplementedMembers,
- CancellationToken cancellationToken)
- {
- return
- unimplementedMembers.SelectMany(t => t.Item2)
- .Select(m => GenerateMember(m, cancellationToken))
- .WhereNotNull()
- .ToList();
- }
-
- private ISymbol GenerateMember(
- ISymbol member,
- CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- // Check if we need to add 'unsafe' to the signature we're generating.
- var addUnsafe = member.IsUnsafe() && !_state.Location.IsUnsafeContext();
-
- return GenerateMember(member, addUnsafe, cancellationToken);
- }
-
- private ISymbol GenerateMember(
- ISymbol member,
- bool addUnsafe,
- CancellationToken cancellationToken)
- {
- var modifiers = DeclarationModifiers.None.WithIsOverride(true).WithIsUnsafe (addUnsafe);
- var accessibility = member.ComputeResultantAccessibility(_state.ClassType);
-
- if (member.Kind == SymbolKind.Method)
- {
- return GenerateMethod((IMethodSymbol)member, modifiers, accessibility, cancellationToken);
- }
- else if (member.Kind == SymbolKind.Property)
- {
- return GenerateProperty((IPropertySymbol)member, modifiers, accessibility, cancellationToken);
- }
- else if (member.Kind == SymbolKind.Event)
- {
- var @event = (IEventSymbol)member;
- return CodeGenerationSymbolFactory.CreateEventSymbol(
- @event,
- accessibility: accessibility,
- modifiers: modifiers);
- }
-
- return null;
- }
-
- private ISymbol GenerateMethod(
- IMethodSymbol method, DeclarationModifiers modifiers, Accessibility accessibility, CancellationToken cancellationToken)
- {
- var syntaxFactory = _document.Project.LanguageServices.GetService<SyntaxGenerator>();
-
- var throwingBody = syntaxFactory.CreateThrowNotImplementStatement (_model.Compilation);
-
- method = method.EnsureNonConflictingNames(_state.ClassType, cancellationToken);
-
- return CodeGenerationSymbolFactory.CreateMethodSymbol(
- method,
- accessibility: accessibility,
- modifiers: modifiers,
- statements: new [] { throwingBody });
- }
-
- private IPropertySymbol GenerateProperty(
- IPropertySymbol property,
- DeclarationModifiers modifiers,
- Accessibility accessibility,
- CancellationToken cancellationToken)
- {
- var syntaxFactory = _document.Project.LanguageServices.GetService<SyntaxGenerator>();
-
- var throwingBody = syntaxFactory.CreateThrowNotImplementedStatementBlock(
- _model.Compilation);
-
- var getMethod = ShouldGenerateAccessor(property.GetMethod)
- ? CodeGenerationSymbolFactory.CreateAccessorSymbol(
- property.GetMethod,
- attributes: null,
- accessibility: property.GetMethod.ComputeResultantAccessibility(_state.ClassType),
- statements: throwingBody)
- : null;
-
- var setMethod = ShouldGenerateAccessor(property.SetMethod)
- ? CodeGenerationSymbolFactory.CreateAccessorSymbol(
- property.SetMethod,
- attributes: null,
- accessibility: property.SetMethod.ComputeResultantAccessibility(_state.ClassType),
- statements: throwingBody)
- : null;
-
- return CodeGenerationSymbolFactory.CreatePropertySymbol(
- property,
- accessibility: accessibility,
- modifiers: modifiers,
- getMethod: getMethod,
- setMethod: setMethod);
- }
-
- private bool ShouldGenerateAccessor(IMethodSymbol method)
- {
- return
- method != null &&
- method.IsAccessibleWithin(_state.ClassType) &&
- _state.ClassType.FindImplementationForAbstractMember(method) == null;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.State.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.State.cs
deleted file mode 100644
index 0d924b2c79..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.State.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementAbstractClass
-{
- partial class AbstractImplementAbstractClassService
- {
- private class State
- {
- public SyntaxNode Location { get; }
- public INamedTypeSymbol ClassType { get; }
- public INamedTypeSymbol AbstractClassType { get; }
-
- // The members that are not implemented at all.
- public IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> UnimplementedMembers { get; }
-
- private State(SyntaxNode node, INamedTypeSymbol classType, INamedTypeSymbol abstractClassType, IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> unimplementedMembers)
- {
- this.Location = node;
- this.ClassType = classType;
- this.AbstractClassType = abstractClassType;
- this.UnimplementedMembers = unimplementedMembers;
- }
-
- public static State Generate(
- AbstractImplementAbstractClassService service,
- Document document,
- SemanticModel model,
- SyntaxNode node,
- CancellationToken cancellationToken)
- {
- INamedTypeSymbol classType, abstractClassType;
- if (!service.TryInitializeState(document, model, node, cancellationToken,
- out classType, out abstractClassType))
- {
- return null;
- }
-
- if (!CodeGenerator.CanAdd(document.Project.Solution, classType, cancellationToken))
- {
- return null;
- }
-
- if (classType.IsAbstract)
- {
- return null;
- }
-
- var unimplementedMembers = classType.GetAllUnimplementedMembers(
- SpecializedCollections.SingletonEnumerable(abstractClassType), cancellationToken);
-
- if (unimplementedMembers != null && unimplementedMembers.Count >= 1)
- {
- return new State(node, classType, abstractClassType, unimplementedMembers);
- }
- else
- {
- return null;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.cs
deleted file mode 100644
index b625b46e7d..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/AbstractImplementAbstractClassService.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementAbstractClass
-{
- abstract partial class AbstractImplementAbstractClassService
- {
- protected AbstractImplementAbstractClassService()
- {
- }
-
- protected abstract bool TryInitializeState(Document document, SemanticModel model, SyntaxNode classNode, CancellationToken cancellationToken, out INamedTypeSymbol classType, out INamedTypeSymbol abstractClassType);
-
- public Task<Document> ImplementAbstractClassAsync(Document document, SemanticModel model, SyntaxNode node, CancellationToken cancellationToken)
- {
- var state = State.Generate(this, document, model, node, cancellationToken);
- if (state == null)
- {
- return Task.FromResult (default(Document));
- }
-
- return new Editor(document, model, state).GetEditAsync(cancellationToken);
- }
-
- public bool CanImplementAbstractClass(Document document, SemanticModel model, SyntaxNode node, CancellationToken cancellationToken)
- {
- return State.Generate(this, document, model, node, cancellationToken) != null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/CSharpImplementAbstractClassService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/CSharpImplementAbstractClassService.cs
deleted file mode 100644
index 939d65e432..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementAbstractClass/CSharpImplementAbstractClassService.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementAbstractClass
-{
- class CSharpImplementAbstractClassService : AbstractImplementAbstractClassService
- {
- protected override bool TryInitializeState(
- Document document, SemanticModel model, SyntaxNode node, CancellationToken cancellationToken,
- out INamedTypeSymbol classType, out INamedTypeSymbol abstractClassType)
- {
- var baseClassNode = node as TypeSyntax;
- if (baseClassNode != null && baseClassNode.Parent is BaseTypeSyntax &&
- baseClassNode.Parent.IsParentKind(SyntaxKind.BaseList) &&
- ((BaseTypeSyntax)baseClassNode.Parent).Type == baseClassNode)
- {
- if (baseClassNode.Parent.Parent.IsParentKind(SyntaxKind.ClassDeclaration))
- {
- abstractClassType = model.GetTypeInfo(baseClassNode, cancellationToken).Type as INamedTypeSymbol;
- cancellationToken.ThrowIfCancellationRequested();
-
- if (abstractClassType.IsAbstractClass())
- {
- var classDecl = baseClassNode.Parent.Parent.Parent as ClassDeclarationSyntax;
- classType = model.GetDeclaredSymbol(classDecl, cancellationToken) as INamedTypeSymbol;
-
- return classType != null && abstractClassType != null;
- }
- }
- }
-
- classType = null;
- abstractClassType = null;
- return false;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs
deleted file mode 100644
index 6f66185d4b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs
+++ /dev/null
@@ -1,560 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementInterface
-{
- abstract partial class AbstractImplementInterfaceService
- {
- internal partial class ImplementInterfaceCodeAction : CodeAction
- {
- protected readonly bool Explicitly;
- protected readonly bool Abstractly;
- protected readonly ISymbol ThroughMember;
- protected readonly Document Document;
- protected readonly State State;
- protected readonly AbstractImplementInterfaceService Service;
- private readonly string _equivalenceKey;
-
- internal ImplementInterfaceCodeAction(
- AbstractImplementInterfaceService service,
- Document document,
- State state,
- bool explicitly,
- bool abstractly,
- ISymbol throughMember)
- {
- this.Service = service;
- this.Document = document;
- this.State = state;
- this.Abstractly = abstractly;
- this.Explicitly = explicitly;
- this.ThroughMember = throughMember;
- _equivalenceKey = ComputeEquivalenceKey(state, explicitly, abstractly, throughMember, this.GetType().FullName);
- }
-
- public static ImplementInterfaceCodeAction CreateImplementAbstractlyCodeAction(
- AbstractImplementInterfaceService service,
- Document document,
- State state)
- {
- return new ImplementInterfaceCodeAction(service, document, state, explicitly: false, abstractly: true, throughMember: null);
- }
-
- public static ImplementInterfaceCodeAction CreateImplementCodeAction(
- AbstractImplementInterfaceService service,
- Document document,
- State state)
- {
- return new ImplementInterfaceCodeAction(service, document, state, explicitly: false, abstractly: false, throughMember: null);
- }
-
- public static ImplementInterfaceCodeAction CreateImplementExplicitlyCodeAction(
- AbstractImplementInterfaceService service,
- Document document,
- State state)
- {
- return new ImplementInterfaceCodeAction(service, document, state, explicitly: true, abstractly: false, throughMember: null);
- }
-
- public static ImplementInterfaceCodeAction CreateImplementThroughMemberCodeAction(
- AbstractImplementInterfaceService service,
- Document document,
- State state,
- ISymbol throughMember)
- {
- return new ImplementInterfaceCodeAction(service, document, state, explicitly: false, abstractly: false, throughMember: throughMember);
- }
-
- public override string Title
- {
- get
- {
- if (Explicitly)
- {
- return Resources.ImplementInterfaceExplicitly;
- }
- else if (Abstractly)
- {
- return Resources.ImplementInterfaceAbstractly;
- }
- else if (ThroughMember != null)
- {
- return string.Format(Resources.ImplementInterfaceThrough, GetDescription(ThroughMember));
- }
- else
- {
- return Resources.ImplementInterface;
- }
- }
- }
-
- private static string ComputeEquivalenceKey(
- State state,
- bool explicitly,
- bool abstractly,
- ISymbol throughMember,
- string codeActionTypeName)
- {
- var interfaceType = state.InterfaceTypes.First();
- var typeName = interfaceType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
- var assemblyName = interfaceType.ContainingAssembly.Name;
-
- return GetCodeActionEquivalenceKey(assemblyName, typeName, explicitly, abstractly, throughMember, codeActionTypeName);
- }
-
- // internal for testing purposes.
- internal static string GetCodeActionEquivalenceKey(
- string interfaceTypeAssemblyName,
- string interfaceTypeFullyQualifiedName,
- bool explicitly,
- bool abstractly,
- ISymbol throughMember,
- string codeActionTypeName)
- {
- if (throughMember != null)
- {
- return null;
- }
-
- return explicitly.ToString() + ";" +
- abstractly.ToString() + ";" +
- interfaceTypeAssemblyName + ";" +
- interfaceTypeFullyQualifiedName + ";" +
- codeActionTypeName;
- }
-
- public override string EquivalenceKey
- {
- get
- {
- return _equivalenceKey;
- }
- }
-
- private static string GetDescription(ISymbol throughMember)
- {
- return throughMember.TypeSwitch(
- (IFieldSymbol field) => field.Name,
- (IPropertySymbol property) => property.Name);
- }
-
- protected override Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- return GetUpdatedDocumentAsync(cancellationToken);
- }
-
- public Task<Document> GetUpdatedDocumentAsync(CancellationToken cancellationToken)
- {
- var unimplementedMembers = Explicitly ? State.UnimplementedExplicitMembers : State.UnimplementedMembers;
- return GetUpdatedDocumentAsync(Document, unimplementedMembers, State.ClassOrStructType, State.ClassOrStructDecl, cancellationToken);
- }
-
- public virtual async Task<Document> GetUpdatedDocumentAsync(
- Document document,
- IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> unimplementedMembers,
- INamedTypeSymbol classOrStructType,
- SyntaxNode classOrStructDecl,
- CancellationToken cancellationToken)
- {
- var result = document;
- var compilation = await result.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
-
- var memberDefinitions = GenerateMembers(
- compilation,
- unimplementedMembers,
- cancellationToken);
-
- result = await CodeGenerator.AddMemberDeclarationsAsync(
- result.Project.Solution, classOrStructType, memberDefinitions,
- new CodeGenerationOptions(contextLocation: classOrStructDecl.GetLocation(), generateDefaultAccessibility: false),
- cancellationToken).ConfigureAwait(false);
-
- return result;
- }
-
- private IList<ISymbol> GenerateMembers(
- Compilation compilation,
- IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> unimplementedMembers,
- CancellationToken cancellationToken)
- {
- // As we go along generating members we may end up with conflicts. For example, say
- // you have "interface IFoo { string Bar { get; } }" and "interface IQuux { int Bar
- // { get; } }" and we need to implement both 'Bar' methods. The second will have to
- // be explicitly implemented as it will conflict with the first. So we need to keep
- // track of what we've actually implemented so that we can check further interface
- // members against both the actual type and that list.
- //
- // Similarly, if you have two interfaces with the same member, then we don't want to
- // implement that member twice.
- //
- // Note: if we implement a method explicitly then we do *not* add it to this list.
- // That's because later members won't conflict with it even if they have the same
- // signature otherwise. i.e. if we chose to implement IFoo.Bar explicitly, then we
- // could implement IQuux.Bar implicitly (and vice versa).
- var implementedVisibleMembers = new List<ISymbol>();
- var implementedMembers = new List<ISymbol>();
-
- foreach (var tuple in unimplementedMembers)
- {
- var interfaceType = tuple.Item1;
- var unimplementedInterfaceMembers = tuple.Item2;
-
- foreach (var unimplementedInterfaceMember in unimplementedInterfaceMembers)
- {
- var member = GenerateMember(compilation, unimplementedInterfaceMember, implementedVisibleMembers, cancellationToken);
- if (member != null)
- {
- implementedMembers.Add(member);
-
- if (!(member.ExplicitInterfaceImplementations().Any() && Service.HasHiddenExplicitImplementation))
- {
- implementedVisibleMembers.Add(member);
- }
- }
- }
- }
-
- return implementedMembers;
- }
-
- private bool IsReservedName(string name)
- {
- return
- IdentifiersMatch(State.ClassOrStructType.Name, name) ||
- State.ClassOrStructType.TypeParameters.Any(t => IdentifiersMatch(t.Name, name));
- }
-
- private string DetermineMemberName(ISymbol member, List<ISymbol> implementedVisibleMembers)
- {
- if (HasConflictingMember(member, implementedVisibleMembers))
- {
- var memberNames = State.ClassOrStructType.GetAccessibleMembersInThisAndBaseTypes<ISymbol>(State.ClassOrStructType).Select(m => m.Name);
-
- return NameGenerator.GenerateUniqueName(
- string.Format("{0}_{1}", member.ContainingType.Name, member.Name),
- n => !memberNames.Contains(n) &&
- !implementedVisibleMembers.Any(m => IdentifiersMatch(m.Name, n)) &&
- !IsReservedName(n));
- }
-
- return member.Name;
- }
-
- private ISymbol GenerateMember(
- Compilation compilation,
- ISymbol member,
- List<ISymbol> implementedVisibleMembers,
- CancellationToken cancellationToken)
- {
- // First check if we already generate a member that matches the member we want to
- // generate. This can happen in C# when you have interfaces that have the same
- // method, and you are implementing implicitly. For example:
- //
- // interface IFoo { void Foo(); }
- //
- // interface IBar : IFoo { new void Foo(); }
- //
- // class C : IBar
- //
- // In this case we only want to generate 'Foo' once.
- if (HasMatchingMember(implementedVisibleMembers, member))
- {
- return null;
- }
-
- var memberName = DetermineMemberName(member, implementedVisibleMembers);
-
- // See if we need to generate an invisible member. If we do, then reset the name
- // back to what then member wants it to be.
- var generateInvisibleMember = GenerateInvisibleMember(member, memberName);
- memberName = generateInvisibleMember ? member.Name : memberName;
-
- var generateAbstractly = !generateInvisibleMember && Abstractly;
-
- // Check if we need to add 'new' to the signature we're adding. We only need to do this
- // if we're not generating something explicit and we have a naming conflict with
- // something in our base class hierarchy.
- var addNew = !generateInvisibleMember && HasNameConflict(member, memberName, State.ClassOrStructType.GetBaseTypes());
-
- // Check if we need to add 'unsafe' to the signature we're generating.
- var addUnsafe = member.IsUnsafe() && !State.Location.IsUnsafeContext();
-
- return GenerateMember(compilation, member, memberName, generateInvisibleMember, generateAbstractly, addNew, addUnsafe, cancellationToken);
- }
-
- private bool GenerateInvisibleMember(ISymbol member, string memberName)
- {
- if (Service.HasHiddenExplicitImplementation)
- {
- // User asked for an explicit (i.e. invisible) member.
- if (Explicitly)
- {
- return true;
- }
-
- // Have to create an invisible member if we have constraints we can't express
- // with a visible member.
- if (HasUnexpressableConstraint(member))
- {
- return true;
- }
-
- // If we had a conflict with a member of the same name, then we have to generate
- // as an invisible member.
- if (member.Name != memberName)
- {
- return true;
- }
- }
-
- // Can't generate an invisible member if the lanugage doesn't support it.
- return false;
- }
-
- private bool HasUnexpressableConstraint(ISymbol member)
- {
- // interface IFoo<T> { void Bar<U>() where U : T; }
- //
- // class A : IFoo<int> { }
- //
- // In this case we cannot generate an implement method for Bar. That's because we'd
- // need to say "where U : int" and that's disallowed by the language. So we must
- // generate something explicit here.
- if (member.Kind != SymbolKind.Method)
- {
- return false;
- }
-
- var method = member as IMethodSymbol;
-
- return method.TypeParameters.Any(IsUnexpressableTypeParameter);
- }
-
- private static bool IsUnexpressableTypeParameter(ITypeParameterSymbol typeParameter)
- {
- var condition1 = typeParameter.ConstraintTypes.Count(t => t.TypeKind == TypeKind.Class) >= 2;
- var condition2 = typeParameter.ConstraintTypes.Any(ts => ts.IsUnexpressableTypeParameterConstraint());
- var condition3 = typeParameter.HasReferenceTypeConstraint && typeParameter.ConstraintTypes.Any(ts => ts.IsReferenceType && ts.SpecialType != SpecialType.System_Object);
-
- return condition1 || condition2 || condition3;
- }
-
- private ISymbol GenerateMember(
- Compilation compilation,
- ISymbol member,
- string memberName,
- bool generateInvisibly,
- bool generateAbstractly,
- bool addNew,
- bool addUnsafe,
- CancellationToken cancellationToken)
- {
- var factory = this.Document.GetLanguageService<SyntaxGenerator>();
- var modifiers = DeclarationModifiers.None.WithIsAbstract(generateAbstractly).WithIsNew (addNew).WithIsUnsafe (addUnsafe);
-
- var useExplicitInterfaceSymbol = generateInvisibly || !Service.CanImplementImplicitly;
- var accessibility = member.Name == memberName ? Accessibility.Public : Accessibility.Private;
-
- if (member.Kind == SymbolKind.Method)
- {
- var method = (IMethodSymbol)member;
-
- return GenerateMethod(compilation, method, accessibility, modifiers, generateAbstractly, useExplicitInterfaceSymbol, memberName, cancellationToken);
- }
- else if (member.Kind == SymbolKind.Property)
- {
- var property = (IPropertySymbol)member;
-
- return GenerateProperty(compilation, property, accessibility, modifiers, generateAbstractly, useExplicitInterfaceSymbol, memberName, cancellationToken);
- }
- else if (member.Kind == SymbolKind.Event)
- {
- var @event = (IEventSymbol)member;
-
- var accessor = CodeGenerationSymbolFactory.CreateAccessorSymbol(
- attributes: null,
- accessibility: Accessibility.NotApplicable,
- statements: factory.CreateThrowNotImplementedStatementBlock(compilation));
-
- return CodeGenerationSymbolFactory.CreateEventSymbol(
- @event,
- accessibility: accessibility,
- modifiers: modifiers,
- explicitInterfaceSymbol: useExplicitInterfaceSymbol ? @event : null,
- name: memberName,
- addMethod: generateInvisibly ? accessor : null,
- removeMethod: generateInvisibly ? accessor : null);
- }
-
- return null;
- }
-
- private SyntaxNode CreateThroughExpression(SyntaxGenerator factory)
- {
- var through = ThroughMember.IsStatic
- ? factory.IdentifierName(State.ClassOrStructType.Name)
- : factory.ThisExpression();
-
- through = factory.MemberAccessExpression(
- through, factory.IdentifierName(ThroughMember.Name));
-
- var throughMemberType = ThroughMember.GetMemberType();
- if ((State.InterfaceTypes != null) && (throughMemberType != null))
- {
- // In the case of 'implement interface through field / property' , we need to know what
- // interface we are implementing so that we can insert casts to this interface on every
- // usage of the field in the generated code. Without these casts we would end up generating
- // code that fails compilation in certain situations.
- //
- // For example consider the following code.
- // class C : IReadOnlyList<int> { int[] field; }
- // When applying the 'implement interface through field' code fix in the above example,
- // we need to generate the following code to implement the Count property on IReadOnlyList<int>
- // class C : IReadOnlyList<int> { int[] field; int Count { get { ((IReadOnlyList<int>)field).Count; } ...}
- // as opposed to the following code which will fail to compile (because the array field
- // doesn't have a property named .Count) -
- // class C : IReadOnlyList<int> { int[] field; int Count { get { field.Count; } ...}
- //
- // The 'InterfaceTypes' property on the state object always contains only one item
- // in the case of C# i.e. it will contain exactly the interface we are trying to implement.
- // This is also the case most of the time in the case of VB, except in certain error conditions
- // (recursive / circular cases) where the span of the squiggle for the corresponding
- // diagnostic (BC30149) changes and 'InterfaceTypes' ends up including all interfaces
- // in the Implements clause. For the purposes of inserting the above cast, we ignore the
- // uncommon case and optimize for the common one - in other words, we only apply the cast
- // in cases where we can unambiguously figure out which interface we are trying to implement.
- var interfaceBeingImplemented = State.InterfaceTypes.SingleOrDefault();
- if ((interfaceBeingImplemented != null) && (!throughMemberType.Equals(interfaceBeingImplemented)))
- {
- through = factory.CastExpression(interfaceBeingImplemented,
- through.WithAdditionalAnnotations (Simplifier.Annotation));
-
- through = through.Parenthesize();
- }
- }
-
- return through.WithAdditionalAnnotations(Simplifier.Annotation);
- }
-
- private bool HasNameConflict(
- ISymbol member,
- string memberName,
- IEnumerable<INamedTypeSymbol> baseTypes)
- {
- // There's a naming conflict if any member in the base types chain is accessible to
- // us, has our name. Note: a simple name won't conflict with a generic name (and
- // vice versa). A method only conflicts with another method if they have the same
- // parameter signature (return type is irrelevant).
- return
- baseTypes.Any(ts => ts.GetMembers(memberName)
- .Where(m => m.IsAccessibleWithin(State.ClassOrStructType))
- .Any(m => HasNameConflict(member, memberName, m)));
- }
-
- private static bool HasNameConflict(
- ISymbol member,
- string memberName,
- ISymbol baseMember)
- {
- //Contract.Requires(memberName == baseMember.Name);
-
- if (member.Kind == SymbolKind.Method && baseMember.Kind == SymbolKind.Method)
- {
- // A method only conflicts with another method if htey have the same parameter
- // signature (return type is irrelevant).
- var method1 = (IMethodSymbol)member;
- var method2 = (IMethodSymbol)baseMember;
-
- if (method1.MethodKind == MethodKind.Ordinary &&
- method2.MethodKind == MethodKind.Ordinary &&
- method1.TypeParameters.Length == method2.TypeParameters.Length)
- {
- return method1.Parameters.Select(p => p.Type)
- .SequenceEqual(method2.Parameters.Select(p => p.Type));
- }
- }
-
- // Any non method members with the same name simple name conflict.
- return true;
- }
-
- private bool IdentifiersMatch(string identifier1, string identifier2)
- {
- return this.IsCaseSensitive
- ? identifier1 == identifier2
- : StringComparer.OrdinalIgnoreCase.Equals(identifier1, identifier2);
- }
-
- private bool IsCaseSensitive
- {
- get
- {
- return true;//this.Document.GetLanguageService<ISyntaxFactsService>().IsCaseSensitive;
- }
- }
-
- private bool HasMatchingMember(List<ISymbol> implementedVisibleMembers, ISymbol member)
- {
- // If this is a language that doesn't support implicit implementation then no
- // implemented members will ever match. For example, if you have:
- //
- // Interface IFoo : sub Foo() : End Interface
- //
- // Interface IBar : Inherits IFoo : Shadows Sub Foo() : End Interface
- //
- // Class C : Implements IBar
- //
- // We'll first end up generating:
- //
- // Public Sub Foo() Implements IFoo.Foo
- //
- // However, that same method won't be viable for IBar.Foo (unlike C#) because it
- // explicitly specifies its interface).
- if (!Service.CanImplementImplicitly)
- {
- return false;
- }
-
- return implementedVisibleMembers.Any(m => MembersMatch(m, member));
- }
-
- private bool MembersMatch(ISymbol member1, ISymbol member2)
- {
- if (member1.Kind != member2.Kind)
- {
- return false;
- }
-
- if (member1.DeclaredAccessibility != member2.DeclaredAccessibility ||
- member1.IsStatic != member2.IsStatic)
- {
- return false;
- }
-
- if (member1.ExplicitInterfaceImplementations().Any() || member2.ExplicitInterfaceImplementations().Any())
- {
- return false;
- }
-
- return SignatureComparer.HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors(
- member1, member2, this.IsCaseSensitive);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Conflicts.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Conflicts.cs
deleted file mode 100644
index 0e92c1a073..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Conflicts.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementInterface
-{
- abstract partial class AbstractImplementInterfaceService
- {
- internal partial class ImplementInterfaceCodeAction
- {
- private bool HasConflictingMember(ISymbol member, List<ISymbol> implementedVisibleMembers)
- {
- // Checks if this member conflicts with an existing member in classOrStructType or with
- // a method we've already implemented. If so, we'll need to implement this one
- // explicitly.
-
- var allMembers = State.ClassOrStructType.GetAccessibleMembersInThisAndBaseTypes<ISymbol>(State.ClassOrStructType).Concat(implementedVisibleMembers);
-
- var conflict1 = allMembers.Any(m => HasConflict(m, member));
- var conflict2 = IsReservedName(member.Name);
-
- return conflict1 || conflict2;
- }
-
- private bool HasConflict(ISymbol member1, ISymbol member2)
- {
- // If either of these members are invisible explicit, then there is no conflict.
- if (Service.HasHiddenExplicitImplementation)
- {
- if (member1.ExplicitInterfaceImplementations().Any() || member2.ExplicitInterfaceImplementations().Any())
- {
- // explicit methods don't conflict with anything.
- return false;
- }
- }
-
- // Members normally conflict if they have the same name. The exceptions are methods
- // and parameterized properties (which conflict if htey have the same signature).
- if (!IdentifiersMatch(member1.Name, member2.Name))
- {
- return false;
- }
-
- // If they differ in type, then it's almost always a conflict. There may be
- // exceptions to this, but i don't know of any.
- if (member1.Kind != member2.Kind)
- {
- return true;
- }
-
- // At this point, we have two members of the same type with the same name. If they
- // have a different signature (for example, methods, or parameterized properties),
- // then they do not conflict.
- if (!SignatureComparer.HaveSameSignature(member1, member2, this.IsCaseSensitive))
- {
- return false;
- }
-
- // Now we have to members with the same name, type and signature. If the language
- // doesn't support implicit implementation, then these members are definitely in
- // conflict.
- if (!Service.CanImplementImplicitly)
- {
- return true;
- }
-
- // two members conflict if they have the same signature and have
- //
- // a) different return types
- // b) different accessibility
- // c) different constraints
- if (member1.DeclaredAccessibility != member2.DeclaredAccessibility ||
- !SignatureComparer.HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors(member1, member2, this.IsCaseSensitive))
- {
- return true;
- }
-
- // Same name, type, accessibility, return type, *and* the services can implement
- // implicitly. These are not in conflict.
- return false;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Method.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Method.cs
deleted file mode 100644
index 228a0df7f8..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Method.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementInterface
-{
- abstract partial class AbstractImplementInterfaceService
- {
- internal partial class ImplementInterfaceCodeAction
- {
- private ISymbol GenerateMethod(
- Compilation compilation,
- IMethodSymbol method,
- Accessibility accessibility,
- DeclarationModifiers modifiers,
- bool generateAbstractly,
- bool useExplicitInterfaceSymbol,
- string memberName,
- CancellationToken cancellationToken)
- {
-
- var updatedMethod = method.EnsureNonConflictingNames(
- this.State.ClassOrStructType, cancellationToken);
-
- updatedMethod = updatedMethod.RemoveAttributeFromParametersAndReturnType(compilation.ComAliasNameAttributeType());
-
- return CodeGenerationSymbolFactory.CreateMethodSymbol(
- updatedMethod,
- accessibility: accessibility,
- modifiers: modifiers,
- explicitInterfaceSymbol: useExplicitInterfaceSymbol ? updatedMethod : null,
- name: memberName,
- statements: generateAbstractly ? null : new[] { CreateStatement(compilation, updatedMethod, cancellationToken) });
- }
-
- private SyntaxNode CreateStatement(
- Compilation compilation,
- IMethodSymbol method,
- CancellationToken cancellationToken)
- {
- if (ThroughMember == null)
- {
- var factory = this.Document.GetLanguageService<SyntaxGenerator>();
- return factory.CreateThrowNotImplementStatement(compilation);
- }
- else
- {
- return CreateDelegationStatement(method);
- }
- }
-
- private SyntaxNode CreateDelegationStatement(
- IMethodSymbol method)
- {
- var factory = this.Document.GetLanguageService<SyntaxGenerator>();
- var through = CreateThroughExpression(factory);
-
- var memberName = method.IsGenericMethod
- ? factory.GenericName(method.Name, method.TypeArguments.OfType<ITypeSymbol>().ToList())
- : factory.IdentifierName(method.Name);
-
- through = factory.MemberAccessExpression(
- through, memberName);
-
- var arguments = factory.CreateArguments(method.Parameters.As<IParameterSymbol>());
- var invocationExpression = factory.InvocationExpression(through, arguments);
-
- return method.ReturnsVoid
- ? factory.ExpressionStatement(invocationExpression)
- : factory.ReturnStatement(invocationExpression);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Property.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Property.cs
deleted file mode 100644
index 3141688e3a..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.CodeAction_Property.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementInterface
-{
- abstract partial class AbstractImplementInterfaceService
- {
- internal partial class ImplementInterfaceCodeAction
- {
- private ISymbol GenerateProperty(
- Compilation compilation,
- IPropertySymbol property,
- Accessibility accessibility,
- DeclarationModifiers modifiers,
- bool generateAbstractly,
- bool useExplicitInterfaceSymbol,
- string memberName,
- CancellationToken cancellationToken)
- {
- //var factory = this.Document.GetLanguageService<SyntaxGenerator>();
- var comAliasNameAttribute = compilation.ComAliasNameAttributeType();
-
- var getAccessor = property.GetMethod == null
- ? null
- : CodeGenerationSymbolFactory.CreateAccessorSymbol(
- property.GetMethod.RemoveAttributeFromParametersAndReturnType(comAliasNameAttribute),
- attributes: null,
- accessibility: accessibility,
- explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property.GetMethod : null,
- statements: GetGetAccessorStatements(compilation, property, generateAbstractly, cancellationToken));
-
- var setAccessor = property.SetMethod == null
- ? null
- : CodeGenerationSymbolFactory.CreateAccessorSymbol(
- property.SetMethod.RemoveAttributeFromParametersAndReturnType(comAliasNameAttribute),
- attributes: null,
- accessibility: accessibility,
- explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property.SetMethod : null,
- statements: GetSetAccessorStatements(compilation, property, generateAbstractly, cancellationToken));
-
- var parameterNames = NameGenerator.EnsureUniqueness(
- property.Parameters.Select(p => p.Name).ToList(), isCaseSensitive: true);
-
- var updatedProperty = property.RenameParameters(parameterNames);
-
- updatedProperty = updatedProperty.RemoveAttributeFromParameters(comAliasNameAttribute);
-
- // TODO(cyrusn): Delegate through throughMember if it's non-null.
- return CodeGenerationSymbolFactory.CreatePropertySymbol(
- updatedProperty,
- accessibility: accessibility,
- modifiers: modifiers,
- explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property : null,
- name: memberName,
- getMethod: getAccessor,
- setMethod: setAccessor);
- }
-
- private IList<SyntaxNode> GetSetAccessorStatements(
- Compilation compilation,
- IPropertySymbol property,
- bool generateAbstractly,
- CancellationToken cancellationToken)
- {
- if (generateAbstractly)
- {
- return null;
- }
-
- var factory = this.Document.GetLanguageService<SyntaxGenerator>();
- if (ThroughMember != null)
- {
- var throughExpression = CreateThroughExpression(factory);
- SyntaxNode expression;
-
- if (property.IsIndexer)
- {
- expression = throughExpression;
- }
- else
- {
- expression = factory.MemberAccessExpression(
- throughExpression, factory.IdentifierName(property.Name));
- }
-
- if (property.Parameters.Length > 0)
- {
- var arguments = factory.CreateArguments(property.Parameters.As<IParameterSymbol>());
- expression = factory.ElementAccessExpression(expression, arguments);
- }
-
- expression = factory.AssignmentStatement(expression, factory.IdentifierName("value"));
-
- return new[] { factory.ExpressionStatement(expression) };
- }
-
- return factory.CreateThrowNotImplementedStatementBlock(compilation);
- }
-
- private IList<SyntaxNode> GetGetAccessorStatements(
- Compilation compilation,
- IPropertySymbol property,
- bool generateAbstractly,
- CancellationToken cancellationToken)
- {
- if (generateAbstractly)
- {
- return null;
- }
-
- var factory = this.Document.GetLanguageService<SyntaxGenerator>();
- if (ThroughMember != null)
- {
- var throughExpression = CreateThroughExpression(factory);
- SyntaxNode expression;
-
- if (property.IsIndexer)
- {
- expression = throughExpression;
- }
- else
- {
- expression = factory.MemberAccessExpression(
- throughExpression, factory.IdentifierName(property.Name));
- }
-
- if (property.Parameters.Length > 0)
- {
- var arguments = factory.CreateArguments(property.Parameters.As<IParameterSymbol>());
- expression = factory.ElementAccessExpression(expression, arguments);
- }
-
- return new[] { factory.ReturnStatement(expression) };
- }
-
- return factory.CreateThrowNotImplementedStatementBlock(compilation);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.DisposePatternCodeAction.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.DisposePatternCodeAction.cs
deleted file mode 100644
index f88296279e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.DisposePatternCodeAction.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementInterface
-{
- abstract partial class AbstractImplementInterfaceService
- {
- private static INamedTypeSymbol TryGetSymbolForIDisposable(Compilation compilation)
- {
- // Get symbol for 'System.IDisposable'.
- var idisposable = compilation.GetSpecialType(SpecialType.System_IDisposable);
- if ((idisposable != null) && (idisposable.TypeKind == TypeKind.Interface))
- {
- var idisposableMembers = idisposable.GetMembers().ToArray();
-
- // Get symbol for 'System.IDisposable.Dispose()'.
- IMethodSymbol disposeMethod = null;
- if ((idisposableMembers.Length == 1) && (idisposableMembers[0].Kind == SymbolKind.Method) &&
- (idisposableMembers[0].Name == "Dispose"))
- {
- disposeMethod = idisposableMembers[0] as IMethodSymbol;
- if ((disposeMethod != null) && (!disposeMethod.IsStatic) && disposeMethod.ReturnsVoid &&
- (disposeMethod.Arity == 0) && (disposeMethod.Parameters.Length == 0))
- {
- return idisposable;
- }
- }
- }
-
- return null;
- }
-
- private bool ShouldImplementDisposePattern(Document document, State state, bool explicitly)
- {
- // Dispose pattern should be implemented only if -
- // 1. An interface named 'System.IDisposable' is unimplemented.
- // 2. This interface has one and only one member - a non-generic method named 'Dispose' that takes no arguments and returns 'void'.
- // 3. The implementing type is a class that does not already declare any conflicting members named 'disposedValue' or 'Dispose'
- // (because we will be generating a 'disposedValue' field and a couple of methods named 'Dispose' as part of implementing
- // the dispose pattern).
- var unimplementedMembers = explicitly ? state.UnimplementedExplicitMembers : state.UnimplementedMembers;
- var idisposable = TryGetSymbolForIDisposable(state.Model.Compilation);
- return (idisposable != null) &&
- unimplementedMembers.Any(m => m.Item1.Equals(idisposable)) &&
- this.CanImplementDisposePattern(state.ClassOrStructType, state.ClassOrStructDecl);
- }
-
- internal class ImplementInterfaceWithDisposePatternCodeAction : ImplementInterfaceCodeAction
- {
- internal ImplementInterfaceWithDisposePatternCodeAction(
- AbstractImplementInterfaceService service,
- Document document,
- State state,
- bool explicitly,
- bool abstractly,
- ISymbol throughMember) : base(service, document, state, explicitly, abstractly, throughMember)
- {
- }
-
- public static ImplementInterfaceWithDisposePatternCodeAction CreateImplementWithDisposePatternCodeAction(
- AbstractImplementInterfaceService service,
- Document document,
- State state)
- {
- return new ImplementInterfaceWithDisposePatternCodeAction(service, document, state, explicitly: false, abstractly: false, throughMember: null);
- }
-
- public static ImplementInterfaceWithDisposePatternCodeAction CreateImplementExplicitlyWithDisposePatternCodeAction(
- AbstractImplementInterfaceService service,
- Document document,
- State state)
- {
- return new ImplementInterfaceWithDisposePatternCodeAction(service, document, state, explicitly: true, abstractly: false, throughMember: null);
- }
-
- public override string Title
- {
- get
- {
- if (Explicitly)
- {
- return Resources.ImplementInterfaceExplicitlyWithDisposePattern;
- }
- else
- {
- return Resources.ImplementInterfaceWithDisposePattern;
- }
- }
- }
-
- private static readonly SyntaxAnnotation s_implementingTypeAnnotation = new SyntaxAnnotation("ImplementingType");
- public override async Task<Document> GetUpdatedDocumentAsync(
- Document document,
- IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> unimplementedMembers,
- INamedTypeSymbol classOrStructType,
- SyntaxNode classOrStructDecl,
- CancellationToken cancellationToken)
- {
- var result = document;
- var compilation = await result.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
-
- // Add an annotation to the type declaration node so that we can find it again to append the dispose pattern implementation below.
- result = await result.ReplaceNodeAsync(
- classOrStructDecl,
- classOrStructDecl.WithAdditionalAnnotations(s_implementingTypeAnnotation),
- cancellationToken).ConfigureAwait(false);
- var root = await result.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- classOrStructDecl = root.GetAnnotatedNodes(s_implementingTypeAnnotation).Single();
- compilation = await result.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
- classOrStructType = classOrStructType.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as INamedTypeSymbol;
-
- // Use the code generation service to generate all unimplemented members except those that are
- // part of the dispose pattern. We can't use the code generation service to implement the dispose
- // pattern since the code generation service doesn't support injection of the custom boiler
- // plate code required for implementing the dispose pattern.
- var idisposable = TryGetSymbolForIDisposable(compilation);
- result = await base.GetUpdatedDocumentAsync(
- result,
- unimplementedMembers.Where(m => !m.Item1.Equals(idisposable)).ToList(),
- classOrStructType,
- classOrStructDecl,
- cancellationToken).ConfigureAwait(false);
-
- // Now append the dispose pattern implementation.
- root = await result.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- classOrStructDecl = root.GetAnnotatedNodes(s_implementingTypeAnnotation).Single();
- compilation = await result.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
- classOrStructType = classOrStructType.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as INamedTypeSymbol;
- result = Service.ImplementDisposePattern(result, root, classOrStructType, classOrStructDecl.SpanStart, Explicitly);
-
- // Remove the annotation since we don't need it anymore.
- root = await result.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- classOrStructDecl = root.GetAnnotatedNodes(s_implementingTypeAnnotation).Single();
- result = await result.ReplaceNodeAsync(
- classOrStructDecl,
- classOrStructDecl.WithoutAnnotations(s_implementingTypeAnnotation),
- cancellationToken).ConfigureAwait(false);
-
- return result;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.State.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.State.cs
deleted file mode 100644
index b1048b7efa..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.State.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementInterface
-{
- abstract partial class AbstractImplementInterfaceService
- {
- internal protected class State
- {
- public SyntaxNode Location { get; }
- public SyntaxNode ClassOrStructDecl { get; }
- public INamedTypeSymbol ClassOrStructType { get; }
- public IEnumerable<INamedTypeSymbol> InterfaceTypes { get; }
- public SemanticModel Model { get; }
-
- // The members that are not implemented at all.
- public IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> UnimplementedMembers { get; private set; }
-
- // The members that have no explicit implementation.
- public IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> UnimplementedExplicitMembers { get; private set; }
-
- public State(SyntaxNode interfaceNode, SyntaxNode classOrStructDecl, INamedTypeSymbol classOrStructType, IEnumerable<INamedTypeSymbol> interfaceTypes, SemanticModel model)
- {
- this.Location = interfaceNode;
- this.ClassOrStructDecl = classOrStructDecl;
- this.ClassOrStructType = classOrStructType;
- this.InterfaceTypes = interfaceTypes;
- this.Model = model;
- }
-
- public static State Generate(
- AbstractImplementInterfaceService service,
- Document document,
- SemanticModel model,
- SyntaxNode interfaceNode,
- CancellationToken cancellationToken)
- {
- SyntaxNode classOrStructDecl;
- INamedTypeSymbol classOrStructType;
- IEnumerable<INamedTypeSymbol> interfaceTypes;
- if (!service.TryInitializeState(document, model, interfaceNode, cancellationToken,
- out classOrStructDecl, out classOrStructType, out interfaceTypes))
- {
- return null;
- }
-
- if (!CodeGenerator.CanAdd(document.Project.Solution, classOrStructType, cancellationToken))
- {
- return null;
- }
-
- var state = new State(interfaceNode, classOrStructDecl, classOrStructType, interfaceTypes, model);
-
- if (service.CanImplementImplicitly)
- {
- state.UnimplementedMembers = state.ClassOrStructType.GetAllUnimplementedMembers(
- interfaceTypes, cancellationToken);
-
- state.UnimplementedExplicitMembers = state.ClassOrStructType.GetAllUnimplementedExplicitMembers(
- interfaceTypes, cancellationToken);
-
- var allMembersImplemented = state.UnimplementedMembers == null || state.UnimplementedMembers.Count == 0;
- var allMembersImplementedExplicitly = state.UnimplementedExplicitMembers == null || state.UnimplementedExplicitMembers.Count == 0;
-
- return !allMembersImplementedExplicitly && !allMembersImplemented ? state : null;
- }
- else
- {
- state.UnimplementedMembers = state.ClassOrStructType.GetAllUnimplementedExplicitMembers(
- interfaceTypes, cancellationToken);
-
- var allMembersImplemented = state.UnimplementedMembers == null || state.UnimplementedMembers.Count == 0;
- return !allMembersImplemented ? state : null;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.cs
deleted file mode 100644
index f4ba3bcf6f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/AbstractImplementInterfaceService.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementInterface
-{
- abstract partial class AbstractImplementInterfaceService
- {
- protected AbstractImplementInterfaceService()
- {
- }
-
- protected abstract bool CanImplementImplicitly { get; }
- protected abstract bool HasHiddenExplicitImplementation { get; }
- protected abstract bool TryInitializeState(Document document, SemanticModel model, SyntaxNode interfaceNode, CancellationToken cancellationToken, out SyntaxNode classOrStructDecl, out INamedTypeSymbol classOrStructType, out IEnumerable<INamedTypeSymbol> interfaceTypes);
- protected abstract bool CanImplementDisposePattern(INamedTypeSymbol symbol, SyntaxNode classDecl);
- protected abstract Document ImplementDisposePattern(Document document, SyntaxNode root, INamedTypeSymbol symbol, int position, bool explicitly);
-
- public async Task<Document> ImplementInterfaceAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
- var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- var state = State.Generate(this, document, model, node, cancellationToken);
- if (state == null)
- {
- return document;
- }
-
- // While implementing just one default action, like in the case of pressing enter after interface name in VB,
- // choose to implement with the dispose pattern as that's the Dev12 behavior.
- var action = ShouldImplementDisposePattern(document, state, explicitly: false) ?
- ImplementInterfaceWithDisposePatternCodeAction.CreateImplementWithDisposePatternCodeAction(this, document, state) :
- ImplementInterfaceCodeAction.CreateImplementCodeAction(this, document, state);
-
- return await action.GetUpdatedDocumentAsync(cancellationToken).ConfigureAwait(false);
- }
-
- public IEnumerable<CodeAction> GetCodeActions(Document document, SemanticModel model, SyntaxNode node, CancellationToken cancellationToken)
- {
- var state = State.Generate(this, document, model, node, cancellationToken);
- return GetActions(document, state);
- }
-
- private IEnumerable<CodeAction> GetActions(Document document, State state)
- {
- if (state == null)
- {
- yield break;
- }
-
- if (state.UnimplementedMembers != null && state.UnimplementedMembers.Count > 0)
- {
- yield return ImplementInterfaceCodeAction.CreateImplementCodeAction(this, document, state);
-
- if (ShouldImplementDisposePattern(document, state, explicitly: false))
- {
- yield return ImplementInterfaceWithDisposePatternCodeAction.CreateImplementWithDisposePatternCodeAction(this, document, state);
- }
-
- var delegatableMembers = GetDelegatableMembers(state);
- foreach (var member in delegatableMembers)
- {
- yield return ImplementInterfaceCodeAction.CreateImplementThroughMemberCodeAction(this, document, state, member);
- }
-
- if (state.ClassOrStructType.IsAbstract)
- {
- yield return ImplementInterfaceCodeAction.CreateImplementAbstractlyCodeAction(this, document, state);
- }
- }
-
- if (state.UnimplementedExplicitMembers != null && state.UnimplementedExplicitMembers.Count > 0)
- {
- yield return ImplementInterfaceCodeAction.CreateImplementExplicitlyCodeAction(this, document, state);
-
- if (ShouldImplementDisposePattern(document, state, explicitly: true))
- {
- yield return ImplementInterfaceWithDisposePatternCodeAction.CreateImplementExplicitlyWithDisposePatternCodeAction(this, document, state);
- }
- }
- }
-
- private IList<ISymbol> GetDelegatableMembers(State state)
- {
- var fields =
- state.ClassOrStructType.GetMembers()
- .OfType<IFieldSymbol>()
- .Where(f => !f.IsImplicitlyDeclared)
- .Where(f => f.Type.GetAllInterfacesIncludingThis().Contains(state.InterfaceTypes.First()))
- .OfType<ISymbol>();
-
- // Select all properties with zero parameters that also have a getter
- var properties =
- state.ClassOrStructType.GetMembers()
- .OfType<IPropertySymbol>()
- .Where(p => (!p.IsImplicitlyDeclared) && (p.Parameters.Length == 0) && (p.GetMethod != null))
- .Where(p => p.Type.GetAllInterfacesIncludingThis().Contains(state.InterfaceTypes.First()))
- .OfType<ISymbol>();
-
- return fields.Concat(properties).ToList();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/CSharpImplementInterfaceService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/CSharpImplementInterfaceService.cs
deleted file mode 100644
index 33834a9f6e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ImplementInterface/CSharpImplementInterfaceService.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Composition;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.ImplementInterface
-{
- class CSharpImplementInterfaceService : AbstractImplementInterfaceService
- {
- protected override bool TryInitializeState(
- Document document, SemanticModel model, SyntaxNode node, CancellationToken cancellationToken,
- out SyntaxNode classOrStructDecl, out INamedTypeSymbol classOrStructType, out IEnumerable<INamedTypeSymbol> interfaceTypes)
- {
- if (!cancellationToken.IsCancellationRequested)
- {
- var interfaceNode = node as TypeSyntax;
- if (interfaceNode != null && interfaceNode.Parent is BaseTypeSyntax &&
- interfaceNode.Parent.IsParentKind(SyntaxKind.BaseList) &&
- ((BaseTypeSyntax)interfaceNode.Parent).Type == interfaceNode)
- {
- if (interfaceNode.Parent.Parent.IsParentKind(SyntaxKind.ClassDeclaration) ||
- interfaceNode.Parent.Parent.IsParentKind(SyntaxKind.StructDeclaration))
- {
- var interfaceSymbolInfo = model.GetSymbolInfo(interfaceNode, cancellationToken);
- if (interfaceSymbolInfo.CandidateReason != CandidateReason.WrongArity)
- {
- var interfaceType = interfaceSymbolInfo.GetAnySymbol() as INamedTypeSymbol;
- cancellationToken.ThrowIfCancellationRequested();
-
- if (interfaceType != null && interfaceType.TypeKind == TypeKind.Interface)
- {
- classOrStructDecl = interfaceNode.Parent.Parent.Parent as TypeDeclarationSyntax;
- classOrStructType = model.GetDeclaredSymbol(classOrStructDecl, cancellationToken) as INamedTypeSymbol;
- interfaceTypes = SpecializedCollections.SingletonEnumerable(interfaceType);
-
- return interfaceTypes != null && classOrStructType != null;
- }
- }
- }
- }
- }
-
- classOrStructDecl = null;
- classOrStructType = null;
- interfaceTypes = null;
- return false;
- }
-
- protected override bool CanImplementImplicitly
- {
- get
- {
- return true;
- }
- }
-
- protected override bool HasHiddenExplicitImplementation
- {
- get
- {
- return true;
- }
- }
-
- private static ClassDeclarationSyntax GetClassDeclarationAt(SyntaxNode root, int position)
- {
- var node = root.FindToken(position).Parent.FirstAncestorOrSelf((SyntaxNode n) => n.IsKind(SyntaxKind.ClassDeclaration));
- return node as ClassDeclarationSyntax;
- }
-
- protected override bool CanImplementDisposePattern(INamedTypeSymbol symbol, SyntaxNode classDecl)
- {
- // The dispose pattern is only applicable if the implementing type is a class that does not already declare any conflicting
- // members named 'disposedValue' or 'Dispose' (because we will be generating a 'disposedValue' field and a couple of methods
- // named 'Dispose' as part of implementing the dispose pattern).
- return (classDecl != null) &&
- classDecl.IsKind(SyntaxKind.ClassDeclaration) &&
- (symbol != null) &&
- !symbol.GetMembers().Any(m => (m.MetadataName == "Dispose") || (m.MetadataName == "disposedValue"));
- }
-
- protected override Document ImplementDisposePattern(Document document, SyntaxNode root, INamedTypeSymbol symbol, int position, bool explicitly)
- {
- var classDecl = GetClassDeclarationAt(root, position);
- Debug.Assert(CanImplementDisposePattern(symbol, classDecl), "ImplementDisposePattern called with bad inputs");
-
- // Generate the IDisposable boilerplate code. The generated code cannot be one giant resource string
- // because of the need to parse, format, and simplify the result; during pseudo-localized builds, resource
- // strings are given a special prefix and suffix that will break the parser, hence the requirement to
- // localize the comments individually.
- var code = string.Format (@"
- #region IDisposable Support
- private bool disposedValue = false; // {0}
-
- {1}void Dispose(bool disposing)
- {{
- if (!disposedValue)
- {{
- if (disposing)
- {{
- // {2}
- }}
-
- // {3}
- // {4}
-
- disposedValue = true;
- }}
- }}
-
- // {5}
- // ~{6}() {{
- // // {7}
- // Dispose(false);
- // }}
-
- // {8}
- {9}Dispose()
- {{
- // {10}
- Dispose(true);
- // {11}
- // GC.SuppressFinalize(this);
- }}
- #endregion
- ",
- Resources.ToDetectRedundantCalls,
- (symbol.IsSealed ? "" : "protected virtual "),
- Resources.DisposeManagedStateTodo,
- Resources.FreeUnmanagedResourcesTodo,
- Resources.SetLargeFieldsToNullTodo,
- Resources.OverrideAFinalizerTodo,
- classDecl.Identifier.Value,
- Resources.DoNotChangeThisCodeUseDispose,
- Resources.ThisCodeAddedToCorrectlyImplementDisposable,
- (explicitly ? "void System.IDisposable." : "public void "),
- Resources.DoNotChangeThisCodeUseDispose,
- Resources.UncommentTheFollowingIfFinalizerOverriddenTodo
- );
-
- var decls = SyntaxFactory.ParseSyntaxTree(code)
- .GetRoot().DescendantNodes().OfType<MemberDeclarationSyntax>()
- .Select(decl => decl.WithAdditionalAnnotations(Formatter.Annotation, Simplifier.Annotation))
- .ToArray();
-
- // Append #endregion to the trailing trivia of the last declaration being generated.
- decls[decls.Length - 1] = decls[decls.Length - 1].WithAppendedTrailingTrivia(
- SyntaxFactory.TriviaList(
- SyntaxFactory.Trivia(SyntaxFactory.EndRegionDirectiveTrivia(true)),
- SyntaxFactory.CarriageReturnLineFeed));
-
- // Ensure that open and close brace tokens are generated in case they are missing.
- var newNode = classDecl.EnsureOpenAndCloseBraceTokens().AddMembers(decls);
-
- return document.WithSyntaxRoot(root.ReplaceNode(classDecl, newNode));
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.AbstractIntroduceVariableCodeAction.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.AbstractIntroduceVariableCodeAction.cs
deleted file mode 100644
index d233632cbb..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.AbstractIntroduceVariableCodeAction.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text.RegularExpressions;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Simplification;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- internal abstract class AbstractIntroduceVariableCodeAction : CodeAction
- {
- private readonly bool _allOccurrences;
- private readonly bool _isConstant;
- private readonly bool _isLocal;
- private readonly bool _isQueryLocal;
- private readonly TExpressionSyntax _expression;
- private readonly SemanticDocument _document;
- private readonly TService _service;
- private readonly string _title;
-
- private static Regex s_newlinePattern = new Regex(@"[\r\n]+", RegexOptions.Compiled);
-
- internal AbstractIntroduceVariableCodeAction(
- TService service,
- SemanticDocument document,
- TExpressionSyntax expression,
- bool allOccurrences,
- bool isConstant,
- bool isLocal,
- bool isQueryLocal)
- {
- _service = service;
- _document = document;
- _expression = expression;
- _allOccurrences = allOccurrences;
- _isConstant = isConstant;
- _isLocal = isLocal;
- _isQueryLocal = isQueryLocal;
- _title = CreateDisplayText(expression);
- }
-
- public override string Title
- {
- get { return _title; }
- }
-
- protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- var changedDocument = await GetChangedDocumentCoreAsync(cancellationToken).ConfigureAwait(false);
- return await Simplifier.ReduceAsync(changedDocument, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
-
- private async Task<Document> GetChangedDocumentCoreAsync(CancellationToken cancellationToken)
- {
- if (_isQueryLocal)
- {
- return await _service.IntroduceQueryLocalAsync(_document, _expression, _allOccurrences, cancellationToken).ConfigureAwait(false);
- }
- else if (_isLocal)
- {
- return await _service.IntroduceLocalAsync(_document, _expression, _allOccurrences, _isConstant, cancellationToken).ConfigureAwait(false);
- }
- else
- {
- return await IntroduceFieldAsync(cancellationToken).ConfigureAwait(false);
- }
- }
-
- private async Task<Document> IntroduceFieldAsync(CancellationToken cancellationToken)
- {
- var result = await _service.IntroduceFieldAsync(_document, _expression, _allOccurrences, _isConstant, cancellationToken).ConfigureAwait(false);
- return result.Item1;
- }
-
- private string CreateDisplayText(TExpressionSyntax expression)
- {
- var singleLineExpression = expression.ConvertToSingleLine();
- var nodeString = singleLineExpression.ToFullString().Trim();
-
- // prevent the display string from spanning multiple lines
- nodeString = s_newlinePattern.Replace(nodeString, " ");
-
- // prevent the display string from being too long
- const int MaxLength = 40;
- if (nodeString.Length > MaxLength)
- {
- nodeString = nodeString.Substring(0, MaxLength) + "...";
- }
-
- return CreateDisplayText(nodeString);
- }
-
- private string CreateDisplayText(string nodeString)
- {
- // Indexed by: allOccurrences, isConstant, isLocal
- var formatStrings = new string[2, 2, 2]
- {
- {
- { Resources.IntroduceFieldFor, Resources.IntroduceLocalFor },
- { Resources.IntroduceConstantFor, Resources.IntroduceLocalConstantFor }
- },
- {
- { Resources.IntroduceFieldForAllOccurrences, Resources.IntroduceLocalForAllOccurrences },
- { Resources.IntroduceConstantForAllOccurrences, Resources.IntroduceLocalConstantForAll }
- }
- };
-
- var formatString = _isQueryLocal
- ? _allOccurrences
- ? Resources.IntroduceQueryVariableForAll
- : Resources.IntroduceQueryVariableFor
- : formatStrings[_allOccurrences ? 1 : 0, _isConstant ? 1 : 0, _isLocal ? 1 : 0];
- return string.Format(formatString, nodeString);
- }
-
- protected ITypeSymbol GetExpressionType(
- CancellationToken cancellationToken)
- {
- var semanticModel = _document.SemanticModel;
- var typeInfo = semanticModel.GetTypeInfo(_expression, cancellationToken);
-
- return typeInfo.Type ?? typeInfo.ConvertedType ?? semanticModel.Compilation.GetSpecialType(SpecialType.System_Object);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.CodeAction.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.CodeAction.cs
deleted file mode 100644
index f4084abecb..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.CodeAction.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Simplification;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- private class IntroduceVariableCodeAction : AbstractIntroduceVariableCodeAction
- {
- internal IntroduceVariableCodeAction(
- TService service,
- SemanticDocument document,
- TExpressionSyntax expression,
- bool allOccurrences,
- bool isConstant,
- bool isLocal,
- bool isQueryLocal)
- : base(service, document, expression, allOccurrences, isConstant, isLocal, isQueryLocal)
- {
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.IntroduceVariableAllOccurrenceCodeAction.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.IntroduceVariableAllOccurrenceCodeAction.cs
deleted file mode 100644
index aebb852346..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.IntroduceVariableAllOccurrenceCodeAction.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CaseCorrection;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Simplification;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- private class IntroduceVariableAllOccurrenceCodeAction : AbstractIntroduceVariableCodeAction
- {
- internal IntroduceVariableAllOccurrenceCodeAction(
- TService service,
- SemanticDocument document,
- TExpressionSyntax expression,
- bool allOccurrences,
- bool isConstant,
- bool isLocal,
- bool isQueryLocal)
- : base(service, document, expression, allOccurrences, isConstant, isLocal, isQueryLocal)
- {
- }
-
- protected override async Task<Document> PostProcessChangesAsync(Document document, CancellationToken cancellationToken)
- {
- // TODO: Formatting conversation ? AllowDisjointSpanMerging not supported in nuget roslyn right now.
- var optionSet = document.Project.Solution.Workspace.Options;//.WithChangedOption(FormattingOptions.AllowDisjointSpanMerging, true);
- document = await Simplifier.ReduceAsync(document, Simplifier.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false);
- document = await Formatter.FormatAsync(document, Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false);
- document = await CaseCorrector.CaseCorrectAsync(document, CaseCorrector.Annotation, cancellationToken).ConfigureAwait(false);
- return document;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State.cs
deleted file mode 100644
index 49d2c8aa67..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State.cs
+++ /dev/null
@@ -1,271 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- private partial class State
- {
- public SemanticDocument Document { get; private set; }
- public TExpressionSyntax Expression { get; private set; }
-
- public bool InAttributeContext { get; private set; }
- public bool InBlockContext { get; private set; }
- public bool InConstructorInitializerContext { get; private set; }
- public bool InFieldContext { get; private set; }
- public bool InParameterContext { get; private set; }
- public bool InQueryContext { get; private set; }
- public bool InExpressionBodiedMemberContext { get; private set; }
-
- public bool IsConstant { get; private set; }
-
- private SemanticMap _semanticMap;
- private readonly TService _service;
-
- public State(TService service, SemanticDocument document)
- {
- _service = service;
- this.Document = document;
- }
-
- public static State Generate(
- TService service,
- SemanticDocument document,
- TextSpan textSpan,
- CancellationToken cancellationToken)
- {
- var state = new State(service, document);
- if (!state.TryInitialize(textSpan, cancellationToken))
- {
- return null;
- }
-
- return state;
- }
-
- private bool TryInitialize(
- TextSpan textSpan,
- CancellationToken cancellationToken)
- {
- if (cancellationToken.IsCancellationRequested)
- {
- return false;
- }
-
- var tree = this.Document.SyntaxTree;
-
- this.Expression = this.GetExpressionUnderSpan(tree, textSpan, cancellationToken);
- if (this.Expression == null)
- {
- return false;
- }
-
- var containingType = this.Expression.AncestorsAndSelf()
- .Select(n => this.Document.SemanticModel.GetDeclaredSymbol(n, cancellationToken))
- .OfType<INamedTypeSymbol>()
- .FirstOrDefault();
-
- containingType = containingType ?? this.Document.SemanticModel.Compilation.ScriptClass;
-
- if (containingType == null || containingType.TypeKind == TypeKind.Interface)
- {
- return false;
- }
-
- if (!CanIntroduceVariable(cancellationToken))
- {
- return false;
- }
-
- this.IsConstant = this.Document.SemanticModel.GetConstantValue(this.Expression, cancellationToken).HasValue;
-
- // Note: the ordering of these clauses are important. They go, generally, from
- // innermost to outermost order.
- if (IsInQueryContext(cancellationToken))
- {
- if (CanGenerateInto<TQueryExpressionSyntax>(cancellationToken))
- {
- this.InQueryContext = true;
- return true;
- }
-
- return false;
- }
-
- if (IsInConstructorInitializerContext(cancellationToken))
- {
- if (CanGenerateInto<TTypeDeclarationSyntax>(cancellationToken))
- {
- this.InConstructorInitializerContext = true;
- return true;
- }
-
- return false;
- }
-
- var enclosingBlocks = _service.GetContainingExecutableBlocks(this.Expression);
- if (enclosingBlocks.Any())
- {
- // If we're inside a block, then don't even try the other options (like field,
- // constructor initializer, etc.). This is desirable behavior. If we're in a
- // block in a field, then we're in a lambda, and we want to offer to generate
- // a local, and not a field.
- if (IsInBlockContext(cancellationToken))
- {
- this.InBlockContext = true;
- return true;
- }
-
- return false;
- }
-
- // The ordering of checks is important here. If we are inside a block within an Expression
- // bodied member, we should treat it as if we are in block context.
- // For example, in such a scenario we should generate inside the block, instead of rewriting
- // a concise expression bodied member to its equivalent that has a body with a block.
- // For this reason, block should precede expression bodied member check.
- if (_service.IsInExpressionBodiedMember(this.Expression))
- {
- if (CanGenerateInto<TTypeDeclarationSyntax>(cancellationToken))
- {
- this.InExpressionBodiedMemberContext = true;
- return true;
- }
-
- return false;
- }
-
- if (CanGenerateInto<TTypeDeclarationSyntax>(cancellationToken))
- {
- if (IsInParameterContext(cancellationToken))
- {
- this.InParameterContext = true;
- return true;
- }
- else if (IsInFieldContext(cancellationToken))
- {
- this.InFieldContext = true;
- return true;
- }
- else if (IsInAttributeContext(cancellationToken))
- {
- this.InAttributeContext = true;
- return true;
- }
- }
-
- return false;
- }
-
- public SemanticMap GetSemanticMap(CancellationToken cancellationToken)
- {
- _semanticMap = _semanticMap ?? this.Document.SemanticModel.GetSemanticMap(this.Expression, cancellationToken);
- return _semanticMap;
- }
-
- private TExpressionSyntax GetExpressionUnderSpan(SyntaxTree tree, TextSpan textSpan, CancellationToken cancellationToken)
- {
- var root = tree.GetRoot(cancellationToken);
- var startToken = root.FindToken(textSpan.Start);
- var stopToken = root.FindToken(textSpan.End);
-
- if (textSpan.End <= stopToken.SpanStart)
- {
- stopToken = stopToken.GetPreviousToken(includeSkipped: true);
- }
-
- if (startToken.RawKind == 0 || stopToken.RawKind == 0)
- {
- return null;
- }
-
- var containingExpressions1 = startToken.GetAncestors<TExpressionSyntax>().ToList();
- var containingExpressions2 = stopToken.GetAncestors<TExpressionSyntax>().ToList();
-
- var commonExpression = containingExpressions1.FirstOrDefault(containingExpressions2.Contains);
- if (commonExpression == null)
- {
- return null;
- }
-
- if (!(textSpan.Start >= commonExpression.FullSpan.Start &&
- textSpan.Start <= commonExpression.SpanStart))
- {
- return null;
- }
-
- if (!(textSpan.End >= commonExpression.Span.End &&
- textSpan.End <= commonExpression.FullSpan.End))
- {
- return null;
- }
-
- return commonExpression;
- }
-
- private bool CanIntroduceVariable(
- CancellationToken cancellationToken)
- {
- // Don't generate a variable for an expression that's the only expression in a
- // statement. Otherwise we'll end up with something like "v;" which is not
- // legal in C#.
- if (!_service.CanIntroduceVariableFor(this.Expression))
- {
- return false;
- }
-
- if (this.Expression is TTypeSyntax)
- {
- return false;
- }
-
- // Even though we're creating a variable, we still ask if we can be replaced with an
- // RValue and not an LValue. This is because introduction of a local adds a *new* LValue
- // location, and we want to ensure that any writes will still happen to the *original*
- // LValue location. i.e. if you have: "a[1] = b" then you don't want to change that to
- // "var c = a[1]; c = b", as that write is no longer happening into the right LValue.
- //
- // In essense, this says "i can be replaced with an expression as long as i'm not being
- // written to".
- return this.Document.SemanticModel.CanReplaceWithRValue(this.Expression, cancellationToken);
- }
-
- private bool CanGenerateInto<TSyntax>(CancellationToken cancellationToken)
- where TSyntax : SyntaxNode
- {
- if (this.Document.SemanticModel.Compilation.ScriptClass != null)
- {
- return true;
- }
-
- var syntax = this.Expression.GetAncestor<TSyntax>();
- return syntax != null && !syntax.OverlapsHiddenPosition(cancellationToken);
- }
-
- private bool IsInTypeDeclarationOrValidCompilationUnit()
- {
- if (this.Expression.GetAncestorOrThis<TTypeDeclarationSyntax>() != null)
- {
- return true;
- }
-
- // If we're interactive/script, we can generate into the compilation unit.
- if (this.Document.Document.SourceCodeKind != SourceCodeKind.Regular)
- {
- return true;
- }
-
- return false;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Attribute.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Attribute.cs
deleted file mode 100644
index 16057e7b78..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Attribute.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- private partial class State
- {
- private bool IsInAttributeContext(
- CancellationToken cancellationToken)
- {
- if (!_service.IsInAttributeArgumentInitializer(this.Expression))
- {
- return false;
- }
-
- // Have to make sure we're on or inside a type decl so that we have some place to
- // put the result.
- return IsInTypeDeclarationOrValidCompilationUnit();
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Block.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Block.cs
deleted file mode 100644
index 6c557e43ee..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Block.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- private partial class State
- {
- private bool IsInBlockContext(
- CancellationToken cancellationToken)
- {
- if (!this.IsInTypeDeclarationOrValidCompilationUnit())
- {
- return false;
- }
-
- // If refer to a query property, then we use the query context instead.
- var bindingMap = GetSemanticMap(cancellationToken);
- if (bindingMap.AllReferencedSymbols.Any(s => s is IRangeVariableSymbol))
- {
- return false;
- }
-
- var type = GetTypeSymbol(this.Document, this.Expression, cancellationToken, objectAsDefault: false);
- if (type == null || type.SpecialType == SpecialType.System_Void)
- {
- return false;
- }
-
- return true;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_ConstructorInitializer.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_ConstructorInitializer.cs
deleted file mode 100644
index d83304cfe1..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_ConstructorInitializer.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- private partial class State
- {
- private bool IsInConstructorInitializerContext(
- CancellationToken cancellationToken)
- {
- // Note: if we're in a lambda that has a block body, then we don't ever get here
- // because of the early check for IsInBlockContext.
- if (!_service.IsInConstructorInitializer(this.Expression))
- {
- return false;
- }
-
- var bindingMap = GetSemanticMap(cancellationToken);
-
- // Can't extract out if a parameter is referenced.
- if (bindingMap.AllReferencedSymbols.OfType<IParameterSymbol>().Any())
- {
- return false;
- }
-
- // Can't extract out an anonymous type used in a constructor initializer.
- var info = this.Document.SemanticModel.GetTypeInfo(this.Expression, cancellationToken);
- if (info.Type.ContainsAnonymousType())
- {
- return false;
- }
-
- return true;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Field.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Field.cs
deleted file mode 100644
index 5ca19e5b3b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Field.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- private partial class State
- {
- private bool IsInFieldContext(
- CancellationToken cancellationToken)
- {
- // Note: if we're in a lambda that has a block body, then we don't ever get here
- // because of the early check for IsInBlockContext.
- if (!_service.IsInFieldInitializer(this.Expression))
- {
- return false;
- }
-
- if (!IsInTypeDeclarationOrValidCompilationUnit())
- {
- return false;
- }
-
- // if the expression in the field references any parameters then that means it was
- // either an expression inside a lambda in the field, or it was an expression in a
- // query inside the field. Either of which cannot be extracted out further by this
- // fix.
- var bindingMap = GetSemanticMap(cancellationToken);
- if (bindingMap.AllReferencedSymbols.OfType<IParameterSymbol>().Any())
- {
- return false;
- }
-
- // Can't extract out an anonymous type used in a field initializer.
- var info = this.Document.SemanticModel.GetTypeInfo(this.Expression, cancellationToken);
- if (info.Type.ContainsAnonymousType())
- {
- return false;
- }
-
- return true;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Parameter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Parameter.cs
deleted file mode 100644
index c7564e8f43..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Parameter.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- private partial class State
- {
- private bool IsInParameterContext(
- CancellationToken cancellationToken)
- {
- if (!_service.IsInParameterInitializer(this.Expression))
- {
- return false;
- }
-
- // The default value for a parameter is a constant. So we always allow it unless it
- // happens to capture one of the method's type parameters.
- var bindingMap = this.GetSemanticMap(cancellationToken);
- if (bindingMap.AllReferencedSymbols.OfType<ITypeParameterSymbol> ()
- .Any (tp => tp.TypeParameterKind == TypeParameterKind.Method))
- {
- return false;
- }
-
- return true;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Query.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Query.cs
deleted file mode 100644
index 4612e91aa3..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.State_Query.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- {
- private partial class State
- {
- private bool IsInQueryContext(
- CancellationToken cancellationToken)
- {
- if (!_service.IsInNonFirstQueryClause(this.Expression))
- {
- return false;
- }
-
- var semanticMap = GetSemanticMap(cancellationToken);
- if (!semanticMap.AllReferencedSymbols.Any(s => s is IRangeVariableSymbol))
- {
- return false;
- }
-
- var info = this.Document.SemanticModel.GetTypeInfo(this.Expression, cancellationToken);
- if (info.Type == null || info.Type.SpecialType == SpecialType.System_Void)
- {
- return false;
- }
-
- return true;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.cs
deleted file mode 100644
index 105a11dd3c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/AbstractIntroduceVariableService.cs
+++ /dev/null
@@ -1,330 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using RefactoringEssentials;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.Ide.TypeSystem;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- abstract partial class AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- where TService : AbstractIntroduceVariableService<TService, TExpressionSyntax, TTypeSyntax, TTypeDeclarationSyntax, TQueryExpressionSyntax>
- where TExpressionSyntax : SyntaxNode
- where TTypeSyntax : TExpressionSyntax
- where TTypeDeclarationSyntax : SyntaxNode
- where TQueryExpressionSyntax : TExpressionSyntax
- {
- protected abstract bool IsInNonFirstQueryClause(TExpressionSyntax expression);
- protected abstract bool IsInFieldInitializer(TExpressionSyntax expression);
- protected abstract bool IsInParameterInitializer(TExpressionSyntax expression);
- protected abstract bool IsInConstructorInitializer(TExpressionSyntax expression);
- protected abstract bool IsInAttributeArgumentInitializer(TExpressionSyntax expression);
- protected abstract bool IsInExpressionBodiedMember(TExpressionSyntax expression);
-
- protected abstract IEnumerable<SyntaxNode> GetContainingExecutableBlocks(TExpressionSyntax expression);
- protected abstract IList<bool> GetInsertionIndices(TTypeDeclarationSyntax destination, CancellationToken cancellationToken);
-
- protected abstract bool CanIntroduceVariableFor(TExpressionSyntax expression);
- protected abstract bool CanReplace(TExpressionSyntax expression);
-
- protected abstract Task<Document> IntroduceQueryLocalAsync(SemanticDocument document, TExpressionSyntax expression, bool allOccurrences, CancellationToken cancellationToken);
- protected abstract Task<Document> IntroduceLocalAsync(SemanticDocument document, TExpressionSyntax expression, bool allOccurrences, bool isConstant, CancellationToken cancellationToken);
- protected abstract Task<Tuple<Document, SyntaxNode, int>> IntroduceFieldAsync(SemanticDocument document, TExpressionSyntax expression, bool allOccurrences, bool isConstant, CancellationToken cancellationToken);
-
- protected virtual bool BlockOverlapsHiddenPosition(SyntaxNode block, CancellationToken cancellationToken)
- {
- return block.OverlapsHiddenPosition(cancellationToken);
- }
-
- public async Task<IntroduceVariableResult> IntroduceVariableAsync(
- Document document,
- TextSpan textSpan,
- CancellationToken cancellationToken)
- {
- var semanticDocument = await SemanticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);
-
- var state = State.Generate((TService)this, semanticDocument, textSpan, cancellationToken);
- if (state == null)
- {
- return IntroduceVariableResult.Failure;
- }
-
- var actions = await CreateActionsAsync(state, cancellationToken).ConfigureAwait(false);
- if (actions.Count == 0)
- {
- return IntroduceVariableResult.Failure;
- }
-
- return new IntroduceVariableResult(new CodeRefactoring(null, actions));
- }
-
- private async Task<List<CodeAction>> CreateActionsAsync(State state, CancellationToken cancellationToken)
- {
- var actions = new List<CodeAction>();
-
- if (state.InQueryContext)
- {
- actions.Add(CreateAction(state, allOccurrences: false, isConstant: false, isLocal: false, isQueryLocal: true));
- actions.Add(CreateAction(state, allOccurrences: true, isConstant: false, isLocal: false, isQueryLocal: true));
- }
- else if (state.InParameterContext)
- {
- actions.Add(CreateAction(state, allOccurrences: false, isConstant: true, isLocal: false, isQueryLocal: false));
- actions.Add(CreateAction(state, allOccurrences: true, isConstant: true, isLocal: false, isQueryLocal: false));
- }
- else if (state.InFieldContext)
- {
- actions.Add(CreateAction(state, allOccurrences: false, isConstant: state.IsConstant, isLocal: false, isQueryLocal: false));
- actions.Add(CreateAction(state, allOccurrences: true, isConstant: state.IsConstant, isLocal: false, isQueryLocal: false));
- }
- else if (state.InConstructorInitializerContext)
- {
- actions.Add(CreateAction(state, allOccurrences: false, isConstant: state.IsConstant, isLocal: false, isQueryLocal: false));
- actions.Add(CreateAction(state, allOccurrences: true, isConstant: state.IsConstant, isLocal: false, isQueryLocal: false));
- }
- else if (state.InAttributeContext)
- {
- actions.Add(CreateAction(state, allOccurrences: false, isConstant: true, isLocal: false, isQueryLocal: false));
- actions.Add(CreateAction(state, allOccurrences: true, isConstant: true, isLocal: false, isQueryLocal: false));
- }
- else if (state.InBlockContext)
- {
- await CreateConstantFieldActionsAsync(state, actions, cancellationToken).ConfigureAwait(false);
-
- var blocks = this.GetContainingExecutableBlocks(state.Expression);
- var block = blocks.FirstOrDefault();
-
- if (!BlockOverlapsHiddenPosition(block, cancellationToken))
- {
- actions.Add(CreateAction(state, allOccurrences: false, isConstant: state.IsConstant, isLocal: true, isQueryLocal: false));
-
- if (blocks.All(b => !BlockOverlapsHiddenPosition(b, cancellationToken)))
- {
- actions.Add(CreateAction(state, allOccurrences: true, isConstant: state.IsConstant, isLocal: true, isQueryLocal: false));
- }
- }
- }
- else if (state.InExpressionBodiedMemberContext)
- {
- await CreateConstantFieldActionsAsync(state, actions, cancellationToken).ConfigureAwait(false);
- actions.Add(CreateAction(state, allOccurrences: false, isConstant: state.IsConstant, isLocal: true, isQueryLocal: false));
- actions.Add(CreateAction(state, allOccurrences: true, isConstant: state.IsConstant, isLocal: true, isQueryLocal: false));
- }
-
- return actions;
- }
-
- private async Task CreateConstantFieldActionsAsync(State state, List<CodeAction> actions, CancellationToken cancellationToken)
- {
- if (state.IsConstant &&
- !state.GetSemanticMap(cancellationToken).AllReferencedSymbols.OfType<ILocalSymbol>().Any() &&
- !state.GetSemanticMap(cancellationToken).AllReferencedSymbols.OfType<IParameterSymbol>().Any())
- {
- // If something is a constant, and it doesn't access any other locals constants,
- // then we prefer to offer to generate a constant field instead of a constant
- // local.
- var action1 = CreateAction(state, allOccurrences: false, isConstant: true, isLocal: false, isQueryLocal: false);
- if (await CanGenerateIntoContainerAsync(state, action1, cancellationToken).ConfigureAwait(false))
- {
- actions.Add(action1);
- }
-
- var action2 = CreateAction(state, allOccurrences: true, isConstant: true, isLocal: false, isQueryLocal: false);
- if (await CanGenerateIntoContainerAsync(state, action2, cancellationToken).ConfigureAwait(false))
- {
- actions.Add(action2);
- }
- }
- }
-
- private async Task<bool> CanGenerateIntoContainerAsync(State state, CodeAction action, CancellationToken cancellationToken)
- {
- var result = await this.IntroduceFieldAsync(
- state.Document, state.Expression,
- allOccurrences: false, isConstant: state.IsConstant, cancellationToken: cancellationToken).ConfigureAwait(false);
-
- SyntaxNode destination = result.Item2;
- int insertionIndex = result.Item3;
-
- if (!destination.OverlapsHiddenPosition(cancellationToken))
- {
- return true;
- }
-
- if (destination is TTypeDeclarationSyntax)
- {
- var insertionIndices = this.GetInsertionIndices((TTypeDeclarationSyntax)destination, cancellationToken);
- if (insertionIndices != null &&
- insertionIndices.Count > insertionIndex &&
- insertionIndices[insertionIndex])
- {
- return true;
- }
- }
-
- return false;
- }
-
- private CodeAction CreateAction(State state, bool allOccurrences, bool isConstant, bool isLocal, bool isQueryLocal)
- {
- if (allOccurrences)
- {
- return new IntroduceVariableAllOccurrenceCodeAction((TService)this, state.Document, state.Expression, allOccurrences, isConstant, isLocal, isQueryLocal);
- }
-
- return new IntroduceVariableCodeAction((TService)this, state.Document, state.Expression, allOccurrences, isConstant, isLocal, isQueryLocal);
- }
-
- protected static SyntaxToken GenerateUniqueFieldName(
- SemanticDocument document,
- TExpressionSyntax expression,
- bool isConstant,
- CancellationToken cancellationToken)
- {
- var semanticModel = document.SemanticModel;
- var baseName = semanticModel.GenerateNameForExpression(expression, isConstant);
-
- // A field can't conflict with any existing member names.
- var declaringType = semanticModel.GetEnclosingNamedType(expression.SpanStart, cancellationToken);
- var reservedNames = declaringType.GetMembers().Select(m => m.Name);
-
- return NameGenerator.EnsureUniqueness(baseName, reservedNames, true).ToIdentifierToken();
- }
-
- protected static SyntaxToken GenerateUniqueLocalName(
- SemanticDocument document,
- TExpressionSyntax expression,
- bool isConstant,
- CancellationToken cancellationToken)
- {
-
- var semanticModel = document.SemanticModel;
- var baseName = semanticModel.GenerateNameForExpression(expression, capitalize: isConstant);
- var reservedNames = semanticModel.LookupSymbols(expression.SpanStart).Select(s => s.Name);
-
- return NameGenerator.EnsureUniqueness(baseName, reservedNames, true).ToIdentifierToken();
- }
-
- protected ISet<TExpressionSyntax> FindMatches(
- SemanticDocument originalDocument,
- TExpressionSyntax expressionInOriginal,
- SemanticDocument currentDocument,
- SyntaxNode withinNodeInCurrent,
- bool allOccurrences,
- CancellationToken cancellationToken)
- {
- var originalSemanticModel = originalDocument.SemanticModel;
- var currentSemanticModel = currentDocument.SemanticModel;
-
- var matches = from nodeInCurrent in withinNodeInCurrent.DescendantNodesAndSelf().OfType<TExpressionSyntax>()
- where NodeMatchesExpression(originalSemanticModel, currentSemanticModel, expressionInOriginal, nodeInCurrent, allOccurrences, cancellationToken)
- select nodeInCurrent;
- return new HashSet<TExpressionSyntax>(matches.OfType<TExpressionSyntax>());
- }
-
- private bool NodeMatchesExpression(
- SemanticModel originalSemanticModel,
- SemanticModel currentSemanticModel,
- TExpressionSyntax expressionInOriginal,
- TExpressionSyntax nodeInCurrent,
- bool allOccurrences,
- CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
- if (nodeInCurrent == expressionInOriginal)
- {
- return true;
- }
- else
- {
- if (allOccurrences &&
- this.CanReplace(nodeInCurrent))
- {
- return SemanticEquivalence.AreSemanticallyEquivalent(
- originalSemanticModel, currentSemanticModel, expressionInOriginal, nodeInCurrent);
- }
- }
-
- return false;
- }
-
- protected TNode Rewrite<TNode>(
- SemanticDocument originalDocument,
- TExpressionSyntax expressionInOriginal,
- TExpressionSyntax variableName,
- SemanticDocument currentDocument,
- TNode withinNodeInCurrent,
- bool allOccurrences,
- CancellationToken cancellationToken)
- where TNode : SyntaxNode
- {
- var matches = FindMatches(originalDocument, expressionInOriginal, currentDocument, withinNodeInCurrent, allOccurrences, cancellationToken);
-
- // Parenthesize the variable, and go and replace anything we find with it.
- // NOTE: we do not want elastic trivia as we want to just replace the existing code
- // as is, while preserving the trivia there. We do not want to update it.
- var replacement = variableName.Parenthesize(includeElasticTrivia: false)
- .WithAdditionalAnnotations(Formatter.Annotation);
-
- return RewriteCore(withinNodeInCurrent, replacement, matches);
- }
-
- protected abstract TNode RewriteCore<TNode>(
- TNode node,
- SyntaxNode replacementNode,
- ISet<TExpressionSyntax> matches)
- where TNode : SyntaxNode;
-
- protected static ITypeSymbol GetTypeSymbol(
- SemanticDocument document,
- TExpressionSyntax expression,
- CancellationToken cancellationToken,
- bool objectAsDefault = true)
- {
- var semanticModel = document.SemanticModel;
- var typeInfo = semanticModel.GetTypeInfo(expression, cancellationToken);
-
- if (typeInfo.Type != null)
- {
- return typeInfo.Type;
- }
-
- if (typeInfo.ConvertedType != null)
- {
- return typeInfo.ConvertedType;
- }
-
- if (objectAsDefault)
- {
- return semanticModel.Compilation.GetSpecialType(SpecialType.System_Object);
- }
-
- return null;
- }
-
- protected static IEnumerable<IParameterSymbol> GetAnonymousMethodParameters(
- SemanticDocument document, TExpressionSyntax expression, CancellationToken cancellationToken)
- {
- var semanticModel = document.SemanticModel;
- var semanticMap = semanticModel.GetSemanticMap(expression, cancellationToken);
-
- var anonymousMethodParameters = semanticMap.AllReferencedSymbols
- .OfType<IParameterSymbol>()
- .Where(p => p.ContainingSymbol.IsAnonymousFunction());
- return anonymousMethodParameters;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService.Rewriter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService.Rewriter.cs
deleted file mode 100644
index f72aaf5a12..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService.Rewriter.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Simplification;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class CSharpIntroduceVariableService
- {
- private class Rewriter : CSharpSyntaxRewriter
- {
- private readonly SyntaxAnnotation _replacementAnnotation = new SyntaxAnnotation ();
- private readonly SyntaxNode _replacementNode;
- private readonly ISet<ExpressionSyntax> _matches;
-
- private Rewriter (SyntaxNode replacementNode, ISet<ExpressionSyntax> matches)
- {
- _replacementNode = replacementNode;
- _matches = matches;
- }
-
- public override SyntaxNode Visit (SyntaxNode node)
- {
- var expression = node as ExpressionSyntax;
- if (expression != null &&
- _matches.Contains (expression)) {
- return _replacementNode
- .WithLeadingTrivia (expression.GetLeadingTrivia ())
- .WithTrailingTrivia (expression.GetTrailingTrivia ())
- .WithAdditionalAnnotations (_replacementAnnotation);
- }
-
- return base.Visit (node);
- }
-
- public override SyntaxNode VisitParenthesizedExpression (ParenthesizedExpressionSyntax node)
- {
- var newNode = base.VisitParenthesizedExpression (node);
- if (node != newNode &&
- newNode.IsKind (SyntaxKind.ParenthesizedExpression)) {
- var parenthesizedExpression = (ParenthesizedExpressionSyntax)newNode;
- var innerExpression = parenthesizedExpression.OpenParenToken.GetNextToken ().Parent;
- if (innerExpression.HasAnnotation (_replacementAnnotation)) {
- return newNode.WithAdditionalAnnotations (Simplifier.Annotation);
- }
- }
-
- return newNode;
- }
-
- public static SyntaxNode Visit (SyntaxNode node, SyntaxNode replacementNode, ISet<ExpressionSyntax> matches)
- {
- return new Rewriter (replacementNode, matches).Visit ((SyntaxNode)node);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService.cs
deleted file mode 100644
index f049393d89..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
- {
- partial class CSharpIntroduceVariableService :
- AbstractIntroduceVariableService<CSharpIntroduceVariableService, ExpressionSyntax, TypeSyntax, TypeDeclarationSyntax, QueryExpressionSyntax>
- {
- protected override bool IsInNonFirstQueryClause(ExpressionSyntax expression)
- {
- var query = expression.GetAncestor<QueryExpressionSyntax>();
- if (query != null)
- {
- // Can't introduce for the first clause in a query.
- var fromClause = expression.GetAncestor<FromClauseSyntax>();
- if (fromClause == null || query.FromClause != fromClause)
- {
- return true;
- }
- }
-
- return false;
- }
-
- protected override bool IsInFieldInitializer(ExpressionSyntax expression)
- {
- return expression.GetAncestorOrThis<VariableDeclaratorSyntax>()
- .GetAncestorOrThis<FieldDeclarationSyntax>() != null;
- }
-
- protected override bool IsInParameterInitializer(ExpressionSyntax expression)
- {
- return expression.GetAncestorOrThis<EqualsValueClauseSyntax>().IsParentKind(SyntaxKind.Parameter);
- }
-
- protected override bool IsInConstructorInitializer(ExpressionSyntax expression)
- {
- return expression.GetAncestorOrThis<ConstructorInitializerSyntax>() != null;
- }
-
- protected override bool IsInExpressionBodiedMember(ExpressionSyntax expression)
- {
- // walk up until we find a nearest enclosing block or arrow expression.
- for (SyntaxNode node = expression; node != null; node = node.GetParent())
- {
- // If we are in an expression bodied member and if the expression has a block body, then,
- // act as if we're in a block context and not in an expression body context at all.
- if (node.IsKind(SyntaxKind.Block))
- {
- return false;
- }
- else if (node.IsKind(SyntaxKind.ArrowExpressionClause))
- {
- return true;
- }
- }
-
- return false;
- }
-
- protected override bool IsInAttributeArgumentInitializer(ExpressionSyntax expression)
- {
- // Don't call the base here. We want to let the user extract a constant if they've
- // said "Foo(a = 10)"
- var attributeArgument = expression.GetAncestorOrThis<AttributeArgumentSyntax>();
- if (attributeArgument != null)
- {
- // Can't extract an attribute initializer if it contains an array initializer of any
- // sort. Also, we can't extract if there's any typeof expression within it.
- if (!expression.DepthFirstTraversal().Any(n => n.RawKind == (int)SyntaxKind.ArrayCreationExpression) &&
- !expression.DepthFirstTraversal().Any(n => n.RawKind == (int)SyntaxKind.TypeOfExpression))
- {
- var attributeDecl = attributeArgument.GetAncestorOrThis<AttributeListSyntax>();
-
- // Also can't extract an attribute initializer if the attribute is a global one.
- if (!attributeDecl.IsParentKind(SyntaxKind.CompilationUnit))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- protected override bool CanIntroduceVariableFor(ExpressionSyntax expression)
- {
- if (expression.WalkUpParentheses().IsParentKind(SyntaxKind.ExpressionStatement))
- {
- return false;
- }
-
- return true;
- }
-
- protected override IEnumerable<SyntaxNode> GetContainingExecutableBlocks(ExpressionSyntax expression)
- {
- return expression.GetAncestorsOrThis<BlockSyntax>();
- }
-
- protected override IList<bool> GetInsertionIndices(TypeDeclarationSyntax destination, CancellationToken cancellationToken)
- {
- return destination.GetInsertionIndices(cancellationToken);
- }
-
- protected override bool CanReplace(ExpressionSyntax expression)
- {
- return true;
- }
-
- protected override TNode RewriteCore<TNode>(
- TNode node,
- SyntaxNode replacementNode,
- ISet<ExpressionSyntax> matches)
- {
- return (TNode)Rewriter.Visit(node, replacementNode, matches);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceField.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceField.cs
deleted file mode 100644
index 6e4c8a22a5..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceField.cs
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class CSharpIntroduceVariableService
- {
- protected override Task<Tuple<Document, SyntaxNode, int>> IntroduceFieldAsync(
- SemanticDocument document,
- ExpressionSyntax expression,
- bool allOccurrences,
- bool isConstant,
- CancellationToken cancellationToken)
- {
- var oldTypeDeclaration = expression.GetAncestorOrThis<TypeDeclarationSyntax>();
-
- var oldType = oldTypeDeclaration != null
- ? document.SemanticModel.GetDeclaredSymbol(oldTypeDeclaration, cancellationToken) as INamedTypeSymbol
- : document.SemanticModel.Compilation.ScriptClass;
- var newNameToken = (SyntaxToken)GenerateUniqueFieldName(document, expression, isConstant, cancellationToken);
-
- var newQualifiedName = oldTypeDeclaration != null
- ? SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.ParseName(oldType.ToDisplayString (Ambience.NameFormat)), SyntaxFactory.IdentifierName(newNameToken))
- : (ExpressionSyntax)SyntaxFactory.IdentifierName(newNameToken);
-
- newQualifiedName = newQualifiedName.WithAdditionalAnnotations(Simplifier.Annotation);
-
- var newFieldDeclaration = SyntaxFactory.FieldDeclaration(
- default(SyntaxList<AttributeListSyntax>),
- MakeFieldModifiers(isConstant, inScript: oldType.IsScriptClass),
- SyntaxFactory.VariableDeclaration(
- GetTypeSymbol(document, expression, cancellationToken).GenerateTypeSyntax(),
- SyntaxFactory.SingletonSeparatedList(
- SyntaxFactory.VariableDeclarator(
- newNameToken.WithAdditionalAnnotations(RenameAnnotation.Create()),
- null,
- SyntaxFactory.EqualsValueClause(expression))))).WithAdditionalAnnotations(Formatter.Annotation);
-
- if (oldTypeDeclaration != null)
- {
- var newTypeDeclaration = Rewrite(
- document, expression, newQualifiedName, document, oldTypeDeclaration, allOccurrences, cancellationToken);
-
- var insertionIndex = isConstant ?
- DetermineConstantInsertPosition(oldTypeDeclaration.Members, newTypeDeclaration.Members) :
- DetermineFieldInsertPosition(oldTypeDeclaration.Members, newTypeDeclaration.Members);
-
- var finalTypeDeclaration = InsertMember(newTypeDeclaration, newFieldDeclaration, insertionIndex);
-
- SyntaxNode destination = oldTypeDeclaration;
- var newRoot = document.Root.ReplaceNode(oldTypeDeclaration, finalTypeDeclaration);
- return Task.FromResult(Tuple.Create(document.Document.WithSyntaxRoot(newRoot), destination, insertionIndex));
- }
- else
- {
- var oldCompilationUnit = (CompilationUnitSyntax)document.Root;
- var newCompilationUnit = Rewrite(
- document, expression, newQualifiedName, document, oldCompilationUnit, allOccurrences, cancellationToken);
-
- var insertionIndex = isConstant ?
- DetermineConstantInsertPosition(oldCompilationUnit.Members, newCompilationUnit.Members) :
- DetermineFieldInsertPosition(oldCompilationUnit.Members, newCompilationUnit.Members);
-
- SyntaxNode destination = oldCompilationUnit;
- var newRoot = newCompilationUnit.WithMembers(newCompilationUnit.Members.Insert(insertionIndex, newFieldDeclaration));
- return Task.FromResult(Tuple.Create(document.Document.WithSyntaxRoot(newRoot), destination, insertionIndex));
- }
- }
-
- protected static int DetermineConstantInsertPosition(
- SyntaxList<MemberDeclarationSyntax> oldMembers,
- SyntaxList<MemberDeclarationSyntax> newMembers)
- {
- // 1) Place the constant after the last constant.
- //
- // 2) If there is no constant, place it before the first field
- //
- // 3) If the first change is before either of those, then place before the first
- // change
- //
- // 4) Otherwise, place it at the start.
- var index = 0;
- var lastConstantIndex = oldMembers.LastIndexOf(IsConstantField);
-
- if (lastConstantIndex >= 0)
- {
- index = lastConstantIndex + 1;
- }
- else
- {
- var firstFieldIndex = oldMembers.IndexOf(member => member is FieldDeclarationSyntax);
- if (firstFieldIndex >= 0)
- {
- index = firstFieldIndex;
- }
- }
-
- var firstChangeIndex = DetermineFirstChange(oldMembers, newMembers);
- if (firstChangeIndex >= 0)
- {
- index = Math.Min(index, firstChangeIndex);
- }
-
- return index;
- }
-
- protected static int DetermineFieldInsertPosition(
- SyntaxList<MemberDeclarationSyntax> oldMembers,
- SyntaxList<MemberDeclarationSyntax> newMembers)
- {
- // 1) Place the constant after the last field.
- //
- // 2) If there is no field, place it after the last constant
- //
- // 3) If the first change is before either of those, then place before the first
- // change
- //
- // 4) Otherwise, place it at the start.
- var index = 0;
- var lastFieldIndex = oldMembers.LastIndexOf(member => member is FieldDeclarationSyntax);
- if (lastFieldIndex >= 0)
- {
- index = lastFieldIndex + 1;
- }
- else
- {
- var lastConstantIndex = oldMembers.LastIndexOf(IsConstantField);
- if (lastConstantIndex >= 0)
- {
- index = lastConstantIndex + 1;
- }
- }
-
- var firstChangeIndex = DetermineFirstChange(oldMembers, newMembers);
- if (firstChangeIndex >= 0)
- {
- index = Math.Min(index, firstChangeIndex);
- }
-
- return index;
- }
-
- private static bool IsConstantField(MemberDeclarationSyntax member)
- {
- var field = member as FieldDeclarationSyntax;
- return field != null && field.Modifiers.Any(SyntaxKind.ConstKeyword);
- }
-
- protected static int DetermineFirstChange(SyntaxList<MemberDeclarationSyntax> oldMembers, SyntaxList<MemberDeclarationSyntax> newMembers)
- {
- for (int i = 0; i < oldMembers.Count; i++)
- {
- if (!SyntaxFactory.AreEquivalent(oldMembers[i], newMembers[i], topLevel: false))
- {
- return i;
- }
- }
-
- return -1;
- }
-
- protected static TypeDeclarationSyntax InsertMember(
- TypeDeclarationSyntax typeDeclaration,
- MemberDeclarationSyntax memberDeclaration,
- int index)
- {
- return typeDeclaration.WithMembers(
- typeDeclaration.Members.Insert(index, memberDeclaration));
- }
-
- private SyntaxTokenList MakeFieldModifiers(bool isConstant, bool inScript)
- {
- if (isConstant)
- {
- return SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.ConstKeyword));
- }
- else if (inScript)
- {
- return SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword));
- }
- else
- {
- return SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword));
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceLocal.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceLocal.cs
deleted file mode 100644
index 32798618b1..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceLocal.cs
+++ /dev/null
@@ -1,378 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class CSharpIntroduceVariableService
- {
- protected override Task<Document> IntroduceLocalAsync(
- SemanticDocument document,
- ExpressionSyntax expression,
- bool allOccurrences,
- bool isConstant,
- CancellationToken cancellationToken)
- {
- var options = document.Project.Solution.Workspace.Options;
-
- var newLocalNameToken = (SyntaxToken)GenerateUniqueLocalName(document, expression, isConstant, cancellationToken);
- var newLocalName = SyntaxFactory.IdentifierName(newLocalNameToken);
-
- var modifiers = isConstant
- ? SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.ConstKeyword))
- : default(SyntaxTokenList);
-
- var declarationStatement = SyntaxFactory.LocalDeclarationStatement(
- modifiers,
- SyntaxFactory.VariableDeclaration(
- this.GetTypeSyntax(document, expression, isConstant, options, cancellationToken),
- SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(
- newLocalNameToken.WithAdditionalAnnotations(RenameAnnotation.Create()),
- null,
- SyntaxFactory.EqualsValueClause(expression.WithoutTrailingTrivia().WithoutLeadingTrivia())))));
-
- var anonymousMethodParameters = GetAnonymousMethodParameters(document, expression, cancellationToken);
- var lambdas = anonymousMethodParameters.SelectMany(p => p.ContainingSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).AsEnumerable())
- .Where(n => n is ParenthesizedLambdaExpressionSyntax || n is SimpleLambdaExpressionSyntax)
- .ToSet();
-
- var parentLambda = GetParentLambda(expression, lambdas);
-
- if (parentLambda != null)
- {
- return Task.FromResult(IntroduceLocalDeclarationIntoLambda(
- document, expression, newLocalName, declarationStatement, parentLambda, allOccurrences, cancellationToken));
- }
- else if (IsInExpressionBodiedMember(expression))
- {
- return Task.FromResult(RewriteExpressionBodiedMemberAndIntroduceLocalDeclaration(
- document, expression, newLocalName, declarationStatement, allOccurrences, cancellationToken));
- }
- else
- {
- return IntroduceLocalDeclarationIntoBlockAsync(
- document, expression, newLocalName, declarationStatement, allOccurrences, cancellationToken);
- }
- }
-
- private Document IntroduceLocalDeclarationIntoLambda(
- SemanticDocument document,
- ExpressionSyntax expression,
- IdentifierNameSyntax newLocalName,
- LocalDeclarationStatementSyntax declarationStatement,
- SyntaxNode oldLambda,
- bool allOccurrences,
- CancellationToken cancellationToken)
- {
- var oldBody = oldLambda is ParenthesizedLambdaExpressionSyntax
- ? (ExpressionSyntax)((ParenthesizedLambdaExpressionSyntax)oldLambda).Body
- : (ExpressionSyntax)((SimpleLambdaExpressionSyntax)oldLambda).Body;
-
- var rewrittenBody = Rewrite(
- document, expression, newLocalName, document, oldBody, allOccurrences, cancellationToken);
-
- var delegateType = document.SemanticModel.GetTypeInfo(oldLambda, cancellationToken).ConvertedType as INamedTypeSymbol;
-
- var newBody = delegateType != null && delegateType.DelegateInvokeMethod != null && delegateType.DelegateInvokeMethod.ReturnsVoid
- ? SyntaxFactory.Block(declarationStatement)
- : SyntaxFactory.Block(declarationStatement, SyntaxFactory.ReturnStatement(rewrittenBody));
-
- newBody = newBody.WithAdditionalAnnotations(Formatter.Annotation);
-
- var newLambda = oldLambda is ParenthesizedLambdaExpressionSyntax
- ? ((ParenthesizedLambdaExpressionSyntax)oldLambda).WithBody(newBody)
- : (SyntaxNode)((SimpleLambdaExpressionSyntax)oldLambda).WithBody(newBody);
-
- var newRoot = document.Root.ReplaceNode(oldLambda, newLambda);
- return document.Document.WithSyntaxRoot(newRoot);
- }
-
- private SyntaxNode GetParentLambda(ExpressionSyntax expression, ISet<SyntaxNode> lambdas)
- {
- var current = expression;
- while (current != null)
- {
- if (lambdas.Contains(current.Parent))
- {
- return current.Parent;
- }
-
- current = current.Parent as ExpressionSyntax;
- }
-
- return null;
- }
-
- private TypeSyntax GetTypeSyntax(SemanticDocument document, ExpressionSyntax expression, bool isConstant, OptionSet options, CancellationToken cancellationToken)
- {
- var typeSymbol = GetTypeSymbol(document, expression, cancellationToken);
- if (typeSymbol.ContainsAnonymousType())
- {
- return SyntaxFactory.IdentifierName("var");
- }
-
- if (!isConstant && true /*options.GetOption(CSharpCodeStyleOptions.UseVarWhenDeclaringLocals) */&& CanUseVar(typeSymbol))
- {
- return SyntaxFactory.IdentifierName("var");
- }
-
- return typeSymbol.GenerateTypeSyntax();
- }
-
- private bool CanUseVar(ITypeSymbol typeSymbol)
- {
- return typeSymbol.TypeKind != TypeKind.Delegate && !typeSymbol.IsErrorType();
- }
-
- private static async Task<Tuple<SemanticDocument, ISet<ExpressionSyntax>>> ComplexifyParentingStatements(
- SemanticDocument semanticDocument,
- ISet<ExpressionSyntax> matches,
- CancellationToken cancellationToken)
- {
- // First, track the matches so that we can get back to them later.
- var newRoot = semanticDocument.Root.TrackNodes(matches);
- var newDocument = semanticDocument.Document.WithSyntaxRoot(newRoot);
- var newSemanticDocument = await SemanticDocument.CreateAsync(newDocument, cancellationToken).ConfigureAwait(false);
- var newMatches = newSemanticDocument.Root.GetCurrentNodes(matches.AsEnumerable()).ToSet();
-
- // Next, expand the topmost parenting expression of each match, being careful
- // not to expand the matches themselves.
- var topMostExpressions = newMatches
- .Select(m => m.AncestorsAndSelf().OfType<ExpressionSyntax>().Last())
- .Distinct();
-
- newRoot = await newSemanticDocument.Root
- .ReplaceNodesAsync(
- topMostExpressions,
- computeReplacementAsync: async (oldNode, newNode, ct) =>
- {
- return await Simplifier
- .ExpandAsync(
- oldNode,
- newSemanticDocument.Document,
- expandInsideNode: node =>
- {
- var expression = node as ExpressionSyntax;
- return expression == null
- || !newMatches.Contains(expression);
- },
- cancellationToken: ct)
- .ConfigureAwait(false);
- },
- cancellationToken: cancellationToken)
- .ConfigureAwait(false);
-
- newDocument = newSemanticDocument.Document.WithSyntaxRoot(newRoot);
- newSemanticDocument = await SemanticDocument.CreateAsync(newDocument, cancellationToken).ConfigureAwait(false);
- newMatches = newSemanticDocument.Root.GetCurrentNodes(matches.AsEnumerable()).ToSet();
-
- return Tuple.Create(newSemanticDocument, newMatches);
- }
-
- private Document RewriteExpressionBodiedMemberAndIntroduceLocalDeclaration(
- SemanticDocument document,
- ExpressionSyntax expression,
- NameSyntax newLocalName,
- LocalDeclarationStatementSyntax declarationStatement,
- bool allOccurrences,
- CancellationToken cancellationToken)
- {
- var oldBody = expression.GetAncestorOrThis<ArrowExpressionClauseSyntax>();
- var oldParentingNode = oldBody.Parent;
- var leadingTrivia = oldBody.GetLeadingTrivia()
- .AddRange(oldBody.ArrowToken.TrailingTrivia);
-
- var newStatement = Rewrite(document, expression, newLocalName, document, oldBody.Expression, allOccurrences, cancellationToken);
- var newBody = SyntaxFactory.Block(declarationStatement, SyntaxFactory.ReturnStatement(newStatement))
- .WithLeadingTrivia(leadingTrivia)
- .WithTrailingTrivia(oldBody.GetTrailingTrivia())
- .WithAdditionalAnnotations(Formatter.Annotation);
-
- SyntaxNode newParentingNode = null;
- if (oldParentingNode is BasePropertyDeclarationSyntax)
- {
- var getAccessor = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration, newBody);
- var accessorList = SyntaxFactory.AccessorList(SyntaxFactory.List(new[] { getAccessor }));
-
- newParentingNode = ((BasePropertyDeclarationSyntax)oldParentingNode).RemoveNode(oldBody, SyntaxRemoveOptions.KeepNoTrivia);
-
- if (newParentingNode.IsKind(SyntaxKind.PropertyDeclaration))
- {
- var propertyDeclaration = ((PropertyDeclarationSyntax)newParentingNode);
- newParentingNode = propertyDeclaration
- .WithAccessorList(accessorList)
- .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.None))
- .WithTrailingTrivia(propertyDeclaration.SemicolonToken.TrailingTrivia);
- }
- else if (newParentingNode.IsKind(SyntaxKind.IndexerDeclaration))
- {
- var indexerDeclaration = ((IndexerDeclarationSyntax)newParentingNode);
- newParentingNode = indexerDeclaration
- .WithAccessorList(accessorList)
- .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.None))
- .WithTrailingTrivia(indexerDeclaration.SemicolonToken.TrailingTrivia);
- }
- }
- else if (oldParentingNode is BaseMethodDeclarationSyntax)
- {
- newParentingNode = ((BaseMethodDeclarationSyntax)oldParentingNode)
- .RemoveNode(oldBody, SyntaxRemoveOptions.KeepNoTrivia)
- .WithBody(newBody);
-
- if (newParentingNode.IsKind(SyntaxKind.MethodDeclaration))
- {
- var methodDeclaration = ((MethodDeclarationSyntax)newParentingNode);
- newParentingNode = methodDeclaration
- .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.None))
- .WithTrailingTrivia(methodDeclaration.SemicolonToken.TrailingTrivia);
- }
- else if (newParentingNode.IsKind(SyntaxKind.OperatorDeclaration))
- {
- var operatorDeclaration = ((OperatorDeclarationSyntax)newParentingNode);
- newParentingNode = operatorDeclaration
- .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.None))
- .WithTrailingTrivia(operatorDeclaration.SemicolonToken.TrailingTrivia);
- }
- else if (newParentingNode.IsKind(SyntaxKind.ConversionOperatorDeclaration))
- {
- var conversionOperatorDeclaration = ((ConversionOperatorDeclarationSyntax)newParentingNode);
- newParentingNode = conversionOperatorDeclaration
- .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.None))
- .WithTrailingTrivia(conversionOperatorDeclaration.SemicolonToken.TrailingTrivia);
- }
- }
-
- var newRoot = document.Root.ReplaceNode(oldParentingNode, newParentingNode);
- return document.Document.WithSyntaxRoot(newRoot);
- }
-
- private async Task<Document> IntroduceLocalDeclarationIntoBlockAsync(
- SemanticDocument document,
- ExpressionSyntax expression,
- NameSyntax newLocalName,
- LocalDeclarationStatementSyntax declarationStatement,
- bool allOccurrences,
- CancellationToken cancellationToken)
- {
- declarationStatement = declarationStatement.WithAdditionalAnnotations(Formatter.Annotation);
-
- var oldOutermostBlock = expression.GetAncestorsOrThis<BlockSyntax>().LastOrDefault();
- var matches = FindMatches(document, expression, document, oldOutermostBlock, allOccurrences, cancellationToken);
- Debug.Assert(matches.Contains(expression));
-
- var complexified = await ComplexifyParentingStatements(document, matches, cancellationToken).ConfigureAwait(false);
- document = complexified.Item1;
- matches = complexified.Item2;
-
- // Our original expression should have been one of the matches, which were tracked as part
- // of complexification, so we can retrieve the latest version of the expression here.
- expression = document.Root.GetCurrentNodes(expression).First();
-
- var innermostStatements = new HashSet<StatementSyntax>(
- matches.Select(expr => expr.GetAncestorOrThis<StatementSyntax>()));
-
- if (innermostStatements.Count == 1)
- {
- // If there was only one match, or all the matches came from the same
- // statement, then we want to place the declaration right above that
- // statement. Note: we special case this because the statement we are going
- // to go above might not be in a block and we may have to generate it
- return IntroduceLocalForSingleOccurrenceIntoBlock(
- document, expression, newLocalName, declarationStatement, allOccurrences, cancellationToken);
- }
-
- var oldInnerMostCommonBlock = matches.FindInnermostCommonBlock();
- var allAffectedStatements = new HashSet<StatementSyntax>(matches.SelectMany(SyntaxNodeExtensions.GetAncestorsOrThis<StatementSyntax>));
- var firstStatementAffectedInBlock = oldInnerMostCommonBlock.Statements.First(allAffectedStatements.Contains);
-
- var firstStatementAffectedIndex = oldInnerMostCommonBlock.Statements.IndexOf(firstStatementAffectedInBlock);
-
- var newInnerMostBlock = Rewrite(
- document, expression, newLocalName, document, oldInnerMostCommonBlock, allOccurrences, cancellationToken);
-
- var statements = new List<StatementSyntax>();
- statements.AddRange(newInnerMostBlock.Statements.Take(firstStatementAffectedIndex));
- statements.Add(declarationStatement);
- statements.AddRange(newInnerMostBlock.Statements.Skip(firstStatementAffectedIndex));
-
- var finalInnerMostBlock = newInnerMostBlock.WithStatements(
- SyntaxFactory.List<StatementSyntax>(statements));
-
- var newRoot = document.Root.ReplaceNode(oldInnerMostCommonBlock, finalInnerMostBlock);
- return document.Document.WithSyntaxRoot(newRoot);
- }
-
- private Document IntroduceLocalForSingleOccurrenceIntoBlock(
- SemanticDocument document,
- ExpressionSyntax expression,
- NameSyntax localName,
- LocalDeclarationStatementSyntax localDeclaration,
- bool allOccurrences,
- CancellationToken cancellationToken)
- {
- var oldStatement = expression.GetAncestorOrThis<StatementSyntax>();
- var newStatement = Rewrite(
- document, expression, localName, document, oldStatement, allOccurrences, cancellationToken);
-
- if (oldStatement.IsParentKind(SyntaxKind.Block))
- {
- var oldBlock = oldStatement.Parent as BlockSyntax;
- var statementIndex = oldBlock.Statements.IndexOf(oldStatement);
-
- var newBlock = oldBlock.WithStatements(CreateNewStatementList(
- oldBlock.Statements, localDeclaration, newStatement, statementIndex));
-
- var newRoot = document.Root.ReplaceNode(oldBlock, newBlock);
- return document.Document.WithSyntaxRoot(newRoot);
- }
- else if (oldStatement.IsParentKind(SyntaxKind.SwitchSection))
- {
- var oldSwitchSection = oldStatement.Parent as SwitchSectionSyntax;
- var statementIndex = oldSwitchSection.Statements.IndexOf(oldStatement);
-
- var newSwitchSection = oldSwitchSection.WithStatements(CreateNewStatementList(
- oldSwitchSection.Statements, localDeclaration, newStatement, statementIndex));
-
- var newRoot = document.Root.ReplaceNode(oldSwitchSection, newSwitchSection);
- return document.Document.WithSyntaxRoot(newRoot);
- }
- else
- {
- // we need to introduce a block to put the original statement, along with
- // the statement we're generating
- var newBlock = SyntaxFactory.Block(localDeclaration, newStatement).WithAdditionalAnnotations(Formatter.Annotation);
-
- var newRoot = document.Root.ReplaceNode(oldStatement, newBlock);
- return document.Document.WithSyntaxRoot(newRoot);
- }
- }
-
- private static SyntaxList<StatementSyntax> CreateNewStatementList(
- SyntaxList<StatementSyntax> oldStatements,
- LocalDeclarationStatementSyntax localDeclaration,
- StatementSyntax newStatement,
- int statementIndex)
- {
- return oldStatements.Take(statementIndex)
- .Concat(localDeclaration.WithLeadingTrivia(oldStatements.Skip(statementIndex).First().GetLeadingTrivia()))
- .Concat(newStatement.WithoutLeadingTrivia())
- .Concat(oldStatements.Skip(statementIndex + 1))
- .ToSyntaxList();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceQueryLocal.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceQueryLocal.cs
deleted file mode 100644
index 79ff57296e..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/CSharpIntroduceVariableService_IntroduceQueryLocal.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- partial class CSharpIntroduceVariableService
- {
- private static bool IsAnyQueryClause(SyntaxNode node)
- {
- return node is QueryClauseSyntax || node is SelectOrGroupClauseSyntax;
- }
-
- protected override Task<Document> IntroduceQueryLocalAsync(
- SemanticDocument document, ExpressionSyntax expression, bool allOccurrences, CancellationToken cancellationToken)
- {
- var newLocalNameToken = (SyntaxToken)GenerateUniqueLocalName(document, expression, isConstant: false, cancellationToken: cancellationToken);
- var newLocalName = SyntaxFactory.IdentifierName(newLocalNameToken);
-
- var letClause = SyntaxFactory.LetClause(
- newLocalNameToken.WithAdditionalAnnotations(RenameAnnotation.Create()),
- expression).WithAdditionalAnnotations(Formatter.Annotation);
-
- var oldOutermostQuery = expression.GetAncestorsOrThis<QueryExpressionSyntax>().LastOrDefault();
- var matches = FindMatches(document, expression, document, oldOutermostQuery, allOccurrences, cancellationToken);
- var innermostClauses = new HashSet<SyntaxNode>(
- matches.Select(expr => expr.GetAncestorsOrThis<SyntaxNode>().First(IsAnyQueryClause)));
-
- if (innermostClauses.Count == 1)
- {
- // If there was only one match, or all the matches came from the same
- // statement, hten we want to place the declaration right above that
- // statement. Note: we special case this because the statement we are going
- // to go above might not be in a block and we may have to generate it
- return Task.FromResult(IntroduceQueryLocalForSingleOccurrence(
- document, expression, newLocalName, letClause, allOccurrences, cancellationToken));
- }
-
- var oldInnerMostCommonQuery = matches.FindInnermostCommonNode<QueryExpressionSyntax>();
- var newInnerMostQuery = Rewrite(
- document, expression, newLocalName, document, oldInnerMostCommonQuery, allOccurrences, cancellationToken);
-
- var allAffectedClauses = new HashSet<SyntaxNode>(matches.SelectMany(expr => expr.GetAncestorsOrThis<SyntaxNode>().Where(IsAnyQueryClause)));
-
- var oldClauses = oldInnerMostCommonQuery.GetAllClauses();
- var newClauses = newInnerMostQuery.GetAllClauses();
-
- var firstClauseAffectedInQuery = oldClauses.First(allAffectedClauses.Contains);
- var firstClauseAffectedIndex = oldClauses.IndexOf(firstClauseAffectedInQuery);
-
- var finalClauses = newClauses.Take(firstClauseAffectedIndex)
- .Concat(letClause)
- .Concat(newClauses.Skip(firstClauseAffectedIndex)).ToList();
-
- var finalQuery = newInnerMostQuery.WithAllClauses(finalClauses);
- var newRoot = document.Root.ReplaceNode(oldInnerMostCommonQuery, finalQuery);
-
- return Task.FromResult(document.Document.WithSyntaxRoot(newRoot));
- }
-
- private Document IntroduceQueryLocalForSingleOccurrence(
- SemanticDocument document,
- ExpressionSyntax expression,
- NameSyntax newLocalName,
- LetClauseSyntax letClause,
- bool allOccurrences,
- CancellationToken cancellationToken)
- {
- var oldClause = expression.GetAncestors<SyntaxNode>().First(IsAnyQueryClause);
- var newClause = Rewrite(
- document, expression, newLocalName, document, oldClause, allOccurrences, cancellationToken);
-
- var oldQuery = (QueryBodySyntax)oldClause.Parent;
- var newQuery = GetNewQuery(oldQuery, oldClause, newClause, letClause);
-
- var newRoot = document.Root.ReplaceNode(oldQuery, newQuery);
- return document.Document.WithSyntaxRoot(newRoot);
- }
-
- private static QueryBodySyntax GetNewQuery(
- QueryBodySyntax oldQuery,
- SyntaxNode oldClause,
- SyntaxNode newClause,
- LetClauseSyntax letClause)
- {
- var oldClauses = oldQuery.GetAllClauses();
- var oldClauseIndex = oldClauses.IndexOf(oldClause);
-
- var newClauses = oldClauses.Take(oldClauseIndex)
- .Concat(letClause)
- .Concat(newClause)
- .Concat(oldClauses.Skip(oldClauseIndex + 1)).ToList();
- return oldQuery.WithAllClauses(newClauses);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/IntroduceVariableResult.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/IntroduceVariableResult.cs
deleted file mode 100644
index 3277daf9fe..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/IntroduceVariable/IntroduceVariableResult.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using RefactoringEssentials;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.IntroduceVariable
-{
- class IntroduceVariableResult
- {
- public static readonly IntroduceVariableResult Failure = new IntroduceVariableResult(null);
-
- private readonly CodeRefactoring _codeRefactoring;
-
- public IntroduceVariableResult(CodeRefactoring codeRefactoring)
- {
- _codeRefactoring = codeRefactoring;
- }
-
- public bool ContainsChanges
- {
- get
- {
- return _codeRefactoring != null;
- }
- }
-
- public CodeRefactoring GetCodeRefactoring(CancellationToken cancellationToken)
- {
- return _codeRefactoring;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/OrganizeImports/CSharpOrganizeImportsService.Rewriter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/OrganizeImports/CSharpOrganizeImportsService.Rewriter.cs
deleted file mode 100644
index 003760e4bb..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/OrganizeImports/CSharpOrganizeImportsService.Rewriter.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.OrganizeImports
-{
- partial class CSharpOrganizeImportsService
- {
- private class Rewriter : CSharpSyntaxRewriter
- {
- private readonly bool _placeSystemNamespaceFirst;
- public readonly IList<TextChange> TextChanges = new List<TextChange>();
-
- public Rewriter(bool placeSystemNamespaceFirst)
- {
- _placeSystemNamespaceFirst = placeSystemNamespaceFirst;
- }
-
- public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
- {
- node = (CompilationUnitSyntax)base.VisitCompilationUnit(node);
-
- SyntaxList<ExternAliasDirectiveSyntax> organizedExternAliasList;
- SyntaxList<UsingDirectiveSyntax> organizedUsingList;
- UsingsAndExternAliasesOrganizer.Organize(
- node.Externs, node.Usings, _placeSystemNamespaceFirst,
- out organizedExternAliasList, out organizedUsingList);
-
- var result = node.WithExterns(organizedExternAliasList).WithUsings(organizedUsingList);
- if (node != result)
- {
- AddTextChange(node.Externs, organizedExternAliasList);
- AddTextChange(node.Usings, organizedUsingList);
- }
-
- return result;
- }
-
- public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
- {
- node = (NamespaceDeclarationSyntax)base.VisitNamespaceDeclaration(node);
-
- SyntaxList<ExternAliasDirectiveSyntax> organizedExternAliasList;
- SyntaxList<UsingDirectiveSyntax> organizedUsingList;
- UsingsAndExternAliasesOrganizer.Organize(
- node.Externs, node.Usings, _placeSystemNamespaceFirst,
- out organizedExternAliasList, out organizedUsingList);
-
- var result = node.WithExterns(organizedExternAliasList).WithUsings(organizedUsingList);
- if (node != result)
- {
- AddTextChange(node.Externs, organizedExternAliasList);
- AddTextChange(node.Usings, organizedUsingList);
- }
-
- return result;
- }
-
- private void AddTextChange<TSyntax>(SyntaxList<TSyntax> list, SyntaxList<TSyntax> organizedList)
- where TSyntax : SyntaxNode
- {
- if (list.Count > 0)
- {
- this.TextChanges.Add(new TextChange(GetTextSpan(list), GetNewText(organizedList)));
- }
- }
-
- private string GetNewText<TSyntax>(SyntaxList<TSyntax> organizedList)
- where TSyntax : SyntaxNode
- {
- return string.Join(string.Empty, organizedList.Select(t => t.ToFullString()));
- }
-
- private TextSpan GetTextSpan<TSyntax>(SyntaxList<TSyntax> list)
- where TSyntax : SyntaxNode
- {
- return TextSpan.FromBounds(list.First().FullSpan.Start, list.Last().FullSpan.End);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/OrganizeImports/CSharpOrganizeImportsService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/OrganizeImports/CSharpOrganizeImportsService.cs
deleted file mode 100644
index 67542be953..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/OrganizeImports/CSharpOrganizeImportsService.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Composition;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.OrganizeImports
-{
- partial class CSharpOrganizeImportsService
- {
- public async Task<Document> OrganizeImportsAsync(Document document, bool placeSystemNamespaceFirst, CancellationToken cancellationToken)
- {
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var rewriter = new Rewriter(placeSystemNamespaceFirst);
- var newRoot = rewriter.Visit(root);
-
- return document.WithSyntaxRoot(newRoot);
- }
-
- public string OrganizeImportsDisplayStringWithAccelerator
- {
- get
- {
- return Resources.OrganizeUsingsWithAccelerator;
- }
- }
-
- public string SortImportsDisplayStringWithAccelerator
- {
- get
- {
- return Resources.SortUsingsWithAccelerator;
- }
- }
-
- public string RemoveUnusedImportsDisplayStringWithAccelerator
- {
- get
- {
- return Resources.RemoveUnnecessaryUsingsWithAccelerator;
- }
- }
-
- public string SortAndRemoveUnusedImportsDisplayStringWithAccelerator
- {
- get
- {
- return Resources.RemoveAndSortUsingsWithAccelerator;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ParameterHinting/ParameterHintingEngine.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ParameterHinting/ParameterHintingEngine.cs
index 716eebd13d..eaf91272a6 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ParameterHinting/ParameterHintingEngine.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ParameterHinting/ParameterHintingEngine.cs
@@ -26,14 +26,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.CodeAnalysis;
using System.Threading;
-using System.CodeDom;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
using System.Threading.Tasks;
-using MonoDevelop.Ide.TypeSystem;
-using System.Security.Cryptography;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.Shared.Utilities;
namespace ICSharpCode.NRefactory6.CSharp.Completion
{
@@ -161,7 +161,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
filterMethod.Add (method.OverriddenMethod);
if (filterMethod.Contains (method))
continue;
- if (addedMethods.Any (added => SignatureComparer.HaveSameSignature (method, added, true)))
+ if (addedMethods.Any (added => SignatureComparer.Instance.HaveSameSignature (method, added, true)))
continue;
if (method.IsAccessibleWithin (within)) {
if (info.Symbol != null) {
@@ -186,9 +186,9 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
{
var usedNamespaces = new List<string> ();
foreach (var un in semanticModel.GetUsingNamespacesInScope (node)) {
- usedNamespaces.Add (un.GetFullName ());
+ usedNamespaces.Add (MonoDevelop.Ide.TypeSystem.NR5CompatibiltyExtensions.GetFullName (un));
}
- var enclosingNamespaceName = semanticModel.GetEnclosingNamespace (node.SpanStart, cancellationToken).GetFullName ();
+ var enclosingNamespaceName = MonoDevelop.Ide.TypeSystem.NR5CompatibiltyExtensions.GetFullName (semanticModel.GetEnclosingNamespace (node.SpanStart, cancellationToken));
var stack = new Stack<INamespaceOrTypeSymbol> ();
stack.Push (semanticModel.Compilation.GlobalNamespace);
@@ -201,7 +201,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
if (currentNs != null) {
foreach (var member in currentNs.GetNamespaceMembers ()) {
- var currentNsName = member.GetFullName ();
+ var currentNsName = MonoDevelop.Ide.TypeSystem.NR5CompatibiltyExtensions.GetFullName (member);
if (usedNamespaces.Any (u => u.StartsWith (currentNsName, StringComparison.Ordinal)) ||
enclosingNamespaceName == currentNsName ||
(enclosingNamespaceName.StartsWith (currentNsName, StringComparison.Ordinal) &&
@@ -249,7 +249,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
foreach (var cand in semanticModel.LookupSymbols (node.SpanStart).OfType<INamedTypeSymbol> ()) {
if (cand.TypeParameters.Length == 0)
continue;
- if (cand.Name == typeName || cand.GetFullName () == typeName)
+ if (cand.Name == typeName || MonoDevelop.Ide.TypeSystem.NR5CompatibiltyExtensions.GetFullName (cand) == typeName)
result.AddData(factory.CreateTypeParameterDataProvider(cand));
}
@@ -316,7 +316,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion
var addedProperties = new List<IPropertySymbol> ();
for (;type != null; type = type.BaseType) {
foreach (var indexer in type.GetMembers ().OfType<IPropertySymbol> ().Where (p => p.IsIndexer)) {
- if (addedProperties.Any (added => SignatureComparer.HaveSameSignature (indexer, added, true)))
+ if (addedProperties.Any (added => SignatureComparer.Instance.HaveSameSignature (indexer, added, true)))
continue;
if (indexer.IsAccessibleWithin (within)) {
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.Rewriter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.Rewriter.cs
deleted file mode 100644
index d46886d49f..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.Rewriter.cs
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.RemoveUnnecessaryImports
-{
- partial class CSharpRemoveUnnecessaryImportsService
- {
- private class Rewriter : CSharpSyntaxRewriter
- {
- private readonly ISet<UsingDirectiveSyntax> _unnecessaryUsingsDoNotAccessDirectly;
- private readonly CancellationToken _cancellationToken;
-
- public Rewriter(ISet<UsingDirectiveSyntax> unnecessaryUsings, CancellationToken cancellationToken)
- : base(visitIntoStructuredTrivia: true)
- {
- _unnecessaryUsingsDoNotAccessDirectly = unnecessaryUsings;
- _cancellationToken = cancellationToken;
- }
-
- public override SyntaxNode DefaultVisit(SyntaxNode node)
- {
- _cancellationToken.ThrowIfCancellationRequested();
- return base.DefaultVisit(node);
- }
-
- private void ProcessUsings(
- SyntaxList<UsingDirectiveSyntax> usings,
- ISet<UsingDirectiveSyntax> usingsToRemove,
- out SyntaxList<UsingDirectiveSyntax> finalUsings,
- out SyntaxTriviaList finalTrivia)
- {
- var currentUsings = new List<UsingDirectiveSyntax>(usings);
-
- finalTrivia = default(SyntaxTriviaList);
- for (int i = 0; i < usings.Count; i++)
- {
- if (usingsToRemove.Contains(usings[i]))
- {
- var currentUsing = currentUsings[i];
- currentUsings[i] = null;
-
- var leadingTrivia = currentUsing.GetLeadingTrivia();
- if (leadingTrivia.Any(t => t.Kind() != SyntaxKind.EndOfLineTrivia && t.Kind() != SyntaxKind.WhitespaceTrivia))
- {
- // This using had trivia we want to preserve. If we're the last
- // directive, then copy this trivia out so that our caller can place
- // it on the next token. If there is any directive following us,
- // then place it on that.
- if (i < usings.Count - 1)
- {
- currentUsings[i + 1] = currentUsings[i + 1].WithPrependedLeadingTrivia(leadingTrivia);
- }
- else
- {
- finalTrivia = leadingTrivia;
- }
- }
- }
- }
-
- finalUsings = currentUsings.WhereNotNull().ToSyntaxList();
- }
-
- private ISet<UsingDirectiveSyntax> GetUsingsToRemove(
- SyntaxList<UsingDirectiveSyntax> oldUsings,
- SyntaxList<UsingDirectiveSyntax> newUsings)
- {
- var result = new HashSet<UsingDirectiveSyntax>();
- for (int i = 0; i < oldUsings.Count; i++)
- {
- if (_unnecessaryUsingsDoNotAccessDirectly.Contains(oldUsings[i]))
- {
- result.Add(newUsings[i]);
- }
- }
-
- return result;
- }
-
- public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
- {
- var compilationUnit = (CompilationUnitSyntax)base.VisitCompilationUnit(node);
-
- var usingsToRemove = GetUsingsToRemove(node.Usings, compilationUnit.Usings);
- if (usingsToRemove.Count == 0)
- {
- return compilationUnit;
- }
-
- SyntaxList<UsingDirectiveSyntax> finalUsings;
- SyntaxTriviaList finalTrivia;
- ProcessUsings(compilationUnit.Usings, usingsToRemove, out finalUsings, out finalTrivia);
-
- // If there was any left over trivia, then attach it to the next token that
- // follows the usings.
- if (finalTrivia.Count > 0)
- {
- var nextToken = compilationUnit.Usings.Last().GetLastToken().GetNextToken();
- compilationUnit = compilationUnit.ReplaceToken(nextToken, nextToken.WithPrependedLeadingTrivia(finalTrivia));
- }
-
- var resultCompilationUnit = compilationUnit.WithUsings(finalUsings);
- if (finalUsings.Count == 0 &&
- resultCompilationUnit.Externs.Count == 0 &&
- resultCompilationUnit.Members.Count >= 1)
- {
- // We've removed all the usings and now the first thing in the namespace is a
- // type. In this case, remove any newlines preceding the type.
- var firstToken = resultCompilationUnit.GetFirstToken();
- var newFirstToken = StripNewLines(firstToken);
- resultCompilationUnit = resultCompilationUnit.ReplaceToken(firstToken, newFirstToken);
- }
-
- return resultCompilationUnit;
- }
-
- public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
- {
- var namespaceDeclaration = (NamespaceDeclarationSyntax)base.VisitNamespaceDeclaration(node);
- var usingsToRemove = GetUsingsToRemove(node.Usings, namespaceDeclaration.Usings);
- if (usingsToRemove.Count == 0)
- {
- return namespaceDeclaration;
- }
-
- SyntaxList<UsingDirectiveSyntax> finalUsings;
- SyntaxTriviaList finalTrivia;
- ProcessUsings(namespaceDeclaration.Usings, usingsToRemove, out finalUsings, out finalTrivia);
-
- // If there was any left over trivia, then attach it to the next token that
- // follows the usings.
- if (finalTrivia.Count > 0)
- {
- var nextToken = namespaceDeclaration.Usings.Last().GetLastToken().GetNextToken();
- namespaceDeclaration = namespaceDeclaration.ReplaceToken(nextToken, nextToken.WithPrependedLeadingTrivia(finalTrivia));
- }
-
- var resultNamespace = namespaceDeclaration.WithUsings(finalUsings);
- if (finalUsings.Count == 0 &&
- resultNamespace.Externs.Count == 0 &&
- resultNamespace.Members.Count >= 1)
- {
- // We've removed all the usings and now the first thing in the namespace is a
- // type. In this case, remove any newlines preceding the type.
- var firstToken = resultNamespace.Members.First().GetFirstToken();
- var newFirstToken = StripNewLines(firstToken);
- resultNamespace = resultNamespace.ReplaceToken(firstToken, newFirstToken);
- }
-
- return resultNamespace;
- }
-
- private static SyntaxToken StripNewLines(SyntaxToken firstToken)
- {
- return firstToken.WithLeadingTrivia(firstToken.LeadingTrivia.SkipWhile(t => t.Kind() == SyntaxKind.EndOfLineTrivia));
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs
deleted file mode 100644
index fd5496194c..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Internal.Log;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp.Features.RemoveUnnecessaryImports
-{
- partial class CSharpRemoveUnnecessaryImportsService
- {
- public static IEnumerable<SyntaxNode> GetUnnecessaryImports(SemanticModel semanticModel, SyntaxNode root, CancellationToken cancellationToken)
- {
- var diagnostics = semanticModel.GetDiagnostics(cancellationToken: cancellationToken);
- if (!diagnostics.Any())
- {
- return null;
- }
-
- var unnecessaryImports = new HashSet<UsingDirectiveSyntax>();
-
- foreach (var diagnostic in diagnostics)
- {
- if (diagnostic.Id == "CS8019")
- {
- var node = root.FindNode(diagnostic.Location.SourceSpan) as UsingDirectiveSyntax;
-
- if (node != null)
- {
- unnecessaryImports.Add(node);
- }
- }
- }
-
- if (cancellationToken.IsCancellationRequested || !unnecessaryImports.Any())
- {
- return null;
- }
-
- return unnecessaryImports;
- }
-
- public Document RemoveUnnecessaryImports(Document document, SemanticModel model, SyntaxNode root, CancellationToken cancellationToken)
- {
- var unnecessaryImports = GetUnnecessaryImports(model, root, cancellationToken) as ISet<UsingDirectiveSyntax>;
- if (unnecessaryImports == null)
- {
- return document;
- }
-
- var oldRoot = (CompilationUnitSyntax)root;
- if (unnecessaryImports.Any(import => oldRoot.OverlapsHiddenPosition(cancellationToken)))
- {
- return document;
- }
-
- var newRoot = (CompilationUnitSyntax)new Rewriter(unnecessaryImports, cancellationToken).Visit(oldRoot);
- if (cancellationToken.IsCancellationRequested)
- {
- return null;
- }
-
- return document.WithSyntaxRoot(FormatResult(document, newRoot, cancellationToken));
- }
-
- private SyntaxNode FormatResult(Document document, CompilationUnitSyntax newRoot, CancellationToken cancellationToken)
- {
- var spans = new List<TextSpan>();
- AddFormattingSpans(newRoot, spans, cancellationToken);
- return Formatter.Format(newRoot, spans, document.Project.Solution.Workspace, document.Project.Solution.Workspace.Options, cancellationToken: cancellationToken);
- }
-
- private void AddFormattingSpans(
- CompilationUnitSyntax compilationUnit,
- List<TextSpan> spans,
- CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
- spans.Add(TextSpan.FromBounds(0, GetEndPosition(compilationUnit, compilationUnit.Members)));
-
- foreach (var @namespace in compilationUnit.Members.OfType<NamespaceDeclarationSyntax>())
- {
- AddFormattingSpans(@namespace, spans, cancellationToken);
- }
- }
-
- private void AddFormattingSpans(
- NamespaceDeclarationSyntax namespaceMember,
- List<TextSpan> spans,
- CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
- spans.Add(TextSpan.FromBounds(namespaceMember.SpanStart, GetEndPosition(namespaceMember, namespaceMember.Members)));
-
- foreach (var @namespace in namespaceMember.Members.OfType<NamespaceDeclarationSyntax>())
- {
- AddFormattingSpans(@namespace, spans, cancellationToken);
- }
- }
-
- private int GetEndPosition(SyntaxNode container, SyntaxList<MemberDeclarationSyntax> list)
- {
- return list.Count > 0 ? list[0].SpanStart : container.Span.End;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
index 783c205840..e2e1b1ba30 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
@@ -574,7 +574,7 @@ namespace MonoDevelop.CSharp.Formatting
if (!skipFormatting && service.SupportsFormattingOnTypedCharacter (document, descriptor.KeyChar)) {
var caretPosition = Editor.CaretOffset;
var token = CSharpEditorFormattingService.GetTokenBeforeTheCaretAsync (document, caretPosition, default(CancellationToken)).Result;
- if (token.IsMissing || !service.ValidSingleOrMultiCharactersTokenKind (descriptor.KeyChar, token.Kind ()) || token.IsKind (SyntaxKind.EndOfFileToken, SyntaxKind.None))
+ if (token.IsMissing || !service.ValidSingleOrMultiCharactersTokenKind (descriptor.KeyChar, token.Kind ()) || token.IsKind (SyntaxKind.EndOfFileToken) || token.IsKind (SyntaxKind.None))
return;
if (CSharpEditorFormattingService.TokenShouldNotFormatOnTypeChar (token))
return;
@@ -606,7 +606,7 @@ namespace MonoDevelop.CSharp.Formatting
var token = await CSharpEditorFormattingService.GetTokenBeforeTheCaretAsync (document, caretPosition, default (CancellationToken)).ConfigureAwait (false);
if (token.IsMissing || !token.Parent.IsKind (SyntaxKind.ElseDirectiveTrivia))
return;
- var tokenRange = FormattingRangeHelper.FindAppropriateRange (token);
+ var tokenRange = Microsoft.CodeAnalysis.CSharp.Utilities.FormattingRangeHelper.FindAppropriateRange (token);
if (tokenRange == null || !tokenRange.HasValue || tokenRange.Value.Item1.Equals (tokenRange.Value.Item2))
return;
@@ -632,7 +632,7 @@ namespace MonoDevelop.CSharp.Formatting
// Check to see if the token is ')' and also the parent is a using statement. If not, bail
if (CSharpEditorFormattingService.TokenShouldNotFormatOnReturn (token))
return;
- var tokenRange = FormattingRangeHelper.FindAppropriateRange (token);
+ var tokenRange = Microsoft.CodeAnalysis.CSharp.Utilities.FormattingRangeHelper.FindAppropriateRange (token);
if (tokenRange == null || !tokenRange.HasValue || tokenRange.Value.Item1.Equals (tokenRange.Value.Item2))
return;
var value = tokenRange.Value;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs
index eade293a33..bb0419201f 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs
@@ -36,6 +36,7 @@ using MonoDevelop.Core;
using MonoDevelop.Ide.Editor;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Ide.Gui.Content;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Options;
@@ -83,7 +84,7 @@ namespace MonoDevelop.CSharp.Formatting
if (formatLastStatementOnly) {
var root = syntaxTree.GetRoot ();
var token = root.FindToken (endOffset);
- var tokens = ICSharpCode.NRefactory6.CSharp.FormattingRangeHelper.FindAppropriateRange (token);
+ var tokens = Microsoft.CodeAnalysis.CSharp.Utilities.FormattingRangeHelper.FindAppropriateRange (token);
if (tokens.HasValue) {
span = new TextSpan (tokens.Value.Item1.SpanStart, tokens.Value.Item2.Span.End - tokens.Value.Item1.SpanStart);
} else {
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs
index eddc6ce8e7..d45dca9602 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs
@@ -23,27 +23,30 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
using System.Collections.Generic;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.FindInFiles;
+using System.Collections.Immutable;
+using System.Linq;
using System.Threading;
-using MonoDevelop.SourceEditor;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.Ide;
-using MonoDevelop.Refactoring;
-using Microsoft.CodeAnalysis.FindSymbols;
-using MonoDevelop.Ide.TypeSystem;
using System.Threading.Tasks;
-using System.Collections.Immutable;
-using MonoDevelop.Ide.Editor;
-using MonoDevelop.Ide.Editor.Extension;
+
+using ICSharpCode.NRefactory6.CSharp;
+
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Linq;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.Editor.CSharp.KeywordHighlighting.KeywordHighlighters;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.Editor.Implementation.Highlighting;
+using Microsoft.CodeAnalysis.FindSymbols;
+using Roslyn.Utilities;
+
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using MonoDevelop.Ide.Editor.Extension;
+using MonoDevelop.Ide.FindInFiles;
+using MonoDevelop.Ide.TypeSystem;
+using MonoDevelop.Refactoring;
namespace MonoDevelop.CSharp.Highlighting
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/AbstractAsyncHighlighter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/AbstractAsyncHighlighter.cs
index 83b9f20e7c..45fb68939d 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/AbstractAsyncHighlighter.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/AbstractAsyncHighlighter.cs
@@ -49,10 +49,9 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.KeywordHighlighting.KeywordHighli
}
});
- // Highlight await keywords
- node.TypeSwitch(
- (AwaitExpressionSyntax awaitExpression) =>
- {
+ // Highlight await keywords
+ var awaitExpression = node as AwaitExpressionSyntax;
+ {
// Note if there is already a highlight for the previous token, merge it
// with this span. That way, we highlight nested awaits with a single span.
var handled = false;
@@ -73,7 +72,7 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.KeywordHighlighting.KeywordHighli
{
spans.Add(awaitToken.Span);
}
- });
+ };
foreach (var child in node.ChildNodes())
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ConditionalPreprocessorHighlighter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ConditionalPreprocessorHighlighter.cs
index 48cb19a19d..eb3695b9c7 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ConditionalPreprocessorHighlighter.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ConditionalPreprocessorHighlighter.cs
@@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Threading;
-using ICSharpCode.NRefactory6.CSharp;
using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editor.Implementation.Highlighting;
using Microsoft.CodeAnalysis.Text;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ReturnStatementHighlighter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ReturnStatementHighlighter.cs
index d18660ebe5..32d42b280f 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ReturnStatementHighlighter.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/ReturnStatementHighlighter.cs
@@ -3,9 +3,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
-using ICSharpCode.NRefactory6;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editor.Implementation.Highlighting;
@@ -15,49 +12,43 @@ using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Editor.CSharp.KeywordHighlighting.KeywordHighlighters
{
- internal class ReturnStatementHighlighter : AbstractKeywordHighlighter<ReturnStatementSyntax>
- {
- protected override IEnumerable<TextSpan> GetHighlights(
- ReturnStatementSyntax returnStatement, CancellationToken cancellationToken)
- {
- var parent = returnStatement
- .GetAncestorsOrThis<SyntaxNode>()
- .FirstOrDefault(n => n.IsReturnableConstruct());
+ internal class ReturnStatementHighlighter : AbstractKeywordHighlighter<ReturnStatementSyntax>
+ {
+ protected override IEnumerable<TextSpan> GetHighlights (
+ ReturnStatementSyntax returnStatement, CancellationToken cancellationToken)
+ {
+ var parent = returnStatement
+ .GetAncestorsOrThis<SyntaxNode> ()
+ .FirstOrDefault (n => n.IsReturnableConstruct ());
- if (parent == null)
- {
- return SpecializedCollections.EmptyEnumerable<TextSpan>();
- }
+ if (parent == null) {
+ return SpecializedCollections.EmptyEnumerable<TextSpan> ();
+ }
- var spans = new List<TextSpan>();
+ var spans = new List<TextSpan> ();
- HighlightRelatedKeywords(parent, spans);
+ HighlightRelatedKeywords (parent, spans);
- return spans;
- }
+ return spans;
+ }
- /// <summary>
- /// Finds all returns that are children of this node, and adds the appropriate spans to the spans list.
- /// </summary>
- private void HighlightRelatedKeywords(SyntaxNode node, List<TextSpan> spans)
- {
- node.TypeSwitch(
- (ReturnStatementSyntax statement) =>
- {
- spans.Add(statement.ReturnKeyword.Span);
- spans.Add(EmptySpan(statement.SemicolonToken.Span.End));
- },
- _ =>
- {
- foreach (var child in node.ChildNodes())
- {
- // Only recurse if we have anything to do
- if (!child.IsReturnableConstruct())
- {
- HighlightRelatedKeywords(child, spans);
- }
- }
- });
- }
- }
+ /// <summary>
+ /// Finds all returns that are children of this node, and adds the appropriate spans to the spans list.
+ /// </summary>
+ private void HighlightRelatedKeywords (SyntaxNode node, List<TextSpan> spans)
+ {
+ var statement = node as ReturnStatementSyntax;
+ if (statement != null) {
+ spans.Add (statement.ReturnKeyword.Span);
+ spans.Add (EmptySpan (statement.SemicolonToken.Span.End));
+ } else {
+ foreach (var child in node.ChildNodes ()) {
+ // Only recurse if we have anything to do
+ if (!child.IsReturnableConstruct ()) {
+ HighlightRelatedKeywords (child, spans);
+ }
+ }
+ }
+ }
+ }
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/SwitchStatementHighlighter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/SwitchStatementHighlighter.cs
index a5258f7548..626bd299e0 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/SwitchStatementHighlighter.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/SwitchStatementHighlighter.cs
@@ -2,8 +2,7 @@
using System.Collections.Generic;
using System.Threading;
-using ICSharpCode.NRefactory6;
-using ICSharpCode.NRefactory6.CSharp;
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/YieldStatementHighlighter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/YieldStatementHighlighter.cs
index 5ccdce54e9..c377cb819f 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/YieldStatementHighlighter.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/KeywordHighlighters/YieldStatementHighlighter.cs
@@ -41,27 +41,22 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.KeywordHighlighting.KeywordHighli
/// </summary>
private void HighlightRelatedKeywords(SyntaxNode node, List<TextSpan> spans)
{
- node.TypeSwitch(
- (YieldStatementSyntax statement) =>
- {
- spans.Add(
- TextSpan.FromBounds(
- statement.YieldKeyword.SpanStart,
- statement.ReturnOrBreakKeyword.Span.End));
-
- spans.Add(EmptySpan(statement.SemicolonToken.Span.End));
- },
- _ =>
- {
- foreach (var child in node.ChildNodes())
- {
- // Only recurse if we have anything to do
- if (!child.IsReturnableConstruct())
- {
- HighlightRelatedKeywords(child, spans);
- }
- }
- });
+ var statement = node as YieldStatementSyntax;
+ if (statement != null) {
+ spans.Add (
+ TextSpan.FromBounds (
+ statement.YieldKeyword.SpanStart,
+ statement.ReturnOrBreakKeyword.Span.End));
+
+ spans.Add (EmptySpan (statement.SemicolonToken.Span.End));
+ } else {
+ foreach (var child in node.ChildNodes ()) {
+ // Only recurse if we have anything to do
+ if (!child.IsReturnableConstruct ()) {
+ HighlightRelatedKeywords (child, spans);
+ }
+ }
+ }
}
}
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindBaseSymbolsHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindBaseSymbolsHandler.cs
index e7b2bde6aa..d732aca199 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindBaseSymbolsHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindBaseSymbolsHandler.cs
@@ -30,6 +30,7 @@ using MonoDevelop.Ide.FindInFiles;
using MonoDevelop.Ide.TypeSystem;
using MonoDevelop.Core;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Components.Commands;
using MonoDevelop.Refactoring;
using System.Threading.Tasks;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindDerivedSymbolsHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindDerivedSymbolsHandler.cs
index e6ca8cef4c..d547c26724 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindDerivedSymbolsHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindDerivedSymbolsHandler.cs
@@ -23,25 +23,23 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
-using MonoDevelop.Ide;
-using MonoDevelop.Ide.FindInFiles;
-using MonoDevelop.Ide.TypeSystem;
using System.Collections.Generic;
using System.Linq;
-using System.Threading.Tasks;
-using MonoDevelop.Projects;
using System.Threading;
-using MonoDevelop.Core;
+using System.Threading.Tasks;
+using ICSharpCode.NRefactory6.CSharp;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.FindSymbols;
-using ICSharpCode.NRefactory6.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Components.Commands;
-using MonoDevelop.Refactoring;
-using System.Runtime.CompilerServices;
-using System.Collections.Concurrent;
-using System.Collections.Immutable;
+using MonoDevelop.Core;
using MonoDevelop.CSharp.Navigation;
+using MonoDevelop.Ide;
+using MonoDevelop.Ide.FindInFiles;
+using MonoDevelop.Ide.TypeSystem;
namespace MonoDevelop.CSharp.Refactoring
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindExtensionMethodsHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindExtensionMethodsHandler.cs
index 4091082d63..c7a5f0c5a9 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindExtensionMethodsHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindExtensionMethodsHandler.cs
@@ -24,17 +24,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using MonoDevelop.Ide;
using MonoDevelop.Ide.FindInFiles;
-using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.Core;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Components.Commands;
using MonoDevelop.Refactoring;
-using System.Collections;
-using System.Reflection;
-using System.Collections.Generic;
using System.Linq;
using ICSharpCode.NRefactory6.CSharp;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindMemberOverloadsHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindMemberOverloadsHandler.cs
index 40790bf58c..f88698e842 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindMemberOverloadsHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Navigation/FindMemberOverloadsHandler.cs
@@ -23,15 +23,16 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
+
using System.Linq;
-using MonoDevelop.Ide;
-using MonoDevelop.Ide.FindInFiles;
using Microsoft.CodeAnalysis;
-using MonoDevelop.Core;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Components.Commands;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using MonoDevelop.Ide.FindInFiles;
using MonoDevelop.Refactoring;
-using ICSharpCode.NRefactory6.CSharp;
namespace MonoDevelop.CSharp.Navigation
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs
index 2668268e7c..b89ceff60c 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs
@@ -119,7 +119,7 @@ namespace MonoDevelop.CSharp.Parser
// compilerArguments.AllowUnsafeBlocks = par.UnsafeCode;
- compilerArguments = compilerArguments.WithLanguageVersion (ConvertLanguageVersion (par.LangVersion));
+ compilerArguments = compilerArguments.WithLanguageVersion (par.LangVersion);
// compilerArguments.CheckForOverflow = par.GenerateOverflowChecks;
// compilerArguments.WarningLevel = par.WarningLevel;
@@ -138,27 +138,6 @@ namespace MonoDevelop.CSharp.Parser
return compilerArguments;
}
-
- internal static Microsoft.CodeAnalysis.CSharp.LanguageVersion ConvertLanguageVersion (LangVersion ver)
- {
- switch (ver) {
- case LangVersion.ISO_1:
- return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp1;
- case LangVersion.ISO_2:
- return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp2;
- case LangVersion.Version3:
- return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp3;
- case LangVersion.Version4:
- return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp4;
- case LangVersion.Version5:
- return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp5;
- case LangVersion.Version6:
- return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp6;
- case LangVersion.Default:
- break;
- }
- return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp6;
- }
}
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs
index 585a470c4c..958a221479 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs
@@ -27,68 +27,56 @@
//
using System;
using System.Collections.Generic;
-
-using MonoDevelop.Projects;
-using MonoDevelop.Core.Serialization;
-using MonoDevelop.Core;
-using Mono.Collections.Generic;
-using System.Linq;
-using MonoDevelop.Projects.MSBuild;
using System.Collections.Immutable;
+using System.Globalization;
+using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Serialization;
+using MonoDevelop.Projects;
namespace MonoDevelop.CSharp.Project
{
- public enum LangVersion {
- Default = 0,
- ISO_1 = 1,
- ISO_2 = 2,
- Version3 = 3,
- Version4 = 4,
- Version5 = 5,
- Version6 = 6
- }
-
/// <summary>
/// This class handles project specific compiler parameters
/// </summary>
- public class CSharpCompilerParameters: DotNetCompilerParameters
+ public class CSharpCompilerParameters : DotNetCompilerParameters
{
// Configuration parameters
int? warninglevel = 4;
-
+
[ItemProperty ("NoWarn", DefaultValue = "")]
string noWarnings = String.Empty;
-
+
bool? optimize = false;
-
+
[ItemProperty ("AllowUnsafeBlocks", DefaultValue = false)]
bool unsafecode = false;
-
+
[ItemProperty ("CheckForOverflowUnderflow", DefaultValue = false)]
bool generateOverflowChecks;
-
+
[ItemProperty ("DefineConstants", DefaultValue = "")]
string definesymbols = String.Empty;
[ProjectPathItemProperty ("DocumentationFile")]
FilePath documentationFile;
-
+
[ItemProperty ("LangVersion", DefaultValue = "Default")]
string langVersion = "Default";
-
+
[ItemProperty ("NoStdLib", DefaultValue = false)]
bool noStdLib;
-
+
[ItemProperty ("TreatWarningsAsErrors", DefaultValue = false)]
bool treatWarningsAsErrors;
- [ItemProperty("PlatformTarget", DefaultValue="anycpu")]
+ [ItemProperty ("PlatformTarget", DefaultValue = "anycpu")]
string platformTarget = "anycpu";
-
- [ItemProperty("WarningsNotAsErrors", DefaultValue="")]
+
+ [ItemProperty ("WarningsNotAsErrors", DefaultValue = "")]
string warningsNotAsErrors = "";
protected override void Write (IPropertySet pset)
@@ -121,7 +109,7 @@ namespace MonoDevelop.CSharp.Project
public override CompilationOptions CreateCompilationOptions ()
{
- var project = (CSharpProject) ParentProject;
+ var project = (CSharpProject)ParentProject;
var options = new CSharpCompilationOptions (
OutputKind.ConsoleApplication,
false,
@@ -175,38 +163,42 @@ namespace MonoDevelop.CSharp.Project
}
}
- public override Microsoft.CodeAnalysis.ParseOptions CreateParseOptions (DotNetProjectConfiguration configuration)
+ public override ParseOptions CreateParseOptions (DotNetProjectConfiguration configuration)
{
var symbols = GetDefineSymbols ();
if (configuration != null)
symbols = symbols.Concat (configuration.GetDefineSymbols ()).Distinct ();
- return new Microsoft.CodeAnalysis.CSharp.CSharpParseOptions (
- GetRoslynLanguageVersion (langVersion),
- Microsoft.CodeAnalysis.DocumentationMode.Parse,
- Microsoft.CodeAnalysis.SourceCodeKind.Regular,
+
+ LanguageVersion lv;
+ TryParseLanguageVersion (langVersion, out lv);
+
+ return new CSharpParseOptions (
+ lv,
+ DocumentationMode.Parse,
+ SourceCodeKind.Regular,
ImmutableArray<string>.Empty.AddRange (symbols)
);
}
- public LangVersion LangVersion {
+ public LanguageVersion LangVersion {
get {
- var val = TryLangVersionFromString (langVersion);
- if (val == null) {
- throw new Exception ("Unknown LangVersion string '" + val + "'");
+ LanguageVersion val;
+ if (!TryParseLanguageVersion (langVersion, out val)) {
+ throw new Exception ("Unknown LangVersion string '" + langVersion + "'");
}
- return val.Value;
+ return val;
}
set {
- var v = TryLangVersionToString (value);
- if (v == null) {
- throw new ArgumentOutOfRangeException ("Unknown LangVersion enum value '" + value + "'");
+ if (LangVersion == value) {
+ return;
}
- langVersion = v;
+
+ langVersion = LanguageVersionToString (value);
}
}
-#region Code Generation
+ #region Code Generation
public override void AddDefineSymbol (string symbol)
{
@@ -230,7 +222,7 @@ namespace MonoDevelop.CSharp.Project
else
definesymbols = string.Empty;
}
-
+
public string DefineSymbols {
get {
return definesymbols;
@@ -239,7 +231,7 @@ namespace MonoDevelop.CSharp.Project
definesymbols = value ?? string.Empty;
}
}
-
+
public bool Optimize {
get {
return optimize ?? false;
@@ -249,7 +241,7 @@ namespace MonoDevelop.CSharp.Project
optimize = value;
}
}
-
+
public bool UnsafeCode {
get {
return unsafecode;
@@ -258,7 +250,7 @@ namespace MonoDevelop.CSharp.Project
unsafecode = value;
}
}
-
+
public bool GenerateOverflowChecks {
get {
return generateOverflowChecks;
@@ -267,7 +259,7 @@ namespace MonoDevelop.CSharp.Project
generateOverflowChecks = value;
}
}
-
+
public FilePath DocumentationFile {
get {
return documentationFile;
@@ -276,7 +268,7 @@ namespace MonoDevelop.CSharp.Project
documentationFile = value;
}
}
-
+
public string PlatformTarget {
get {
return platformTarget;
@@ -286,9 +278,9 @@ namespace MonoDevelop.CSharp.Project
}
}
-#endregion
+ #endregion
-#region Errors and Warnings
+ #region Errors and Warnings
public int WarningLevel {
get {
return warninglevel ?? 4;
@@ -298,11 +290,11 @@ namespace MonoDevelop.CSharp.Project
warninglevel = value;
} else {
if (value != 4)
- warninglevel = value;
+ warninglevel = value;
}
}
}
-
+
public string NoWarnings {
get {
return noWarnings;
@@ -329,7 +321,7 @@ namespace MonoDevelop.CSharp.Project
treatWarningsAsErrors = value;
}
}
-
+
public string WarningsNotAsErrors {
get {
return warningsNotAsErrors;
@@ -338,46 +330,67 @@ namespace MonoDevelop.CSharp.Project
warningsNotAsErrors = value;
}
}
-#endregion
+ #endregion
- static LangVersion? TryLangVersionFromString (string value)
+ internal static string LanguageVersionToString (LanguageVersion value)
{
switch (value) {
- case "Default": return LangVersion.Default;
- case "ISO-1": return LangVersion.ISO_1;
- case "ISO-2": return LangVersion.ISO_2;
- case "3": return LangVersion.Version3;
- case "4": return LangVersion.Version4;
- case "5": return LangVersion.Version5;
- case "6": return LangVersion.Version6;
- default: return null;
+ case LanguageVersion.Default: return "Default";
+ case LanguageVersion.Latest: return "Latest";
+ case LanguageVersion.CSharp1: return "ISO-1";
+ case LanguageVersion.CSharp2: return "ISO-2";
+ default: return ((int)value).ToString ();
}
}
- Microsoft.CodeAnalysis.CSharp.LanguageVersion GetRoslynLanguageVersion (string value)
+ // From https://github.com/dotnet/roslyn/blob/f60facc9f40ddc40f85411372f5b8dde9dd5e3b4/src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs
+ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+ static bool TryParseLanguageVersion (string str, out LanguageVersion version)
{
- switch (value) {
- case "ISO-1": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp1;
- case "ISO-2": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp2;
- case "3": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp3;
- case "4": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp4;
- case "5": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp5;
- case "6": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp6;
- default: return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp6;
+ if (str == null) {
+ version = LanguageVersion.Default;
+ return true;
}
- }
- internal static string TryLangVersionToString (LangVersion value)
- {
- switch (value) {
- case LangVersion.Default: return "Default";
- case LangVersion.ISO_1: return "ISO-1";
- case LangVersion.ISO_2: return "ISO-2";
- case LangVersion.Version3: return "3";
- case LangVersion.Version4: return "4";
- case LangVersion.Version5: return "5";
- case LangVersion.Version6: return "6";
- default: return null;
+ switch (str.ToLowerInvariant ()) {
+ case "iso-1":
+ version = LanguageVersion.CSharp1;
+ return true;
+
+ case "iso-2":
+ version = LanguageVersion.CSharp2;
+ return true;
+
+ case "7":
+ version = LanguageVersion.CSharp7;
+ return true;
+
+ case "default":
+ version = LanguageVersion.Default;
+ return true;
+
+ case "latest":
+ version = LanguageVersion.Latest;
+ return true;
+
+ default:
+ // We are likely to introduce minor version numbers after C# 7, thus breaking the
+ // one-to-one correspondence between the integers and the corresponding
+ // LanguageVersion enum values. But for compatibility we continue to accept any
+ // integral value parsed by int.TryParse for its corresponding LanguageVersion enum
+ // value for language version C# 6 and earlier (e.g. leading zeros are allowed)
+ int versionNumber;
+ if (int.TryParse (str, NumberStyles.None, CultureInfo.InvariantCulture, out versionNumber) &&
+ //HACK: IsValid isn't accessible, do our own check here
+ //&& versionNumber <= 6 && ((LanguageVersion)versionNumber).IsValid ())
+ versionNumber > 0 && versionNumber <= 6)
+ {
+ version = (LanguageVersion)versionNumber;
+ return true;
+ }
+
+ version = LanguageVersion.Default;
+ return false;
}
}
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs
index c98423fcf2..1da11ca8ab 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs
@@ -38,6 +38,7 @@ using MonoDevelop.Ide.Gui.Dialogs;
using MonoDevelop.Ide;
using MonoDevelop.Ide.TypeSystem;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
namespace MonoDevelop.CSharp.Project
{
@@ -100,16 +101,28 @@ namespace MonoDevelop.CSharp.Project
allowUnsafeCodeCheckButton.Active = compilerParameters.UnsafeCode;
noStdLibCheckButton.Active = compilerParameters.NoStdLib;
- ListStore langVerStore = new ListStore (typeof (string));
- langVerStore.AppendValues (GettextCatalog.GetString ("Default"));
- langVerStore.AppendValues ("ISO-1");
- langVerStore.AppendValues ("ISO-2");
- langVerStore.AppendValues ("Version 3");
- langVerStore.AppendValues ("Version 4");
- langVerStore.AppendValues ("Version 5");
- langVerStore.AppendValues ("Version 6");
+ var langVerStore = new ListStore (typeof (string), typeof(LanguageVersion));
+ langVerStore.AppendValues (GettextCatalog.GetString ("Default"), LanguageVersion.Default);
+ langVerStore.AppendValues ("ISO-1", LanguageVersion.CSharp1);
+ langVerStore.AppendValues ("ISO-2", LanguageVersion.CSharp2);
+ langVerStore.AppendValues (GettextCatalog.GetString ("Version 3"), LanguageVersion.CSharp3);
+ langVerStore.AppendValues (GettextCatalog.GetString ("Version 4"), LanguageVersion.CSharp4);
+ langVerStore.AppendValues (GettextCatalog.GetString ("Version 5"), LanguageVersion.CSharp5);
+ langVerStore.AppendValues (GettextCatalog.GetString ("Version 6"), LanguageVersion.CSharp6);
+ langVerStore.AppendValues (GettextCatalog.GetString ("Version 7"), LanguageVersion.CSharp7);
+ langVerStore.AppendValues (GettextCatalog.GetString ("Latest"), LanguageVersion.Latest);
langVerCombo.Model = langVerStore;
- langVerCombo.Active = (int) compilerParameters.LangVersion;
+
+ TreeIter iter;
+ if (langVerStore.GetIterFirst (out iter)) {
+ do {
+ var val = (LanguageVersion)(int)langVerStore.GetValue (iter, 1);
+ if (val == compilerParameters.LangVersion) {
+ langVerCombo.SetActiveIter (iter);
+ break;
+ }
+ } while (langVerStore.IterNext (ref iter));
+ }
}
public bool ValidateChanges ()
@@ -137,10 +150,14 @@ namespace MonoDevelop.CSharp.Project
public void Store (ItemConfigurationCollection<ItemConfiguration> configs)
{
int codePage;
- CompileTarget compileTarget = (CompileTarget) compileTargetCombo.Active;
- LangVersion langVersion = (LangVersion) langVerCombo.Active;
-
-
+ var compileTarget = (CompileTarget) compileTargetCombo.Active;
+
+ var langVersion = LanguageVersion.Default;
+ TreeIter iter;
+ if (langVerCombo.GetActiveIter (out iter)) {
+ langVersion = (LanguageVersion)langVerCombo.Model.GetValue (iter, 1);
+ }
+
if (codepageEntry.Entry.Text.Length > 0) {
// Get the codepage. If the user specified an encoding name, find it.
int trialCodePage = -1;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerationService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerationService.cs
deleted file mode 100644
index a28f8a3750..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerationService.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-////
-//// CSharpCodeGenerationService.cs
-////
-//// Author:
-//// Mike Krüger <mkrueger@xamarin.com>
-////
-//// Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
-////
-//// Permission is hereby granted, free of charge, to any person obtaining a copy
-//// of this software and associated documentation files (the "Software"), to deal
-//// in the Software without restriction, including without limitation the rights
-//// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-//// copies of the Software, and to permit persons to whom the Software is
-//// furnished to do so, subject to the following conditions:
-////
-//// The above copyright notice and this permission notice shall be included in
-//// all copies or substantial portions of the Software.
-////
-//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-//// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-//// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-//// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-//// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-//// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-//// THE SOFTWARE.
-//using System;
-//using ICSharpCode.NRefactory.CSharp;
-//using ICSharpCode.NRefactory.TypeSystem;
-//using ICSharpCode.NRefactory.CSharp.Refactoring;
-//using System.Linq;
-//using Atk;
-//using Gdk;
-//
-//namespace MonoDevelop.CSharp.Refactoring
-//{
-// public class CSharpCodeGenerationService : DefaultCodeGenerationService
-// {
-// public override EntityDeclaration GenerateMemberImplementation (RefactoringContext context, IMember member, bool explicitImplementation)
-// {
-// var result = base.GenerateMemberImplementation (context, member, explicitImplementation);
-// if (CSharpCodeGenerator.IsMonoTouchModelMember (member)) {
-// var m = result as MethodDeclaration;
-// if (m != null) {
-// for (int i = CSharpCodeGenerator.MonoTouchComments.Length - 1; i >= 0; i--) {
-// m.Body.InsertChildBefore (m.Body.Statements.First (), new Comment (CSharpCodeGenerator.MonoTouchComments [i]), Roles.Comment);
-// }
-// }
-//
-// var p = result as PropertyDeclaration;
-// if (p != null) {
-// for (int i = CSharpCodeGenerator.MonoTouchComments.Length - 1; i >= 0; i--) {
-// if (!p.Getter.IsNull)
-// p.Getter.Body.InsertChildBefore (p.Getter.Body.Statements.First (), new Comment (CSharpCodeGenerator.MonoTouchComments [i]), Roles.Comment);
-// if (!p.Setter.IsNull)
-// p.Setter.Body.InsertChildBefore (p.Setter.Body.Statements.First (), new Comment (CSharpCodeGenerator.MonoTouchComments [i]), Roles.Comment);
-// }
-// }
-// }
-// return result;
-// }
-// }
-//}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethodCommandHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethodCommandHandler.cs
index 37e0ab49fc..499d7d9002 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethodCommandHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethodCommandHandler.cs
@@ -24,23 +24,22 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
-using MonoDevelop.Components.Commands;
-using ICSharpCode.NRefactory6.CSharp.ExtractMethod;
-using MonoDevelop.Ide;
-using ICSharpCode.NRefactory6.CSharp;
-using System.Threading;
-using Microsoft.CodeAnalysis.Text;
using System.Linq;
-using MonoDevelop.Refactoring;
-using MonoDevelop.Core;
+using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis.CSharp.ExtractMethod;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using MonoDevelop.Refactoring;
namespace MonoDevelop.CSharp.Refactoring
{
class ExtractMethodCommandHandler : CommandHandler
{
- public static async Task<bool> IsValid (MonoDevelop.Ide.Gui.Document doc, CancellationToken cancellationToken = default(CancellationToken))
+ public static async Task<bool> IsValid (MonoDevelop.Ide.Gui.Document doc, CancellationToken cancellationToken = default (CancellationToken))
{
if (doc == null)
return false;
@@ -70,11 +69,11 @@ namespace MonoDevelop.CSharp.Refactoring
if (!doc.Editor.IsSomethingSelected)
return;
var ad = doc.AnalysisDocument;
- if (ad == null || ! await IsValid (doc))
+ if (ad == null || !await IsValid (doc))
return;
try {
var selectionRange = doc.Editor.SelectionRange;
- var token = default(CancellationToken);
+ var token = default (CancellationToken);
var selection = new CSharpSelectionValidator (await SemanticDocument.CreateAsync (ad, token).ConfigureAwait (false), new TextSpan (selectionRange.Offset, selectionRange.Length), doc.GetOptionSet ());
var result = await selection.GetValidSelectionAsync (token).ConfigureAwait (false);
if (!result.ContainsValidContext)
@@ -96,8 +95,7 @@ namespace MonoDevelop.CSharp.Refactoring
var sym = info.DeclaredSymbol ?? info.Symbol;
if (sym != null)
await new MonoDevelop.Refactoring.Rename.RenameRefactoring ().Rename (sym);
- }
- catch (Exception e) {
+ } catch (Exception e) {
LoggingService.LogError ("Error while extracting method", e);
}
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindReferencesHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindReferencesHandler.cs
index 588dd991d3..6a03989ce1 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindReferencesHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindReferencesHandler.cs
@@ -25,22 +25,18 @@
// THE SOFTWARE.
using System;
-using System.Linq;
-using System.Threading;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.FindSymbols;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Components.Commands;
using MonoDevelop.Core;
+using MonoDevelop.CSharp.Highlighting;
using MonoDevelop.Ide;
-using MonoDevelop.Refactoring;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis;
-using MonoDevelop.Ide.TypeSystem;
using MonoDevelop.Ide.FindInFiles;
-using MonoDevelop.Ide.Tasks;
-using System.Threading.Tasks;
-using System.Collections.Generic;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.CSharp;
-using MonoDevelop.CSharp.Highlighting;
+using MonoDevelop.Ide.TypeSystem;
+using MonoDevelop.Refactoring;
namespace MonoDevelop.CSharp.Refactoring
{
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/OrganizeImportsCommandHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/OrganizeImportsCommandHandler.cs
index 7f40207999..e92f5897b6 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/OrganizeImportsCommandHandler.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/OrganizeImportsCommandHandler.cs
@@ -23,25 +23,23 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
-using MonoDevelop.Components.Commands;
-using ICSharpCode.NRefactory6.CSharp.ExtractMethod;
-using MonoDevelop.Ide;
-using ICSharpCode.NRefactory6.CSharp;
+using System.Collections.Generic;
using System.Threading;
-using Microsoft.CodeAnalysis.Text;
-using System.Linq;
-using MonoDevelop.Refactoring;
-using MonoDevelop.Core;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
-using ICSharpCode.NRefactory6.CSharp.Features.OrganizeImports;
-using System.Collections.Generic;
-using ICSharpCode.NRefactory6.CSharp.Features.RemoveUnnecessaryImports;
+using Microsoft.CodeAnalysis.RemoveUnnecessaryImports;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.Text;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using Microsoft.CodeAnalysis.OrganizeImports;
namespace MonoDevelop.CSharp.Refactoring
{
- internal static partial class IWorkspaceExtensions
+ static class IWorkspaceExtensions
{
/// <summary>
/// Update the workspace so that the document with the Id of <paramref name="newDocument"/>
@@ -58,30 +56,26 @@ namespace MonoDevelop.CSharp.Refactoring
}
- internal static Solution UpdateDocument(this Solution solution, DocumentId id, IEnumerable<TextChange> textChanges, CancellationToken cancellationToken)
+ internal static Solution UpdateDocument (this Solution solution, DocumentId id, IEnumerable<TextChange> textChanges, CancellationToken cancellationToken)
{
- var oldDocument = solution.GetDocument(id);
- var oldText = oldDocument.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken);
- var newText = oldText.WithChanges(textChanges);
- return solution.WithDocumentText(id, newText, PreservationMode.PreserveIdentity);
+ var oldDocument = solution.GetDocument (id);
+ var oldText = oldDocument.GetTextAsync (cancellationToken).WaitAndGetResult (cancellationToken);
+ var newText = oldText.WithChanges (textChanges);
+ return solution.WithDocumentText (id, newText, PreservationMode.PreserveIdentity);
}
}
class RemoveUnusedImportsCommandHandler : CommandHandler
{
- internal static readonly CSharpRemoveUnnecessaryImportsService service = new CSharpRemoveUnnecessaryImportsService();
-
public async static Task Run (MonoDevelop.Ide.Gui.Document doc)
{
var ad = doc.AnalysisDocument;
if (ad == null)
return;
try {
-
- var model = await ad.GetSemanticModelAsync (default (CancellationToken));
- var root = model.SyntaxTree.GetRoot (default (CancellationToken));
- var newDocument = service.RemoveUnnecessaryImports(ad, model, root, default (CancellationToken));
- ad.Project.Solution.Workspace.ApplyDocumentChanges(newDocument, CancellationToken.None);
+ var service = ad.GetLanguageService<IRemoveUnnecessaryImportsService> ();
+ var newDocument = await service.RemoveUnnecessaryImportsAsync (ad, default (CancellationToken));
+ ad.Project.Solution.Workspace.ApplyDocumentChanges (newDocument, CancellationToken.None);
} catch (Exception e) {
LoggingService.LogError ("Error while removing unused usings", e);
@@ -99,8 +93,6 @@ namespace MonoDevelop.CSharp.Refactoring
class OrganizeImportsCommandHandler : CommandHandler
{
- internal static readonly CSharpOrganizeImportsService service = new CSharpOrganizeImportsService ();
-
public async static Task Run (MonoDevelop.Ide.Gui.Document doc)
{
var ad = doc.AnalysisDocument;
@@ -111,14 +103,14 @@ namespace MonoDevelop.CSharp.Refactoring
ad.Project.Solution.Workspace.ApplyDocumentChanges (newDocument, CancellationToken.None);
} catch (Exception e) {
- LoggingService.LogError ("Error while sotring usings", e);
+ LoggingService.LogError ("Error while sorting usings", e);
}
}
internal static async Task<Document> SortUsingsAsync (Document ad, CancellationToken token)
{
+ var service = ad.GetLanguageService<IOrganizeImportsService> ();
var policy = IdeApp.Workbench.ActiveDocument.GetFormattingPolicy ();
- Console.WriteLine (policy.PlaceSystemDirectiveFirst);
return await service.OrganizeImportsAsync (ad, policy != null ? policy.PlaceSystemDirectiveFirst : true, token);
}
@@ -148,9 +140,8 @@ namespace MonoDevelop.CSharp.Refactoring
internal static async Task<Document> SortAndRemoveAsync (Document ad, CancellationToken token)
{
- var model = await ad.GetSemanticModelAsync (token);
- var root = model.SyntaxTree.GetRoot (token);
- var newDocument = RemoveUnusedImportsCommandHandler.service.RemoveUnnecessaryImports (ad, model, root, token);
+ var service = ad.GetLanguageService<IRemoveUnnecessaryImportsService> ();
+ var newDocument = await service.RemoveUnnecessaryImportsAsync (ad, token);
return await OrganizeImportsCommandHandler.SortUsingsAsync (newDocument, token);
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs
index 64ad7f28dd..c92a825224 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs
@@ -29,7 +29,6 @@
using System;
using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
using MonoDevelop.Components.Commands;
using MonoDevelop.Ide;
using System.Linq;
@@ -37,7 +36,6 @@ using Microsoft.CodeAnalysis;
using MonoDevelop.Ide.Editor;
using MonoDevelop.CodeActions;
using MonoDevelop.CodeIssues;
-using MonoDevelop.CSharp.Refactoring;
using MonoDevelop.Refactoring;
using Microsoft.CodeAnalysis.CodeFixes;
using System.Collections.Immutable;
@@ -45,8 +43,6 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using System.Collections.Generic;
-using ICSharpCode.NRefactory.CSharp.Refactoring;
-using MonoDevelop.CSharp.Navigation;
using Microsoft.CodeAnalysis.Text;
namespace MonoDevelop.CSharp.Refactoring
@@ -55,141 +51,11 @@ namespace MonoDevelop.CSharp.Refactoring
{
protected override void Run (object dataItem)
{
- var del = (Action) dataItem;
+ var del = (Action)dataItem;
if (del != null)
del ();
}
- static CommandInfoSet CreateFixMenu (TextEditor editor, DocumentContext ctx, SemanticModel semanticModel, CodeActionContainer container)
- {
- if (editor == null)
- throw new ArgumentNullException (nameof (editor));
- if (ctx == null)
- throw new ArgumentNullException (nameof (ctx));
- if (container == null)
- throw new ArgumentNullException (nameof (container));
- var result = new CommandInfoSet ();
- result.Text = GettextCatalog.GetString ("Fix");
- foreach (var diagnostic in container.CodeFixActions) {
- var info = new CommandInfo (diagnostic.CodeAction.Title);
- result.CommandInfos.Add (info, new Action (async () => await new CodeActionEditorExtension.ContextActionRunner (diagnostic.CodeAction, editor, ctx).Run ()));
- }
- bool firstDiagnosticOption = result.CommandInfos.Count != 0;
-
- var warningsAtCaret = semanticModel
- .GetDiagnostics (new TextSpan (editor.CaretOffset, 0))
- .Where (diag => diag.Severity == DiagnosticSeverity.Warning).ToList ();
- foreach (var warning in warningsAtCaret) {
-
- if (firstDiagnosticOption) {
- result.CommandInfos.AddSeparator ();
- firstDiagnosticOption = false;
- }
-
- var label = GettextCatalog.GetString ("_Options for \"{0}\"", warning.Descriptor.Title);
- var subMenu = new CommandInfoSet ();
- subMenu.Text = label;
-
- var info = new CommandInfo (GettextCatalog.GetString ("_Suppress with #pragma"));
- subMenu.CommandInfos.Add (info, new Action (async delegate {
-
- var fixes = await CSharpSuppressionFixProvider.Instance.GetSuppressionsAsync (ctx.AnalysisDocument, new TextSpan (editor.CaretOffset, 0), new [] { warning }, default (CancellationToken)).ConfigureAwait (false);
- foreach (var f in fixes) {
- CodeDiagnosticDescriptor.RunAction (ctx, f.Action, default (CancellationToken));
- }
- }));
-
- result.CommandInfos.Add (subMenu);
- }
-
- foreach (var fix in container.DiagnosticsAtCaret) {
- var inspector = BuiltInCodeDiagnosticProvider.GetCodeDiagnosticDescriptor (fix.Id);
- if (inspector == null)
- continue;
-
- if (firstDiagnosticOption) {
- result.CommandInfos.AddSeparator ();
- firstDiagnosticOption = false;
- }
-
- var label = GettextCatalog.GetString ("_Options for \"{0}\"", fix.GetMessage ());
- var subMenu = new CommandInfoSet ();
- subMenu.Text = label;
-
- // if (inspector.CanSuppressWithAttribute) {
- // var menuItem = new FixMenuEntry (GettextCatalog.GetString ("_Suppress with attribute"),
- // delegate {
- //
- // inspector.SuppressWithAttribute (Editor, DocumentContext, GetTextSpan (fix.Item2));
- // });
- // subMenu.Add (menuItem);
- // }
-
- if (inspector.CanDisableWithPragma) {
- var info = new CommandInfo (GettextCatalog.GetString ("_Suppress with #pragma"));
- subMenu.CommandInfos.Add (info, new Action (() => inspector.DisableWithPragma (editor, ctx, fix)));
-
- info = new CommandInfo (GettextCatalog.GetString ("_Suppress with file"));
- subMenu.CommandInfos.Add (info, new Action (() => inspector.DisableWithFile (editor, ctx, fix)));
- }
-
- var configInfo = new CommandInfo (GettextCatalog.GetString ("_Configure Rule"));
- subMenu.CommandInfos.Add (configInfo, new Action (() => {
- IdeApp.Workbench.ShowGlobalPreferencesDialog (null, "C#", dialog => {
- var panel = dialog.GetPanel<CodeIssuePanel> ("C#");
- if (panel == null)
- return;
- panel.Widget.SelectCodeIssue (inspector.IdString);
- });
- }));
-
- foreach (var fix2 in container.CodeFixActions) {
-
- var provider = fix2.Diagnostic.GetCodeFixProvider ().GetFixAllProvider ();
- if (provider == null)
- continue;
- if (!provider.GetSupportedFixAllScopes ().Contains (FixAllScope.Document))
- continue;
- var subMenu2 = new CommandInfoSet ();
- subMenu2.Text = GettextCatalog.GetString ("Fix all");
- var diagnosticAnalyzer = fix2.Diagnostic.GetCodeDiagnosticDescriptor (LanguageNames.CSharp).GetProvider ();
- if (!diagnosticAnalyzer.SupportedDiagnostics.Contains (fix.Descriptor))
- continue;
-
- var info = new CommandInfo (GettextCatalog.GetString ("In _Document"));
- subMenu2.CommandInfos.Add (info, new Action (async delegate {
-
- var fixAllDiagnosticProvider = new CodeActionEditorExtension.FixAllDiagnosticProvider (diagnosticAnalyzer.SupportedDiagnostics.Select (d => d.Id).ToImmutableHashSet (), async (Microsoft.CodeAnalysis.Document doc, ImmutableHashSet<string> diagnostics, CancellationToken token) => {
-
- var model = await doc.GetSemanticModelAsync (token);
- var compilationWithAnalyzer = model.Compilation.WithAnalyzers (new [] { diagnosticAnalyzer }.ToImmutableArray (), null, token);
-
- return await compilationWithAnalyzer.GetAnalyzerSemanticDiagnosticsAsync (model, null, token);
- }, (arg1, arg2, arg3, arg4) => {
- return Task.FromResult ((IEnumerable<Diagnostic>)new Diagnostic [] { });
- });
- var ctx2 = new FixAllContext (
- ctx.AnalysisDocument,
- fix2.Diagnostic.GetCodeFixProvider (),
- FixAllScope.Document,
- fix2.CodeAction.EquivalenceKey,
- diagnosticAnalyzer.SupportedDiagnostics.Select (d => d.Id),
- fixAllDiagnosticProvider,
- default (CancellationToken)
- );
- var fixAll = await provider.GetFixAsync (ctx2);
- using (var undo = editor.OpenUndoGroup ()) {
- CodeDiagnosticDescriptor.RunAction (ctx, fixAll, default (CancellationToken));
- }
- }));
- subMenu.CommandInfos.Add (subMenu2);
- }
- result.CommandInfos.Add (subMenu);
- }
-
- return result;
- }
-
protected override void Update (CommandArrayInfo ainfo)
{
var doc = IdeApp.Workbench.ActiveDocument;
@@ -206,13 +72,6 @@ namespace MonoDevelop.CSharp.Refactoring
var ext = doc.GetContent<CodeActionEditorExtension> ();
- //if (ext != null) {
- // var fixMenu = CreateFixMenu (doc.Editor, doc, semanticModel, ext.GetCurrentFixes ());
- // if (fixMenu.CommandInfos.Count > 0) {
- // ainfo.Add (fixMenu, null);
- // added = true;
- // }
- //}
var ciset = new CommandInfoSet ();
ciset.Text = GettextCatalog.GetString ("Refactor");
@@ -224,16 +83,6 @@ namespace MonoDevelop.CSharp.Refactoring
added = true;
}
bool first = true;
- //if (ext != null) {
- // foreach (var fix in ext.GetCurrentFixes ().CodeRefactoringActions) {
- // if (added & first && ciset.CommandInfos.Count > 0)
- // ciset.CommandInfos.AddSeparator ();
- // var info2 = new CommandInfo (fix.CodeAction.Title);
- // ciset.CommandInfos.Add (info2, new Action (async () => await new CodeActionEditorExtension.ContextActionRunner (fix.CodeAction, doc.Editor, doc).Run ()));
- // added = true;
- // first = false;
- // }
- //}
if (ciset.CommandInfos.Count > 0) {
ainfo.Add (ciset, null);
@@ -244,7 +93,7 @@ namespace MonoDevelop.CSharp.Refactoring
if (gotoDeclarationSymbol == null && info.DeclaredSymbol != null && info.DeclaredSymbol.Locations.Length > 1)
gotoDeclarationSymbol = info.DeclaredSymbol;
if (IdeApp.ProjectOperations.CanJumpToDeclaration (gotoDeclarationSymbol) || gotoDeclarationSymbol == null && IdeApp.ProjectOperations.CanJumpToDeclaration (info.CandidateSymbols.FirstOrDefault ())) {
-
+
var type = (gotoDeclarationSymbol ?? info.CandidateSymbols.FirstOrDefault ()) as INamedTypeSymbol;
if (type != null && type.Locations.Length > 1) {
var declSet = new CommandInfoSet ();
@@ -292,11 +141,11 @@ namespace MonoDevelop.CSharp.Refactoring
{
if (fileName == null)
return null;
- char[] seperators = { System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar };
+ char [] seperators = { System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar };
int idx = fileName.LastIndexOfAny (seperators);
- if (idx > 0)
+ if (idx > 0)
idx = fileName.LastIndexOfAny (seperators, idx - 1);
- if (idx > 0)
+ if (idx > 0)
return "..." + fileName.Substring (idx);
return fileName;
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DebuggerExpressionResolver.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DebuggerExpressionResolver.cs
index 9ec0edec0f..ea9c035e2e 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DebuggerExpressionResolver.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DebuggerExpressionResolver.cs
@@ -35,6 +35,8 @@ using System.Threading;
using System.Threading.Tasks;
using ICSharpCode.NRefactory6.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Ide.Editor;
using MonoDevelop.Debugger;
using MonoDevelop.Ide.TypeSystem;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs
index 2b8c299ad6..2230aa2164 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs
@@ -204,8 +204,8 @@ namespace MonoDevelop.CSharp
sb.AppendLine ("/debug:" + debugType);
}
- if (compilerParameters.LangVersion != LangVersion.Default) {
- var langVersionString = CSharpCompilerParameters.TryLangVersionToString (compilerParameters.LangVersion);
+ if (compilerParameters.LangVersion != Microsoft.CodeAnalysis.CSharp.LanguageVersion.Default) {
+ var langVersionString = CSharpCompilerParameters.LanguageVersionToString (compilerParameters.LangVersion);
if (langVersionString == null) {
string message = "Invalid LangVersion enum value '" + compilerParameters.LangVersion.ToString () + "'";
monitor.ReportError (message, null);
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBraceMatcher.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBraceMatcher.cs
index 548aafec05..feaa639f8f 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBraceMatcher.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBraceMatcher.cs
@@ -31,6 +31,7 @@ using MonoDevelop.Ide.Editor;
using MonoDevelop.CSharp.Formatting;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using MonoDevelop.Core.Text;
using MonoDevelop.CSharp.Completion;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -148,4 +149,4 @@ namespace MonoDevelop.CSharp
return false;
}
}
-} \ No newline at end of file
+}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs
index ad3534d624..f0f7785112 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs
@@ -38,6 +38,8 @@ using MonoDevelop.Ide.Editor.Extension;
using MonoDevelop.Projects;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using System.Threading.Tasks;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/ProjectSearchCategory.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/ProjectSearchCategory.cs
index f41e15570b..31c4743a58 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/ProjectSearchCategory.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/ProjectSearchCategory.cs
@@ -23,25 +23,24 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using ICSharpCode.NRefactory6.CSharp;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using MonoDevelop.Components.MainToolbar;
using MonoDevelop.Core;
-using System.Collections.Generic;
using MonoDevelop.Core.Instrumentation;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui;
+using MonoDevelop.Core.Text;
using MonoDevelop.Ide;
using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.Core.Text;
-using Gtk;
-using System.Linq;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis;
-using System.Collections.Immutable;
-using System.Diagnostics;
-using System.Collections.Concurrent;
-using MonoDevelop.Components.MainToolbar;
namespace MonoDevelop.CSharp
{
@@ -231,7 +230,7 @@ namespace MonoDevelop.CSharp
foreach (var kind in AllKinds) {
infos [kind] = new List<DeclaredSymbolInfo> ();
}
- foreach (var current in root.DescendantNodesAndSelf (CSharpSyntaxFactsService.DescentIntoSymbolForDeclarationSearch)) {
+ foreach (var current in root.DescendantNodesAndSelf (n => !(n is BlockSyntax))) {
cancellationToken.ThrowIfCancellationRequested ();
DeclaredSymbolInfo declaredSymbolInfo;
if (current.TryGetDeclaredSymbolInfo (out declaredSymbolInfo)) {
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs
index 984f7a64b1..b07ea83581 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs
@@ -38,6 +38,8 @@ using Microsoft.CodeAnalysis.Simplification;
using Microsoft.CodeAnalysis.CSharp.Formatting;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp;
using MonoDevelop.Ide.Editor;
using MonoDevelop.Components;
diff --git a/main/src/addins/CSharpBinding/Util/AccessibilityUtilities.cs b/main/src/addins/CSharpBinding/Util/AccessibilityUtilities.cs
deleted file mode 100644
index f0c0560f3d..0000000000
--- a/main/src/addins/CSharpBinding/Util/AccessibilityUtilities.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-// AccessibilityUtilities.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal static class AccessibilityUtilities
- {
- public static Accessibility Minimum(Accessibility accessibility1, Accessibility accessibility2)
- {
- if (accessibility1 == Accessibility.Private || accessibility2 == Accessibility.Private)
- {
- return Accessibility.Private;
- }
-
- if (accessibility1 == Accessibility.ProtectedAndInternal || accessibility2 == Accessibility.ProtectedAndInternal)
- {
- return Accessibility.ProtectedAndInternal;
- }
-
- if (accessibility1 == Accessibility.Protected || accessibility2 == Accessibility.Protected)
- {
- return Accessibility.Protected;
- }
-
- if (accessibility1 == Accessibility.Internal || accessibility2 == Accessibility.Internal)
- {
- return Accessibility.Internal;
- }
-
- if (accessibility1 == Accessibility.ProtectedOrInternal || accessibility2 == Accessibility.ProtectedOrInternal)
- {
- return Accessibility.ProtectedOrInternal;
- }
-
- return Accessibility.Public;
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/AnnotationTable.cs b/main/src/addins/CSharpBinding/Util/AnnotationTable.cs
deleted file mode 100644
index 195fae7397..0000000000
--- a/main/src/addins/CSharpBinding/Util/AnnotationTable.cs
+++ /dev/null
@@ -1,275 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- /// <summary>
- /// An AnnotationTable helps you attach your own annotation types/instances to syntax.
- ///
- /// It maintains a map between your instances and actual SyntaxAnnotation's used to annotate the nodes
- /// and offers an API that matches the true annotation API on SyntaxNode.
- ///
- /// The table controls the lifetime of when you can find and retrieve your annotations. You won't be able to
- /// find your annotations via HasAnnotations/GetAnnotations unless you use the same annotation table for these operations
- /// that you used for the WithAdditionalAnnotations operation.
- ///
- /// Your custom annotations are not serialized with the syntax tree, so they won't move across boundaries unless the
- /// same AnnotationTable is available on both ends.
- ///
- /// also, note that this table is not thread safe.
- /// </summary>
- class AnnotationTable<TAnnotation> where TAnnotation : class
- {
- private int _globalId = 0;
-
- private readonly Dictionary<TAnnotation, SyntaxAnnotation> _realAnnotationMap = new Dictionary<TAnnotation, SyntaxAnnotation>();
- private readonly Dictionary<string, TAnnotation> _annotationMap = new Dictionary<string, TAnnotation>();
-
- private readonly string _annotationKind;
-
- public AnnotationTable(string annotationKind)
- {
- _annotationKind = annotationKind;
- }
-
- private IEnumerable<SyntaxAnnotation> GetOrCreateRealAnnotations(TAnnotation[] annotations)
- {
- foreach (var annotation in annotations)
- {
- yield return this.GetOrCreateRealAnnotation(annotation);
- }
- }
-
- private SyntaxAnnotation GetOrCreateRealAnnotation(TAnnotation annotation)
- {
- SyntaxAnnotation realAnnotation;
- if (!_realAnnotationMap.TryGetValue(annotation, out realAnnotation))
- {
- var id = Interlocked.Increment(ref _globalId);
- var idString = id.ToString();
-
- realAnnotation = new SyntaxAnnotation(_annotationKind, idString);
- _annotationMap.Add(idString, annotation);
- _realAnnotationMap.Add(annotation, realAnnotation);
- }
-
- return realAnnotation;
- }
-
- private IEnumerable<SyntaxAnnotation> GetRealAnnotations(TAnnotation[] annotations)
- {
- foreach (var annotation in annotations)
- {
- var realAnnotation = this.GetRealAnnotation(annotation);
- if (realAnnotation != null)
- {
- yield return realAnnotation;
- }
- }
- }
-
- private SyntaxAnnotation GetRealAnnotation(TAnnotation annotation)
- {
- SyntaxAnnotation realAnnotation;
- _realAnnotationMap.TryGetValue(annotation, out realAnnotation);
- return realAnnotation;
- }
-
- public TSyntaxNode WithAdditionalAnnotations<TSyntaxNode>(TSyntaxNode node, params TAnnotation[] annotations) where TSyntaxNode : SyntaxNode
- {
- return node.WithAdditionalAnnotations(this.GetOrCreateRealAnnotations(annotations).ToArray());
- }
-
- public SyntaxToken WithAdditionalAnnotations(SyntaxToken token, params TAnnotation[] annotations)
- {
- return token.WithAdditionalAnnotations(this.GetOrCreateRealAnnotations(annotations).ToArray());
- }
-
- public SyntaxTrivia WithAdditionalAnnotations(SyntaxTrivia trivia, params TAnnotation[] annotations)
- {
- return trivia.WithAdditionalAnnotations(this.GetOrCreateRealAnnotations(annotations).ToArray());
- }
-
- public SyntaxNodeOrToken WithAdditionalAnnotations(SyntaxNodeOrToken nodeOrToken, params TAnnotation[] annotations)
- {
- return nodeOrToken.WithAdditionalAnnotations(this.GetOrCreateRealAnnotations(annotations).ToArray());
- }
-
- public TSyntaxNode WithoutAnnotations<TSyntaxNode>(TSyntaxNode node, params TAnnotation[] annotations) where TSyntaxNode : SyntaxNode
- {
- return node.WithoutAnnotations(GetRealAnnotations(annotations).ToArray());
- }
-
- public SyntaxToken WithoutAnnotations(SyntaxToken token, params TAnnotation[] annotations)
- {
- return token.WithoutAnnotations(GetRealAnnotations(annotations).ToArray());
- }
-
- public SyntaxTrivia WithoutAnnotations(SyntaxTrivia trivia, params TAnnotation[] annotations)
- {
- return trivia.WithoutAnnotations(GetRealAnnotations(annotations).ToArray());
- }
-
- public SyntaxNodeOrToken WithoutAnnotations(SyntaxNodeOrToken nodeOrToken, params TAnnotation[] annotations)
- {
- return nodeOrToken.WithoutAnnotations(GetRealAnnotations(annotations).ToArray());
- }
-
- private IEnumerable<TAnnotation> GetAnnotations(IEnumerable<SyntaxAnnotation> realAnnotations)
- {
- foreach (var ra in realAnnotations)
- {
- TAnnotation annotation;
- if (_annotationMap.TryGetValue(ra.Data, out annotation))
- {
- yield return annotation;
- }
- }
- }
-
- public IEnumerable<TAnnotation> GetAnnotations(SyntaxNode node)
- {
- return GetAnnotations(node.GetAnnotations(_annotationKind));
- }
-
- public IEnumerable<TAnnotation> GetAnnotations(SyntaxToken token)
- {
- return GetAnnotations(token.GetAnnotations(_annotationKind));
- }
-
- public IEnumerable<TAnnotation> GetAnnotations(SyntaxTrivia trivia)
- {
- return GetAnnotations(trivia.GetAnnotations(_annotationKind));
- }
-
- public IEnumerable<TAnnotation> GetAnnotations(SyntaxNodeOrToken nodeOrToken)
- {
- return GetAnnotations(nodeOrToken.GetAnnotations(_annotationKind));
- }
-
- public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
- {
- return this.GetAnnotations(node).OfType<TSpecificAnnotation>();
- }
-
- public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxToken token) where TSpecificAnnotation : TAnnotation
- {
- return this.GetAnnotations(token).OfType<TSpecificAnnotation>();
- }
-
- public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxTrivia trivia) where TSpecificAnnotation : TAnnotation
- {
- return this.GetAnnotations(trivia).OfType<TSpecificAnnotation>();
- }
-
- public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxNodeOrToken nodeOrToken) where TSpecificAnnotation : TAnnotation
- {
- return this.GetAnnotations(nodeOrToken).OfType<TSpecificAnnotation>();
- }
-
- public bool HasAnnotations(SyntaxNode node)
- {
- return node.HasAnnotations(_annotationKind);
- }
-
- public bool HasAnnotations(SyntaxToken token)
- {
- return token.HasAnnotations(_annotationKind);
- }
-
- public bool HasAnnotations(SyntaxTrivia trivia)
- {
- return trivia.HasAnnotations(_annotationKind);
- }
-
- public bool HasAnnotations(SyntaxNodeOrToken nodeOrToken)
- {
- return nodeOrToken.HasAnnotations(_annotationKind);
- }
-
- public bool HasAnnotations<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
- {
- return this.GetAnnotations(node).OfType<TSpecificAnnotation>().Any();
- }
-
- public bool HasAnnotations<TSpecificAnnotation>(SyntaxToken token) where TSpecificAnnotation : TAnnotation
- {
- return this.GetAnnotations(token).OfType<TSpecificAnnotation>().Any();
- }
-
- public bool HasAnnotations<TSpecificAnnotation>(SyntaxTrivia trivia) where TSpecificAnnotation : TAnnotation
- {
- return this.GetAnnotations(trivia).OfType<TSpecificAnnotation>().Any();
- }
-
- public bool HasAnnotations<TSpecificAnnotation>(SyntaxNodeOrToken nodeOrToken) where TSpecificAnnotation : TAnnotation
- {
- return this.GetAnnotations(nodeOrToken).OfType<TSpecificAnnotation>().Any();
- }
-
- public bool HasAnnotation(SyntaxNode node, TAnnotation annotation)
- {
- return node.HasAnnotation(this.GetRealAnnotation(annotation));
- }
-
- public bool HasAnnotation(SyntaxToken token, TAnnotation annotation)
- {
- return token.HasAnnotation(this.GetRealAnnotation(annotation));
- }
-
- public bool HasAnnotation(SyntaxTrivia trivia, TAnnotation annotation)
- {
- return trivia.HasAnnotation(this.GetRealAnnotation(annotation));
- }
-
- public bool HasAnnotation(SyntaxNodeOrToken nodeOrToken, TAnnotation annotation)
- {
- return nodeOrToken.HasAnnotation(this.GetRealAnnotation(annotation));
- }
-
- public IEnumerable<SyntaxNodeOrToken> GetAnnotatedNodesAndTokens(SyntaxNode node)
- {
- return node.GetAnnotatedNodesAndTokens(_annotationKind);
- }
-
- public IEnumerable<SyntaxNode> GetAnnotatedNodes(SyntaxNode node)
- {
- return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(nt => nt.IsNode).Select(nt => nt.AsNode());
- }
-
- public IEnumerable<SyntaxToken> GetAnnotatedTokens(SyntaxNode node)
- {
- return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(nt => nt.IsToken).Select(nt => nt.AsToken());
- }
-
- public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(SyntaxNode node)
- {
- return node.GetAnnotatedTrivia(_annotationKind);
- }
-
- public IEnumerable<SyntaxNodeOrToken> GetAnnotatedNodesAndTokens<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
- {
- return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(HasAnnotations<TSpecificAnnotation>);
- }
-
- public IEnumerable<SyntaxNode> GetAnnotatedNodes<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
- {
- return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(nt => nt.IsNode && this.HasAnnotations<TSpecificAnnotation>(nt)).Select(nt => nt.AsNode());
- }
-
- public IEnumerable<SyntaxToken> GetAnnotatedTokens<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
- {
- return node.GetAnnotatedNodesAndTokens(_annotationKind).Where(nt => nt.IsToken && this.HasAnnotations<TSpecificAnnotation>(nt)).Select(nt => nt.AsToken());
- }
-
- public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
- {
- return node.GetAnnotatedTrivia(_annotationKind).Where(HasAnnotations<TSpecificAnnotation>);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/CSharpSemanticFactsService.cs b/main/src/addins/CSharpBinding/Util/CSharpSemanticFactsService.cs
deleted file mode 100644
index fdb3b22f72..0000000000
--- a/main/src/addins/CSharpBinding/Util/CSharpSemanticFactsService.cs
+++ /dev/null
@@ -1,270 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CSharpSemanticFactsService
- {
- public static bool SupportsImplicitInterfaceImplementation
- {
- get
- {
- return true;
- }
- }
-
- public static bool ExposesAnonymousFunctionParameterNames
- {
- get
- {
- return false;
- }
- }
-
- public static bool IsExpressionContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsExpressionContext(
- position,
- csharpModel.SyntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken),
- attributes: true, cancellationToken: cancellationToken, semanticModelOpt: csharpModel);
- }
-
- public static bool IsStatementContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsStatementContext(
- position, csharpModel.SyntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken), cancellationToken);
- }
-
- public static bool IsTypeContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsTypeContext(position, cancellationToken, csharpModel);
- }
-
- public static bool IsNamespaceContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsNamespaceContext(position, cancellationToken, csharpModel);
- }
-
- public static bool IsTypeDeclarationContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsTypeDeclarationContext(
- position, csharpModel.SyntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken), cancellationToken);
- }
-
- public static bool IsMemberDeclarationContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsMemberDeclarationContext(
- position, csharpModel.SyntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken), cancellationToken);
- }
-
- public static bool IsPreProcessorDirectiveContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsPreProcessorDirectiveContext(
- position, csharpModel.SyntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken, includeDirectives: true), cancellationToken);
- }
-
- public static bool IsGlobalStatementContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsGlobalStatementContext(position, cancellationToken);
- }
-
- public static bool IsLabelContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsLabelContext(position, cancellationToken);
- }
-
- public static bool IsAttributeNameContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var csharpModel = (SemanticModel)semanticModel;
- return csharpModel.SyntaxTree.IsAttributeNameContext(position, cancellationToken);
- }
-
- public static bool IsWrittenTo(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
- {
- return (node as ExpressionSyntax).IsWrittenTo();
- }
-
- public static bool IsOnlyWrittenTo(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
- {
- return (node as ExpressionSyntax).IsOnlyWrittenTo();
- }
-
- public static bool IsInOutContext(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
- {
- return (node as ExpressionSyntax).IsInOutContext();
- }
-
- public static bool IsInRefContext(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
- {
- return (node as ExpressionSyntax).IsInRefContext();
- }
-
- public static bool CanReplaceWithRValue(this SemanticModel semanticModel, SyntaxNode expression, CancellationToken cancellationToken)
- {
- return (expression as ExpressionSyntax).CanReplaceWithRValue(semanticModel, cancellationToken);
- }
-
- public static string GenerateNameForExpression(this SemanticModel semanticModel, SyntaxNode expression, bool capitalize = false)
- {
- return semanticModel.GenerateNameForExpression((ExpressionSyntax)expression, capitalize);
- }
-
- public static ISymbol GetDeclaredSymbol(this SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken)
- {
- var location = token.GetLocation();
- var q = from node in token.GetAncestors<SyntaxNode>()
- let symbol = semanticModel.GetDeclaredSymbol(node, cancellationToken)
- where symbol != null && symbol.Locations.Contains(location)
- select symbol;
-
- return q.FirstOrDefault();
- }
-
- public static bool LastEnumValueHasInitializer(INamedTypeSymbol namedTypeSymbol)
- {
- var enumDecl = namedTypeSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<EnumDeclarationSyntax>().FirstOrDefault();
- if (enumDecl != null)
- {
- var lastMember = enumDecl.Members.LastOrDefault();
- if (lastMember != null)
- {
- return lastMember.EqualsValue != null;
- }
- }
-
- return false;
- }
-
- public static bool SupportsParameterizedProperties
- {
- get
- {
- return false;
- }
- }
-
- public static bool SupportsParameterizedEvents
- {
- get
- {
- return true;
- }
- }
-
- public static bool TryGetSpeculativeSemanticModel(this SemanticModel oldSemanticModel, SyntaxNode oldNode, SyntaxNode newNode, out SemanticModel speculativeModel)
- {
- var model = oldSemanticModel;
-
- // currently we only support method. field support will be added later.
- var oldMethod = oldNode as BaseMethodDeclarationSyntax;
- var newMethod = newNode as BaseMethodDeclarationSyntax;
- if (oldMethod == null || newMethod == null || oldMethod.Body == null)
- {
- speculativeModel = null;
- return false;
- }
-
- SemanticModel csharpModel;
- bool success = model.TryGetSpeculativeSemanticModelForMethodBody(oldMethod.Body.OpenBraceToken.Span.End, newMethod, out csharpModel);
- speculativeModel = csharpModel;
- return success;
- }
-
-// public static ImmutableHashSet<string> GetAliasNameSet(this SemanticModel model, CancellationToken cancellationToken)
-// {
-// var original = (SemanticModel)model.GetOriginalSemanticModel();
-// if (!original.SyntaxTree.HasCompilationUnitRoot)
-// {
-// return ImmutableHashSet.Create<string>();
-// }
-//
-// var root = original.SyntaxTree.GetCompilationUnitRoot(cancellationToken);
-// var builder = ImmutableHashSet.CreateBuilder<string>(StringComparer.Ordinal);
-//
-// AppendAliasNames(root.Usings, builder);
-// AppendAliasNames(root.Members.OfType<NamespaceDeclarationSyntax>(), builder, cancellationToken);
-//
-// return builder.ToImmutable();
-// }
-//
-// private static void AppendAliasNames(SyntaxList<UsingDirectiveSyntax> usings, ImmutableHashSet<string>.Builder builder)
-// {
-// foreach (var @using in usings)
-// {
-// if (@using.Alias == null || @using.Alias.Name == null)
-// {
-// continue;
-// }
-//
-// @using.Alias.Name.Identifier.ValueText.AppendToAliasNameSet(builder);
-// }
-// }
-//
-// private void AppendAliasNames(IEnumerable<NamespaceDeclarationSyntax> namespaces, ImmutableHashSet<string>.Builder builder, CancellationToken cancellationToken)
-// {
-// foreach (var @namespace in namespaces)
-// {
-// cancellationToken.ThrowIfCancellationRequested();
-//
-// AppendAliasNames(@namespace.Usings, builder);
-// AppendAliasNames(@namespace.Members.OfType<NamespaceDeclarationSyntax>(), builder, cancellationToken);
-// }
-// }
-
-// public static ForEachSymbols GetForEachSymbols(this SemanticModel semanticModel, SyntaxNode forEachStatement)
-// {
-// var csforEachStatement = forEachStatement as ForEachStatementSyntax;
-// if (csforEachStatement != null)
-// {
-// var info = semanticModel.GetForEachStatementInfo(csforEachStatement);
-// return new ForEachSymbols(
-// info.GetEnumeratorMethod,
-// info.MoveNextMethod,
-// info.CurrentProperty,
-// info.DisposeMethod,
-// info.ElementType);
-// }
-// else
-// {
-// return default(ForEachSymbols);
-// }
-// }
-
- public static bool IsAssignableTo(ITypeSymbol fromSymbol, ITypeSymbol toSymbol, Compilation compilation)
- {
- return fromSymbol != null &&
- toSymbol != null &&
- ((CSharpCompilation)compilation).ClassifyConversion(fromSymbol, toSymbol).IsImplicit;
- }
-
- public static bool IsNameOfContext(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- return semanticModel.SyntaxTree.IsNameOfContext(position, semanticModel, cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/CSharpSyntaxContext.cs b/main/src/addins/CSharpBinding/Util/CSharpSyntaxContext.cs
deleted file mode 100644
index 5e9780f70d..0000000000
--- a/main/src/addins/CSharpBinding/Util/CSharpSyntaxContext.cs
+++ /dev/null
@@ -1,572 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Reflection;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class ReflectionNamespaces
- {
- public const string WorkspacesAsmName = ", Microsoft.CodeAnalysis.Workspaces";
- public const string CSWorkspacesAsmName = ", Microsoft.CodeAnalysis.CSharp.Workspaces";
- public const string CAAsmName = ", Microsoft.CodeAnalysis";
- public const string CACSharpAsmName = ", Microsoft.CodeAnalysis.CSharp";
- }
-
- class CSharpSyntaxContext
- {
- readonly static Type typeInfoCSharpSyntaxContext;
- readonly static Type typeInfoAbstractSyntaxContext;
- readonly static MethodInfo createContextMethod;
- readonly static PropertyInfo leftTokenProperty;
- readonly static PropertyInfo targetTokenProperty;
- readonly static FieldInfo isIsOrAsTypeContextField;
- readonly static FieldInfo isInstanceContextField;
- readonly static FieldInfo isNonAttributeExpressionContextField;
- readonly static FieldInfo isPreProcessorKeywordContextField;
- readonly static FieldInfo isPreProcessorExpressionContextField;
- readonly static FieldInfo containingTypeDeclarationField;
- readonly static FieldInfo isGlobalStatementContextField;
- readonly static FieldInfo isParameterTypeContextField;
- readonly static PropertyInfo syntaxTreeProperty;
-
-
- object instance;
-
- public SyntaxToken LeftToken {
- get {
- return (SyntaxToken)leftTokenProperty.GetValue (instance);
- }
- }
-
- public SyntaxToken TargetToken {
- get {
- return (SyntaxToken)targetTokenProperty.GetValue (instance);
- }
- }
-
- public bool IsIsOrAsTypeContext {
- get {
- return (bool)isIsOrAsTypeContextField.GetValue (instance);
- }
- }
-
- public bool IsInstanceContext {
- get {
- return (bool)isInstanceContextField.GetValue (instance);
- }
- }
-
- public bool IsNonAttributeExpressionContext {
- get {
- return (bool)isNonAttributeExpressionContextField.GetValue (instance);
- }
- }
-
- public bool IsPreProcessorKeywordContext {
- get {
- return (bool)isPreProcessorKeywordContextField.GetValue (instance);
- }
- }
-
- public bool IsPreProcessorExpressionContext {
- get {
- return (bool)isPreProcessorExpressionContextField.GetValue (instance);
- }
- }
-
- public TypeDeclarationSyntax ContainingTypeDeclaration {
- get {
- return (TypeDeclarationSyntax)containingTypeDeclarationField.GetValue (instance);
- }
- }
-
- public bool IsGlobalStatementContext {
- get {
- return (bool)isGlobalStatementContextField.GetValue (instance);
- }
- }
-
- public bool IsParameterTypeContext {
- get {
- return (bool)isParameterTypeContextField.GetValue (instance);
- }
- }
-
- public SyntaxTree SyntaxTree {
- get {
- return (SyntaxTree)syntaxTreeProperty.GetValue (instance);
- }
- }
-
-
- readonly static MethodInfo isMemberDeclarationContextMethod;
-
- public bool IsMemberDeclarationContext (
- ISet<SyntaxKind> validModifiers = null,
- ISet<SyntaxKind> validTypeDeclarations = null,
- bool canBePartial = false,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (bool)isMemberDeclarationContextMethod.Invoke (instance, new object[] {
- validModifiers,
- validTypeDeclarations,
- canBePartial,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- readonly static MethodInfo isTypeDeclarationContextMethod;
-
- public bool IsTypeDeclarationContext (
- ISet<SyntaxKind> validModifiers = null,
- ISet<SyntaxKind> validTypeDeclarations = null,
- bool canBePartial = false,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (bool)isTypeDeclarationContextMethod.Invoke (instance, new object[] {
- validModifiers,
- validTypeDeclarations,
- canBePartial,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- readonly static PropertyInfo isPreProcessorDirectiveContextProperty;
-
- public bool IsPreProcessorDirectiveContext {
- get {
- return (bool)isPreProcessorDirectiveContextProperty.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isInNonUserCodeField;
-
- public bool IsInNonUserCode {
- get {
- return (bool)isInNonUserCodeField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isIsOrAsContextField;
-
- public bool IsIsOrAsContext {
- get {
- return (bool)isIsOrAsContextField.GetValue (instance);
- }
- }
-
- readonly static MethodInfo isTypeAttributeContextMethod;
-
- public bool IsTypeAttributeContext (CancellationToken cancellationToken)
- {
- try {
- return (bool)isTypeAttributeContextMethod.Invoke (instance, new object[] { cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- readonly static PropertyInfo isAnyExpressionContextProperty;
-
- public bool IsAnyExpressionContext {
- get {
- return (bool)isAnyExpressionContextProperty.GetValue (instance);
- }
- }
-
- readonly static PropertyInfo isStatementContextProperty;
-
- public bool IsStatementContext {
- get {
- return (bool)isStatementContextProperty.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isDefiniteCastTypeContextField;
-
- public bool IsDefiniteCastTypeContext {
- get {
- return (bool)isDefiniteCastTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isObjectCreationTypeContextField;
-
- public bool IsObjectCreationTypeContext {
- get {
- return (bool)isObjectCreationTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isGenericTypeArgumentContextField;
-
- public bool IsGenericTypeArgumentContext {
- get {
- return (bool)isGenericTypeArgumentContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isLocalVariableDeclarationContextField;
-
- public bool IsLocalVariableDeclarationContext {
- get {
- return (bool)isLocalVariableDeclarationContextField.GetValue (instance);
- }
- }
-
-
- readonly static FieldInfo isFixedVariableDeclarationContextField;
-
- public bool IsFixedVariableDeclarationContext {
- get {
- return (bool)isFixedVariableDeclarationContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isPossibleLambdaOrAnonymousMethodParameterTypeContextField;
-
- public bool IsPossibleLambdaOrAnonymousMethodParameterTypeContext {
- get {
- return (bool)isPossibleLambdaOrAnonymousMethodParameterTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isImplicitOrExplicitOperatorTypeContextField;
-
- public bool IsImplicitOrExplicitOperatorTypeContext {
- get {
- return (bool)isImplicitOrExplicitOperatorTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isPrimaryFunctionExpressionContextField;
-
- public bool IsPrimaryFunctionExpressionContext {
- get {
- return (bool)isPrimaryFunctionExpressionContextField.GetValue (instance);
- }
- }
-
-
- readonly static FieldInfo isCrefContextField;
-
- public bool IsCrefContext {
- get {
- return (bool)isCrefContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isDelegateReturnTypeContextField;
-
- public bool IsDelegateReturnTypeContext {
- get {
- return (bool)isDelegateReturnTypeContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isEnumBaseListContextField;
-
- public bool IsEnumBaseListContext {
- get {
- return (bool)isEnumBaseListContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isConstantExpressionContextField;
-
- public bool IsConstantExpressionContext {
- get {
- return (bool)isConstantExpressionContextField.GetValue (instance);
- }
- }
-
- readonly static MethodInfo isMemberAttributeContextMethod;
- public bool IsMemberAttributeContext(ISet<SyntaxKind> validTypeDeclarations, CancellationToken cancellationToken)
- {
- try {
- return (bool)isMemberAttributeContextMethod.Invoke (instance, new object [] {
- validTypeDeclarations,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
-
- }
-
- readonly static FieldInfo precedingModifiersField;
-
- public ISet<SyntaxKind> PrecedingModifiers {
- get {
- return (ISet<SyntaxKind>)precedingModifiersField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo isTypeOfExpressionContextField;
-
- public bool IsTypeOfExpressionContext {
- get {
- return (bool)isTypeOfExpressionContextField.GetValue (instance);
- }
- }
-
- readonly static FieldInfo containingTypeOrEnumDeclarationField;
-
- public BaseTypeDeclarationSyntax ContainingTypeOrEnumDeclaration {
- get {
- return (BaseTypeDeclarationSyntax)containingTypeOrEnumDeclarationField.GetValue (instance);
- }
- }
- static readonly PropertyInfo isAttributeNameContextProperty;
-
- public bool IsAttributeNameContext {
- get {
- return (bool)isAttributeNameContextProperty.GetValue (instance);
- }
- }
-
- static readonly PropertyInfo isInQueryProperty;
- public bool IsInQuery {
- get {
- return (bool)isInQueryProperty.GetValue (instance);
- }
- }
-
-
- static CSharpSyntaxContext ()
- {
- typeInfoAbstractSyntaxContext = Type.GetType("Microsoft.CodeAnalysis.Shared.Extensions.ContextQuery.AbstractSyntaxContext" + ReflectionNamespaces.WorkspacesAsmName, true);
- typeInfoCSharpSyntaxContext = Type.GetType ("Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery.CSharpSyntaxContext" + ReflectionNamespaces.CSWorkspacesAsmName, true);
-
- createContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("CreateContext", BindingFlags.Static | BindingFlags.Public);
- leftTokenProperty = typeInfoAbstractSyntaxContext.GetProperty ("LeftToken");
- targetTokenProperty = typeInfoAbstractSyntaxContext.GetProperty ("TargetToken");
- isIsOrAsTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsIsOrAsTypeContext");
- isInstanceContextField = typeInfoCSharpSyntaxContext.GetField ("IsInstanceContext");
- isNonAttributeExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsNonAttributeExpressionContext");
- isPreProcessorKeywordContextField = typeInfoCSharpSyntaxContext.GetField ("IsPreProcessorKeywordContext");
- isPreProcessorExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsPreProcessorExpressionContext");
- containingTypeDeclarationField = typeInfoCSharpSyntaxContext.GetField ("ContainingTypeDeclaration");
- isGlobalStatementContextField = typeInfoCSharpSyntaxContext.GetField ("IsGlobalStatementContext");
- isParameterTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsParameterTypeContext");
- isMemberDeclarationContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("IsMemberDeclarationContext", BindingFlags.Instance | BindingFlags.Public);
- isTypeDeclarationContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("IsTypeDeclarationContext", BindingFlags.Instance | BindingFlags.Public);
- syntaxTreeProperty = typeInfoAbstractSyntaxContext.GetProperty ("SyntaxTree");
- isPreProcessorDirectiveContextProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsPreProcessorDirectiveContext");
- isInNonUserCodeField = typeInfoCSharpSyntaxContext.GetField ("IsInNonUserCode");
- isIsOrAsContextField = typeInfoCSharpSyntaxContext.GetField ("IsIsOrAsContext");
- isTypeAttributeContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("IsTypeAttributeContext", BindingFlags.Instance | BindingFlags.Public);
- isAnyExpressionContextProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsAnyExpressionContext");
- isStatementContextProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsStatementContext");
- isDefiniteCastTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsDefiniteCastTypeContext");
- isObjectCreationTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsObjectCreationTypeContext");
- isGenericTypeArgumentContextField = typeInfoCSharpSyntaxContext.GetField ("IsGenericTypeArgumentContext");
- isLocalVariableDeclarationContextField = typeInfoCSharpSyntaxContext.GetField ("IsLocalVariableDeclarationContext");
- isFixedVariableDeclarationContextField = typeInfoCSharpSyntaxContext.GetField ("IsFixedVariableDeclarationContext");
- isPossibleLambdaOrAnonymousMethodParameterTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsPossibleLambdaOrAnonymousMethodParameterTypeContext");
- isImplicitOrExplicitOperatorTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsImplicitOrExplicitOperatorTypeContext");
- isPrimaryFunctionExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsPrimaryFunctionExpressionContext");
- isCrefContextField = typeInfoCSharpSyntaxContext.GetField ("IsCrefContext");
- isDelegateReturnTypeContextField = typeInfoCSharpSyntaxContext.GetField ("IsDelegateReturnTypeContext");
- isEnumBaseListContextField = typeInfoCSharpSyntaxContext.GetField ("IsEnumBaseListContext");
- isConstantExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsConstantExpressionContext");
- isMemberAttributeContextMethod = typeInfoCSharpSyntaxContext.GetMethod ("IsMemberAttributeContext", BindingFlags.Instance | BindingFlags.Public);
- precedingModifiersField = typeInfoCSharpSyntaxContext.GetField ("PrecedingModifiers");
- isTypeOfExpressionContextField = typeInfoCSharpSyntaxContext.GetField ("IsTypeOfExpressionContext");
- containingTypeOrEnumDeclarationField = typeInfoCSharpSyntaxContext.GetField ("ContainingTypeOrEnumDeclaration");
-
- isAttributeNameContextProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsAttributeNameContext");
- isInQueryProperty = typeInfoAbstractSyntaxContext.GetProperty ("IsInQuery");
- }
-
- public SemanticModel SemanticModel {
- get;
- private set;
- }
-
- public int Position {
- get;
- private set;
- }
-
- CSharpSyntaxContext (object instance)
- {
- this.instance = instance;
- }
-
- public static CSharpSyntaxContext CreateContext (Workspace workspace, SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- try {
- return new CSharpSyntaxContext (createContextMethod.Invoke (null, new object[] {
- workspace,
- semanticModel,
- position,
- cancellationToken
- })) {
- SemanticModel = semanticModel,
- Position = position
- };
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-
- class CSharpTypeInferenceService
- {
- readonly static Type typeInfo;
- readonly static MethodInfo inferTypesMethod;
- readonly static MethodInfo inferTypes2Method;
- readonly object instance;
-
- static CSharpTypeInferenceService ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CSharp.CSharpTypeInferenceService" + ReflectionNamespaces.CSWorkspacesAsmName, true);
-
- inferTypesMethod = typeInfo.GetMethod ("InferTypes", new[] {
- typeof(SemanticModel),
- typeof(int),
- typeof(CancellationToken)
- });
- inferTypes2Method = typeInfo.GetMethod ("InferTypes", new[] {
- typeof(SemanticModel),
- typeof(SyntaxNode),
- typeof(CancellationToken)
- });
- }
-
- public CSharpTypeInferenceService ()
- {
- instance = Activator.CreateInstance (typeInfo);
- }
-
- public IEnumerable<ITypeSymbol> InferTypes (SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- try {
- return (IEnumerable<ITypeSymbol>)inferTypesMethod.Invoke (instance, new object[] {
- semanticModel,
- position,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public IEnumerable<ITypeSymbol> InferTypes (SemanticModel semanticModel, SyntaxNode expression, CancellationToken cancellationToken)
- {
- try {
- return (IEnumerable<ITypeSymbol>)inferTypes2Method.Invoke (instance, new object[] {
- semanticModel,
- expression,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- public ITypeSymbol InferType(
- SemanticModel semanticModel,
- SyntaxNode expression,
- bool objectAsDefault,
- CancellationToken cancellationToken)
- {
- var types = InferTypes(semanticModel, expression, cancellationToken)
- .WhereNotNull();
-
- if (!types.Any())
- {
- return objectAsDefault ? semanticModel.Compilation.ObjectType : null;
- }
-
- return types.FirstOrDefault();
- }
-
-
- public INamedTypeSymbol InferDelegateType(
- SemanticModel semanticModel,
- SyntaxNode expression,
- CancellationToken cancellationToken)
- {
- var type = this.InferType(semanticModel, expression, objectAsDefault: false, cancellationToken: cancellationToken);
- return type.GetDelegateType(semanticModel.Compilation);
- }
-
-
- public ITypeSymbol InferType(
- SemanticModel semanticModel,
- int position,
- bool objectAsDefault,
- CancellationToken cancellationToken)
- {
- var types = this.InferTypes(semanticModel, position, cancellationToken)
- .WhereNotNull();
-
- if (!types.Any())
- {
- return objectAsDefault ? semanticModel.Compilation.ObjectType : null;
- }
-
- return types.FirstOrDefault();
- }
-
- }
-
- class CaseCorrector
- {
- readonly static Type typeInfo;
- readonly static MethodInfo caseCorrectAsyncMethod;
-
- static CaseCorrector ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CaseCorrection.CaseCorrector" + ReflectionNamespaces.WorkspacesAsmName, true);
-
- Annotation = (SyntaxAnnotation)typeInfo.GetField ("Annotation", BindingFlags.Public | BindingFlags.Static).GetValue (null);
-
- caseCorrectAsyncMethod = typeInfo.GetMethod ("CaseCorrectAsync", new[] {
- typeof(Document),
- typeof(SyntaxAnnotation),
- typeof(CancellationToken)
- });
- }
-
- public static readonly SyntaxAnnotation Annotation;
-
- public static Task<Document> CaseCorrectAsync (Document document, SyntaxAnnotation annotation, CancellationToken cancellationToken)
- {
- try {
- return (Task<Document>)caseCorrectAsyncMethod.Invoke (null, new object[] { document, annotation, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-
-
-}
diff --git a/main/src/addins/CSharpBinding/Util/CSharpSyntaxFactsService.cs b/main/src/addins/CSharpBinding/Util/CSharpSyntaxFactsService.cs
deleted file mode 100644
index 1e14ae518a..0000000000
--- a/main/src/addins/CSharpBinding/Util/CSharpSyntaxFactsService.cs
+++ /dev/null
@@ -1,1040 +0,0 @@
-//
-// CSharpSyntaxFactsService.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Diagnostics;
-using System.Text;
-using System.Collections.Generic;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CSharpSyntaxFactsService
- {
- public static bool IsAwaitKeyword (this SyntaxToken token)
- {
- return token.IsKind (SyntaxKind.AwaitKeyword);
- }
-
- public static bool IsIdentifier (this SyntaxToken token)
- {
- return token.IsKind (SyntaxKind.IdentifierToken);
- }
-
- public static bool IsGlobalNamespaceKeyword (this SyntaxToken token)
- {
- return token.IsKind (SyntaxKind.GlobalKeyword);
- }
-
- public static bool IsVerbatimIdentifier (this SyntaxToken token)
- {
- return token.IsKind (SyntaxKind.IdentifierToken) && token.Text.Length > 0 && token.Text [0] == '@';
- }
-
- public static bool IsOperator (this SyntaxToken token)
- {
- var kind = token.Kind ();
-
- return
- (SyntaxFacts.IsAnyUnaryExpression (kind) &&
- (token.Parent is PrefixUnaryExpressionSyntax || token.Parent is PostfixUnaryExpressionSyntax)) ||
- (SyntaxFacts.IsBinaryExpression (kind) && token.Parent is BinaryExpressionSyntax) ||
- (SyntaxFacts.IsAssignmentExpressionOperatorToken (kind) && token.Parent is AssignmentExpressionSyntax);
- }
-
- public static bool IsKeyword (this SyntaxToken token)
- {
- var kind = (SyntaxKind)token.RawKind;
- return
- SyntaxFacts.IsKeywordKind (kind); // both contextual and reserved keywords
- }
- //
- // public bool IsContextualKeyword(SyntaxToken token)
- // {
- // var kind = (SyntaxKind)token.RawKind;
- // return
- // SyntaxFacts.IsContextualKeyword(kind);
- // }
- //
- // public bool IsPreprocessorKeyword(SyntaxToken token)
- // {
- // var kind = (SyntaxKind)token.RawKind;
- // return
- // SyntaxFacts.IsPreprocessorKeyword(kind);
- // }
- //
- // public bool IsHashToken(SyntaxToken token)
- // {
- // return (SyntaxKind)token.RawKind == SyntaxKind.HashToken;
- // }
- //
- // public bool IsInInactiveRegion(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- // {
- // var csharpTree = syntaxTree as SyntaxTree;
- // if (csharpTree == null)
- // {
- // return false;
- // }
- //
- // return csharpTree.IsInInactiveRegion(position, cancellationToken);
- // }
- //
- // public bool IsInNonUserCode(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- // {
- // var csharpTree = syntaxTree as SyntaxTree;
- // if (csharpTree == null)
- // {
- // return false;
- // }
- //
- // return csharpTree.IsInNonUserCode(position, cancellationToken);
- // }
- //
- // public bool IsEntirelyWithinStringOrCharLiteral(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- // {
- // var csharpTree = syntaxTree as SyntaxTree;
- // if (csharpTree == null)
- // {
- // return false;
- // }
- //
- // return csharpTree.IsEntirelyWithinStringOrCharLiteral(position, cancellationToken);
- // }
- //
- // public bool IsDirective(SyntaxNode node)
- // {
- // return node is DirectiveTriviaSyntax;
- // }
- //
- // public bool TryGetExternalSourceInfo(SyntaxNode node, out ExternalSourceInfo info)
- // {
- // var lineDirective = node as LineDirectiveTriviaSyntax;
- // if (lineDirective != null)
- // {
- // if (lineDirective.Line.Kind() == SyntaxKind.DefaultKeyword)
- // {
- // info = new ExternalSourceInfo(null, ends: true);
- // return true;
- // }
- // else if (lineDirective.Line.Kind() == SyntaxKind.NumericLiteralToken &&
- // lineDirective.Line.Value is int)
- // {
- // info = new ExternalSourceInfo((int)lineDirective.Line.Value, false);
- // return true;
- // }
- // }
- //
- // info = default(ExternalSourceInfo);
- // return false;
- // }
-
- public static bool IsRightSideOfQualifiedName (this SyntaxNode node)
- {
- var name = node as SimpleNameSyntax;
- return name.IsRightSideOfQualifiedName ();
- }
-
- public static bool IsMemberAccessExpressionName (this SyntaxNode node)
- {
- var name = node as SimpleNameSyntax;
- return name.IsMemberAccessExpressionName ();
- }
-
- public static bool IsObjectCreationExpressionType (this SyntaxNode node)
- {
- return node.IsParentKind (SyntaxKind.ObjectCreationExpression) &&
- ((ObjectCreationExpressionSyntax)node.Parent).Type == node;
- }
-
- public static bool IsAttributeName (this SyntaxNode node)
- {
- return SyntaxFacts.IsAttributeName (node);
- }
-
- // public bool IsInvocationExpression(SyntaxNode node)
- // {
- // return node is InvocationExpressionSyntax;
- // }
- //
- // public bool IsAnonymousFunction(SyntaxNode node)
- // {
- // return node is ParenthesizedLambdaExpressionSyntax ||
- // node is SimpleLambdaExpressionSyntax ||
- // node is AnonymousMethodExpressionSyntax;
- // }
- //
- // public bool IsGenericName(SyntaxNode node)
- // {
- // return node is GenericNameSyntax;
- // }
-
- public static bool IsNamedParameter (this SyntaxNode node)
- {
- return node.CheckParent<NameColonSyntax> (p => p.Name == node);
- }
-
- // public bool IsSkippedTokensTrivia(SyntaxNode node)
- // {
- // return node is SkippedTokensTriviaSyntax;
- // }
-
- public static bool HasIncompleteParentMember (this SyntaxNode node)
- {
- return node.IsParentKind (SyntaxKind.IncompleteMember);
- }
-
- // public SyntaxToken GetIdentifierOfGenericName(SyntaxNode genericName)
- // {
- // var csharpGenericName = genericName as GenericNameSyntax;
- // return csharpGenericName != null
- // ? csharpGenericName.Identifier
- // : default(SyntaxToken);
- // }
- //
- // public bool IsCaseSensitive
- // {
- // get
- // {
- // return true;
- // }
- // }
- //
- // public bool IsUsingDirectiveName(SyntaxNode node)
- // {
- // return
- // node.IsParentKind(SyntaxKind.UsingDirective) &&
- // ((UsingDirectiveSyntax)node.Parent).Name == node;
- // }
- //
- // public bool IsForEachStatement(SyntaxNode node)
- // {
- // return node is ForEachStatementSyntax;
- // }
- //
- // public bool IsLockStatement(SyntaxNode node)
- // {
- // return node is LockStatementSyntax;
- // }
- //
- // public bool IsUsingStatement(SyntaxNode node)
- // {
- // return node is UsingStatementSyntax;
- // }
- //
- // public bool IsThisConstructorInitializer(SyntaxToken token)
- // {
- // return token.Parent.IsKind(SyntaxKind.ThisConstructorInitializer) &&
- // ((ConstructorInitializerSyntax)token.Parent).ThisOrBaseKeyword == token;
- // }
- //
- // public bool IsBaseConstructorInitializer(SyntaxToken token)
- // {
- // return token.Parent.IsKind(SyntaxKind.BaseConstructorInitializer) &&
- // ((ConstructorInitializerSyntax)token.Parent).ThisOrBaseKeyword == token;
- // }
- //
- // public bool IsQueryExpression(SyntaxNode node)
- // {
- // return node is QueryExpressionSyntax;
- // }
- //
- // public bool IsPredefinedType(SyntaxToken token)
- // {
- // PredefinedType actualType;
- // return TryGetPredefinedType(token, out actualType) && actualType != PredefinedType.None;
- // }
- //
- // public bool IsPredefinedType(SyntaxToken token, PredefinedType type)
- // {
- // PredefinedType actualType;
- // return TryGetPredefinedType(token, out actualType) && actualType == type;
- // }
- //
- // public bool TryGetPredefinedType(SyntaxToken token, out PredefinedType type)
- // {
- // type = GetPredefinedType(token);
- // return type != PredefinedType.None;
- // }
- //
- // private PredefinedType GetPredefinedType(SyntaxToken token)
- // {
- // switch ((SyntaxKind)token.RawKind)
- // {
- // case SyntaxKind.BoolKeyword:
- // return PredefinedType.Boolean;
- // case SyntaxKind.ByteKeyword:
- // return PredefinedType.Byte;
- // case SyntaxKind.SByteKeyword:
- // return PredefinedType.SByte;
- // case SyntaxKind.IntKeyword:
- // return PredefinedType.Int32;
- // case SyntaxKind.UIntKeyword:
- // return PredefinedType.UInt32;
- // case SyntaxKind.ShortKeyword:
- // return PredefinedType.Int16;
- // case SyntaxKind.UShortKeyword:
- // return PredefinedType.UInt16;
- // case SyntaxKind.LongKeyword:
- // return PredefinedType.Int64;
- // case SyntaxKind.ULongKeyword:
- // return PredefinedType.UInt64;
- // case SyntaxKind.FloatKeyword:
- // return PredefinedType.Single;
- // case SyntaxKind.DoubleKeyword:
- // return PredefinedType.Double;
- // case SyntaxKind.DecimalKeyword:
- // return PredefinedType.Decimal;
- // case SyntaxKind.StringKeyword:
- // return PredefinedType.String;
- // case SyntaxKind.CharKeyword:
- // return PredefinedType.Char;
- // case SyntaxKind.ObjectKeyword:
- // return PredefinedType.Object;
- // case SyntaxKind.VoidKeyword:
- // return PredefinedType.Void;
- // default:
- // return PredefinedType.None;
- // }
- // }
- //
- // public bool IsPredefinedOperator(SyntaxToken token)
- // {
- // PredefinedOperator actualOperator;
- // return TryGetPredefinedOperator(token, out actualOperator) && actualOperator != PredefinedOperator.None;
- // }
- //
- // public bool IsPredefinedOperator(SyntaxToken token, PredefinedOperator op)
- // {
- // PredefinedOperator actualOperator;
- // return TryGetPredefinedOperator(token, out actualOperator) && actualOperator == op;
- // }
- //
- // public bool TryGetPredefinedOperator(SyntaxToken token, out PredefinedOperator op)
- // {
- // op = GetPredefinedOperator(token);
- // return op != PredefinedOperator.None;
- // }
- //
- // private PredefinedOperator GetPredefinedOperator(SyntaxToken token)
- // {
- // switch ((SyntaxKind)token.RawKind)
- // {
- // case SyntaxKind.PlusToken:
- // case SyntaxKind.PlusEqualsToken:
- // return PredefinedOperator.Addition;
- //
- // case SyntaxKind.MinusToken:
- // case SyntaxKind.MinusEqualsToken:
- // return PredefinedOperator.Subtraction;
- //
- // case SyntaxKind.AmpersandToken:
- // case SyntaxKind.AmpersandEqualsToken:
- // return PredefinedOperator.BitwiseAnd;
- //
- // case SyntaxKind.BarToken:
- // case SyntaxKind.BarEqualsToken:
- // return PredefinedOperator.BitwiseOr;
- //
- // case SyntaxKind.MinusMinusToken:
- // return PredefinedOperator.Decrement;
- //
- // case SyntaxKind.PlusPlusToken:
- // return PredefinedOperator.Increment;
- //
- // case SyntaxKind.SlashToken:
- // case SyntaxKind.SlashEqualsToken:
- // return PredefinedOperator.Division;
- //
- // case SyntaxKind.EqualsEqualsToken:
- // return PredefinedOperator.Equality;
- //
- // case SyntaxKind.CaretToken:
- // case SyntaxKind.CaretEqualsToken:
- // return PredefinedOperator.ExclusiveOr;
- //
- // case SyntaxKind.GreaterThanToken:
- // return PredefinedOperator.GreaterThan;
- //
- // case SyntaxKind.GreaterThanEqualsToken:
- // return PredefinedOperator.GreaterThanOrEqual;
- //
- // case SyntaxKind.ExclamationEqualsToken:
- // return PredefinedOperator.Inequality;
- //
- // case SyntaxKind.LessThanLessThanToken:
- // case SyntaxKind.LessThanLessThanEqualsToken:
- // return PredefinedOperator.LeftShift;
- //
- // case SyntaxKind.LessThanEqualsToken:
- // return PredefinedOperator.LessThanOrEqual;
- //
- // case SyntaxKind.AsteriskToken:
- // case SyntaxKind.AsteriskEqualsToken:
- // return PredefinedOperator.Multiplication;
- //
- // case SyntaxKind.PercentToken:
- // case SyntaxKind.PercentEqualsToken:
- // return PredefinedOperator.Modulus;
- //
- // case SyntaxKind.ExclamationToken:
- // case SyntaxKind.TildeToken:
- // return PredefinedOperator.Complement;
- //
- // case SyntaxKind.GreaterThanGreaterThanToken:
- // case SyntaxKind.GreaterThanGreaterThanEqualsToken:
- // return PredefinedOperator.RightShift;
- // }
- //
- // return PredefinedOperator.None;
- // }
- //
- // public string GetText(int kind)
- // {
- // return SyntaxFacts.GetText((SyntaxKind)kind);
- // }
- //
- // public bool IsIdentifierStartCharacter(char c)
- // {
- // return SyntaxFacts.IsIdentifierStartCharacter(c);
- // }
- //
- // public bool IsIdentifierPartCharacter(char c)
- // {
- // return SyntaxFacts.IsIdentifierPartCharacter(c);
- // }
- //
- // public bool IsIdentifierEscapeCharacter(char c)
- // {
- // return c == '@';
- // }
- //
- // public bool IsValidIdentifier(string identifier)
- // {
- // var token = SyntaxFactory.ParseToken(identifier);
- // return IsIdentifier(token) && !token.ContainsDiagnostics && token.ToString().Length == identifier.Length;
- // }
- //
- // public bool IsVerbatimIdentifier(string identifier)
- // {
- // var token = SyntaxFactory.ParseToken(identifier);
- // return IsIdentifier(token) && !token.ContainsDiagnostics && token.ToString().Length == identifier.Length && token.IsVerbatimIdentifier();
- // }
- //
- // public bool IsTypeCharacter(char c)
- // {
- // return false;
- // }
- //
- // public bool IsStartOfUnicodeEscapeSequence(char c)
- // {
- // return c == '\\';
- // }
- //
- // public bool IsLiteral(SyntaxToken token)
- // {
- // switch (token.Kind())
- // {
- // case SyntaxKind.NumericLiteralToken:
- // case SyntaxKind.CharacterLiteralToken:
- // case SyntaxKind.StringLiteralToken:
- // case SyntaxKind.NullKeyword:
- // case SyntaxKind.TrueKeyword:
- // case SyntaxKind.FalseKeyword:
- // return true;
- // }
- //
- // return false;
- // }
- //
- // public bool IsStringLiteral(SyntaxToken token)
- // {
- // return token.IsKind(SyntaxKind.StringLiteralToken);
- // }
- //
- // public bool IsTypeNamedVarInVariableOrFieldDeclaration(SyntaxToken token, SyntaxNode parent)
- // {
- // var typedToken = token;
- // var typedParent = parent;
- //
- // if (typedParent.IsKind(SyntaxKind.IdentifierName))
- // {
- // TypeSyntax declaredType = null;
- // if (typedParent.IsParentKind(SyntaxKind.VariableDeclaration))
- // {
- // declaredType = ((VariableDeclarationSyntax)typedParent.Parent).Type;
- // }
- // else if (typedParent.IsParentKind(SyntaxKind.FieldDeclaration))
- // {
- // declaredType = ((FieldDeclarationSyntax)typedParent.Parent).Declaration.Type;
- // }
- //
- // return declaredType == typedParent && typedToken.ValueText == "var";
- // }
- //
- // return false;
- // }
- //
- // public bool IsTypeNamedDynamic(SyntaxToken token, SyntaxNode parent)
- // {
- // var typedParent = parent as ExpressionSyntax;
- //
- // if (typedParent != null)
- // {
- // if (SyntaxFacts.IsInTypeOnlyContext(typedParent) &&
- // typedParent.IsKind(SyntaxKind.IdentifierName) &&
- // token.ValueText == "dynamic")
- // {
- // return true;
- // }
- // }
- //
- // return false;
- // }
- //
- // public bool IsBindableToken(SyntaxToken token)
- // {
- // if (this.IsWord(token) || this.IsLiteral(token) || this.IsOperator(token))
- // {
- // switch ((SyntaxKind)token.RawKind)
- // {
- // case SyntaxKind.DelegateKeyword:
- // case SyntaxKind.VoidKeyword:
- // return false;
- // }
- //
- // return true;
- // }
- //
- // return false;
- // }
-
- public static bool IsMemberAccessExpression (this SyntaxNode node)
- {
- return node is MemberAccessExpressionSyntax &&
- ((MemberAccessExpressionSyntax)node).Kind () == SyntaxKind.SimpleMemberAccessExpression;
- }
-
- public static bool IsConditionalMemberAccessExpression (this SyntaxNode node)
- {
- return node is ConditionalAccessExpressionSyntax;
- }
-
- public static bool IsPointerMemberAccessExpression (this SyntaxNode node)
- {
- return node is MemberAccessExpressionSyntax &&
- ((MemberAccessExpressionSyntax)node).Kind () == SyntaxKind.PointerMemberAccessExpression;
- }
-
- public static void GetNameAndArityOfSimpleName (this SyntaxNode node, out string name, out int arity)
- {
- name = null;
- arity = 0;
-
- var simpleName = node as SimpleNameSyntax;
- if (simpleName != null) {
- name = simpleName.Identifier.ValueText;
- arity = simpleName.Arity;
- }
- }
-
- public static SyntaxNode GetExpressionOfMemberAccessExpression (this SyntaxNode node)
- {
- if (node.IsKind (SyntaxKind.MemberBindingExpression)) {
- if (node.IsParentKind (SyntaxKind.ConditionalAccessExpression)) {
- return GetExpressionOfConditionalMemberAccessExpression (node.Parent);
- }
- if (node.IsParentKind (SyntaxKind.InvocationExpression) &&
- node.Parent.IsParentKind (SyntaxKind.ConditionalAccessExpression)) {
- return GetExpressionOfConditionalMemberAccessExpression (node.Parent.Parent);
- }
- }
-
- return (node as MemberAccessExpressionSyntax)?.Expression;
- }
-
- public static SyntaxNode GetExpressionOfConditionalMemberAccessExpression (this SyntaxNode node)
- {
- return (node as ConditionalAccessExpressionSyntax)?.Expression;
- }
-
-
- public static bool IsInNamespaceOrTypeContext (this SyntaxNode node)
- {
- return SyntaxFacts.IsInNamespaceOrTypeContext (node as ExpressionSyntax);
- }
-
- public static SyntaxNode GetExpressionOfArgument (this SyntaxNode node)
- {
- return ((ArgumentSyntax)node).Expression;
- }
-
- public static RefKind GetRefKindOfArgument (this SyntaxNode node)
- {
- return (node as ArgumentSyntax).GetRefKind ();
- }
-
- public static bool IsInConstantContext (this SyntaxNode node)
- {
- return (node as ExpressionSyntax).IsInConstantContext ();
- }
-
- public static bool IsInConstructor (this SyntaxNode node)
- {
- return node.GetAncestor<ConstructorDeclarationSyntax> () != null;
- }
-
- // public bool IsUnsafeContext(SyntaxNode node)
- // {
- // return node.IsUnsafeContext();
- // }
-
- public static SyntaxNode GetNameOfAttribute (this SyntaxNode node)
- {
- return ((AttributeSyntax)node).Name;
- }
-
- public static bool IsAttribute (this SyntaxNode node)
- {
- return node is AttributeSyntax;
- }
-
- public static bool IsAttributeNamedArgumentIdentifier (this SyntaxNode node)
- {
- var identifier = node as IdentifierNameSyntax;
- return
- identifier != null &&
- identifier.IsParentKind (SyntaxKind.NameEquals) &&
- identifier.Parent.IsParentKind (SyntaxKind.AttributeArgument);
- }
-
- public static SyntaxNode GetContainingTypeDeclaration (this SyntaxNode root, int position)
- {
- if (root == null) {
- throw new ArgumentNullException ("root");
- }
-
- if (position < 0 || position > root.Span.End) {
- throw new ArgumentOutOfRangeException ("position");
- }
-
- return root
- .FindToken (position)
- .GetAncestors<SyntaxNode> ()
- .FirstOrDefault (n => n is BaseTypeDeclarationSyntax || n is DelegateDeclarationSyntax);
- }
- //
- // public SyntaxNode GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode node)
- // {
- // throw ExceptionUtilities.Unreachable;
- // }
- //
- // public SyntaxToken FindTokenOnLeftOfPosition(
- // SyntaxNode node, int position, bool includeSkipped, bool includeDirectives, bool includeDocumentationComments)
- // {
- // return node.FindTokenOnLeftOfPosition(position, includeSkipped, includeDirectives, includeDocumentationComments);
- // }
- //
- // public SyntaxToken FindTokenOnRightOfPosition(
- // SyntaxNode node, int position, bool includeSkipped, bool includeDirectives, bool includeDocumentationComments)
- // {
- // return node.FindTokenOnRightOfPosition(position, includeSkipped, includeDirectives, includeDocumentationComments);
- // }
-
- public static bool IsObjectCreationExpression (this SyntaxNode node)
- {
- return node is ObjectCreationExpressionSyntax;
- }
-
- public static bool IsObjectInitializerNamedAssignmentIdentifier (this SyntaxNode node)
- {
- var identifier = node as IdentifierNameSyntax;
- return
- identifier != null &&
- identifier.IsLeftSideOfAssignExpression () &&
- identifier.Parent.IsParentKind (SyntaxKind.ObjectInitializerExpression);
- }
-
- public static bool IsElementAccessExpression (this SyntaxNode node)
- {
- return node.Kind () == SyntaxKind.ElementAccessExpression;
- }
-
- // public SyntaxToken ToIdentifierToken(string name)
- // {
- // return name.ToIdentifierToken();
- // }
-
- public static SyntaxNode Parenthesize (this SyntaxNode expression, bool includeElasticTrivia = true)
- {
- return ((ExpressionSyntax)expression).Parenthesize (includeElasticTrivia);
- }
-
- // public bool IsIndexerMemberCRef(SyntaxNode node)
- // {
- // return node.Kind() == SyntaxKind.IndexerMemberCref;
- // }
- //
- // public SyntaxNode GetContainingMemberDeclaration(SyntaxNode root, int position)
- // {
- // Contract.ThrowIfNull(root, "root");
- // Contract.ThrowIfTrue(position < 0 || position > root.FullSpan.End, "position");
- //
- // var end = root.FullSpan.End;
- // if (end == 0)
- // {
- // // empty file
- // return null;
- // }
- //
- // // make sure position doesn't touch end of root
- // position = Math.Min(position, end - 1);
- //
- // var node = root.FindToken(position).Parent;
- // while (node != null)
- // {
- // if (node is MemberDeclarationSyntax)
- // {
- // return node;
- // }
- //
- // node = node.Parent;
- // }
- //
- // return null;
- // }
- //
- // public bool IsMethodLevelMember(SyntaxNode node)
- // {
- // return node is BaseMethodDeclarationSyntax || node is BasePropertyDeclarationSyntax || node is EnumMemberDeclarationSyntax || node is BaseFieldDeclarationSyntax;
- // }
- //
- // public bool IsTopLevelNodeWithMembers(SyntaxNode node)
- // {
- // return node is NamespaceDeclarationSyntax ||
- // node is TypeDeclarationSyntax ||
- // node is EnumDeclarationSyntax;
- // }
- //
-
-
- public static bool DescentIntoSymbolForDeclarationSearch (SyntaxNode node)
- {
- var b = !(node is BlockSyntax);
- return b;
- }
-
-
- //
- // public List<SyntaxNode> GetMethodLevelMembers(SyntaxNode root)
- // {
- // var list = new List<SyntaxNode>();
- // AppendMethodLevelMembers(root, list);
- // return list;
- // }
- //
- // private void AppendMethodLevelMembers(SyntaxNode node, List<SyntaxNode> list)
- // {
- // foreach (var member in node.GetMembers())
- // {
- // if (IsTopLevelNodeWithMembers(member))
- // {
- // AppendMethodLevelMembers(member, list);
- // continue;
- // }
- //
- // if (IsMethodLevelMember(member))
- // {
- // list.Add(member);
- // }
- // }
- // }
- //
- // public TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node)
- // {
- // if (node.Span.IsEmpty)
- // {
- // return default(TextSpan);
- // }
- //
- // var member = GetContainingMemberDeclaration(node, node.SpanStart);
- // if (member == null)
- // {
- // return default(TextSpan);
- // }
- //
- // // TODO: currently we only support method for now
- // var method = member as BaseMethodDeclarationSyntax;
- // if (method != null)
- // {
- // if (method.Body == null)
- // {
- // return default(TextSpan);
- // }
- //
- // return GetBlockBodySpan(method.Body);
- // }
- //
- // return default(TextSpan);
- // }
- //
- // public bool ContainsInMemberBody(SyntaxNode node, TextSpan span)
- // {
- // var constructor = node as ConstructorDeclarationSyntax;
- // if (constructor != null)
- // {
- // return (constructor.Body != null && GetBlockBodySpan(constructor.Body).Contains(span)) ||
- // (constructor.Initializer != null && constructor.Initializer.Span.Contains(span));
- // }
- //
- // var method = node as BaseMethodDeclarationSyntax;
- // if (method != null)
- // {
- // return method.Body != null && GetBlockBodySpan(method.Body).Contains(span);
- // }
- //
- // var property = node as BasePropertyDeclarationSyntax;
- // if (property != null)
- // {
- // return property.AccessorList != null && property.AccessorList.Span.Contains(span);
- // }
- //
- // var @enum = node as EnumMemberDeclarationSyntax;
- // if (@enum != null)
- // {
- // return @enum.EqualsValue != null && @enum.EqualsValue.Span.Contains(span);
- // }
- //
- // var field = node as BaseFieldDeclarationSyntax;
- // if (field != null)
- // {
- // return field.Declaration != null && field.Declaration.Span.Contains(span);
- // }
- //
- // return false;
- // }
- //
- // private TextSpan GetBlockBodySpan(BlockSyntax body)
- // {
- // return TextSpan.FromBounds(body.OpenBraceToken.Span.End, body.CloseBraceToken.SpanStart);
- // }
- //
- // public int GetMethodLevelMemberId(SyntaxNode root, SyntaxNode node)
- // {
- // Contract.Requires(root.SyntaxTree == node.SyntaxTree);
- //
- // int currentId = 0;
- // SyntaxNode currentNode;
- // Contract.ThrowIfFalse(TryGetMethodLevelMember(root, (n, i) => n == node, ref currentId, out currentNode));
- //
- // Contract.ThrowIfFalse(currentId >= 0);
- // CheckMemberId(root, node, currentId);
- // return currentId;
- // }
- //
- // public SyntaxNode GetMethodLevelMember(SyntaxNode root, int memberId)
- // {
- // int currentId = 0;
- // SyntaxNode currentNode;
- // if (!TryGetMethodLevelMember(root, (n, i) => i == memberId, ref currentId, out currentNode))
- // {
- // return null;
- // }
- //
- // Contract.ThrowIfNull(currentNode);
- // CheckMemberId(root, currentNode, memberId);
- // return currentNode;
- // }
- //
- // private bool TryGetMethodLevelMember(
- // SyntaxNode node, Func<SyntaxNode, int, bool> predicate, ref int currentId, out SyntaxNode currentNode)
- // {
- // foreach (var member in node.GetMembers())
- // {
- // if (IsTopLevelNodeWithMembers(member))
- // {
- // if (TryGetMethodLevelMember(member, predicate, ref currentId, out currentNode))
- // {
- // return true;
- // }
- //
- // continue;
- // }
- //
- // if (IsMethodLevelMember(member))
- // {
- // if (predicate(member, currentId))
- // {
- // currentNode = member;
- // return true;
- // }
- //
- // currentId++;
- // }
- // }
- //
- // currentNode = null;
- // return false;
- // }
- //
- // [Conditional("DEBUG")]
- // private void CheckMemberId(SyntaxNode root, SyntaxNode node, int memberId)
- // {
- // var list = GetMethodLevelMembers(root);
- // var index = list.IndexOf(node);
- //
- // Contract.ThrowIfFalse(index == memberId);
- // }
- //
- // public SyntaxNode GetBindableParent(SyntaxToken token)
- // {
- // var node = token.Parent;
- // while (node != null)
- // {
- // var parent = node.Parent;
- //
- // // If this node is on the left side of a member access expression, don't ascend
- // // further or we'll end up binding to something else.
- // var memberAccess = parent as MemberAccessExpressionSyntax;
- // if (memberAccess != null)
- // {
- // if (memberAccess.Expression == node)
- // {
- // break;
- // }
- // }
- //
- // // If this node is on the left side of a qualified name, don't ascend
- // // further or we'll end up binding to something else.
- // var qualifiedName = parent as QualifiedNameSyntax;
- // if (qualifiedName != null)
- // {
- // if (qualifiedName.Left == node)
- // {
- // break;
- // }
- // }
- //
- // // If this node is on the left side of a alias-qualified name, don't ascend
- // // further or we'll end up binding to something else.
- // var aliasQualifiedName = parent as AliasQualifiedNameSyntax;
- // if (aliasQualifiedName != null)
- // {
- // if (aliasQualifiedName.Alias == node)
- // {
- // break;
- // }
- // }
- //
- // // If this node is the type of an object creation expression, return the
- // // object creation expression.
- // var objectCreation = parent as ObjectCreationExpressionSyntax;
- // if (objectCreation != null)
- // {
- // if (objectCreation.Type == node)
- // {
- // node = parent;
- // break;
- // }
- // }
- //
- // // If this node is not parented by a name, we're done.
- // var name = parent as NameSyntax;
- // if (name == null)
- // {
- // break;
- // }
- //
- // node = parent;
- // }
- //
- // return node;
- // }
- //
- // public IEnumerable<SyntaxNode> GetConstructors(SyntaxNode root, CancellationToken cancellationToken)
- // {
- // var compilationUnit = root as CompilationUnitSyntax;
- // if (compilationUnit == null)
- // {
- // return SpecializedCollections.EmptyEnumerable<SyntaxNode>();
- // }
- //
- // var constructors = new List<SyntaxNode>();
- // AppendConstructors(compilationUnit.Members, constructors, cancellationToken);
- // return constructors;
- // }
- //
- // private void AppendConstructors(SyntaxList<MemberDeclarationSyntax> members, List<SyntaxNode> constructors, CancellationToken cancellationToken)
- // {
- // foreach (var member in members)
- // {
- // cancellationToken.ThrowIfCancellationRequested();
- //
- // var constructor = member as ConstructorDeclarationSyntax;
- // if (constructor != null)
- // {
- // constructors.Add(constructor);
- // continue;
- // }
- //
- // var @namespace = member as NamespaceDeclarationSyntax;
- // if (@namespace != null)
- // {
- // AppendConstructors(@namespace.Members, constructors, cancellationToken);
- // }
- //
- // var @class = member as ClassDeclarationSyntax;
- // if (@class != null)
- // {
- // AppendConstructors(@class.Members, constructors, cancellationToken);
- // }
- //
- // var @struct = member as StructDeclarationSyntax;
- // if (@struct != null)
- // {
- // AppendConstructors(@struct.Members, constructors, cancellationToken);
- // }
- // }
- // }
- //
- // public bool TryGetCorrespondingOpenBrace(SyntaxToken token, out SyntaxToken openBrace)
- // {
- // if (token.Kind() == SyntaxKind.CloseBraceToken)
- // {
- // var tuple = token.Parent.GetBraces();
- //
- // openBrace = tuple.Item1;
- // return openBrace.Kind() == SyntaxKind.OpenBraceToken;
- // }
- //
- // openBrace = default(SyntaxToken);
- // return false;
- // }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/CSharpUtil.cs b/main/src/addins/CSharpBinding/Util/CSharpUtil.cs
index 1784f099cf..1d5bbcd9c6 100644
--- a/main/src/addins/CSharpBinding/Util/CSharpUtil.cs
+++ b/main/src/addins/CSharpBinding/Util/CSharpUtil.cs
@@ -23,11 +23,13 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.Shared.Extensions;
namespace ICSharpCode.NRefactory6.CSharp
{
@@ -37,72 +39,72 @@ namespace ICSharpCode.NRefactory6.CSharp
/// Inverts a boolean condition. Note: The condition object can be frozen (from AST) it's cloned internally.
/// </summary>
/// <param name="condition">The condition to invert.</param>
- public static ExpressionSyntax InvertCondition(ExpressionSyntax condition)
+ public static ExpressionSyntax InvertCondition (ExpressionSyntax condition)
{
- return InvertConditionInternal(condition);
+ return InvertConditionInternal (condition);
}
-
- static ExpressionSyntax InvertConditionInternal(ExpressionSyntax condition)
+
+ static ExpressionSyntax InvertConditionInternal (ExpressionSyntax condition)
{
if (condition is ParenthesizedExpressionSyntax) {
- return SyntaxFactory.ParenthesizedExpression(InvertCondition(((ParenthesizedExpressionSyntax)condition).Expression));
+ return SyntaxFactory.ParenthesizedExpression (InvertCondition (((ParenthesizedExpressionSyntax)condition).Expression));
}
if (condition is PrefixUnaryExpressionSyntax) {
var uOp = (PrefixUnaryExpressionSyntax)condition;
- if (uOp.IsKind(SyntaxKind.LogicalNotExpression)) {
+ if (uOp.IsKind (SyntaxKind.LogicalNotExpression)) {
if (!(uOp.Parent is ExpressionSyntax))
- return uOp.Operand.SkipParens();
+ return uOp.Operand.SkipParens ();
return uOp.Operand;
}
- return SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, uOp);
+ return SyntaxFactory.PrefixUnaryExpression (SyntaxKind.LogicalNotExpression, uOp);
}
-
+
if (condition is BinaryExpressionSyntax) {
var bOp = (BinaryExpressionSyntax)condition;
- if (bOp.IsKind(SyntaxKind.LogicalAndExpression) || bOp.IsKind(SyntaxKind.LogicalOrExpression))
- return SyntaxFactory.BinaryExpression(NegateConditionOperator(bOp.Kind()), InvertCondition(bOp.Left), InvertCondition(bOp.Right));
+ if (bOp.IsKind (SyntaxKind.LogicalAndExpression) || bOp.IsKind (SyntaxKind.LogicalOrExpression))
+ return SyntaxFactory.BinaryExpression (NegateConditionOperator (bOp.Kind ()), InvertCondition (bOp.Left), InvertCondition (bOp.Right));
- if (bOp.IsKind(SyntaxKind.EqualsExpression) ||
- bOp.IsKind(SyntaxKind.NotEqualsExpression) ||
- bOp.IsKind(SyntaxKind.GreaterThanExpression) ||
- bOp.IsKind(SyntaxKind.GreaterThanOrEqualExpression) ||
- bOp.IsKind(SyntaxKind.LessThanExpression) ||
- bOp.IsKind(SyntaxKind.LessThanOrEqualExpression))
- return SyntaxFactory.BinaryExpression(NegateRelationalOperator(bOp.Kind()), bOp.Left, bOp.Right);
+ if (bOp.IsKind (SyntaxKind.EqualsExpression) ||
+ bOp.IsKind (SyntaxKind.NotEqualsExpression) ||
+ bOp.IsKind (SyntaxKind.GreaterThanExpression) ||
+ bOp.IsKind (SyntaxKind.GreaterThanOrEqualExpression) ||
+ bOp.IsKind (SyntaxKind.LessThanExpression) ||
+ bOp.IsKind (SyntaxKind.LessThanOrEqualExpression))
+ return SyntaxFactory.BinaryExpression (NegateRelationalOperator (bOp.Kind ()), bOp.Left, bOp.Right);
- return SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, SyntaxFactory.ParenthesizedExpression(condition));
+ return SyntaxFactory.PrefixUnaryExpression (SyntaxKind.LogicalNotExpression, SyntaxFactory.ParenthesizedExpression (condition));
}
if (condition is ConditionalExpressionSyntax) {
var cEx = condition as ConditionalExpressionSyntax;
- return cEx.WithCondition(InvertCondition(cEx.Condition));
+ return cEx.WithCondition (InvertCondition (cEx.Condition));
}
if (condition is LiteralExpressionSyntax) {
- if (condition.Kind() == SyntaxKind.TrueLiteralExpression)
- return SyntaxFactory.LiteralExpression(SyntaxKind.FalseLiteralExpression);
- if (condition.Kind() == SyntaxKind.FalseLiteralExpression)
- return SyntaxFactory.LiteralExpression(SyntaxKind.TrueLiteralExpression);
+ if (condition.Kind () == SyntaxKind.TrueLiteralExpression)
+ return SyntaxFactory.LiteralExpression (SyntaxKind.FalseLiteralExpression);
+ if (condition.Kind () == SyntaxKind.FalseLiteralExpression)
+ return SyntaxFactory.LiteralExpression (SyntaxKind.TrueLiteralExpression);
}
- return SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, AddParensForUnaryExpressionIfRequired(condition));
+ return SyntaxFactory.PrefixUnaryExpression (SyntaxKind.LogicalNotExpression, AddParensForUnaryExpressionIfRequired (condition));
}
/// <summary>
/// When negating an expression this is required, otherwise you would end up with
/// a or b -> !a or b
/// </summary>
- public static ExpressionSyntax AddParensForUnaryExpressionIfRequired(ExpressionSyntax expression)
+ public static ExpressionSyntax AddParensForUnaryExpressionIfRequired (ExpressionSyntax expression)
{
if ((expression is BinaryExpressionSyntax) ||
- (expression is AssignmentExpressionSyntax) ||
+ (expression is AssignmentExpressionSyntax) ||
(expression is CastExpressionSyntax) ||
(expression is ParenthesizedLambdaExpressionSyntax) ||
(expression is SimpleLambdaExpressionSyntax) ||
(expression is ConditionalExpressionSyntax)) {
- return SyntaxFactory.ParenthesizedExpression(expression);
+ return SyntaxFactory.ParenthesizedExpression (expression);
}
return expression;
@@ -114,44 +116,44 @@ namespace ICSharpCode.NRefactory6.CSharp
/// <returns>
/// negation of the specified relational operator, or BinaryOperatorType.Any if it's not a relational operator
/// </returns>
- public static SyntaxKind NegateRelationalOperator(SyntaxKind op)
+ public static SyntaxKind NegateRelationalOperator (SyntaxKind op)
{
switch (op) {
- case SyntaxKind.EqualsExpression:
- return SyntaxKind.NotEqualsExpression;
- case SyntaxKind.NotEqualsExpression:
- return SyntaxKind.EqualsExpression;
- case SyntaxKind.GreaterThanExpression:
- return SyntaxKind.LessThanOrEqualExpression;
- case SyntaxKind.GreaterThanOrEqualExpression:
- return SyntaxKind.LessThanExpression;
- case SyntaxKind.LessThanExpression:
- return SyntaxKind.GreaterThanOrEqualExpression;
- case SyntaxKind.LessThanOrEqualExpression:
- return SyntaxKind.GreaterThanExpression;
- case SyntaxKind.LogicalOrExpression:
- return SyntaxKind.LogicalAndExpression;
- case SyntaxKind.LogicalAndExpression:
- return SyntaxKind.LogicalOrExpression;
+ case SyntaxKind.EqualsExpression:
+ return SyntaxKind.NotEqualsExpression;
+ case SyntaxKind.NotEqualsExpression:
+ return SyntaxKind.EqualsExpression;
+ case SyntaxKind.GreaterThanExpression:
+ return SyntaxKind.LessThanOrEqualExpression;
+ case SyntaxKind.GreaterThanOrEqualExpression:
+ return SyntaxKind.LessThanExpression;
+ case SyntaxKind.LessThanExpression:
+ return SyntaxKind.GreaterThanOrEqualExpression;
+ case SyntaxKind.LessThanOrEqualExpression:
+ return SyntaxKind.GreaterThanExpression;
+ case SyntaxKind.LogicalOrExpression:
+ return SyntaxKind.LogicalAndExpression;
+ case SyntaxKind.LogicalAndExpression:
+ return SyntaxKind.LogicalOrExpression;
}
- throw new ArgumentOutOfRangeException("op");
+ throw new ArgumentOutOfRangeException ("op");
}
/// <summary>
/// Returns true, if the specified operator is a relational operator
/// </summary>
- public static bool IsRelationalOperator(SyntaxKind op)
+ public static bool IsRelationalOperator (SyntaxKind op)
{
switch (op) {
- case SyntaxKind.EqualsExpression:
- case SyntaxKind.NotEqualsExpression:
- case SyntaxKind.GreaterThanExpression:
- case SyntaxKind.GreaterThanOrEqualExpression:
- case SyntaxKind.LessThanExpression:
- case SyntaxKind.LessThanOrEqualExpression:
- case SyntaxKind.LogicalOrExpression:
- case SyntaxKind.LogicalAndExpression:
- return true;
+ case SyntaxKind.EqualsExpression:
+ case SyntaxKind.NotEqualsExpression:
+ case SyntaxKind.GreaterThanExpression:
+ case SyntaxKind.GreaterThanOrEqualExpression:
+ case SyntaxKind.LessThanExpression:
+ case SyntaxKind.LessThanOrEqualExpression:
+ case SyntaxKind.LogicalOrExpression:
+ case SyntaxKind.LogicalAndExpression:
+ return true;
}
return false;
}
@@ -162,22 +164,22 @@ namespace ICSharpCode.NRefactory6.CSharp
/// <returns>
/// negation of the specified condition operator, or BinaryOperatorType.Any if it's not a condition operator
/// </returns>
- public static SyntaxKind NegateConditionOperator(SyntaxKind op)
+ public static SyntaxKind NegateConditionOperator (SyntaxKind op)
{
switch (op) {
- case SyntaxKind.LogicalOrExpression:
- return SyntaxKind.LogicalAndExpression;
- case SyntaxKind.LogicalAndExpression:
- return SyntaxKind.LogicalOrExpression;
+ case SyntaxKind.LogicalOrExpression:
+ return SyntaxKind.LogicalAndExpression;
+ case SyntaxKind.LogicalAndExpression:
+ return SyntaxKind.LogicalOrExpression;
}
- throw new ArgumentOutOfRangeException("op");
+ throw new ArgumentOutOfRangeException ("op");
}
-
- public static bool AreConditionsEqual(ExpressionSyntax cond1, ExpressionSyntax cond2)
+
+ public static bool AreConditionsEqual (ExpressionSyntax cond1, ExpressionSyntax cond2)
{
if (cond1 == null || cond2 == null)
return false;
- return cond1.SkipParens().IsEquivalentTo(cond2.SkipParens(), true);
+ return cond1.SkipParens ().IsEquivalentTo (cond2.SkipParens (), true);
}
}
} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/Util/CastExpressionSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/CastExpressionSyntaxExtensions.cs
deleted file mode 100644
index 62daf3ab81..0000000000
--- a/main/src/addins/CSharpBinding/Util/CastExpressionSyntaxExtensions.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using System;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CastExpressionSyntaxExtensions
- {
- readonly static MethodInfo isUnnecessaryCastMethod;
-
- static CastExpressionSyntaxExtensions ()
- {
- var typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CSharp.Extensions.CastExpressionSyntaxExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- isUnnecessaryCastMethod = typeInfo.GetMethod ("IsUnnecessaryCast", BindingFlags.Static | BindingFlags.Public);
- }
-
- public static bool IsUnnecessaryCast(this CastExpressionSyntax cast, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- try {
- return (bool)isUnnecessaryCastMethod.Invoke (null, new object[] { cast, semanticModel, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/CodeFixContextExtensions.cs b/main/src/addins/CSharpBinding/Util/CodeFixContextExtensions.cs
deleted file mode 100644
index 824b169071..0000000000
--- a/main/src/addins/CSharpBinding/Util/CodeFixContextExtensions.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using Microsoft.CodeAnalysis.CodeFixes;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using System.Collections.Immutable;
-using Microsoft.CodeAnalysis.CodeActions;
-
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CodeFixContextExtensions
- {
- /// <summary>
- /// Use this helper to register multiple fixes (<paramref name="actions"/>) each of which addresses / fixes the same supplied <paramref name="diagnostic"/>.
- /// </summary>
- public static void RegisterFixes(this CodeFixContext context, IEnumerable<CodeAction> actions, Diagnostic diagnostic)
- {
- foreach (var action in actions)
- {
- context.RegisterCodeFix(action, diagnostic);
- }
- }
-
- /// <summary>
- /// Use this helper to register multiple fixes (<paramref name="actions"/>) each of which addresses / fixes the same set of supplied <paramref name="diagnostics"/>.
- /// </summary>
- public static void RegisterFixes(this CodeFixContext context, IEnumerable<CodeAction> actions, ImmutableArray<Diagnostic> diagnostics)
- {
- foreach (var action in actions)
- {
- context.RegisterCodeFix(action, diagnostics);
- }
- }
- }
-
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/CodeGenerationSymbolFactory.cs b/main/src/addins/CSharpBinding/Util/CodeGenerationSymbolFactory.cs
deleted file mode 100644
index a81ad838af..0000000000
--- a/main/src/addins/CSharpBinding/Util/CodeGenerationSymbolFactory.cs
+++ /dev/null
@@ -1,466 +0,0 @@
-//
-// CodeGenerationSymbolFactory.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Reflection;
-using Microsoft.CodeAnalysis;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using Microsoft.CodeAnalysis.Editing;
-using System.Runtime.ExceptionServices;
-
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- /// <summary>
- /// Generates symbols that describe declarations to be generated.
- /// </summary>
- static class CodeGenerationSymbolFactory
- {
- readonly static Type typeInfo;
-
- static CodeGenerationSymbolFactory ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationSymbolFactory" + ReflectionNamespaces.WorkspacesAsmName, true);
-
- isCodeGenerationSymbolMethod = typeInfo.GetMethod ("IsCodeGenerationSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(ISymbol) }, null);
- if (isCodeGenerationSymbolMethod == null)
- throw new InvalidOperationException ("IsCodeGenerationSymbol not found.");
-
- createParameterSymbolMethod = typeInfo.GetMethods ().First (m => m.Name == "CreateParameterSymbol" && m.GetParameters ().Length == 8);
-
- createTypeParameterSymbolMethod = typeInfo.GetMethod ("CreateTypeParameterSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(string), typeof(int) }, null);
- if (createTypeParameterSymbolMethod == null)
- throw new InvalidOperationException ("CreateTypeParameterSymbol not found.");
-
- createTypeParameterMethod = typeInfo.GetMethod ("CreateTypeParameter", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(IList<AttributeData>), typeof(VarianceKind), typeof(string), typeof(ImmutableArray<ITypeSymbol>), typeof(bool), typeof(bool), typeof(bool), typeof(int) }, null);
- if (createTypeParameterMethod == null)
- throw new InvalidOperationException ("CreateTypeParameter not found.");
-
- createMethodSymbolMethod = typeInfo.GetMethod ("CreateMethodSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(IList<AttributeData>), typeof(Accessibility), typeof(DeclarationModifiers), typeof(ITypeSymbol), typeof(IMethodSymbol), typeof(string), typeof(IList<ITypeParameterSymbol>), typeof(IList<IParameterSymbol>), typeof(IList<SyntaxNode>), typeof(IList<SyntaxNode>), typeof(IList<AttributeData>), typeof(MethodKind) }, null);
- if (createMethodSymbolMethod == null)
- throw new InvalidOperationException ("CreateMethodSymbol not found.");
-
- createMethodSymbolMethod2 = typeInfo.GetMethod ("CreateMethodSymbol", BindingFlags.Static | BindingFlags.NonPublic, null, new [] { typeof(INamedTypeSymbol), typeof(IList<AttributeData>), typeof(Accessibility), typeof(DeclarationModifiers), typeof(ITypeSymbol), typeof(IMethodSymbol) , typeof(string), typeof(IList<ITypeParameterSymbol>), typeof(IList<IParameterSymbol>), typeof(IList<SyntaxNode>), typeof(IList<SyntaxNode>), typeof(IList<AttributeData>), typeof(MethodKind) }, null);
- if (createMethodSymbolMethod2 == null)
- throw new InvalidOperationException ("CreateMethodSymbol not found.");
-
- createConstructorSymbolMethod = typeInfo.GetMethod ("CreateConstructorSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(IList<AttributeData>), typeof(Accessibility), typeof(DeclarationModifiers), typeof(string), typeof(IList<IParameterSymbol>), typeof(IList<SyntaxNode>), typeof(IList<SyntaxNode>), typeof(IList<SyntaxNode>) }, null);
- if (createConstructorSymbolMethod == null)
- throw new InvalidOperationException ("CreateConstructorSymbol not found.");
-
-
- createAccessorSymbolMethod = typeInfo.GetMethod ("CreateAccessorSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(IList<AttributeData>), typeof(Accessibility), typeof(IList<SyntaxNode>) }, null);
- if (createAccessorSymbolMethod == null)
- throw new InvalidOperationException ("CreateAccessorSymbol not found.");
-
- createPropertySymbolMethod = typeInfo.GetMethod ("CreatePropertySymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(IList<AttributeData>), typeof(Accessibility), typeof(DeclarationModifiers), typeof(ITypeSymbol), typeof(IPropertySymbol), typeof(string), typeof(IList<IParameterSymbol>), typeof(IMethodSymbol), typeof(IMethodSymbol), typeof(bool) }, null);
- if (createPropertySymbolMethod == null)
- throw new InvalidOperationException ("CreatePropertySymbol not found.");
-
- createFieldSymbolMethod = typeInfo.GetMethod ("CreateFieldSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(IList<AttributeData>), typeof(Accessibility), typeof(DeclarationModifiers), typeof(ITypeSymbol), typeof(string), typeof(bool), typeof(object), typeof(SyntaxNode) }, null);
- if (createFieldSymbolMethod == null)
- throw new InvalidOperationException ("CreateFieldSymbol not found.");
-
- createPointerTypeSymbolMethod = typeInfo.GetMethod ("CreatePointerTypeSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(ITypeSymbol) }, null);
- if (createPointerTypeSymbolMethod == null)
- throw new InvalidOperationException ("CreatePointerTypeSymbol not found.");
-
- createArrayTypeSymbolMethod = typeInfo.GetMethod ("CreateArrayTypeSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(ITypeSymbol), typeof(int) }, null);
- if (createArrayTypeSymbolMethod == null)
- throw new InvalidOperationException ("CreateArrayTypeSymbol not found.");
-
- createNamespaceSymbolMethod = typeInfo.GetMethod ("CreateNamespaceSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(string), typeof(IList<ISymbol>), typeof(IList<INamespaceOrTypeSymbol>) }, null);
- if (createNamespaceSymbolMethod == null)
- throw new InvalidOperationException ("CreateNamespaceSymbol not found.");
-
- createNamedTypeSymbolMethod = typeInfo.GetMethod ("CreateNamedTypeSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(IList<AttributeData>), typeof(Accessibility), typeof(DeclarationModifiers), typeof(TypeKind), typeof(string), typeof(IList<ITypeParameterSymbol>), typeof(INamedTypeSymbol), typeof(IList<INamedTypeSymbol>), typeof(SpecialType), typeof(IList<ISymbol>) }, null);
- if (createNamedTypeSymbolMethod == null)
- throw new InvalidOperationException ("CreateNamedTypeSymbol not found.");
-
- createDelegateTypeSymbolMethod = typeInfo.GetMethod ("CreateDelegateTypeSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(IList<AttributeData>), typeof(Accessibility), typeof(DeclarationModifiers), typeof(ITypeSymbol), typeof(string), typeof(IList<ITypeParameterSymbol>), typeof(IList<IParameterSymbol>) }, null);
- if (createDelegateTypeSymbolMethod == null)
- throw new InvalidOperationException ("CreateDelegateTypeSymbol not found.");
-
- createAttributeDataMethod = typeInfo.GetMethod ("CreateAttributeData", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(INamedTypeSymbol), typeof(ImmutableArray<TypedConstant>), typeof(ImmutableArray<KeyValuePair<string, TypedConstant>>) }, null);
- if (createAttributeDataMethod == null)
- throw new InvalidOperationException ("CreateAttributeData not found.");
-
- createEventSymbol = typeInfo.GetMethod ("CreateEventSymbol", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(IList<AttributeData>), typeof(Accessibility), typeof(DeclarationModifiers), typeof(ITypeSymbol), typeof(IEventSymbol), typeof(string), typeof(IMethodSymbol), typeof(IMethodSymbol), typeof(IMethodSymbol), typeof(IList<IParameterSymbol>) }, null);
- if (createEventSymbol == null)
- throw new InvalidOperationException ("CreateEventSymbol not found.");
-
- createPropertySymbolMethod2 = typeInfo.GetMethod ("CreatePropertySymbol", BindingFlags.Static | BindingFlags.NonPublic, null, new [] {
- typeof(INamedTypeSymbol),
- typeof(IList<AttributeData>),
- typeof(Accessibility),
- typeof(DeclarationModifiers),
- typeof(ITypeSymbol),
- typeof(IPropertySymbol),
- typeof(string),
- typeof(IList<IParameterSymbol>),
- typeof(IMethodSymbol),
- typeof(IMethodSymbol),
- typeof(bool),
- typeof(SyntaxNode)
- }, null);
- if (createPropertySymbolMethod2 == null)
- throw new InvalidOperationException ("CreatePropertySymbol2 not found.");
-
- }
-
- static MethodInfo createPropertySymbolMethod2;
-
- public static IPropertySymbol CreatePropertySymbol(
- INamedTypeSymbol containingType,
- IList<AttributeData> attributes,
- Accessibility accessibility,
- DeclarationModifiers modifiers,
- ITypeSymbol type,
- IPropertySymbol explicitInterfaceSymbol,
- string name,
- IList<IParameterSymbol> parameters,
- IMethodSymbol getMethod,
- IMethodSymbol setMethod,
- bool isIndexer = false,
- SyntaxNode initializer = null)
- {
- try {
- return (IPropertySymbol)createPropertySymbolMethod2.Invoke (null, new object[] { containingType,
- attributes,
- accessibility,
- modifiers,
- type,
- explicitInterfaceSymbol,
- name,
- parameters,
- getMethod,
- setMethod,
- isIndexer,
- initializer
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- static MethodInfo createEventSymbol;
-
- public static IEventSymbol CreateEventSymbol(IList<AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, ITypeSymbol type, IEventSymbol explicitInterfaceSymbol, string name, IMethodSymbol addMethod = null, IMethodSymbol removeMethod = null, IMethodSymbol raiseMethod = null, IList<IParameterSymbol> parameterList = null)
- {
- try {
- return (IEventSymbol)createEventSymbol.Invoke (null, new object[] { attributes, accessibility, modifiers, type, explicitInterfaceSymbol, name, addMethod, removeMethod, raiseMethod, parameterList });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public static IEventSymbol CreateEventSymbol(
- IEventSymbol @event,
- IList<AttributeData> attributes = null,
- Accessibility? accessibility = null,
- DeclarationModifiers? modifiers = null,
- IEventSymbol explicitInterfaceSymbol = null,
- string name = null,
- IMethodSymbol addMethod = null,
- IMethodSymbol removeMethod = null)
- {
- return CodeGenerationSymbolFactory.CreateEventSymbol(
- attributes,
- accessibility ?? @event.DeclaredAccessibility,
- modifiers ?? @event.GetSymbolModifiers(),
- @event.Type,
- explicitInterfaceSymbol,
- name ?? @event.Name,
- addMethod,
- removeMethod);
- }
-
- public static IMethodSymbol CreateMethodSymbol(
- IMethodSymbol method,
- IList<AttributeData> attributes = null,
- Accessibility? accessibility = null,
- DeclarationModifiers? modifiers = null,
- IMethodSymbol explicitInterfaceSymbol = null,
- string name = null,
- IList<SyntaxNode> statements = null)
- {
- return CodeGenerationSymbolFactory.CreateMethodSymbol(
- attributes,
- accessibility ?? method.DeclaredAccessibility,
- modifiers ?? method.GetSymbolModifiers(),
- method.ReturnType,
- explicitInterfaceSymbol,
- name ?? method.Name,
- method.TypeParameters,
- method.Parameters,
- statements,
- returnTypeAttributes: method.GetReturnTypeAttributes());
- }
-
- public static IPropertySymbol CreatePropertySymbol(
- IPropertySymbol property,
- IList<AttributeData> attributes = null,
- Accessibility? accessibility = null,
- DeclarationModifiers? modifiers = null,
- IPropertySymbol explicitInterfaceSymbol = null,
- string name = null,
- bool? isIndexer = null,
- IMethodSymbol getMethod = null,
- IMethodSymbol setMethod = null)
- {
- return CodeGenerationSymbolFactory.CreatePropertySymbol(
- attributes,
- accessibility ?? property.DeclaredAccessibility,
- modifiers ?? property.GetSymbolModifiers(),
- property.Type,
- explicitInterfaceSymbol,
- name ?? property.Name,
- property.Parameters,
- getMethod,
- setMethod,
- isIndexer ?? property.IsIndexer);
- }
-
- public static IMethodSymbol CreateAccessorSymbol(
- IMethodSymbol accessor,
- IList<AttributeData> attributes = null,
- Accessibility? accessibility = null,
- IMethodSymbol explicitInterfaceSymbol = null,
- IList<SyntaxNode> statements = null)
- {
- return CodeGenerationSymbolFactory.CreateMethodSymbol(
- attributes,
- accessibility ?? accessor.DeclaredAccessibility,
- accessor.GetSymbolModifiers().WithIsAbstract(statements == null),
- accessor.ReturnType,
- explicitInterfaceSymbol ?? accessor.ExplicitInterfaceImplementations.FirstOrDefault(),
- accessor.Name,
- accessor.TypeParameters,
- accessor.Parameters,
- statements,
- returnTypeAttributes: accessor.GetReturnTypeAttributes());
- }
-
-
- static MethodInfo createAttributeDataMethod;
-
- public static AttributeData CreateAttributeData(
- INamedTypeSymbol attributeClass,
- ImmutableArray<TypedConstant> constructorArguments = default(ImmutableArray<TypedConstant>),
- ImmutableArray<KeyValuePair<string, TypedConstant>> namedArguments = default(ImmutableArray<KeyValuePair<string, TypedConstant>>))
- {
- try {
- return (AttributeData)createAttributeDataMethod.Invoke (null, new object[] { attributeClass, constructorArguments, namedArguments });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createNamedTypeSymbolMethod;
- public static INamedTypeSymbol CreateNamedTypeSymbol(IList<AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, TypeKind typeKind, string name, IList<ITypeParameterSymbol> typeParameters = null, INamedTypeSymbol baseType = null, IList<INamedTypeSymbol> interfaces = null, SpecialType specialType = SpecialType.None, IList<ISymbol> members = null)
- {
- try {
- return (INamedTypeSymbol)createNamedTypeSymbolMethod.Invoke (null, new object[] { attributes, accessibility, modifiers, typeKind, name, typeParameters, baseType, interfaces, specialType, members });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createDelegateTypeSymbolMethod;
- public static INamedTypeSymbol CreateDelegateTypeSymbol(IList<AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, ITypeSymbol returnType, string name, IList<ITypeParameterSymbol> typeParameters = null, IList<IParameterSymbol> parameters = null)
- {
- try {
- return (INamedTypeSymbol)createDelegateTypeSymbolMethod.Invoke (null, new object[] { attributes, accessibility, modifiers, returnType, name, typeParameters, parameters });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createNamespaceSymbolMethod;
-
- public static INamespaceSymbol CreateNamespaceSymbol(string name, IList<ISymbol> imports = null, IList<INamespaceOrTypeSymbol> members = null)
- {
- try {
- return (INamespaceSymbol)createNamespaceSymbolMethod.Invoke (null, new object[] { name, imports, members });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static readonly MethodInfo isCodeGenerationSymbolMethod;
- /// <summary>
- /// Determines if the symbol is purely a code generation symbol.
- /// </summary>
- public static bool IsCodeGenerationSymbol(this ISymbol symbol)
- {
- try {
- return (bool)isCodeGenerationSymbolMethod.Invoke (null, new object[] { symbol });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- static readonly MethodInfo createParameterSymbolMethod;
- public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
- {
- return CreateParameterSymbol(attributes: null, refKind: RefKind.None, isParams: false, type: type, name: name, isOptional: false);
- }
-
- public static IParameterSymbol CreateParameterSymbol(IList<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object defaultValue = null)
- {
- try {
- return (IParameterSymbol)createParameterSymbolMethod.Invoke (null, new object[] { attributes, refKind, isParams, type, name, isOptional, hasDefaultValue, defaultValue });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static readonly MethodInfo createTypeParameterSymbolMethod;
- public static ITypeParameterSymbol CreateTypeParameterSymbol(string name, int ordinal = 0)
- {
- try {
- return (ITypeParameterSymbol)createTypeParameterSymbolMethod.Invoke (null, new object[] { name, ordinal });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createTypeParameterMethod;
- public static ITypeParameterSymbol CreateTypeParameter(IList<AttributeData> attributes, VarianceKind varianceKind, string name, ImmutableArray<ITypeSymbol> constraintTypes, bool hasConstructorConstraint = false, bool hasReferenceConstraint = false, bool hasValueConstraint = false, int ordinal = 0)
- {
- try {
- return (ITypeParameterSymbol)createTypeParameterMethod.Invoke (null, new object[] { attributes, varianceKind, name, constraintTypes, hasConstructorConstraint, hasReferenceConstraint, hasValueConstraint, ordinal});
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createMethodSymbolMethod;
- public static IMethodSymbol CreateMethodSymbol(IList<AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, ITypeSymbol returnType, IMethodSymbol explicitInterfaceSymbol, string name, IList<ITypeParameterSymbol> typeParameters, IList<IParameterSymbol> parameters, IList<SyntaxNode> statements = null, IList<SyntaxNode> handlesExpressions = null, IList<AttributeData> returnTypeAttributes = null, MethodKind methodKind = MethodKind.Ordinary)
- {
- try {
- return (IMethodSymbol)createMethodSymbolMethod.Invoke (null, new object[] { attributes, accessibility, modifiers, returnType, explicitInterfaceSymbol, name, typeParameters, parameters, statements, handlesExpressions, returnTypeAttributes, methodKind });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createMethodSymbolMethod2;
- public static IMethodSymbol CreateMethodSymbol(INamedTypeSymbol containingType, IList<AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, ITypeSymbol returnType, IMethodSymbol explicitInterfaceSymbol, string name, IList<ITypeParameterSymbol> typeParameters, IList<IParameterSymbol> parameters, IList<SyntaxNode> statements = null, IList<SyntaxNode> handlesExpressions = null, IList<AttributeData> returnTypeAttributes = null, MethodKind methodKind = MethodKind.Ordinary)
- {
- try {
- return (IMethodSymbol)createMethodSymbolMethod2.Invoke (null, new object[] { containingType, attributes, accessibility, modifiers, returnType, explicitInterfaceSymbol, name, typeParameters, parameters, statements, null, returnTypeAttributes, methodKind });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createPointerTypeSymbolMethod;
- public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
- {
- try {
- return (IPointerTypeSymbol)createPointerTypeSymbolMethod.Invoke (null, new object[] { pointedAtType });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createArrayTypeSymbolMethod;
- public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1)
- {
- try {
- return (IArrayTypeSymbol)createArrayTypeSymbolMethod.Invoke (null, new object[] { elementType, rank });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createConstructorSymbolMethod;
- public static IMethodSymbol CreateConstructorSymbol(IList<AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, string typeName, IList<IParameterSymbol> parameters, IList<SyntaxNode> statements = null, IList<SyntaxNode> baseConstructorArguments = null, IList<SyntaxNode> thisConstructorArguments = null)
- {
- try {
- return (IMethodSymbol)createConstructorSymbolMethod.Invoke (null, new object[] { attributes, accessibility, modifiers, typeName, parameters, statements, baseConstructorArguments, thisConstructorArguments });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createAccessorSymbolMethod;
- public static IMethodSymbol CreateAccessorSymbol(IList<AttributeData> attributes, Accessibility accessibility, IList<SyntaxNode> statements)
- {
- try {
- return (IMethodSymbol)createAccessorSymbolMethod.Invoke (null, new object[] { attributes, accessibility, statements });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createPropertySymbolMethod;
-
- /// <summary>
- /// Creates a property symbol that can be used to describe a property declaration.
- /// </summary>
- public static IPropertySymbol CreatePropertySymbol(IList<AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, ITypeSymbol type, IPropertySymbol explicitInterfaceSymbol, string name, IList<IParameterSymbol> parameters, IMethodSymbol getMethod, IMethodSymbol setMethod, bool isIndexer = false)
- {
- try {
- return (IPropertySymbol)createPropertySymbolMethod.Invoke (null, new object[] { attributes, accessibility, modifiers, type, explicitInterfaceSymbol, name, parameters, getMethod, setMethod, isIndexer });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo createFieldSymbolMethod;
-
- public static IFieldSymbol CreateFieldSymbol(IList<AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, ITypeSymbol type, string name, bool hasConstantValue = false, object constantValue = null, SyntaxNode initializer = null)
- {
- try {
- return (IFieldSymbol)createFieldSymbolMethod.Invoke (null, new object[] { attributes, accessibility, modifiers, type, name, hasConstantValue, constantValue, initializer });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/CodeRefactoringContextExtensions.cs b/main/src/addins/CSharpBinding/Util/CodeRefactoringContextExtensions.cs
deleted file mode 100644
index 9a7608c8f8..0000000000
--- a/main/src/addins/CSharpBinding/Util/CodeRefactoringContextExtensions.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// CodeRefactoringContextExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis.CodeRefactorings;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.CodeActions;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CodeRefactoringContextExtensions
- {
- public static void RegisterRefactorings(this CodeRefactoringContext context, IEnumerable<CodeAction> actions)
- {
- foreach (var action in actions) {
- context.RegisterRefactoring(action);
- }
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/CommonAccessibilityUtilities.cs b/main/src/addins/CSharpBinding/Util/CommonAccessibilityUtilities.cs
deleted file mode 100644
index a143df376e..0000000000
--- a/main/src/addins/CSharpBinding/Util/CommonAccessibilityUtilities.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// ITypeSymbolExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Linq;
-using System.ComponentModel;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using System.Reflection;
-using System.Collections.Generic;
-using System.Threading;
-using System.Collections.Immutable;
-using System.Diagnostics;
-using System.Threading.Tasks;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CommonAccessibilityUtilities
- {
- public static Accessibility Minimum(Accessibility accessibility1, Accessibility accessibility2)
- {
- if (accessibility1 == Accessibility.Private || accessibility2 == Accessibility.Private)
- {
- return Accessibility.Private;
- }
-
- if (accessibility1 == Accessibility.ProtectedAndInternal || accessibility2 == Accessibility.ProtectedAndInternal)
- {
- return Accessibility.ProtectedAndInternal;
- }
-
- if (accessibility1 == Accessibility.Protected || accessibility2 == Accessibility.Protected)
- {
- return Accessibility.Protected;
- }
-
- if (accessibility1 == Accessibility.Internal || accessibility2 == Accessibility.Internal)
- {
- return Accessibility.Internal;
- }
-
- if (accessibility1 == Accessibility.ProtectedOrInternal || accessibility2 == Accessibility.ProtectedOrInternal)
- {
- return Accessibility.ProtectedOrInternal;
- }
-
- return Accessibility.Public;
- }
- }
-
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/CommonLocationExtensions.cs b/main/src/addins/CSharpBinding/Util/CommonLocationExtensions.cs
deleted file mode 100644
index e5733fb93a..0000000000
--- a/main/src/addins/CSharpBinding/Util/CommonLocationExtensions.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CommonLocationExtensions
- {
- public static SyntaxToken FindToken(this Location location, CancellationToken cancellationToken)
- {
- return location.SourceTree.GetRoot(cancellationToken).FindToken(location.SourceSpan.Start);
- }
-
- public static bool IsVisibleSourceLocation(this Location loc)
- {
- if (!loc.IsInSource)
- {
- return false;
- }
-
- var tree = loc.SourceTree;
- return !(tree == null || tree.IsHiddenPosition(loc.SourceSpan.Start));
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/CommonSyntaxNodeOrTokenExtensions.cs b/main/src/addins/CSharpBinding/Util/CommonSyntaxNodeOrTokenExtensions.cs
deleted file mode 100644
index b99585496f..0000000000
--- a/main/src/addins/CSharpBinding/Util/CommonSyntaxNodeOrTokenExtensions.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CommonSyntaxNodeOrTokenExtensions
- {
- public static IEnumerable<SyntaxNodeOrToken> DepthFirstTraversal(this SyntaxNodeOrToken node)
- {
- var stack = new Stack<SyntaxNodeOrToken>();
- stack.Push(node);
-
- while (!stack.IsEmpty())
- {
- var current = stack.Pop();
-
- yield return current;
-
- if (current.IsNode)
- {
- foreach (var child in current.ChildNodesAndTokens().Reverse())
- {
- stack.Push(child);
- }
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/ConflictResolver.cs b/main/src/addins/CSharpBinding/Util/ConflictResolver.cs
deleted file mode 100644
index 760c1757be..0000000000
--- a/main/src/addins/CSharpBinding/Util/ConflictResolver.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-//
-// ConflictResolver.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using System;
-using Microsoft.CodeAnalysis.Options;
-using System.Threading.Tasks;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class ConflictResolution
- {
- //static Type typeInfo;
- internal object instance;
-
- static ConflictResolution ()
- {
- //typeInfo = Type.GetType ("Microsoft.CodeAnalysis.Rename.ConflictEngine.ConflictResolution" + ReflectionNamespaces.WorkspacesAsmName, true);
-
- }
-
- public ConflictResolution (object instance)
- {
- this.instance = instance;
- }
-
- }
-
- class RenameLocations
- {
- //static Type typeInfo;
- internal object instance;
-
- static RenameLocations ()
- {
- //typeInfo = Type.GetType ("Microsoft.CodeAnalysis.Rename.RenameLocations" + ReflectionNamespaces.WorkspacesAsmName, true);
-
- }
-
- public RenameLocations (object instance)
- {
- this.instance = instance;
- }
-
- }
-
-
- class ConflictResolver
- {
- static MethodInfo resolveConflictsAsyncMethod;
- static Type typeInfo;
-
- static ConflictResolver ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.Rename.ConflictEngine.ConflictResolver" + ReflectionNamespaces.WorkspacesAsmName, true);
- resolveConflictsAsyncMethod = typeInfo.GetMethod ("ResolveConflictsAsync");
-
- }
-
- public static Task<ConflictResolution> ResolveConflictsAsync(
- RenameLocations renameLocationSet,
- string originalText,
- string replacementText,
- OptionSet optionSet,
- Func<IEnumerable<ISymbol>, bool?> hasConflict,
- CancellationToken cancellationToken)
- {
- try {
- var task = resolveConflictsAsyncMethod.Invoke (null, new object [] { renameLocationSet.instance, originalText, replacementText, optionSet, hasConflict, cancellationToken });
- var propertyInfo = task.GetType ().GetProperty ("Result");
- return Task.FromResult (new ConflictResolution (propertyInfo.GetValue (task)));
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/CrefSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/CrefSyntaxExtensions.cs
deleted file mode 100644
index 1d80af7b2f..0000000000
--- a/main/src/addins/CSharpBinding/Util/CrefSyntaxExtensions.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-//
-// CrefSyntaxExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Simplification;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Rename.ConflictEngine;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Simplification;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-using System;
-using System.Reflection;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class CrefSyntaxExtensions
- {
- public static bool TryReduceOrSimplifyExplicitName(
- this CrefSyntax crefSyntax,
- SemanticModel semanticModel,
- out CrefSyntax replacementNode,
- out TextSpan issueSpan,
- OptionSet optionSet,
- CancellationToken cancellationToken)
- {
- replacementNode = null;
- issueSpan = default(TextSpan);
-
- // Currently Qualified Cref is the only CrefSyntax We are handling separately
- if (crefSyntax.Kind() != SyntaxKind.QualifiedCref)
- {
- return false;
- }
-
- var qualifiedCrefSyntax = (QualifiedCrefSyntax)crefSyntax;
- var memberCref = qualifiedCrefSyntax.Member;
-
- // Currently we are dealing with only the NameMemberCrefs
- if (optionSet.GetOption(SimplificationOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, LanguageNames.CSharp) &&
- (memberCref.Kind() == SyntaxKind.NameMemberCref))
- {
- var nameMemberCref = ((NameMemberCrefSyntax)memberCref).Name;
- var symbolInfo = semanticModel.GetSymbolInfo(nameMemberCref, cancellationToken);
- var symbol = symbolInfo.Symbol;
-
- if (symbol == null)
- {
- return false;
- }
-
- if (symbol is INamespaceOrTypeSymbol)
- {
- //var namespaceOrTypeSymbol = (INamespaceOrTypeSymbol)symbol;
-
- // 1. Check for Predefined Types
- if (symbol is INamedTypeSymbol)
- {
- var namedSymbol = (INamedTypeSymbol)symbol;
- var keywordKind = ExpressionSyntaxExtensions.GetPredefinedKeywordKind(namedSymbol.SpecialType);
-
- if (keywordKind != SyntaxKind.None)
- {
- replacementNode = SyntaxFactory.TypeCref(
- SyntaxFactory.PredefinedType(
- SyntaxFactory.Token(crefSyntax.GetLeadingTrivia(), keywordKind, crefSyntax.GetTrailingTrivia())));
- replacementNode = crefSyntax.CopyAnnotationsTo(replacementNode);
-
- // we want to show the whole name expression as unnecessary
- issueSpan = crefSyntax.Span;
-
- return true;
- }
- }
- }
- }
-
- var oldSymbol = semanticModel.GetSymbolInfo(crefSyntax, cancellationToken).Symbol;
- if (oldSymbol != null)
- {
- var speculativeBindingOption = SpeculativeBindingOption.BindAsExpression;
- if (oldSymbol is INamespaceOrTypeSymbol)
- {
- speculativeBindingOption = SpeculativeBindingOption.BindAsTypeOrNamespace;
- }
-
- var newSymbol = semanticModel.GetSpeculativeSymbolInfo(crefSyntax.SpanStart, memberCref, speculativeBindingOption).Symbol;
-
- if (newSymbol == oldSymbol)
- {
- // Copy Trivia and Annotations
- memberCref = memberCref.WithLeadingTrivia(crefSyntax.GetLeadingTrivia());
- memberCref = crefSyntax.CopyAnnotationsTo(memberCref);
- issueSpan = qualifiedCrefSyntax.Container.Span;
- replacementNode = memberCref;
- return true;
- }
- }
-
- return false;
- }
- }
-
-}
diff --git a/main/src/addins/CSharpBinding/Util/DirectiveSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/DirectiveSyntaxExtensions.cs
deleted file mode 100644
index 3bed8b6c58..0000000000
--- a/main/src/addins/CSharpBinding/Util/DirectiveSyntaxExtensions.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.ExceptionServices;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal static partial class DirectiveSyntaxExtensions
- {
- readonly static MethodInfo getMatchingDirective;
- readonly static MethodInfo getMatchingConditionalDirectives;
-
- static DirectiveSyntaxExtensions()
- {
- var typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.DirectiveSyntaxExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- if (typeInfo == null)
- throw new InvalidOperationException ("DirectiveSyntaxExtensions not found.");
- getMatchingDirective = typeInfo.GetMethod("GetMatchingDirective", BindingFlags.NonPublic | BindingFlags.Static);
- if (getMatchingDirective == null)
- throw new InvalidOperationException ("GetMatchingDirective not found.");
- getMatchingConditionalDirectives = typeInfo.GetMethod("GetMatchingConditionalDirectives", BindingFlags.NonPublic | BindingFlags.Static);
- if (getMatchingDirective == null)
- throw new InvalidOperationException ("GetMatchingConditionalDirectives not found.");
- }
-
-
-
- internal static DirectiveTriviaSyntax GetMatchingDirective(this DirectiveTriviaSyntax directive, CancellationToken cancellationToken)
- {
- try {
- return (DirectiveTriviaSyntax)getMatchingDirective.Invoke(null, new object[] { directive, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- internal static IReadOnlyList<DirectiveTriviaSyntax> GetMatchingConditionalDirectives(this DirectiveTriviaSyntax directive, CancellationToken cancellationToken)
- {
- try {
- return (IReadOnlyList<DirectiveTriviaSyntax>)getMatchingConditionalDirectives.Invoke(null, new object[] { directive, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/Util/DocumentExtensions.cs b/main/src/addins/CSharpBinding/Util/DocumentExtensions.cs
deleted file mode 100644
index d61a6c9a79..0000000000
--- a/main/src/addins/CSharpBinding/Util/DocumentExtensions.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.SemanticModelWorkspaceService;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-using System;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static partial class DocumentExtensions
- {
- public static TLanguageService GetLanguageService<TLanguageService>(this Document document) where TLanguageService : class, ILanguageService
- {
- return document.Project.LanguageServices.GetService<TLanguageService>();
- }
-
- public static bool IsOpen(this Document document)
- {
- var workspace = document.Project.Solution.Workspace as Workspace;
- return workspace != null && workspace.IsDocumentOpen(document.Id);
- }
-
- /// <summary>
- /// this will return either regular semantic model or speculative semantic based on context.
- /// any feature that is involved in typing or run on UI thread should use this to take advantage of speculative semantic model
- /// whenever possible automatically.
- ///
- /// when using this API, semantic model should only be used to ask node inside of the given span.
- /// otherwise, it might throw if semantic model returned by this API is a speculative semantic model.
- ///
- /// also, symbols from the semantic model returned by this API might have out of date location information.
- /// if exact location (not relative location) is needed from symbol, regular GetSemanticModel should be used.
- /// </summary>
- public static async Task<SemanticModel> GetSemanticModelForSpanAsync(this Document document, TextSpan span, CancellationToken cancellationToken)
- {
-// var syntaxFactService = document.Project.LanguageServices.GetService<ISyntaxFactsService>();
-// var semanticModelService = document.Project.Solution.Workspace.Services.GetService<ISemanticModelService>();
-// if (semanticModelService == null || syntaxFactService == null)
-// {
- return await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
-// }
-//
-// var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
-// var token = root.FindToken(span.Start);
-// if (token.Parent == null)
-// {
-// return await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
-// }
-//
-// var node = token.Parent.AncestorsAndSelf().FirstOrDefault(a => a.FullSpan.Contains(span));
-// return await GetSemanticModelForNodeAsync(semanticModelService, syntaxFactService, document, node, span, cancellationToken).ConfigureAwait(false);
- }
-
- /// <summary>
- /// this will return either regular semantic model or speculative semantic based on context.
- /// any feature that is involved in typing or run on UI thread should use this to take advantage of speculative semantic model
- /// whenever possible automatically.
- ///
- /// when using this API, semantic model should only be used to ask node inside of the given node except ones that belong to
- /// member signature. otherwise, it might throw if semantic model returned by this API is a speculative semantic model.
- ///
- /// also, symbols from the semantic model returned by this API might have out of date location information.
- /// if exact location (not relative location) is needed from symbol, regular GetSemanticModel should be used.
- /// </summary>
- public static Task<SemanticModel> GetSemanticModelForNodeAsync(this Document document, SyntaxNode node, CancellationToken cancellationToken)
- {
-// var syntaxFactService = document.Project.LanguageServices.GetService<ISyntaxFactsService>();
-// var semanticModelService = document.Project.Solution.Workspace.Services.GetService<ISemanticModelService>();
-// if (semanticModelService == null || syntaxFactService == null || node == null)
-// {
- return document.GetSemanticModelAsync(cancellationToken);
-// }
-//
-// return GetSemanticModelForNodeAsync(semanticModelService, syntaxFactService, document, node, node.FullSpan, cancellationToken);
- }
-
- public static async Task<IEnumerable<T>> GetUnionResultsFromDocumentAndLinks<T>(
- this Document document,
- IEqualityComparer<T> comparer,
- Func<Document, CancellationToken, Task<IEnumerable<T>>> getItemsWorker,
- CancellationToken cancellationToken)
- {
- var linkedDocumentIds = document.GetLinkedDocumentIds();
- var itemsForCurrentContext = await getItemsWorker(document, cancellationToken).ConfigureAwait(false) ?? SpecializedCollections.EmptyEnumerable<T>();
- if (!linkedDocumentIds.Any())
- {
- return itemsForCurrentContext;
- }
-
- ISet<T> totalItems = itemsForCurrentContext.ToSet(comparer);
- foreach (var linkedDocumentId in linkedDocumentIds)
- {
- var linkedDocument = document.Project.Solution.GetDocument(linkedDocumentId);
- var items = await getItemsWorker(linkedDocument, cancellationToken).ConfigureAwait(false);
- if (items != null)
- {
- foreach (var item in items)
- totalItems.Add (item);
- }
- }
-
- return totalItems;
- }
-
- public static bool ShouldHideAdvancedMembers(this Document document)
- {
- return false;
-// var service = document.Project.Solution.Workspace.Services.GetService<IOptionService>();
-// return service.GetOption(CompletionOptions.HideAdvancedMembers, document.Project.Language);
- }
-
- public static async Task<Document> ReplaceNodeAsync<TNode>(this Document document, TNode oldNode, TNode newNode, CancellationToken cancellationToken) where TNode : SyntaxNode
- {
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var newRoot = root.ReplaceNode(oldNode, newNode);
- return document.WithSyntaxRoot(newRoot);
- }
-
- public static async Task<Document> ReplaceNodesAsync(this Document document,
- IEnumerable<SyntaxNode> nodes,
- Func<SyntaxNode, SyntaxNode, SyntaxNode> computeReplacementNode,
- CancellationToken cancellationToken)
- {
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var newRoot = root.ReplaceNodes(nodes, computeReplacementNode);
- return document.WithSyntaxRoot(newRoot);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/EnumValueUtilities.cs b/main/src/addins/CSharpBinding/Util/EnumValueUtilities.cs
deleted file mode 100644
index deb4b97893..0000000000
--- a/main/src/addins/CSharpBinding/Util/EnumValueUtilities.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// EnumValueUtilities.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Reflection;
-using Microsoft.CodeAnalysis;
-using System.Threading;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class EnumValueUtilities
- {
- readonly static Type typeInfo;
-
- static EnumValueUtilities ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.Shared.Utilities.EnumValueUtilities" + ReflectionNamespaces.WorkspacesAsmName, true);
- getNextEnumValueMethod = typeInfo.GetMethod ("GetNextEnumValue", BindingFlags.Static | BindingFlags.Public);
- }
-
- readonly static MethodInfo getNextEnumValueMethod;
-
- public static object GetNextEnumValue(INamedTypeSymbol enumType, CancellationToken cancellationToken)
- {
- try {
- return getNextEnumValueMethod.Invoke (null, new object[] { enumType, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/EnumerableExtensions.cs b/main/src/addins/CSharpBinding/Util/EnumerableExtensions.cs
deleted file mode 100644
index 0d54dd99c0..0000000000
--- a/main/src/addins/CSharpBinding/Util/EnumerableExtensions.cs
+++ /dev/null
@@ -1,351 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static partial class EnumerableExtensions
- {
- public static IEnumerable<T> Do<T>(this IEnumerable<T> source, Action<T> action)
- {
- if (source == null)
- {
- throw new ArgumentNullException(nameof(source));
- }
-
- if (action == null)
- {
- throw new ArgumentNullException(nameof(action));
- }
-
- // perf optimization. try to not use enumerator if possible
- var list = source as IList<T>;
- if (list != null)
- {
- for (int i = 0, count = list.Count; i < count; i++)
- {
- action(list[i]);
- }
- }
- else
- {
- foreach (var value in source)
- {
- action(value);
- }
- }
-
- return source;
- }
-
- public static ReadOnlyCollection<T> ToReadOnlyCollection<T>(this IEnumerable<T> source)
- {
- if (source == null)
- {
- throw new ArgumentNullException(nameof(source));
- }
-
- return new ReadOnlyCollection<T>(source.ToList());
- }
-
- public static IEnumerable<T> Concat<T>(this IEnumerable<T> source, T value)
- {
- if (source == null)
- {
- throw new ArgumentNullException(nameof(source));
- }
-
- return source.ConcatWorker(value);
- }
-
- private static IEnumerable<T> ConcatWorker<T>(this IEnumerable<T> source, T value)
- {
- foreach (var v in source)
- {
- yield return v;
- }
-
- yield return value;
- }
-
- public static bool SetEquals<T>(this IEnumerable<T> source1, IEnumerable<T> source2, IEqualityComparer<T> comparer)
- {
- if (source1 == null)
- {
- throw new ArgumentNullException(nameof(source1));
- }
-
- if (source2 == null)
- {
- throw new ArgumentNullException(nameof(source2));
- }
-
- return source1.ToSet(comparer).SetEquals(source2);
- }
-
- public static bool SetEquals<T>(this IEnumerable<T> source1, IEnumerable<T> source2)
- {
- if (source1 == null)
- {
- throw new ArgumentNullException(nameof(source1));
- }
-
- if (source2 == null)
- {
- throw new ArgumentNullException(nameof(source2));
- }
-
- return source1.ToSet().SetEquals(source2);
- }
-
- public static ISet<T> ToSet<T>(this IEnumerable<T> source, IEqualityComparer<T> comparer)
- {
- if (source == null)
- {
- throw new ArgumentNullException(nameof(source));
- }
-
- return new HashSet<T>(source, comparer);
- }
-
- public static ISet<T> ToSet<T>(this IEnumerable<T> source)
- {
- if (source == null)
- {
- throw new ArgumentNullException(nameof(source));
- }
-
- return source as ISet<T> ?? new HashSet<T>(source);
- }
-
- public static T? FirstOrNullable<T>(this IEnumerable<T> source)
- where T : struct
- {
- if (source == null)
- {
- throw new ArgumentNullException(nameof(source));
- }
-
- return source.Cast<T?>().FirstOrDefault();
- }
-
- public static T? FirstOrNullable<T>(this IEnumerable<T> source, Func<T, bool> predicate)
- where T : struct
- {
- if (source == null)
- {
- throw new ArgumentNullException(nameof(source));
- }
-
- return source.Cast<T?>().FirstOrDefault(v => predicate(v.Value));
- }
-
- public static T? LastOrNullable<T>(this IEnumerable<T> source)
- where T : struct
- {
- if (source == null)
- {
- throw new ArgumentNullException(nameof(source));
- }
-
- return source.Cast<T?>().LastOrDefault();
- }
-
- public static bool IsSingle<T>(this IEnumerable<T> list)
- {
- using (var enumerator = list.GetEnumerator())
- {
- return enumerator.MoveNext() && !enumerator.MoveNext();
- }
- }
-
- public static bool IsEmpty<T>(this IEnumerable<T> source)
- {
- var readOnlyCollection = source as IReadOnlyCollection<T>;
- if (readOnlyCollection != null)
- {
- return readOnlyCollection.Count == 0;
- }
-
- var genericCollection = source as ICollection<T>;
- if (genericCollection != null)
- {
- return genericCollection.Count == 0;
- }
-
- var collection = source as ICollection;
- if (collection != null)
- {
- return collection.Count == 0;
- }
-
- var str = source as string;
- if (str != null)
- {
- return str.Length == 0;
- }
-
- foreach (var t in source)
- {
- return false;
- }
-
- return true;
- }
-
- public static bool IsEmpty<T>(this IReadOnlyCollection<T> source)
- {
- return source.Count == 0;
- }
-
- public static bool IsEmpty<T>(this ICollection<T> source)
- {
- return source.Count == 0;
- }
-
- public static bool IsEmpty(this string source)
- {
- return source.Length == 0;
- }
-
- /// <remarks>
- /// This method is necessary to avoid an ambiguity between <see cref="IsEmpty{T}(IReadOnlyCollection{T})"/> and <see cref="IsEmpty{T}(ICollection{T})"/>.
- /// </remarks>
- public static bool IsEmpty<T>(this T[] source)
- {
- return source.Length == 0;
- }
-
- /// <remarks>
- /// This method is necessary to avoid an ambiguity between <see cref="IsEmpty{T}(IReadOnlyCollection{T})"/> and <see cref="IsEmpty{T}(ICollection{T})"/>.
- /// </remarks>
- public static bool IsEmpty<T>(this List<T> source)
- {
- return source.Count == 0;
- }
-
- private static readonly Func<object, bool> s_notNullTest = x => x != null;
-
- public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T> source)
- where T : class
- {
- if (source == null)
- {
- return SpecializedCollections.EmptyEnumerable<T>();
- }
-
- return source.Where((Func<T, bool>)s_notNullTest);
- }
-
- public static bool All(this IEnumerable<bool> source)
- {
- if (source == null)
- {
- throw new ArgumentNullException(nameof(source));
- }
-
- foreach (var b in source)
- {
- if (!b)
- {
- return false;
- }
- }
-
- return true;
- }
-
- public static IEnumerable<T> Flatten<T>(this IEnumerable<IEnumerable<T>> sequence)
- {
- if (sequence == null)
- {
- throw new ArgumentNullException(nameof(sequence));
- }
-
- return sequence.SelectMany(s => s);
- }
-
- public static IEnumerable<T> OrderBy<T>(this IEnumerable<T> source, IComparer<T> comparer)
- {
- return source.OrderBy(t => t, comparer);
- }
-
-// public static IEnumerable<T> OrderBy<T>(this IEnumerable<T> source, Comparison<T> compare)
-// {
-// return source.OrderBy(new ComparisonComparer<T>(compare));
-// }
-
-// public static IEnumerable<T> Order<T>(this IEnumerable<T> source) where T : IComparable<T>
-// {
-// return source.OrderBy((t1, t2) => t1.CompareTo(t2));
-// }
-
- public static bool IsSorted<T>(this IEnumerable<T> enumerable, IComparer<T> comparer)
- {
- using (var e = enumerable.GetEnumerator())
- {
- if (!e.MoveNext())
- {
- return true;
- }
-
- var previous = e.Current;
- while (e.MoveNext())
- {
- if (comparer.Compare(previous, e.Current) > 0)
- {
- return false;
- }
-
- previous = e.Current;
- }
-
- return true;
- }
- }
-
- public static bool SequenceEqual<T>(this IEnumerable<T> first, IEnumerable<T> second, Func<T, T, bool> comparer)
- {
- Debug.Assert(comparer != null);
-
- if (first == second)
- {
- return true;
- }
-
- if (first == null || second == null)
- {
- return false;
- }
-
- using (var enumerator = first.GetEnumerator())
- using (var enumerator2 = second.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- if (!enumerator2.MoveNext() || !comparer(enumerator.Current, enumerator2.Current))
- {
- return false;
- }
- }
-
- if (enumerator2.MoveNext())
- {
- return false;
- }
- }
-
- return true;
- }
-
- public static bool Contains<T>(this IEnumerable<T> sequence, Func<T, bool> predicate)
- {
- return sequence.Any(predicate);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs
deleted file mode 100644
index 5fce0d401b..0000000000
--- a/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs
+++ /dev/null
@@ -1,2380 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
-using Microsoft.CodeAnalysis.CSharp.Simplification;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Rename.ConflictEngine;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Simplification;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-using System;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static partial class ExpressionSyntaxExtensions
- {
- static MethodInfo castIfPossibleMethod;
-
-
- static ExpressionSyntaxExtensions ()
- {
- var typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.ExpressionSyntaxExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- castIfPossibleMethod = typeInfo.GetMethod("CastIfPossible", BindingFlags.Static | BindingFlags.Public);
- if (castIfPossibleMethod == null)
- throw new Exception ("ExpressionSyntaxExtensions: CastIfPossible not found");
- tryReduceOrSimplifyExplicitNameMethod = typeInfo.GetMethod("TryReduceOrSimplifyExplicitName", BindingFlags.Static | BindingFlags.Public);
- if (tryReduceOrSimplifyExplicitNameMethod == null)
- throw new Exception ("ExpressionSyntaxExtensions: TryReduceOrSimplifyExplicitName not found");
- }
-
- /// <summary>
- /// Adds to <paramref name="targetType"/> if it does not contain an anonymous
- /// type and binds to the same type at the given <paramref name="position"/>.
- /// </summary>
- public static ExpressionSyntax CastIfPossible(
- this ExpressionSyntax expression,
- ITypeSymbol targetType,
- int position,
- SemanticModel semanticModel)
- {
- try {
- var args = new object [] { expression, targetType, position, semanticModel};
- var result = (ExpressionSyntax)castIfPossibleMethod.Invoke (null, args);
- return result;
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- throw ex;
- }
- }
-
- public static ExpressionSyntax WalkUpParentheses(this ExpressionSyntax expression)
- {
- while (expression.IsParentKind(SyntaxKind.ParenthesizedExpression))
- {
- expression = (ExpressionSyntax)expression.Parent;
- }
-
- return expression;
- }
-
- public static ExpressionSyntax WalkDownParentheses(this ExpressionSyntax expression)
- {
- while (expression.IsKind(SyntaxKind.ParenthesizedExpression))
- {
- expression = ((ParenthesizedExpressionSyntax)expression).Expression;
- }
-
- return expression;
- }
-
- public static ExpressionSyntax Parenthesize(this ExpressionSyntax expression, bool includeElasticTrivia = true)
- {
- var leadingTrivia = expression.GetLeadingTrivia();
- var trailingTrivia = expression.GetTrailingTrivia();
- expression = expression.WithoutLeadingTrivia()
- .WithoutTrailingTrivia();
-
- if (includeElasticTrivia)
- {
- return SyntaxFactory.ParenthesizedExpression(expression)
- .WithLeadingTrivia(leadingTrivia)
- .WithTrailingTrivia(trailingTrivia)
- .WithAdditionalAnnotations(Simplifier.Annotation);
- }
- else
- {
- return SyntaxFactory.ParenthesizedExpression(
- SyntaxFactory.Token(SyntaxTriviaList.Empty, SyntaxKind.OpenParenToken, SyntaxTriviaList.Empty),
- expression,
- SyntaxFactory.Token(SyntaxTriviaList.Empty, SyntaxKind.CloseParenToken, SyntaxTriviaList.Empty))
- .WithLeadingTrivia(leadingTrivia)
- .WithTrailingTrivia(trailingTrivia)
- .WithAdditionalAnnotations(Simplifier.Annotation);
- }
- }
-
- public static CastExpressionSyntax Cast(
- this ExpressionSyntax expression,
- ITypeSymbol targetType)
- {
- return SyntaxFactory.CastExpression(
- type: targetType.GenerateTypeSyntax(),
- expression: expression.Parenthesize())
- .WithAdditionalAnnotations(Simplifier.Annotation);
- }
-
- public static bool IsQualifiedCrefName(this ExpressionSyntax expression)
- {
- return expression.IsParentKind(SyntaxKind.NameMemberCref) && expression.Parent.IsParentKind(SyntaxKind.QualifiedCref);
- }
-
- public static bool IsMemberAccessExpressionName(this ExpressionSyntax expression)
- {
- return (expression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) && ((MemberAccessExpressionSyntax)expression.Parent).Name == expression) ||
- (IsMemberBindingExpressionName(expression));
- }
-
- public static bool IsAnyMemberAccessExpressionName(this ExpressionSyntax expression)
- {
- if (expression == null)
- {
- return false;
- }
-
- return expression == (expression.Parent as MemberAccessExpressionSyntax)?.Name ||
- expression.IsMemberBindingExpressionName();
- }
-
- private static bool IsMemberBindingExpressionName(this ExpressionSyntax expression)
- {
- return expression.IsParentKind(SyntaxKind.MemberBindingExpression) &&
- ((MemberBindingExpressionSyntax)expression.Parent).Name == expression;
- }
-
- public static bool IsRightSideOfQualifiedName(this ExpressionSyntax expression)
- {
- return expression.IsParentKind(SyntaxKind.QualifiedName) && ((QualifiedNameSyntax)expression.Parent).Right == expression;
- }
-
- public static bool IsRightSideOfColonColon(this ExpressionSyntax expression)
- {
- return expression.IsParentKind(SyntaxKind.AliasQualifiedName) && ((AliasQualifiedNameSyntax)expression.Parent).Name == expression;
- }
-
- public static bool IsRightSideOfDot(this ExpressionSyntax name)
- {
- return IsMemberAccessExpressionName(name) || IsRightSideOfQualifiedName(name) || IsQualifiedCrefName(name);
- }
-
- public static bool IsRightSideOfDotOrArrow(this ExpressionSyntax name)
- {
- return IsAnyMemberAccessExpressionName(name) || IsRightSideOfQualifiedName(name);
- }
-
- public static bool IsRightSideOfDotOrColonColon(this ExpressionSyntax name)
- {
- return IsRightSideOfDot(name) || IsRightSideOfColonColon(name);
- }
-
- public static bool IsRightSideOfDotOrArrowOrColonColon(this ExpressionSyntax name)
- {
- return IsRightSideOfDotOrArrow(name) || IsRightSideOfColonColon(name);
- }
-
- public static bool IsRightOfCloseParen(this ExpressionSyntax expression)
- {
- var firstToken = expression.GetFirstToken();
- return firstToken.Kind() != SyntaxKind.None
- && firstToken.GetPreviousToken().Kind() == SyntaxKind.CloseParenToken;
- }
-
- public static bool IsLeftSideOfDot(this ExpressionSyntax expression)
- {
- return
- IsLeftSideOfQualifiedName(expression) ||
- (expression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) && ((MemberAccessExpressionSyntax)expression.Parent).Expression == expression);
- }
-
- public static bool IsLeftSideOfDotOrArrow(this ExpressionSyntax expression)
- {
- return
- IsLeftSideOfQualifiedName(expression) ||
- (expression.Parent is MemberAccessExpressionSyntax && ((MemberAccessExpressionSyntax)expression.Parent).Expression == expression);
- }
-
- public static bool IsLeftSideOfQualifiedName(this ExpressionSyntax expression)
- {
- return
- expression.IsParentKind(SyntaxKind.QualifiedName) && ((QualifiedNameSyntax)expression.Parent).Left == expression;
- }
-
- public static bool IsExpressionOfInvocation(this ExpressionSyntax expression)
- {
- return
- expression.IsParentKind(SyntaxKind.InvocationExpression) && ((InvocationExpressionSyntax)expression.Parent).Expression == expression;
- }
-
- public static bool TryGetNameParts(this ExpressionSyntax expression, out IList<string> parts)
- {
- var partsList = new List<string>();
- if (!TryGetNameParts(expression, partsList))
- {
- parts = null;
- return false;
- }
-
- parts = partsList;
- return true;
- }
-
- public static bool TryGetNameParts(this ExpressionSyntax expression, List<string> parts)
- {
- if (expression.IsKind(SyntaxKind.SimpleMemberAccessExpression))
- {
- var memberAccess = (MemberAccessExpressionSyntax)expression;
- if (!TryGetNameParts(memberAccess.Expression, parts))
- {
- return false;
- }
-
- return AddSimpleName(memberAccess.Name, parts);
- }
- else if (expression.IsKind(SyntaxKind.QualifiedName))
- {
- var qualifiedName = (QualifiedNameSyntax)expression;
- if (!TryGetNameParts(qualifiedName.Left, parts))
- {
- return false;
- }
-
- return AddSimpleName(qualifiedName.Right, parts);
- }
- else if (expression is SimpleNameSyntax)
- {
- return AddSimpleName((SimpleNameSyntax)expression, parts);
- }
- else
- {
- return false;
- }
- }
-
- private static bool AddSimpleName(SimpleNameSyntax simpleName, List<string> parts)
- {
- if (!simpleName.IsKind(SyntaxKind.IdentifierName))
- {
- return false;
- }
-
- parts.Add(simpleName.Identifier.ValueText);
- return true;
- }
-
- public static bool IsAnyLiteralExpression(this ExpressionSyntax expression)
- {
- return
- expression.IsKind(SyntaxKind.CharacterLiteralExpression) ||
- expression.IsKind(SyntaxKind.FalseLiteralExpression) ||
- expression.IsKind(SyntaxKind.NullLiteralExpression) ||
- expression.IsKind(SyntaxKind.NumericLiteralExpression) ||
- expression.IsKind(SyntaxKind.StringLiteralExpression) ||
- expression.IsKind(SyntaxKind.TrueLiteralExpression);
- }
-
- public static bool IsInConstantContext(this ExpressionSyntax expression)
- {
- if (expression.GetAncestor<ParameterSyntax>() != null)
- {
- return true;
- }
-
- var attributeArgument = expression.GetAncestor<AttributeArgumentSyntax>();
- if (attributeArgument != null)
- {
- if (attributeArgument.NameEquals == null ||
- expression != attributeArgument.NameEquals.Name)
- {
- return true;
- }
- }
-
- // TODO(cyrusn): Add more cases.
- return false;
- }
-
- public static bool IsInOutContext(this ExpressionSyntax expression)
- {
- var argument = expression.Parent as ArgumentSyntax;
- return
- argument != null &&
- argument.Expression == expression &&
- argument.RefOrOutKeyword.Kind() == SyntaxKind.OutKeyword;
- }
-
- public static bool IsInRefContext(this ExpressionSyntax expression)
- {
- var argument = expression.Parent as ArgumentSyntax;
- return
- argument != null &&
- argument.Expression == expression &&
- argument.RefOrOutKeyword.Kind() == SyntaxKind.RefKeyword;
- }
-
- public static bool IsOnlyWrittenTo(this ExpressionSyntax expression)
- {
- if (expression.IsRightSideOfDotOrArrow())
- {
- expression = expression.Parent as ExpressionSyntax;
- }
-
- if (expression != null)
- {
- if (expression.IsInOutContext())
- {
- return true;
- }
-
- if (expression.Parent != null)
- {
- if (expression.IsLeftSideOfAssignExpression())
- {
- return true;
- }
-
- var nameEquals = expression.Parent as NameEqualsSyntax;
- if (nameEquals != null && nameEquals.IsParentKind(SyntaxKind.AttributeArgument))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public static bool IsWrittenTo(this ExpressionSyntax expression)
- {
- if (expression.IsOnlyWrittenTo())
- {
- return true;
- }
-
- if (expression.IsRightSideOfDotOrArrow())
- {
- expression = expression.Parent as ExpressionSyntax;
- }
-
- if (expression != null)
- {
- if (expression.IsInRefContext())
- {
- return true;
- }
-
- // We're written if we're used in a ++, or -- expression.
- if (expression.Parent != null)
- {
- switch (expression.Parent.Kind())
- {
- case SyntaxKind.PostIncrementExpression:
- case SyntaxKind.PreIncrementExpression:
- case SyntaxKind.PostDecrementExpression:
- case SyntaxKind.PreDecrementExpression:
- return true;
- }
-
- if (expression.IsLeftSideOfAnyAssignExpression())
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public static bool IsNamedArgumentIdentifier(this ExpressionSyntax expression)
- {
- return expression is IdentifierNameSyntax && expression.Parent is NameColonSyntax;
- }
-
- public static bool IsInsideNameOf(this ExpressionSyntax expression)
- {
- return expression.SyntaxTree.IsNameOfContext(expression.SpanStart);
- }
-
- private static bool CanReplace(ISymbol symbol)
- {
- switch (symbol.Kind)
- {
- case SymbolKind.Field:
- case SymbolKind.Local:
- case SymbolKind.Method:
- case SymbolKind.Parameter:
- case SymbolKind.Property:
- case SymbolKind.RangeVariable:
- return true;
- }
-
- return false;
- }
-
- public static bool CanReplaceWithRValue(
- this ExpressionSyntax expression, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- // An RValue can't be written into.
- // i.e. you can't replace "a" in "a = b" with "Foo() = b".
- return
- expression != null &&
- !expression.IsWrittenTo() &&
- CanReplaceWithLValue(expression, semanticModel, cancellationToken);
- }
-
- public static bool CanReplaceWithLValue(
- this ExpressionSyntax expression, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- if (expression.IsKind(SyntaxKind.StackAllocArrayCreationExpression))
- {
- // Stack alloc is very interesting. While it appears to be an expression, it is only
- // such so it can appear in a variable decl. It is not a normal expression that can
- // go anywhere.
- return false;
- }
-
- if (expression.IsKind(SyntaxKind.BaseExpression) ||
- expression.IsKind(SyntaxKind.CollectionInitializerExpression) ||
- expression.IsKind(SyntaxKind.ObjectInitializerExpression) ||
- expression.IsKind(SyntaxKind.ComplexElementInitializerExpression))
- {
- return false;
- }
-
- // literal can be always replaced.
- if (expression is LiteralExpressionSyntax && !expression.IsParentKind(SyntaxKind.UnaryMinusExpression))
- {
- return true;
- }
-
- if (!(expression is ObjectCreationExpressionSyntax) && !(expression is AnonymousObjectCreationExpressionSyntax))
- {
- var symbolInfo = semanticModel.GetSymbolInfo(expression, cancellationToken);
- if (!symbolInfo.GetBestOrAllSymbols().All(CanReplace))
- {
- // If the expression is actually a reference to a type, then it can't be replaced
- // with an arbitrary expression.
- return false;
- }
- }
-
- switch (expression.Parent.Kind())
- {
- case SyntaxKind.InvocationExpression:
- // Technically, you could introduce an LValue for "Foo" in "Foo()" even if "Foo" binds
- // to a method. (i.e. by assigning to a Func<...> type). However, this is so contrived
- // and none of the features that use this extension consider this replaceable.
- if (expression.IsKind(SyntaxKind.IdentifierName) || expression is MemberAccessExpressionSyntax)
- {
- // If it looks like a method then we don't allow it to be replaced if it is a
- // method (or if it doesn't bind).
-
- var symbolInfo = semanticModel.GetSymbolInfo(expression, cancellationToken);
- return symbolInfo.GetBestOrAllSymbols().Any() && !symbolInfo.GetBestOrAllSymbols().Any(s => s is IMethodSymbol);
- }
- else
- {
- // It doesn't look like a method, we allow this to be replaced.
- return true;
- }
-
- case SyntaxKind.IsExpression:
- case SyntaxKind.AsExpression:
- // Can't introduce a variable for the type portion of an is/as check.
- var isOrAsExpression = (BinaryExpressionSyntax)expression.Parent;
- return expression == isOrAsExpression.Left;
- case SyntaxKind.EqualsValueClause:
- case SyntaxKind.ExpressionStatement:
- case SyntaxKind.ArrayInitializerExpression:
- case SyntaxKind.CollectionInitializerExpression:
- case SyntaxKind.ConditionalAccessExpression:
- case SyntaxKind.Argument:
- case SyntaxKind.AttributeArgument:
- case SyntaxKind.AnonymousObjectMemberDeclarator:
- case SyntaxKind.ArrowExpressionClause:
- case SyntaxKind.AwaitExpression:
- case SyntaxKind.ReturnStatement:
- case SyntaxKind.YieldReturnStatement:
- case SyntaxKind.ParenthesizedLambdaExpression:
- case SyntaxKind.SimpleLambdaExpression:
- case SyntaxKind.ParenthesizedExpression:
- case SyntaxKind.ArrayRankSpecifier:
- case SyntaxKind.ConditionalExpression:
- case SyntaxKind.IfStatement:
- case SyntaxKind.CatchFilterClause:
- case SyntaxKind.WhileStatement:
- case SyntaxKind.DoStatement:
- case SyntaxKind.ThrowStatement:
- case SyntaxKind.SwitchStatement:
- // TODO: uncomment on roslyn update
- //case SyntaxKind.InterpolatedStringExpression:
- case SyntaxKind.ComplexElementInitializerExpression:
-
- // TODO: uncomment on roslyn update
- // case SyntaxKind.Interpolation:
- // Direct parent kind checks.
- return true;
- }
-
- if (expression.Parent is PrefixUnaryExpressionSyntax)
- {
- if (!(expression is LiteralExpressionSyntax && expression.IsParentKind(SyntaxKind.UnaryMinusExpression)))
- {
- return true;
- }
- }
-
- var parentNonExpression = expression.GetAncestors().SkipWhile(n => n is ExpressionSyntax).FirstOrDefault();
- var topExpression = expression;
- while (topExpression.Parent is TypeSyntax)
- {
- topExpression = (TypeSyntax)topExpression.Parent;
- }
-
- if (parentNonExpression != null &&
- parentNonExpression.IsKind(SyntaxKind.FromClause) &&
- topExpression != null &&
- ((FromClauseSyntax)parentNonExpression).Type == topExpression)
- {
- return false;
- }
-
- // Parent type checks.
- if (expression.Parent is PostfixUnaryExpressionSyntax ||
- expression.Parent is BinaryExpressionSyntax ||
- expression.Parent is AssignmentExpressionSyntax ||
- expression.Parent is QueryClauseSyntax ||
- expression.Parent is SelectOrGroupClauseSyntax ||
- expression.Parent is CheckedExpressionSyntax)
- {
- return true;
- }
-
- // Specific child checks.
- if (expression.CheckParent<ForEachStatementSyntax>(f => f.Expression == expression) ||
- expression.CheckParent<MemberAccessExpressionSyntax>(m => m.Expression == expression) ||
- expression.CheckParent<CastExpressionSyntax>(c => c.Expression == expression))
- {
- return true;
- }
-
- // Misc checks.
- if ((expression.IsParentKind(SyntaxKind.NameEquals) && expression.Parent.IsParentKind(SyntaxKind.AttributeArgument)) ||
- expression.IsLeftSideOfAnyAssignExpression())
- {
- return true;
- }
-
- return false;
- }
-
-// public static bool CanAccessInstanceAndStaticMembersOffOf(
-// this ExpressionSyntax expression,
-// SemanticModel semanticModel,
-// CancellationToken cancellationToken)
-// {
-// // Check for the Color Color case.
-// //
-// // color color: if you bind "A" and you get a symbol and the type of that symbol is
-// // Q; and if you bind "A" *again* as a type and you get type Q, then both A.static
-// // and A.instance are permitted
-// if (expression is IdentifierNameSyntax)
-// {
-// var instanceSymbol = semanticModel.GetSymbolInfo(expression, cancellationToken).GetAnySymbol();
-//
-// if (!(instanceSymbol is INamespaceOrTypeSymbol))
-// {
-// var instanceType = instanceSymbol.GetSymbolType();
-// if (instanceType != null)
-// {
-// var speculativeSymbolInfo = semanticModel.GetSpeculativeSymbolInfo(expression.SpanStart, expression, SpeculativeBindingOption.BindAsTypeOrNamespace);
-// if (speculativeSymbolInfo.CandidateReason != CandidateReason.NotATypeOrNamespace)
-// {
-// var staticType = speculativeSymbolInfo.GetAnySymbol().GetSymbolType();
-//
-// return SymbolEquivalenceComparer.Instance.Equals(instanceType, staticType);
-// }
-// }
-// }
-// }
-//
-// return false;
-// }
-
- readonly static MethodInfo tryReduceOrSimplifyExplicitNameMethod;
-
- public static bool TryReduceOrSimplifyExplicitName(
- this ExpressionSyntax expression,
- SemanticModel semanticModel,
- out ExpressionSyntax replacementNode,
- out TextSpan issueSpan,
- OptionSet optionSet,
- CancellationToken cancellationToken)
- {
- try {
- var args = new object[] { expression, semanticModel, default(ExpressionSyntax), default(TextSpan), optionSet, cancellationToken };
- var result = (bool)tryReduceOrSimplifyExplicitNameMethod.Invoke (null, args);
- replacementNode = (ExpressionSyntax)args [2];
- issueSpan = (TextSpan)args [3];
- return result;
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- throw ex;
- }
- }
-
-// public static bool TryReduceExplicitName(
-// this ExpressionSyntax expression,
-// SemanticModel semanticModel,
-// out TypeSyntax replacementNode,
-// out TextSpan issueSpan,
-// OptionSet optionSet,
-// CancellationToken cancellationToken)
-// {
-// replacementNode = null;
-// issueSpan = default(TextSpan);
-//
-// if (expression.ContainsInterleavedDirective(cancellationToken))
-// {
-// return false;
-// }
-//
-// if (expression.Kind() == SyntaxKind.SimpleMemberAccessExpression)
-// {
-// var memberAccess = (MemberAccessExpressionSyntax)expression;
-// return memberAccess.TryReduce(semanticModel, out replacementNode, out issueSpan, optionSet, cancellationToken);
-// }
-// else if (expression is NameSyntax)
-// {
-// var name = (NameSyntax)expression;
-// return name.TryReduce(semanticModel, out replacementNode, out issueSpan, optionSet, cancellationToken);
-// }
-// else if (expression is TypeSyntax)
-// {
-// var typeName = (TypeSyntax)expression;
-// return typeName.IsReplacableByVar(semanticModel, out replacementNode, out issueSpan, optionSet, cancellationToken);
-// }
-//
-// return false;
-// }
-//
-// private static bool TryReduce(
-// this MemberAccessExpressionSyntax memberAccess,
-// SemanticModel semanticModel,
-// out TypeSyntax replacementNode,
-// out TextSpan issueSpan,
-// OptionSet optionSet,
-// CancellationToken cancellationToken)
-// {
-// replacementNode = null;
-// issueSpan = default(TextSpan);
-//
-// if (memberAccess.Name == null || memberAccess.Expression == null)
-// {
-// return false;
-// }
-//
-// if (optionSet.GetOption(SimplificationOptions.QualifyMemberAccessWithThisOrMe, semanticModel.Language) &&
-// memberAccess.Expression.Kind() == SyntaxKind.ThisExpression)
-// {
-// return false;
-// }
-//
-// // if this node is annotated as being a specialtype, let's use this information.
-// if (memberAccess.HasAnnotations(SpecialTypeAnnotation.Kind))
-// {
-// replacementNode = SyntaxFactory.PredefinedType(
-// SyntaxFactory.Token(
-// memberAccess.GetLeadingTrivia(),
-// GetPredefinedKeywordKind(SpecialTypeAnnotation.GetSpecialType(memberAccess.GetAnnotations(SpecialTypeAnnotation.Kind).First())),
-// memberAccess.GetTrailingTrivia()));
-//
-// issueSpan = memberAccess.Span;
-//
-// return true;
-// }
-//
-// // if this node is on the left side, we could simplify to aliases
-// if (!memberAccess.IsRightSideOfDot())
-// {
-// // Check if we need to replace this syntax with an alias identifier
-// IAliasSymbol aliasReplacement;
-// if (memberAccess.TryReplaceWithAlias(semanticModel, optionSet.GetOption(SimplificationOptions.PreferAliasToQualification), cancellationToken, out aliasReplacement))
-// {
-// // get the token text as it appears in source code to preserve e.g. unicode character escaping
-// var text = aliasReplacement.Name;
-// var syntaxRef = aliasReplacement.DeclaringSyntaxReferences.FirstOrDefault();
-//
-// if (syntaxRef != null)
-// {
-// var declIdentifier = ((UsingDirectiveSyntax)syntaxRef.GetSyntax(cancellationToken)).Alias.Name.Identifier;
-// text = declIdentifier.IsVerbatimIdentifier() ? declIdentifier.ToString().Substring(1) : declIdentifier.ToString();
-// }
-//
-// replacementNode = SyntaxFactory.IdentifierName(
-// memberAccess.Name.Identifier.CopyAnnotationsTo(SyntaxFactory.Identifier(
-// memberAccess.GetLeadingTrivia(),
-// SyntaxKind.IdentifierToken,
-// text,
-// aliasReplacement.Name,
-// memberAccess.GetTrailingTrivia())));
-//
-// replacementNode = memberAccess.CopyAnnotationsTo(replacementNode);
-// replacementNode = memberAccess.Name.CopyAnnotationsTo(replacementNode);
-//
-// issueSpan = memberAccess.Span;
-//
-// // In case the alias name is the same as the last name of the alias target, we only include
-// // the left part of the name in the unnecessary span to Not confuse uses.
-// if (memberAccess.Name.Identifier.ValueText == ((IdentifierNameSyntax)replacementNode).Identifier.ValueText)
-// {
-// issueSpan = memberAccess.Expression.Span;
-// }
-//
-// return true;
-// }
-//
-// // Check if the Expression can be replaced by Predefined Type keyword
-// if (PreferPredefinedTypeKeywordInMemberAccess(memberAccess, optionSet, semanticModel))
-// {
-// var symbol = semanticModel.GetSymbolInfo(memberAccess, cancellationToken).Symbol;
-// if (symbol != null && symbol.IsKind(SymbolKind.NamedType))
-// {
-// var keywordKind = GetPredefinedKeywordKind(((INamedTypeSymbol)symbol).SpecialType);
-// if (keywordKind != SyntaxKind.None)
-// {
-// replacementNode = CreatePredefinedTypeSyntax(memberAccess, keywordKind);
-//
-// issueSpan = memberAccess.Span; // we want to show the whole expression as unnecessary
-//
-// return true;
-// }
-// }
-// }
-// }
-//
-// replacementNode = memberAccess.Name.WithLeadingTrivia(memberAccess.GetLeadingTrivia()).WithTrailingTrivia(memberAccess.GetTrailingTrivia());
-// issueSpan = memberAccess.Expression.Span;
-//
-// if (replacementNode == null)
-// {
-// return false;
-// }
-//
-// return memberAccess.CanReplaceWithReducedName(replacementNode, semanticModel, cancellationToken);
-// }
-
- private static bool InsideCrefReference(ExpressionSyntax expr)
- {
- var crefAttribute = expr.FirstAncestorOrSelf<XmlCrefAttributeSyntax>();
- return crefAttribute != null;
- }
-
- private static bool InsideNameOfExpression(ExpressionSyntax expr, SemanticModel semanticModel)
- {
- var nameOfInvocationExpr = expr.FirstAncestorOrSelf<InvocationExpressionSyntax>(
- invocationExpr =>
- {
- var expression = invocationExpr.Expression as IdentifierNameSyntax;
- return (expression != null) && (expression.Identifier.Text == "nameof") &&
- semanticModel.GetConstantValue(invocationExpr).HasValue &&
- (semanticModel.GetTypeInfo(invocationExpr).Type.SpecialType == SpecialType.System_String);
- });
-
- return nameOfInvocationExpr != null;
- }
-
- private static bool PreferPredefinedTypeKeywordInDeclarations(NameSyntax name, OptionSet optionSet, SemanticModel semanticModel)
- {
- return (name.Parent != null) && !(name.Parent is MemberAccessExpressionSyntax) &&
- !InsideCrefReference(name) && !InsideNameOfExpression(name, semanticModel) &&
- optionSet.GetOption(SimplificationOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, LanguageNames.CSharp);
- }
-
- private static bool PreferPredefinedTypeKeywordInMemberAccess(ExpressionSyntax memberAccess, OptionSet optionSet, SemanticModel semanticModel)
- {
- return (((memberAccess.Parent != null) && (memberAccess.Parent is MemberAccessExpressionSyntax)) || InsideCrefReference(memberAccess)) &&
- !InsideNameOfExpression(memberAccess, semanticModel) &&
- optionSet.GetOption(SimplificationOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, LanguageNames.CSharp);
- }
-
- public static bool IsAliasReplaceableExpression(this ExpressionSyntax expression)
- {
- if (expression.Kind() == SyntaxKind.IdentifierName ||
- expression.Kind() == SyntaxKind.QualifiedName ||
- expression.Kind() == SyntaxKind.AliasQualifiedName)
- {
- return true;
- }
-
- if (expression.Kind() == SyntaxKind.SimpleMemberAccessExpression)
- {
- var memberAccess = (MemberAccessExpressionSyntax)expression;
- return memberAccess.Expression != null && memberAccess.Expression.IsAliasReplaceableExpression();
- }
-
- return false;
- }
-//
-// private static bool TryReplaceWithAlias(this ExpressionSyntax node, SemanticModel semanticModel, bool preferAliasToQualifiedName, CancellationToken cancellationToken, out IAliasSymbol aliasReplacement)
-// {
-// aliasReplacement = null;
-//
-// if (!node.IsAliasReplaceableExpression())
-// {
-// return false;
-// }
-//
-// var symbol = semanticModel.GetSymbolInfo(node, cancellationToken).Symbol;
-//
-// // If the Symbol is a contrcutor get its containing type
-// if (symbol.IsConstructor())
-// {
-// symbol = symbol.ContainingType;
-// }
-//
-// if (node is QualifiedNameSyntax || node is AliasQualifiedNameSyntax)
-// {
-// SyntaxAnnotation aliasAnnotationInfo = null;
-//
-// // The following condition checks if the user has used alias in the original code and
-// // if so the expression is replaced with the Alias
-// if (node is QualifiedNameSyntax)
-// {
-// var qualifiedNameNode = (QualifiedNameSyntax)node;
-// if (qualifiedNameNode.Right.Identifier.HasAnnotations(AliasAnnotation.Kind))
-// {
-// aliasAnnotationInfo = qualifiedNameNode.Right.Identifier.GetAnnotations(AliasAnnotation.Kind).Single();
-// }
-// }
-//
-// if (node is AliasQualifiedNameSyntax)
-// {
-// var aliasQualifiedNameNode = (AliasQualifiedNameSyntax)node;
-// if (aliasQualifiedNameNode.Name.Identifier.HasAnnotations(AliasAnnotation.Kind))
-// {
-// aliasAnnotationInfo = aliasQualifiedNameNode.Name.Identifier.GetAnnotations(AliasAnnotation.Kind).Single();
-// }
-// }
-//
-// if (aliasAnnotationInfo != null)
-// {
-// var aliasName = AliasAnnotation.GetAliasName(aliasAnnotationInfo);
-// var aliasIdentifier = SyntaxFactory.IdentifierName(aliasName);
-//
-// var aliasTypeInfo = semanticModel.GetSpeculativeAliasInfo(node.SpanStart, aliasIdentifier, SpeculativeBindingOption.BindAsTypeOrNamespace);
-//
-// if (aliasTypeInfo != null)
-// {
-// aliasReplacement = aliasTypeInfo;
-// return ValidateAliasForTarget(aliasReplacement, semanticModel, node, symbol);
-// }
-// }
-// }
-//
-// if (node.Kind() == SyntaxKind.IdentifierName &&
-// semanticModel.GetAliasInfo((IdentifierNameSyntax)node, cancellationToken) != null)
-// {
-// return false;
-// }
-//
-// // an alias can only replace a type or namespace
-// if (symbol == null ||
-// (symbol.Kind != SymbolKind.Namespace && symbol.Kind != SymbolKind.NamedType))
-// {
-// return false;
-// }
-//
-// if (node is QualifiedNameSyntax)
-// {
-// var qualifiedName = (QualifiedNameSyntax)node;
-// if (!qualifiedName.Right.HasAnnotation(Simplifier.SpecialTypeAnnotation))
-// {
-// var type = semanticModel.GetTypeInfo(node, cancellationToken).Type;
-// if (type != null)
-// {
-// var keywordKind = GetPredefinedKeywordKind(type.SpecialType);
-// if (keywordKind != SyntaxKind.None)
-// {
-// preferAliasToQualifiedName = false;
-// }
-// }
-// }
-// }
-//
-// if (node is AliasQualifiedNameSyntax)
-// {
-// var aliasQualifiedNameSyntax = (AliasQualifiedNameSyntax)node;
-// if (!aliasQualifiedNameSyntax.Name.HasAnnotation(Simplifier.SpecialTypeAnnotation))
-// {
-// var type = semanticModel.GetTypeInfo(node, cancellationToken).Type;
-// if (type != null)
-// {
-// var keywordKind = GetPredefinedKeywordKind(type.SpecialType);
-// if (keywordKind != SyntaxKind.None)
-// {
-// preferAliasToQualifiedName = false;
-// }
-// }
-// }
-// }
-//
-// aliasReplacement = GetAliasForSymbol((INamespaceOrTypeSymbol)symbol, node.GetFirstToken(), semanticModel, cancellationToken);
-// if (aliasReplacement != null && preferAliasToQualifiedName)
-// {
-// return ValidateAliasForTarget(aliasReplacement, semanticModel, node, symbol);
-// }
-//
-// return false;
-// }
-//
- // We must verify that the alias actually binds back to the thing it's aliasing.
- // It's possible there's another symbol with the same name as the alias that binds
- // first
- private static bool ValidateAliasForTarget(IAliasSymbol aliasReplacement, SemanticModel semanticModel, ExpressionSyntax node, ISymbol symbol)
- {
- var aliasName = aliasReplacement.Name;
-
- var boundSymbols = semanticModel.LookupNamespacesAndTypes(node.SpanStart, name: aliasName);
-
- if (boundSymbols.Length == 1)
- {
- var boundAlias = boundSymbols[0] as IAliasSymbol;
- if (boundAlias != null && aliasReplacement.Target.Equals(symbol))
- {
- return true;
- }
- }
-
- return false;
- }
-
-// public static IAliasSymbol GetAliasForSymbol(INamespaceOrTypeSymbol symbol, SyntaxToken token, SemanticModel semanticModel, CancellationToken cancellationToken)
-// {
-// var originalSemanticModel = (SemanticModel)semanticModel.GetOriginalSemanticModel();
-// if (!originalSemanticModel.SyntaxTree.HasCompilationUnitRoot)
-// {
-// return null;
-// }
-//
-// IAliasSymbol aliasSymbol;
-// var namespaceId = GetNamespaceIdForAliasSearch(semanticModel, token, cancellationToken);
-// if (namespaceId < 0)
-// {
-// return null;
-// }
-//
-// if (!AliasSymbolCache.TryGetAliasSymbol(originalSemanticModel, namespaceId, symbol, out aliasSymbol))
-// {
-// // add cache
-// AliasSymbolCache.AddAliasSymbols(originalSemanticModel, namespaceId, semanticModel.LookupNamespacesAndTypes(token.SpanStart).OfType<IAliasSymbol>());
-//
-// // retry
-// AliasSymbolCache.TryGetAliasSymbol(originalSemanticModel, namespaceId, symbol, out aliasSymbol);
-// }
-//
-// return aliasSymbol;
-// }
-//
-// private static SyntaxNode GetStartNodeForNamespaceId(SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken)
-// {
-// if (!semanticModel.IsSpeculativeSemanticModel)
-// {
-// return token.Parent;
-// }
-//
-// var originalSemanticMode = (SemanticModel)semanticModel.GetOriginalSemanticModel();
-// token = originalSemanticMode.SyntaxTree.GetRoot(cancellationToken).FindToken(semanticModel.OriginalPositionForSpeculation);
-//
-// return token.Parent;
-// }
-
-// private static int GetNamespaceIdForAliasSearch(SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken)
-// {
-// var startNode = GetStartNodeForNamespaceId(semanticModel, token, cancellationToken);
-// if (!startNode.SyntaxTree.HasCompilationUnitRoot)
-// {
-// return -1;
-// }
-//
-// // NOTE: If we're currently in a block of usings, then we want to collect the
-// // aliases that are higher up than this block. Using aliases declared in a block of
-// // usings are not usable from within that same block.
-// var usingDirective = startNode.GetAncestorOrThis<UsingDirectiveSyntax>();
-// if (usingDirective != null)
-// {
-// startNode = usingDirective.Parent.Parent;
-// if (startNode == null)
-// {
-// return -1;
-// }
-// }
-//
-// // check whether I am under a namespace
-// var @namespace = startNode.GetAncestorOrThis<NamespaceDeclarationSyntax>();
-// if (@namespace != null)
-// {
-// // since we have node inside of the root, root should be already there
-// // search for namespace id should be quite cheap since normally there should be
-// // only a few namespace defined in a source file if it is not 1. that is why it is
-// // not cached.
-// var startIndex = 1;
-// return GetNamespaceId(startNode.SyntaxTree.GetRoot(cancellationToken), @namespace, ref startIndex);
-// }
-//
-// // no namespace, under compilation unit directly
-// return 0;
-// }
-//
-// private static int GetNamespaceId(SyntaxNode container, NamespaceDeclarationSyntax target, ref int index)
-// {
-// var compilation = container as CompilationUnitSyntax;
-// if (compilation != null)
-// {
-// return GetNamespaceId(compilation.Members, target, ref index);
-// }
-//
-// var @namespace = container as NamespaceDeclarationSyntax;
-// if (@namespace != null)
-// {
-// return GetNamespaceId(@namespace.Members, target, ref index);
-// }
-//
-// return Contract.FailWithReturn<int>("shouldn't reach here");
-// }
-//
-// private static int GetNamespaceId(SyntaxList<MemberDeclarationSyntax> members, NamespaceDeclarationSyntax target, ref int index)
-// {
-// foreach (var member in members)
-// {
-// var childNamespace = member as NamespaceDeclarationSyntax;
-// if (childNamespace == null)
-// {
-// continue;
-// }
-//
-// if (childNamespace == target)
-// {
-// return index;
-// }
-//
-// index++;
-// var result = GetNamespaceId(childNamespace, target, ref index);
-// if (result > 0)
-// {
-// return result;
-// }
-// }
-//
-// return -1;
-// }
-//
-// private static bool TryReduce(
-// this NameSyntax name,
-// SemanticModel semanticModel,
-// out TypeSyntax replacementNode,
-// out TextSpan issueSpan,
-// OptionSet optionSet,
-// CancellationToken cancellationToken)
-// {
-// replacementNode = null;
-// issueSpan = default(TextSpan);
-//
-// if (name.IsVar)
-// {
-// return false;
-// }
-//
-// // we should not simplify a name of a namespace declaration
-// if (IsPartOfNamespaceDeclarationName(name))
-// {
-// return false;
-// }
-//
-// // We can simplify Qualified names and AliasQualifiedNames. Generally, if we have
-// // something like "A.B.C.D", we only consider the full thing something we can simplify.
-// // However, in the case of "A.B.C<>.D", then we'll only consider simplifying up to the
-// // first open name. This is because if we remove the open name, we'll often change
-// // meaning as "D" will bind to C<T>.D which is different than C<>.D!
-// if (name is QualifiedNameSyntax)
-// {
-// var left = ((QualifiedNameSyntax)name).Left;
-// if (ContainsOpenName(left))
-// {
-// // Don't simplify A.B<>.C
-// return false;
-// }
-// }
-//
-// // 1. see whether binding the name binds to a symbol/type. if not, it is ambiguous and
-// // nothing we can do here.
-// var symbol = SimplificationHelpers.GetOriginalSymbolInfo(semanticModel, name);
-// if (symbol == null)
-// {
-// return false;
-// }
-//
-// // treat constructor names as types
-// var method = symbol as IMethodSymbol;
-// if (method.IsConstructor())
-// {
-// symbol = method.ContainingType;
-// }
-//
-// if (symbol.Kind == SymbolKind.Method && name.Kind() == SyntaxKind.GenericName)
-// {
-// // The option wants the generic method invocation name to be explicit, then quit the reduction
-// if (!optionSet.GetOption(SimplificationOptions.PreferImplicitTypeInference))
-// {
-// return false;
-// }
-//
-// var genericName = (GenericNameSyntax)name;
-// replacementNode = SyntaxFactory.IdentifierName(genericName.Identifier)
-// .WithLeadingTrivia(genericName.GetLeadingTrivia())
-// .WithTrailingTrivia(genericName.GetTrailingTrivia());
-//
-// issueSpan = genericName.TypeArgumentList.Span;
-// return name.CanReplaceWithReducedName(replacementNode, semanticModel, cancellationToken);
-// }
-//
-// if (!(symbol is INamespaceOrTypeSymbol))
-// {
-// return false;
-// }
-//
-// if (name.HasAnnotations(SpecialTypeAnnotation.Kind))
-// {
-// replacementNode = SyntaxFactory.PredefinedType(
-// SyntaxFactory.Token(
-// name.GetLeadingTrivia(),
-// GetPredefinedKeywordKind(SpecialTypeAnnotation.GetSpecialType(name.GetAnnotations(SpecialTypeAnnotation.Kind).First())),
-// name.GetTrailingTrivia()));
-//
-// issueSpan = name.Span;
-//
-// return name.CanReplaceWithReducedNameInContext(replacementNode, semanticModel, cancellationToken);
-// }
-// else
-// {
-// if (!name.IsRightSideOfDotOrColonColon())
-// {
-// IAliasSymbol aliasReplacement;
-// if (name.TryReplaceWithAlias(semanticModel, optionSet.GetOption(SimplificationOptions.PreferAliasToQualification), cancellationToken, out aliasReplacement))
-// {
-// // get the token text as it appears in source code to preserve e.g. unicode character escaping
-// var text = aliasReplacement.Name;
-// var syntaxRef = aliasReplacement.DeclaringSyntaxReferences.FirstOrDefault();
-//
-// if (syntaxRef != null)
-// {
-// var declIdentifier = ((UsingDirectiveSyntax)syntaxRef.GetSyntax(cancellationToken)).Alias.Name.Identifier;
-// text = declIdentifier.IsVerbatimIdentifier() ? declIdentifier.ToString().Substring(1) : declIdentifier.ToString();
-// }
-//
-// var identifierToken = SyntaxFactory.Identifier(
-// name.GetLeadingTrivia(),
-// SyntaxKind.IdentifierToken,
-// text,
-// aliasReplacement.Name,
-// name.GetTrailingTrivia());
-//
-// identifierToken = CSharpSimplificationService.TryEscapeIdentifierToken(identifierToken, name, semanticModel);
-// replacementNode = SyntaxFactory.IdentifierName(identifierToken);
-//
-// // Merge annotation to new syntax node
-// var annotatedNodesOrTokens = name.GetAnnotatedNodesAndTokens(RenameAnnotation.Kind);
-// foreach (var annotatedNodeOrToken in annotatedNodesOrTokens)
-// {
-// if (annotatedNodeOrToken.IsToken)
-// {
-// identifierToken = annotatedNodeOrToken.AsToken().CopyAnnotationsTo(identifierToken);
-// }
-// else
-// {
-// replacementNode = annotatedNodeOrToken.AsNode().CopyAnnotationsTo(replacementNode);
-// }
-// }
-//
-// annotatedNodesOrTokens = name.GetAnnotatedNodesAndTokens(AliasAnnotation.Kind);
-// foreach (var annotatedNodeOrToken in annotatedNodesOrTokens)
-// {
-// if (annotatedNodeOrToken.IsToken)
-// {
-// identifierToken = annotatedNodeOrToken.AsToken().CopyAnnotationsTo(identifierToken);
-// }
-// else
-// {
-// replacementNode = annotatedNodeOrToken.AsNode().CopyAnnotationsTo(replacementNode);
-// }
-// }
-//
-// replacementNode = ((SimpleNameSyntax)replacementNode).WithIdentifier(identifierToken);
-// issueSpan = name.Span;
-//
-// // In case the alias name is the same as the last name of the alias target, we only include
-// // the left part of the name in the unnecessary span to Not confuse uses.
-// if (name.Kind() == SyntaxKind.QualifiedName)
-// {
-// QualifiedNameSyntax qualifiedName = (QualifiedNameSyntax)name;
-//
-// if (qualifiedName.Right.Identifier.ValueText == identifierToken.ValueText)
-// {
-// issueSpan = qualifiedName.Left.Span;
-// }
-// }
-//
-// // first check if this would be a valid reduction
-// if (name.CanReplaceWithReducedNameInContext(replacementNode, semanticModel, cancellationToken))
-// {
-// // in case this alias name ends with "Attribute", we're going to see if we can also
-// // remove that suffix.
-// TypeSyntax replacementNodeWithoutAttributeSuffix;
-// TextSpan issueSpanWithoutAttributeSuffix;
-// if (TryReduceAttributeSuffix(
-// name,
-// identifierToken,
-// semanticModel,
-// out replacementNodeWithoutAttributeSuffix,
-// out issueSpanWithoutAttributeSuffix,
-// cancellationToken))
-// {
-// if (name.CanReplaceWithReducedName(replacementNodeWithoutAttributeSuffix, semanticModel, cancellationToken))
-// {
-// replacementNode = replacementNode.CopyAnnotationsTo(replacementNodeWithoutAttributeSuffix);
-// issueSpan = issueSpanWithoutAttributeSuffix;
-// }
-// }
-//
-// return true;
-// }
-//
-// return false;
-// }
-//
-// var nameHasNoAlias = false;
-//
-// if (name is SimpleNameSyntax)
-// {
-// var simpleName = (SimpleNameSyntax)name;
-// if (!simpleName.Identifier.HasAnnotations(AliasAnnotation.Kind))
-// {
-// nameHasNoAlias = true;
-// }
-// }
-//
-// if (name is QualifiedNameSyntax)
-// {
-// var qualifiedName = (QualifiedNameSyntax)name;
-// if (!qualifiedName.Right.HasAnnotation(Simplifier.SpecialTypeAnnotation))
-// {
-// nameHasNoAlias = true;
-// }
-// }
-//
-// if (name is AliasQualifiedNameSyntax)
-// {
-// var aliasQualifiedName = (AliasQualifiedNameSyntax)name;
-// if (aliasQualifiedName.Name is SimpleNameSyntax &&
-// !aliasQualifiedName.Name.Identifier.HasAnnotations(AliasAnnotation.Kind) &&
-// !aliasQualifiedName.Name.HasAnnotation(Simplifier.SpecialTypeAnnotation))
-// {
-// nameHasNoAlias = true;
-// }
-// }
-//
-// var aliasInfo = semanticModel.GetAliasInfo(name, cancellationToken);
-// if (nameHasNoAlias && aliasInfo == null)
-// {
-// if (IsReplacableByVar(name, semanticModel, out replacementNode, out issueSpan, optionSet, cancellationToken))
-// {
-// return true;
-// }
-//
-// if (PreferPredefinedTypeKeywordInDeclarations(name, optionSet, semanticModel) ||
-// PreferPredefinedTypeKeywordInMemberAccess(name, optionSet, semanticModel))
-// {
-// var type = semanticModel.GetTypeInfo(name, cancellationToken).Type;
-// if (type != null)
-// {
-// var keywordKind = GetPredefinedKeywordKind(type.SpecialType);
-// if (keywordKind != SyntaxKind.None)
-// {
-// return CanReplaceWithPredefinedTypeKeywordInContext(name, semanticModel, out replacementNode, ref issueSpan, keywordKind, cancellationToken);
-// }
-// }
-// else
-// {
-// var typeSymbol = semanticModel.GetSymbolInfo(name, cancellationToken).Symbol;
-// if (typeSymbol.IsKind(SymbolKind.NamedType))
-// {
-// var keywordKind = GetPredefinedKeywordKind(((INamedTypeSymbol)typeSymbol).SpecialType);
-// if (keywordKind != SyntaxKind.None)
-// {
-// return CanReplaceWithPredefinedTypeKeywordInContext(name, semanticModel, out replacementNode, ref issueSpan, keywordKind, cancellationToken);
-// }
-// }
-// }
-// }
-// }
-//
-// // nullable rewrite: Nullable<int> -> int?
-// // Don't rewrite in the case where Nullable<int> is part of some qualified name like Nullable<int>.Something
-// if (!name.IsVar && (symbol.Kind == SymbolKind.NamedType) && !name.IsLeftSideOfQualifiedName())
-// {
-// var type = (INamedTypeSymbol)symbol;
-// if (!type.IsUnboundGenericType && // Don't rewrite unbound generic type "Nullable<>"
-// type.IsNullable() &&
-// aliasInfo == null)
-// {
-// GenericNameSyntax genericName;
-// if (name.Kind() == SyntaxKind.QualifiedName)
-// {
-// genericName = (GenericNameSyntax)((QualifiedNameSyntax)name).Right;
-// }
-// else
-// {
-// genericName = (GenericNameSyntax)name;
-// }
-//
-// var oldType = genericName.TypeArgumentList.Arguments.First();
-// if (oldType.Kind() == SyntaxKind.OmittedTypeArgument)
-// {
-// return false;
-// }
-//
-// replacementNode = SyntaxFactory.NullableType(oldType)
-// .WithLeadingTrivia(name.GetLeadingTrivia())
-// .WithTrailingTrivia(name.GetTrailingTrivia());
-// issueSpan = name.Span;
-//
-// // we need to simplify the whole qualified name at once, because replacing the identifier on the left in
-// // System.Nullable<int> alone would be illegal.
-// // If this fails we want to continue to try at least to remove the System if possible.
-// if (name.CanReplaceWithReducedNameInContext(replacementNode, semanticModel, cancellationToken))
-// {
-// return true;
-// }
-// }
-// }
-// }
-//
-// SyntaxToken identifier;
-// switch (name.Kind())
-// {
-// case SyntaxKind.AliasQualifiedName:
-// var simpleName = ((AliasQualifiedNameSyntax)name).Name
-// .WithLeadingTrivia(name.GetLeadingTrivia());
-//
-// simpleName = simpleName.ReplaceToken(simpleName.Identifier,
-// ((AliasQualifiedNameSyntax)name).Name.Identifier.CopyAnnotationsTo(
-// simpleName.Identifier.WithLeadingTrivia(
-// ((AliasQualifiedNameSyntax)name).Alias.Identifier.LeadingTrivia)));
-//
-// replacementNode = simpleName;
-//
-// issueSpan = ((AliasQualifiedNameSyntax)name).Alias.Span;
-//
-// break;
-//
-// case SyntaxKind.QualifiedName:
-// replacementNode = ((QualifiedNameSyntax)name).Right.WithLeadingTrivia(name.GetLeadingTrivia());
-// issueSpan = ((QualifiedNameSyntax)name).Left.Span;
-//
-// break;
-//
-// case SyntaxKind.IdentifierName:
-// identifier = ((IdentifierNameSyntax)name).Identifier;
-//
-// // we can try to remove the Attribute suffix if this is the attribute name
-// TryReduceAttributeSuffix(name, identifier, semanticModel, out replacementNode, out issueSpan, cancellationToken);
-// break;
-// }
-// }
-//
-// if (replacementNode == null)
-// {
-// return false;
-// }
-//
-// return name.CanReplaceWithReducedName(replacementNode, semanticModel, cancellationToken);
-// }
-//
-// private static bool CanReplaceWithPredefinedTypeKeywordInContext(NameSyntax name, SemanticModel semanticModel, out TypeSyntax replacementNode, ref TextSpan issueSpan, SyntaxKind keywordKind, CancellationToken cancellationToken)
-// {
-// replacementNode = CreatePredefinedTypeSyntax(name, keywordKind);
-//
-// issueSpan = name.Span; // we want to show the whole name expression as unnecessary
-//
-// return name.CanReplaceWithReducedNameInContext(replacementNode, semanticModel, cancellationToken);
-// }
-//
-// private static TypeSyntax CreatePredefinedTypeSyntax(ExpressionSyntax expression, SyntaxKind keywordKind)
-// {
-// return SyntaxFactory.PredefinedType(SyntaxFactory.Token(expression.GetLeadingTrivia(), keywordKind, expression.GetTrailingTrivia()));
-// }
-//
-// private static bool TryReduceAttributeSuffix(
-// NameSyntax name,
-// SyntaxToken identifierToken,
-// SemanticModel semanticModel,
-// out TypeSyntax replacementNode,
-// out TextSpan issueSpan,
-// CancellationToken cancellationToken)
-// {
-// issueSpan = default(TextSpan);
-// replacementNode = default(TypeSyntax);
-//
-// // we can try to remove the Attribute suffix if this is the attribute name
-// if (SyntaxFacts.IsAttributeName(name))
-// {
-// if (name.Parent.Kind() == SyntaxKind.Attribute || name.IsRightSideOfDotOrColonColon())
-// {
-// const string AttributeName = "Attribute";
-//
-// // an attribute that should keep it (unnecessary "Attribute" suffix should be annotated with a DontSimplifyAnnotation
-// if (identifierToken.ValueText != AttributeName && identifierToken.ValueText.EndsWith(AttributeName) && !identifierToken.HasAnnotation(SimplificationHelpers.DontSimplifyAnnotation))
-// {
-// // weird. the semantic model is able to bind attribute syntax like "[as()]" although it's not valid code.
-// // so we need another check for keywords manually.
-// var newAttributeName = identifierToken.ValueText.Substring(0, identifierToken.ValueText.Length - 9);
-// if (SyntaxFacts.GetKeywordKind(newAttributeName) != SyntaxKind.None)
-// {
-// return false;
-// }
-//
-// // if this attribute name in source contained unicode escaping, we will loose it now
-// // because there is no easy way to determine the substring from identifier->ToString()
-// // which would be needed to pass to SyntaxFactory.Identifier
-// // The result is an unescaped unicode character in source.
-//
-// // once we remove the Attribute suffix, we can't use an escaped identifier
-// var newIdentifierToken = identifierToken.CopyAnnotationsTo(
-// SyntaxFactory.Identifier(
-// identifierToken.LeadingTrivia,
-// newAttributeName,
-// identifierToken.TrailingTrivia));
-//
-// replacementNode = SyntaxFactory.IdentifierName(newIdentifierToken)
-// .WithLeadingTrivia(name.GetLeadingTrivia());
-// issueSpan = new TextSpan(identifierToken.Span.End - 9, 9);
-//
-// return true;
-// }
-// }
-// }
-//
-// return false;
-// }
-//
-// /// <summary>
-// /// Checks if the SyntaxNode is a name of a namespace declaration. To be a namespace name, the syntax
-// /// must be parented by an namespace declaration and the node itself must be equal to the declaration's Name
-// /// property.
-// /// </summary>
-// /// <param name="node"></param>
-// /// <returns></returns>
-// public static bool IsPartOfNamespaceDeclarationName(SyntaxNode node)
-// {
-// var parent = node;
-//
-// while (parent != null)
-// {
-// switch (parent.Kind())
-// {
-// case SyntaxKind.IdentifierName:
-// case SyntaxKind.QualifiedName:
-// node = parent;
-// parent = parent.Parent;
-// break;
-//
-// case SyntaxKind.NamespaceDeclaration:
-// var namespaceDeclaration = (NamespaceDeclarationSyntax)parent;
-// return object.Equals(namespaceDeclaration.Name, node);
-//
-// default:
-// return false;
-// }
-// }
-//
-// return false;
-// }
-//
-// private static bool TrySimplify(
-// this ExpressionSyntax expression,
-// SemanticModel semanticModel,
-// OptionSet optionSet,
-// out ExpressionSyntax replacementNode,
-// out TextSpan issueSpan)
-// {
-// replacementNode = null;
-// issueSpan = default(TextSpan);
-//
-// switch (expression.Kind())
-// {
-// case SyntaxKind.SimpleMemberAccessExpression:
-// {
-// var memberAccess = (MemberAccessExpressionSyntax)expression;
-// ExpressionSyntax newLeft;
-//
-// if (IsMemberAccessADynamicInvocation(memberAccess, semanticModel))
-// {
-// return false;
-// }
-//
-// if (TrySimplifyMemberAccessOrQualifiedName(memberAccess.Expression, memberAccess.Name, semanticModel, optionSet, out newLeft, out issueSpan))
-// {
-// // replacement node might not be in it's simplest form, so add simplify annotation to it.
-// replacementNode = memberAccess.Update(newLeft, memberAccess.OperatorToken, memberAccess.Name)
-// .WithAdditionalAnnotations(Simplifier.Annotation);
-//
-// // Ensure that replacement doesn't change semantics.
-// return !ReplacementChangesSemantics(memberAccess, replacementNode, semanticModel);
-// }
-//
-// return false;
-// }
-//
-// case SyntaxKind.QualifiedName:
-// {
-// var qualifiedName = (QualifiedNameSyntax)expression;
-// ExpressionSyntax newLeft;
-// if (TrySimplifyMemberAccessOrQualifiedName(qualifiedName.Left, qualifiedName.Right, semanticModel, optionSet, out newLeft, out issueSpan))
-// {
-// // replacement node might not be in it's simplest form, so add simplify annotation to it.
-// replacementNode = qualifiedName.Update((NameSyntax)newLeft, qualifiedName.DotToken, qualifiedName.Right)
-// .WithAdditionalAnnotations(Simplifier.Annotation);
-//
-// // Ensure that replacement doesn't change semantics.
-// return !ReplacementChangesSemantics(qualifiedName, replacementNode, semanticModel);
-// }
-//
-// return false;
-// }
-// }
-//
-// return false;
-// }
-//
-// private static bool ReplacementChangesSemantics(ExpressionSyntax originalExpression, ExpressionSyntax replacedExpression, SemanticModel semanticModel)
-// {
-// var speculationAnalyzer = new SpeculationAnalyzer(originalExpression, replacedExpression, semanticModel, CancellationToken.None);
-// return speculationAnalyzer.ReplacementChangesSemantics();
-// }
-//
-// // Note: The caller needs to verify that replacement doesn't change semantics of the original expression.
-// private static bool TrySimplifyMemberAccessOrQualifiedName(
-// ExpressionSyntax left,
-// ExpressionSyntax right,
-// SemanticModel semanticModel,
-// OptionSet optionSet,
-// out ExpressionSyntax replacementNode,
-// out TextSpan issueSpan)
-// {
-// replacementNode = null;
-// issueSpan = default(TextSpan);
-//
-// if (left != null && right != null)
-// {
-// var leftSymbol = SimplificationHelpers.GetOriginalSymbolInfo(semanticModel, left);
-// if (leftSymbol != null && (leftSymbol.Kind == SymbolKind.NamedType))
-// {
-// var rightSymbol = SimplificationHelpers.GetOriginalSymbolInfo(semanticModel, right);
-// if (rightSymbol != null && (rightSymbol.IsStatic || rightSymbol.Kind == SymbolKind.NamedType))
-// {
-// // Static member access or nested type member access.
-// INamedTypeSymbol containingType = rightSymbol.ContainingType;
-//
-// var enclosingSymbol = semanticModel.GetEnclosingSymbol(left.SpanStart);
-// List<ISymbol> enclosingTypeParametersInsideOut = new List<ISymbol>();
-//
-// while (enclosingSymbol != null)
-// {
-// if (enclosingSymbol is IMethodSymbol)
-// {
-// var methodSymbol = (IMethodSymbol)enclosingSymbol;
-// if (methodSymbol.TypeArguments.Length != 0)
-// {
-// enclosingTypeParametersInsideOut.AddRange(methodSymbol.TypeArguments);
-// }
-// }
-//
-// if (enclosingSymbol is INamedTypeSymbol)
-// {
-// var namedTypeSymbol = (INamedTypeSymbol)enclosingSymbol;
-// if (namedTypeSymbol.TypeArguments.Length != 0)
-// {
-// enclosingTypeParametersInsideOut.AddRange(namedTypeSymbol.TypeArguments);
-// }
-// }
-//
-// enclosingSymbol = enclosingSymbol.ContainingSymbol;
-// }
-//
-// if (containingType != null && !containingType.Equals(leftSymbol))
-// {
-// var namedType = leftSymbol as INamedTypeSymbol;
-// if (namedType != null)
-// {
-// if ((namedType.GetBaseTypes().Contains(containingType) &&
-// !optionSet.GetOption(SimplificationOptions.AllowSimplificationToBaseType)) ||
-// (!optionSet.GetOption(SimplificationOptions.AllowSimplificationToGenericType) &&
-// containingType.TypeArguments.Count() != 0))
-// {
-// return false;
-// }
-// }
-//
-// // We have a static member access or a nested type member access using a more derived type.
-// // Simplify syntax so as to use accessed member's most immediate containing type instead of the derived type.
-// replacementNode = containingType.GenerateTypeSyntax()
-// .WithLeadingTrivia(left.GetLeadingTrivia())
-// .WithTrailingTrivia(left.GetTrailingTrivia());
-// issueSpan = left.Span;
-// return true;
-// }
-// }
-// }
-// }
-//
-// return false;
-// }
-//
-// /// <summary>
-// /// Returns True if enclosingTypeParametersInsideOut contains a symbol with the same name as the candidateSymbol
-// /// thereby saying that there exists a symbol which hides the candidate Symbol
-// /// </summary>
-// private static bool HidingTypeParameterSymbolExists(ISymbol candidateSymbol, List<ISymbol> enclosingTypeParametersInsideOut)
-// {
-// foreach (var enclosingTypeParameter in enclosingTypeParametersInsideOut)
-// {
-// ISymbol newCandidateSymbol = candidateSymbol;
-// if (candidateSymbol.IsKind(SymbolKind.ArrayType))
-// {
-// newCandidateSymbol = ((IArrayTypeSymbol)candidateSymbol).ElementType;
-// }
-//
-// if (newCandidateSymbol.MetadataName == enclosingTypeParameter.MetadataName)
-// {
-// if (SymbolEquivalenceComparer.Instance.Equals(newCandidateSymbol.GetOriginalUnreducedDefinition(), enclosingTypeParameter.GetOriginalUnreducedDefinition()))
-// {
-// return false;
-// }
-//
-// return true;
-// }
-// }
-//
-// return false;
-// }
-
-// private static bool CanReplaceWithReducedName(
-// this MemberAccessExpressionSyntax memberAccess,
-// ExpressionSyntax reducedName,
-// SemanticModel semanticModel,
-// CancellationToken cancellationToken)
-// {
-// if (!IsThisOrTypeOrNamespace(memberAccess, semanticModel))
-// {
-// return false;
-// }
-//
-// var speculationAnalyzer = new SpeculationAnalyzer(memberAccess, reducedName, semanticModel, cancellationToken);
-// if (!speculationAnalyzer.SymbolsForOriginalAndReplacedNodesAreCompatible() ||
-// speculationAnalyzer.ReplacementChangesSemantics())
-// {
-// return false;
-// }
-//
-// if (WillConflictWithExistingLocal(memberAccess, reducedName))
-// {
-// return false;
-// }
-//
-// if (IsMemberAccessADynamicInvocation(memberAccess, semanticModel))
-// {
-// return false;
-// }
-//
-// if (memberAccess.AccessMethodWithDynamicArgumentInsideStructConstructor(semanticModel))
-// {
-// return false;
-// }
-//
-// if (memberAccess.Expression.Kind() == SyntaxKind.BaseExpression)
-// {
-// var enclosingNamedType = semanticModel.GetEnclosingNamedType(memberAccess.SpanStart, cancellationToken);
-// var symbol = semanticModel.GetSymbolInfo(memberAccess.Name, cancellationToken).Symbol;
-// if (enclosingNamedType != null &&
-// !enclosingNamedType.IsSealed &&
-// symbol != null &&
-// symbol.IsOverridable())
-// {
-// return false;
-// }
-// }
-//
-// var invalidTransformation1 = ParserWouldTreatExpressionAsCast(reducedName, memberAccess);
-//
-// return !invalidTransformation1;
-// }
-
- private static bool ParserWouldTreatExpressionAsCast(ExpressionSyntax reducedNode, MemberAccessExpressionSyntax originalNode)
- {
- SyntaxNode parent = originalNode;
- while (parent != null)
- {
- if (parent.IsParentKind(SyntaxKind.SimpleMemberAccessExpression))
- {
- parent = parent.Parent;
- continue;
- }
-
- if (!parent.IsParentKind(SyntaxKind.ParenthesizedExpression))
- {
- return false;
- }
-
- break;
- }
-
- var newExpression = parent.ReplaceNode(originalNode, reducedNode);
-
- // detect cast ambiguities according to C# spec #7.7.6
- if (IsNameOrMemberAccessButNoExpression(newExpression))
- {
- var nextToken = parent.Parent.GetLastToken().GetNextToken();
-
- return nextToken.Kind() == SyntaxKind.OpenParenToken ||
- nextToken.Kind() == SyntaxKind.TildeToken ||
- nextToken.Kind() == SyntaxKind.ExclamationToken ||
- (SyntaxFacts.IsKeywordKind(nextToken.Kind()) && !(nextToken.Kind() == SyntaxKind.AsKeyword || nextToken.Kind() == SyntaxKind.IsKeyword));
- }
-
- return false;
- }
-
- private static bool IsNameOrMemberAccessButNoExpression(SyntaxNode node)
- {
- if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression))
- {
- var memberAccess = (MemberAccessExpressionSyntax)node;
-
- return memberAccess.Expression.IsKind(SyntaxKind.IdentifierName) ||
- IsNameOrMemberAccessButNoExpression(memberAccess.Expression);
- }
-
- return node.IsKind(SyntaxKind.IdentifierName);
- }
-
- /// <summary>
- /// Tells if the Member access is the starting part of a Dynamic Invocation
- /// </summary>
- /// <param name="memberAccess"></param>
- /// <param name="semanticModel"></param>
- /// <returns>Return true, if the member access is the starting point of a Dynamic Invocation</returns>
- private static bool IsMemberAccessADynamicInvocation(MemberAccessExpressionSyntax memberAccess, SemanticModel semanticModel)
- {
- var ancestorInvocation = memberAccess.FirstAncestorOrSelf<InvocationExpressionSyntax>();
-
- if (ancestorInvocation != null && ancestorInvocation.SpanStart == memberAccess.SpanStart)
- {
- var typeInfo = semanticModel.GetTypeInfo(ancestorInvocation);
- if (typeInfo.Type != null &&
- typeInfo.Type.Kind == SymbolKind.DynamicType)
- {
- return true;
- }
- }
-
- return false;
- }
-
- /*
- * Name Reduction, to implicitly mean "this", is possible only after the initialization of all member variables but
- * since the check for initialization of all member variable is a lot of work for this simplification we don't simplify
- * even if all the member variables are initialized
- */
- private static bool AccessMethodWithDynamicArgumentInsideStructConstructor(this MemberAccessExpressionSyntax memberAccess, SemanticModel semanticModel)
- {
- var constructor = memberAccess.Ancestors().OfType<ConstructorDeclarationSyntax>().SingleOrDefault();
-
- if (constructor == null || constructor.Parent.Kind() != SyntaxKind.StructDeclaration)
- {
- return false;
- }
-
- return semanticModel.GetSymbolInfo(memberAccess.Name).CandidateReason == CandidateReason.LateBound;
- }
-
-// private static bool CanReplaceWithReducedName(this NameSyntax name, TypeSyntax reducedName, SemanticModel semanticModel, CancellationToken cancellationToken)
-// {
-// var speculationAnalyzer = new SpeculationAnalyzer(name, reducedName, semanticModel, cancellationToken);
-// if (speculationAnalyzer.ReplacementChangesSemantics())
-// {
-// return false;
-// }
-//
-// return CanReplaceWithReducedNameInContext(name, reducedName, semanticModel, cancellationToken);
-// }
-//
-// private static bool CanReplaceWithReducedNameInContext(this NameSyntax name, TypeSyntax reducedName, SemanticModel semanticModel, CancellationToken cancellationToken)
-// {
-// // Special case. if this new minimal name parses out to a predefined type, then we
-// // have to make sure that we're not in a using alias. That's the one place where the
-// // language doesn't allow predefined types. You have to use the fully qualified name
-// // instead.
-// var invalidTransformation1 = IsNonNameSyntaxInUsingDirective(name, reducedName);
-// var invalidTransformation2 = WillConflictWithExistingLocal(name, reducedName);
-// var invalidTransformation3 = IsAmbiguousCast(name, reducedName);
-// var invalidTransformation4 = IsNullableTypeInPointerExpression(name, reducedName);
-// var isNotNullableReplacable = name.IsNotNullableReplacable(reducedName);
-//
-// if (invalidTransformation1 || invalidTransformation2 || invalidTransformation3 || invalidTransformation4
-// || isNotNullableReplacable)
-// {
-// return false;
-// }
-//
-// return true;
-// }
-
- private static bool IsNotNullableReplacable(this NameSyntax name, TypeSyntax reducedName)
- {
- var isNotNullableReplacable = false;
- // var isLeftSideOfDot = name.IsLeftSideOfDot();
- // var isRightSideOfDot = name.IsRightSideOfDot();
-
- if (reducedName.Kind() == SyntaxKind.NullableType)
- {
- if (((NullableTypeSyntax)reducedName).ElementType.Kind() == SyntaxKind.OmittedTypeArgument)
- {
- isNotNullableReplacable = true;
- }
- else
- {
- isNotNullableReplacable = name.IsLeftSideOfDot() || name.IsRightSideOfDot();
- }
- }
-
- return isNotNullableReplacable;
- }
-
-// private static bool IsThisOrTypeOrNamespace(MemberAccessExpressionSyntax memberAccess, SemanticModel semanticModel)
-// {
-// if (memberAccess.Expression.Kind() == SyntaxKind.ThisExpression)
-// {
-// var previousToken = memberAccess.Expression.GetFirstToken().GetPreviousToken();
-//
-// var symbol = semanticModel.GetSymbolInfo(memberAccess.Name).Symbol;
-//
-// if (previousToken.Kind() == SyntaxKind.OpenParenToken &&
-// previousToken.Parent.IsKind(SyntaxKind.ParenthesizedExpression) &&
-// !previousToken.Parent.IsParentKind(SyntaxKind.ParenthesizedExpression) &&
-// ((ParenthesizedExpressionSyntax)previousToken.Parent).Expression.Kind() == SyntaxKind.SimpleMemberAccessExpression &&
-// symbol != null && symbol.Kind == SymbolKind.Method)
-// {
-// return false;
-// }
-//
-// return true;
-// }
-//
-// var expressionInfo = semanticModel.GetSymbolInfo(memberAccess.Expression);
-// if (SimplificationHelpers.IsValidSymbolInfo(expressionInfo.Symbol))
-// {
-// if (expressionInfo.Symbol is INamespaceOrTypeSymbol)
-// {
-// return true;
-// }
-//
-// if (expressionInfo.Symbol.IsThisParameter())
-// {
-// return true;
-// }
-// }
-//
-// return false;
-// }
-
- private static bool IsReplacableByVar(
- this TypeSyntax simpleName,
- SemanticModel semanticModel,
- out TypeSyntax replacementNode,
- out TextSpan issueSpan,
- OptionSet optionSet,
- CancellationToken cancellationToken)
- {
- replacementNode = null;
- issueSpan = default(TextSpan);
-
- if (!optionSet.GetOption(SimplificationOptions.PreferImplicitTypeInLocalDeclaration))
- {
- return false;
- }
-
- // If it is already var
- if (simpleName.IsVar)
- {
- return false;
- }
-
- var candidateReplacementNode = SyntaxFactory.IdentifierName("var")
- .WithLeadingTrivia(simpleName.GetLeadingTrivia())
- .WithTrailingTrivia(simpleName.GetTrailingTrivia());
- var candidateIssueSpan = simpleName.Span;
-
- // If there exists a Type called var , fail.
- var checkSymbol = semanticModel.GetSpeculativeSymbolInfo(simpleName.SpanStart, candidateReplacementNode, SpeculativeBindingOption.BindAsTypeOrNamespace).Symbol;
- if (checkSymbol != null && checkSymbol.IsKind(SymbolKind.NamedType) && ((INamedTypeSymbol)checkSymbol).TypeKind == TypeKind.Class && checkSymbol.Name == "var")
- {
- return false;
- }
-
- // If the simpleName is the type of the Variable Declaration Syntax belonging to LocalDeclaration, For Statement or Using statement
- if (simpleName.IsParentKind(SyntaxKind.VariableDeclaration) &&
- ((VariableDeclarationSyntax)simpleName.Parent).Type == simpleName &&
- simpleName.Parent.Parent.IsKind(SyntaxKind.LocalDeclarationStatement, SyntaxKind.ForStatement, SyntaxKind.UsingStatement))
- {
- if (simpleName.Parent.IsParentKind(SyntaxKind.LocalDeclarationStatement) &&
- ((LocalDeclarationStatementSyntax)simpleName.Parent.Parent).Modifiers.Any(n => n.Kind() == SyntaxKind.ConstKeyword))
- {
- return false;
- }
-
- var variableDeclaration = (VariableDeclarationSyntax)simpleName.Parent;
-
- // Check the Initialized Value to see if it is allowed to be in the Var initialization
- if (variableDeclaration.Variables.Count != 1 ||
- !variableDeclaration.Variables.Single().Initializer.IsKind(SyntaxKind.EqualsValueClause))
- {
- return false;
- }
-
- var variable = variableDeclaration.Variables.Single();
- var initializer = (EqualsValueClauseSyntax)variable.Initializer;
- var identifier = variable.Identifier;
-
- if (EqualsValueClauseNotSuitableForVar(identifier, simpleName, initializer, semanticModel, cancellationToken))
- {
- return false;
- }
-
- replacementNode = candidateReplacementNode;
- issueSpan = candidateIssueSpan;
- return true;
- }
-
- if (simpleName.IsParentKind(SyntaxKind.ForEachStatement) &&
- ((ForEachStatementSyntax)simpleName.Parent).Type == simpleName)
- {
- replacementNode = candidateReplacementNode;
- issueSpan = candidateIssueSpan;
- return true;
- }
-
- return false;
- }
-
- private static bool EqualsValueClauseNotSuitableForVar(
- SyntaxToken identifier,
- TypeSyntax simpleName,
- EqualsValueClauseSyntax equalsValueClause,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- // var cannot be assigned null
- if (equalsValueClause.IsKind(SyntaxKind.NullLiteralExpression))
- {
- return true;
- }
-
- var type = semanticModel.GetTypeInfo(simpleName, cancellationToken).Type;
-
- // the variable cannot be initialized to a method group or an anonymous function
- if (type != null &&
- type.TypeKind == TypeKind.Delegate)
- {
- return true;
- }
-
- var initializerType = semanticModel.GetTypeInfo(equalsValueClause.Value, cancellationToken).Type;
-
- if (!type.Equals(initializerType))
- {
- return true;
- }
-
- // The assign expression in the initializer cannot be the same symbol as the i
- var possibleSameLocals = equalsValueClause.DescendantNodesAndSelf().Where(n => n.Kind() == SyntaxKind.IdentifierName && ((IdentifierNameSyntax)n).Identifier.ValueText.Equals(identifier.ValueText));
- var anyUse = possibleSameLocals.Any(n =>
- {
- var symbol = semanticModel.GetSymbolInfo(n, cancellationToken).Symbol;
- if (symbol != null && symbol.Kind == SymbolKind.Local)
- {
- return true;
- }
-
- return false;
- });
-
- if (anyUse)
- {
- return true;
- }
-
- return false;
- }
-
- private static bool ContainsOpenName(NameSyntax name)
- {
- if (name is QualifiedNameSyntax)
- {
- var qualifiedName = (QualifiedNameSyntax)name;
- return ContainsOpenName(qualifiedName.Left) || ContainsOpenName(qualifiedName.Right);
- }
- else if (name is GenericNameSyntax)
- {
- return ((GenericNameSyntax)name).IsUnboundGenericName;
- }
- else
- {
- return false;
- }
- }
-
- private static bool IsNullableTypeInPointerExpression(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
- {
- // Note: nullable type syntax is not allowed in pointer type syntax
- if (simplifiedNode.Kind() == SyntaxKind.NullableType &&
- simplifiedNode.DescendantNodes().Any(n => n is PointerTypeSyntax))
- {
- return true;
- }
-
- return false;
- }
-
- private static bool IsNonNameSyntaxInUsingDirective(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
- {
- return
- expression.IsParentKind(SyntaxKind.UsingDirective) &&
- !(simplifiedNode is NameSyntax);
- }
-
-// private static bool WillConflictWithExistingLocal(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
-// {
-// if (simplifiedNode.Kind() == SyntaxKind.IdentifierName && !SyntaxFacts.IsInNamespaceOrTypeContext(expression))
-// {
-// var identifierName = (IdentifierNameSyntax)simplifiedNode;
-// var enclosingDeclarationSpace = FindImmediatelyEnclosingLocalVariableDeclarationSpace(expression);
-// var enclosingMemberDeclaration = expression.FirstAncestorOrSelf<MemberDeclarationSyntax>();
-// if (enclosingDeclarationSpace != null && enclosingMemberDeclaration != null)
-// {
-// var locals = enclosingMemberDeclaration.GetLocalDeclarationMap()[identifierName.Identifier.ValueText];
-// foreach (var token in locals)
-// {
-// if (token.GetAncestors<SyntaxNode>().Contains(enclosingDeclarationSpace))
-// {
-// return true;
-// }
-// }
-// }
-// }
-//
-// return false;
-// }
-
- private static bool IsAmbiguousCast(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
- {
- // Can't simplify a type name in a cast expression if it would then cause the cast to be
- // parsed differently. For example: (Foo::Bar)+1 is a cast. But if that simplifies to
- // (Bar)+1 then that's an arithmetic expression.
- if (expression.IsParentKind(SyntaxKind.CastExpression))
- {
- var castExpression = (CastExpressionSyntax)expression.Parent;
- if (castExpression.Type == expression)
- {
- var newCastExpression = castExpression.ReplaceNode(castExpression.Type, simplifiedNode);
- var reparsedCastExpression = SyntaxFactory.ParseExpression(newCastExpression.ToString());
-
- if (!reparsedCastExpression.IsKind(SyntaxKind.CastExpression))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- private static SyntaxNode FindImmediatelyEnclosingLocalVariableDeclarationSpace(SyntaxNode syntax)
- {
- for (var declSpace = syntax; declSpace != null; declSpace = declSpace.Parent)
- {
- switch (declSpace.Kind())
- {
- // These are declaration-space-defining syntaxes, by the spec:
- case SyntaxKind.MethodDeclaration:
- case SyntaxKind.IndexerDeclaration:
- case SyntaxKind.OperatorDeclaration:
- case SyntaxKind.ConstructorDeclaration:
- case SyntaxKind.Block:
- case SyntaxKind.ParenthesizedLambdaExpression:
- case SyntaxKind.SimpleLambdaExpression:
- case SyntaxKind.AnonymousMethodExpression:
- case SyntaxKind.SwitchStatement:
- case SyntaxKind.ForEachKeyword:
- case SyntaxKind.ForStatement:
- case SyntaxKind.UsingStatement:
-
- // SPEC VIOLATION: We also want to stop walking out if, say, we are in a field
- // initializer. Technically according to the wording of the spec it should be
- // legal to use a simple name inconsistently inside a field initializer because
- // it does not define a local variable declaration space. In practice of course
- // we want to check for that. (As the native compiler does as well.)
-
- case SyntaxKind.FieldDeclaration:
- return declSpace;
- }
- }
-
- return null;
- }
-
- /// <summary>
- /// Returns the predefined keyword kind for a given specialtype.
- /// </summary>
- /// <param name="specialType">The specialtype of this type.</param>
- /// <returns>The keyword kind for a given special type, or SyntaxKind.None if the type name is not a predefined type.</returns>
- public static SyntaxKind GetPredefinedKeywordKind(SpecialType specialType)
- {
- switch (specialType)
- {
- case SpecialType.System_Boolean:
- return SyntaxKind.BoolKeyword;
- case SpecialType.System_Byte:
- return SyntaxKind.ByteKeyword;
- case SpecialType.System_SByte:
- return SyntaxKind.SByteKeyword;
- case SpecialType.System_Int32:
- return SyntaxKind.IntKeyword;
- case SpecialType.System_UInt32:
- return SyntaxKind.UIntKeyword;
- case SpecialType.System_Int16:
- return SyntaxKind.ShortKeyword;
- case SpecialType.System_UInt16:
- return SyntaxKind.UShortKeyword;
- case SpecialType.System_Int64:
- return SyntaxKind.LongKeyword;
- case SpecialType.System_UInt64:
- return SyntaxKind.ULongKeyword;
- case SpecialType.System_Single:
- return SyntaxKind.FloatKeyword;
- case SpecialType.System_Double:
- return SyntaxKind.DoubleKeyword;
- case SpecialType.System_Decimal:
- return SyntaxKind.DecimalKeyword;
- case SpecialType.System_String:
- return SyntaxKind.StringKeyword;
- case SpecialType.System_Char:
- return SyntaxKind.CharKeyword;
- case SpecialType.System_Object:
- return SyntaxKind.ObjectKeyword;
- case SpecialType.System_Void:
- return SyntaxKind.VoidKeyword;
- default:
- return SyntaxKind.None;
- }
- }
-
- public static NameSyntax GetRightmostName(this ExpressionSyntax node)
- {
- var memberAccess = node as MemberAccessExpressionSyntax;
- if (memberAccess != null && memberAccess.Name != null)
- {
- return memberAccess.Name;
- }
-
- var qualified = node as QualifiedNameSyntax;
- if (qualified != null && qualified.Right != null)
- {
- return qualified.Right;
- }
-
- var simple = node as SimpleNameSyntax;
- if (simple != null)
- {
- return simple;
- }
-
- var conditional = node as ConditionalAccessExpressionSyntax;
- if (conditional != null)
- {
- return conditional.WhenNotNull.GetRightmostName();
- }
-
- return null;
- }
-
- public static OperatorPrecedence GetOperatorPrecedence(this ExpressionSyntax expression)
- {
- switch (expression.Kind())
- {
- case SyntaxKind.SimpleMemberAccessExpression:
- case SyntaxKind.InvocationExpression:
- case SyntaxKind.ElementAccessExpression:
- case SyntaxKind.PostIncrementExpression:
- case SyntaxKind.PostDecrementExpression:
- case SyntaxKind.ObjectCreationExpression:
- case SyntaxKind.TypeOfExpression:
- case SyntaxKind.DefaultExpression:
- case SyntaxKind.CheckedExpression:
- case SyntaxKind.UncheckedExpression:
- case SyntaxKind.AnonymousMethodExpression:
- // From C# spec, 7.3.1:
- // Primary: x.y f(x) a[x] x++ x-- new typeof default checked unchecked delegate
-
- return OperatorPrecedence.Primary;
-
- case SyntaxKind.UnaryPlusExpression:
- case SyntaxKind.UnaryMinusExpression:
- case SyntaxKind.LogicalNotExpression:
- case SyntaxKind.BitwiseNotExpression:
- case SyntaxKind.PreIncrementExpression:
- case SyntaxKind.PreDecrementExpression:
- case SyntaxKind.CastExpression:
- // From C# spec, 7.3.1:
- // Unary: + - ! ~ ++x --x (T)x
-
- return OperatorPrecedence.Unary;
-
- case SyntaxKind.MultiplyExpression:
- case SyntaxKind.DivideExpression:
- case SyntaxKind.ModuloExpression:
- // From C# spec, 7.3.1:
- // Multiplicative: * / %
-
- return OperatorPrecedence.Multiplicative;
-
- case SyntaxKind.AddExpression:
- case SyntaxKind.SubtractExpression:
- // From C# spec, 7.3.1:
- // Additive: + -
-
- return OperatorPrecedence.Additive;
-
- case SyntaxKind.LeftShiftExpression:
- case SyntaxKind.RightShiftExpression:
- // From C# spec, 7.3.1:
- // Shift: << >>
-
- return OperatorPrecedence.Shift;
-
- case SyntaxKind.LessThanExpression:
- case SyntaxKind.GreaterThanExpression:
- case SyntaxKind.LessThanOrEqualExpression:
- case SyntaxKind.GreaterThanOrEqualExpression:
- case SyntaxKind.IsExpression:
- case SyntaxKind.AsExpression:
- // From C# spec, 7.3.1:
- // Relational and type testing: < > <= >= is as
-
- return OperatorPrecedence.RelationalAndTypeTesting;
-
- case SyntaxKind.EqualsExpression:
- case SyntaxKind.NotEqualsExpression:
- // From C# spec, 7.3.1:
- // Equality: == !=
-
- return OperatorPrecedence.Equality;
-
- case SyntaxKind.BitwiseAndExpression:
- // From C# spec, 7.3.1:
- // Logical AND: &
-
- return OperatorPrecedence.LogicalAnd;
-
- case SyntaxKind.ExclusiveOrExpression:
- // From C# spec, 7.3.1:
- // Logical XOR: ^
-
- return OperatorPrecedence.LogicalXor;
-
- case SyntaxKind.BitwiseOrExpression:
- // From C# spec, 7.3.1:
- // Logical OR: |
-
- return OperatorPrecedence.LogicalOr;
-
- case SyntaxKind.LogicalAndExpression:
- // From C# spec, 7.3.1:
- // Conditional AND: &&
-
- return OperatorPrecedence.ConditionalAnd;
-
- case SyntaxKind.LogicalOrExpression:
- // From C# spec, 7.3.1:
- // Conditional AND: ||
-
- return OperatorPrecedence.ConditionalOr;
-
- case SyntaxKind.CoalesceExpression:
- // From C# spec, 7.3.1:
- // Null coalescing: ??
-
- return OperatorPrecedence.NullCoalescing;
-
- case SyntaxKind.ConditionalExpression:
- // From C# spec, 7.3.1:
- // Conditional: ?:
-
- return OperatorPrecedence.Conditional;
-
- case SyntaxKind.SimpleAssignmentExpression:
- case SyntaxKind.MultiplyAssignmentExpression:
- case SyntaxKind.DivideAssignmentExpression:
- case SyntaxKind.ModuloAssignmentExpression:
- case SyntaxKind.AddAssignmentExpression:
- case SyntaxKind.SubtractAssignmentExpression:
- case SyntaxKind.LeftShiftAssignmentExpression:
- case SyntaxKind.RightShiftAssignmentExpression:
- case SyntaxKind.AndAssignmentExpression:
- case SyntaxKind.ExclusiveOrAssignmentExpression:
- case SyntaxKind.OrAssignmentExpression:
- case SyntaxKind.SimpleLambdaExpression:
- case SyntaxKind.ParenthesizedLambdaExpression:
- // From C# spec, 7.3.1:
- // Conditional: ?:
-
- return OperatorPrecedence.AssignmentAndLambdaExpression;
-
- default:
- return OperatorPrecedence.None;
- }
- }
- }
-
- /// <summary>
- /// Operator precedence classes from section 7.3.1 of the C# language specification.
- /// </summary>
- enum OperatorPrecedence
- {
- None = 0,
- AssignmentAndLambdaExpression,
- Conditional,
- NullCoalescing,
- ConditionalOr,
- ConditionalAnd,
- LogicalOr,
- LogicalXor,
- LogicalAnd,
- Equality,
- RelationalAndTypeTesting,
- Shift,
- Additive,
- Multiplicative,
- Unary,
- Primary
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/FindTokenHelper.cs b/main/src/addins/CSharpBinding/Util/FindTokenHelper.cs
deleted file mode 100644
index 327f990410..0000000000
--- a/main/src/addins/CSharpBinding/Util/FindTokenHelper.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal static class FindTokenHelper
- {
- /// <summary>
- /// If the position is inside of token, return that token; otherwise, return the token to the right.
- /// </summary>
- public static SyntaxToken FindTokenOnRightOfPosition<TRoot>(
- SyntaxNode root,
- int position,
- Func<SyntaxTriviaList, int, SyntaxToken> skippedTokenFinder,
- bool includeSkipped = false,
- bool includeDirectives = false,
- bool includeDocumentationComments = false)
- where TRoot : SyntaxNode
- {
- var findSkippedToken = skippedTokenFinder ?? ((l, p) => default(SyntaxToken));
-
- var token = GetInitialToken<TRoot>(root, position, includeSkipped, includeDirectives, includeDocumentationComments);
-
- if (position < token.SpanStart)
- {
- var skippedToken = findSkippedToken(token.LeadingTrivia, position);
- token = skippedToken.RawKind != 0 ? skippedToken : token;
- }
- else if (token.Span.End <= position)
- {
- do
- {
- var skippedToken = findSkippedToken(token.TrailingTrivia, position);
- token = skippedToken.RawKind != 0
- ? skippedToken
- : token.GetNextToken(includeZeroWidth: false, includeSkipped: includeSkipped, includeDirectives: includeDirectives, includeDocumentationComments: includeDocumentationComments);
- }
- while (token.RawKind != 0 && token.Span.End <= position && token.Span.End <= root.FullSpan.End);
- }
-
- if (token.Span.Length == 0)
- {
- token = token.GetNextToken();
- }
-
- return token;
- }
-
- /// <summary>
- /// If the position is inside of token, return that token; otherwise, return the token to the left.
- /// </summary>
- public static SyntaxToken FindTokenOnLeftOfPosition<TRoot>(
- SyntaxNode root,
- int position,
- Func<SyntaxTriviaList, int, SyntaxToken> skippedTokenFinder,
- bool includeSkipped = false,
- bool includeDirectives = false,
- bool includeDocumentationComments = false)
- where TRoot : SyntaxNode
- {
- var findSkippedToken = skippedTokenFinder ?? ((l, p) => default(SyntaxToken));
-
- var token = GetInitialToken<TRoot>(root, position, includeSkipped, includeDirectives, includeDocumentationComments);
-
- if (position <= token.SpanStart)
- {
- do
- {
- var skippedToken = findSkippedToken(token.LeadingTrivia, position);
- token = skippedToken.RawKind != 0
- ? skippedToken
- : token.GetPreviousToken(includeZeroWidth: false, includeSkipped: includeSkipped, includeDirectives: includeDirectives, includeDocumentationComments: includeDocumentationComments);
- }
- while (position <= token.SpanStart && root.FullSpan.Start < token.SpanStart);
- }
- else if (token.Span.End < position)
- {
- var skippedToken = findSkippedToken(token.TrailingTrivia, position);
- token = skippedToken.RawKind != 0 ? skippedToken : token;
- }
-
- if (token.Span.Length == 0)
- {
- token = token.GetPreviousToken();
- }
-
- return token;
- }
-
- private static SyntaxToken GetInitialToken<TRoot>(
- SyntaxNode root,
- int position,
- bool includeSkipped = false,
- bool includeDirectives = false,
- bool includeDocumentationComments = false)
- where TRoot : SyntaxNode
- {
- var token = (position < root.FullSpan.End || !(root is TRoot))
- ? root.FindToken(position, includeSkipped || includeDirectives || includeDocumentationComments)
- : root.GetLastToken(includeZeroWidth: true, includeSkipped: true, includeDirectives: true, includeDocumentationComments: true)
- .GetPreviousToken(includeZeroWidth: false, includeSkipped: includeSkipped, includeDirectives: includeDirectives, includeDocumentationComments: includeDocumentationComments);
- return token;
- }
-
- /// <summary>
- /// Look inside a trivia list for a skipped token that contains the given position.
- /// </summary>
- public static SyntaxToken FindSkippedTokenBackward(IEnumerable<SyntaxToken> skippedTokenList, int position)
- {
- // the given skipped token list is already in order
- var skippedTokenContainingPosition = skippedTokenList.LastOrDefault(skipped => skipped.Span.Length > 0 && skipped.SpanStart <= position);
- if (skippedTokenContainingPosition != default(SyntaxToken))
- {
- return skippedTokenContainingPosition;
- }
-
- return default(SyntaxToken);
- }
-
- /// <summary>
- /// Look inside a trivia list for a skipped token that contains the given position.
- /// </summary>
- public static SyntaxToken FindSkippedTokenForward(IEnumerable<SyntaxToken> skippedTokenList, int position)
- {
- // the given token list is already in order
- var skippedTokenContainingPosition = skippedTokenList.FirstOrDefault(skipped => skipped.Span.Length > 0 && position <= skipped.Span.End);
- if (skippedTokenContainingPosition != default(SyntaxToken))
- {
- return skippedTokenContainingPosition;
- }
-
- return default(SyntaxToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/GeneratedCodeRecognitionService.cs b/main/src/addins/CSharpBinding/Util/GeneratedCodeRecognitionService.cs
index 8deade5244..b4bc921430 100644
--- a/main/src/addins/CSharpBinding/Util/GeneratedCodeRecognitionService.cs
+++ b/main/src/addins/CSharpBinding/Util/GeneratedCodeRecognitionService.cs
@@ -23,11 +23,15 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
-using System.IO;
using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
+using System.IO;
using System.Linq;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Roslyn.Utilities;
namespace ICSharpCode.NRefactory6.CSharp
{
@@ -65,7 +69,7 @@ namespace ICSharpCode.NRefactory6.CSharp
// First return visible source locations if we have them. Else, go to the non-visible
// source locations.
- var visibleSourceLocations = locations.Where(CommonLocationExtensions.IsVisibleSourceLocation);
+ var visibleSourceLocations = locations.Where(LocationExtensions.IsVisibleSourceLocation);
return visibleSourceLocations.Any()
? visibleSourceLocations
: locations.Where(loc => loc.IsInSource);
diff --git a/main/src/addins/CSharpBinding/Util/Glyph.cs b/main/src/addins/CSharpBinding/Util/Glyph.cs
deleted file mode 100644
index 912aa81f84..0000000000
--- a/main/src/addins/CSharpBinding/Util/Glyph.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-//
-// Glyph.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal enum Glyph
- {
- Assembly,
-
- BasicFile,
- BasicProject,
-
- ClassPublic,
- ClassProtected,
- ClassPrivate,
- ClassInternal,
-
- CSharpFile,
- CSharpProject,
-
- ConstantPublic,
- ConstantProtected,
- ConstantPrivate,
- ConstantInternal,
-
- DelegatePublic,
- DelegateProtected,
- DelegatePrivate,
- DelegateInternal,
-
- EnumPublic,
- EnumProtected,
- EnumPrivate,
- EnumInternal,
-
- EnumMember,
-
- Error,
-
- EventPublic,
- EventProtected,
- EventPrivate,
- EventInternal,
-
- ExtensionMethodPublic,
- ExtensionMethodProtected,
- ExtensionMethodPrivate,
- ExtensionMethodInternal,
-
- FieldPublic,
- FieldProtected,
- FieldPrivate,
- FieldInternal,
-
- InterfacePublic,
- InterfaceProtected,
- InterfacePrivate,
- InterfaceInternal,
-
- Intrinsic,
-
- Keyword,
-
- Label,
-
- Local,
-
- Namespace,
-
- MethodPublic,
- MethodProtected,
- MethodPrivate,
- MethodInternal,
-
- ModulePublic,
- ModuleProtected,
- ModulePrivate,
- ModuleInternal,
-
- OpenFolder,
-
- Operator,
-
- Parameter,
-
- PropertyPublic,
- PropertyProtected,
- PropertyPrivate,
- PropertyInternal,
-
- RangeVariable,
-
- Reference,
-
- StructurePublic,
- StructureProtected,
- StructurePrivate,
- StructureInternal,
-
- TypeParameter,
-
- Snippet,
-
- CompletionWarning
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/Hash.cs b/main/src/addins/CSharpBinding/Util/Hash.cs
deleted file mode 100644
index e6a2fa4ef0..0000000000
--- a/main/src/addins/CSharpBinding/Util/Hash.cs
+++ /dev/null
@@ -1,350 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.IO;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class Hash
- {
- /// <summary>
- /// This is how VB Anonymous Types combine hash values for fields.
- /// </summary>
- internal static int Combine(int newKey, int currentKey)
- {
- return unchecked((currentKey * (int)0xA5555529) + newKey);
- }
-
- internal static int Combine(bool newKeyPart, int currentKey)
- {
- return Combine(currentKey, newKeyPart ? 1 : 0);
- }
-
- /// <summary>
- /// This is how VB Anonymous Types combine hash values for fields.
- /// PERF: Do not use with enum types because that involves multiple
- /// unnecessary boxing operations. Unfortunately, we can't constrain
- /// T to "non-enum", so we'll use a more restrictive constraint.
- /// </summary>
- internal static int Combine<T>(T newKeyPart, int currentKey) where T : class
- {
- int hash = unchecked(currentKey * (int)0xA5555529);
-
- if (newKeyPart != null)
- {
- return unchecked(hash + newKeyPart.GetHashCode());
- }
-
- return hash;
- }
-
- internal static int CombineValues<T>(IEnumerable<T> values, int maxItemsToHash = int.MaxValue)
- {
- if (values == null)
- {
- return 0;
- }
-
- var hashCode = 0;
- var count = 0;
- foreach (var value in values)
- {
- if (count++ >= maxItemsToHash)
- {
- break;
- }
-
- // Should end up with a constrained virtual call to object.GetHashCode (i.e. avoid boxing where possible).
- if (value != null)
- {
- hashCode = Hash.Combine(value.GetHashCode(), hashCode);
- }
- }
-
- return hashCode;
- }
-
- internal static int CombineValues<T>(T[] values, int maxItemsToHash = int.MaxValue)
- {
- if (values == null)
- {
- return 0;
- }
-
- var maxSize = Math.Min(maxItemsToHash, values.Length);
- var hashCode = 0;
-
- for (int i = 0; i < maxSize; i++)
- {
- T value = values[i];
-
- // Should end up with a constrained virtual call to object.GetHashCode (i.e. avoid boxing where possible).
- if (value != null)
- {
- hashCode = Hash.Combine(value.GetHashCode(), hashCode);
- }
- }
-
- return hashCode;
- }
-
- internal static int CombineValues<T>(ImmutableArray<T> values, int maxItemsToHash = int.MaxValue)
- {
- if (values.IsDefaultOrEmpty)
- {
- return 0;
- }
-
- var hashCode = 0;
- var count = 0;
- foreach (var value in values)
- {
- if (count++ >= maxItemsToHash)
- {
- break;
- }
-
- // Should end up with a constrained virtual call to object.GetHashCode (i.e. avoid boxing where possible).
- if (value != null)
- {
- hashCode = Hash.Combine(value.GetHashCode(), hashCode);
- }
- }
-
- return hashCode;
- }
-
- internal static int CombineValues(IEnumerable<string> values, StringComparer stringComparer, int maxItemsToHash = int.MaxValue)
- {
- if (values == null)
- {
- return 0;
- }
-
- var hashCode = 0;
- var count = 0;
- foreach (var value in values)
- {
- if (count++ >= maxItemsToHash)
- {
- break;
- }
-
- if (value != null)
- {
- hashCode = Hash.Combine(stringComparer.GetHashCode(value), hashCode);
- }
- }
-
- return hashCode;
- }
-
- /// <summary>
- /// The offset bias value used in the FNV-1a algorithm
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- internal const int FnvOffsetBias = unchecked((int)2166136261);
-
- /// <summary>
- /// The generative factor used in the FNV-1a algorithm
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- internal const int FnvPrime = 16777619;
-
- /// <summary>
- /// Compute the FNV-1a hash of a sequence of bytes
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- /// <param name="data">The sequence of bytes</param>
- /// <returns>The FNV-1a hash of <paramref name="data"/></returns>
- internal static int GetFNVHashCode(byte[] data)
- {
- int hashCode = Hash.FnvOffsetBias;
-
- for (int i = 0; i < data.Length; i++)
- {
- hashCode = unchecked((hashCode ^ data[i]) * Hash.FnvPrime);
- }
-
- return hashCode;
- }
-
- /// <summary>
- /// Compute the FNV-1a hash of a sequence of bytes and determines if the byte
- /// sequence is valid ASCII and hence the hash code matches a char sequence
- /// encoding the same text.
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- /// <param name="data">The sequence of bytes that are likely to be ASCII text.</param>
- /// <param name="length">The length of the sequence.</param>
- /// <param name="isAscii">True if the sequence contains only characters in the ASCII range.</param>
- /// <returns>The FNV-1a hash of <paramref name="data"/></returns>
- internal static unsafe int GetFNVHashCode(byte* data, int length, out bool isAscii)
- {
- int hashCode = Hash.FnvOffsetBias;
-
- byte asciiMask = 0;
-
- for (int i = 0; i < length; i++)
- {
- byte b = data[i];
- asciiMask |= b;
- hashCode = unchecked((hashCode ^ b) * Hash.FnvPrime);
- }
-
- isAscii = (asciiMask & 0x80) == 0;
- return hashCode;
- }
-
- /// <summary>
- /// Compute the FNV-1a hash of a sequence of bytes
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- /// <param name="data">The sequence of bytes</param>
- /// <returns>The FNV-1a hash of <paramref name="data"/></returns>
- internal static int GetFNVHashCode(ImmutableArray<byte> data)
- {
- int hashCode = Hash.FnvOffsetBias;
-
- for (int i = 0; i < data.Length; i++)
- {
- hashCode = unchecked((hashCode ^ data[i]) * Hash.FnvPrime);
- }
-
- return hashCode;
- }
-
- /// <summary>
- /// Compute the hashcode of a sub-string using FNV-1a
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// Note: FNV-1a was developed and tuned for 8-bit sequences. We're using it here
- /// for 16-bit Unicode chars on the understanding that the majority of chars will
- /// fit into 8-bits and, therefore, the algorithm will retain its desirable traits
- /// for generating hash codes.
- /// </summary>
- /// <param name="text">The input string</param>
- /// <param name="start">The start index of the first character to hash</param>
- /// <param name="length">The number of characters, beginning with <paramref name="start"/> to hash</param>
- /// <returns>The FNV-1a hash code of the substring beginning at <paramref name="start"/> and ending after <paramref name="length"/> characters.</returns>
- internal static int GetFNVHashCode(string text, int start, int length)
- {
- int hashCode = Hash.FnvOffsetBias;
- int end = start + length;
-
- for (int i = start; i < end; i++)
- {
- hashCode = unchecked((hashCode ^ text[i]) * Hash.FnvPrime);
- }
-
- return hashCode;
- }
-
- /// <summary>
- /// Compute the hashcode of a sub-string using FNV-1a
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- /// <param name="text">The input string</param>
- /// <param name="start">The start index of the first character to hash</param>
- /// <returns>The FNV-1a hash code of the substring beginning at <paramref name="start"/> and ending at the end of the string.</returns>
- internal static int GetFNVHashCode(string text, int start)
- {
- return GetFNVHashCode(text, start, length: text.Length - start);
- }
-
- /// <summary>
- /// Compute the hashcode of a string using FNV-1a
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- /// <param name="text">The input string</param>
- /// <returns>The FNV-1a hash code of <paramref name="text"/></returns>
- internal static int GetFNVHashCode(string text)
- {
- return CombineFNVHash(Hash.FnvOffsetBias, text);
- }
-
- /// <summary>
- /// Compute the hashcode of a string using FNV-1a
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- /// <param name="text">The input string</param>
- /// <returns>The FNV-1a hash code of <paramref name="text"/></returns>
- internal static int GetFNVHashCode(System.Text.StringBuilder text)
- {
- int hashCode = Hash.FnvOffsetBias;
- int end = text.Length;
-
- for (int i = 0; i < end; i++)
- {
- hashCode = unchecked((hashCode ^ text[i]) * Hash.FnvPrime);
- }
-
- return hashCode;
- }
-
- /// <summary>
- /// Compute the hashcode of a sub string using FNV-1a
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- /// <param name="text">The input string as a char array</param>
- /// <param name="start">The start index of the first character to hash</param>
- /// <param name="length">The number of characters, beginning with <paramref name="start"/> to hash</param>
- /// <returns>The FNV-1a hash code of the substring beginning at <paramref name="start"/> and ending after <paramref name="length"/> characters.</returns>
- internal static int GetFNVHashCode(char[] text, int start, int length)
- {
- int hashCode = Hash.FnvOffsetBias;
- int end = start + length;
-
- for (int i = start; i < end; i++)
- {
- hashCode = unchecked((hashCode ^ text[i]) * Hash.FnvPrime);
- }
-
- return hashCode;
- }
-
- /// <summary>
- /// Compute the hashcode of a single character using the FNV-1a algorithm
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// Note: In general, this isn't any more useful than "char.GetHashCode". However,
- /// it may be needed if you need to generate the same hash code as a string or
- /// substring with just a single character.
- /// </summary>
- /// <param name="ch">The character to hash</param>
- /// <returns>The FNV-1a hash code of the character.</returns>
- internal static int GetFNVHashCode(char ch)
- {
- return Hash.CombineFNVHash(Hash.FnvOffsetBias, ch);
- }
-
- /// <summary>
- /// Combine a string with an existing FNV-1a hash code
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- /// <param name="hashCode">The accumulated hash code</param>
- /// <param name="text">The string to combine</param>
- /// <returns>The result of combining <paramref name="hashCode"/> with <paramref name="text"/> using the FNV-1a algorithm</returns>
- internal static int CombineFNVHash(int hashCode, string text)
- {
- foreach (char ch in text)
- {
- hashCode = unchecked((hashCode ^ ch) * Hash.FnvPrime);
- }
-
- return hashCode;
- }
-
- /// <summary>
- /// Combine a char with an existing FNV-1a hash code
- /// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
- /// </summary>
- /// <param name="hashCode">The accumulated hash code</param>
- /// <param name="ch">The new character to combine</param>
- /// <returns>The result of combining <paramref name="hashCode"/> with <paramref name="ch"/> using the FNV-1a algorithm</returns>
- internal static int CombineFNVHash(int hashCode, char ch)
- {
- return unchecked((hashCode ^ ch) * Hash.FnvPrime);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/HelpLink.cs b/main/src/addins/CSharpBinding/Util/HelpLink.cs
deleted file mode 100644
index 6800e8c384..0000000000
--- a/main/src/addins/CSharpBinding/Util/HelpLink.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// HelpLink.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class HelpLink
- {
- internal static string CreateFor (string diagnosticId)
- {
- return NRefactory6Host.GetHelpLinkForDiagnostic (diagnosticId);
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/Util/IAssemblySymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/IAssemblySymbolExtensions.cs
deleted file mode 100644
index 7b5b2e1efe..0000000000
--- a/main/src/addins/CSharpBinding/Util/IAssemblySymbolExtensions.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// IAssemblySymbolExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class IAssemblySymbolExtensions
- {
- private const string AttributeSuffix = "Attribute";
-
- public static bool ContainsNamespaceName(
- this List<IAssemblySymbol> assemblies,
- string namespaceName)
- {
- // PERF: Expansion of "assemblies.Any(a => a.NamespaceNames.Contains(namespaceName))"
- // to avoid allocating a lambda.
- foreach (var a in assemblies)
- {
- if (a.NamespaceNames.Contains(namespaceName))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool ContainsTypeName(this List<IAssemblySymbol> assemblies, string typeName, bool tryWithAttributeSuffix = false)
- {
- if (!tryWithAttributeSuffix)
- {
- // PERF: Expansion of "assemblies.Any(a => a.TypeNames.Contains(typeName))"
- // to avoid allocating a lambda.
- foreach (var a in assemblies)
- {
- if (a.TypeNames.Contains(typeName))
- {
- return true;
- }
- }
- }
- else
- {
- var attributeName = typeName + AttributeSuffix;
- foreach (var a in assemblies)
- {
- var typeNames = a.TypeNames;
- if (typeNames.Contains(typeName) || typeNames.Contains(attributeName))
- {
- return true;
- }
- }
- }
-
- return false;
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/ICodeDefinitionFactoryExtensions.cs b/main/src/addins/CSharpBinding/Util/ICodeDefinitionFactoryExtensions.cs
deleted file mode 100644
index 781c4aecaa..0000000000
--- a/main/src/addins/CSharpBinding/Util/ICodeDefinitionFactoryExtensions.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-using System;
-using System.Reflection;
-using System.Threading;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Editing;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Runtime.ExceptionServices;
-
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class ICodeDefinitionFactoryExtensions
- {
- readonly static Type typeInfo;
-
- static ICodeDefinitionFactoryExtensions ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.Shared.Extensions.ICodeDefinitionFactoryExtensions" + ReflectionNamespaces.WorkspacesAsmName, true);
- createFieldDelegatingConstructorMethod = typeInfo.GetMethod ("CreateFieldDelegatingConstructor", BindingFlags.Static | BindingFlags.Public);
- createFieldsForParametersMethod = typeInfo.GetMethod ("CreateFieldsForParameters", BindingFlags.Static | BindingFlags.Public);
- createAssignmentStatementMethod = typeInfo.GetMethod ("CreateAssignmentStatements", BindingFlags.Static | BindingFlags.Public);
- createThrowNotImplementStatementMethod = typeInfo.GetMethod ("CreateThrowNotImplementStatement", new [] { typeof (SyntaxGenerator), typeof(Compilation) });
-
- }
-
- public static IList<SyntaxNode> CreateThrowNotImplementedStatementBlock(
- this SyntaxGenerator codeDefinitionFactory,
- Compilation compilation)
- {
- return new[] { CreateThrowNotImplementStatement(codeDefinitionFactory, compilation) };
- }
-
-
- static MethodInfo createThrowNotImplementStatementMethod;
- public static SyntaxNode CreateThrowNotImplementStatement(
- this SyntaxGenerator codeDefinitionFactory,
- Compilation compilation)
- {
- try {
- return (SyntaxNode)createThrowNotImplementStatementMethod.Invoke (null, new object[] { codeDefinitionFactory, compilation });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- readonly static MethodInfo createFieldDelegatingConstructorMethod;
-
- public static IEnumerable<ISymbol> CreateFieldDelegatingConstructor(
- this SyntaxGenerator factory,
- string typeName,
- INamedTypeSymbol containingTypeOpt,
- IList<IParameterSymbol> parameters,
- IDictionary<string, ISymbol> parameterToExistingFieldMap,
- IDictionary<string, string> parameterToNewFieldMap,
- CancellationToken cancellationToken)
- {
- try {
- return (IEnumerable<ISymbol>)createFieldDelegatingConstructorMethod.Invoke (null, new object[] {
- factory,
- typeName,
- containingTypeOpt,
- parameters,
- parameterToExistingFieldMap,
- parameterToNewFieldMap,
- cancellationToken
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- readonly static MethodInfo createFieldsForParametersMethod;
-
- public static IEnumerable<IFieldSymbol> CreateFieldsForParameters(
- this SyntaxGenerator factory,
- IList<IParameterSymbol> parameters,
- IDictionary<string, string> parameterToNewFieldMap)
- {
- try {
- return (IEnumerable<IFieldSymbol>)createFieldsForParametersMethod.Invoke (null, new object[] {
- factory,
- parameters,
- parameterToNewFieldMap
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- readonly static MethodInfo createAssignmentStatementMethod;
-
- public static IEnumerable<SyntaxNode> CreateAssignmentStatements(
- this SyntaxGenerator factory,
- IList<IParameterSymbol> parameters,
- IDictionary<string, ISymbol> parameterToExistingFieldMap,
- IDictionary<string, string> parameterToNewFieldMap)
- {
- try {
- return (IEnumerable<SyntaxNode>)createAssignmentStatementMethod.Invoke (null, new object[] {
- factory,
- parameters,
- parameterToExistingFieldMap,
- parameterToNewFieldMap
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public static IList<SyntaxNode> CreateArguments(
- this SyntaxGenerator factory,
- ImmutableArray<IParameterSymbol> parameters)
- {
- return parameters.Select(p => CreateArgument(factory, p)).ToList();
- }
-
- private static SyntaxNode CreateArgument(
- this SyntaxGenerator factory,
- IParameterSymbol parameter)
- {
- return factory.Argument(parameter.RefKind, factory.IdentifierName(parameter.Name));
- }
-
- public static IMethodSymbol CreateBaseDelegatingConstructor(
- this SyntaxGenerator factory,
- IMethodSymbol constructor,
- string typeName)
- {
- return CodeGenerationSymbolFactory.CreateConstructorSymbol(
- attributes: null,
- accessibility: Accessibility.Public,
- modifiers: new DeclarationModifiers(),
- typeName: typeName,
- parameters: constructor.Parameters,
- statements: null,
- baseConstructorArguments: constructor.Parameters.Length == 0 ? null : factory.CreateArguments(constructor.Parameters));
- }
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/ICompilationExtensions.cs b/main/src/addins/CSharpBinding/Util/ICompilationExtensions.cs
deleted file mode 100644
index 28d70bbea1..0000000000
--- a/main/src/addins/CSharpBinding/Util/ICompilationExtensions.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-//
-// ICompilationExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class ICompilationExtensions
- {
- public static INamedTypeSymbol AttributeType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Attribute");
- }
-
- public static INamedTypeSymbol ExceptionType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Exception");
- }
-
- public static INamedTypeSymbol DesignerCategoryAttributeType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.ComponentModel.DesignerCategoryAttribute");
- }
-
- public static INamedTypeSymbol DesignerGeneratedAttributeType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("Microsoft.VisualBasic.CompilerServices.DesignerGeneratedAttribute");
- }
-
- public static INamedTypeSymbol HideModuleNameAttribute(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("Microsoft.VisualBasic.HideModuleNameAttribute");
- }
-
- public static INamedTypeSymbol EventArgsType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.EventArgs");
- }
-
- public static INamedTypeSymbol NotImplementedExceptionType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.NotImplementedException");
- }
-
- public static INamedTypeSymbol EqualityComparerOfTType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Collections.Generic.EqualityComparer`1");
- }
-
- public static INamedTypeSymbol ActionType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Action");
- }
-
- public static INamedTypeSymbol ExpressionOfTType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Linq.Expressions.Expression`1");
- }
-
- public static INamedTypeSymbol EditorBrowsableAttributeType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.ComponentModel.EditorBrowsableAttribute");
- }
-
- public static INamedTypeSymbol EditorBrowsableStateType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.ComponentModel.EditorBrowsableState");
- }
-
- public static INamedTypeSymbol TaskType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Threading.Tasks.Task");
- }
-
- public static INamedTypeSymbol TaskOfTType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Threading.Tasks.Task`1");
- }
-
- public static INamedTypeSymbol SerializableAttributeType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.SerializableAttribute");
- }
-
- public static INamedTypeSymbol CoClassType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Runtime.InteropServices.CoClassAttribute");
- }
-
- public static INamedTypeSymbol ComAliasNameAttributeType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Runtime.InteropServices.ComAliasNameAttribute");
- }
-
- public static INamedTypeSymbol SuppressMessageAttributeType(this Compilation compilation)
- {
- return compilation.GetTypeByMetadataName("System.Diagnostics.CodeAnalysis.SuppressMessageAttribute");
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/IDictionaryExtensions.cs b/main/src/addins/CSharpBinding/Util/IDictionaryExtensions.cs
deleted file mode 100644
index 264f8b85f0..0000000000
--- a/main/src/addins/CSharpBinding/Util/IDictionaryExtensions.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class IDictionaryExtensions
- {
- // Copied from ConcurrentDictionary since IDictionary doesn't have this useful method
- public static V GetOrAdd<K, V>(this IDictionary<K, V> dictionary, K key, Func<K, V> function)
- {
- V value;
- if (!dictionary.TryGetValue(key, out value))
- {
- value = function(key);
- dictionary.Add(key, value);
- }
-
- return value;
- }
-
- public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
- {
- TValue value;
- if (dictionary.TryGetValue(key, out value))
- {
- return value;
- }
-
- return default(TValue);
- }
-
- public static bool DictionaryEquals<K, V>(this IDictionary<K, V> left, IDictionary<K, V> right, IEqualityComparer<KeyValuePair<K, V>> comparer = null)
- {
- comparer = comparer ?? EqualityComparer<KeyValuePair<K, V>>.Default;
-
- // two dictionaries should have same number of entries
- if (left.Count != right.Count)
- {
- return false;
- }
-
- // check two dictionaries have same key/value pairs
- return left.All(pair => comparer.Equals(pair));
- }
-
- public static void MultiAdd<TKey, TValue, TCollection>(this IDictionary<TKey, TCollection> dictionary, TKey key, TValue value)
- where TCollection : ICollection<TValue>, new()
- {
- TCollection collection;
- if (!dictionary.TryGetValue(key, out collection))
- {
- collection = new TCollection();
- dictionary.Add(key, collection);
- }
-
- collection.Add(value);
- }
-
- public static void MultiRemove<TKey, TValue, TCollection>(this IDictionary<TKey, TCollection> dictionary, TKey key, TValue value)
- where TCollection : ICollection<TValue>
- {
- TCollection collection;
- if (dictionary.TryGetValue(key, out collection))
- {
- collection.Remove(value);
-
- if (collection.Count == 0)
- {
- dictionary.Remove(key);
- }
- }
- }
-
- public static void MultiAddRange<TKey, TValue, TCollection>(this IDictionary<TKey, TCollection> dictionary, TKey key, IEnumerable<TValue> values)
- where TCollection : ICollection<TValue>, new()
- {
- TCollection collection;
- if (!dictionary.TryGetValue(key, out collection))
- {
- collection = new TCollection();
- dictionary.Add(key, collection);
- }
- foreach (var val in values)
- collection.Add (val);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/IDocumentExtensions.cs b/main/src/addins/CSharpBinding/Util/IDocumentExtensions.cs
deleted file mode 100644
index 00e100ee8e..0000000000
--- a/main/src/addins/CSharpBinding/Util/IDocumentExtensions.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class IDocumentExtensions
- {
- public static async Task<CompilationUnitSyntax> GetCSharpSyntaxRootAsync(this Document document, CancellationToken cancellationToken = default(CancellationToken))
- {
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- return (CompilationUnitSyntax)root;
- }
-
- public static Task<SyntaxTree> GetCSharpSyntaxTreeAsync(this Document document, CancellationToken cancellationToken = default(CancellationToken))
- {
- return document.GetSyntaxTreeAsync(cancellationToken);
- }
-
- public static Task<SemanticModel> GetCSharpSemanticModelAsync(this Document document, CancellationToken cancellationToken = default(CancellationToken))
- {
- return document.GetSemanticModelAsync(cancellationToken);
- }
-
- public static Task<SemanticModel> GetCSharpSemanticModelForNodeAsync(this Document document, SyntaxNode node, CancellationToken cancellationToken = default(CancellationToken))
- {
- return document.GetSemanticModelForNodeAsync(node, cancellationToken);
- }
-
- public static Task<SemanticModel> GetCSharpSemanticModelForSpanAsync(this Document document, TextSpan span, CancellationToken cancellationToken = default(CancellationToken))
- {
- return document.GetSemanticModelForSpanAsync(span, cancellationToken);
- }
-
- public static Task<Compilation> GetCSharpCompilationAsync(this Document document, CancellationToken cancellationToken = default(CancellationToken))
- {
- return document.Project.GetCompilationAsync(cancellationToken);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/IMethodSymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/IMethodSymbolExtensions.cs
deleted file mode 100644
index cdb3788d4f..0000000000
--- a/main/src/addins/CSharpBinding/Util/IMethodSymbolExtensions.cs
+++ /dev/null
@@ -1,325 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Roslyn.Utilities;
-using System.Reflection;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class IMethodSymbolExtensions
- {
-// public static bool CompatibleSignatureToDelegate(this IMethodSymbol method, INamedTypeSymbol delegateType)
-// {
-// //Contract.ThrowIfFalse(delegateType.TypeKind == TypeKind.Delegate);
-//
-// var invoke = delegateType.DelegateInvokeMethod;
-// if (invoke == null)
-// {
-// // It's possible to get events with no invoke method from metadata. We will assume
-// // that no method can be an event handler for one.
-// return false;
-// }
-//
-// if (method.Parameters.Length != invoke.Parameters.Length)
-// {
-// return false;
-// }
-//
-// if (method.ReturnsVoid != invoke.ReturnsVoid)
-// {
-// return false;
-// }
-//
-// if (!method.ReturnType.InheritsFromOrEquals(invoke.ReturnType))
-// {
-// return false;
-// }
-//
-// for (int i = 0; i < method.Parameters.Length; i++)
-// {
-// if (!invoke.Parameters[i].Type.InheritsFromOrEquals(method.Parameters[i].Type))
-// {
-// return false;
-// }
-// }
-//
-// return true;
-// }
-//
- public static IMethodSymbol RenameTypeParameters(this IMethodSymbol method, IList<string> newNames)
- {
- if (method.TypeParameters.Select(t => t.Name).SequenceEqual(newNames))
- {
- return method;
- }
-
- var typeGenerator = new TypeGenerator();
- var updatedTypeParameters = RenameTypeParameters(
- method.TypeParameters, newNames, typeGenerator);
-
- var mapping = new Dictionary<ITypeSymbol, ITypeSymbol>();
- for (int i = 0; i < method.TypeParameters.Length; i++)
- {
- mapping.Add(method.TypeParameters[i], updatedTypeParameters[i]);
- }
-
- return CodeGenerationSymbolFactory.CreateMethodSymbol(
- method.ContainingType,
- method.GetAttributes(),
- method.DeclaredAccessibility,
- method.GetSymbolModifiers(),
- method.ReturnType.SubstituteTypes(mapping, typeGenerator),
- method.ExplicitInterfaceImplementations.FirstOrDefault(),
- method.Name,
- updatedTypeParameters,
- method.Parameters.Select(p =>
- CodeGenerationSymbolFactory.CreateParameterSymbol(p.GetAttributes(), p.RefKind, p.IsParams, p.Type.SubstituteTypes(mapping, typeGenerator), p.Name, p.IsOptional,
- p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null)).ToList());
- }
-
- public static IMethodSymbol RenameParameters(this IMethodSymbol method, IList<string> parameterNames)
- {
- var parameterList = method.Parameters;
- if (parameterList.Select(p => p.Name).SequenceEqual(parameterNames))
- {
- return method;
- }
-
- var parameters = parameterList.RenameParameters(parameterNames);
-
- return CodeGenerationSymbolFactory.CreateMethodSymbol(
- method.ContainingType,
- method.GetAttributes(),
- method.DeclaredAccessibility,
- method.GetSymbolModifiers(),
- method.ReturnType,
- method.ExplicitInterfaceImplementations.FirstOrDefault(),
- method.Name,
- method.TypeParameters,
- parameters);
- }
-
- private static IList<ITypeParameterSymbol> RenameTypeParameters(
- IList<ITypeParameterSymbol> typeParameters,
- IList<string> newNames,
- TypeGenerator typeGenerator)
- {
- // We generate the type parameter in two passes. The first creates the new type
- // parameter. The second updates the constraints to point at this new type parameter.
- var newTypeParameters = new List<CodeGenerationTypeParameterSymbol>();
- var mapping = new Dictionary<ITypeSymbol, ITypeSymbol>();
- for (int i = 0; i < typeParameters.Count; i++)
- {
- var typeParameter = typeParameters[i];
-
- var newTypeParameter = new CodeGenerationTypeParameterSymbol(
- typeParameter.ContainingType,
- typeParameter.GetAttributes(),
- typeParameter.Variance,
- newNames[i],
- typeParameter.ConstraintTypes,
- typeParameter.HasConstructorConstraint,
- typeParameter.HasReferenceTypeConstraint,
- typeParameter.HasValueTypeConstraint,
- typeParameter.Ordinal);
-
- newTypeParameters.Add(newTypeParameter);
- mapping.Add(typeParameter, (ITypeSymbol)newTypeParameter.Instance);
- }
-
- // Now we update the constraints.
- foreach (var newTypeParameter in newTypeParameters)
- {
- newTypeParameter.ConstraintTypes = ImmutableArray.CreateRange(newTypeParameter.ConstraintTypes, t => t.SubstituteTypes(mapping, typeGenerator));
- }
-
- return newTypeParameters.Cast<ITypeParameterSymbol>().ToList();
- }
-
- public static IMethodSymbol EnsureNonConflictingNames(
- this IMethodSymbol method, INamedTypeSymbol containingType, CancellationToken cancellationToken)
- {
- // The method's type parameters may conflict with the type parameters in the type
- // we're generating into. In that case, rename them.
- var parameterNames = NameGenerator.EnsureUniqueness(
- method.Parameters.Select(p => p.Name).ToList(), isCaseSensitive: true);
-
- var outerTypeParameterNames =
- containingType.GetAllTypeParameters()
- .Select(tp => tp.Name)
- .Concat(method.Name)
- .Concat(containingType.Name);
-
- var unusableNames = parameterNames.Concat(outerTypeParameterNames).ToSet(StringComparer.Ordinal);
-
- var newTypeParameterNames = NameGenerator.EnsureUniqueness(
- method.TypeParameters.Select(tp => tp.Name).ToList(),
- n => !unusableNames.Contains(n));
-
- var updatedMethod = method.RenameTypeParameters(newTypeParameterNames);
- return updatedMethod.RenameParameters(parameterNames);
- }
-
- public static IMethodSymbol RemoveAttributeFromParametersAndReturnType(
- this IMethodSymbol method, INamedTypeSymbol attributeType,
- IList<SyntaxNode> statements = null, IList<SyntaxNode> handlesExpressions = null)
- {
- if (attributeType == null)
- {
- return method;
- }
-
- var someParameterHasAttribute = method.Parameters
- .Any(m => m.GetAttributes().Any(a => a.AttributeClass.Equals(attributeType)));
-
- var returnTypeHasAttribute = method.GetReturnTypeAttributes()
- .Any(a => a.AttributeClass.Equals(attributeType));
-
- if (!someParameterHasAttribute && !returnTypeHasAttribute)
- {
- return method;
- }
-
- return CodeGenerationSymbolFactory.CreateMethodSymbol(
- method.ContainingType,
- method.GetAttributes(),
- method.DeclaredAccessibility,
- method.GetSymbolModifiers(),
- method.ReturnType,
- method.ExplicitInterfaceImplementations.FirstOrDefault(),
- method.Name,
- method.TypeParameters,
- method.Parameters.Select(p =>
- CodeGenerationSymbolFactory.CreateParameterSymbol(
- p.GetAttributes().Where(a => !a.AttributeClass.Equals(attributeType)).ToList(),
- p.RefKind, p.IsParams, p.Type, p.Name, p.IsOptional,
- p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null)).ToList(),
- statements,
- handlesExpressions,
- method.GetReturnTypeAttributes().Where(a => !a.AttributeClass.Equals(attributeType)).ToList());
- }
-
- public static bool? IsMoreSpecificThan(this IMethodSymbol method1, IMethodSymbol method2)
- {
- var p1 = method1.Parameters;
- var p2 = method2.Parameters;
-
- // If the methods don't have the same parameter count, then method1 can't be more or
- // less specific htan method2.
- if (p1.Length != p2.Length)
- {
- return null;
- }
-
- // If the methods' parameter types differ, or they have different names, then one can't
- // be more specific htan the other.
- if (!SignatureComparer.HaveSameSignature(method1.Parameters, method2.Parameters) ||
- !method1.Parameters.Select(p => p.Name).SequenceEqual(method2.Parameters.Select(p => p.Name)))
- {
- return null;
- }
-
- // Ok. We have two methods that look extremely similar to each other. However, one might
- // be more specific if, for example, it was actually written with concrete types (like 'int')
- // versus the other which may have been instantiated from a type parameter. i.e.
- //
- // class C<T> { void Foo(T t); void Foo(int t); }
- //
- // THe latter Foo is more specific when comparing "C<int>.Foo(int t)" (method1) vs
- // "C<int>.Foo(int t)" (method2).
- p1 = method1.OriginalDefinition.Parameters;
- p2 = method2.OriginalDefinition.Parameters;
- return p1.Select(p => p.Type).ToList().AreMoreSpecificThan(p2.Select(p => p.Type).ToList());
- }
-
- public static bool TryGetPredefinedComparisonOperator(this IMethodSymbol symbol, out PredefinedOperator op)
- {
- if (symbol.MethodKind == MethodKind.BuiltinOperator)
- {
- op = symbol.GetPredefinedOperator();
- switch (op)
- {
- case PredefinedOperator.Equality:
- case PredefinedOperator.Inequality:
- case PredefinedOperator.GreaterThanOrEqual:
- case PredefinedOperator.LessThanOrEqual:
- case PredefinedOperator.GreaterThan:
- case PredefinedOperator.LessThan:
- return true;
- }
- }
- else
- {
- op = PredefinedOperator.None;
- }
-
- return false;
- }
-
- public static PredefinedOperator GetPredefinedOperator(this IMethodSymbol symbol)
- {
- switch (symbol.Name)
- {
- case "op_Addition":
- case "op_UnaryPlus":
- return PredefinedOperator.Addition;
- case "op_BitwiseAnd":
- return PredefinedOperator.BitwiseAnd;
- case "op_BitwiseOr":
- return PredefinedOperator.BitwiseOr;
- case "op_Concatenate":
- return PredefinedOperator.Concatenate;
- case "op_Decrement":
- return PredefinedOperator.Decrement;
- case "op_Division":
- return PredefinedOperator.Division;
- case "op_Equality":
- return PredefinedOperator.Equality;
- case "op_ExclusiveOr":
- return PredefinedOperator.ExclusiveOr;
- case "op_Exponent":
- return PredefinedOperator.Exponent;
- case "op_GreaterThan":
- return PredefinedOperator.GreaterThan;
- case "op_GreaterThanOrEqual":
- return PredefinedOperator.GreaterThanOrEqual;
- case "op_Increment":
- return PredefinedOperator.Increment;
- case "op_Inequality":
- return PredefinedOperator.Inequality;
- case "op_IntegerDivision":
- return PredefinedOperator.IntegerDivision;
- case "op_LeftShift":
- return PredefinedOperator.LeftShift;
- case "op_LessThan":
- return PredefinedOperator.LessThan;
- case "op_LessThanOrEqual":
- return PredefinedOperator.LessThanOrEqual;
- case "op_Like":
- return PredefinedOperator.Like;
- case "op_LogicalNot":
- case "op_OnesComplement":
- return PredefinedOperator.Complement;
- case "op_Modulus":
- return PredefinedOperator.Modulus;
- case "op_Multiply":
- return PredefinedOperator.Multiplication;
- case "op_RightShift":
- return PredefinedOperator.RightShift;
- case "op_Subtraction":
- case "op_UnaryNegation":
- return PredefinedOperator.Subtraction;
- default:
- return PredefinedOperator.None;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/INamedTypeSymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/INamedTypeSymbolExtensions.cs
deleted file mode 100644
index caadc26ab6..0000000000
--- a/main/src/addins/CSharpBinding/Util/INamedTypeSymbolExtensions.cs
+++ /dev/null
@@ -1,518 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.FindSymbols;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static partial class INamedTypeSymbolExtensions
- {
- public static IEnumerable<INamedTypeSymbol> GetBaseTypesAndThis(this INamedTypeSymbol namedType)
- {
- var current = namedType;
- while (current != null)
- {
- yield return current;
- current = current.BaseType;
- }
- }
-
-// public static Task<IEnumerable<INamedTypeSymbol>> FindDerivedClassesAsync(
-// this INamedTypeSymbol type,
-// Solution solution,
-// CancellationToken cancellationToken)
-// {
-// return FindDerivedClassesAsync(type, solution, null, cancellationToken);
-// }
-
-// public static Task<IEnumerable<INamedTypeSymbol>> FindDerivedClassesAsync(
-// this INamedTypeSymbol type,
-// Solution solution,
-// IImmutableSet<Project> projects,
-// CancellationToken cancellationToken)
-// {
-// return DependentTypeFinder.FindDerivedClassesAsync(type, solution, projects, cancellationToken);
-// }
-//
-// public static Task<IEnumerable<INamedTypeSymbol>> FindDerivedInterfacesAsync(
-// this INamedTypeSymbol type,
-// Solution solution,
-// CancellationToken cancellationToken)
-// {
-// return FindDerivedInterfacesAsync(type, solution, null, cancellationToken);
-// }
-//
-// public static Task<IEnumerable<INamedTypeSymbol>> FindDerivedInterfacesAsync(
-// this INamedTypeSymbol type,
-// Solution solution,
-// IImmutableSet<Project> projects,
-// CancellationToken cancellationToken)
-// {
-// return DependentTypeFinder.FindDerivedInterfacesAsync(type, solution, projects, cancellationToken);
-// }
-//
-// public static Task<IEnumerable<INamedTypeSymbol>> FindImplementingTypesAsync(
-// this INamedTypeSymbol type,
-// Solution solution,
-// IImmutableSet<Project> projects,
-// CancellationToken cancellationToken)
-// {
-// return DependentTypeFinder.FindImplementingTypesAsync(type, solution, projects, cancellationToken);
-// }
-
- public static IEnumerable<ITypeParameterSymbol> GetAllTypeParameters(this INamedTypeSymbol symbol)
- {
- var stack = GetContainmentStack(symbol);
- return stack.SelectMany(n => n.TypeParameters);
- }
-
- public static IEnumerable<ITypeSymbol> GetAllTypeArguments(this INamedTypeSymbol symbol)
- {
- var stack = GetContainmentStack(symbol);
- return stack.SelectMany(n => n.TypeArguments);
- }
-
- private static Stack<INamedTypeSymbol> GetContainmentStack(INamedTypeSymbol symbol)
- {
- var stack = new Stack<INamedTypeSymbol>();
- for (var current = symbol; current != null; current = current.ContainingType)
- {
- stack.Push(current);
- }
-
- return stack;
- }
-
- public static bool IsContainedWithin(this INamedTypeSymbol symbol, INamedTypeSymbol outer)
- {
- // TODO(cyrusn): Should we be using OriginalSymbol here?
- for (var current = symbol; current != null; current = current.ContainingType)
- {
- if (current.Equals(outer))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static ISymbol FindImplementationForAbstractMember(this INamedTypeSymbol type, ISymbol symbol)
- {
- if (symbol.IsAbstract)
- {
- return type.GetBaseTypesAndThis().SelectMany(t => t.GetMembers(symbol.Name))
- .FirstOrDefault(s => symbol.Equals(GetOverriddenMember(s)));
- }
-
- return null;
- }
-
- private static ISymbol GetOverriddenMember(ISymbol symbol)
- {
- return symbol.TypeSwitch(
- (IMethodSymbol method) => (ISymbol)method.OverriddenMethod,
- (IPropertySymbol property) => property.OverriddenProperty,
- (IEventSymbol @event) => @event.OverriddenEvent);
- }
-
- private static bool ImplementationExists(INamedTypeSymbol classOrStructType, ISymbol member)
- {
- return classOrStructType.FindImplementationForInterfaceMember(member) != null;
- }
-
- private static bool IsImplemented(
- this INamedTypeSymbol classOrStructType,
- ISymbol member,
- Func<INamedTypeSymbol, ISymbol, bool> isValidImplementation,
- CancellationToken cancellationToken)
- {
- if (member.ContainingType.TypeKind == TypeKind.Interface)
- {
- if (member.Kind == SymbolKind.Property)
- {
- return IsInterfacePropertyImplemented(classOrStructType, (IPropertySymbol)member, cancellationToken);
- }
- else
- {
- return isValidImplementation(classOrStructType, member);
- }
- }
-
- if (member.IsAbstract)
- {
- if (member.Kind == SymbolKind.Property)
- {
- return IsAbstractPropertyImplemented(classOrStructType, (IPropertySymbol)member, cancellationToken);
- }
- else
- {
- return classOrStructType.FindImplementationForAbstractMember(member) != null;
- }
- }
-
- return true;
- }
-
- private static bool IsInterfacePropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol, CancellationToken cancellationToken)
- {
- // A property is only fully implemented if both it's setter and getter is implemented.
- if (propertySymbol.GetMethod != null)
- {
- if (classOrStructType.FindImplementationForInterfaceMember(propertySymbol.GetMethod) == null)
- {
- return false;
- }
- }
-
- if (propertySymbol.SetMethod != null)
- {
- if (classOrStructType.FindImplementationForInterfaceMember(propertySymbol.SetMethod) == null)
- {
- return false;
- }
- }
-
- return true;
- }
-
- private static bool IsAbstractPropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol, CancellationToken cancellationToken)
- {
- // A property is only fully implemented if both it's setter and getter is implemented.
- if (propertySymbol.GetMethod != null)
- {
- if (classOrStructType.FindImplementationForAbstractMember(propertySymbol.GetMethod) == null)
- {
- return false;
- }
- }
-
- if (propertySymbol.SetMethod != null)
- {
- if (classOrStructType.FindImplementationForAbstractMember(propertySymbol.SetMethod) == null)
- {
- return false;
- }
- }
-
- return true;
- }
-
- private static bool IsExplicitlyImplemented(
- this INamedTypeSymbol classOrStructType,
- ISymbol member,
- Func<INamedTypeSymbol, ISymbol, bool> isValid,
- CancellationToken cancellationToken)
- {
- var implementation = classOrStructType.FindImplementationForInterfaceMember(member);
- return implementation.TypeSwitch(
- (IEventSymbol @event) => @event.ExplicitInterfaceImplementations.Length > 0,
- (IMethodSymbol method) => method.ExplicitInterfaceImplementations.Length > 0,
- (IPropertySymbol property) => property.ExplicitInterfaceImplementations.Length > 0);
- }
-
- public static IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> GetAllUnimplementedMembers(
- this INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
- CancellationToken cancellationToken)
- {
- return classOrStructType.GetAllUnimplementedMembers(
- interfacesOrAbstractClasses,
- IsImplemented,
- ImplementationExists,
- GetMembers,
- allowReimplementation: false,
- cancellationToken: cancellationToken);
- }
-
- public static IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> GetAllUnimplementedMembersInThis(
- this INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
- CancellationToken cancellationToken)
- {
- return classOrStructType.GetAllUnimplementedMembers(
- interfacesOrAbstractClasses,
- IsImplemented,
- (t, m) =>
- {
- var implementation = classOrStructType.FindImplementationForInterfaceMember(m);
- return implementation != null && implementation.ContainingType == classOrStructType;
- },
- GetMembers,
- allowReimplementation: true,
- cancellationToken: cancellationToken);
- }
-
- public static IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> GetAllUnimplementedMembersInThis(
- this INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
- Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
- CancellationToken cancellationToken)
- {
- return classOrStructType.GetAllUnimplementedMembers(
- interfacesOrAbstractClasses,
- IsImplemented,
- (t, m) =>
- {
- var implementation = classOrStructType.FindImplementationForInterfaceMember(m);
- return implementation != null && implementation.ContainingType == classOrStructType;
- },
- interfaceMemberGetter,
- allowReimplementation: true,
- cancellationToken: cancellationToken);
- }
-
- public static IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> GetAllUnimplementedMembers(
- this INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
- Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
- CancellationToken cancellationToken)
- {
- return classOrStructType.GetAllUnimplementedMembers(
- interfacesOrAbstractClasses,
- IsImplemented,
- ImplementationExists,
- interfaceMemberGetter,
- allowReimplementation: false,
- cancellationToken: cancellationToken);
- }
-
- public static IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> GetAllUnimplementedExplicitMembers(
- this INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> interfaces,
- CancellationToken cancellationToken)
- {
- return classOrStructType.GetAllUnimplementedMembers(
- interfaces,
- IsExplicitlyImplemented,
- ImplementationExists,
- GetMembers,
- allowReimplementation: false,
- cancellationToken: cancellationToken);
- }
-
- public static IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> GetAllUnimplementedExplicitMembers(
- this INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> interfaces,
- Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
- CancellationToken cancellationToken)
- {
- return classOrStructType.GetAllUnimplementedMembers(
- interfaces,
- IsExplicitlyImplemented,
- ImplementationExists,
- interfaceMemberGetter,
- allowReimplementation: false,
- cancellationToken: cancellationToken);
- }
-
- private static IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> GetAllUnimplementedMembers(
- this INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
- Func<INamedTypeSymbol, ISymbol, Func<INamedTypeSymbol, ISymbol, bool>, CancellationToken, bool> isImplemented,
- Func<INamedTypeSymbol, ISymbol, bool> isValidImplementation,
- Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
- bool allowReimplementation,
- CancellationToken cancellationToken)
- {
-// Contract.ThrowIfNull(classOrStructType);
-// Contract.ThrowIfNull(interfacesOrAbstractClasses);
-// Contract.ThrowIfNull(isImplemented);
-
- if (classOrStructType.TypeKind != TypeKind.Class && classOrStructType.TypeKind != TypeKind.Struct)
- {
- return SpecializedCollections.EmptyList<Tuple<INamedTypeSymbol, IList<ISymbol>>>();
- }
-
- if (!interfacesOrAbstractClasses.Any())
- {
- return SpecializedCollections.EmptyList<Tuple<INamedTypeSymbol, IList<ISymbol>>>();
- }
-
- if (!interfacesOrAbstractClasses.All(i => i.TypeKind == TypeKind.Interface) &&
- !interfacesOrAbstractClasses.All(i => i.IsAbstractClass()))
- {
- return SpecializedCollections.EmptyList<Tuple<INamedTypeSymbol, IList<ISymbol>>>();
- }
-
- var typesToImplement = GetTypesToImplement(classOrStructType, interfacesOrAbstractClasses, allowReimplementation, cancellationToken);
- return typesToImplement.Select(s => Tuple.Create(s, GetUnimplementedMembers(classOrStructType, s, isImplemented, isValidImplementation, interfaceMemberGetter, cancellationToken)))
- .Where(t => t.Item2.Count > 0)
- .ToList();
- }
-
- private static IList<INamedTypeSymbol> GetTypesToImplement(
- INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
- bool allowReimplementation,
- CancellationToken cancellationToken)
- {
- return interfacesOrAbstractClasses.First().TypeKind == TypeKind.Interface
- ? GetInterfacesToImplement(classOrStructType, interfacesOrAbstractClasses, allowReimplementation, cancellationToken)
- : GetAbstractClassesToImplement(classOrStructType, interfacesOrAbstractClasses, cancellationToken);
- }
-
- private static IList<INamedTypeSymbol> GetAbstractClassesToImplement(
- INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> abstractClasses,
- CancellationToken cancellationToken)
- {
- return abstractClasses.SelectMany(GetBaseTypesAndThis)
- .Where(ITypeSymbolExtensions.IsAbstractClass)
- .ToList();
- }
-
- private static IList<INamedTypeSymbol> GetInterfacesToImplement(
- INamedTypeSymbol classOrStructType,
- IEnumerable<INamedTypeSymbol> interfaces,
- bool allowReimplementation,
- CancellationToken cancellationToken)
- {
- // We need to not only implement the specified interface, but also everything it
- // inherits from.
- cancellationToken.ThrowIfCancellationRequested();
- var interfacesToImplement = new List<INamedTypeSymbol>(
- interfaces.SelectMany(ITypeSymbolExtensions.GetAllInterfacesIncludingThis).Distinct());
-
- // However, there's no need to reimplement any interfaces that our base types already
- // implement. By definition they must contain all the necessary methods.
- var baseType = classOrStructType.BaseType;
- var alreadyImplementedInterfaces = baseType == null || allowReimplementation
- ? SpecializedCollections.EmptyEnumerable<INamedTypeSymbol>()
- : baseType.AllInterfaces;
-
- cancellationToken.ThrowIfCancellationRequested();
- foreach (var i in alreadyImplementedInterfaces)
- interfacesToImplement.Remove (i);
- return interfacesToImplement;
- }
-
- private static IList<ISymbol> GetUnimplementedMembers(
- this INamedTypeSymbol classOrStructType,
- INamedTypeSymbol interfaceType,
- Func<INamedTypeSymbol, ISymbol, Func<INamedTypeSymbol, ISymbol, bool>, CancellationToken, bool> isImplemented,
- Func<INamedTypeSymbol, ISymbol, bool> isValidImplementation,
- Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
- CancellationToken cancellationToken)
- {
- var q = from m in interfaceMemberGetter(interfaceType, classOrStructType)
- where m.Kind != SymbolKind.NamedType
- where m.Kind != SymbolKind.Method || ((IMethodSymbol)m).MethodKind == MethodKind.Ordinary
- where m.Kind != SymbolKind.Property || ((IPropertySymbol)m).IsIndexer || ((IPropertySymbol)m).CanBeReferencedByName
- where m.Kind != SymbolKind.Event || ((IEventSymbol)m).CanBeReferencedByName
- where !isImplemented(classOrStructType, m, isValidImplementation, cancellationToken)
- select m;
-
- return q.ToList();
- }
-
- public static IEnumerable<ISymbol> GetAttributeNamedParameters(
- this INamedTypeSymbol attributeSymbol,
- Compilation compilation,
- ISymbol within)
- {
- var systemAttributeType = compilation.AttributeType();
-
- foreach (var type in attributeSymbol.GetBaseTypesAndThis())
- {
- if (type.Equals(systemAttributeType))
- {
- break;
- }
-
- foreach (var member in type.GetMembers())
- {
- var namedParameter = IsAttributeNamedParameter(member, within ?? compilation.Assembly);
- if (namedParameter != null)
- {
- yield return namedParameter;
- }
- }
- }
- }
-
- private static ISymbol IsAttributeNamedParameter(
- ISymbol symbol,
- ISymbol within)
- {
- if (!symbol.CanBeReferencedByName ||
- !symbol.IsAccessibleWithin(within))
- {
- return null;
- }
-
- switch (symbol.Kind)
- {
- case SymbolKind.Field:
- var fieldSymbol = (IFieldSymbol)symbol;
- if (!fieldSymbol.IsConst &&
- !fieldSymbol.IsReadOnly &&
- !fieldSymbol.IsStatic)
- {
- return fieldSymbol;
- }
-
- break;
-
- case SymbolKind.Property:
- var propertySymbol = (IPropertySymbol)symbol;
- if (!propertySymbol.IsReadOnly &&
- !propertySymbol.IsWriteOnly &&
- !propertySymbol.IsStatic &&
- propertySymbol.GetMethod != null &&
- propertySymbol.SetMethod != null &&
- propertySymbol.GetMethod.IsAccessibleWithin(within) &&
- propertySymbol.SetMethod.IsAccessibleWithin(within))
- {
- return propertySymbol;
- }
-
- break;
- }
-
- return null;
- }
-
- private static ImmutableArray<ISymbol> GetMembers(INamedTypeSymbol type, ISymbol within)
- {
- return type.GetMembers();
- }
-
- public static INamespaceOrTypeSymbol GenerateRootNamespaceOrType(this INamedTypeSymbol namedType, string[] containers)
- {
- INamespaceOrTypeSymbol currentSymbol = namedType;
- for (int i = containers.Length - 1; i >= 0; i--)
- {
- currentSymbol = CodeGenerationSymbolFactory.CreateNamespaceSymbol(containers[i], members: new[] { currentSymbol });
- }
-
- return currentSymbol;
- }
-
- public static bool LastEnumValueHasInitializer(this INamedTypeSymbol namedTypeSymbol)
- {
- var enumDecl = namedTypeSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<EnumDeclarationSyntax>().FirstOrDefault();
- if (enumDecl != null)
- {
- var lastMember = enumDecl.Members.LastOrDefault();
- if (lastMember != null)
- {
- return lastMember.EqualsValue != null;
- }
- }
-
- return false;
- }
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/INamespaceOrTypeSymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/INamespaceOrTypeSymbolExtensions.cs
deleted file mode 100644
index 8d82d1473e..0000000000
--- a/main/src/addins/CSharpBinding/Util/INamespaceOrTypeSymbolExtensions.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static partial class INamespaceOrTypeSymbolExtensions
- {
- private static readonly ConditionalWeakTable<INamespaceOrTypeSymbol, List<string>> s_namespaceOrTypeToNameMap =
- new ConditionalWeakTable<INamespaceOrTypeSymbol, List<string>>();
-
- private static readonly SymbolDisplayFormat s_shortNameFormat = new SymbolDisplayFormat(
- miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes | SymbolDisplayMiscellaneousOptions.ExpandNullable);
-
- public static readonly Comparison<INamespaceOrTypeSymbol> CompareNamespaceOrTypeSymbols = CompareTo;
-
- public static string GetShortName(this INamespaceOrTypeSymbol symbol)
- {
- return symbol.ToDisplayString(s_shortNameFormat);
- }
-
- public static IEnumerable<IPropertySymbol> GetIndexers(this INamespaceOrTypeSymbol symbol)
- {
- return symbol == null
- ? SpecializedCollections.EmptyEnumerable<IPropertySymbol>()
- : symbol.GetMembers(WellKnownMemberNames.Indexer).OfType<IPropertySymbol>().Where(p => p.IsIndexer);
- }
-
- public static int CompareTo(this INamespaceOrTypeSymbol n1, INamespaceOrTypeSymbol n2)
- {
- var names1 = s_namespaceOrTypeToNameMap.GetValue(n1, GetNameParts);
- var names2 = s_namespaceOrTypeToNameMap.GetValue(n2, GetNameParts);
-
- for (var i = 0; i < Math.Min(names1.Count, names2.Count); i++)
- {
- var comp = names1[i].CompareTo(names2[i]);
- if (comp != 0)
- {
- return comp;
- }
- }
-
- return names1.Count - names2.Count;
- }
-
- private static List<string> GetNameParts(INamespaceOrTypeSymbol namespaceSymbol)
- {
- var result = new List<string>();
- GetNameParts(namespaceSymbol, result);
- return result;
- }
-
- private static void GetNameParts(INamespaceOrTypeSymbol namespaceOrTypeSymbol, List<string> result)
- {
- if (namespaceOrTypeSymbol == null || (namespaceOrTypeSymbol.IsNamespace && ((INamespaceSymbol)namespaceOrTypeSymbol).IsGlobalNamespace))
- {
- return;
- }
-
- GetNameParts(namespaceOrTypeSymbol.ContainingNamespace, result);
- result.Add(namespaceOrTypeSymbol.Name);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/IParameterSymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/IParameterSymbolExtensions.cs
deleted file mode 100644
index daddbf02a3..0000000000
--- a/main/src/addins/CSharpBinding/Util/IParameterSymbolExtensions.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.Text;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class IParameterSymbolExtensions
- {
- public static bool IsRefOrOut(this IParameterSymbol symbol)
- {
- return symbol.RefKind != RefKind.None;
- }
-
- public static IParameterSymbol RenameParameter(this IParameterSymbol parameter, string parameterName)
- {
- return parameter.Name == parameterName
- ? parameter
- : CodeGenerationSymbolFactory.CreateParameterSymbol(
- parameter.GetAttributes(),
- parameter.RefKind,
- parameter.IsParams,
- parameter.Type,
- parameterName,
- parameter.IsOptional,
- parameter.HasExplicitDefaultValue,
- parameter.HasExplicitDefaultValue ? parameter.ExplicitDefaultValue : null);
- }
-
- public static IList<IParameterSymbol> RenameParameters(this IList<IParameterSymbol> parameters, IList<string> parameterNames)
- {
- var result = new List<IParameterSymbol>();
- for (int i = 0; i < parameterNames.Count; i++)
- {
- result.Add(parameters[i].RenameParameter(parameterNames[i]));
- }
-
- return result;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/IPropertySymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/IPropertySymbolExtensions.cs
deleted file mode 100644
index 9ca69b2f10..0000000000
--- a/main/src/addins/CSharpBinding/Util/IPropertySymbolExtensions.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class IPropertySymbolExtensions
- {
- public static IPropertySymbol RenameParameters(this IPropertySymbol property, IList<string> parameterNames)
- {
- var parameterList = property.Parameters;
- if (parameterList.Select(p => p.Name).SequenceEqual(parameterNames))
- {
- return property;
- }
-
- var parameters = parameterList.RenameParameters(parameterNames);
-
- return CodeGenerationSymbolFactory.CreatePropertySymbol(
- property.ContainingType,
- property.GetAttributes(),
- property.DeclaredAccessibility,
- property.GetSymbolModifiers(),
- property.Type,
- property.ExplicitInterfaceImplementations.FirstOrDefault(),
- property.Name,
- parameters,
- property.GetMethod,
- property.SetMethod,
- property.IsIndexer);
- }
-
- public static IPropertySymbol RemoveAttributeFromParameters(
- this IPropertySymbol property, INamedTypeSymbol attributeType)
- {
- if (attributeType == null)
- {
- return property;
- }
-
- var someParameterHasAttribute = property.Parameters
- .Any(p => p.GetAttributes().Any(a => a.AttributeClass.Equals(attributeType)));
- if (!someParameterHasAttribute)
- {
- return property;
- }
-
- return CodeGenerationSymbolFactory.CreatePropertySymbol(
- property.ContainingType,
- property.GetAttributes(),
- property.DeclaredAccessibility,
- property.GetSymbolModifiers(),
- property.Type,
- property.ExplicitInterfaceImplementations.FirstOrDefault(),
- property.Name,
- property.Parameters.Select(p =>
- CodeGenerationSymbolFactory.CreateParameterSymbol(
- p.GetAttributes().Where(a => !a.AttributeClass.Equals(attributeType)).ToList(),
- p.RefKind, p.IsParams, p.Type, p.Name, p.IsOptional,
- p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null)).ToList(),
- property.GetMethod,
- property.SetMethod,
- property.IsIndexer);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/ISymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/ISymbolExtensions.cs
deleted file mode 100644
index 29bd917a4b..0000000000
--- a/main/src/addins/CSharpBinding/Util/ISymbolExtensions.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// ISymbolExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Editing;
-using System.Collections.Generic;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class ISymbolExtensions
- {
- public static DeclarationModifiers GetSymbolModifiers(this ISymbol symbol)
- {
- // ported from roslyn source - why they didn't use DeclarationModifiers.From (symbol) ?
- return DeclarationModifiers.None
- .WithIsStatic (symbol.IsStatic)
- .WithIsAbstract (symbol.IsAbstract)
- .WithIsUnsafe (symbol.IsUnsafe ())
- .WithIsVirtual (symbol.IsVirtual)
- .WithIsOverride (symbol.IsOverride)
- .WithIsSealed (symbol.IsSealed);
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/ITypeParameterSymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/ITypeParameterSymbolExtensions.cs
deleted file mode 100644
index 86b28def3a..0000000000
--- a/main/src/addins/CSharpBinding/Util/ITypeParameterSymbolExtensions.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class ITypeParameterSymbolExtensions
- {
- public static INamedTypeSymbol GetNamedTypeSymbolConstraint(this ITypeParameterSymbol typeParameter)
- {
- return typeParameter.ConstraintTypes.Select(GetNamedTypeSymbol).WhereNotNull().FirstOrDefault();
- }
-
- private static INamedTypeSymbol GetNamedTypeSymbol(ITypeSymbol type)
- {
- return type is INamedTypeSymbol
- ? (INamedTypeSymbol)type
- : type is ITypeParameterSymbol
- ? GetNamedTypeSymbolConstraint((ITypeParameterSymbol)type)
- : null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/ITypeSymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/ITypeSymbolExtensions.cs
deleted file mode 100644
index ff226ddfe1..0000000000
--- a/main/src/addins/CSharpBinding/Util/ITypeSymbolExtensions.cs
+++ /dev/null
@@ -1,1108 +0,0 @@
-//
-// ITypeSymbolExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Linq;
-using System.ComponentModel;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis;
-using System.Reflection;
-using System.Collections.Generic;
-using System.Threading;
-using System.Collections.Immutable;
-using System.Diagnostics;
-using System.Threading.Tasks;
-using System.Runtime.ExceptionServices;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- static class ITypeSymbolExtensions
- {
- readonly static MethodInfo generateTypeSyntax;
- readonly static MethodInfo inheritsFromOrEqualsIgnoringConstructionMethod;
-
- static ITypeSymbolExtensions()
- {
- var typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.ITypeSymbolExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- generateTypeSyntax = typeInfo.GetMethod("GenerateTypeSyntax", new[] { typeof(ITypeSymbol) });
- containingTypesOrSelfHasUnsafeKeywordMethod = typeInfo.GetMethod("ContainingTypesOrSelfHasUnsafeKeyword", BindingFlags.Public | BindingFlags.Static);
-
- typeInfo = Type.GetType("Microsoft.CodeAnalysis.Shared.Extensions.ITypeSymbolExtensions" + ReflectionNamespaces.WorkspacesAsmName, true);
- inheritsFromOrEqualsIgnoringConstructionMethod = typeInfo.GetMethod("InheritsFromOrEqualsIgnoringConstruction");
- removeUnavailableTypeParametersMethod = typeInfo.GetMethod("RemoveUnavailableTypeParameters");
- removeUnnamedErrorTypesMethod = typeInfo.GetMethod("RemoveUnnamedErrorTypes");
- replaceTypeParametersBasedOnTypeConstraintsMethod = typeInfo.GetMethod("ReplaceTypeParametersBasedOnTypeConstraints");
- foreach (var m in typeInfo.GetMethods (BindingFlags.Public | BindingFlags.Static)) {
- if (m.Name != "SubstituteTypes")
- continue;
- var parameters = m.GetParameters ();
- if (parameters.Length != 3)
- continue;
-
- if (parameters [2].Name == "typeGenerator") {
- substituteTypesMethod2 = m;
- } else if (parameters [2].Name == "compilation"){
- substituteTypesMethod = m;
- }
- break;
- }
- }
-
- public static TypeSyntax GenerateTypeSyntax (this ITypeSymbol typeSymbol)
- {
- return (TypeSyntax)generateTypeSyntax.Invoke (null, new [] { typeSymbol });
- }
-
- readonly static MethodInfo containingTypesOrSelfHasUnsafeKeywordMethod;
- public static bool ContainingTypesOrSelfHasUnsafeKeyword(this ITypeSymbol containingType)
- {
- return (bool)containingTypesOrSelfHasUnsafeKeywordMethod.Invoke (null, new object[] { containingType });
- }
-
-
-
- private const string DefaultParameterName = "p";
- private const string DefaultBuiltInParameterName = "v";
-
- public static IList<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
- {
- var allInterfaces = type.AllInterfaces;
- var namedType = type as INamedTypeSymbol;
- if (namedType != null && namedType.TypeKind == TypeKind.Interface && !allInterfaces.Contains(namedType))
- {
- var result = new List<INamedTypeSymbol>(allInterfaces.Length + 1);
- result.Add(namedType);
- result.AddRange(allInterfaces);
- return result;
- }
-
- return allInterfaces;
- }
-
- public static bool IsAbstractClass(this ITypeSymbol symbol)
- {
- return symbol?.TypeKind == TypeKind.Class && symbol.IsAbstract;
- }
-
- public static bool IsSystemVoid(this ITypeSymbol symbol)
- {
- return symbol?.SpecialType == SpecialType.System_Void;
- }
-
- public static bool IsNullable(this ITypeSymbol symbol)
- {
- return symbol?.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T;
- }
-
- public static bool IsErrorType(this ITypeSymbol symbol)
- {
- return symbol?.TypeKind == TypeKind.Error;
- }
-
- public static bool IsModuleType(this ITypeSymbol symbol)
- {
- return symbol?.TypeKind == TypeKind.Module;
- }
-
- public static bool IsInterfaceType(this ITypeSymbol symbol)
- {
- return symbol?.TypeKind == TypeKind.Interface;
- }
-
- public static bool IsDelegateType(this ITypeSymbol symbol)
- {
- return symbol?.TypeKind == TypeKind.Delegate;
- }
-
- public static bool IsAnonymousType(this INamedTypeSymbol symbol)
- {
- return symbol?.IsAnonymousType == true;
- }
-
-// public static ITypeSymbol RemoveNullableIfPresent(this ITypeSymbol symbol)
-// {
-// if (symbol.IsNullable())
-// {
-// return symbol.GetTypeArguments().Single();
-// }
-//
-// return symbol;
-// }
-
-// /// <summary>
-// /// Returns the corresponding symbol in this type or a base type that implements
-// /// interfaceMember (either implicitly or explicitly), or null if no such symbol exists
-// /// (which might be either because this type doesn't implement the container of
-// /// interfaceMember, or this type doesn't supply a member that successfully implements
-// /// interfaceMember).
-// /// </summary>
-// public static IEnumerable<ISymbol> FindImplementationsForInterfaceMember(
-// this ITypeSymbol typeSymbol,
-// ISymbol interfaceMember,
-// Workspace workspace,
-// CancellationToken cancellationToken)
-// {
-// // This method can return multiple results. Consider the case of:
-// //
-// // interface IFoo<X> { void Foo(X x); }
-// //
-// // class C : IFoo<int>, IFoo<string> { void Foo(int x); void Foo(string x); }
-// //
-// // If you're looking for the implementations of IFoo<X>.Foo then you want to find both
-// // results in C.
-//
-// // TODO(cyrusn): Implement this using the actual code for
-// // TypeSymbol.FindImplementationForInterfaceMember
-//
-// if (typeSymbol == null || interfaceMember == null)
-// {
-// yield break;
-// }
-//
-// if (interfaceMember.Kind != SymbolKind.Event &&
-// interfaceMember.Kind != SymbolKind.Method &&
-// interfaceMember.Kind != SymbolKind.Property)
-// {
-// yield break;
-// }
-//
-// // WorkItem(4843)
-// //
-// // 'typeSymbol' has to at least implement the interface containing the member. note:
-// // this just means that the interface shows up *somewhere* in the inheritance chain of
-// // this type. However, this type may not actually say that it implements it. For
-// // example:
-// //
-// // interface I { void Foo(); }
-// //
-// // class B { }
-// //
-// // class C : B, I { }
-// //
-// // class D : C { }
-// //
-// // D does implement I transitively through C. However, even if D has a "Foo" method, it
-// // won't be an implementation of I.Foo. The implementation of I.Foo must be from a type
-// // that actually has I in it's direct interface chain, or a type that's a base type of
-// // that. in this case, that means only classes C or B.
-// var interfaceType = interfaceMember.ContainingType;
-// if (!typeSymbol.ImplementsIgnoringConstruction(interfaceType))
-// {
-// yield break;
-// }
-//
-// // We've ascertained that the type T implements some constructed type of the form I<X>.
-// // However, we're not precisely sure which constructions of I<X> are being used. For
-// // example, a type C might implement I<int> and I<string>. If we're searching for a
-// // method from I<X> we might need to find several methods that implement different
-// // instantiations of that method.
-// var originalInterfaceType = interfaceMember.ContainingType.OriginalDefinition;
-// var originalInterfaceMember = interfaceMember.OriginalDefinition;
-// var constructedInterfaces = typeSymbol.AllInterfaces.Where(i =>
-// SymbolEquivalenceComparer.Instance.Equals(i.OriginalDefinition, originalInterfaceType));
-//
-// foreach (var constructedInterface in constructedInterfaces)
-// {
-// cancellationToken.ThrowIfCancellationRequested();
-// var constructedInterfaceMember = constructedInterface.GetMembers().FirstOrDefault(m =>
- // SymbolEquivalenceComparer.Instance.Equals(m.OriginalDefinition, originalInterfaceMember));
-//
-// if (constructedInterfaceMember == null)
-// {
-// continue;
-// }
-//
-// // Now we need to walk the base type chain, but we start at the first type that actually
-// // has the interface directly in its interface hierarchy.
-// var seenTypeDeclaringInterface = false;
-// for (var currentType = typeSymbol; currentType != null; currentType = currentType.BaseType)
-// {
-// seenTypeDeclaringInterface = seenTypeDeclaringInterface ||
-// currentType.GetOriginalInterfacesAndTheirBaseInterfaces().Contains(interfaceType.OriginalDefinition);
-//
-// if (seenTypeDeclaringInterface)
-// {
-// var result = constructedInterfaceMember.TypeSwitch(
-// (IEventSymbol eventSymbol) => FindImplementations(currentType, eventSymbol, workspace, e => e.ExplicitInterfaceImplementations),
-// (IMethodSymbol methodSymbol) => FindImplementations(currentType, methodSymbol, workspace, m => m.ExplicitInterfaceImplementations),
-// (IPropertySymbol propertySymbol) => FindImplementations(currentType, propertySymbol, workspace, p => p.ExplicitInterfaceImplementations));
-//
-// if (result != null)
-// {
-// yield return result;
-// break;
-// }
-// }
-// }
-// }
-// }
-//
-// private static HashSet<INamedTypeSymbol> GetOriginalInterfacesAndTheirBaseInterfaces(
-// this ITypeSymbol type,
-// HashSet<INamedTypeSymbol> symbols = null)
-// {
-// symbols = symbols ?? new HashSet<INamedTypeSymbol>(SymbolEquivalenceComparer.Instance);
-//
-// foreach (var interfaceType in type.Interfaces)
-// {
-// symbols.Add(interfaceType.OriginalDefinition);
-// symbols.AddRange(interfaceType.AllInterfaces.Select(i => i.OriginalDefinition));
-// }
-//
-// return symbols;
-// }
-
-// private static ISymbol FindImplementations<TSymbol>(
-// ITypeSymbol typeSymbol,
-// TSymbol interfaceSymbol,
-// Workspace workspace,
-// Func<TSymbol, ImmutableArray<TSymbol>> getExplicitInterfaceImplementations) where TSymbol : class, ISymbol
-// {
-// // Check the current type for explicit interface matches. Otherwise, check
-// // the current type and base types for implicit matches.
-// var explicitMatches =
-// from member in typeSymbol.GetMembers().OfType<TSymbol>()
-// where getExplicitInterfaceImplementations(member).Length > 0
-// from explicitInterfaceMethod in getExplicitInterfaceImplementations(member)
-// where SymbolEquivalenceComparer.Instance.Equals(explicitInterfaceMethod, interfaceSymbol)
-// select member;
-//
-// var provider = workspace.Services.GetLanguageServices(typeSymbol.Language);
-// var semanticFacts = provider.GetService<ISemanticFactsService>();
-//
-// // Even if a language only supports explicit interface implementation, we
-// // can't enforce it for types from metadata. For example, a VB symbol
-// // representing System.Xml.XmlReader will say it implements IDisposable, but
-// // the XmlReader.Dispose() method will not be an explicit implementation of
-// // IDisposable.Dispose()
-// if (!semanticFacts.SupportsImplicitInterfaceImplementation &&
-// typeSymbol.Locations.Any(location => location.IsInSource))
-// {
-// return explicitMatches.FirstOrDefault();
-// }
-//
-// var syntaxFacts = provider.GetService<ISyntaxFactsService>();
-// var implicitMatches =
-// from baseType in typeSymbol.GetBaseTypesAndThis()
-// from member in baseType.GetMembers(interfaceSymbol.Name).OfType<TSymbol>()
-// where member.DeclaredAccessibility == Accessibility.Public &&
-// !member.IsStatic &&
-// SignatureComparer.Instance.HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors(member, interfaceSymbol, syntaxFacts.IsCaseSensitive)
-// select member;
-//
-// return explicitMatches.FirstOrDefault() ?? implicitMatches.FirstOrDefault();
-// }
-
- public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol type)
- {
- var current = type;
- while (current != null)
- {
- yield return current;
- current = current.ContainingType;
- }
- }
-
- public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
- {
- var current = type.ContainingType;
- while (current != null)
- {
- yield return current;
- current = current.ContainingType;
- }
- }
-
-// // Determine if "type" inherits from "baseType", ignoring constructed types, and dealing
-// // only with original types.
-// public static bool InheritsFromOrEquals(
-// this ITypeSymbol type, ITypeSymbol baseType)
-// {
-// return type.GetBaseTypesAndThis().Contains(t => SymbolEquivalenceComparer.Instance.Equals(t, baseType));
-// }
-//
- // Determine if "type" inherits from "baseType", ignoring constructed types, and dealing
- // only with original types.
- public static bool InheritsFromOrEqualsIgnoringConstruction(
- this ITypeSymbol type, ITypeSymbol baseType)
- {
- return (bool)inheritsFromOrEqualsIgnoringConstructionMethod.Invoke (null, new [] { type, baseType });
- }
-//
-// // Determine if "type" inherits from "baseType", ignoring constructed types, and dealing
-// // only with original types.
-// public static bool InheritsFromIgnoringConstruction(
-// this ITypeSymbol type, ITypeSymbol baseType)
-// {
-// var originalBaseType = baseType.OriginalDefinition;
-//
-// // We could just call GetBaseTypes and foreach over it, but this
-// // is a hot path in Find All References. This avoid the allocation
-// // of the enumerator type.
-// var currentBaseType = type.BaseType;
-// while (currentBaseType != null)
-// {
-// if (SymbolEquivalenceComparer.Instance.Equals(currentBaseType.OriginalDefinition, originalBaseType))
-// {
-// return true;
-// }
-//
-// currentBaseType = currentBaseType.BaseType;
-// }
-//
-// return false;
-// }
-
-// public static bool ImplementsIgnoringConstruction(
-// this ITypeSymbol type, ITypeSymbol interfaceType)
-// {
-// var originalInterfaceType = interfaceType.OriginalDefinition;
-// if (type is INamedTypeSymbol && type.TypeKind == TypeKind.Interface)
-// {
-// // Interfaces don't implement other interfaces. They extend them.
-// return false;
-// }
-//
-// return type.AllInterfaces.Any(t => SymbolEquivalenceComparer.Instance.Equals(t.OriginalDefinition, originalInterfaceType));
-// }
-//
-// public static bool Implements(
-// this ITypeSymbol type, ITypeSymbol interfaceType)
-// {
-// return type.AllInterfaces.Contains(t => SymbolEquivalenceComparer.Instance.Equals(t, interfaceType));
-// }
-//
- public static bool IsAttribute(this ITypeSymbol symbol)
- {
- for (var b = symbol.BaseType; b != null; b = b.BaseType)
- {
- if (b.MetadataName == "Attribute" &&
- b.ContainingType == null &&
- b.ContainingNamespace != null &&
- b.ContainingNamespace.Name == "System" &&
- b.ContainingNamespace.ContainingNamespace != null &&
- b.ContainingNamespace.ContainingNamespace.IsGlobalNamespace)
- {
- return true;
- }
- }
-
- return false;
- }
- readonly static MethodInfo removeUnavailableTypeParametersMethod;
-
- public static ITypeSymbol RemoveUnavailableTypeParameters(
- this ITypeSymbol type,
- Compilation compilation,
- IEnumerable<ITypeParameterSymbol> availableTypeParameters)
- {
- try {
- return (ITypeSymbol)removeUnavailableTypeParametersMethod.Invoke (null, new object[] { type, compilation, availableTypeParameters });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- public static ITypeSymbol RemoveAnonymousTypes(
- this ITypeSymbol type,
- Compilation compilation)
- {
- return type?.Accept(new AnonymousTypeRemover(compilation));
- }
-
- private class AnonymousTypeRemover : SymbolVisitor<ITypeSymbol>
- {
- private readonly Compilation _compilation;
-
- public AnonymousTypeRemover(Compilation compilation)
- {
- _compilation = compilation;
- }
-
- public override ITypeSymbol DefaultVisit(ISymbol node)
- {
- throw new NotImplementedException();
- }
-
- public override ITypeSymbol VisitDynamicType(IDynamicTypeSymbol symbol)
- {
- return symbol;
- }
-
- public override ITypeSymbol VisitArrayType(IArrayTypeSymbol symbol)
- {
- var elementType = symbol.ElementType.Accept(this);
- if (elementType != null && elementType.Equals(symbol.ElementType))
- {
- return symbol;
- }
-
- return _compilation.CreateArrayTypeSymbol(elementType, symbol.Rank);
- }
-
- public override ITypeSymbol VisitNamedType(INamedTypeSymbol symbol)
- {
- if (symbol.IsNormalAnonymousType() ||
- symbol.IsAnonymousDelegateType())
- {
- return _compilation.ObjectType;
- }
-
- var arguments = symbol.TypeArguments.Select(t => t.Accept(this)).ToArray();
- if (arguments.SequenceEqual(symbol.TypeArguments))
- {
- return symbol;
- }
-
- return symbol.ConstructedFrom.Construct(arguments.ToArray());
- }
-
- public override ITypeSymbol VisitPointerType(IPointerTypeSymbol symbol)
- {
- var elementType = symbol.PointedAtType.Accept(this);
- if (elementType != null && elementType.Equals(symbol.PointedAtType))
- {
- return symbol;
- }
-
- return _compilation.CreatePointerTypeSymbol(elementType);
- }
-
- public override ITypeSymbol VisitTypeParameter(ITypeParameterSymbol symbol)
- {
- return symbol;
- }
- }
-
- readonly static MethodInfo replaceTypeParametersBasedOnTypeConstraintsMethod;
- public static ITypeSymbol ReplaceTypeParametersBasedOnTypeConstraints(
- this ITypeSymbol type,
- Compilation compilation,
- IEnumerable<ITypeParameterSymbol> availableTypeParameters,
- Solution solution,
- CancellationToken cancellationToken)
- {
- try {
- return (ITypeSymbol)replaceTypeParametersBasedOnTypeConstraintsMethod.Invoke (null, new object[] { type, compilation, availableTypeParameters, solution, cancellationToken});
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- readonly static MethodInfo removeUnnamedErrorTypesMethod;
- public static ITypeSymbol RemoveUnnamedErrorTypes(
- this ITypeSymbol type,
- Compilation compilation)
- {
- try {
- return (ITypeSymbol)removeUnnamedErrorTypesMethod.Invoke (null, new object[] { type, compilation });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- public static IList<ITypeParameterSymbol> GetReferencedMethodTypeParameters(
- this ITypeSymbol type, IList<ITypeParameterSymbol> result = null)
- {
- result = result ?? new List<ITypeParameterSymbol>();
- type?.Accept(new CollectTypeParameterSymbolsVisitor(result, onlyMethodTypeParameters: true));
- return result;
- }
-
- public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(
- this ITypeSymbol type, IList<ITypeParameterSymbol> result = null)
- {
- result = result ?? new List<ITypeParameterSymbol>();
- type?.Accept(new CollectTypeParameterSymbolsVisitor(result, onlyMethodTypeParameters: false));
- return result;
- }
-
- private class CollectTypeParameterSymbolsVisitor : SymbolVisitor
- {
- private readonly HashSet<ISymbol> _visited = new HashSet<ISymbol>();
- private readonly bool _onlyMethodTypeParameters;
- private readonly IList<ITypeParameterSymbol> _typeParameters;
-
- public CollectTypeParameterSymbolsVisitor(
- IList<ITypeParameterSymbol> typeParameters,
- bool onlyMethodTypeParameters)
- {
- _onlyMethodTypeParameters = onlyMethodTypeParameters;
- _typeParameters = typeParameters;
- }
-
- public override void DefaultVisit(ISymbol node)
- {
- throw new NotImplementedException();
- }
-
- public override void VisitDynamicType(IDynamicTypeSymbol symbol)
- {
- }
-
- public override void VisitArrayType(IArrayTypeSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return;
- }
-
- symbol.ElementType.Accept(this);
- }
-
- public override void VisitNamedType(INamedTypeSymbol symbol)
- {
- if (_visited.Add(symbol))
- {
- foreach (var child in symbol.GetAllTypeArguments())
- {
- child.Accept(this);
- }
- }
- }
-
- public override void VisitPointerType(IPointerTypeSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return;
- }
-
- symbol.PointedAtType.Accept(this);
- }
-
- public override void VisitTypeParameter(ITypeParameterSymbol symbol)
- {
- if (_visited.Add(symbol))
- {
- if (symbol.TypeParameterKind == TypeParameterKind.Method || !_onlyMethodTypeParameters)
- {
- if (!_typeParameters.Contains(symbol))
- {
- _typeParameters.Add(symbol);
- }
- }
-
- foreach (var constraint in symbol.ConstraintTypes)
- {
- constraint.Accept(this);
- }
- }
- }
- }
-
- readonly static MethodInfo substituteTypesMethod;
- public static ITypeSymbol SubstituteTypes<TType1, TType2>(
- this ITypeSymbol type,
- IDictionary<TType1, TType2> mapping,
- Compilation compilation)
- where TType1 : ITypeSymbol
- where TType2 : ITypeSymbol
- {
- if (type == null)
- throw new ArgumentNullException ("type");
- try {
- return (ITypeSymbol)substituteTypesMethod.MakeGenericMethod (typeof(TType1), typeof(TType2)).Invoke (null, new object[] { type, mapping, compilation });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- readonly static MethodInfo substituteTypesMethod2;
- public static ITypeSymbol SubstituteTypes<TType1, TType2>(
- this ITypeSymbol type,
- IDictionary<TType1, TType2> mapping,
- TypeGenerator typeGenerator)
- where TType1 : ITypeSymbol
- where TType2 : ITypeSymbol
- {
- try {
- return (ITypeSymbol)substituteTypesMethod2.MakeGenericMethod (typeof(TType1), typeof(TType2)).Invoke (null, new object[] { type, mapping, typeGenerator.Instance });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
-
- public static bool IsUnexpressableTypeParameterConstraint(this ITypeSymbol typeSymbol)
- {
- if (typeSymbol.IsSealed || typeSymbol.IsValueType)
- {
- return true;
- }
-
- switch (typeSymbol.TypeKind)
- {
- case TypeKind.Array:
- case TypeKind.Delegate:
- return true;
- }
-
- switch (typeSymbol.SpecialType)
- {
- case SpecialType.System_Array:
- case SpecialType.System_Delegate:
- case SpecialType.System_MulticastDelegate:
- case SpecialType.System_Enum:
- case SpecialType.System_ValueType:
- return true;
- }
-
- return false;
- }
-
- public static bool IsNumericType(this ITypeSymbol type)
- {
- if (type != null)
- {
- switch (type.SpecialType)
- {
- case SpecialType.System_Byte:
- case SpecialType.System_SByte:
- case SpecialType.System_Int16:
- case SpecialType.System_UInt16:
- case SpecialType.System_Int32:
- case SpecialType.System_UInt32:
- case SpecialType.System_Int64:
- case SpecialType.System_UInt64:
- case SpecialType.System_Single:
- case SpecialType.System_Double:
- case SpecialType.System_Decimal:
- return true;
- }
- }
-
- return false;
- }
-
- public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
- {
- return typeSymbol.Accept(MinimalAccessibilityVisitor.Instance);
- }
- private class MinimalAccessibilityVisitor : SymbolVisitor<Accessibility>
- {
- public static readonly SymbolVisitor<Accessibility> Instance = new MinimalAccessibilityVisitor();
-
- public override Accessibility DefaultVisit(ISymbol node)
- {
- throw new NotImplementedException();
- }
-
- public override Accessibility VisitAlias(IAliasSymbol symbol)
- {
- return symbol.Target.Accept(this);
- }
-
- public override Accessibility VisitArrayType(IArrayTypeSymbol symbol)
- {
- return symbol.ElementType.Accept(this);
- }
-
- public override Accessibility VisitDynamicType(IDynamicTypeSymbol symbol)
- {
- return Accessibility.Public;
- }
-
- public override Accessibility VisitNamedType(INamedTypeSymbol symbol)
- {
- var accessibility = symbol.DeclaredAccessibility;
-
- foreach (var arg in symbol.TypeArguments)
- {
- accessibility = CommonAccessibilityUtilities.Minimum(accessibility, arg.Accept(this));
- }
-
- if (symbol.ContainingType != null)
- {
- accessibility = CommonAccessibilityUtilities.Minimum(accessibility, symbol.ContainingType.Accept(this));
- }
-
- return accessibility;
- }
-
- public override Accessibility VisitPointerType(IPointerTypeSymbol symbol)
- {
- return symbol.PointedAtType.Accept(this);
- }
-
- public override Accessibility VisitTypeParameter(ITypeParameterSymbol symbol)
- {
- // TODO(cyrusn): Do we have to consider the constraints?
- return Accessibility.Public;
- }
- }
- public static bool ContainsAnonymousType(this ITypeSymbol symbol)
- {
- return symbol.TypeSwitch(
- (IArrayTypeSymbol a) => ContainsAnonymousType(a.ElementType),
- (IPointerTypeSymbol p) => ContainsAnonymousType(p.PointedAtType),
- (INamedTypeSymbol n) => ContainsAnonymousType(n),
- _ => false);
- }
-
- private static bool ContainsAnonymousType(INamedTypeSymbol type)
- {
- if (type.IsAnonymousType)
- {
- return true;
- }
-
- foreach (var typeArg in type.GetAllTypeArguments())
- {
- if (ContainsAnonymousType(typeArg))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
- {
- while (true)
- {
- var arrayType = type as IArrayTypeSymbol;
- if (arrayType != null)
- {
- type = arrayType.ElementType;
- continue;
- }
-
- var pointerType = type as IPointerTypeSymbol;
- if (pointerType != null)
- {
- type = pointerType.PointedAtType;
- continue;
- }
-
- break;
- }
-
- var shortName = GetParameterName(type);
- return capitalize ? shortName.ToPascalCase() : shortName.ToCamelCase();
- }
-
- private static string GetParameterName(ITypeSymbol type)
- {
- if (type == null || type.IsAnonymousType())
- {
- return DefaultParameterName;
- }
-
- if (type.IsSpecialType() || type.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T)
- {
- return DefaultBuiltInParameterName;
- }
-
- var shortName = type.GetShortName();
- return shortName.Length == 0
- ? DefaultParameterName
- : shortName;
- }
-
- private static bool IsSpecialType(this ITypeSymbol symbol)
- {
- if (symbol != null)
- {
- switch (symbol.SpecialType)
- {
- case SpecialType.System_Object:
- case SpecialType.System_Void:
- case SpecialType.System_Boolean:
- case SpecialType.System_SByte:
- case SpecialType.System_Byte:
- case SpecialType.System_Decimal:
- case SpecialType.System_Single:
- case SpecialType.System_Double:
- case SpecialType.System_Int16:
- case SpecialType.System_Int32:
- case SpecialType.System_Int64:
- case SpecialType.System_Char:
- case SpecialType.System_String:
- case SpecialType.System_UInt16:
- case SpecialType.System_UInt32:
- case SpecialType.System_UInt64:
- return true;
- }
- }
-
- return false;
- }
-
- public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol)
- {
- if (typeSymbol.AllInterfaces.Any (i => i.SpecialType == SpecialType.System_Collections_IEnumerable)) {
- var curType = typeSymbol;
- while (curType != null) {
- if (HasAddMethod (curType))
- return true;
- curType = curType.BaseType;
- }
- }
- return false;
- }
-
- static bool HasAddMethod (ITypeSymbol typeSymbol)
- {
- return typeSymbol
- .GetMembers (WellKnownMemberNames.CollectionInitializerAddMethodName)
- .OfType<IMethodSymbol> ().Any (m => m.Parameters.Any ());
- }
-
- public static INamedTypeSymbol GetDelegateType(this ITypeSymbol typeSymbol, Compilation compilation)
- {
- if (typeSymbol != null)
- {
- var expressionOfT = compilation.ExpressionOfTType();
- if (typeSymbol.OriginalDefinition.Equals(expressionOfT))
- {
- var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
- return typeArgument as INamedTypeSymbol;
- }
-
- if (typeSymbol.IsDelegateType())
- {
- return typeSymbol as INamedTypeSymbol;
- }
- }
-
- return null;
- }
-
- public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
- {
- if (containingType == null)
- {
- return SpecializedCollections.EmptyEnumerable<T>();
- }
-
- var types = containingType.GetBaseTypes();
- return types.SelectMany(x => x.GetMembers().OfType<T>().Where(m => m.IsAccessibleWithin(within)));
- }
-
- public static IEnumerable<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
- {
- if (containingType == null)
- {
- return SpecializedCollections.EmptyEnumerable<T>();
- }
-
- var types = containingType.GetBaseTypesAndThis();
- return types.SelectMany(x => x.GetMembers().OfType<T>().Where(m => m.IsAccessibleWithin(within)));
- }
-
- public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
- {
- if (t1.Count != t2.Count)
- {
- return null;
- }
-
- // For t1 to be more specific than t2, it has to be not less specific in every member,
- // and more specific in at least one.
-
- bool? result = null;
- for (int i = 0; i < t1.Count; ++i)
- {
- var r = t1[i].IsMoreSpecificThan(t2[i]);
- if (r == null)
- {
- // We learned nothing. Do nothing.
- }
- else if (result == null)
- {
- // We have found the first more specific type. See if
- // all the rest on this side are not less specific.
- result = r;
- }
- else if (result != r)
- {
- // We have more specific types on both left and right, so we
- // cannot succeed in picking a better type list. Bail out now.
- return null;
- }
- }
-
- return result;
- }
-
- private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
- {
- // SPEC: A type parameter is less specific than a non-type parameter.
-
- var isTypeParameter1 = t1 is ITypeParameterSymbol;
- var isTypeParameter2 = t2 is ITypeParameterSymbol;
-
- if (isTypeParameter1 && !isTypeParameter2)
- {
- return false;
- }
-
- if (!isTypeParameter1 && isTypeParameter2)
- {
- return true;
- }
-
- if (isTypeParameter1)
- {
- Debug.Assert(isTypeParameter2);
- return null;
- }
-
- if (t1.TypeKind != t2.TypeKind)
- {
- return null;
- }
-
- // There is an identity conversion between the types and they are both substitutions on type parameters.
- // They had better be the same kind.
-
- // UNDONE: Strip off the dynamics.
-
- // SPEC: An array type is more specific than another
- // SPEC: array type (with the same number of dimensions)
- // SPEC: if the element type of the first is
- // SPEC: more specific than the element type of the second.
-
- if (t1 is IArrayTypeSymbol)
- {
- var arr1 = (IArrayTypeSymbol)t1;
- var arr2 = (IArrayTypeSymbol)t2;
-
- // We should not have gotten here unless there were identity conversions
- // between the two types.
-
- return arr1.ElementType.IsMoreSpecificThan(arr2.ElementType);
- }
-
- // SPEC EXTENSION: We apply the same rule to pointer types.
-
- if (t1 is IPointerTypeSymbol)
- {
- var p1 = (IPointerTypeSymbol)t1;
- var p2 = (IPointerTypeSymbol)t2;
- return p1.PointedAtType.IsMoreSpecificThan(p2.PointedAtType);
- }
-
- // SPEC: A constructed type is more specific than another
- // SPEC: constructed type (with the same number of type arguments) if at least one type
- // SPEC: argument is more specific and no type argument is less specific than the
- // SPEC: corresponding type argument in the other.
-
- var n1 = t1 as INamedTypeSymbol;
- var n2 = t2 as INamedTypeSymbol;
-
- if (n1 == null)
- {
- return null;
- }
-
- // We should not have gotten here unless there were identity conversions between the
- // two types.
-
- var allTypeArgs1 = n1.GetAllTypeArguments().ToList();
- var allTypeArgs2 = n2.GetAllTypeArguments().ToList();
-
- return allTypeArgs1.AreMoreSpecificThan(allTypeArgs2);
- }
-
- public static bool IsOrDerivesFromExceptionType(this ITypeSymbol type, Compilation compilation)
- {
- if (type != null)
- {
- foreach (var baseType in type.GetBaseTypesAndThis())
- {
- if (baseType.Equals(compilation.ExceptionType()))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public static bool IsEnumType(this ITypeSymbol type)
- {
- return type.IsValueType && type.TypeKind == TypeKind.Enum;
- }
-
-
- public static async Task<ISymbol> FindApplicableAlias(this ITypeSymbol type, int position, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- if (semanticModel.IsSpeculativeSemanticModel)
- {
- position = semanticModel.OriginalPositionForSpeculation;
- semanticModel = semanticModel.ParentModel;
- }
-
- var root = await semanticModel.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
-
- IEnumerable<UsingDirectiveSyntax> applicableUsings = GetApplicableUsings(position, root as CompilationUnitSyntax);
- foreach (var applicableUsing in applicableUsings)
- {
- var alias = semanticModel.GetOriginalSemanticModel().GetDeclaredSymbol(applicableUsing, cancellationToken) as IAliasSymbol;
-
- if (alias != null && alias.Target == type)
- {
- return alias;
- }
- }
-
- return null;
- }
-
- private static IEnumerable<UsingDirectiveSyntax> GetApplicableUsings(int position, SyntaxNode root)
- {
- var namespaceUsings = root.FindToken(position).Parent.GetAncestors<NamespaceDeclarationSyntax>().SelectMany(n => n.Usings);
- var allUsings = root is CompilationUnitSyntax
- ? ((CompilationUnitSyntax)root).Usings.Concat(namespaceUsings)
- : namespaceUsings;
- return allUsings.Where(u => u.Alias != null);
- }
-
- public static ITypeSymbol RemoveNullableIfPresent(this ITypeSymbol symbol)
- {
- if (symbol.IsNullable())
- {
- return symbol.GetTypeArguments().Single();
- }
-
- return symbol;
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/ImmutableArrayExtensions.cs b/main/src/addins/CSharpBinding/Util/ImmutableArrayExtensions.cs
deleted file mode 100644
index 559c626422..0000000000
--- a/main/src/addins/CSharpBinding/Util/ImmutableArrayExtensions.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class ImmutableArrayExtensions
- {
- public static ImmutableArray<T> ToImmutableArrayOrEmpty<T>(this IEnumerable<T> items)
- {
- if (items == null)
- {
- return ImmutableArray.Create<T>();
- }
-
- return ImmutableArray.CreateRange<T>(items);
- }
-
- public static ImmutableArray<T> ToImmutableArrayOrEmpty<T>(this ImmutableArray<T> items)
- {
- if (items.IsDefault)
- {
- return ImmutableArray.Create<T>();
- }
-
- return items;
- }
-
- // same as Array.BinarySearch but the ability to pass arbitrary value to the comparer without allocation
- public static int BinarySearch<TElement, TValue>(this ImmutableArray<TElement> array, TValue value, Func<TElement, TValue, int> comparer)
- {
- int low = 0;
- int high = array.Length - 1;
-
- while (low <= high)
- {
- int middle = low + ((high - low) >> 1);
- int comparison = comparer(array[middle], value);
-
- if (comparison == 0)
- {
- return middle;
- }
-
- if (comparison > 0)
- {
- high = middle - 1;
- }
- else
- {
- low = middle + 1;
- }
- }
-
- return ~low;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/LinkedListExtension.cs b/main/src/addins/CSharpBinding/Util/LinkedListExtension.cs
deleted file mode 100644
index af02a85afb..0000000000
--- a/main/src/addins/CSharpBinding/Util/LinkedListExtension.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// LinkedListExtension.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class LinkedListExtensions
- {
- public static void AddRangeAtHead<T>(this LinkedList<T> list, IEnumerable<T> values)
- {
- var currentNode = default(LinkedListNode<T>);
- foreach (var value in values)
- {
- if (currentNode == null)
- {
- currentNode = list.AddFirst(value);
- }
- else
- {
- currentNode = list.AddAfter(currentNode, value);
- }
- }
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/Matcher.cs b/main/src/addins/CSharpBinding/Util/Matcher.cs
deleted file mode 100644
index 4a0c90db95..0000000000
--- a/main/src/addins/CSharpBinding/Util/Matcher.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.CodeAnalysis.Text;
-using System.Collections.Generic;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- abstract class Matcher<T>
- {
- // Tries to match this matcher against the provided sequence at the given index. If the
- // match succeeds, 'true' is returned, and 'index' points to the location after the match
- // ends. If the match fails, then false it returned and index remains the same. Note: the
- // matcher does not need to consume to the end of the sequence to succeed.
- public abstract bool TryMatch(IList<T> sequence, ref int index);
-
- internal static Matcher<T> Repeat(Matcher<T> matcher)
- {
- return new RepeatMatcher(matcher);
- }
-
- internal static Matcher<T> OneOrMore(Matcher<T> matcher)
- {
- // m+ is the same as (m m*)
- return Sequence(matcher, Repeat(matcher));
- }
-
- internal static Matcher<T> Choice(Matcher<T> matcher1, Matcher<T> matcher2)
- {
- return new ChoiceMatcher(matcher1, matcher2);
- }
-
- internal static Matcher<T> Sequence(params Matcher<T>[] matchers)
- {
- return new SequenceMatcher(matchers);
- }
-
- internal static Matcher<T> Single(Func<T, bool> predicate, string description)
- {
- return new SingleMatcher(predicate, description);
- }
- private class ChoiceMatcher : Matcher<T>
- {
- private readonly Matcher<T> _matcher1;
- private readonly Matcher<T> _matcher2;
-
- public ChoiceMatcher(Matcher<T> matcher1, Matcher<T> matcher2)
- {
- _matcher1 = matcher1;
- _matcher2 = matcher2;
- }
-
- public override bool TryMatch(IList<T> sequence, ref int index)
- {
- return
- _matcher1.TryMatch(sequence, ref index) ||
- _matcher2.TryMatch(sequence, ref index);
- }
-
- public override string ToString()
- {
- return string.Format("({0}|{1})", _matcher1, _matcher2);
- }
- }
- private class RepeatMatcher : Matcher<T>
- {
- private readonly Matcher<T> _matcher;
-
- public RepeatMatcher(Matcher<T> matcher)
- {
- _matcher = matcher;
- }
-
- public override bool TryMatch(IList<T> sequence, ref int index)
- {
- while (_matcher.TryMatch(sequence, ref index))
- {
- }
-
- return true;
- }
-
- public override string ToString()
- {
- return string.Format("({0}*)", _matcher);
- }
- }
- private class SequenceMatcher : Matcher<T>
- {
- private readonly Matcher<T>[] _matchers;
-
- public SequenceMatcher(params Matcher<T>[] matchers)
- {
- _matchers = matchers;
- }
-
- public override bool TryMatch(IList<T> sequence, ref int index)
- {
- var currentIndex = index;
- foreach (var matcher in _matchers)
- {
- if (!matcher.TryMatch(sequence, ref currentIndex))
- {
- return false;
- }
- }
-
- index = currentIndex;
- return true;
- }
-
- public override string ToString()
- {
- return string.Format("({0})", string.Join(",", (object[])_matchers));
- }
- }
- private class SingleMatcher : Matcher<T>
- {
- private readonly Func<T, bool> _predicate;
- private readonly string _description;
-
- public SingleMatcher(Func<T, bool> predicate, string description)
- {
- _predicate = predicate;
- _description = description;
- }
-
- public override bool TryMatch(IList<T> sequence, ref int index)
- {
- if (index < sequence.Count && _predicate(sequence[index]))
- {
- index++;
- return true;
- }
-
- return false;
- }
-
- public override string ToString()
- {
- return _description;
- }
- }
- }
-
- class Matcher
- {
- /// <summary>
- /// Matcher equivalent to (m*)
- /// </summary>
- public static Matcher<T> Repeat<T>(Matcher<T> matcher)
- {
- return Matcher<T>.Repeat(matcher);
- }
-
- /// <summary>
- /// Matcher equivalent to (m+)
- /// </summary>
- public static Matcher<T> OneOrMore<T>(Matcher<T> matcher)
- {
- return Matcher<T>.OneOrMore(matcher);
- }
-
- /// <summary>
- /// Matcher equivalent to (m_1|m_2)
- /// </summary>
- public static Matcher<T> Choice<T>(Matcher<T> matcher1, Matcher<T> matcher2)
- {
- return Matcher<T>.Choice(matcher1, matcher2);
- }
-
- /// <summary>
- /// Matcher equivalent to (m_1 ... m_n)
- /// </summary>
- public static Matcher<T> Sequence<T>(params Matcher<T>[] matchers)
- {
- return Matcher<T>.Sequence(matchers);
- }
-
- /// <summary>
- /// Matcher that matches an element if the provide predicate returns true.
- /// </summary>
- public static Matcher<T> Single<T>(Func<T, bool> predicate, string description)
- {
- return Matcher<T>.Single(predicate, description);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/MemberDeclarationSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/MemberDeclarationSyntaxExtensions.cs
deleted file mode 100644
index 2b48ad393b..0000000000
--- a/main/src/addins/CSharpBinding/Util/MemberDeclarationSyntaxExtensions.cs
+++ /dev/null
@@ -1,341 +0,0 @@
-using System.Linq;
-using System.Runtime.CompilerServices;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static partial class MemberDeclarationSyntaxExtensions
- {
-// private static readonly ConditionalWeakTable<MemberDeclarationSyntax, Dictionary<string, ImmutableArray<SyntaxToken>>> s_declarationCache =
-// new ConditionalWeakTable<MemberDeclarationSyntax, Dictionary<string, ImmutableArray<SyntaxToken>>>();
-// private static readonly ConditionalWeakTable<MemberDeclarationSyntax, Dictionary<string, ImmutableArray<SyntaxToken>>>.CreateValueCallback s_createLocalDeclarationMap = CreateLocalDeclarationMap;
-//
-// public static Microsoft.CodeAnalysis.CSharp.Extensions.MemberDeclarationSyntaxExtensions.LocalDeclarationMap GetLocalDeclarationMap(this MemberDeclarationSyntax member)
-// {
-// var result = s_declarationCache.GetValue(member, s_createLocalDeclarationMap);
-// return new Microsoft.CodeAnalysis.CSharp.Extensions.MemberDeclarationSyntaxExtensions.LocalDeclarationMap(result);
-// }
-
-// private static Dictionary<string, ImmutableArray<SyntaxToken>> CreateLocalDeclarationMap(MemberDeclarationSyntax member)
-// {
-// var dictionary = DeclarationFinder.GetAllDeclarations(member);
-// return dictionary.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.AsImmutable<SyntaxToken>());
-// }
-
- public static SyntaxList<AttributeListSyntax> GetAttributes(this MemberDeclarationSyntax member)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.EnumDeclaration:
- return ((EnumDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.EnumMemberDeclaration:
- return ((EnumMemberDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.ClassDeclaration:
- case SyntaxKind.InterfaceDeclaration:
- case SyntaxKind.StructDeclaration:
- return ((TypeDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.FieldDeclaration:
- return ((FieldDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.EventFieldDeclaration:
- return ((EventFieldDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.ConstructorDeclaration:
- return ((ConstructorDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.DestructorDeclaration:
- return ((DestructorDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.PropertyDeclaration:
- return ((PropertyDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.EventDeclaration:
- return ((EventDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.IndexerDeclaration:
- return ((IndexerDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.OperatorDeclaration:
- return ((OperatorDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.ConversionOperatorDeclaration:
- return ((ConversionOperatorDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).AttributeLists;
- case SyntaxKind.IncompleteMember:
- return ((IncompleteMemberSyntax)member).AttributeLists;
- }
- }
-
- return SyntaxFactory.List<AttributeListSyntax>();
- }
-
- public static SyntaxToken GetNameToken(this MemberDeclarationSyntax member)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.EnumDeclaration:
- return ((EnumDeclarationSyntax)member).Identifier;
- case SyntaxKind.ClassDeclaration:
- case SyntaxKind.InterfaceDeclaration:
- case SyntaxKind.StructDeclaration:
- return ((TypeDeclarationSyntax)member).Identifier;
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).Identifier;
- case SyntaxKind.FieldDeclaration:
- return ((FieldDeclarationSyntax)member).Declaration.Variables.First().Identifier;
- case SyntaxKind.EventFieldDeclaration:
- return ((EventFieldDeclarationSyntax)member).Declaration.Variables.First().Identifier;
- case SyntaxKind.PropertyDeclaration:
- return ((PropertyDeclarationSyntax)member).Identifier;
- case SyntaxKind.EventDeclaration:
- return ((EventDeclarationSyntax)member).Identifier;
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).Identifier;
- }
- }
-
- // Constructors, destructors, indexers and operators don't have names.
- return default(SyntaxToken);
- }
-
- public static int GetArity(this MemberDeclarationSyntax member)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- case SyntaxKind.InterfaceDeclaration:
- case SyntaxKind.StructDeclaration:
- return ((TypeDeclarationSyntax)member).Arity;
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).Arity;
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).Arity;
- }
- }
-
- return 0;
- }
-
- public static TypeParameterListSyntax GetTypeParameterList(this MemberDeclarationSyntax member)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- case SyntaxKind.InterfaceDeclaration:
- case SyntaxKind.StructDeclaration:
- return ((TypeDeclarationSyntax)member).TypeParameterList;
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).TypeParameterList;
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).TypeParameterList;
- }
- }
-
- return null;
- }
-
- public static BaseParameterListSyntax GetParameterList(this MemberDeclarationSyntax member)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).ParameterList;
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).ParameterList;
- case SyntaxKind.ConstructorDeclaration:
- return ((ConstructorDeclarationSyntax)member).ParameterList;
- case SyntaxKind.IndexerDeclaration:
- return ((IndexerDeclarationSyntax)member).ParameterList;
- case SyntaxKind.OperatorDeclaration:
- return ((OperatorDeclarationSyntax)member).ParameterList;
- case SyntaxKind.ConversionOperatorDeclaration:
- return ((ConversionOperatorDeclarationSyntax)member).ParameterList;
- }
- }
-
- return null;
- }
-
- public static MemberDeclarationSyntax WithParameterList(
- this MemberDeclarationSyntax member,
- BaseParameterListSyntax parameterList)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).WithParameterList((ParameterListSyntax)parameterList);
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).WithParameterList((ParameterListSyntax)parameterList);
- case SyntaxKind.ConstructorDeclaration:
- return ((ConstructorDeclarationSyntax)member).WithParameterList((ParameterListSyntax)parameterList);
- case SyntaxKind.IndexerDeclaration:
- return ((IndexerDeclarationSyntax)member).WithParameterList((BracketedParameterListSyntax)parameterList);
- case SyntaxKind.OperatorDeclaration:
- return ((OperatorDeclarationSyntax)member).WithParameterList((ParameterListSyntax)parameterList);
- case SyntaxKind.ConversionOperatorDeclaration:
- return ((ConversionOperatorDeclarationSyntax)member).WithParameterList((ParameterListSyntax)parameterList);
- }
- }
-
- return null;
- }
-
- public static MemberDeclarationSyntax AddAttributeLists(
- this MemberDeclarationSyntax member,
- params AttributeListSyntax[] attributeLists)
- {
- return member.WithAttributeLists(member.GetAttributes().AddRange(attributeLists));
- }
-
- public static MemberDeclarationSyntax WithAttributeLists(
- this MemberDeclarationSyntax member,
- SyntaxList<AttributeListSyntax> attributeLists)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.EnumDeclaration:
- return ((EnumDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.EnumMemberDeclaration:
- return ((EnumMemberDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.ClassDeclaration:
- case SyntaxKind.InterfaceDeclaration:
- case SyntaxKind.StructDeclaration:
- return ((TypeDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.FieldDeclaration:
- return ((FieldDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.EventFieldDeclaration:
- return ((EventFieldDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.ConstructorDeclaration:
- return ((ConstructorDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.DestructorDeclaration:
- return ((DestructorDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.PropertyDeclaration:
- return ((PropertyDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.EventDeclaration:
- return ((EventDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.IndexerDeclaration:
- return ((IndexerDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.OperatorDeclaration:
- return ((OperatorDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.ConversionOperatorDeclaration:
- return ((ConversionOperatorDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).WithAttributeLists(attributeLists);
- case SyntaxKind.IncompleteMember:
- return ((IncompleteMemberSyntax)member).WithAttributeLists(attributeLists);
- }
- }
-
- return null;
- }
-
- public static TypeSyntax GetMemberType(this MemberDeclarationSyntax member)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).ReturnType;
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).ReturnType;
- case SyntaxKind.OperatorDeclaration:
- return ((OperatorDeclarationSyntax)member).ReturnType;
- case SyntaxKind.PropertyDeclaration:
- return ((PropertyDeclarationSyntax)member).Type;
- case SyntaxKind.IndexerDeclaration:
- return ((IndexerDeclarationSyntax)member).Type;
- case SyntaxKind.EventDeclaration:
- return ((EventDeclarationSyntax)member).Type;
- case SyntaxKind.EventFieldDeclaration:
- return ((EventFieldDeclarationSyntax)member).Declaration.Type;
- case SyntaxKind.FieldDeclaration:
- return ((FieldDeclarationSyntax)member).Declaration.Type;
- }
- }
-
- return null;
- }
-
- public static bool HasMethodShape(this MemberDeclarationSyntax memberDeclaration)
- {
- if (memberDeclaration != null)
- {
- switch (memberDeclaration.Kind())
- {
- case SyntaxKind.MethodDeclaration:
- case SyntaxKind.OperatorDeclaration:
- case SyntaxKind.ConversionOperatorDeclaration:
- case SyntaxKind.ConstructorDeclaration:
- case SyntaxKind.DestructorDeclaration:
- return true;
- }
- }
-
- return false;
- }
-
- public static BlockSyntax GetBody(this MemberDeclarationSyntax memberDeclaration)
- {
- if (memberDeclaration != null)
- {
- switch (memberDeclaration.Kind())
- {
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)memberDeclaration).Body;
- case SyntaxKind.OperatorDeclaration:
- return ((OperatorDeclarationSyntax)memberDeclaration).Body;
- case SyntaxKind.ConversionOperatorDeclaration:
- return ((ConversionOperatorDeclarationSyntax)memberDeclaration).Body;
- case SyntaxKind.ConstructorDeclaration:
- return ((ConstructorDeclarationSyntax)memberDeclaration).Body;
- case SyntaxKind.DestructorDeclaration:
- return ((DestructorDeclarationSyntax)memberDeclaration).Body;
- }
- }
-
- return null;
- }
-
- public static MemberDeclarationSyntax WithBody(
- this MemberDeclarationSyntax memberDeclaration,
- BlockSyntax body)
- {
- if (memberDeclaration != null)
- {
- switch (memberDeclaration.Kind())
- {
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)memberDeclaration).WithBody(body);
- case SyntaxKind.OperatorDeclaration:
- return ((OperatorDeclarationSyntax)memberDeclaration).WithBody(body);
- case SyntaxKind.ConversionOperatorDeclaration:
- return ((ConversionOperatorDeclarationSyntax)memberDeclaration).WithBody(body);
- case SyntaxKind.ConstructorDeclaration:
- return ((ConstructorDeclarationSyntax)memberDeclaration).WithBody(body);
- case SyntaxKind.DestructorDeclaration:
- return ((DestructorDeclarationSyntax)memberDeclaration).WithBody(body);
- }
- }
-
- return null;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/NameGenerator.cs b/main/src/addins/CSharpBinding/Util/NameGenerator.cs
deleted file mode 100644
index 60331fd7f2..0000000000
--- a/main/src/addins/CSharpBinding/Util/NameGenerator.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis.Text;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class NameGenerator
- {
- public static IList<string> EnsureUniqueness(
- IList<string> names,
- Func<string, bool> canUse = null)
- {
- return EnsureUniqueness(names, names.Select(_ => false).ToList(), canUse);
- }
-
- /// <summary>
- /// Ensures that any 'names' is unique and does not collide with any other name. Names that
- /// are marked as IsFixed can not be touched. This does mean that if there are two names
- /// that are the same, and both are fixed that you will end up with non-unique names at the
- /// end.
- /// </summary>
- public static IList<string> EnsureUniqueness(
- IList<string> names,
- IList<bool> isFixed,
- Func<string, bool> canUse = null,
- bool isCaseSensitive = true)
- {
- var copy = names.ToList();
- EnsureUniquenessInPlace(copy, isFixed, canUse, isCaseSensitive);
- return copy;
- }
-
- public static IList<string> EnsureUniqueness(IList<string> names, bool isCaseSensitive)
- {
- return EnsureUniqueness(names, names.Select(_ => false).ToList(), isCaseSensitive: isCaseSensitive);
- }
-
- /// <summary>
- /// Transforms baseName into a name that does not conflict with any name in 'reservedNames'
- /// </summary>
- public static string EnsureUniqueness(
- string baseName,
- IEnumerable<string> reservedNames,
- bool isCaseSensitive = true)
- {
- var names = new List<string> { baseName };
- var isFixed = new List<bool> { false };
-
- names.AddRange(reservedNames.Distinct());
- isFixed.AddRange(Enumerable.Repeat(true, names.Count - 1));
-
- var result = EnsureUniqueness(names, isFixed, isCaseSensitive: isCaseSensitive);
- return result.First();
- }
-
- private static void EnsureUniquenessInPlace(
- IList<string> names,
- IList<bool> isFixed,
- Func<string, bool> canUse,
- bool isCaseSensitive = true)
- {
- canUse = canUse ?? (s => true);
-
- // Don't enumerate as we will be modifying the collection in place.
- for (var i = 0; i < names.Count; i++)
- {
- var name = names[i];
- var collisionIndices = GetCollisionIndices(names, name, isCaseSensitive);
-
- if (canUse(name) && collisionIndices.Count < 2)
- {
- // no problems with this parameter name, move onto the next one.
- continue;
- }
-
- HandleCollisions(isFixed, names, name, collisionIndices, canUse, isCaseSensitive);
- }
- }
-
- private static void HandleCollisions(
- IList<bool> isFixed,
- IList<string> names,
- string name,
- List<int> collisionIndices,
- Func<string, bool> canUse,
- bool isCaseSensitive = true)
- {
- var suffix = 1;
- var comparer = isCaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
- for (var i = 0; i < collisionIndices.Count; i++)
- {
- var collisionIndex = collisionIndices[i];
- if (isFixed[collisionIndex])
- {
- // can't do anything about this name.
- continue;
- }
-
- while (true)
- {
- var newName = name + suffix++;
- if (!names.Contains(newName, comparer) && canUse(newName))
- {
- // Found a name that doesn't conflict with anything else.
- names[collisionIndex] = newName;
- break;
- }
- }
- }
- }
-
- private static List<int> GetCollisionIndices(
- IList<string> names,
- string name,
- bool isCaseSensitive = true)
- {
- var comparer = isCaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
- var collisionIndices =
- names.Select((currentName, index) => new { currentName, index })
- .Where(t => comparer.Equals(t.currentName, name))
- .Select(t => t.index)
- .ToList();
- return collisionIndices;
- }
-
- public static string GenerateUniqueName(string baseName, Func<string, bool> canUse)
- {
- return GenerateUniqueName(baseName, string.Empty, canUse);
- }
-
- public static string GenerateUniqueName(string baseName, ISet<string> names, StringComparer comparer)
- {
- return GenerateUniqueName(baseName, x => !names.Contains(x, comparer));
- }
-
- public static string GenerateUniqueName(string baseName, string extension, Func<string, bool> canUse)
- {
- if (!string.IsNullOrEmpty(extension) && !extension.StartsWith("."))
- {
- extension = "." + extension;
- }
-
- var name = baseName + extension;
- var index = 1;
-
- // Check for collisions
- while (!canUse(name))
- {
- name = baseName + index + extension;
- index++;
- }
-
- return name;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/NameSyntaxComparer.cs b/main/src/addins/CSharpBinding/Util/NameSyntaxComparer.cs
deleted file mode 100644
index 9808e524a5..0000000000
--- a/main/src/addins/CSharpBinding/Util/NameSyntaxComparer.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal class NameSyntaxComparer : IComparer<NameSyntax>
- {
- private readonly IComparer<SyntaxToken> _tokenComparer;
- internal TypeSyntaxComparer TypeComparer;
-
- internal NameSyntaxComparer(IComparer<SyntaxToken> tokenComparer)
- {
- _tokenComparer = tokenComparer;
- }
-
- public static IComparer<NameSyntax> Create()
- {
- return Create(TokenComparer.NormalInstance);
- }
-
- public static IComparer<NameSyntax> Create(IComparer<SyntaxToken> tokenComparer)
- {
- var nameComparer = new NameSyntaxComparer(tokenComparer);
- var typeComparer = new TypeSyntaxComparer(tokenComparer);
-
- nameComparer.TypeComparer = typeComparer;
- typeComparer.NameComparer = nameComparer;
-
- return nameComparer;
- }
-
- public int Compare(NameSyntax x, NameSyntax y)
- {
- if (x == y)
- {
- return 0;
- }
-
- if (x.IsMissing && y.IsMissing)
- {
- return 0;
- }
-
- if (x.IsMissing)
- {
- return -1;
- }
- else if (y.IsMissing)
- {
- return 1;
- }
-
- // If we have a basic name, then it's simple to compare. Just
- // check that token versus whatever the other name has as the
- // first token.
- if (x is IdentifierNameSyntax && y is IdentifierNameSyntax)
- {
- return _tokenComparer.Compare(x.GetFirstToken(includeSkipped: true), y.GetFirstToken());
- }
- else if (x is GenericNameSyntax && y is GenericNameSyntax)
- {
- // if both names are generic, then use a specialized routine
- // that will check the names *and* the arguments.
- return Compare((GenericNameSyntax)x, (GenericNameSyntax)y);
- }
- else if (x is IdentifierNameSyntax && y is GenericNameSyntax)
- {
- int compare = _tokenComparer.Compare(x.GetFirstToken(includeSkipped: true), y.GetFirstToken());
- if (compare != 0)
- {
- return compare;
- }
-
- // Foo goes before Foo<T>
- return -1;
- }
- else if (x is GenericNameSyntax && y is IdentifierNameSyntax)
- {
- int compare = _tokenComparer.Compare(x.GetFirstToken(includeSkipped: true), y.GetFirstToken());
- if (compare != 0)
- {
- return compare;
- }
-
- // Foo<T> goes after Foo
- return 1;
- }
-
- // At this point one or both of the nodes is a dotted name or
- // aliased name. Break them apart into individual pieces and
- // compare those.
-
- var xNameParts = DecomposeNameParts(x);
- var yNameParts = DecomposeNameParts(y);
-
- for (int i = 0; i < xNameParts.Count && i < yNameParts.Count; i++)
- {
- int compare = Compare(xNameParts[i], yNameParts[i]);
- if (compare != 0)
- {
- return compare;
- }
- }
-
- // they matched up to this point. The shorter one should come
- // first.
- return xNameParts.Count - yNameParts.Count;
- }
-
- private IList<SimpleNameSyntax> DecomposeNameParts(NameSyntax name)
- {
- var result = new List<SimpleNameSyntax>();
- DecomposeNameParts(name, result);
- return result;
- }
-
- private void DecomposeNameParts(NameSyntax name, List<SimpleNameSyntax> result)
- {
- switch (name.Kind())
- {
- case SyntaxKind.QualifiedName:
- var dottedName = (QualifiedNameSyntax)name;
- DecomposeNameParts(dottedName.Left, result);
- DecomposeNameParts(dottedName.Right, result);
- break;
- case SyntaxKind.AliasQualifiedName:
- var aliasedName = (AliasQualifiedNameSyntax)name;
- result.Add(aliasedName.Alias);
- DecomposeNameParts(aliasedName.Name, result);
- break;
- case SyntaxKind.IdentifierName:
- result.Add((IdentifierNameSyntax)name);
- break;
- case SyntaxKind.GenericName:
- result.Add((GenericNameSyntax)name);
- break;
- }
- }
-
- private int Compare(GenericNameSyntax x, GenericNameSyntax y)
- {
- int compare = _tokenComparer.Compare(x.Identifier, y.Identifier);
- if (compare != 0)
- {
- return compare;
- }
-
- // The one with less type params comes first.
- compare = x.Arity - y.Arity;
- if (compare != 0)
- {
- return compare;
- }
-
- // Same name, same parameter count. Compare each parameter.
- for (int i = 0; i < x.Arity; i++)
- {
- var xArg = x.TypeArgumentList.Arguments[i];
- var yArg = y.TypeArgumentList.Arguments[i];
-
- compare = TypeComparer.Compare(xArg, yArg);
- if (compare != 0)
- {
- return compare;
- }
- }
-
- return 0;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/NameSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/NameSyntaxExtensions.cs
deleted file mode 100644
index d16dc2a152..0000000000
--- a/main/src/addins/CSharpBinding/Util/NameSyntaxExtensions.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class NameSyntaxExtensions
- {
- public static IList<NameSyntax> GetNameParts(this NameSyntax nameSyntax)
- {
- return new NameSyntaxIterator(nameSyntax).ToList();
- }
-
- public static NameSyntax GetLastDottedName(this NameSyntax nameSyntax)
- {
- var parts = nameSyntax.GetNameParts();
- return parts[parts.Count - 1];
- }
-
- public static SyntaxToken GetNameToken(this NameSyntax nameSyntax)
- {
- while (true)
- {
- if (nameSyntax.Kind() == SyntaxKind.IdentifierName)
- {
- return ((IdentifierNameSyntax)nameSyntax).Identifier;
- }
- else if (nameSyntax.Kind() == SyntaxKind.QualifiedName)
- {
- nameSyntax = ((QualifiedNameSyntax)nameSyntax).Right;
- }
- else if (nameSyntax.Kind() == SyntaxKind.GenericName)
- {
- return ((GenericNameSyntax)nameSyntax).Identifier;
- }
- else if (nameSyntax.Kind() == SyntaxKind.AliasQualifiedName)
- {
- nameSyntax = ((AliasQualifiedNameSyntax)nameSyntax).Name;
- }
- else
- {
- throw new NotSupportedException();
- }
- }
- }
-
- public static bool CanBeReplacedWithAnyName(this NameSyntax nameSyntax)
- {
- if (nameSyntax.IsParentKind(SyntaxKind.AliasQualifiedName) ||
- nameSyntax.IsParentKind(SyntaxKind.NameColon) ||
- nameSyntax.IsParentKind(SyntaxKind.NameEquals) ||
- nameSyntax.IsParentKind(SyntaxKind.TypeParameterConstraintClause))
- {
- return false;
- }
-
- if (nameSyntax.CheckParent<QualifiedNameSyntax>(q => q.Right == nameSyntax) ||
- nameSyntax.CheckParent<MemberAccessExpressionSyntax>(m => m.Name == nameSyntax))
- {
- return false;
- }
-
- // TODO(cyrusn): Add more cases as the language changes.
- return true;
- }
- }
-
- internal class NameSyntaxIterator : IEnumerable<NameSyntax>
- {
- private readonly NameSyntax _name;
-
- public NameSyntaxIterator(NameSyntax name)
- {
- if (name == null)
- {
- throw new ArgumentNullException(@"name");
- }
-
- _name = name;
- }
-
- public LinkedList<NameSyntax>.Enumerator GetEnumerator ()
- {
- var nodes = new LinkedList<NameSyntax> ();
-
- var currentNode = _name;
- while (true) {
- if (currentNode.Kind () == SyntaxKind.QualifiedName) {
- var qualifiedName = currentNode as QualifiedNameSyntax;
- nodes.AddFirst (qualifiedName.Right);
- currentNode = qualifiedName.Left;
- } else {
- nodes.AddFirst (currentNode);
- break;
- }
- }
-
- return nodes.GetEnumerator ();
- }
-
- IEnumerator<NameSyntax> IEnumerable<NameSyntax>.GetEnumerator()
- {
- return GetEnumerator ();
- }
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/NamespaceDeclarationSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/NamespaceDeclarationSyntaxExtensions.cs
deleted file mode 100644
index de5cf065f5..0000000000
--- a/main/src/addins/CSharpBinding/Util/NamespaceDeclarationSyntaxExtensions.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class NamespaceDeclarationSyntaxExtensions
- {
- public static NamespaceDeclarationSyntax AddUsingDirectives(
- this NamespaceDeclarationSyntax namespaceDeclaration,
- IList<UsingDirectiveSyntax> usingDirectives,
- bool placeSystemNamespaceFirst,
- params SyntaxAnnotation[] annotations)
- {
- if (!usingDirectives.Any())
- {
- return namespaceDeclaration;
- }
-
- var specialCaseSystem = placeSystemNamespaceFirst;
- var comparer = specialCaseSystem
- ? UsingsAndExternAliasesDirectiveComparer.SystemFirstInstance
- : UsingsAndExternAliasesDirectiveComparer.NormalInstance;
-
- var usings = new List<UsingDirectiveSyntax>();
- usings.AddRange(namespaceDeclaration.Usings);
- usings.AddRange(usingDirectives);
-
- if (namespaceDeclaration.Usings.IsSorted(comparer))
- {
- usings.Sort(comparer);
- }
-
- usings = usings.Select(u => u.WithAdditionalAnnotations(annotations)).ToList();
- var newNamespace = namespaceDeclaration.WithUsings(usings.ToSyntaxList());
-
- return newNamespace;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/ObjectExtensions.cs b/main/src/addins/CSharpBinding/Util/ObjectExtensions.cs
deleted file mode 100644
index cf055ed025..0000000000
--- a/main/src/addins/CSharpBinding/Util/ObjectExtensions.cs
+++ /dev/null
@@ -1,7667 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-
-namespace ICSharpCode.NRefactory6
-{
- static partial class ObjectExtensions
- {
-
-
- #region TypeSwitch on Action
-
- public static void TypeSwitch<TBaseType, TDerivedType1>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TBaseType> defaultAction = null) where TDerivedType1 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TDerivedType25> matchAction25, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- matchAction25((TDerivedType25)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TDerivedType25> matchAction25, Action<TDerivedType26> matchAction26, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- matchAction25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- matchAction26((TDerivedType26)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TDerivedType25> matchAction25, Action<TDerivedType26> matchAction26, Action<TDerivedType27> matchAction27, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- matchAction25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- matchAction26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- matchAction27((TDerivedType27)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TDerivedType25> matchAction25, Action<TDerivedType26> matchAction26, Action<TDerivedType27> matchAction27, Action<TDerivedType28> matchAction28, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- matchAction25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- matchAction26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- matchAction27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- matchAction28((TDerivedType28)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TDerivedType25> matchAction25, Action<TDerivedType26> matchAction26, Action<TDerivedType27> matchAction27, Action<TDerivedType28> matchAction28, Action<TDerivedType29> matchAction29, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- matchAction25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- matchAction26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- matchAction27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- matchAction28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- matchAction29((TDerivedType29)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TDerivedType25> matchAction25, Action<TDerivedType26> matchAction26, Action<TDerivedType27> matchAction27, Action<TDerivedType28> matchAction28, Action<TDerivedType29> matchAction29, Action<TDerivedType30> matchAction30, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- matchAction25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- matchAction26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- matchAction27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- matchAction28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- matchAction29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- matchAction30((TDerivedType30)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TDerivedType25> matchAction25, Action<TDerivedType26> matchAction26, Action<TDerivedType27> matchAction27, Action<TDerivedType28> matchAction28, Action<TDerivedType29> matchAction29, Action<TDerivedType30> matchAction30, Action<TDerivedType31> matchAction31, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- matchAction25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- matchAction26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- matchAction27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- matchAction28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- matchAction29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- matchAction30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- matchAction31((TDerivedType31)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TDerivedType25> matchAction25, Action<TDerivedType26> matchAction26, Action<TDerivedType27> matchAction27, Action<TDerivedType28> matchAction28, Action<TDerivedType29> matchAction29, Action<TDerivedType30> matchAction30, Action<TDerivedType31> matchAction31, Action<TDerivedType32> matchAction32, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- matchAction25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- matchAction26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- matchAction27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- matchAction28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- matchAction29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- matchAction30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- matchAction31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- matchAction32((TDerivedType32)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TDerivedType33>(this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TDerivedType5> matchAction5, Action<TDerivedType6> matchAction6, Action<TDerivedType7> matchAction7, Action<TDerivedType8> matchAction8, Action<TDerivedType9> matchAction9, Action<TDerivedType10> matchAction10, Action<TDerivedType11> matchAction11, Action<TDerivedType12> matchAction12, Action<TDerivedType13> matchAction13, Action<TDerivedType14> matchAction14, Action<TDerivedType15> matchAction15, Action<TDerivedType16> matchAction16, Action<TDerivedType17> matchAction17, Action<TDerivedType18> matchAction18, Action<TDerivedType19> matchAction19, Action<TDerivedType20> matchAction20, Action<TDerivedType21> matchAction21, Action<TDerivedType22> matchAction22, Action<TDerivedType23> matchAction23, Action<TDerivedType24> matchAction24, Action<TDerivedType25> matchAction25, Action<TDerivedType26> matchAction26, Action<TDerivedType27> matchAction27, Action<TDerivedType28> matchAction28, Action<TDerivedType29> matchAction29, Action<TDerivedType30> matchAction30, Action<TDerivedType31> matchAction31, Action<TDerivedType32> matchAction32, Action<TDerivedType33> matchAction33, Action<TBaseType> defaultAction = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- where TDerivedType33 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- matchAction1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- matchAction2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- matchAction3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- matchAction4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- matchAction5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- matchAction6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- matchAction7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- matchAction8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- matchAction9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- matchAction10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- matchAction11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- matchAction12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- matchAction13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- matchAction14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- matchAction15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- matchAction16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- matchAction17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- matchAction18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- matchAction19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- matchAction20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- matchAction21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- matchAction22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- matchAction23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- matchAction24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- matchAction25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- matchAction26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- matchAction27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- matchAction28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- matchAction29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- matchAction30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- matchAction31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- matchAction32((TDerivedType32)obj);
- }
- else if (obj is TDerivedType33)
- {
- matchAction33((TDerivedType33)obj);
- }
- else if (defaultAction != null)
- {
- defaultAction(obj);
- }
- }
-
- #endregion
-
- #region TypeSwitch on Func<T>
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TBaseType, TResult> defaultFunc = null) where TDerivedType1 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TDerivedType32, TResult> matchFunc32, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- return matchFunc32((TDerivedType32)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TDerivedType33, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TDerivedType32, TResult> matchFunc32, Func<TDerivedType33, TResult> matchFunc33, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- where TDerivedType33 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- return matchFunc32((TDerivedType32)obj);
- }
- else if (obj is TDerivedType33)
- {
- return matchFunc33((TDerivedType33)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TDerivedType33, TDerivedType34, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TDerivedType32, TResult> matchFunc32, Func<TDerivedType33, TResult> matchFunc33, Func<TDerivedType34, TResult> matchFunc34, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- where TDerivedType33 : TBaseType
- where TDerivedType34 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- return matchFunc32((TDerivedType32)obj);
- }
- else if (obj is TDerivedType33)
- {
- return matchFunc33((TDerivedType33)obj);
- }
- else if (obj is TDerivedType34)
- {
- return matchFunc34((TDerivedType34)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TDerivedType33, TDerivedType34, TDerivedType35, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TDerivedType32, TResult> matchFunc32, Func<TDerivedType33, TResult> matchFunc33, Func<TDerivedType34, TResult> matchFunc34, Func<TDerivedType35, TResult> matchFunc35, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- where TDerivedType33 : TBaseType
- where TDerivedType34 : TBaseType
- where TDerivedType35 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- return matchFunc32((TDerivedType32)obj);
- }
- else if (obj is TDerivedType33)
- {
- return matchFunc33((TDerivedType33)obj);
- }
- else if (obj is TDerivedType34)
- {
- return matchFunc34((TDerivedType34)obj);
- }
- else if (obj is TDerivedType35)
- {
- return matchFunc35((TDerivedType35)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TDerivedType33, TDerivedType34, TDerivedType35, TDerivedType36, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TDerivedType32, TResult> matchFunc32, Func<TDerivedType33, TResult> matchFunc33, Func<TDerivedType34, TResult> matchFunc34, Func<TDerivedType35, TResult> matchFunc35, Func<TDerivedType36, TResult> matchFunc36, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- where TDerivedType33 : TBaseType
- where TDerivedType34 : TBaseType
- where TDerivedType35 : TBaseType
- where TDerivedType36 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- return matchFunc32((TDerivedType32)obj);
- }
- else if (obj is TDerivedType33)
- {
- return matchFunc33((TDerivedType33)obj);
- }
- else if (obj is TDerivedType34)
- {
- return matchFunc34((TDerivedType34)obj);
- }
- else if (obj is TDerivedType35)
- {
- return matchFunc35((TDerivedType35)obj);
- }
- else if (obj is TDerivedType36)
- {
- return matchFunc36((TDerivedType36)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TDerivedType33, TDerivedType34, TDerivedType35, TDerivedType36, TDerivedType37, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TDerivedType32, TResult> matchFunc32, Func<TDerivedType33, TResult> matchFunc33, Func<TDerivedType34, TResult> matchFunc34, Func<TDerivedType35, TResult> matchFunc35, Func<TDerivedType36, TResult> matchFunc36, Func<TDerivedType37, TResult> matchFunc37, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- where TDerivedType33 : TBaseType
- where TDerivedType34 : TBaseType
- where TDerivedType35 : TBaseType
- where TDerivedType36 : TBaseType
- where TDerivedType37 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- return matchFunc32((TDerivedType32)obj);
- }
- else if (obj is TDerivedType33)
- {
- return matchFunc33((TDerivedType33)obj);
- }
- else if (obj is TDerivedType34)
- {
- return matchFunc34((TDerivedType34)obj);
- }
- else if (obj is TDerivedType35)
- {
- return matchFunc35((TDerivedType35)obj);
- }
- else if (obj is TDerivedType36)
- {
- return matchFunc36((TDerivedType36)obj);
- }
- else if (obj is TDerivedType37)
- {
- return matchFunc37((TDerivedType37)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TDerivedType33, TDerivedType34, TDerivedType35, TDerivedType36, TDerivedType37, TDerivedType38, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TDerivedType32, TResult> matchFunc32, Func<TDerivedType33, TResult> matchFunc33, Func<TDerivedType34, TResult> matchFunc34, Func<TDerivedType35, TResult> matchFunc35, Func<TDerivedType36, TResult> matchFunc36, Func<TDerivedType37, TResult> matchFunc37, Func<TDerivedType38, TResult> matchFunc38, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- where TDerivedType33 : TBaseType
- where TDerivedType34 : TBaseType
- where TDerivedType35 : TBaseType
- where TDerivedType36 : TBaseType
- where TDerivedType37 : TBaseType
- where TDerivedType38 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- return matchFunc32((TDerivedType32)obj);
- }
- else if (obj is TDerivedType33)
- {
- return matchFunc33((TDerivedType33)obj);
- }
- else if (obj is TDerivedType34)
- {
- return matchFunc34((TDerivedType34)obj);
- }
- else if (obj is TDerivedType35)
- {
- return matchFunc35((TDerivedType35)obj);
- }
- else if (obj is TDerivedType36)
- {
- return matchFunc36((TDerivedType36)obj);
- }
- else if (obj is TDerivedType37)
- {
- return matchFunc37((TDerivedType37)obj);
- }
- else if (obj is TDerivedType38)
- {
- return matchFunc38((TDerivedType38)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TDerivedType33, TDerivedType34, TDerivedType35, TDerivedType36, TDerivedType37, TDerivedType38, TDerivedType39, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TDerivedType32, TResult> matchFunc32, Func<TDerivedType33, TResult> matchFunc33, Func<TDerivedType34, TResult> matchFunc34, Func<TDerivedType35, TResult> matchFunc35, Func<TDerivedType36, TResult> matchFunc36, Func<TDerivedType37, TResult> matchFunc37, Func<TDerivedType38, TResult> matchFunc38, Func<TDerivedType39, TResult> matchFunc39, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- where TDerivedType33 : TBaseType
- where TDerivedType34 : TBaseType
- where TDerivedType35 : TBaseType
- where TDerivedType36 : TBaseType
- where TDerivedType37 : TBaseType
- where TDerivedType38 : TBaseType
- where TDerivedType39 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- return matchFunc32((TDerivedType32)obj);
- }
- else if (obj is TDerivedType33)
- {
- return matchFunc33((TDerivedType33)obj);
- }
- else if (obj is TDerivedType34)
- {
- return matchFunc34((TDerivedType34)obj);
- }
- else if (obj is TDerivedType35)
- {
- return matchFunc35((TDerivedType35)obj);
- }
- else if (obj is TDerivedType36)
- {
- return matchFunc36((TDerivedType36)obj);
- }
- else if (obj is TDerivedType37)
- {
- return matchFunc37((TDerivedType37)obj);
- }
- else if (obj is TDerivedType38)
- {
- return matchFunc38((TDerivedType38)obj);
- }
- else if (obj is TDerivedType39)
- {
- return matchFunc39((TDerivedType39)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
-
- public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4, TDerivedType5, TDerivedType6, TDerivedType7, TDerivedType8, TDerivedType9, TDerivedType10, TDerivedType11, TDerivedType12, TDerivedType13, TDerivedType14, TDerivedType15, TDerivedType16, TDerivedType17, TDerivedType18, TDerivedType19, TDerivedType20, TDerivedType21, TDerivedType22, TDerivedType23, TDerivedType24, TDerivedType25, TDerivedType26, TDerivedType27, TDerivedType28, TDerivedType29, TDerivedType30, TDerivedType31, TDerivedType32, TDerivedType33, TDerivedType34, TDerivedType35, TDerivedType36, TDerivedType37, TDerivedType38, TDerivedType39, TDerivedType40, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TDerivedType3, TResult> matchFunc3, Func<TDerivedType4, TResult> matchFunc4, Func<TDerivedType5, TResult> matchFunc5, Func<TDerivedType6, TResult> matchFunc6, Func<TDerivedType7, TResult> matchFunc7, Func<TDerivedType8, TResult> matchFunc8, Func<TDerivedType9, TResult> matchFunc9, Func<TDerivedType10, TResult> matchFunc10, Func<TDerivedType11, TResult> matchFunc11, Func<TDerivedType12, TResult> matchFunc12, Func<TDerivedType13, TResult> matchFunc13, Func<TDerivedType14, TResult> matchFunc14, Func<TDerivedType15, TResult> matchFunc15, Func<TDerivedType16, TResult> matchFunc16, Func<TDerivedType17, TResult> matchFunc17, Func<TDerivedType18, TResult> matchFunc18, Func<TDerivedType19, TResult> matchFunc19, Func<TDerivedType20, TResult> matchFunc20, Func<TDerivedType21, TResult> matchFunc21, Func<TDerivedType22, TResult> matchFunc22, Func<TDerivedType23, TResult> matchFunc23, Func<TDerivedType24, TResult> matchFunc24, Func<TDerivedType25, TResult> matchFunc25, Func<TDerivedType26, TResult> matchFunc26, Func<TDerivedType27, TResult> matchFunc27, Func<TDerivedType28, TResult> matchFunc28, Func<TDerivedType29, TResult> matchFunc29, Func<TDerivedType30, TResult> matchFunc30, Func<TDerivedType31, TResult> matchFunc31, Func<TDerivedType32, TResult> matchFunc32, Func<TDerivedType33, TResult> matchFunc33, Func<TDerivedType34, TResult> matchFunc34, Func<TDerivedType35, TResult> matchFunc35, Func<TDerivedType36, TResult> matchFunc36, Func<TDerivedType37, TResult> matchFunc37, Func<TDerivedType38, TResult> matchFunc38, Func<TDerivedType39, TResult> matchFunc39, Func<TDerivedType40, TResult> matchFunc40, Func<TBaseType, TResult> defaultFunc = null)
- where TDerivedType1 : TBaseType
- where TDerivedType2 : TBaseType
- where TDerivedType3 : TBaseType
- where TDerivedType4 : TBaseType
- where TDerivedType5 : TBaseType
- where TDerivedType6 : TBaseType
- where TDerivedType7 : TBaseType
- where TDerivedType8 : TBaseType
- where TDerivedType9 : TBaseType
- where TDerivedType10 : TBaseType
- where TDerivedType11 : TBaseType
- where TDerivedType12 : TBaseType
- where TDerivedType13 : TBaseType
- where TDerivedType14 : TBaseType
- where TDerivedType15 : TBaseType
- where TDerivedType16 : TBaseType
- where TDerivedType17 : TBaseType
- where TDerivedType18 : TBaseType
- where TDerivedType19 : TBaseType
- where TDerivedType20 : TBaseType
- where TDerivedType21 : TBaseType
- where TDerivedType22 : TBaseType
- where TDerivedType23 : TBaseType
- where TDerivedType24 : TBaseType
- where TDerivedType25 : TBaseType
- where TDerivedType26 : TBaseType
- where TDerivedType27 : TBaseType
- where TDerivedType28 : TBaseType
- where TDerivedType29 : TBaseType
- where TDerivedType30 : TBaseType
- where TDerivedType31 : TBaseType
- where TDerivedType32 : TBaseType
- where TDerivedType33 : TBaseType
- where TDerivedType34 : TBaseType
- where TDerivedType35 : TBaseType
- where TDerivedType36 : TBaseType
- where TDerivedType37 : TBaseType
- where TDerivedType38 : TBaseType
- where TDerivedType39 : TBaseType
- where TDerivedType40 : TBaseType
- {
- if (obj is TDerivedType1)
- {
- return matchFunc1((TDerivedType1)obj);
- }
- else if (obj is TDerivedType2)
- {
- return matchFunc2((TDerivedType2)obj);
- }
- else if (obj is TDerivedType3)
- {
- return matchFunc3((TDerivedType3)obj);
- }
- else if (obj is TDerivedType4)
- {
- return matchFunc4((TDerivedType4)obj);
- }
- else if (obj is TDerivedType5)
- {
- return matchFunc5((TDerivedType5)obj);
- }
- else if (obj is TDerivedType6)
- {
- return matchFunc6((TDerivedType6)obj);
- }
- else if (obj is TDerivedType7)
- {
- return matchFunc7((TDerivedType7)obj);
- }
- else if (obj is TDerivedType8)
- {
- return matchFunc8((TDerivedType8)obj);
- }
- else if (obj is TDerivedType9)
- {
- return matchFunc9((TDerivedType9)obj);
- }
- else if (obj is TDerivedType10)
- {
- return matchFunc10((TDerivedType10)obj);
- }
- else if (obj is TDerivedType11)
- {
- return matchFunc11((TDerivedType11)obj);
- }
- else if (obj is TDerivedType12)
- {
- return matchFunc12((TDerivedType12)obj);
- }
- else if (obj is TDerivedType13)
- {
- return matchFunc13((TDerivedType13)obj);
- }
- else if (obj is TDerivedType14)
- {
- return matchFunc14((TDerivedType14)obj);
- }
- else if (obj is TDerivedType15)
- {
- return matchFunc15((TDerivedType15)obj);
- }
- else if (obj is TDerivedType16)
- {
- return matchFunc16((TDerivedType16)obj);
- }
- else if (obj is TDerivedType17)
- {
- return matchFunc17((TDerivedType17)obj);
- }
- else if (obj is TDerivedType18)
- {
- return matchFunc18((TDerivedType18)obj);
- }
- else if (obj is TDerivedType19)
- {
- return matchFunc19((TDerivedType19)obj);
- }
- else if (obj is TDerivedType20)
- {
- return matchFunc20((TDerivedType20)obj);
- }
- else if (obj is TDerivedType21)
- {
- return matchFunc21((TDerivedType21)obj);
- }
- else if (obj is TDerivedType22)
- {
- return matchFunc22((TDerivedType22)obj);
- }
- else if (obj is TDerivedType23)
- {
- return matchFunc23((TDerivedType23)obj);
- }
- else if (obj is TDerivedType24)
- {
- return matchFunc24((TDerivedType24)obj);
- }
- else if (obj is TDerivedType25)
- {
- return matchFunc25((TDerivedType25)obj);
- }
- else if (obj is TDerivedType26)
- {
- return matchFunc26((TDerivedType26)obj);
- }
- else if (obj is TDerivedType27)
- {
- return matchFunc27((TDerivedType27)obj);
- }
- else if (obj is TDerivedType28)
- {
- return matchFunc28((TDerivedType28)obj);
- }
- else if (obj is TDerivedType29)
- {
- return matchFunc29((TDerivedType29)obj);
- }
- else if (obj is TDerivedType30)
- {
- return matchFunc30((TDerivedType30)obj);
- }
- else if (obj is TDerivedType31)
- {
- return matchFunc31((TDerivedType31)obj);
- }
- else if (obj is TDerivedType32)
- {
- return matchFunc32((TDerivedType32)obj);
- }
- else if (obj is TDerivedType33)
- {
- return matchFunc33((TDerivedType33)obj);
- }
- else if (obj is TDerivedType34)
- {
- return matchFunc34((TDerivedType34)obj);
- }
- else if (obj is TDerivedType35)
- {
- return matchFunc35((TDerivedType35)obj);
- }
- else if (obj is TDerivedType36)
- {
- return matchFunc36((TDerivedType36)obj);
- }
- else if (obj is TDerivedType37)
- {
- return matchFunc37((TDerivedType37)obj);
- }
- else if (obj is TDerivedType38)
- {
- return matchFunc38((TDerivedType38)obj);
- }
- else if (obj is TDerivedType39)
- {
- return matchFunc39((TDerivedType39)obj);
- }
- else if (obj is TDerivedType40)
- {
- return matchFunc40((TDerivedType40)obj);
- }
- else if (defaultFunc != null)
- {
- return defaultFunc(obj);
- }
- else
- {
- return default(TResult);
- }
- }
- #endregion
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/PortingExtensions.cs b/main/src/addins/CSharpBinding/Util/PortingExtensions.cs
new file mode 100644
index 0000000000..3d465bf428
--- /dev/null
+++ b/main/src/addins/CSharpBinding/Util/PortingExtensions.cs
@@ -0,0 +1,203 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using Microsoft.CodeAnalysis.Text;
+using Roslyn.Utilities;
+
+namespace Microsoft.CodeAnalysis
+{
+ [Obsolete]
+ internal static class PortingExtensions
+ {
+ /// <summary>
+ /// Gets the invoke method for a delegate type.
+ /// </summary>
+ /// <remarks>
+ /// Returns null if the type is not a delegate type; or if the invoke method could not be found.
+ /// </remarks>
+ public static IMethodSymbol GetDelegateInvokeMethod (this ITypeSymbol type)
+ {
+ if (type == null)
+ throw new ArgumentNullException (nameof (type));
+ if (type.TypeKind == TypeKind.Delegate)
+ return type.GetMembers ("Invoke").OfType<IMethodSymbol> ().FirstOrDefault (m => m.MethodKind == MethodKind.DelegateInvoke);
+ return null;
+ }
+
+ public static async Task<CompilationUnitSyntax> GetCSharpSyntaxRootAsync (this Document document, CancellationToken cancellationToken = default (CancellationToken))
+ {
+ var root = await document.GetSyntaxRootAsync (cancellationToken).ConfigureAwait (false);
+ return (CompilationUnitSyntax)root;
+ }
+
+ public static Task<SyntaxTree> GetCSharpSyntaxTreeAsync (this Document document, CancellationToken cancellationToken = default (CancellationToken))
+ {
+ return document.GetSyntaxTreeAsync (cancellationToken);
+ }
+
+ public static Task<SemanticModel> GetCSharpSemanticModelForNodeAsync (this Document document, SyntaxNode node, CancellationToken cancellationToken = default (CancellationToken))
+ {
+ return document.GetSemanticModelForNodeAsync (node, cancellationToken);
+ }
+
+ public static Task<SemanticModel> GetCSharpSemanticModelForSpanAsync (this Document document, TextSpan span, CancellationToken cancellationToken = default (CancellationToken))
+ {
+ return document.GetSemanticModelForSpanAsync (span, cancellationToken);
+ }
+
+ public static Task<Compilation> GetCSharpCompilationAsync (this Document document, CancellationToken cancellationToken = default (CancellationToken))
+ {
+ return document.Project.GetCompilationAsync (cancellationToken);
+ }
+
+ public static async Task<IEnumerable<T>> GetUnionResultsFromDocumentAndLinks<T> (
+ this Document document,
+ IEqualityComparer<T> comparer,
+ Func<Document, CancellationToken, Task<IEnumerable<T>>> getItemsWorker,
+ CancellationToken cancellationToken)
+ {
+ var linkedDocumentIds = document.GetLinkedDocumentIds ();
+ var itemsForCurrentContext = await getItemsWorker (document, cancellationToken).ConfigureAwait (false) ?? SpecializedCollections.EmptyEnumerable<T> ();
+ if (!linkedDocumentIds.Any ()) {
+ return itemsForCurrentContext;
+ }
+
+ ISet<T> totalItems = itemsForCurrentContext.ToSet (comparer);
+ foreach (var linkedDocumentId in linkedDocumentIds) {
+ var linkedDocument = document.Project.Solution.GetDocument (linkedDocumentId);
+ var items = await getItemsWorker (linkedDocument, cancellationToken).ConfigureAwait (false);
+ if (items != null) {
+ foreach (var item in items)
+ totalItems.Add (item);
+ }
+ }
+
+ return totalItems;
+ }
+
+ /// <summary>
+ /// Gets all base classes and interfaces.
+ /// </summary>
+ /// <returns>All classes and interfaces.</returns>
+ /// <param name="type">Type.</param>
+ public static IEnumerable<INamedTypeSymbol> GetAllBaseClassesAndInterfaces (this INamedTypeSymbol type, bool includeSuperType = false)
+ {
+ if (!includeSuperType)
+ type = type.BaseType;
+ var curType = type;
+ while (curType != null) {
+ yield return curType;
+ curType = curType.BaseType;
+ }
+
+ foreach (var inter in type.AllInterfaces) {
+ yield return inter;
+ }
+ }
+
+ /// <summary>
+ /// Gets the EditorBrowsableState of an entity.
+ /// </summary>
+ /// <returns>
+ /// The editor browsable state.
+ /// </returns>
+ /// <param name='symbol'>
+ /// Entity.
+ /// </param>
+ public static System.ComponentModel.EditorBrowsableState GetEditorBrowsableState (this ISymbol symbol)
+ {
+ if (symbol == null)
+ throw new ArgumentNullException ("symbol");
+ var browsableState = symbol.GetAttributes ().FirstOrDefault (attr => attr.AttributeClass.Name == "EditorBrowsableAttribute" && attr.AttributeClass.ContainingNamespace.MetadataName == "System.ComponentModel");
+ if (browsableState != null && browsableState.ConstructorArguments.Length == 1) {
+ try {
+ return (System.ComponentModel.EditorBrowsableState)browsableState.ConstructorArguments [0].Value;
+ } catch {
+ }
+ }
+ return System.ComponentModel.EditorBrowsableState.Always;
+ }
+
+ /// <summary>
+ /// Determines if an entity should be shown in the code completion window. This is the same as:
+ /// <c>GetEditorBrowsableState (entity) != System.ComponentModel.EditorBrowsableState.Never</c>
+ /// </summary>
+ /// <returns>
+ /// <c>true</c> if the entity should be shown; otherwise, <c>false</c>.
+ /// </returns>
+ /// <param name='symbol'>
+ /// The entity.
+ /// </param>
+ public static bool IsEditorBrowsable (this ISymbol symbol)
+ {
+ if (symbol == null)
+ throw new ArgumentNullException ("symbol");
+ return GetEditorBrowsableState (symbol) != System.ComponentModel.EditorBrowsableState.Never;
+ }
+
+ public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2> (this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TBaseType> defaultAction = null)
+ where TDerivedType1 : TBaseType
+ where TDerivedType2 : TBaseType
+ {
+ if (obj is TDerivedType1) {
+ matchAction1 ((TDerivedType1)obj);
+ } else if (obj is TDerivedType2) {
+ matchAction2 ((TDerivedType2)obj);
+ } else {
+ defaultAction?.Invoke (obj);
+ }
+ }
+
+ public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3> (this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TBaseType> defaultAction = null)
+ where TDerivedType1 : TBaseType
+ where TDerivedType2 : TBaseType
+ where TDerivedType3 : TBaseType
+ {
+ if (obj is TDerivedType1) {
+ matchAction1 ((TDerivedType1)obj);
+ } else if (obj is TDerivedType2) {
+ matchAction2 ((TDerivedType2)obj);
+ } else if (obj is TDerivedType3) {
+ matchAction3 ((TDerivedType3)obj);
+ } else {
+ defaultAction?.Invoke (obj);
+ }
+ }
+
+ public static void TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TDerivedType3, TDerivedType4> (this TBaseType obj, Action<TDerivedType1> matchAction1, Action<TDerivedType2> matchAction2, Action<TDerivedType3> matchAction3, Action<TDerivedType4> matchAction4, Action<TBaseType> defaultAction = null)
+ where TDerivedType1 : TBaseType
+ where TDerivedType2 : TBaseType
+ where TDerivedType3 : TBaseType
+ where TDerivedType4 : TBaseType
+ {
+ if (obj is TDerivedType1) {
+ matchAction1 ((TDerivedType1)obj);
+ } else if (obj is TDerivedType2) {
+ matchAction2 ((TDerivedType2)obj);
+ } else if (obj is TDerivedType3) {
+ matchAction3 ((TDerivedType3)obj);
+ } else if (obj is TDerivedType4) {
+ matchAction4 ((TDerivedType4)obj);
+ } else {
+ defaultAction?.Invoke (obj);
+ }
+ }
+
+ public static ExpressionSyntax SkipParens (this ExpressionSyntax expression)
+ {
+ if (expression == null)
+ return null;
+ while (expression != null && expression.IsKind (SyntaxKind.ParenthesizedExpression)) {
+ expression = ((ParenthesizedExpressionSyntax)expression).Expression;
+ }
+ return expression;
+ }
+ }
+}
diff --git a/main/src/addins/CSharpBinding/Util/PredefinedOperator.cs b/main/src/addins/CSharpBinding/Util/PredefinedOperator.cs
deleted file mode 100644
index 794f8f25c4..0000000000
--- a/main/src/addins/CSharpBinding/Util/PredefinedOperator.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- enum PredefinedOperator
- {
- None = 0,
- Addition = 1,
- BitwiseAnd = 1 << 1,
- BitwiseOr = 1 << 2,
- Complement = 1 << 3, // ~ or ! in C#, 'Not' in VB.
- Concatenate = 1 << 4,
- Decrement = 1 << 5,
- Division = 1 << 6,
- Equality = 1 << 7,
- ExclusiveOr = 1 << 8,
- Exponent = 1 << 9,
- GreaterThan = 1 << 10,
- GreaterThanOrEqual = 1 << 11,
- Increment = 1 << 12,
- Inequality = 1 << 13,
- IntegerDivision = 1 << 14,
- LeftShift = 1 << 15,
- LessThan = 1 << 16,
- LessThanOrEqual = 1 << 17,
- Like = 1 << 18,
- Modulus = 1 << 19,
- Multiplication = 1 << 20,
- RightShift = 1 << 21,
- Subtraction = 1 << 22,
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/QueryExpressionSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/QueryExpressionSyntaxExtensions.cs
deleted file mode 100644
index ade55d10ae..0000000000
--- a/main/src/addins/CSharpBinding/Util/QueryExpressionSyntaxExtensions.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class QueryExpressionSyntaxExtensions
- {
- public static IList<SyntaxNode> GetAllClauses(this QueryExpressionSyntax query)
- {
- var result = new List<SyntaxNode>();
- result.Add(query.FromClause);
- result.AddRange(query.Body.Clauses);
- result.Add(query.Body.SelectOrGroup);
- return result;
- }
-
- public static IList<SyntaxNode> GetAllClauses(this QueryBodySyntax body)
- {
- var result = new List<SyntaxNode>();
- result.AddRange(body.Clauses);
- result.Add(body.SelectOrGroup);
- return result;
- }
-
- public static QueryExpressionSyntax WithAllClauses(
- this QueryExpressionSyntax query,
- IList<SyntaxNode> allClauses)
- {
- var fromClause = (FromClauseSyntax)allClauses.First();
- return query.WithFromClause(fromClause).WithBody(query.Body.WithAllClauses(allClauses.Skip(1)));
- }
-
- public static QueryBodySyntax WithAllClauses(
- this QueryBodySyntax body,
- IEnumerable<SyntaxNode> allClauses)
- {
- var clauses = SyntaxFactory.List(allClauses.Take(allClauses.Count() - 1).Cast<QueryClauseSyntax>());
- var selectOrGroup = (SelectOrGroupClauseSyntax)allClauses.Last();
- return body.WithClauses(clauses).WithSelectOrGroup(selectOrGroup);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/RefactoringHelpers.cs b/main/src/addins/CSharpBinding/Util/RefactoringHelpers.cs
deleted file mode 100644
index 561f73c241..0000000000
--- a/main/src/addins/CSharpBinding/Util/RefactoringHelpers.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using MonoDevelop.CSharp.Completion;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class RefactoringHelpers
- {
- public static TypeSyntax ConvertType(SemanticModel model, int position, ITypeSymbol type)
- {
- return SyntaxFactory.ParseTypeName(RoslynCompletionData.SafeMinimalDisplayString (type, model, position));
- }
-
- static string GetNameProposal(string eventName)
- {
- return "On" + char.ToUpper(eventName[0]) + eventName.Substring(1);
- }
-
- static string CreateBaseNameFromString(string str)
- {
- if (string.IsNullOrEmpty(str)) {
- return "empty";
- }
- var sb = new StringBuilder();
- bool firstLetter = true, wordStart = false;
- foreach (char ch in str) {
- if (char.IsWhiteSpace(ch)) {
- wordStart = true;
- continue;
- }
- if (!char.IsLetter(ch))
- continue;
- if (firstLetter) {
- sb.Append(char.ToLower(ch));
- firstLetter = false;
- continue;
- }
- if (wordStart) {
- sb.Append(char.ToUpper(ch));
- wordStart = false;
- continue;
- }
- sb.Append(ch);
- }
- return sb.Length == 0 ? "str" : sb.ToString();
- }
-
- public static string CreateBaseName(SyntaxNode node, ITypeSymbol type)
- {
- string name = null;
-
- if (node.IsKind(SyntaxKind.Argument))
- node = ((ArgumentSyntax)node).Expression;
-
- if (node.IsKind(SyntaxKind.NullLiteralExpression))
- return "o";
- if (node.IsKind(SyntaxKind.InvocationExpression))
- return CreateBaseName(((InvocationExpressionSyntax)node).Expression, type);
- if (node.IsKind(SyntaxKind.IdentifierName)) {
- name = node.ToString();
- } else if (node is MemberAccessExpressionSyntax) {
- name = ((MemberAccessExpressionSyntax)node).Name.ToString();
- } else if (node is LiteralExpressionSyntax) {
- var pe = (LiteralExpressionSyntax)node;
- if (pe.IsKind(SyntaxKind.StringLiteralExpression)) {
- name = CreateBaseNameFromString(pe.Token.ToString());
- } else {
- return char.ToLower(type.Name[0]).ToString();
- }
- } else if (node is ArrayCreationExpressionSyntax) {
- name = "arr";
- } else {
- if (type.TypeKind == TypeKind.Error)
- return "par";
- name = GuessNameFromType(type);
- }
- var sb = new StringBuilder();
- sb.Append(char.ToLower(name[0]));
- for (int i = 1; i < name.Length; i++) {
- var ch = name[i];
- if (char.IsLetterOrDigit(ch) || ch == '_')
- sb.Append(ch);
- }
- return sb.ToString();
- }
-
- internal static string GuessNameFromType(ITypeSymbol returnType)
- {
- switch (returnType.SpecialType) {
- case SpecialType.System_Object:
- return "obj";
- case SpecialType.System_Boolean:
- return "b";
- case SpecialType.System_Char:
- return "ch";
- case SpecialType.System_SByte:
- case SpecialType.System_Byte:
- return "b";
- case SpecialType.System_Int16:
- case SpecialType.System_UInt16:
- case SpecialType.System_Int32:
- case SpecialType.System_UInt32:
- case SpecialType.System_Int64:
- case SpecialType.System_UInt64:
- return "i";
- case SpecialType.System_Decimal:
- return "d";
- case SpecialType.System_Single:
- return "f";
- case SpecialType.System_Double:
- return "d";
- case SpecialType.System_String:
- return "str";
- case SpecialType.System_IntPtr:
- case SpecialType.System_UIntPtr:
- return "ptr";
- case SpecialType.System_DateTime:
- return "date";
- }
- if (returnType.TypeKind == TypeKind.Array)
- return "arr";
- switch (returnType.GetFullName()) {
- case "System.Exception":
- return "e";
- case "System.Object":
- case "System.Func":
- case "System.Action":
- return "action";
- }
- return string.IsNullOrEmpty(returnType.Name) ? "obj" : returnType.Name;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/ReflectionCompatibilityExtensions.cs b/main/src/addins/CSharpBinding/Util/ReflectionCompatibilityExtensions.cs
deleted file mode 100644
index c9de6159e5..0000000000
--- a/main/src/addins/CSharpBinding/Util/ReflectionCompatibilityExtensions.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- [Flags]
- internal enum BindingFlags
- {
- Default = 0,
- Instance = 1,
- Static = 2,
- Public = 4,
- NonPublic = 8,
- }
-
- internal static class ReflectionCompatibilityExtensions
- {
- public static object[] GetCustomAttributes(this Type type, bool inherit)
- {
- return type.GetTypeInfo().GetCustomAttributes(inherit).ToArray();
- }
-
- public static MethodInfo GetMethod(this Type type, string name)
- {
- return type.GetTypeInfo().DeclaredMethods.FirstOrDefault(m => m.Name == name);
- }
-
- public static MethodInfo GetMethod(this Type type, string name, BindingFlags bindingFlags)
- {
- return type.GetTypeInfo().DeclaredMethods.FirstOrDefault(m => (m.Name == name) && IsConformWithBindingFlags(m, bindingFlags));
- }
-
- public static MethodInfo GetMethod(this Type type, string name, Type[] types)
- {
- return type.GetTypeInfo().DeclaredMethods.FirstOrDefault(
- m => (m.Name == name) && TypesAreEqual(m.GetParameters().Select(p => p.ParameterType).ToArray(), types));
- }
-
- public static MethodInfo GetMethod(this Type type, string name, BindingFlags bindingFlags, object binder, Type[] types, object modifiers)
- {
- return type.GetTypeInfo().DeclaredMethods.FirstOrDefault(
- m => (m.Name == name) && IsConformWithBindingFlags(m, bindingFlags) && TypesAreEqual(m.GetParameters().Select(p => p.ParameterType).ToArray(), types));
- }
-
- public static IEnumerable<MethodInfo> GetMethods(this Type type)
- {
- return type.GetTypeInfo().DeclaredMethods;
- }
-
- public static IEnumerable<MethodInfo> GetMethods(this Type type, string name)
- {
- return type.GetTypeInfo().DeclaredMethods.Where(m => m.Name == name);
- }
-
- public static IEnumerable<MethodInfo> GetMethods(this Type type, BindingFlags bindingFlags)
- {
- return type.GetTypeInfo().DeclaredMethods.Where(m => IsConformWithBindingFlags(m, bindingFlags));
- }
-
- public static FieldInfo GetField(this Type type, string name)
- {
- return type.GetTypeInfo().DeclaredFields.FirstOrDefault(f => f.Name == name);
- }
-
- public static FieldInfo GetField(this Type type, string name, BindingFlags bindingFlags)
- {
- return type.GetTypeInfo().DeclaredFields.FirstOrDefault(f => (f.Name == name) && IsConformWithBindingFlags(f, bindingFlags));
- }
-
- public static PropertyInfo GetProperty(this Type type, string name)
- {
- return type.GetTypeInfo().DeclaredProperties.FirstOrDefault(p => p.Name == name);
- }
-
- public static IEnumerable<PropertyInfo> GetProperties(this Type type)
- {
- return type.GetTypeInfo().DeclaredProperties;
- }
-
- private static bool TypesAreEqual(Type[] memberTypes, Type[] searchedTypes)
- {
- if (((memberTypes == null) || (searchedTypes == null)) && (memberTypes != searchedTypes))
- return false;
-
- if (memberTypes.Length != searchedTypes.Length)
- return false;
-
- for (int i = 0; i < memberTypes.Length; i++)
- {
- if (memberTypes[i] != searchedTypes[i])
- return false;
- }
-
- return true;
- }
-
- private static bool IsConformWithBindingFlags(MethodBase method, BindingFlags bindingFlags)
- {
- if (method.IsPublic && !bindingFlags.HasFlag(BindingFlags.Public))
- return false;
- if (method.IsPrivate && !bindingFlags.HasFlag(BindingFlags.NonPublic))
- return false;
- if (method.IsStatic && !bindingFlags.HasFlag(BindingFlags.Static))
- return false;
- if (!method.IsStatic && !bindingFlags.HasFlag(BindingFlags.Instance))
- return false;
-
- return true;
- }
-
- private static bool IsConformWithBindingFlags(FieldInfo method, BindingFlags bindingFlags)
- {
- if (method.IsPublic && !bindingFlags.HasFlag(BindingFlags.Public))
- return false;
- if (method.IsPrivate && !bindingFlags.HasFlag(BindingFlags.NonPublic))
- return false;
- if (method.IsStatic && !bindingFlags.HasFlag(BindingFlags.Static))
- return false;
- if (!method.IsStatic && !bindingFlags.HasFlag(BindingFlags.Instance))
- return false;
-
- return true;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SemanticDocument.cs b/main/src/addins/CSharpBinding/Util/SemanticDocument.cs
deleted file mode 100644
index b4d251aa51..0000000000
--- a/main/src/addins/CSharpBinding/Util/SemanticDocument.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class SemanticDocument : SyntacticDocument
- {
- public readonly SemanticModel SemanticModel;
-
- private SemanticDocument(Document document, SourceText text, SyntaxTree tree, SyntaxNode root, SemanticModel semanticModel)
- : base(document, text, tree, root)
- {
- this.SemanticModel = semanticModel;
- }
-
- public static new async Task<SemanticDocument> CreateAsync(Document document, CancellationToken cancellationToken)
- {
- var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
- return new SemanticDocument(document, text, root.SyntaxTree, root, model);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SemanticEquivalence.cs b/main/src/addins/CSharpBinding/Util/SemanticEquivalence.cs
deleted file mode 100644
index 82da9dc7bb..0000000000
--- a/main/src/addins/CSharpBinding/Util/SemanticEquivalence.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-// SemanticEquivalence.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Reflection;
-using Microsoft.CodeAnalysis;
-using System.Runtime.ExceptionServices;
-using System.ComponentModel.Design;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SemanticEquivalence
- {
- readonly static Type typeInfo;
-
- static SemanticEquivalence ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.Shared.Extensions.SemanticEquivalence" + ReflectionNamespaces.WorkspacesAsmName, true);
- areSemanticallyEquivalentMethod = typeInfo.GetMethod ("AreSemanticallyEquivalent", BindingFlags.Static | BindingFlags.Public);
- }
-
- static readonly MethodInfo areSemanticallyEquivalentMethod;
-
- public static bool AreSemanticallyEquivalent(
- SemanticModel semanticModel1,
- SemanticModel semanticModel2,
- SyntaxNode node1,
- SyntaxNode node2,
- Func<SyntaxNode, bool> predicate = null)
- {
- try {
- return (bool)areSemanticallyEquivalentMethod.Invoke (null, new object[] {
- semanticModel1,
- semanticModel2,
- node1,
- node2,
- predicate
- });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/SemanticMap.cs b/main/src/addins/CSharpBinding/Util/SemanticMap.cs
deleted file mode 100644
index ee69eb9fe6..0000000000
--- a/main/src/addins/CSharpBinding/Util/SemanticMap.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- partial class SemanticMap
- {
- private readonly Dictionary<SyntaxNode, SymbolInfo> _expressionToInfoMap =
- new Dictionary<SyntaxNode, SymbolInfo>();
-
- private readonly Dictionary<SyntaxToken, SymbolInfo> _tokenToInfoMap =
- new Dictionary<SyntaxToken, SymbolInfo>();
-
- private SemanticMap()
- {
- }
-
- internal static SemanticMap From(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
- {
- var map = new SemanticMap();
- var walker = new Walker(semanticModel, map, cancellationToken);
- walker.Visit(node);
- return map;
- }
-
- public IEnumerable<ISymbol> AllReferencedSymbols
- {
- get
- {
- return _expressionToInfoMap.Values.Concat(_tokenToInfoMap.Values).Select(info => info.Symbol).Distinct();
- }
- }
-
- private class Walker : SyntaxWalker
- {
- private readonly SemanticModel _semanticModel;
- private readonly SemanticMap _map;
- private readonly CancellationToken _cancellationToken;
-
- public Walker(SemanticModel semanticModel, SemanticMap map, CancellationToken cancellationToken) :
- base(SyntaxWalkerDepth.Token)
- {
- _semanticModel = semanticModel;
- _map = map;
- _cancellationToken = cancellationToken;
- }
-
- public override void Visit(SyntaxNode node)
- {
- var info = _semanticModel.GetSymbolInfo(node);
- if (!IsNone(info))
- {
- _map._expressionToInfoMap.Add(node, info);
- }
-
- base.Visit(node);
- }
-
- protected override void VisitToken(SyntaxToken token)
- {
- var info = _semanticModel.GetSymbolInfo(token, _cancellationToken);
- if (!IsNone(info))
- {
- _map._tokenToInfoMap.Add(token, info);
- }
-
- base.VisitToken(token);
- }
-
- private bool IsNone(SymbolInfo info)
- {
- return info.Symbol == null && info.CandidateSymbols.Length == 0;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SemanticModelExtensions.cs b/main/src/addins/CSharpBinding/Util/SemanticModelExtensions.cs
deleted file mode 100644
index 7ce27a713d..0000000000
--- a/main/src/addins/CSharpBinding/Util/SemanticModelExtensions.cs
+++ /dev/null
@@ -1,622 +0,0 @@
-//
-// SemanticModelExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Collections.Immutable;
-using Microsoft.CodeAnalysis.CSharp;
-using System.Linq;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SemanticModelExtensions
- {
- public static IEnumerable<ITypeSymbol> LookupTypeRegardlessOfArity(
- this SemanticModel semanticModel,
- SyntaxToken name,
- CancellationToken cancellationToken)
- {
- var expression = name.Parent as ExpressionSyntax;
- if (expression != null)
- {
- var results = semanticModel.LookupName(expression, namespacesAndTypesOnly: true, cancellationToken: cancellationToken);
- if (results.Length > 0)
- {
- return results.OfType<ITypeSymbol>();
- }
- }
-
- return SpecializedCollections.EmptyEnumerable<ITypeSymbol>();
- }
-
- public static ImmutableArray<ISymbol> LookupName(
- this SemanticModel semanticModel,
- SyntaxToken name,
- bool namespacesAndTypesOnly,
- CancellationToken cancellationToken)
- {
- var expression = name.Parent as ExpressionSyntax;
- if (expression != null)
- {
- return semanticModel.LookupName(expression, namespacesAndTypesOnly, cancellationToken);
- }
-
- return ImmutableArray.Create<ISymbol>();
- }
-
- /// <summary>
- /// Decomposes a name or member access expression into its component parts.
- /// </summary>
- /// <param name="expression">The name or member access expression.</param>
- /// <param name="qualifier">The qualifier (or left-hand-side) of the name expression. This may be null if there is no qualifier.</param>
- /// <param name="name">The name of the expression.</param>
- /// <param name="arity">The number of generic type parameters.</param>
- private static void DecomposeName(ExpressionSyntax expression, out ExpressionSyntax qualifier, out string name, out int arity)
- {
- switch (expression.Kind())
- {
- case SyntaxKind.SimpleMemberAccessExpression:
- case SyntaxKind.PointerMemberAccessExpression:
- var max = (MemberAccessExpressionSyntax)expression;
- qualifier = max.Expression;
- name = max.Name.Identifier.ValueText;
- arity = max.Name.Arity;
- break;
- case SyntaxKind.QualifiedName:
- var qn = (QualifiedNameSyntax)expression;
- qualifier = qn.Left;
- name = qn.Right.Identifier.ValueText;
- arity = qn.Arity;
- break;
- case SyntaxKind.AliasQualifiedName:
- var aq = (AliasQualifiedNameSyntax)expression;
- qualifier = aq.Alias;
- name = aq.Name.Identifier.ValueText;
- arity = aq.Name.Arity;
- break;
- case SyntaxKind.GenericName:
- var gx = (GenericNameSyntax)expression;
- qualifier = null;
- name = gx.Identifier.ValueText;
- arity = gx.Arity;
- break;
- case SyntaxKind.IdentifierName:
- var nx = (IdentifierNameSyntax)expression;
- qualifier = null;
- name = nx.Identifier.ValueText;
- arity = 0;
- break;
- default:
- qualifier = null;
- name = null;
- arity = 0;
- break;
- }
- }
-
- public static ImmutableArray<ISymbol> LookupName(
- this SemanticModel semanticModel,
- ExpressionSyntax expression,
- bool namespacesAndTypesOnly,
- CancellationToken cancellationToken)
- {
- var expr = SyntaxFactory.GetStandaloneExpression(expression);
-
- ExpressionSyntax qualifier;
- string name;
- int arity;
- DecomposeName(expr, out qualifier, out name, out arity);
-
- INamespaceOrTypeSymbol symbol = null;
- if (qualifier != null)
- {
- var typeInfo = semanticModel.GetTypeInfo(qualifier, cancellationToken);
- var symbolInfo = semanticModel.GetSymbolInfo(qualifier, cancellationToken);
- if (typeInfo.Type != null)
- {
- symbol = typeInfo.Type;
- }
- else if (symbolInfo.Symbol != null)
- {
- symbol = symbolInfo.Symbol as INamespaceOrTypeSymbol;
- }
- }
-
- return semanticModel.LookupSymbols(expr.SpanStart, container: symbol, name: name, includeReducedExtensionMethods: true);
- }
-
- public static SymbolInfo GetSymbolInfo(this SemanticModel semanticModel, SyntaxToken token)
- {
- if (!CanBindToken(token))
- {
- return default(SymbolInfo);
- }
-
- var expression = token.Parent as ExpressionSyntax;
- if (expression != null)
- {
- return semanticModel.GetSymbolInfo(expression);
- }
-
- var attribute = token.Parent as AttributeSyntax;
- if (attribute != null)
- {
- return semanticModel.GetSymbolInfo(attribute);
- }
-
- var constructorInitializer = token.Parent as ConstructorInitializerSyntax;
- if (constructorInitializer != null)
- {
- return semanticModel.GetSymbolInfo(constructorInitializer);
- }
-
- return default(SymbolInfo);
- }
-
- private static bool CanBindToken(SyntaxToken token)
- {
- // Add more token kinds if necessary;
- switch (token.Kind())
- {
- case SyntaxKind.CommaToken:
- case SyntaxKind.DelegateKeyword:
- return false;
- }
-
- return true;
- }
-
- /// <summary>
- /// Given an argument node, tries to generate an appropriate name that can be used for that
- /// argument.
- /// </summary>
- public static string GenerateNameForArgument(
- this SemanticModel semanticModel, ArgumentSyntax argument)
- {
- // If it named argument then we use the name provided.
- if (argument.NameColon != null)
- {
- return argument.NameColon.Name.Identifier.ValueText;
- }
-
- return semanticModel.GenerateNameForExpression(argument.Expression);
- }
-
- public static string GenerateNameForArgument(
- this SemanticModel semanticModel, AttributeArgumentSyntax argument)
- {
- // If it named argument then we use the name provided.
- if (argument.NameEquals != null)
- {
- return argument.NameEquals.Name.Identifier.ValueText;
- }
-
- return semanticModel.GenerateNameForExpression(argument.Expression);
- }
-
- /// <summary>
- /// Given an expression node, tries to generate an appropriate name that can be used for
- /// that expression.
- /// </summary>
- public static string GenerateNameForExpression(
- this SemanticModel semanticModel, ExpressionSyntax expression, bool capitalize = false)
- {
- // Try to find a usable name node that we can use to name the
- // parameter. If we have an expression that has a name as part of it
- // then we try to use that part.
- var current = expression;
- while (true)
- {
- current = current.WalkDownParentheses();
-
- if (current.Kind() == SyntaxKind.IdentifierName)
- {
- return ((IdentifierNameSyntax)current).Identifier.ValueText.ToCamelCase();
- }
- else if (current is MemberAccessExpressionSyntax)
- {
- return ((MemberAccessExpressionSyntax)current).Name.Identifier.ValueText.ToCamelCase();
- }
- else if (current is MemberBindingExpressionSyntax)
- {
- return ((MemberBindingExpressionSyntax)current).Name.Identifier.ValueText.ToCamelCase();
- }
- else if (current is ConditionalAccessExpressionSyntax)
- {
- current = ((ConditionalAccessExpressionSyntax)current).WhenNotNull;
- }
- else if (current is CastExpressionSyntax)
- {
- current = ((CastExpressionSyntax)current).Expression;
- }
- else
- {
- break;
- }
- }
-
- // Otherwise, figure out the type of the expression and generate a name from that
- // isntead.
- var info = semanticModel.GetTypeInfo(expression);
-
- // If we can't determine the type, then fallback to some placeholders.
- var type = info.Type;
- return type.CreateParameterName(capitalize);
- }
-
- public static IList<string> GenerateParameterNames(
- this SemanticModel semanticModel,
- ArgumentListSyntax argumentList)
- {
- return semanticModel.GenerateParameterNames(argumentList.Arguments);
- }
-
- public static IList<string> GenerateParameterNames(
- this SemanticModel semanticModel,
- AttributeArgumentListSyntax argumentList)
- {
- return semanticModel.GenerateParameterNames(argumentList.Arguments);
- }
-
- public static IList<string> GenerateParameterNames(
- this SemanticModel semanticModel,
- IEnumerable<ArgumentSyntax> arguments,
- IList<string> reservedNames = null)
- {
- reservedNames = reservedNames ?? SpecializedCollections.EmptyList<string>();
-
- // We can't change the names of named parameters. Any other names we're flexible on.
- var isFixed = reservedNames.Select(s => true).Concat(
- arguments.Select(a => a.NameColon != null)).ToList();
-
- var parameterNames = reservedNames.Concat(
- arguments.Select(semanticModel.GenerateNameForArgument)).ToList();
-
- return NameGenerator.EnsureUniqueness(parameterNames, isFixed).Skip(reservedNames.Count).ToList();
- }
-
- public static IList<string> GenerateParameterNames(
- this SemanticModel semanticModel,
- IEnumerable<AttributeArgumentSyntax> arguments,
- IList<string> reservedNames = null)
- {
- reservedNames = reservedNames ?? SpecializedCollections.EmptyList<string>();
-
- // We can't change the names of named parameters. Any other names we're flexible on.
- var isFixed = reservedNames.Select(s => true).Concat(
- arguments.Select(a => a.NameEquals != null)).ToList();
-
- var parameterNames = reservedNames.Concat(
- arguments.Select(semanticModel.GenerateNameForArgument)).ToList();
-
- return NameGenerator.EnsureUniqueness(parameterNames, isFixed).Skip(reservedNames.Count).ToList();
- }
-
- public static ISet<INamespaceSymbol> GetUsingNamespacesInScope(this SemanticModel semanticModel, SyntaxNode location)
- {
- // Avoiding linq here for perf reasons. This is used heavily in the AddImport service
- HashSet<INamespaceSymbol> result = null;
-
- foreach (var @using in location.GetEnclosingUsingDirectives())
- {
- if (@using.Alias == null)
- {
- var symbolInfo = semanticModel.GetSymbolInfo(@using.Name);
- if (symbolInfo.Symbol != null && symbolInfo.Symbol.Kind == SymbolKind.Namespace)
- {
- result = result ?? new HashSet<INamespaceSymbol>();
- result.Add((INamespaceSymbol)symbolInfo.Symbol);
- }
- }
- }
-
- return result ?? SpecializedCollections.EmptySet<INamespaceSymbol>();
- }
-
- public static Accessibility DetermineAccessibilityConstraint(
- this SemanticModel semanticModel,
- TypeSyntax type,
- CancellationToken cancellationToken)
- {
- if (type == null)
- {
- return Accessibility.Private;
- }
-
- type = GetOutermostType(type);
-
- // Interesting cases based on 3.5.4 Accessibility constraints in the language spec.
- // If any of the below hold, then we will override the default accessibility if the
- // constraint wants the type to be more accessible. i.e. if by default we generate
- // 'internal', but a constraint makes us 'public', then be public.
-
- // 1) The direct base class of a class type must be at least as accessible as the
- // class type itself.
- //
- // 2) The explicit base interfaces of an interface type must be at least as accessible
- // as the interface type itself.
- if (type != null)
- {
- if (type.Parent is BaseTypeSyntax && type.Parent.IsParentKind(SyntaxKind.BaseList) && ((BaseTypeSyntax)type.Parent).Type == type)
- {
- var containingType = semanticModel.GetDeclaredSymbol(type.GetAncestor<BaseTypeDeclarationSyntax>(), cancellationToken) as INamedTypeSymbol;
- if (containingType != null && containingType.TypeKind == TypeKind.Interface)
- {
- return containingType.DeclaredAccessibility;
- }
- else if (((BaseListSyntax)type.Parent.Parent).Types[0] == type.Parent)
- {
- return containingType.DeclaredAccessibility;
- }
- }
- }
-
- // 4) The type of a constant must be at least as accessible as the constant itself.
- // 5) The type of a field must be at least as accessible as the field itself.
- if (type.IsParentKind(SyntaxKind.VariableDeclaration) &&
- type.Parent.IsParentKind(SyntaxKind.FieldDeclaration))
- {
- var variableDeclaration = (VariableDeclarationSyntax)type.Parent;
- return ((ISymbol)semanticModel.GetDeclaredSymbol(
- variableDeclaration.Variables[0], cancellationToken)).DeclaredAccessibility;
- }
-
- // 3) The return type of a delegate type must be at least as accessible as the
- // delegate type itself.
- // 6) The return type of a method must be at least as accessible as the method
- // itself.
- // 7) The type of a property must be at least as accessible as the property itself.
- // 8) The type of an event must be at least as accessible as the event itself.
- // 9) The type of an indexer must be at least as accessible as the indexer itself.
- // 10) The return type of an operator must be at least as accessible as the operator
- // itself.
- if (type.IsParentKind(SyntaxKind.DelegateDeclaration) ||
- type.IsParentKind(SyntaxKind.MethodDeclaration) ||
- type.IsParentKind(SyntaxKind.PropertyDeclaration) ||
- type.IsParentKind(SyntaxKind.EventDeclaration) ||
- type.IsParentKind(SyntaxKind.IndexerDeclaration) ||
- type.IsParentKind(SyntaxKind.OperatorDeclaration))
- {
- return semanticModel.GetDeclaredSymbol(
- type.Parent, cancellationToken).DeclaredAccessibility;
- }
-
- // 3) The parameter types of a delegate type must be at least as accessible as the
- // delegate type itself.
- // 6) The parameter types of a method must be at least as accessible as the method
- // itself.
- // 9) The parameter types of an indexer must be at least as accessible as the
- // indexer itself.
- // 10) The parameter types of an operator must be at least as accessible as the
- // operator itself.
- // 11) The parameter types of an instance constructor must be at least as accessible
- // as the instance constructor itself.
- if (type.IsParentKind(SyntaxKind.Parameter) && type.Parent.IsParentKind(SyntaxKind.ParameterList))
- {
- if (type.Parent.Parent.IsParentKind(SyntaxKind.DelegateDeclaration) ||
- type.Parent.Parent.IsParentKind(SyntaxKind.MethodDeclaration) ||
- type.Parent.Parent.IsParentKind(SyntaxKind.IndexerDeclaration) ||
- type.Parent.Parent.IsParentKind(SyntaxKind.OperatorDeclaration))
- {
- return semanticModel.GetDeclaredSymbol(
- type.Parent.Parent.Parent, cancellationToken).DeclaredAccessibility;
- }
-
- if (type.Parent.Parent.IsParentKind(SyntaxKind.ConstructorDeclaration))
- {
- var symbol = semanticModel.GetDeclaredSymbol(type.Parent.Parent.Parent, cancellationToken);
- if (!symbol.IsStatic)
- {
- return symbol.DeclaredAccessibility;
- }
- }
- }
-
- // 8) The type of an event must be at least as accessible as the event itself.
- if (type.IsParentKind(SyntaxKind.VariableDeclaration) &&
- type.Parent.IsParentKind(SyntaxKind.EventFieldDeclaration))
- {
- var variableDeclaration = (VariableDeclarationSyntax)type.Parent;
- var symbol = semanticModel.GetDeclaredSymbol(variableDeclaration.Variables[0], cancellationToken);
- if (symbol != null)
- {
- return ((ISymbol)symbol).DeclaredAccessibility;
- }
- }
-
- return Accessibility.Private;
- }
-
- private static TypeSyntax GetOutermostType(TypeSyntax type)
- {
- return type.GetAncestorsOrThis<TypeSyntax>().Last();
- }
-
- public static SemanticMap GetSemanticMap(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
- {
- return SemanticMap.From(semanticModel, node, cancellationToken);
- }
-
- /// <summary>
- /// Gets semantic information, such as type, symbols, and diagnostics, about the parent of a token.
- /// </summary>
- /// <param name="semanticModel">The SemanticModel object to get semantic information
- /// from.</param>
- /// <param name="token">The token to get semantic information from. This must be part of the
- /// syntax tree associated with the binding.</param>
- /// <param name="cancellationToken">A cancellation token.</param>
- public static SymbolInfo GetSymbolInfo(this SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken)
- {
- return semanticModel.GetSymbolInfo(token.Parent, cancellationToken);
- }
-
- public static ISymbol GetEnclosingNamedTypeOrAssembly(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- return semanticModel.GetEnclosingSymbol<INamedTypeSymbol>(position, cancellationToken) ??
- (ISymbol)semanticModel.Compilation.Assembly;
- }
-
- public static INamespaceSymbol GetEnclosingNamespace(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- return semanticModel.GetEnclosingSymbol<INamespaceSymbol>(position, cancellationToken);
- }
-
- public static ITypeSymbol GetType(
- this SemanticModel semanticModel,
- SyntaxNode expression,
- CancellationToken cancellationToken)
- {
- var typeInfo = semanticModel.GetTypeInfo(expression, cancellationToken);
- var symbolInfo = semanticModel.GetSymbolInfo(expression, cancellationToken);
- return typeInfo.Type ?? symbolInfo.GetAnySymbol().ConvertToType(semanticModel.Compilation);
- }
-
-// public static IEnumerable<ISymbol> GetSymbols(
-// this SemanticModel semanticModel,
-// SyntaxToken token,
-// Workspace workspace,
-// bool bindLiteralsToUnderlyingType,
-// CancellationToken cancellationToken)
-// {
-// var languageServices = workspace.Services.GetLanguageServices(token.Language);
-// var syntaxFacts = languageServices.GetService<ISyntaxFactsService>();
-// if (!syntaxFacts.IsBindableToken(token))
-// {
-// return SpecializedCollections.EmptyEnumerable<ISymbol>();
-// }
-//
-// var semanticFacts = languageServices.GetService<ISemanticFactsService>();
-//
-// return GetSymbolsEnumerable(
-// semanticModel, semanticFacts, syntaxFacts,
-// token, bindLiteralsToUnderlyingType, cancellationToken)
-// .WhereNotNull()
-// .Select(MapSymbol);
-// }
-
- private static ISymbol MapSymbol(ISymbol symbol)
- {
- return symbol.IsConstructor() && symbol.ContainingType.IsAnonymousType
- ? symbol.ContainingType
- : symbol;
- }
-
-// private static IEnumerable<ISymbol> GetSymbolsEnumerable(
-// SemanticModel semanticModel,
-// ISemanticFactsService semanticFacts,
-// ISyntaxFactsService syntaxFacts,
-// SyntaxToken token,
-// bool bindLiteralsToUnderlyingType,
-// CancellationToken cancellationToken)
-// {
-// var declaredSymbol = semanticFacts.GetDeclaredSymbol(semanticModel, token, cancellationToken);
-// if (declaredSymbol != null)
-// {
-// yield return declaredSymbol;
-// yield break;
-// }
-//
-// var aliasInfo = semanticModel.GetAliasInfo(token.Parent, cancellationToken);
-// if (aliasInfo != null)
-// {
-// yield return aliasInfo;
-// }
-//
-// var bindableParent = syntaxFacts.GetBindableParent(token);
-// var allSymbols = semanticModel.GetSymbolInfo(bindableParent, cancellationToken).GetBestOrAllSymbols().ToList();
-// var type = semanticModel.GetTypeInfo(bindableParent, cancellationToken).Type;
-//
-// if (type != null && allSymbols.Count == 0)
-// {
-// if ((bindLiteralsToUnderlyingType && syntaxFacts.IsLiteral(token)) ||
-// syntaxFacts.IsAwaitKeyword(token))
-// {
-// yield return type;
-// }
-//
-// if (type.Kind == SymbolKind.NamedType)
-// {
-// var namedType = (INamedTypeSymbol)type;
-// if (namedType.TypeKind == TypeKind.Delegate ||
-// namedType.AssociatedSymbol != null)
-// {
-// yield return type;
-// }
-// }
-// }
-//
-// foreach (var symbol in allSymbols)
-// {
-// if (symbol.IsThisParameter() && type != null)
-// {
-// yield return type;
-// }
-// else if (symbol.IsFunctionValue())
-// {
-// var method = symbol.ContainingSymbol as IMethodSymbol;
-//
-// if (method != null)
-// {
-// if (method.AssociatedSymbol != null)
-// {
-// yield return method.AssociatedSymbol;
-// }
-// else
-// {
-// yield return method;
-// }
-// }
-// else
-// {
-// yield return symbol;
-// }
-// }
-// else
-// {
-// yield return symbol;
-// }
-// }
-// }
-
- public static SemanticModel GetOriginalSemanticModel(this SemanticModel semanticModel)
- {
- if (!semanticModel.IsSpeculativeSemanticModel)
- {
- return semanticModel;
- }
-
-// Contract.ThrowIfNull(semanticModel.ParentModel);
-// Contract.ThrowIfTrue(semanticModel.ParentModel.IsSpeculativeSemanticModel);
-// Contract.ThrowIfTrue(semanticModel.ParentModel.ParentModel != null);
- return semanticModel.ParentModel;
- }
-
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/SignatureComparer.cs b/main/src/addins/CSharpBinding/Util/SignatureComparer.cs
deleted file mode 100644
index 4f9e4c02a7..0000000000
--- a/main/src/addins/CSharpBinding/Util/SignatureComparer.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SignatureComparer
- {
- readonly static Type typeInfo;
- readonly static object instance;
- readonly static MethodInfo haveSameSignatureMethod;
- readonly static MethodInfo haveSameSignature2Method;
- readonly static MethodInfo haveSameSignature3Method;
- readonly static MethodInfo haveSameSignature4Method;
- readonly static MethodInfo haveSameSignature5Method;
-
- static SignatureComparer()
- {
- typeInfo = Type.GetType("Microsoft.CodeAnalysis.Shared.Utilities.SignatureComparer" + ReflectionNamespaces.WorkspacesAsmName, true);
-
- instance = typeInfo.GetField("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
-
- haveSameSignatureMethod = typeInfo.GetMethod("HaveSameSignature", new[] { typeof(IList<IParameterSymbol>), typeof(IList<IParameterSymbol>) });
- haveSameSignature2Method = typeInfo.GetMethod("HaveSameSignature", new[] { typeof(IPropertySymbol), typeof(IPropertySymbol), typeof(bool) });
- haveSameSignature3Method = typeInfo.GetMethod("HaveSameSignature", new[] { typeof(ISymbol), typeof(ISymbol), typeof(bool) });
- haveSameSignature4Method = typeInfo.GetMethod("HaveSameSignature", new[] { typeof(IMethodSymbol), typeof(IMethodSymbol), typeof(bool), typeof(bool), typeof(bool) });
- haveSameSignature5Method = typeInfo.GetMethod("HaveSameSignature", new[] { typeof(IList<IParameterSymbol>), typeof(IList<IParameterSymbol>), typeof(bool), typeof(bool) });
- haveSameSignatureAndConstraintsAndReturnTypeAndAccessorsMethod = typeInfo.GetMethod ("HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors", BindingFlags.Public | BindingFlags.Instance);
- }
-
- public static bool HaveSameSignature (IList<IParameterSymbol> parameters1, IList<IParameterSymbol> parameters2)
- {
- try {
- return (bool)haveSameSignatureMethod.Invoke (instance, new object [] { parameters1, parameters2 });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- public static bool HaveSameSignature (IPropertySymbol property1, IPropertySymbol property2, bool caseSensitive)
- {
- try {
- return (bool)haveSameSignature2Method.Invoke(instance, new object[] { property1, property2, caseSensitive });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- public static bool HaveSameSignature (ISymbol symbol1, ISymbol symbol2, bool caseSensitive)
- {
- try {
- return (bool)haveSameSignature3Method.Invoke(instance, new object[] { symbol1, symbol2, caseSensitive });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- public static bool HaveSameSignature (IMethodSymbol method1, IMethodSymbol method2, bool caseSensitive, bool compareParameterName = false, bool isParameterCaseSensitive = false)
- {
- try {
- return (bool)haveSameSignature4Method.Invoke(instance, new object[] { method1, method2, caseSensitive, compareParameterName, isParameterCaseSensitive });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- public static bool HaveSameSignature (IList<IParameterSymbol> parameters1, IList<IParameterSymbol> parameters2, bool compareParameterName, bool isCaseSensitive)
- {
- try {
- return (bool)haveSameSignature5Method.Invoke(instance, new object[] { parameters1, parameters2, compareParameterName, isCaseSensitive });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- readonly static MethodInfo haveSameSignatureAndConstraintsAndReturnTypeAndAccessorsMethod;
- public static bool HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors(ISymbol symbol1, ISymbol symbol2, bool caseSensitive)
- {
- try {
- return (bool)haveSameSignatureAndConstraintsAndReturnTypeAndAccessorsMethod.Invoke(instance, new object[] { symbol1, symbol2, caseSensitive });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/Util/SimpleNameSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/SimpleNameSyntaxExtensions.cs
deleted file mode 100644
index f129328f64..0000000000
--- a/main/src/addins/CSharpBinding/Util/SimpleNameSyntaxExtensions.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SimpleNameSyntaxExtensions
- {
- public static ExpressionSyntax GetLeftSideOfDot(this SimpleNameSyntax name)
- {
- if (name.IsMemberAccessExpressionName())
- {
- return ((MemberAccessExpressionSyntax)name.Parent).Expression;
- }
- else if (name.IsRightSideOfQualifiedName())
- {
- return ((QualifiedNameSyntax)name.Parent).Left;
- }
- else
- {
- return ((QualifiedCrefSyntax)name.Parent.Parent).Container;
- }
- }
-
- // Returns true if this looks like a possible type name that is on it's own (i.e. not after
- // a dot). This function is not exhaustive and additional checks may be added if they are
- // beleived to be valuable.
- public static bool LooksLikeStandaloneTypeName(this SimpleNameSyntax simpleName)
- {
- if (simpleName == null)
- {
- return false;
- }
-
- // Isn't stand-alone if it's on the right of a dot/arrow
- if (simpleName.IsRightSideOfDotOrArrow())
- {
- return false;
- }
-
- // type names can't be invoked.
- if (simpleName.IsParentKind(SyntaxKind.InvocationExpression) &&
- ((InvocationExpressionSyntax)simpleName.Parent).Expression == simpleName)
- {
- return false;
- }
-
- // type names can't be indexed into.
- if (simpleName.IsParentKind(SyntaxKind.ElementAccessExpression) &&
- ((ElementAccessExpressionSyntax)simpleName.Parent).Expression == simpleName)
- {
- return false;
- }
-
- // Looks good. However, feel free to add additional checks if this funciton is too
- // lenient in some circumstances.
- return true;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SourceTextExtensions.cs b/main/src/addins/CSharpBinding/Util/SourceTextExtensions.cs
deleted file mode 100644
index 94bd2c4e6a..0000000000
--- a/main/src/addins/CSharpBinding/Util/SourceTextExtensions.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Threading;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal static class SourceTextExtensions
- {
- /// <summary>
- /// Returns the leading whitespace of the line located at the specified position in the given snapshot.
- /// </summary>
- public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position)
- {
- // Contract.ThrowIfNull(text);
-
- var line = text.Lines.GetLineFromPosition(position);
- var linePosition = line.GetFirstNonWhitespacePosition();
- if (!linePosition.HasValue)
- {
- return line.ToString();
- }
-
- var lineText = line.ToString();
- return lineText.Substring(0, linePosition.Value - line.Start);
- }
-
- public static void GetLineAndOffset(this SourceText text, int position, out int lineNumber, out int offset)
- {
- var line = text.Lines.GetLineFromPosition(position);
-
- lineNumber = line.LineNumber;
- offset = position - line.Start;
- }
-
- public static void GetLinesAndOffsets(
- this SourceText text,
- TextSpan textSpan,
- out int startLineNumber,
- out int startOffset,
- out int endLineNumber,
- out int endOffset)
- {
- text.GetLineAndOffset(textSpan.Start, out startLineNumber, out startOffset);
- text.GetLineAndOffset(textSpan.End, out endLineNumber, out endOffset);
- }
-
- public static bool OverlapsHiddenPosition(
- this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken)
- {
- var result = TryOverlapsHiddenPosition(text, span, isPositionHidden, cancellationToken);
- cancellationToken.ThrowIfCancellationRequested();
- return result;
- }
-
- /// <summary>
- /// Same as OverlapsHiddenPosition but doesn't throw on cancellation. Instead, returns false
- /// in that case.
- /// </summary>
- public static bool TryOverlapsHiddenPosition(
- this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden,
- CancellationToken cancellationToken)
- {
- var startLineNumber = text.Lines.IndexOf(span.Start);
- var endLineNumber = text.Lines.IndexOf(span.End);
-
- // NOTE(cyrusn): It's safe to examine the start of a line because you can't have a line
- // with both a pp directive and code on it. so, for example, if a node crosses a region
- // then it must be the case that the start of some line from the start of the node to
- // the end is hidden. i.e.:
- #if false
- ' class C
- ' {
- '#line hidden
- ' }
- '#line default
- #endif
- // The start of the line with the } on it is hidden, and thus the node overlaps a hidden
- // region.
-
- for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++)
- {
- if (cancellationToken.IsCancellationRequested)
- {
- break;
- }
-
- var linePosition = text.Lines[lineNumber].Start;
- var isHidden = isPositionHidden(linePosition, cancellationToken);
- if (isHidden)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static TextChangeRange GetEncompassingTextChangeRange(this SourceText newText, SourceText oldText)
- {
- var ranges = newText.GetChangeRanges(oldText);
- if (ranges.Count == 0)
- {
- return default(TextChangeRange);
- }
-
- // simple case.
- if (ranges.Count == 1)
- {
- return ranges[0];
- }
-
- return TextChangeRange.Collapse(ranges);
- }
-
- public static int IndexOf(this SourceText text, string value, int startIndex, bool caseSensitive)
- {
- var length = text.Length - value.Length;
- var normalized = caseSensitive ? value : value.ToLowerInvariant();
-
- for (var i = startIndex; i <= length; i++)
- {
- var match = true;
- for (var j = 0; j < normalized.Length; j++)
- {
- // just use indexer of source text. perf of indexer depends on actual implementation of SourceText.
- // * all of our implementation at editor layer should provide either O(1) or O(logn).
- //
- // only one implementation we have that could have bad indexer perf is CompositeText with heavily modified text
- // at compiler layer but I believe that being used in find all reference will be very rare if not none.
- if (!Match(normalized[j], text[i + j], caseSensitive))
- {
- match = false;
- break;
- }
- }
-
- if (match)
- {
- return i;
- }
- }
-
- return -1;
- }
-
- public static int LastIndexOf(this SourceText text, string value, int startIndex, bool caseSensitive)
- {
- var normalized = caseSensitive ? value : value.ToLowerInvariant();
- startIndex = startIndex + normalized.Length > text.Length
- ? text.Length - normalized.Length
- : startIndex;
-
- for (var i = startIndex; i >= 0; i--)
- {
- var match = true;
- for (var j = 0; j < normalized.Length; j++)
- {
- // just use indexer of source text. perf of indexer depends on actual implementation of SourceText.
- // * all of our implementation at editor layer should provide either O(1) or O(logn).
- //
- // only one implementation we have that could have bad indexer perf is CompositeText with heavily modified text
- // at compiler layer but I believe that being used in find all reference will be very rare if not none.
- if (!Match(normalized[j], text[i + j], caseSensitive))
- {
- match = false;
- break;
- }
- }
-
- if (match)
- {
- return i;
- }
- }
-
- return -1;
- }
-
- private static readonly TextInfo s_invariantTextInfo = CultureInfo.InvariantCulture.TextInfo;
-
- private static bool Match(char nomalizedLeft, char right, bool caseSensitive)
- {
- return caseSensitive ? nomalizedLeft == right : nomalizedLeft == s_invariantTextInfo.ToLower(right);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SpecializedCollections.cs b/main/src/addins/CSharpBinding/Util/SpecializedCollections.cs
deleted file mode 100644
index 18160000b6..0000000000
--- a/main/src/addins/CSharpBinding/Util/SpecializedCollections.cs
+++ /dev/null
@@ -1,673 +0,0 @@
-//
-// SpecializedCollections.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-using System.Collections;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static partial class SpecializedCollections
- {
- public static readonly byte[] EmptyBytes = EmptyArray<byte>();
- public static readonly object[] EmptyObjects = EmptyArray<object>();
-
- public static T[] EmptyArray<T>()
- {
- return Empty.Array<T>.Instance;
- }
-
- public static IEnumerator<T> EmptyEnumerator<T>()
- {
- return Empty.Enumerator<T>.Instance;
- }
-
- public static IEnumerable<T> EmptyEnumerable<T>()
- {
- return Empty.List<T>.Instance;
- }
-
- public static ICollection<T> EmptyCollection<T>()
- {
- return Empty.List<T>.Instance;
- }
-
- public static IList<T> EmptyList<T>()
- {
- return Empty.List<T>.Instance;
- }
-
- public static IReadOnlyList<T> EmptyReadOnlyList<T>()
- {
- return Empty.List<T>.Instance;
- }
-
- public static ISet<T> EmptySet<T>()
- {
- return Empty.Set<T>.Instance;
- }
-
- public static IDictionary<TKey, TValue> EmptyDictionary<TKey, TValue>()
- {
- return Empty.Dictionary<TKey, TValue>.Instance;
- }
-
- public static IEnumerable<T> SingletonEnumerable<T>(T value)
- {
- return new Singleton.Collection<T>(value);
- }
-
- public static ICollection<T> SingletonCollection<T>(T value)
- {
- return new Singleton.Collection<T>(value);
- }
-
- public static IEnumerator<T> SingletonEnumerator<T>(T value)
- {
- return new Singleton.Enumerator<T>(value);
- }
-
- public static IEnumerable<T> ReadOnlyEnumerable<T>(IEnumerable<T> values)
- {
- return new ReadOnly.Enumerable<IEnumerable<T>, T>(values);
- }
-
- public static ICollection<T> ReadOnlyCollection<T>(ICollection<T> collection)
- {
- return collection == null || collection.Count == 0
- ? EmptyCollection<T>()
- : new ReadOnly.Collection<ICollection<T>, T>(collection);
- }
-
- public static ISet<T> ReadOnlySet<T>(ISet<T> set)
- {
- return set == null || set.Count == 0
- ? EmptySet<T>()
- : new ReadOnly.Set<ISet<T>, T>(set);
- }
-
- public static ISet<T> ReadOnlySet<T>(IEnumerable<T> values)
- {
- if (values is ISet<T>)
- {
- return ReadOnlySet((ISet<T>)values);
- }
-
- HashSet<T> result = null;
- foreach (var item in values)
- {
- result = result ?? new HashSet<T>();
- result.Add(item);
- }
-
- return ReadOnlySet(result);
- }
-
- private partial class Empty
- {
- internal class Array<T>
- {
- public static readonly T[] Instance = new T[0];
- }
-
- internal class Collection<T> : Enumerable<T>, ICollection<T>
- {
- public static readonly ICollection<T> Instance = new Collection<T>();
-
- protected Collection()
- {
- }
-
- public void Add(T item)
- {
- throw new NotSupportedException();
- }
-
- public void Clear()
- {
- }
-
- public bool Contains(T item)
- {
- return false;
- }
-
- public void CopyTo(T[] array, int arrayIndex)
- {
- }
-
- public int Count
- {
- get
- {
- return 0;
- }
- }
-
- public bool IsReadOnly
- {
- get
- {
- return true;
- }
- }
-
- public bool Remove(T item)
- {
- throw new NotSupportedException();
- }
- }
-
- internal class Dictionary<TKey, TValue> : Collection<KeyValuePair<TKey, TValue>>, IDictionary<TKey, TValue>
- {
- public static readonly new IDictionary<TKey, TValue> Instance = new Dictionary<TKey, TValue>();
-
- private Dictionary()
- {
- }
-
- public void Add(TKey key, TValue value)
- {
- throw new NotSupportedException();
- }
-
- public bool ContainsKey(TKey key)
- {
- return false;
- }
-
- public ICollection<TKey> Keys
- {
- get
- {
- return Collection<TKey>.Instance;
- }
- }
-
- public bool Remove(TKey key)
- {
- throw new NotSupportedException();
- }
-
- public bool TryGetValue(TKey key, out TValue value)
- {
- value = default(TValue);
- return false;
- }
-
- public ICollection<TValue> Values
- {
- get
- {
- return Collection<TValue>.Instance;
- }
- }
-
- public TValue this[TKey key]
- {
- get
- {
- throw new NotSupportedException();
- }
-
- set
- {
- throw new NotSupportedException();
- }
- }
-
- }
-
- internal class Enumerable<T> : IEnumerable<T>
- {
- // PERF: cache the instance of enumerator.
- // accessing a generic static field is kinda slow from here,
- // but since empty enumerables are singletons, there is no harm in having
- // one extra instance field
- private readonly IEnumerator<T> _enumerator = Enumerator<T>.Instance;
-
- public IEnumerator<T> GetEnumerator()
- {
- return _enumerator;
- }
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-
- internal class Enumerator : IEnumerator
- {
- public static readonly IEnumerator Instance = new Enumerator();
-
- protected Enumerator()
- {
- }
-
- public object Current
- {
- get
- {
- throw new InvalidOperationException();
- }
- }
-
- public bool MoveNext()
- {
- return false;
- }
-
- public void Reset()
- {
- throw new InvalidOperationException();
- }
- }
-
- internal class Enumerator<T> : Enumerator, IEnumerator<T>
- {
- public static new readonly IEnumerator<T> Instance = new Enumerator<T>();
-
- protected Enumerator()
- {
- }
-
- public new T Current
- {
- get
- {
- throw new InvalidOperationException();
- }
- }
-
- public void Dispose()
- {
- }
- }
-
- internal class List<T> : Collection<T>, IList<T>, IReadOnlyList<T>
- {
- public static readonly new List<T> Instance = new List<T>();
-
- protected List()
- {
- }
-
- public int IndexOf(T item)
- {
- return -1;
- }
-
- public void Insert(int index, T item)
- {
- throw new NotSupportedException();
- }
-
- public void RemoveAt(int index)
- {
- throw new NotSupportedException();
- }
-
- public T this[int index]
- {
- get
- {
- throw new ArgumentOutOfRangeException("index");
- }
-
- set
- {
- throw new NotSupportedException();
- }
- }
- }
-
- internal class Set<T> : Collection<T>, ISet<T>
- {
- public static readonly new ISet<T> Instance = new Set<T>();
-
- protected Set()
- {
- }
-
- public new bool Add(T item)
- {
- throw new NotImplementedException();
- }
-
- public void ExceptWith(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public void IntersectWith(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public bool IsProperSubsetOf(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public bool IsProperSupersetOf(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public bool IsSubsetOf(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public bool IsSupersetOf(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public bool Overlaps(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public bool SetEquals(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public void SymmetricExceptWith(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public void UnionWith(IEnumerable<T> other)
- {
- throw new NotImplementedException();
- }
-
- public new System.Collections.IEnumerator GetEnumerator()
- {
- return Set<T>.Instance.GetEnumerator();
- }
- }
- }
-
- private static partial class ReadOnly
- {
- internal class Collection<TUnderlying, T> : Enumerable<TUnderlying, T>, ICollection<T>
- where TUnderlying : ICollection<T>
- {
- public Collection(TUnderlying underlying)
- : base(underlying)
- {
- }
-
- public void Add(T item)
- {
- throw new NotSupportedException();
- }
-
- public void Clear()
- {
- throw new NotSupportedException();
- }
-
- public bool Contains(T item)
- {
- return this.Underlying.Contains(item);
- }
-
- public void CopyTo(T[] array, int arrayIndex)
- {
- this.Underlying.CopyTo(array, arrayIndex);
- }
-
- public int Count
- {
- get
- {
- return this.Underlying.Count;
- }
- }
-
- public bool IsReadOnly
- {
- get
- {
- return true;
- }
- }
-
- public bool Remove(T item)
- {
- throw new NotSupportedException();
- }
- }
-
- internal class Enumerable<TUnderlying> : IEnumerable
- where TUnderlying : IEnumerable
- {
- protected readonly TUnderlying Underlying;
-
- public Enumerable(TUnderlying underlying)
- {
- this.Underlying = underlying;
- }
-
- public IEnumerator GetEnumerator()
- {
- return this.Underlying.GetEnumerator();
- }
- }
-
- internal class Enumerable<TUnderlying, T> : Enumerable<TUnderlying>, IEnumerable<T>
- where TUnderlying : IEnumerable<T>
- {
- public Enumerable(TUnderlying underlying)
- : base(underlying)
- {
- }
-
- public new IEnumerator<T> GetEnumerator()
- {
- return this.Underlying.GetEnumerator();
- }
- }
-
- internal class Set<TUnderlying, T> : Collection<TUnderlying, T>, ISet<T>
- where TUnderlying : ISet<T>
- {
- public Set(TUnderlying underlying)
- : base(underlying)
- {
- }
-
- public new bool Add(T item)
- {
- throw new NotSupportedException();
- }
-
- public void ExceptWith(IEnumerable<T> other)
- {
- throw new NotSupportedException();
- }
-
- public void IntersectWith(IEnumerable<T> other)
- {
- throw new NotSupportedException();
- }
-
- public bool IsProperSubsetOf(IEnumerable<T> other)
- {
- return Underlying.IsProperSubsetOf(other);
- }
-
- public bool IsProperSupersetOf(IEnumerable<T> other)
- {
- return Underlying.IsProperSupersetOf(other);
- }
-
- public bool IsSubsetOf(IEnumerable<T> other)
- {
- return Underlying.IsSubsetOf(other);
- }
-
- public bool IsSupersetOf(IEnumerable<T> other)
- {
- return Underlying.IsSupersetOf(other);
- }
-
- public bool Overlaps(IEnumerable<T> other)
- {
- return Underlying.Overlaps(other);
- }
-
- public bool SetEquals(IEnumerable<T> other)
- {
- return Underlying.SetEquals(other);
- }
-
- public void SymmetricExceptWith(IEnumerable<T> other)
- {
- throw new NotSupportedException();
- }
-
- public void UnionWith(IEnumerable<T> other)
- {
- throw new NotSupportedException();
- }
- }
-
-
- }
-
- private static partial class Singleton
- {
- internal sealed class Collection<T> : ICollection<T>, IReadOnlyCollection<T>
- {
- private T _loneValue;
-
- public Collection(T value)
- {
- _loneValue = value;
- }
-
- public void Add(T item)
- {
- throw new NotSupportedException();
- }
-
- public void Clear()
- {
- throw new NotSupportedException();
- }
-
- public bool Contains(T item)
- {
- return EqualityComparer<T>.Default.Equals(_loneValue, item);
- }
-
- public void CopyTo(T[] array, int arrayIndex)
- {
- array[arrayIndex] = _loneValue;
- }
-
- public int Count
- {
- get { return 1; }
- }
-
- public bool IsReadOnly
- {
- get { return true; }
- }
-
- public bool Remove(T item)
- {
- throw new NotSupportedException();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- return new Enumerator<T>(_loneValue);
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
- internal class Enumerator<T> : IEnumerator<T>
- {
- private T _loneValue;
- private bool _moveNextCalled;
-
- public Enumerator(T value)
- {
- _loneValue = value;
- _moveNextCalled = false;
- }
-
- public T Current
- {
- get
- {
- return _loneValue;
- }
- }
-
- object IEnumerator.Current
- {
- get
- {
- return _loneValue;
- }
- }
-
- public void Dispose()
- {
- }
-
- public bool MoveNext()
- {
- if (!_moveNextCalled)
- {
- _moveNextCalled = true;
- return true;
- }
-
- return false;
- }
-
- public void Reset()
- {
- _moveNextCalled = false;
- }
- }
-
- }
-
- }
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/Util/SpeculationAnalyzer.cs b/main/src/addins/CSharpBinding/Util/SpeculationAnalyzer.cs
deleted file mode 100644
index cbca2f38cd..0000000000
--- a/main/src/addins/CSharpBinding/Util/SpeculationAnalyzer.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-//
-// SpeculationAnalyzer.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class SpeculationAnalyzer
- {
- readonly static Type typeInfo;
- readonly static MethodInfo symbolsForOriginalAndReplacedNodesAreCompatibleMethod;
- readonly static MethodInfo replacementChangesSemanticsMethod;
- readonly object instance;
-
- static SpeculationAnalyzer ()
- {
- Type[] abstractSpeculationAnalyzerGenericParams = new[] {
- Type.GetType ("Microsoft.CodeAnalysis.SyntaxNode" + ReflectionNamespaces.CAAsmName, true),
- Type.GetType ("Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax" + ReflectionNamespaces.CACSharpAsmName, true),
- Type.GetType ("Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax" + ReflectionNamespaces.CACSharpAsmName, true),
- Type.GetType ("Microsoft.CodeAnalysis.CSharp.Syntax.AttributeSyntax" + ReflectionNamespaces.CACSharpAsmName, true),
- Type.GetType ("Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax" + ReflectionNamespaces.CACSharpAsmName, true),
- Type.GetType ("Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax" + ReflectionNamespaces.CACSharpAsmName, true),
- Type.GetType ("Microsoft.CodeAnalysis.CSharp.Syntax.ThrowStatementSyntax" + ReflectionNamespaces.CACSharpAsmName, true),
- Type.GetType ("Microsoft.CodeAnalysis.SemanticModel" + ReflectionNamespaces.CAAsmName, true),
- Type.GetType ("Microsoft.CodeAnalysis.CSharp.Conversion" + ReflectionNamespaces.CACSharpAsmName, true)
- };
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.Shared.Utilities.AbstractSpeculationAnalyzer`9" + ReflectionNamespaces.WorkspacesAsmName, true)
- .MakeGenericType (abstractSpeculationAnalyzerGenericParams);
-
- symbolsForOriginalAndReplacedNodesAreCompatibleMethod = typeInfo.GetMethod ("SymbolsForOriginalAndReplacedNodesAreCompatible", BindingFlags.Public | BindingFlags.Instance);
- replacementChangesSemanticsMethod = typeInfo.GetMethod ("ReplacementChangesSemantics", BindingFlags.Public | BindingFlags.Instance);
- symbolInfosAreCompatibleMethod = typeInfo.GetMethod ("SymbolInfosAreCompatible", BindingFlags.Public | BindingFlags.Static);
-
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CSharp.Utilities.SpeculationAnalyzer" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- createSpeculativeSemanticModelForNodeMethod = typeInfo.GetMethod ("CreateSpeculativeSemanticModelForNode", BindingFlags.Public | BindingFlags.Static, null, new [] {typeof (SyntaxNode), typeof (SyntaxNode), typeof (SemanticModel)}, null);
- }
-
- public SpeculationAnalyzer (ExpressionSyntax expression, ExpressionSyntax newExpression, SemanticModel semanticModel, CancellationToken cancellationToken, bool skipVerificationForReplacedNode = false, bool failOnOverloadResolutionFailuresInOriginalCode = false)
- {
- instance = Activator.CreateInstance (typeInfo, new object[] {
- expression,
- newExpression,
- semanticModel,
- cancellationToken,
- skipVerificationForReplacedNode,
- failOnOverloadResolutionFailuresInOriginalCode
- });
- }
-
- static MethodInfo symbolInfosAreCompatibleMethod;
-
- public static bool SymbolInfosAreCompatible(SymbolInfo originalSymbolInfo, SymbolInfo newSymbolInfo, bool performEquivalenceCheck, bool requireNonNullSymbols = false)
- {
- try {
- return (bool)symbolInfosAreCompatibleMethod.Invoke (null, new object [] { originalSymbolInfo, newSymbolInfo, performEquivalenceCheck, requireNonNullSymbols });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- public bool SymbolsForOriginalAndReplacedNodesAreCompatible ()
- {
- try {
- return (bool)symbolsForOriginalAndReplacedNodesAreCompatibleMethod.Invoke (instance, new object[0]);
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- public bool ReplacementChangesSemantics ()
- {
- try {
- return (bool)replacementChangesSemanticsMethod.Invoke (instance, new object[0]);
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- readonly static MethodInfo createSpeculativeSemanticModelForNodeMethod;
-
- public static SemanticModel CreateSpeculativeSemanticModelForNode(SyntaxNode originalNode, SyntaxNode nodeToSpeculate, SemanticModel semanticModel)
- {
- return (SemanticModel)createSpeculativeSemanticModelForNodeMethod.Invoke (null, new object[] {originalNode, nodeToSpeculate, semanticModel });
- }
-
- public static bool CanSpeculateOnNode(SyntaxNode node)
- {
- return (node is StatementSyntax && node.Kind() != SyntaxKind.Block) ||
- node is TypeSyntax ||
- node is CrefSyntax ||
- node.Kind() == SyntaxKind.Attribute ||
- node.Kind() == SyntaxKind.ThisConstructorInitializer ||
- node.Kind() == SyntaxKind.BaseConstructorInitializer ||
- node.Kind() == SyntaxKind.EqualsValueClause ||
- node.Kind() == SyntaxKind.ArrowExpressionClause;
- }
-
- }
-
-}
diff --git a/main/src/addins/CSharpBinding/Util/StringExtensions.cs b/main/src/addins/CSharpBinding/Util/StringExtensions.cs
deleted file mode 100644
index 29cf7ed7f1..0000000000
--- a/main/src/addins/CSharpBinding/Util/StringExtensions.cs
+++ /dev/null
@@ -1,551 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Immutable;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using System.Diagnostics;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Simplification;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class StringExtensions
- {
- public static int? GetFirstNonWhitespaceOffset(this string line)
- {
- // Contract.ThrowIfNull(line);
-
- for (int i = 0; i < line.Length; i++)
- {
- if (!char.IsWhiteSpace(line[i]))
- {
- return i;
- }
- }
-
- return null;
- }
-
- public static string GetLeadingWhitespace(this string lineText)
- {
- // Contract.ThrowIfNull(lineText);
-
- var firstOffset = lineText.GetFirstNonWhitespaceOffset();
-
- return firstOffset.HasValue
- ? lineText.Substring(0, firstOffset.Value)
- : lineText;
- }
-
- public static int GetTextColumn(this string text, int tabSize, int initialColumn)
- {
- var lineText = text.GetLastLineText();
- if (text != lineText)
- {
- return lineText.GetColumnFromLineOffset(lineText.Length, tabSize);
- }
-
- return text.ConvertTabToSpace(tabSize, initialColumn, text.Length) + initialColumn;
- }
-
- public static int ConvertTabToSpace(this string textSnippet, int tabSize, int initialColumn, int endPosition)
- {
- // Contract.Requires(tabSize > 0);
- // Contract.Requires(endPosition >= 0 && endPosition <= textSnippet.Length);
-
- int column = initialColumn;
-
- // now this will calculate indentation regardless of actual content on the buffer except TAB
- for (int i = 0; i < endPosition; i++)
- {
- if (textSnippet[i] == '\t')
- {
- column += tabSize - column % tabSize;
- }
- else
- {
- column++;
- }
- }
-
- return column - initialColumn;
- }
-
- public static int IndexOf(this string text, Func<char, bool> predicate)
- {
- if (text == null)
- {
- return -1;
- }
-
- for (int i = 0; i < text.Length; i++)
- {
- if (predicate(text[i]))
- {
- return i;
- }
- }
-
- return -1;
- }
-
- public static string GetFirstLineText(this string text)
- {
- var lineBreak = text.IndexOf('\n');
- if (lineBreak < 0)
- {
- return text;
- }
-
- return text.Substring(0, lineBreak + 1);
- }
-
- public static string GetLastLineText(this string text)
- {
- var lineBreak = text.LastIndexOf('\n');
- if (lineBreak < 0)
- {
- return text;
- }
-
- return text.Substring(lineBreak + 1);
- }
-
- public static bool ContainsLineBreak(this string text)
- {
- foreach (char ch in text)
- {
- if (ch == '\n' || ch == '\r')
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static int GetNumberOfLineBreaks(this string text)
- {
- int lineBreaks = 0;
- for (int i = 0; i < text.Length; i++)
- {
- if (text[i] == '\n')
- {
- lineBreaks++;
- }
- else if (text[i] == '\r')
- {
- if (i + 1 == text.Length || text[i + 1] != '\n')
- {
- lineBreaks++;
- }
- }
- }
-
- return lineBreaks;
- }
-
- public static bool ContainsTab(this string text)
- {
- // PERF: Tried replacing this with "text.IndexOf('\t')>=0", but that was actually slightly slower
- foreach (char ch in text)
- {
- if (ch == '\t')
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static ImmutableArray<SymbolDisplayPart> ToSymbolDisplayParts(this string text)
- {
- return ImmutableArray.Create<SymbolDisplayPart>(new SymbolDisplayPart(SymbolDisplayPartKind.Text, null, text));
- }
-
- public static int GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine(this string line, int tabSize)
- {
- var firstNonWhitespaceChar = line.GetFirstNonWhitespaceOffset();
-
- if (firstNonWhitespaceChar.HasValue)
- {
- return line.GetColumnFromLineOffset(firstNonWhitespaceChar.Value, tabSize);
- }
- else
- {
- // It's all whitespace, so go to the end
- return line.GetColumnFromLineOffset(line.Length, tabSize);
- }
- }
-
- public static int GetColumnFromLineOffset(this string line, int endPosition, int tabSize)
- {
-// Contract.ThrowIfNull(line);
-// Contract.ThrowIfFalse(0 <= endPosition && endPosition <= line.Length);
-// Contract.ThrowIfFalse(tabSize > 0);
-
- return ConvertTabToSpace(line, tabSize, 0, endPosition);
- }
-
- public static int GetLineOffsetFromColumn(this string line, int column, int tabSize)
- {
-// Contract.ThrowIfNull(line);
-// Contract.ThrowIfFalse(column >= 0);
-// Contract.ThrowIfFalse(tabSize > 0);
-
- var currentColumn = 0;
-
- for (int i = 0; i < line.Length; i++)
- {
- if (currentColumn >= column)
- {
- return i;
- }
-
- if (line[i] == '\t')
- {
- currentColumn += tabSize - (currentColumn % tabSize);
- }
- else
- {
- currentColumn++;
- }
- }
-
- // We're asking for a column past the end of the line, so just go to the end.
- return line.Length;
- }
-
-// public static void AppendToAliasNameSet(this string alias, ImmutableHashSet<string>.Builder builder)
-// {
-// if (string.IsNullOrWhiteSpace(alias))
-// {
-// return;
-// }
-//
-// builder.Add(alias);
-//
-// var caseSensitive = builder.KeyComparer == StringComparer.Ordinal;
-// // Contract.Requires(builder.KeyComparer == StringComparer.Ordinal || builder.KeyComparer == StringComparer.OrdinalIgnoreCase);
-//
-// string aliasWithoutAttribute;
-// if (alias.TryGetWithoutAttributeSuffix(caseSensitive, out aliasWithoutAttribute))
-// {
-// builder.Add(aliasWithoutAttribute);
-// return;
-// }
-//
-// builder.Add(alias.GetWithSingleAttributeSuffix(caseSensitive));
-// }
-
-
- private static ImmutableArray<string> s_lazyNumerals;
-
- internal static string GetNumeral(int number)
- {
- var numerals = s_lazyNumerals;
- if (numerals.IsDefault)
- {
- numerals = ImmutableArray.Create("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
- ImmutableInterlocked.InterlockedInitialize(ref s_lazyNumerals, numerals);
- }
-
- Debug.Assert(number >= 0);
- return (number < numerals.Length) ? numerals[number] : number.ToString();
- }
-
- public static string Join(this IEnumerable<string> source, string separator)
- {
- if (source == null)
- {
- throw new ArgumentNullException("source");
- }
-
- if (separator == null)
- {
- throw new ArgumentNullException("separator");
- }
-
- return string.Join(separator, source);
- }
-
- public static bool LooksLikeInterfaceName(this string name)
- {
- return name.Length >= 3 && name[0] == 'I' && char.IsUpper(name[1]) && char.IsLower(name[2]);
- }
-
- public static bool LooksLikeTypeParameterName(this string name)
- {
- return name.Length >= 3 && name[0] == 'T' && char.IsUpper(name[1]) && char.IsLower(name[2]);
- }
-
- private static readonly Func<char, char> s_toLower = char.ToLower;
- private static readonly Func<char, char> s_toUpper = char.ToUpper;
-
- public static string ToPascalCase(
- this string shortName,
- bool trimLeadingTypePrefix = true)
- {
- return ConvertCase(shortName, trimLeadingTypePrefix, s_toUpper);
- }
-
- public static string ToCamelCase(
- this string shortName,
- bool trimLeadingTypePrefix = true)
- {
- return ConvertCase(shortName, trimLeadingTypePrefix, s_toLower);
- }
-
- private static string ConvertCase(
- this string shortName,
- bool trimLeadingTypePrefix,
- Func<char, char> convert)
- {
- // Special case the common .net pattern of "IFoo" as a type name. In this case we
- // want to generate "foo" as the parameter name.
- if (!string.IsNullOrEmpty(shortName))
- {
- if (trimLeadingTypePrefix && (shortName.LooksLikeInterfaceName() || shortName.LooksLikeTypeParameterName()))
- {
- return convert(shortName[1]) + shortName.Substring(2);
- }
-
- if (convert(shortName[0]) != shortName[0])
- {
- return convert(shortName[0]) + shortName.Substring(1);
- }
- }
-
- return shortName;
- }
-
- internal static bool IsValidClrTypeName(this string name)
- {
- return !string.IsNullOrEmpty(name) && name.IndexOf('\0') == -1;
- }
-
- /// <summary>
- /// Checks if the given name is a sequence of valid CLR names separated by a dot.
- /// </summary>
- internal static bool IsValidClrNamespaceName(this string name)
- {
- if (string.IsNullOrEmpty(name))
- {
- return false;
- }
-
- char lastChar = '.';
- foreach (char c in name)
- {
- if (c == '\0' || (c == '.' && lastChar == '.'))
- {
- return false;
- }
-
- lastChar = c;
- }
-
- return lastChar != '.';
- }
-
- internal static string GetWithSingleAttributeSuffix(
- this string name,
- bool isCaseSensitive)
- {
- string cleaned = name;
- while ((cleaned = GetWithoutAttributeSuffix(cleaned, isCaseSensitive)) != null)
- {
- name = cleaned;
- }
-
- return name + "Attribute";
- }
-
- internal static bool TryGetWithoutAttributeSuffix(
- this string name,
- out string result)
- {
- return TryGetWithoutAttributeSuffix(name, isCaseSensitive: true, result: out result);
- }
-
- internal static string GetWithoutAttributeSuffix(
- this string name,
- bool isCaseSensitive)
- {
- string result;
- return TryGetWithoutAttributeSuffix(name, isCaseSensitive, out result) ? result : null;
- }
-
- internal static bool TryGetWithoutAttributeSuffix(
- this string name,
- bool isCaseSensitive,
- out string result)
- {
- const string AttributeSuffix = "Attribute";
- var comparison = isCaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
- if (name.Length > AttributeSuffix.Length && name.EndsWith(AttributeSuffix, comparison))
- {
- result = name.Substring(0, name.Length - AttributeSuffix.Length);
- return true;
- }
-
- result = null;
- return false;
- }
-
- internal static bool IsValidUnicodeString(this string str)
- {
- int i = 0;
- while (i < str.Length)
- {
- char c = str[i++];
-
- // (high surrogate, low surrogate) makes a valid pair, anything else is invalid:
- if (char.IsHighSurrogate(c))
- {
- if (i < str.Length && char.IsLowSurrogate(str[i]))
- {
- i++;
- }
- else
- {
- // high surrogate not followed by low surrogate
- return false;
- }
- }
- else if (char.IsLowSurrogate(c))
- {
- // previous character wasn't a high surrogate
- return false;
- }
- }
-
- return true;
- }
-
- /// <summary>
- /// Remove one set of leading and trailing double quote characters, if both are present.
- /// </summary>
- internal static string Unquote(this string arg)
- {
- bool quoted;
- return Unquote(arg, out quoted);
- }
-
- internal static string Unquote(this string arg, out bool quoted)
- {
- if (arg.Length > 1 && arg[0] == '"' && arg[arg.Length - 1] == '"')
- {
- quoted = true;
- return arg.Substring(1, arg.Length - 2);
- }
- else
- {
- quoted = false;
- return arg;
- }
- }
-
- internal static int IndexOfBalancedParenthesis(this string str, int openingOffset, char closing)
- {
- char opening = str[openingOffset];
-
- int depth = 1;
- for (int i = openingOffset + 1; i < str.Length; i++)
- {
- var c = str[i];
- if (c == opening)
- {
- depth++;
- }
- else if (c == closing)
- {
- depth--;
- if (depth == 0)
- {
- return i;
- }
- }
- }
-
- return -1;
- }
-
- // String isn't IEnumerable<char> in the current Portable profile.
- internal static char First(this string arg)
- {
- return arg[0];
- }
-
- // String isn't IEnumerable<char> in the current Portable profile.
- internal static char Last(this string arg)
- {
- return arg[arg.Length - 1];
- }
-
- // String isn't IEnumerable<char> in the current Portable profile.
- internal static bool All(this string arg, Predicate<char> predicate)
- {
- foreach (char c in arg)
- {
- if (!predicate(c))
- {
- return false;
- }
- }
-
- return true;
- }
-
- public static string EscapeIdentifier(
- this string identifier,
- bool isQueryContext = false)
- {
- var nullIndex = identifier.IndexOf('\0');
- if (nullIndex >= 0)
- {
- identifier = identifier.Substring(0, nullIndex);
- }
-
- var needsEscaping = SyntaxFacts.GetKeywordKind(identifier) != SyntaxKind.None;
-
- // Check if we need to escape this contextual keyword
- needsEscaping = needsEscaping || (isQueryContext && SyntaxFacts.IsQueryContextualKeyword(SyntaxFacts.GetContextualKeywordKind(identifier)));
-
- return needsEscaping ? "@" + identifier : identifier;
- }
-
- public static SyntaxToken ToIdentifierToken (
- this string identifier,
- bool isQueryContext = false)
- {
- var escaped = identifier.EscapeIdentifier (isQueryContext);
-
- if (escaped.Length == 0 || escaped [0] != '@') {
- return SyntaxFactory.Identifier (escaped);
- }
-
- var unescaped = identifier.StartsWith ("@", StringComparison.Ordinal)
- ? identifier.Substring (1)
- : identifier;
-
- var token = SyntaxFactory.Identifier (
- default(SyntaxTriviaList), SyntaxKind.None, "@" + unescaped, unescaped, default(SyntaxTriviaList));
-
- if (!identifier.StartsWith ("@", StringComparison.Ordinal)) {
- token = token.WithAdditionalAnnotations (Simplifier.Annotation);
- }
-
- return token;
- }
-
- public static IdentifierNameSyntax ToIdentifierName (this string identifier)
- {
- return SyntaxFactory.IdentifierName (identifier.ToIdentifierToken ());
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/StringPclExtensions.cs b/main/src/addins/CSharpBinding/Util/StringPclExtensions.cs
deleted file mode 100644
index f0ea6b01b1..0000000000
--- a/main/src/addins/CSharpBinding/Util/StringPclExtensions.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class StringPclExtensions
- {
- public static bool Any(this string source, Func<char, bool> predicate)
- {
- foreach (char ch in source)
- {
- if (predicate(ch))
- return true;
- }
- return false;
- }
-
- public static IEnumerable<char> Take(this string source, int count)
- {
- if (count > source.Length)
- count = source.Length;
- for (int i = 0; i < count; i++)
- {
- yield return source[i];
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SymbolEquivalenceComparer.cs b/main/src/addins/CSharpBinding/Util/SymbolEquivalenceComparer.cs
deleted file mode 100644
index 81f4ad6d3e..0000000000
--- a/main/src/addins/CSharpBinding/Util/SymbolEquivalenceComparer.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// SymbolEquivalenceComparer.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using System.Reflection;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SymbolEquivalenceComparer
- {
- public static readonly IEqualityComparer<ISymbol> Instance;
- public static readonly IEqualityComparer<ISymbol> IgnoreAssembliesInstance;
-
- static SymbolEquivalenceComparer ()
- {
- var typeInfo = Type.GetType("Microsoft.CodeAnalysis.Shared.Utilities.SymbolEquivalenceComparer" + ReflectionNamespaces.WorkspacesAsmName, true);
- var instanceField = typeInfo.GetField ("Instance", BindingFlags.Static | BindingFlags.Public);
- Instance = (IEqualityComparer<ISymbol> )instanceField.GetValue (null);
-
- var ignoreAssembliesInstanceField = typeInfo.GetField ("IgnoreAssembliesInstance", BindingFlags.Static | BindingFlags.Public);
- IgnoreAssembliesInstance = (IEqualityComparer<ISymbol> )ignoreAssembliesInstanceField.GetValue (null);
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/SymbolExtensions.cs b/main/src/addins/CSharpBinding/Util/SymbolExtensions.cs
deleted file mode 100644
index c6d108853b..0000000000
--- a/main/src/addins/CSharpBinding/Util/SymbolExtensions.cs
+++ /dev/null
@@ -1,1382 +0,0 @@
-//
-// SymbolExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis;
-using System.Linq;
-using System.Collections.Immutable;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-using System.Collections.Generic;
-using System.ComponentModel;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SymbolExtensions
- {
- // public static string GetDocumentationId (this ISymbol symbol)
- // {
- // if (symbol.GetType().FullName != "Microsoft.CodeAnalysis.CSharp.Symbol")
- // return null;
- // var mi = symbol.GetType().GetMethod("GetDocumentationCommentId", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
- // if (mi == null)
- // return null;
- // return (string)mi.Invoke(symbol, null);
- // }
-
- /// <summary>
- /// Gets the EditorBrowsableState of an entity.
- /// </summary>
- /// <returns>
- /// The editor browsable state.
- /// </returns>
- /// <param name='symbol'>
- /// Entity.
- /// </param>
- public static System.ComponentModel.EditorBrowsableState GetEditorBrowsableState(this ISymbol symbol)
- {
- if (symbol == null)
- throw new ArgumentNullException("symbol");
- var browsableState = symbol.GetAttributes().FirstOrDefault(attr => attr.AttributeClass.Name == "EditorBrowsableAttribute" && attr.AttributeClass.ContainingNamespace.MetadataName == "System.ComponentModel");
- if (browsableState != null && browsableState.ConstructorArguments.Length == 1) {
- try {
- return (System.ComponentModel.EditorBrowsableState)browsableState.ConstructorArguments [0].Value;
- } catch {
- }
- }
- return System.ComponentModel.EditorBrowsableState.Always;
- }
-
- /// <summary>
- /// Determines if an entity should be shown in the code completion window. This is the same as:
- /// <c>GetEditorBrowsableState (entity) != System.ComponentModel.EditorBrowsableState.Never</c>
- /// </summary>
- /// <returns>
- /// <c>true</c> if the entity should be shown; otherwise, <c>false</c>.
- /// </returns>
- /// <param name='symbol'>
- /// The entity.
- /// </param>
- public static bool IsEditorBrowsable(this ISymbol symbol)
- {
- if (symbol == null)
- throw new ArgumentNullException("symbol");
- return GetEditorBrowsableState(symbol) != System.ComponentModel.EditorBrowsableState.Never;
- }
- public static ImmutableArray<IParameterSymbol> GetParameters(this ISymbol symbol)
- {
- if (symbol == null)
- throw new ArgumentNullException("symbol");
- var method = symbol as IMethodSymbol;
- if (method != null)
- return method.Parameters;
- var property = symbol as IPropertySymbol;
- if (property != null)
- return property.Parameters;
- return ImmutableArray<IParameterSymbol>.Empty;
- }
-
- public static ImmutableArray<ITypeParameterSymbol> GetTypeParameters(this ISymbol symbol)
- {
- if (symbol == null)
- throw new ArgumentNullException("symbol");
- var type = symbol as INamedTypeSymbol;
- if (type != null)
- return type.TypeParameters;
- var method = symbol as IMethodSymbol;
- if (method != null)
- return method.TypeParameters;
- return ImmutableArray<ITypeParameterSymbol>.Empty;
- }
-
- public static bool IsAnyConstructor(this ISymbol symbol)
- {
- if (symbol == null)
- throw new ArgumentNullException("symbol");
- var method = symbol as IMethodSymbol;
- return method != null && (method.MethodKind == MethodKind.Constructor || method.MethodKind == MethodKind.StaticConstructor);
- }
-
- public static bool IsConstructor(this ISymbol symbol)
- {
- if (symbol == null)
- throw new ArgumentNullException("symbol");
- return symbol is IMethodSymbol && ((IMethodSymbol)symbol).MethodKind == MethodKind.Constructor;
- }
-
- public static bool IsStaticConstructor(this ISymbol symbol)
- {
- if (symbol == null)
- throw new ArgumentNullException("symbol");
- return symbol is IMethodSymbol && ((IMethodSymbol)symbol).MethodKind == MethodKind.StaticConstructor;
- }
-
- public static bool IsDestructor(this ISymbol symbol)
- {
- if (symbol == null)
- throw new ArgumentNullException("symbol");
- return symbol is IMethodSymbol && ((IMethodSymbol)symbol).MethodKind == MethodKind.Destructor;
- }
-
- public static bool IsDelegateType(this ISymbol symbol)
- {
- if (symbol == null)
- throw new ArgumentNullException("symbol");
- return symbol is ITypeSymbol && ((ITypeSymbol)symbol).TypeKind == TypeKind.Delegate;
- }
-
- public static ParameterSyntax GenerateParameterSyntax (this IParameterSymbol symbol)
- {
- var result = SyntaxFactory.Parameter (SyntaxFactory.Identifier (symbol.Name));
- result = result.WithType (symbol.Type.GenerateTypeSyntax ());
- if (symbol.IsThis)
- result = result.WithModifiers(SyntaxFactory.TokenList (SyntaxFactory.Token (SyntaxKind.ThisKeyword)));
- if (symbol.IsParams)
- result = result.WithModifiers(SyntaxFactory.TokenList (SyntaxFactory.Token (SyntaxKind.ParamsKeyword)));
- if (symbol.RefKind == RefKind.Out)
- result = result.WithModifiers(SyntaxFactory.TokenList (SyntaxFactory.Token (SyntaxKind.OutKeyword)));
- if (symbol.RefKind == RefKind.Ref)
- result = result.WithModifiers(SyntaxFactory.TokenList (SyntaxFactory.Token (SyntaxKind.RefKeyword)));
- return result;
- }
-
- public static bool IsType(this ISymbol symbol)
- {
- var typeSymbol = symbol as ITypeSymbol;
- return typeSymbol != null && typeSymbol.IsType;
- }
-
- public static bool IsAccessorMethod(this ISymbol symbol)
- {
- var accessorSymbol = symbol as IMethodSymbol;
- return accessorSymbol != null &&
- (accessorSymbol.MethodKind == MethodKind.PropertySet || accessorSymbol.MethodKind == MethodKind.PropertyGet ||
- accessorSymbol.MethodKind == MethodKind.EventRemove || accessorSymbol.MethodKind == MethodKind.EventAdd);
- }
-
- public static bool IsPublic(this ISymbol symbol)
- {
- return symbol.DeclaredAccessibility == Accessibility.Public;
- }
-
- public static bool IsErrorType(this ISymbol symbol)
- {
- return
- symbol is ITypeSymbol &&
- ((ITypeSymbol)symbol).TypeKind == TypeKind.Error;
- }
-
-
- public static bool IsIndexer(this ISymbol symbol)
- {
- return (symbol as IPropertySymbol)?.IsIndexer == true;
- }
-
- public static bool IsUserDefinedOperator(this ISymbol symbol)
- {
- return (symbol as IMethodSymbol)?.MethodKind == MethodKind.UserDefinedOperator;
- }
-
- public static SymbolVisibility GetResultantVisibility(this ISymbol symbol)
- {
- // Start by assuming it's visible.
- var visibility = SymbolVisibility.Public;
-
- switch (symbol.Kind)
- {
- case SymbolKind.Alias:
- // Aliases are uber private. They're only visible in the same file that they
- // were declared in.
- return SymbolVisibility.Private;
-
- case SymbolKind.Parameter:
- // Parameters are only as visible as their containing symbol
- return GetResultantVisibility(symbol.ContainingSymbol);
-
- case SymbolKind.TypeParameter:
- // Type Parameters are private.
- return SymbolVisibility.Private;
- }
-
- while (symbol != null && symbol.Kind != SymbolKind.Namespace)
- {
- switch (symbol.DeclaredAccessibility)
- {
- // If we see anything private, then the symbol is private.
- case Accessibility.NotApplicable:
- case Accessibility.Private:
- return SymbolVisibility.Private;
-
- // If we see anything internal, then knock it down from public to
- // internal.
- case Accessibility.Internal:
- case Accessibility.ProtectedAndInternal:
- visibility = SymbolVisibility.Internal;
- break;
-
- // For anything else (Public, Protected, ProtectedOrInternal), the
- // symbol stays at the level we've gotten so far.
- }
-
- symbol = symbol.ContainingSymbol;
- }
-
- return visibility;
- }
-
- public static bool IsAnonymousType(this ISymbol symbol)
- {
- return symbol is INamedTypeSymbol && ((INamedTypeSymbol)symbol).IsAnonymousType;
- }
-
-// public static SymbolVisibility GetResultantVisibility(this ISymbol symbol)
-// {
-// // Start by assuming it's visible.
-// var visibility = SymbolVisibility.Public;
-//
-// switch (symbol.Kind)
-// {
-// case SymbolKind.Alias:
-// // Aliases are uber private. They're only visible in the same file that they
-// // were declared in.
-// return SymbolVisibility.Private;
-//
-// case SymbolKind.Parameter:
-// // Parameters are only as visible as their containing symbol
-// return GetResultantVisibility(symbol.ContainingSymbol);
-//
-// case SymbolKind.TypeParameter:
-// // Type Parameters are private.
-// return SymbolVisibility.Private;
-// }
-//
-// while (symbol != null && symbol.Kind != SymbolKind.Namespace)
-// {
-// switch (symbol.DeclaredAccessibility)
-// {
-// // If we see anything private, then the symbol is private.
-// case Accessibility.NotApplicable:
-// case Accessibility.Private:
-// return SymbolVisibility.Private;
-//
-// // If we see anything internal, then knock it down from public to
-// // internal.
-// case Accessibility.Internal:
-// case Accessibility.ProtectedAndInternal:
-// visibility = SymbolVisibility.Internal;
-// break;
-//
-// // For anything else (Public, Protected, ProtectedOrInternal), the
-// // symbol stays at the level we've gotten so far.
-// }
-//
-// symbol = symbol.ContainingSymbol;
-// }
-//
-// return visibility;
-// }
-
- public static ISymbol OverriddenMember(this ISymbol symbol)
- {
- switch (symbol.Kind)
- {
- case SymbolKind.Event:
- return ((IEventSymbol)symbol).OverriddenEvent;
-
- case SymbolKind.Method:
- return ((IMethodSymbol)symbol).OverriddenMethod;
-
- case SymbolKind.Property:
- return ((IPropertySymbol)symbol).OverriddenProperty;
-
- case SymbolKind.NamedType:
- return ((INamedTypeSymbol)symbol).BaseType;
- }
-
- return null;
- }
-
- public static ImmutableArray<ISymbol> ExplicitInterfaceImplementations(this ISymbol symbol)
- {
- return symbol.TypeSwitch(
- (IEventSymbol @event) => @event.ExplicitInterfaceImplementations.As<ISymbol>(),
- (IMethodSymbol method) => method.ExplicitInterfaceImplementations.As<ISymbol>(),
- (IPropertySymbol property) => property.ExplicitInterfaceImplementations.As<ISymbol>(),
- _ => ImmutableArray.Create<ISymbol>());
- }
-
- public static bool IsOverridable(this ISymbol symbol)
- {
- return
- symbol != null &&
- symbol.ContainingType != null &&
- symbol.ContainingType.TypeKind == TypeKind.Class &&
- (symbol.IsVirtual || symbol.IsAbstract || symbol.IsOverride) &&
- !symbol.IsSealed;
- }
-
- public static bool IsImplementable(this ISymbol symbol)
- {
- if (symbol != null &&
- symbol.ContainingType != null &&
- symbol.ContainingType.TypeKind == TypeKind.Interface)
- {
- if (symbol.Kind == SymbolKind.Event)
- {
- return true;
- }
-
- if (symbol.Kind == SymbolKind.Property)
- {
- return true;
- }
-
- if (symbol.Kind == SymbolKind.Method && ((IMethodSymbol)symbol).MethodKind == MethodKind.Ordinary)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static INamedTypeSymbol GetContainingTypeOrThis(this ISymbol symbol)
- {
- if (symbol is INamedTypeSymbol)
- {
- return (INamedTypeSymbol)symbol;
- }
-
- return symbol.ContainingType;
- }
-
- public static bool IsPointerType(this ISymbol symbol)
- {
- return symbol is IPointerTypeSymbol;
- }
-
- public static bool IsModuleType(this ISymbol symbol)
- {
- return (symbol as ITypeSymbol)?.IsModuleType() == true;
- }
-
- public static bool IsInterfaceType(this ISymbol symbol)
- {
- return (symbol as ITypeSymbol)?.IsInterfaceType() == true;
- }
-
- public static bool IsArrayType(this ISymbol symbol)
- {
- return symbol?.Kind == SymbolKind.ArrayType;
- }
-
- public static bool IsAnonymousFunction(this ISymbol symbol)
- {
- return (symbol as IMethodSymbol)?.MethodKind == MethodKind.AnonymousFunction;
- }
-
- public static bool IsKind(this ISymbol symbol, SymbolKind kind)
- {
- return symbol.MatchesKind(kind);
- }
-
- public static bool MatchesKind(this ISymbol symbol, SymbolKind kind)
- {
- return symbol?.Kind == kind;
- }
-
- public static bool MatchesKind(this ISymbol symbol, SymbolKind kind1, SymbolKind kind2)
- {
- return symbol != null
- && (symbol.Kind == kind1 || symbol.Kind == kind2);
- }
-
- public static bool MatchesKind(this ISymbol symbol, SymbolKind kind1, SymbolKind kind2, SymbolKind kind3)
- {
- return symbol != null
- && (symbol.Kind == kind1 || symbol.Kind == kind2 || symbol.Kind == kind3);
- }
-
- public static bool MatchesKind(this ISymbol symbol, params SymbolKind[] kinds)
- {
- return symbol != null
- && kinds.Contains(symbol.Kind);
- }
-
- public static bool IsReducedExtension(this ISymbol symbol)
- {
- return symbol is IMethodSymbol && ((IMethodSymbol)symbol).MethodKind == MethodKind.ReducedExtension;
- }
-
- public static bool IsExtensionMethod(this ISymbol symbol)
- {
- return symbol.Kind == SymbolKind.Method && ((IMethodSymbol)symbol).IsExtensionMethod;
- }
-
- public static bool IsModuleMember(this ISymbol symbol)
- {
- return symbol != null && symbol.ContainingSymbol is INamedTypeSymbol && symbol.ContainingType.TypeKind == TypeKind.Module;
- }
-
-
- public static bool IsConversion(this ISymbol symbol)
- {
- return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Conversion;
- }
-
- public static bool IsOrdinaryMethod(this ISymbol symbol)
- {
- return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Ordinary;
- }
-
-
- public static bool IsNormalAnonymousType(this ISymbol symbol)
- {
- return symbol.IsAnonymousType() && !symbol.IsDelegateType();
- }
-
- public static bool IsAnonymousDelegateType(this ISymbol symbol)
- {
- return symbol.IsAnonymousType() && symbol.IsDelegateType();
- }
-
- public static bool IsAnonymousTypeProperty(this ISymbol symbol)
- {
- return symbol is IPropertySymbol && symbol.ContainingType.IsNormalAnonymousType();
- }
-
-
- public static bool IsWriteableFieldOrProperty(this ISymbol symbol)
- {
- var fieldSymbol = symbol as IFieldSymbol;
- if (fieldSymbol != null)
- {
- return !fieldSymbol.IsReadOnly
- && !fieldSymbol.IsConst;
- }
-
- var propertySymbol = symbol as IPropertySymbol;
- if (propertySymbol != null)
- {
- return !propertySymbol.IsReadOnly;
- }
-
- return false;
- }
-
- public static ITypeSymbol GetMemberType(this ISymbol symbol)
- {
- switch (symbol.Kind)
- {
- case SymbolKind.Field:
- return ((IFieldSymbol)symbol).Type;
- case SymbolKind.Property:
- return ((IPropertySymbol)symbol).Type;
- case SymbolKind.Method:
- return ((IMethodSymbol)symbol).ReturnType;
- case SymbolKind.Event:
- return ((IEventSymbol)symbol).Type;
- }
-
- return null;
- }
-
- public static int GetArity(this ISymbol symbol)
- {
- switch (symbol.Kind)
- {
- case SymbolKind.NamedType:
- return ((INamedTypeSymbol)symbol).Arity;
- case SymbolKind.Method:
- return ((IMethodSymbol)symbol).Arity;
- default:
- return 0;
- }
- }
-
- public static ISymbol GetOriginalUnreducedDefinition(this ISymbol symbol)
- {
- if (symbol.IsReducedExtension())
- {
- // note: ReducedFrom is only a method definition and includes no type arguments.
- symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom();
- }
-
- if (symbol.IsFunctionValue())
- {
- var method = symbol.ContainingSymbol as IMethodSymbol;
- if (method != null)
- {
- symbol = method;
-
- if (method.AssociatedSymbol != null)
- {
- symbol = method.AssociatedSymbol;
- }
- }
- }
-
- if (symbol.IsNormalAnonymousType() || symbol.IsAnonymousTypeProperty())
- {
- return symbol;
- }
-
- var parameter = symbol as IParameterSymbol;
- if (parameter != null)
- {
- var method = parameter.ContainingSymbol as IMethodSymbol;
- if (method?.IsReducedExtension() == true)
- {
- symbol = method.GetConstructedReducedFrom().Parameters[parameter.Ordinal + 1];
- }
- }
-
- return symbol?.OriginalDefinition;
- }
-
- public static bool IsFunctionValue(this ISymbol symbol)
- {
- return symbol is ILocalSymbol && ((ILocalSymbol)symbol).IsFunctionValue;
- }
-
- public static bool IsThisParameter(this ISymbol symbol)
- {
- return symbol != null && symbol.Kind == SymbolKind.Parameter && ((IParameterSymbol)symbol).IsThis;
- }
-
- public static ISymbol ConvertThisParameterToType(this ISymbol symbol)
- {
- if (symbol.IsThisParameter())
- {
- return ((IParameterSymbol)symbol).Type;
- }
-
- return symbol;
- }
-
- public static bool IsParams(this ISymbol symbol)
- {
- var parameters = symbol.GetParameters();
- return parameters.Length > 0 && parameters[parameters.Length - 1].IsParams;
- }
-
- public static ImmutableArray<ITypeSymbol> GetTypeArguments(this ISymbol symbol)
- {
- return symbol.TypeSwitch(
- (IMethodSymbol m) => m.TypeArguments,
- (INamedTypeSymbol nt) => nt.TypeArguments,
- _ => ImmutableArray.Create<ITypeSymbol>());
- }
-
- public static ImmutableArray<ITypeSymbol> GetAllTypeArguments(this ISymbol symbol)
- {
- var results = new List<ITypeSymbol>(symbol.GetTypeArguments());
-
- var containingType = symbol.ContainingType;
- while (containingType != null)
- {
- results.AddRange(containingType.GetTypeArguments());
- containingType = containingType.ContainingType;
- }
-
- return ImmutableArray.CreateRange(results);
- }
-
- public static bool IsAttribute(this ISymbol symbol)
- {
- return (symbol as ITypeSymbol)?.IsAttribute() == true;
- }
-
- /// <summary>
- /// Returns true if this symbol contains anything unsafe within it. for example
- /// List&lt;int*[]&gt; is unsafe, as it "int* Foo { get; }"
- /// </summary>
- public static bool IsUnsafe(this ISymbol member)
- {
- // TODO(cyrusn): Defer to compiler code to handle this once it can.
- return member?.Accept(new IsUnsafeVisitor()) == true;
- }
-
- private class IsUnsafeVisitor : SymbolVisitor<bool>
- {
- private readonly HashSet<ISymbol> _visited = new HashSet<ISymbol>();
-
- public IsUnsafeVisitor()
- {
- }
-
- public override bool DefaultVisit(ISymbol node)
- {
- throw new NotImplementedException();
- }
-
- public override bool VisitArrayType(IArrayTypeSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return symbol.ElementType.Accept(this);
- }
-
- public override bool VisitDynamicType(IDynamicTypeSymbol symbol)
- {
- // The dynamic type is never unsafe (well....you know what I mean
- return false;
- }
-
- public override bool VisitField(IFieldSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return symbol.Type.Accept(this);
- }
-
- public override bool VisitNamedType(INamedTypeSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return symbol.GetAllTypeArguments().Any(ts => ts.Accept(this));
- }
-
- public override bool VisitPointerType(IPointerTypeSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return true;
- }
-
- public override bool VisitProperty(IPropertySymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return
- symbol.Type.Accept(this) ||
- symbol.Parameters.Any(p => p.Accept(this));
- }
-
- public override bool VisitTypeParameter(ITypeParameterSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return symbol.ConstraintTypes.Any(ts => ts.Accept(this));
- }
-
- public override bool VisitMethod(IMethodSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return
- symbol.ReturnType.Accept(this) ||
- symbol.Parameters.Any(p => p.Accept(this)) ||
- symbol.TypeParameters.Any(tp => tp.Accept(this));
- }
-
- public override bool VisitParameter(IParameterSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return symbol.Type.Accept(this);
- }
-
- public override bool VisitEvent(IEventSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return symbol.Type.Accept(this);
- }
-
- public override bool VisitAlias(IAliasSymbol symbol)
- {
- if (!_visited.Add(symbol))
- {
- return false;
- }
-
- return symbol.Target.Accept(this);
- }
- }
-
- public static ITypeSymbol ConvertToType(
- this ISymbol symbol,
- Compilation compilation,
- bool extensionUsedAsInstance = false)
- {
- var type = symbol as ITypeSymbol;
- if (type != null)
- {
- return type;
- }
-
- var method = (IMethodSymbol)symbol;
- if (method != null && !method.Parameters.Any(p => p.RefKind != RefKind.None))
- {
- // Convert the symbol to Func<...> or Action<...>
- if (method.ReturnsVoid)
- {
- var count = extensionUsedAsInstance ? method.Parameters.Length - 1 : method.Parameters.Length;
- var skip = extensionUsedAsInstance ? 1 : 0;
- count = Math.Max(0, count);
- if (count == 0)
- {
- // Action
- return compilation.ActionType();
- }
- else
- {
- // Action<TArg1, ..., TArgN>
- var actionName = "System.Action`" + count;
- var actionType = compilation.GetTypeByMetadataName(actionName);
-
- if (actionType != null)
- {
- var types = method.Parameters
- .Skip(skip)
- .Select(p =>
- (object)p.Type == null ?
- compilation.GetSpecialType(SpecialType.System_Object) :
- p.Type)
- .ToArray();
- return actionType.Construct(types);
- }
- }
- }
- else
- {
- // Func<TArg1,...,TArgN,TReturn>
- //
- // +1 for the return type.
- var count = extensionUsedAsInstance ? method.Parameters.Length - 1 : method.Parameters.Length;
- var skip = extensionUsedAsInstance ? 1 : 0;
- var functionName = "System.Func`" + (count + 1);
- var functionType = compilation.GetTypeByMetadataName(functionName);
-
- if (functionType != null)
- {
- var types = method.Parameters
- .Skip(skip)
- .Select(p => p.Type)
- .Concat(method.ReturnType)
- .Select(t =>
- (object)t == null ?
- compilation.GetSpecialType(SpecialType.System_Object) :
- t)
- .ToArray();
- return functionType.Construct(types);
- }
- }
- }
-
- // Otherwise, just default to object.
- return compilation.ObjectType;
- }
-
- public static bool IsDeprecated(this ISymbol symbol)
- {
- // TODO(cyrusn): Implement this
- return false;
- }
-
- public static bool IsStaticType(this ISymbol symbol)
- {
- return symbol != null && symbol.Kind == SymbolKind.NamedType && symbol.IsStatic;
- }
-
- public static bool IsNamespace(this ISymbol symbol)
- {
- return symbol?.Kind == SymbolKind.Namespace;
- }
-
-// public static bool IsOrContainsAccessibleAttribute(this ISymbol symbol, ISymbol withinType, IAssemblySymbol withinAssembly)
-// {
-// var alias = symbol as IAliasSymbol;
-// if (alias != null)
-// {
-// symbol = alias.Target;
-// }
-//
-// var namespaceOrType = symbol as INamespaceOrTypeSymbol;
-// if (namespaceOrType == null)
-// {
-// return false;
-// }
-//
-// if (namespaceOrType.IsAttribute() && namespaceOrType.IsAccessibleWithin(withinType ?? withinAssembly))
-// {
-// return true;
-// }
-//
-// return namespaceOrType.GetMembers().Any(nt => nt.IsOrContainsAccessibleAttribute(withinType, withinAssembly));
-// }
-
- public static IEnumerable<IPropertySymbol> GetValidAnonymousTypeProperties(this ISymbol symbol)
- {
- // Contract.ThrowIfFalse(symbol.IsNormalAnonymousType());
- return ((INamedTypeSymbol)symbol).GetMembers().OfType<IPropertySymbol>().Where(p => p.CanBeReferencedByName);
- }
-
- public static Accessibility ComputeResultantAccessibility(this ISymbol symbol, ITypeSymbol finalDestination)
- {
- if (symbol == null)
- {
- return Accessibility.Private;
- }
-
- switch (symbol.DeclaredAccessibility)
- {
- default:
- return symbol.DeclaredAccessibility;
- case Accessibility.ProtectedAndInternal:
- return symbol.ContainingAssembly.GivesAccessTo(finalDestination.ContainingAssembly)
- ? Accessibility.ProtectedAndInternal
- : Accessibility.Internal;
- case Accessibility.ProtectedOrInternal:
- return symbol.ContainingAssembly.GivesAccessTo(finalDestination.ContainingAssembly)
- ? Accessibility.ProtectedOrInternal
- : Accessibility.Protected;
- }
- }
-
- /// <returns>
- /// Returns true if symbol is a local variable and its declaring syntax node is
- /// after the current position, false otherwise (including for non-local symbols)
- /// </returns>
- public static bool IsInaccessibleLocal(this ISymbol symbol, int position)
- {
- if (symbol.Kind != SymbolKind.Local)
- {
- return false;
- }
-
- // Implicitly declared locals (with Option Explicit Off in VB) are scoped to the entire
- // method and should always be considered accessible from within the same method.
- if (symbol.IsImplicitlyDeclared)
- {
- return false;
- }
-
- var declarationSyntax = symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).FirstOrDefault();
- return declarationSyntax != null && position < declarationSyntax.SpanStart;
- }
-
-// /// <summary>
-// /// Checks a given symbol for browsability based on its declaration location, attributes
-// /// explicitly limiting browsability, and whether showing of advanced members is enabled.
-// /// The optional attribute constructor parameters may be used to specify the symbols of the
-// /// constructors of the various browsability limiting attributes because finding these
-// /// repeatedly over a large list of symbols can be slow. If providing these constructor
-// /// symbols, they should be in the format provided by
-// /// EditorBrowsableHelpers.GetSpecial*AttributeConstructor(). If these are not provided,
-// /// they will be found in the compilation.
-// /// </summary>
-// public static bool IsEditorBrowsable(
-// this ISymbol symbol,
-// bool hideAdvancedMembers,
-// Compilation compilation,
-// IMethodSymbol editorBrowsableAttributeConstructor = null,
-// List<IMethodSymbol> typeLibTypeAttributeConstructors = null,
-// List<IMethodSymbol> typeLibFuncAttributeConstructors = null,
-// List<IMethodSymbol> typeLibVarAttributeConstructors = null,
-// INamedTypeSymbol hideModuleNameAttribute = null)
-// {
-// // Namespaces can't have attributes, so just return true here. This also saves us a
-// // costly check if this namespace has any locations in source (since a merged namespace
-// // needs to go collect all the locations).
-// if (symbol.Kind == SymbolKind.Namespace)
-// {
-// return true;
-// }
-//
-// // check for IsImplicitlyDeclared so we don't spend time examining VB's embedded types.
-// // This saves a few percent in typing scenarios. An implicitly declared symbol can't
-// // have attributes, so it can't be hidden by them.
-// if (symbol.IsImplicitlyDeclared)
-// {
-// return true;
-// }
-//
-// // Ignore browsability limiting attributes if the symbol is declared in source.
-// // Check all locations since some of VB's embedded My symbols are declared in
-// // both source and the MyTemplateLocation.
-// if (symbol.Locations.All(loc => loc.IsInSource))
-// {
-// // The HideModuleNameAttribute still applies to Modules defined in source
-// return !IsBrowsingProhibitedByHideModuleNameAttribute(symbol, compilation, hideModuleNameAttribute);
-// }
-//
-// return !IsBrowsingProhibited(
-// symbol,
-// hideAdvancedMembers,
-// compilation,
-// editorBrowsableAttributeConstructor,
-// typeLibTypeAttributeConstructors,
-// typeLibFuncAttributeConstructors,
-// typeLibVarAttributeConstructors,
-// hideModuleNameAttribute);
-// }
-//
-// private static bool IsBrowsingProhibited(
-// ISymbol symbol,
-// bool hideAdvancedMembers,
-// Compilation compilation,
-// IMethodSymbol editorBrowsableAttributeConstructor,
-// List<IMethodSymbol> typeLibTypeAttributeConstructors,
-// List<IMethodSymbol> typeLibFuncAttributeConstructors,
-// List<IMethodSymbol> typeLibVarAttributeConstructors,
-// INamedTypeSymbol hideModuleNameAttribute)
-// {
-// var attributes = symbol.GetAttributes();
-// if (attributes.Length == 0)
-// {
-// return false;
-// }
-//
-// return IsBrowsingProhibitedByEditorBrowsableAttribute(symbol, attributes, hideAdvancedMembers, compilation, editorBrowsableAttributeConstructor)
-// || IsBrowsingProhibitedByTypeLibTypeAttribute(symbol, attributes, compilation, typeLibTypeAttributeConstructors)
-// || IsBrowsingProhibitedByTypeLibFuncAttribute(symbol, attributes, compilation, typeLibFuncAttributeConstructors)
-// || IsBrowsingProhibitedByTypeLibVarAttribute(symbol, attributes, compilation, typeLibVarAttributeConstructors)
-// || IsBrowsingProhibitedByHideModuleNameAttribute(symbol, compilation, hideModuleNameAttribute, attributes);
-// }
-//
-// private static bool IsBrowsingProhibitedByHideModuleNameAttribute(
-// ISymbol symbol, Compilation compilation, INamedTypeSymbol hideModuleNameAttribute, ImmutableArray<AttributeData> attributes = default(ImmutableArray<AttributeData>))
-// {
-// if (!symbol.IsModuleType())
-// {
-// return false;
-// }
-//
-// attributes = attributes.IsDefault ? symbol.GetAttributes() : attributes;
-// hideModuleNameAttribute = hideModuleNameAttribute ?? compilation.HideModuleNameAttribute();
-// foreach (var attribute in attributes)
-// {
-// if (attribute.AttributeClass == hideModuleNameAttribute)
-// {
-// return true;
-// }
-// }
-//
-// return false;
-// }
-//
-// private static bool IsBrowsingProhibitedByEditorBrowsableAttribute(
-// ISymbol symbol, ImmutableArray<AttributeData> attributes, bool hideAdvancedMembers, Compilation compilation, IMethodSymbol constructor)
-// {
-// constructor = constructor ?? EditorBrowsableHelpers.GetSpecialEditorBrowsableAttributeConstructor(compilation);
-// if (constructor == null)
-// {
-// return false;
-// }
-//
-// foreach (var attribute in attributes)
-// {
-// if (attribute.AttributeConstructor == constructor &&
-// attribute.ConstructorArguments.Length == 1 &&
-// attribute.ConstructorArguments.First().Value is int)
-// {
-// var state = (EditorBrowsableState)attribute.ConstructorArguments.First().Value;
-//
-// if (EditorBrowsableState.Never == state ||
-// (hideAdvancedMembers && EditorBrowsableState.Advanced == state))
-// {
-// return true;
-// }
-// }
-// }
-//
-// return false;
-// }
-//
-// private static bool IsBrowsingProhibitedByTypeLibTypeAttribute(
-// ISymbol symbol, ImmutableArray<AttributeData> attributes, Compilation compilation, List<IMethodSymbol> constructors)
-// {
-// return IsBrowsingProhibitedByTypeLibAttributeWorker(
-// symbol,
-// attributes,
-// constructors ?? EditorBrowsableHelpers.GetSpecialTypeLibTypeAttributeConstructors(compilation),
-// TypeLibTypeFlagsFHidden);
-// }
-//
-// private static bool IsBrowsingProhibitedByTypeLibFuncAttribute(
-// ISymbol symbol, ImmutableArray<AttributeData> attributes, Compilation compilation, List<IMethodSymbol> constructors)
-// {
-// return IsBrowsingProhibitedByTypeLibAttributeWorker(
-// symbol,
-// attributes,
-// constructors ?? EditorBrowsableHelpers.GetSpecialTypeLibFuncAttributeConstructors(compilation),
-// TypeLibFuncFlagsFHidden);
-// }
-//
-// private static bool IsBrowsingProhibitedByTypeLibVarAttribute(
-// ISymbol symbol, ImmutableArray<AttributeData> attributes, Compilation compilation, List<IMethodSymbol> constructors)
-// {
-// return IsBrowsingProhibitedByTypeLibAttributeWorker(
-// symbol,
-// attributes,
-// constructors ?? EditorBrowsableHelpers.GetSpecialTypeLibVarAttributeConstructors(compilation),
-// TypeLibVarFlagsFHidden);
-// }
-
- private const int TypeLibTypeFlagsFHidden = 0x0010;
- private const int TypeLibFuncFlagsFHidden = 0x0040;
- private const int TypeLibVarFlagsFHidden = 0x0040;
-
- private static bool IsBrowsingProhibitedByTypeLibAttributeWorker(
- ISymbol symbol, ImmutableArray<AttributeData> attributes, List<IMethodSymbol> attributeConstructors, int hiddenFlag)
- {
- foreach (var attribute in attributes)
- {
- if (attribute.ConstructorArguments.Length == 1)
- {
- foreach (var constructor in attributeConstructors)
- {
- if (attribute.AttributeConstructor == constructor)
- {
- var actualFlags = 0;
-
- // Check for both constructor signatures. The constructor that takes a TypeLib*Flags reports an int argument.
- var argumentValue = attribute.ConstructorArguments.First().Value;
-
- if (argumentValue is int)
- {
- actualFlags = (int)argumentValue;
- }
- else if (argumentValue is short)
- {
- actualFlags = (short)argumentValue;
- }
- else
- {
- continue;
- }
-
- if ((actualFlags & hiddenFlag) == hiddenFlag)
- {
- return true;
- }
- }
- }
- }
- }
-
- return false;
- }
-
-// public static bool IsAccessor(this ISymbol symbol)
-// {
-// return symbol.IsPropertyAccessor() || symbol.IsEventAccessor();
-// }
-//
-// public static bool IsPropertyAccessor(this ISymbol symbol)
-// {
-// return (symbol as IMethodSymbol)?.MethodKind.IsPropertyAccessor() == true;
-// }
-
- public static bool IsEventAccessor(this ISymbol symbol)
- {
- var method = symbol as IMethodSymbol;
- return method != null &&
- (method.MethodKind == MethodKind.EventAdd ||
- method.MethodKind == MethodKind.EventRaise ||
- method.MethodKind == MethodKind.EventRemove);
- }
-
- public static ITypeSymbol GetSymbolType(this ISymbol symbol)
- {
- var localSymbol = symbol as ILocalSymbol;
- if (localSymbol != null)
- {
- return localSymbol.Type;
- }
-
- var fieldSymbol = symbol as IFieldSymbol;
- if (fieldSymbol != null)
- {
- return fieldSymbol.Type;
- }
-
- var propertySymbol = symbol as IPropertySymbol;
- if (propertySymbol != null)
- {
- return propertySymbol.Type;
- }
-
- var parameterSymbol = symbol as IParameterSymbol;
- if (parameterSymbol != null)
- {
- return parameterSymbol.Type;
- }
-
- var aliasSymbol = symbol as IAliasSymbol;
- if (aliasSymbol != null)
- {
- return aliasSymbol.Target as ITypeSymbol;
- }
-
- return symbol as ITypeSymbol;
- }
-
- /// <summary>
- /// If the <paramref name="symbol"/> is a method symbol, returns True if the method's return type is "awaitable".
- /// If the <paramref name="symbol"/> is a type symbol, returns True if that type is "awaitable".
- /// An "awaitable" is any type that exposes a GetAwaiter method which returns a valid "awaiter". This GetAwaiter method may be an instance method or an extension method.
- /// </summary>
- public static bool IsAwaitable(this ISymbol symbol, SemanticModel semanticModel, int position)
- {
- IMethodSymbol methodSymbol = symbol as IMethodSymbol;
- ITypeSymbol typeSymbol = null;
-
- if (methodSymbol == null)
- {
- typeSymbol = symbol as ITypeSymbol;
- if (typeSymbol == null)
- {
- return false;
- }
- }
- else
- {
- if (methodSymbol.ReturnType == null)
- {
- return false;
- }
-
- // dynamic
- if (methodSymbol.ReturnType.TypeKind == TypeKind.Dynamic &&
- methodSymbol.MethodKind != MethodKind.BuiltinOperator)
- {
- return true;
- }
- }
-
- // otherwise: needs valid GetAwaiter
- var potentialGetAwaiters = semanticModel.LookupSymbols(position,
- container: typeSymbol ?? methodSymbol.ReturnType.OriginalDefinition,
- name: WellKnownMemberNames.GetAwaiter,
- includeReducedExtensionMethods: true);
- var getAwaiters = potentialGetAwaiters.OfType<IMethodSymbol>().Where(x => !x.Parameters.Any());
- return getAwaiters.Any(VerifyGetAwaiter);
- }
-
- private static bool VerifyGetAwaiter(IMethodSymbol getAwaiter)
- {
- var returnType = getAwaiter.ReturnType;
- if (returnType == null)
- {
- return false;
- }
-
- // bool IsCompleted { get }
- if (!returnType.GetMembers().OfType<IPropertySymbol>().Any(p => p.Name == WellKnownMemberNames.IsCompleted && p.Type.SpecialType == SpecialType.System_Boolean && p.GetMethod != null))
- {
- return false;
- }
-
- var methods = returnType.GetMembers().OfType<IMethodSymbol>();
-
- // NOTE: (vladres) The current version of C# Spec, §7.7.7.3 'Runtime evaluation of await expressions', requires that
- // NOTE: the interface method INotifyCompletion.OnCompleted or ICriticalNotifyCompletion.UnsafeOnCompleted is invoked
- // NOTE: (rather than any OnCompleted method conforming to a certain pattern).
- // NOTE: Should this code be updated to match the spec?
-
- // void OnCompleted(Action)
- // Actions are delegates, so we'll just check for delegates.
- if (!methods.Any(x => x.Name == WellKnownMemberNames.OnCompleted && x.ReturnsVoid && x.Parameters.Length == 1 && x.Parameters.First().Type.TypeKind == TypeKind.Delegate))
- {
- return false;
- }
-
- // void GetResult() || T GetResult()
- return methods.Any(m => m.Name == WellKnownMemberNames.GetResult && !m.Parameters.Any());
- }
-
- public static IList<SymbolDisplayPart> ToAwaitableParts(this ISymbol symbol, string awaitKeyword, string initializedVariableName, SemanticModel semanticModel, int position)
- {
- var spacePart = new SymbolDisplayPart(SymbolDisplayPartKind.Space, null, " ");
- var parts = new List<SymbolDisplayPart>();
-
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Text, null, "\r\nUsage:\r\n "));
-
- var returnType = symbol.InferAwaitableReturnType(semanticModel, position);
- returnType = returnType != null && returnType.SpecialType != SpecialType.System_Void ? returnType : null;
- if (returnType != null)
- {
- if (semanticModel.Language == "C#")
- {
- parts.AddRange(returnType.ToMinimalDisplayParts(semanticModel, position));
- parts.Add(spacePart);
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.LocalName, null, initializedVariableName));
- }
- else
- {
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Keyword, null, "Dim"));
- parts.Add(spacePart);
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.LocalName, null, initializedVariableName));
- parts.Add(spacePart);
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Keyword, null, "as"));
- parts.Add(spacePart);
- parts.AddRange(returnType.ToMinimalDisplayParts(semanticModel, position));
- }
-
- parts.Add(spacePart);
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, null, "="));
- parts.Add(spacePart);
- }
-
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Keyword, null, awaitKeyword));
- parts.Add(spacePart);
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.MethodName, symbol, symbol.Name));
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, null, "("));
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, null, symbol.GetParameters().Any() ? "..." : ""));
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, null, ")"));
- parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, null, semanticModel.Language == "C#" ? ";" : ""));
-
- return parts;
- }
-
- public static ITypeSymbol InferAwaitableReturnType(this ISymbol symbol, SemanticModel semanticModel, int position)
- {
- var methodSymbol = symbol as IMethodSymbol;
- if (methodSymbol == null)
- {
- return null;
- }
-
- var returnType = methodSymbol.ReturnType;
- if (returnType == null)
- {
- return null;
- }
-
- var potentialGetAwaiters = semanticModel.LookupSymbols(position, container: returnType, name: WellKnownMemberNames.GetAwaiter, includeReducedExtensionMethods: true);
- var getAwaiters = potentialGetAwaiters.OfType<IMethodSymbol>().Where(x => !x.Parameters.Any());
- if (!getAwaiters.Any())
- {
- return null;
- }
-
- var getResults = getAwaiters.SelectMany(g => semanticModel.LookupSymbols(position, container: g.ReturnType, name: WellKnownMemberNames.GetResult));
-
- var getResult = getResults.OfType<IMethodSymbol>().FirstOrDefault(g => !g.IsStatic);
- if (getResult == null)
- {
- return null;
- }
-
- return getResult.ReturnType;
- }
-
- /// <summary>
- /// First, remove symbols from the set if they are overridden by other symbols in the set.
- /// If a symbol is overridden only by symbols outside of the set, then it is not removed.
- /// This is useful for filtering out symbols that cannot be accessed in a given context due
- /// to the existence of overriding members. Second, remove remaining symbols that are
- /// unsupported (e.g. pointer types in VB) or not editor browsable based on the EditorBrowsable
- /// attribute.
- /// </summary>
-// public static IEnumerable<T> FilterToVisibleAndBrowsableSymbols<T>(this IEnumerable<T> symbols, bool hideAdvancedMembers, Compilation compilation) where T : ISymbol
-// {
-// symbols = symbols.RemoveOverriddenSymbolsWithinSet();
-//
-// // Since all symbols are from the same compilation, find the required attribute
-// // constructors once and reuse.
-//
-// var editorBrowsableAttributeConstructor = EditorBrowsableHelpers.GetSpecialEditorBrowsableAttributeConstructor(compilation);
-// var typeLibTypeAttributeConstructors = EditorBrowsableHelpers.GetSpecialTypeLibTypeAttributeConstructors(compilation);
-// var typeLibFuncAttributeConstructors = EditorBrowsableHelpers.GetSpecialTypeLibFuncAttributeConstructors(compilation);
-// var typeLibVarAttributeConstructors = EditorBrowsableHelpers.GetSpecialTypeLibVarAttributeConstructors(compilation);
-// var hideModuleNameAttribute = compilation.HideModuleNameAttribute();
-//
-// // PERF: HasUnsupportedMetadata may require recreating the syntax tree to get the base class, so first
-// // check to see if we're referencing a symbol defined in source.
-// Func<Location, bool> isSymbolDefinedInSource = l => l.IsInSource;
-// return symbols.Where(s =>
-// (s.Locations.Any(isSymbolDefinedInSource) || !s.HasUnsupportedMetadata) &&
-// !s.IsDestructor() &&
-// s.IsEditorBrowsable(
-// hideAdvancedMembers,
-// compilation,
-// editorBrowsableAttributeConstructor,
-// typeLibTypeAttributeConstructors,
-// typeLibFuncAttributeConstructors,
-// typeLibVarAttributeConstructors,
-// hideModuleNameAttribute));
-// }
-
- private static IEnumerable<T> RemoveOverriddenSymbolsWithinSet<T>(this IEnumerable<T> symbols) where T : ISymbol
- {
- HashSet<ISymbol> overriddenSymbols = new HashSet<ISymbol>();
-
- foreach (var symbol in symbols)
- {
- if (symbol.OverriddenMember() != null && !overriddenSymbols.Contains(symbol.OverriddenMember()))
- {
- overriddenSymbols.Add(symbol.OverriddenMember());
- }
- }
-
- return symbols.Where(s => !overriddenSymbols.Contains(s));
- }
-
-// public static IEnumerable<T> FilterToVisibleAndBrowsableSymbolsAndNotUnsafeSymbols<T>(this IEnumerable<T> symbols, bool hideAdvancedMembers, Compilation compilation) where T : ISymbol
-// {
-// return symbols.FilterToVisibleAndBrowsableSymbols(hideAdvancedMembers, compilation).Where(s => !s.IsUnsafe());
-// }
- }
-
- enum SymbolVisibility
- {
- Public,
- Internal,
- Private,
- }
-
-} \ No newline at end of file
diff --git a/main/src/addins/CSharpBinding/Util/SymbolInfoExtensions.cs b/main/src/addins/CSharpBinding/Util/SymbolInfoExtensions.cs
deleted file mode 100644
index 9e652103c7..0000000000
--- a/main/src/addins/CSharpBinding/Util/SymbolInfoExtensions.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// SymbolInfoExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SymbolInfoExtensions
- {
- public static IEnumerable<ISymbol> GetAllSymbols(this SymbolInfo info)
- {
- return GetAllSymbolsWorker(info).Distinct();
- }
-
- private static IEnumerable<ISymbol> GetAllSymbolsWorker(this SymbolInfo info)
- {
- if (info.Symbol != null)
- {
- yield return info.Symbol;
- }
-
- foreach (var symbol in info.CandidateSymbols)
- {
- yield return symbol;
- }
- }
-
- public static ISymbol GetAnySymbol(this SymbolInfo info)
- {
- return info.GetAllSymbols().FirstOrDefault();
- }
-
- public static IEnumerable<ISymbol> GetBestOrAllSymbols(this SymbolInfo info)
- {
- if (info.Symbol != null)
- {
- return SpecializedCollections.SingletonEnumerable(info.Symbol);
- }
- else if (info.CandidateSymbols.Length > 0)
- {
- return info.CandidateSymbols;
- }
-
- return SpecializedCollections.EmptyEnumerable<ISymbol>();
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/SymbolKeyExtensions.cs b/main/src/addins/CSharpBinding/Util/SymbolKeyExtensions.cs
deleted file mode 100644
index 398594a25f..0000000000
--- a/main/src/addins/CSharpBinding/Util/SymbolKeyExtensions.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Threading;
-using System;
-using Microsoft.CodeAnalysis;
-using System.Reflection;
-using System.Collections.Immutable;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class SymbolKey
- {
- readonly static Type typeInfo;
-
- readonly object instance;
-
- static SymbolKey ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.SymbolKey" + ReflectionNamespaces.WorkspacesAsmName, true);
- resolveMethod = typeInfo.GetMethod ("Resolve", BindingFlags.Instance | BindingFlags.Public);
- createMethod = typeInfo.GetMethod ("Create", BindingFlags.Static | BindingFlags.NonPublic);
- }
-
- SymbolKey (object instance)
- {
- this.instance = instance;
- }
-
- static MethodInfo createMethod;
-
- /// <summary>
- /// <para>
- /// This entry point should only be called from the actual Symbol classes. It should not be
- /// used internally inside this type. Instead, any time we need to get the <see cref="SymbolKey"/> for a
- /// related symbol (i.e. the containing namespace of a namespace) we should call
- /// GetOrCreate. The benefit of this is twofold. First of all, it keeps the size of the
- /// <see cref="SymbolKey"/> small by allowing up to reuse parts we've already created. For example, if we
- /// have the <see cref="SymbolKey"/> for <c>Foo(int, int)</c>, then we will reuse the <see cref="SymbolKey"/>s for both <c>int</c>s.
- /// Second, this allows us to deal with the recursive nature of MethodSymbols and
- /// TypeParameterSymbols. Specifically, a MethodSymbol is defined by its signature. However,
- /// it's signature may refer to type parameters of that method. Unfortunately, the type
- /// parameters depend on their containing method.
- /// </para>
- /// <para>
- /// For example, if there is <c><![CDATA[Foo<T>(T t)]]></c>, then we must avoid the situation where we:
- /// <list type="number">
- /// <item>try to get the symbol ID for the type parameter <c>T</c>, which in turn</item>
- /// <item>tries to get the symbol ID for the method <c>T</c>, which in turn</item>
- /// <item>tries to get the symbol IDs for the parameter types, which in turn</item>
- /// <item>tries to get the symbol ID for the type parameter <c>T</c>, which leads back to 1 and infinitely loops.</item>
- /// </list>
- /// </para>
- /// <para>
- /// In order to break this circularity we do not create the SymbolIDs for a method's type
- /// parameters directly in the visitor. Instead, we create the SymbolID for the method
- /// itself. When the MethodSymbolId is created it will directly instantiate the SymbolIDs
- /// for the type parameters, and directly assign the type parameter's method ID to itself.
- /// It will also then directly store the mapping from the type parameter to its SymbolID in
- /// the visitor cache. Then when we try to create the symbol IDs for the parameter types,
- /// any reference to the type parameters can be found in the cache.
- /// </para>
- /// <para>
- /// It is for this reason that it is essential that all calls to get related symbol IDs goes
- /// through GetOrCreate and not Create.
- /// </para>
- /// </summary>
- internal static SymbolKey Create(ISymbol symbol, CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- var instance = createMethod.Invoke (null, new object [] { symbol, cancellationToken });
- return new SymbolKey (instance);
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- static MethodInfo resolveMethod;
-
- public SymbolKeyResolution Resolve(Compilation compilation, bool ignoreAssemblyKey = false, CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return new SymbolKeyResolution (resolveMethod.Invoke (instance, new object[] { compilation, ignoreAssemblyKey, cancellationToken }));
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-
- class SymbolKeyResolution
- {
- readonly static Type typeInfo;
- readonly static PropertyInfo symbolProperty;
- readonly static PropertyInfo candidateSymbolsProperty;
- readonly static PropertyInfo candidateReasonProperty;
-
- readonly object instance;
-
-
- public ISymbol Symbol
- {
- get { return (ISymbol)symbolProperty.GetValue (instance); }
- }
-
- public ImmutableArray<ISymbol> CandidateSymbols
- {
- get { return (ImmutableArray<ISymbol>)candidateSymbolsProperty.GetValue (instance); }
- }
-
- public CandidateReason CandidateReason
- {
- get { return (CandidateReason)candidateReasonProperty.GetValue (instance); }
- }
-
- static SymbolKeyResolution ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.SymbolKeyResolution" + ReflectionNamespaces.WorkspacesAsmName, true);
-
- symbolProperty = typeInfo.GetProperty ("Symbol");
- candidateSymbolsProperty = typeInfo.GetProperty ("CandidateSymbols");
- candidateReasonProperty = typeInfo.GetProperty ("CandidateReason");
-
- }
-
- public SymbolKeyResolution (object instance)
- {
- this.instance = instance;
- }
-
-
- }
-
- static class SymbolKeyExtensions
- {
- public static SymbolKey GetSymbolKey(this ISymbol symbol)
- {
- return SymbolKey.Create(symbol, CancellationToken.None);
- }
-
- #if false
- internal static SymbolKey GetSymbolKey(this ISymbol symbol, Compilation compilation, CancellationToken cancellationToken)
- {
- return SymbolKey.Create(symbol, compilation, cancellationToken);
- }
- #endif
-
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SymbolKeyResolutionExtensions.cs b/main/src/addins/CSharpBinding/Util/SymbolKeyResolutionExtensions.cs
deleted file mode 100644
index 6440394c02..0000000000
--- a/main/src/addins/CSharpBinding/Util/SymbolKeyResolutionExtensions.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SymbolKeyResolutionExtensions
- {
- public static ISymbol GetAnySymbol(this SymbolKeyResolution resolution)
- {
- if (resolution.Symbol != null)
- {
- return resolution.Symbol;
- }
-
- if (resolution.CandidateSymbols.Length > 0)
- {
- return resolution.CandidateSymbols[0];
- }
-
- return null;
- }
-
- public static IEnumerable<ISymbol> GetAllSymbols(this SymbolKeyResolution resolution)
- {
- return GetAllSymbolsWorker(resolution).Distinct();
- }
-
- private static IEnumerable<ISymbol> GetAllSymbolsWorker(SymbolKeyResolution resolution)
- {
- if (resolution.Symbol != null)
- {
- yield return resolution.Symbol;
- }
-
- foreach (var symbol in resolution.CandidateSymbols)
- {
- yield return symbol;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SyntacticDocument.cs b/main/src/addins/CSharpBinding/Util/SyntacticDocument.cs
deleted file mode 100644
index 2d23878be4..0000000000
--- a/main/src/addins/CSharpBinding/Util/SyntacticDocument.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class SyntacticDocument
- {
- public readonly Document Document;
- public readonly SourceText Text;
- public readonly SyntaxTree SyntaxTree;
- public readonly SyntaxNode Root;
-
- protected SyntacticDocument(Document document, SourceText text, SyntaxTree tree, SyntaxNode root)
- {
- this.Document = document;
- this.Text = text;
- this.SyntaxTree = tree;
- this.Root = root;
- }
-
- public Project Project
- {
- get { return this.Document.Project; }
- }
-
- public static async Task<SyntacticDocument> CreateAsync(Document document, CancellationToken cancellationToken)
- {
- var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- return new SyntacticDocument(document, text, root.SyntaxTree, root);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SyntaxContext.cs b/main/src/addins/CSharpBinding/Util/SyntaxContext.cs
index caa230fddc..3ee6a0c3ce 100644
--- a/main/src/addins/CSharpBinding/Util/SyntaxContext.cs
+++ b/main/src/addins/CSharpBinding/Util/SyntaxContext.cs
@@ -28,9 +28,10 @@ using System.Linq;
using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using System.Threading;
-using Microsoft.CodeAnalysis.Simplification;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Shared.Extensions;
namespace ICSharpCode.NRefactory6.CSharp
{
diff --git a/main/src/addins/CSharpBinding/Util/SyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/SyntaxExtensions.cs
deleted file mode 100644
index 1b378e9479..0000000000
--- a/main/src/addins/CSharpBinding/Util/SyntaxExtensions.cs
+++ /dev/null
@@ -1,550 +0,0 @@
-//
-// SyntaxExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Simplification;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Rename.ConflictEngine;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Simplification;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using System;
-using System.Reflection;
-using System.Collections.Immutable;
-using System.Runtime.ExceptionServices;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SyntaxExtensions
- {
- readonly static MethodInfo canRemoveParenthesesMethod;
-// readonly static MethodInfo isLeftSideOfDotMethod;
-// readonly static MethodInfo isRightSideOfDotMethod;
-// readonly static MethodInfo getEnclosingNamedTypeMethod;
- readonly static MethodInfo getLocalDeclarationMapMethod;
- readonly static PropertyInfo localDeclarationMapIndexer;
- readonly static MethodInfo getAncestorsMethod;
-
- static SyntaxExtensions()
- {
- var typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.ParenthesizedExpressionSyntaxExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- canRemoveParenthesesMethod = typeInfo.GetMethod("CanRemoveParentheses", new[] { typeof(ParenthesizedExpressionSyntax) });
-
-// typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.ExpressionSyntaxExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true);
-// isLeftSideOfDotMethod = typeInfo.GetMethod("IsLeftSideOfDot", new[] { typeof(ExpressionSyntax) });
-// isRightSideOfDotMethod = typeInfo.GetMethod("IsRightSideOfDot", new[] { typeof(ExpressionSyntax) });
-//
-// typeInfo = Type.GetType("Microsoft.CodeAnalysis.Shared.Extensions.SemanticModelExtensions" + ReflectionNamespaces.WorkspacesAsmName, true);
-// getEnclosingNamedTypeMethod = typeInfo.GetMethod("GetEnclosingNamedType", new[] { typeof(SemanticModel), typeof(int), typeof(CancellationToken) });
-//
- typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.MemberDeclarationSyntaxExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- getLocalDeclarationMapMethod = typeInfo.GetMethod("GetLocalDeclarationMap", new[] { typeof(MemberDeclarationSyntax) });
-
- typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.MemberDeclarationSyntaxExtensions+LocalDeclarationMap" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- localDeclarationMapIndexer = typeInfo.GetProperties().Single(p => p.GetIndexParameters().Any());
-
- typeInfo = Type.GetType("Microsoft.CodeAnalysis.Shared.Extensions.SyntaxTokenExtensions" + ReflectionNamespaces.WorkspacesAsmName, true);
- getAncestorsMethod = typeInfo.GetMethods().Single(m => m.Name == "GetAncestors" && m.IsGenericMethod && m.GetParameters().Length == 1);
- }
-
-
- /// <summary>
- /// Look inside a trivia list for a skipped token that contains the given position.
- /// </summary>
- private static readonly Func<SyntaxTriviaList, int, SyntaxToken> s_findSkippedTokenBackward =
- (l, p) => FindTokenHelper.FindSkippedTokenBackward(GetSkippedTokens(l), p);
-
- /// <summary>
- /// return only skipped tokens
- /// </summary>
- private static IEnumerable<SyntaxToken> GetSkippedTokens(SyntaxTriviaList list)
- {
- return list.Where(trivia => trivia.RawKind == (int)SyntaxKind.SkippedTokensTrivia)
- .SelectMany(t => ((SkippedTokensTriviaSyntax)t.GetStructure()).Tokens);
- }
-
- /// <summary>
- /// If the position is inside of token, return that token; otherwise, return the token to the left.
- /// </summary>
- public static SyntaxToken FindTokenOnLeftOfPosition(
- this SyntaxNode root,
- int position,
- bool includeSkipped = true,
- bool includeDirectives = false,
- bool includeDocumentationComments = false)
- {
- var skippedTokenFinder = includeSkipped ? s_findSkippedTokenBackward : (Func<SyntaxTriviaList, int, SyntaxToken>)null;
-
- return FindTokenHelper.FindTokenOnLeftOfPosition<CompilationUnitSyntax>(
- root, position, skippedTokenFinder, includeSkipped, includeDirectives, includeDocumentationComments);
- }
-
-
-
-// public static bool IntersectsWith(this SyntaxToken token, int position)
-// {
-// return token.Span.IntersectsWith(position);
-// }
-
-// public static bool IsLeftSideOfDot(this ExpressionSyntax syntax)
-// {
-// return (bool)isLeftSideOfDotMethod.Invoke(null, new object[] { syntax });
-// }
-//
-// public static bool IsRightSideOfDot(this ExpressionSyntax syntax)
-// {
-// return (bool)isRightSideOfDotMethod.Invoke(null, new object[] { syntax });
-// }
-
-// public static INamedTypeSymbol GetEnclosingNamedType(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
-// {
-// return (INamedTypeSymbol)getEnclosingNamedTypeMethod.Invoke(null, new object[] { semanticModel, position, cancellationToken });
-// }
-//
- static ImmutableArray<SyntaxToken> GetLocalDeclarationMap(this MemberDeclarationSyntax member, string localName)
- {
- try {
- object map = getLocalDeclarationMapMethod.Invoke(null, new object[] { member });
- return (ImmutableArray<SyntaxToken>)localDeclarationMapIndexer.GetValue(map, new object[] { localName });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return ImmutableArray<SyntaxToken>.Empty;
- }
- }
-
- static IEnumerable<T> GetAncestors<T>(this SyntaxToken token) where T : SyntaxNode
- {
- try {
- return (IEnumerable<T>)getAncestorsMethod.MakeGenericMethod(typeof(T)).Invoke(null, new object[] { token });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public static ExpressionSyntax SkipParens(this ExpressionSyntax expression)
- {
- if (expression == null)
- return null;
- while (expression != null && expression.IsKind(SyntaxKind.ParenthesizedExpression)) {
- expression = ((ParenthesizedExpressionSyntax)expression).Expression;
- }
- return expression;
- }
-
- public static SyntaxNode SkipArgument(this SyntaxNode expression)
- {
- if (expression is ArgumentSyntax)
- return ((ArgumentSyntax)expression).Expression;
- return expression;
- }
-
- public static bool CanRemoveParentheses(this ParenthesizedExpressionSyntax node)
- {
- try {
- return (bool)canRemoveParenthesesMethod.Invoke(null, new object[] { node });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return false;
- }
- }
-
- public static bool IsParentKind(this SyntaxNode node, SyntaxKind kind)
- {
- return node != null && node.Parent.IsKind(kind);
- }
-
- public static bool IsParentKind(this SyntaxToken node, SyntaxKind kind)
- {
- return node.Parent != null && node.Parent.IsKind(kind);
- }
-
- public static bool CanReplaceWithReducedName(
- this MemberAccessExpressionSyntax memberAccess,
- ExpressionSyntax reducedName,
- SemanticModel semanticModel,
- CancellationToken cancellationToken)
- {
- if (!IsThisOrTypeOrNamespace(memberAccess, semanticModel)) {
- return false;
- }
-
- var speculationAnalyzer = new SpeculationAnalyzer(memberAccess, reducedName, semanticModel, cancellationToken);
- if (!speculationAnalyzer.SymbolsForOriginalAndReplacedNodesAreCompatible() ||
- speculationAnalyzer.ReplacementChangesSemantics()) {
- return false;
- }
-
- if (WillConflictWithExistingLocal(memberAccess, reducedName)) {
- return false;
- }
-
- if (IsMemberAccessADynamicInvocation(memberAccess, semanticModel)) {
- return false;
- }
-
- if (memberAccess.AccessMethodWithDynamicArgumentInsideStructConstructor(semanticModel)) {
- return false;
- }
-
- if (memberAccess.Expression.Kind() == SyntaxKind.BaseExpression) {
- var enclosingNamedType = semanticModel.GetEnclosingNamedType(memberAccess.SpanStart, cancellationToken);
- var symbol = semanticModel.GetSymbolInfo(memberAccess.Name).Symbol;
- if (enclosingNamedType != null &&
- !enclosingNamedType.IsSealed &&
- symbol != null &&
- symbol.IsOverridable()) {
- return false;
- }
- }
-
- var invalidTransformation1 = ParserWouldTreatExpressionAsCast(reducedName, memberAccess);
-
- return !invalidTransformation1;
- }
-
- internal static bool IsValidSymbolInfo(ISymbol symbol)
- {
- // name bound to only one symbol is valid
- return symbol != null && !symbol.IsErrorType ();
- }
-
- private static bool IsThisOrTypeOrNamespace(MemberAccessExpressionSyntax memberAccess, SemanticModel semanticModel)
- {
- if (memberAccess.Expression.Kind() == SyntaxKind.ThisExpression) {
- var previousToken = memberAccess.Expression.GetFirstToken().GetPreviousToken();
-
- var symbol = semanticModel.GetSymbolInfo(memberAccess.Name).Symbol;
-
- if (previousToken.Kind() == SyntaxKind.OpenParenToken &&
- previousToken.IsParentKind(SyntaxKind.ParenthesizedExpression) &&
- !previousToken.Parent.IsParentKind(SyntaxKind.ParenthesizedExpression) &&
- ((ParenthesizedExpressionSyntax)previousToken.Parent).Expression.Kind() == SyntaxKind.SimpleMemberAccessExpression &&
- symbol != null && symbol.Kind == SymbolKind.Method) {
- return false;
- }
-
- return true;
- }
-
- var expressionInfo = semanticModel.GetSymbolInfo(memberAccess.Expression);
- if (IsValidSymbolInfo(expressionInfo.Symbol)) {
- if (expressionInfo.Symbol is INamespaceOrTypeSymbol) {
- return true;
- }
-
- if (expressionInfo.Symbol.IsThisParameter()) {
- return true;
- }
- }
-
- return false;
- }
-
- private static bool WillConflictWithExistingLocal(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
- {
- if (simplifiedNode.Kind() == SyntaxKind.IdentifierName && !SyntaxFacts.IsInNamespaceOrTypeContext(expression)) {
- var identifierName = (IdentifierNameSyntax)simplifiedNode;
- var enclosingDeclarationSpace = FindImmediatelyEnclosingLocalVariableDeclarationSpace(expression);
- var enclosingMemberDeclaration = expression.FirstAncestorOrSelf<MemberDeclarationSyntax>();
- if (enclosingDeclarationSpace != null && enclosingMemberDeclaration != null) {
- var locals = enclosingMemberDeclaration.GetLocalDeclarationMap(identifierName.Identifier.ValueText);
- foreach (var token in locals) {
- if (GetAncestors<SyntaxNode>(token).Contains(enclosingDeclarationSpace)) {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- private static SyntaxNode FindImmediatelyEnclosingLocalVariableDeclarationSpace(SyntaxNode syntax)
- {
- for (var declSpace = syntax; declSpace != null; declSpace = declSpace.Parent) {
- switch (declSpace.Kind()) {
- // These are declaration-space-defining syntaxes, by the spec:
- case SyntaxKind.MethodDeclaration:
- case SyntaxKind.IndexerDeclaration:
- case SyntaxKind.OperatorDeclaration:
- case SyntaxKind.ConstructorDeclaration:
- case SyntaxKind.Block:
- case SyntaxKind.ParenthesizedLambdaExpression:
- case SyntaxKind.SimpleLambdaExpression:
- case SyntaxKind.AnonymousMethodExpression:
- case SyntaxKind.SwitchStatement:
- case SyntaxKind.ForEachKeyword:
- case SyntaxKind.ForStatement:
- case SyntaxKind.UsingStatement:
-
- // SPEC VIOLATION: We also want to stop walking out if, say, we are in a field
- // initializer. Technically according to the wording of the spec it should be
- // legal to use a simple name inconsistently inside a field initializer because
- // it does not define a local variable declaration space. In practice of course
- // we want to check for that. (As the native compiler does as well.)
-
- case SyntaxKind.FieldDeclaration:
- return declSpace;
- }
- }
-
- return null;
- }
-
- private static bool ParserWouldTreatExpressionAsCast(ExpressionSyntax reducedNode, MemberAccessExpressionSyntax originalNode)
- {
- SyntaxNode parent = originalNode;
- while (parent != null) {
- if (parent.IsParentKind(SyntaxKind.SimpleMemberAccessExpression)) {
- parent = parent.Parent;
- continue;
- }
-
- if (!parent.IsParentKind(SyntaxKind.ParenthesizedExpression)) {
- return false;
- }
-
- break;
- }
-
- var newExpression = parent.ReplaceNode((SyntaxNode)originalNode, reducedNode);
-
- // detect cast ambiguities according to C# spec #7.7.6
- if (IsNameOrMemberAccessButNoExpression(newExpression)) {
- var nextToken = parent.Parent.GetLastToken().GetNextToken();
-
- return nextToken.Kind() == SyntaxKind.OpenParenToken ||
- nextToken.Kind() == SyntaxKind.TildeToken ||
- nextToken.Kind() == SyntaxKind.ExclamationToken ||
- (SyntaxFacts.IsKeywordKind(nextToken.Kind()) && !(nextToken.Kind() == SyntaxKind.AsKeyword || nextToken.Kind() == SyntaxKind.IsKeyword));
- }
-
- return false;
- }
-
- private static bool IsMemberAccessADynamicInvocation(MemberAccessExpressionSyntax memberAccess, SemanticModel semanticModel)
- {
- var ancestorInvocation = memberAccess.FirstAncestorOrSelf<InvocationExpressionSyntax>();
-
- if (ancestorInvocation != null && ancestorInvocation.SpanStart == memberAccess.SpanStart) {
- var typeInfo = semanticModel.GetTypeInfo(ancestorInvocation);
- if (typeInfo.Type != null &&
- typeInfo.Type.Kind == SymbolKind.DynamicType) {
- return true;
- }
- }
-
- return false;
- }
-
- private static bool IsNameOrMemberAccessButNoExpression(SyntaxNode node)
- {
- if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression)) {
- var memberAccess = (MemberAccessExpressionSyntax)node;
-
- return memberAccess.Expression.IsKind(SyntaxKind.IdentifierName) ||
- IsNameOrMemberAccessButNoExpression(memberAccess.Expression);
- }
-
- return node.IsKind(SyntaxKind.IdentifierName);
- }
-
- private static bool AccessMethodWithDynamicArgumentInsideStructConstructor(this MemberAccessExpressionSyntax memberAccess, SemanticModel semanticModel)
- {
- var constructor = memberAccess.Ancestors().OfType<ConstructorDeclarationSyntax>().SingleOrDefault();
-
- if (constructor == null || constructor.Parent.Kind() != SyntaxKind.StructDeclaration) {
- return false;
- }
-
- return semanticModel.GetSymbolInfo(memberAccess.Name).CandidateReason == CandidateReason.LateBound;
- }
-
-
- public static bool CanReplaceWithReducedName(this NameSyntax name, TypeSyntax reducedName, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- var speculationAnalyzer = new SpeculationAnalyzer(name, reducedName, semanticModel, cancellationToken);
- if (speculationAnalyzer.ReplacementChangesSemantics())
- {
- return false;
- }
-
- return CanReplaceWithReducedNameInContext(name, reducedName, semanticModel, cancellationToken);
- }
-
- private static bool CanReplaceWithReducedNameInContext(this NameSyntax name, TypeSyntax reducedName, SemanticModel semanticModel, CancellationToken cancellationToken)
- {
- // Special case. if this new minimal name parses out to a predefined type, then we
- // have to make sure that we're not in a using alias. That's the one place where the
- // language doesn't allow predefined types. You have to use the fully qualified name
- // instead.
- var invalidTransformation1 = IsNonNameSyntaxInUsingDirective(name, reducedName);
- var invalidTransformation2 = WillConflictWithExistingLocal(name, reducedName);
- var invalidTransformation3 = IsAmbiguousCast(name, reducedName);
- var invalidTransformation4 = IsNullableTypeInPointerExpression(name, reducedName);
- var isNotNullableReplacable = name.IsNotNullableReplacable(reducedName);
-
- if (invalidTransformation1 || invalidTransformation2 || invalidTransformation3 || invalidTransformation4
- || isNotNullableReplacable)
- {
- return false;
- }
-
- return true;
- }
-
- private static bool IsNullableTypeInPointerExpression(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
- {
- // Note: nullable type syntax is not allowed in pointer type syntax
- if (simplifiedNode.Kind() == SyntaxKind.NullableType &&
- simplifiedNode.DescendantNodes().Any(n => n is PointerTypeSyntax))
- {
- return true;
- }
-
- return false;
- }
-
- private static bool IsAmbiguousCast(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
- {
- // Can't simplify a type name in a cast expression if it would then cause the cast to be
- // parsed differently. For example: (Foo::Bar)+1 is a cast. But if that simplifies to
- // (Bar)+1 then that's an arithmetic expression.
- if (expression.IsParentKind(SyntaxKind.CastExpression))
- {
- var castExpression = (CastExpressionSyntax)expression.Parent;
- if (castExpression.Type == expression)
- {
- var newCastExpression = castExpression.ReplaceNode((SyntaxNode)castExpression.Type, simplifiedNode);
- var reparsedCastExpression = SyntaxFactory.ParseExpression(newCastExpression.ToString());
-
- if (!reparsedCastExpression.IsKind(SyntaxKind.CastExpression))
- {
- return true;
- }
- }
- }
-
- return false;
- }
- private static bool IsNonNameSyntaxInUsingDirective(ExpressionSyntax expression, ExpressionSyntax simplifiedNode)
- {
- return
- expression.IsParentKind(SyntaxKind.UsingDirective) &&
- !(simplifiedNode is NameSyntax);
- }
-
- private static bool IsNotNullableReplacable(this NameSyntax name, TypeSyntax reducedName)
- {
- var isNotNullableReplacable = false;
- // var isLeftSideOfDot = name.IsLeftSideOfDot();
- // var isRightSideOfDot = name.IsRightSideOfDot();
-
- if (reducedName.Kind() == SyntaxKind.NullableType)
- {
- if (((NullableTypeSyntax)reducedName).ElementType.Kind() == SyntaxKind.OmittedTypeArgument)
- {
- isNotNullableReplacable = true;
- }
- else
- {
- isNotNullableReplacable = name.IsLeftSideOfDot() || name.IsRightSideOfDot();
- }
- }
-
- return isNotNullableReplacable;
- }
-
- public static SyntaxTokenList GetModifiers (this MemberDeclarationSyntax member)
- {
- if (member == null)
- throw new ArgumentNullException("member");
- var method = member as BaseMethodDeclarationSyntax;
- if (method != null)
- return method.Modifiers;
- var property = member as BasePropertyDeclarationSyntax;
- if (property != null)
- return property.Modifiers;
- var field = member as BaseFieldDeclarationSyntax;
- if (field != null)
- return field.Modifiers;
- return new SyntaxTokenList ();
- }
-
- public static ExplicitInterfaceSpecifierSyntax GetExplicitInterfaceSpecifierSyntax (this MemberDeclarationSyntax member)
- {
- if (member == null)
- throw new ArgumentNullException("member");
- var method = member as MethodDeclarationSyntax;
- if (method != null)
- return method.ExplicitInterfaceSpecifier;
- var property = member as BasePropertyDeclarationSyntax;
- if (property != null)
- return property.ExplicitInterfaceSpecifier;
- var evt = member as EventDeclarationSyntax;
- if (evt != null)
- return evt.ExplicitInterfaceSpecifier;
- return null;
- }
-// public static bool IsKind(this SyntaxToken token, SyntaxKind kind)
-// {
-// return token.RawKind == (int)kind;
-// }
-//
-// public static bool IsKind(this SyntaxTrivia trivia, SyntaxKind kind)
-// {
-// return trivia.RawKind == (int)kind;
-// }
-//
-// public static bool IsKind(this SyntaxNode node, SyntaxKind kind)
-// {
-// return node?.RawKind == (int)kind;
-// }
-//
-// public static bool IsKind(this SyntaxNodeOrToken nodeOrToken, SyntaxKind kind)
-// {
-// return nodeOrToken.RawKind == (int)kind;
-// }
-//
-
-// public static SyntaxNode GetParent(this SyntaxNode node)
-// {
-// return node != null ? node.Parent : null;
-// }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/SyntaxListExtension.cs b/main/src/addins/CSharpBinding/Util/SyntaxListExtension.cs
deleted file mode 100644
index 034fb840f7..0000000000
--- a/main/src/addins/CSharpBinding/Util/SyntaxListExtension.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SyntaxListExtensions
- {
- public static SyntaxList<T> RemoveRange<T>(this SyntaxList<T> syntaxList, int index, int count) where T : SyntaxNode
- {
- var result = new List<T>(syntaxList);
- result.RemoveRange(index, count);
- return SyntaxFactory.List(result);
- }
-
- public static SyntaxList<T> ToSyntaxList<T>(this IEnumerable<T> sequence) where T : SyntaxNode
- {
- return SyntaxFactory.List(sequence);
- }
-
- public static SyntaxList<T> Insert<T>(this SyntaxList<T> list, int index, T item) where T : SyntaxNode
- {
- return list.Take(index).Concat(new T[] { item } ).Concat(list.Skip(index)).ToSyntaxList();
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SyntaxNodeExtensions.cs b/main/src/addins/CSharpBinding/Util/SyntaxNodeExtensions.cs
deleted file mode 100644
index dba318122c..0000000000
--- a/main/src/addins/CSharpBinding/Util/SyntaxNodeExtensions.cs
+++ /dev/null
@@ -1,1721 +0,0 @@
-//
-// SyntaxNodeExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Collections;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using System.Threading.Tasks;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static partial class SyntaxNodeExtensions
- {
- public static IEnumerable<SyntaxNodeOrToken> DepthFirstTraversal(this SyntaxNode node)
- {
- return CommonSyntaxNodeOrTokenExtensions.DepthFirstTraversal(node);
- }
-
- public static IEnumerable<SyntaxNode> GetAncestors(this SyntaxNode node)
- {
- var current = node.Parent;
-
- while (current != null)
- {
- yield return current;
-
- current = current is IStructuredTriviaSyntax
- ? ((IStructuredTriviaSyntax)current).ParentTrivia.Token.Parent
- : current.Parent;
- }
- }
-
- public static IEnumerable<TNode> GetAncestors<TNode>(this SyntaxNode node)
- where TNode : SyntaxNode
- {
- var current = node.Parent;
- while (current != null)
- {
- if (current is TNode)
- {
- yield return (TNode)current;
- }
-
- current = current is IStructuredTriviaSyntax
- ? ((IStructuredTriviaSyntax)current).ParentTrivia.Token.Parent
- : current.Parent;
- }
- }
-
- public static TNode GetAncestor<TNode>(this SyntaxNode node)
- where TNode : SyntaxNode
- {
- if (node == null)
- {
- return default(TNode);
- }
-
- return node.GetAncestors<TNode>().FirstOrDefault();
- }
-
- public static TNode GetAncestorOrThis<TNode>(this SyntaxNode node)
- where TNode : SyntaxNode
- {
- if (node == null)
- {
- return default(TNode);
- }
-
- return node.GetAncestorsOrThis<TNode>().FirstOrDefault();
- }
-
- public static IEnumerable<TNode> GetAncestorsOrThis<TNode>(this SyntaxNode node)
- where TNode : SyntaxNode
- {
- var current = node;
- while (current != null)
- {
- if (current is TNode)
- {
- yield return (TNode)current;
- }
-
- current = current is IStructuredTriviaSyntax
- ? ((IStructuredTriviaSyntax)current).ParentTrivia.Token.Parent
- : current.Parent;
- }
- }
-
- public static bool HasAncestor<TNode>(this SyntaxNode node)
- where TNode : SyntaxNode
- {
- return node.GetAncestors<TNode>().Any();
- }
-
- public static IEnumerable<TSyntaxNode> Traverse<TSyntaxNode>(
- this SyntaxNode node, TextSpan searchSpan, Func<SyntaxNode, bool> predicate)
- where TSyntaxNode : SyntaxNode
- {
- // Contract.ThrowIfNull(node);
-
- var nodes = new LinkedList<SyntaxNode>();
- nodes.AddFirst(node);
-
- while (nodes.Count > 0)
- {
- var currentNode = nodes.First.Value;
- nodes.RemoveFirst();
-
- if (currentNode != null && searchSpan.Contains(currentNode.FullSpan) && predicate(currentNode))
- {
- if (currentNode is TSyntaxNode)
- {
- yield return (TSyntaxNode)currentNode;
- }
-
- nodes.AddRangeAtHead(currentNode.ChildNodes());
- }
- }
- }
-
- public static bool CheckParent<T>(this SyntaxNode node, Func<T, bool> valueChecker) where T : SyntaxNode
- {
- if (node == null)
- {
- return false;
- }
-
- var parentNode = node.Parent as T;
- if (parentNode == null)
- {
- return false;
- }
-
- return valueChecker(parentNode);
- }
-
- /// <summary>
- /// Returns true if is a given token is a child token of of a certain type of parent node.
- /// </summary>
- /// <typeparam name="TParent">The type of the parent node.</typeparam>
- /// <param name="node">The node that we are testing.</param>
- /// <param name="childGetter">A function that, when given the parent node, returns the child token we are interested in.</param>
- public static bool IsChildNode<TParent>(this SyntaxNode node, Func<TParent, SyntaxNode> childGetter)
- where TParent : SyntaxNode
- {
- var ancestor = node.GetAncestor<TParent>();
- if (ancestor == null)
- {
- return false;
- }
-
- var ancestorNode = childGetter(ancestor);
-
- return node == ancestorNode;
- }
-
- /// <summary>
- /// Returns true if this node is found underneath the specified child in the given parent.
- /// </summary>
- public static bool IsFoundUnder<TParent>(this SyntaxNode node, Func<TParent, SyntaxNode> childGetter)
- where TParent : SyntaxNode
- {
- var ancestor = node.GetAncestor<TParent>();
- if (ancestor == null)
- {
- return false;
- }
-
- var child = childGetter(ancestor);
-
- // See if node passes through child on the way up to ancestor.
- return node.GetAncestorsOrThis<SyntaxNode>().Contains(child);
- }
-
- public static SyntaxNode GetCommonRoot(this SyntaxNode node1, SyntaxNode node2)
- {
- //Contract.ThrowIfTrue(node1.RawKind == 0 || node2.RawKind == 0);
-
- // find common starting node from two nodes.
- // as long as two nodes belong to same tree, there must be at least one common root (Ex, compilation unit)
- var ancestors = node1.GetAncestorsOrThis<SyntaxNode>();
- var set = new HashSet<SyntaxNode>(node2.GetAncestorsOrThis<SyntaxNode>());
-
- return ancestors.First(set.Contains);
- }
-
- public static int Width(this SyntaxNode node)
- {
- return node.Span.Length;
- }
-
- public static int FullWidth(this SyntaxNode node)
- {
- return node.FullSpan.Length;
- }
-
- public static SyntaxNode FindInnermostCommonNode(
- this IEnumerable<SyntaxNode> nodes,
- Func<SyntaxNode, bool> predicate)
- {
- IEnumerable<SyntaxNode> blocks = null;
- foreach (var node in nodes)
- {
- blocks = blocks == null
- ? node.AncestorsAndSelf().Where(predicate)
- : blocks.Intersect(node.AncestorsAndSelf().Where(predicate));
- }
-
- return blocks == null ? null : blocks.First();
- }
-
- public static TSyntaxNode FindInnermostCommonNode<TSyntaxNode>(this IEnumerable<SyntaxNode> nodes)
- where TSyntaxNode : SyntaxNode
- {
- return (TSyntaxNode)nodes.FindInnermostCommonNode(n => n is TSyntaxNode);
- }
-
- /// <summary>
- /// create a new root node from the given root after adding annotations to the tokens
- ///
- /// tokens should belong to the given root
- /// </summary>
- public static SyntaxNode AddAnnotations(this SyntaxNode root, IEnumerable<Tuple<SyntaxToken, SyntaxAnnotation>> pairs)
- {
-// Contract.ThrowIfNull(root);
-// Contract.ThrowIfNull(pairs);
-
- var tokenMap = pairs.GroupBy(p => p.Item1, p => p.Item2).ToDictionary(g => g.Key, g => g.ToArray());
- return root.ReplaceTokens(tokenMap.Keys, (o, n) => o.WithAdditionalAnnotations(tokenMap[o]));
- }
-
- /// <summary>
- /// create a new root node from the given root after adding annotations to the nodes
- ///
- /// nodes should belong to the given root
- /// </summary>
- public static SyntaxNode AddAnnotations(this SyntaxNode root, IEnumerable<Tuple<SyntaxNode, SyntaxAnnotation>> pairs)
- {
-// Contract.ThrowIfNull(root);
-// Contract.ThrowIfNull(pairs);
-
- var tokenMap = pairs.GroupBy(p => p.Item1, p => p.Item2).ToDictionary(g => g.Key, g => g.ToArray());
- return root.ReplaceNodes(tokenMap.Keys, (o, n) => o.WithAdditionalAnnotations(tokenMap[o]));
- }
-
- public static TextSpan GetContainedSpan(this IEnumerable<SyntaxNode> nodes)
- {
-// Contract.ThrowIfNull(nodes);
-// Contract.ThrowIfFalse(nodes.Any());
-
- TextSpan fullSpan = nodes.First().Span;
- foreach (var node in nodes)
- {
- fullSpan = TextSpan.FromBounds(
- Math.Min(fullSpan.Start, node.SpanStart),
- Math.Max(fullSpan.End, node.Span.End));
- }
-
- return fullSpan;
- }
-
- public static IEnumerable<TextSpan> GetContiguousSpans(
- this IEnumerable<SyntaxNode> nodes, Func<SyntaxNode, SyntaxToken> getLastToken = null)
- {
- SyntaxNode lastNode = null;
- TextSpan? textSpan = null;
- foreach (var node in nodes)
- {
- if (lastNode == null)
- {
- textSpan = node.Span;
- }
- else
- {
- var lastToken = getLastToken == null
- ? lastNode.GetLastToken()
- : getLastToken(lastNode);
- if (lastToken.GetNextToken(includeDirectives: true) == node.GetFirstToken())
- {
- // Expand the span
- textSpan = TextSpan.FromBounds(textSpan.Value.Start, node.Span.End);
- }
- else
- {
- // Return the last span, and start a new one
- yield return textSpan.Value;
- textSpan = node.Span;
- }
- }
-
- lastNode = node;
- }
-
- if (textSpan.HasValue)
- {
- yield return textSpan.Value;
- }
- }
-
- public static bool OverlapsHiddenPosition(this SyntaxNode node, CancellationToken cancellationToken)
- {
- return node.OverlapsHiddenPosition(node.Span, cancellationToken);
- }
-
- public static bool OverlapsHiddenPosition(this SyntaxNode node, TextSpan span, CancellationToken cancellationToken)
- {
- return node.SyntaxTree.OverlapsHiddenPosition(span, cancellationToken);
- }
-
- public static bool OverlapsHiddenPosition(this SyntaxNode declaration, SyntaxNode startNode, SyntaxNode endNode, CancellationToken cancellationToken)
- {
- var start = startNode.Span.End;
- var end = endNode.SpanStart;
-
- var textSpan = TextSpan.FromBounds(start, end);
- return declaration.OverlapsHiddenPosition(textSpan, cancellationToken);
- }
-
- public static IEnumerable<T> GetAnnotatedNodes<T>(this SyntaxNode node, SyntaxAnnotation syntaxAnnotation) where T : SyntaxNode
- {
- return node.GetAnnotatedNodesAndTokens(syntaxAnnotation).Select(n => n.AsNode()).OfType<T>();
- }
-
- /// <summary>
- /// Creates a new tree of nodes from the existing tree with the specified old nodes replaced with a newly computed nodes.
- /// </summary>
- /// <param name="root">The root of the tree that contains all the specified nodes.</param>
- /// <param name="nodes">The nodes from the tree to be replaced.</param>
- /// <param name="computeReplacementAsync">A function that computes a replacement node for
- /// the argument nodes. The first argument is one of the original specified nodes. The second argument is
- /// the same node possibly rewritten with replaced descendants.</param>
- /// <param name="cancellationToken"></param>
- public static Task<TRootNode> ReplaceNodesAsync<TRootNode>(
- this TRootNode root,
- IEnumerable<SyntaxNode> nodes,
- Func<SyntaxNode, SyntaxNode, CancellationToken, Task<SyntaxNode>> computeReplacementAsync,
- CancellationToken cancellationToken) where TRootNode : SyntaxNode
- {
- return root.ReplaceSyntaxAsync(
- nodes: nodes, computeReplacementNodeAsync: computeReplacementAsync,
- tokens: null, computeReplacementTokenAsync: null,
- trivia: null, computeReplacementTriviaAsync: null,
- cancellationToken: cancellationToken);
- }
-
-// /// <summary>
-// /// Creates a new tree of tokens from the existing tree with the specified old tokens replaced with a newly computed tokens.
-// /// </summary>
-// /// <param name="root">The root of the tree that contains all the specified tokens.</param>
-// /// <param name="tokens">The tokens from the tree to be replaced.</param>
-// /// <param name="computeReplacementAsync">A function that computes a replacement token for
-// /// the argument tokens. The first argument is one of the originally specified tokens. The second argument is
-// /// the same token possibly rewritten with replaced trivia.</param>
-// /// <param name="cancellationToken"></param>
-// public static Task<TRootNode> ReplaceTokensAsync<TRootNode>(
-// this TRootNode root,
-// IEnumerable<SyntaxToken> tokens,
-// Func<SyntaxToken, SyntaxToken, CancellationToken, Task<SyntaxToken>> computeReplacementAsync,
-// CancellationToken cancellationToken) where TRootNode : SyntaxNode
-// {
-// return root.ReplaceSyntaxAsync(
-// nodes: null, computeReplacementNodeAsync: null,
-// tokens: tokens, computeReplacementTokenAsync: computeReplacementAsync,
-// trivia: null, computeReplacementTriviaAsync: null,
-// cancellationToken: cancellationToken);
-// }
-//
-// public static Task<TRoot> ReplaceTriviaAsync<TRoot>(
-// this TRoot root,
-// IEnumerable<SyntaxTrivia> trivia,
-// Func<SyntaxTrivia, SyntaxTrivia, CancellationToken, Task<SyntaxTrivia>> computeReplacementAsync,
-// CancellationToken cancellationToken) where TRoot : SyntaxNode
-// {
-// return root.ReplaceSyntaxAsync(
-// nodes: null, computeReplacementNodeAsync: null,
-// tokens: null, computeReplacementTokenAsync: null,
-// trivia: trivia, computeReplacementTriviaAsync: computeReplacementAsync,
-// cancellationToken: cancellationToken);
-// }
-
- public static async Task<TRoot> ReplaceSyntaxAsync<TRoot>(
- this TRoot root,
- IEnumerable<SyntaxNode> nodes,
- Func<SyntaxNode, SyntaxNode, CancellationToken, Task<SyntaxNode>> computeReplacementNodeAsync,
- IEnumerable<SyntaxToken> tokens,
- Func<SyntaxToken, SyntaxToken, CancellationToken, Task<SyntaxToken>> computeReplacementTokenAsync,
- IEnumerable<SyntaxTrivia> trivia,
- Func<SyntaxTrivia, SyntaxTrivia, CancellationToken, Task<SyntaxTrivia>> computeReplacementTriviaAsync,
- CancellationToken cancellationToken)
- where TRoot : SyntaxNode
- {
- // index all nodes, tokens and trivia by the full spans they cover
- var nodesToReplace = nodes != null ? nodes.ToDictionary(n => n.FullSpan) : new Dictionary<TextSpan, SyntaxNode>();
- var tokensToReplace = tokens != null ? tokens.ToDictionary(t => t.FullSpan) : new Dictionary<TextSpan, SyntaxToken>();
- var triviaToReplace = trivia != null ? trivia.ToDictionary(t => t.FullSpan) : new Dictionary<TextSpan, SyntaxTrivia>();
-
- var nodeReplacements = new Dictionary<SyntaxNode, SyntaxNode>();
- var tokenReplacements = new Dictionary<SyntaxToken, SyntaxToken>();
- var triviaReplacements = new Dictionary<SyntaxTrivia, SyntaxTrivia>();
-
- var retryAnnotations = new AnnotationTable<object>("RetryReplace");
-
- var spans = new List<TextSpan>(nodesToReplace.Count + tokensToReplace.Count + triviaToReplace.Count);
- spans.AddRange(nodesToReplace.Keys);
- spans.AddRange(tokensToReplace.Keys);
- spans.AddRange(triviaToReplace.Keys);
-
- while (spans.Count > 0)
- {
- // sort the spans of the items to be replaced so we can tell if any overlap
- spans.Sort((x, y) =>
- {
- // order by end offset, and then by length
- var d = x.End - y.End;
-
- if (d == 0)
- {
- d = x.Length - y.Length;
- }
-
- return d;
- });
-
- // compute replacements for all nodes that will go in the same batch
- // only spans that do not overlap go in the same batch.
- TextSpan previous = default(TextSpan);
- foreach (var span in spans)
- {
- // only add to replacement map if we don't intersect with the previous node. This taken with the sort order
- // should ensure that parent nodes are not processed in the same batch as child nodes.
- if (previous == default(TextSpan) || !previous.IntersectsWith(span))
- {
- SyntaxNode currentNode;
- SyntaxToken currentToken;
- SyntaxTrivia currentTrivia;
-
- if (nodesToReplace.TryGetValue(span, out currentNode))
- {
- var original = (SyntaxNode)retryAnnotations.GetAnnotations(currentNode).SingleOrDefault() ?? currentNode;
- var newNode = await computeReplacementNodeAsync(original, currentNode, cancellationToken).ConfigureAwait(false);
- nodeReplacements[currentNode] = newNode;
- }
- else if (tokensToReplace.TryGetValue(span, out currentToken))
- {
- var original = (SyntaxToken)retryAnnotations.GetAnnotations(currentToken).SingleOrDefault();
- if (original == default(SyntaxToken))
- {
- original = currentToken;
- }
-
- var newToken = await computeReplacementTokenAsync(original, currentToken, cancellationToken).ConfigureAwait(false);
- tokenReplacements[currentToken] = newToken;
- }
- else if (triviaToReplace.TryGetValue(span, out currentTrivia))
- {
- var original = (SyntaxTrivia)retryAnnotations.GetAnnotations(currentTrivia).SingleOrDefault();
- if (original == default(SyntaxTrivia))
- {
- original = currentTrivia;
- }
-
- var newTrivia = await computeReplacementTriviaAsync(original, currentTrivia, cancellationToken).ConfigureAwait(false);
- triviaReplacements[currentTrivia] = newTrivia;
- }
- }
-
- previous = span;
- }
-
- bool retryNodes = false;
- bool retryTokens = false;
- bool retryTrivia = false;
-
- // replace nodes in batch
- // submit all nodes so we can annotate the ones we don't replace
- root = root.ReplaceSyntax(
- nodes: nodesToReplace.Values,
- computeReplacementNode: (original, rewritten) =>
- {
- SyntaxNode replaced;
- if (rewritten != original || !nodeReplacements.TryGetValue(original, out replaced))
- {
- // the subtree did change, or we didn't have a replacement for it in this batch
- // so we need to add an annotation so we can find this node again for the next batch.
- replaced = retryAnnotations.WithAdditionalAnnotations(rewritten, original);
- retryNodes = true;
- }
-
- return replaced;
- },
- tokens: tokensToReplace.Values,
- computeReplacementToken: (original, rewritten) =>
- {
- SyntaxToken replaced;
- if (rewritten != original || !tokenReplacements.TryGetValue(original, out replaced))
- {
- // the subtree did change, or we didn't have a replacement for it in this batch
- // so we need to add an annotation so we can find this node again for the next batch.
- replaced = retryAnnotations.WithAdditionalAnnotations(rewritten, original);
- retryTokens = true;
- }
-
- return replaced;
- },
- trivia: triviaToReplace.Values,
- computeReplacementTrivia: (original, rewritten) =>
- {
- SyntaxTrivia replaced;
- if (!triviaReplacements.TryGetValue(original, out replaced))
- {
- // the subtree did change, or we didn't have a replacement for it in this batch
- // so we need to add an annotation so we can find this node again for the next batch.
- replaced = retryAnnotations.WithAdditionalAnnotations(rewritten, original);
- retryTrivia = true;
- }
-
- return replaced;
- });
-
- nodesToReplace.Clear();
- tokensToReplace.Clear();
- triviaToReplace.Clear();
- spans.Clear();
-
- // prepare next batch out of all remaining annotated nodes
- if (retryNodes)
- {
- nodesToReplace = retryAnnotations.GetAnnotatedNodes(root).ToDictionary(n => n.FullSpan);
- spans.AddRange(nodesToReplace.Keys);
- }
-
- if (retryTokens)
- {
- tokensToReplace = retryAnnotations.GetAnnotatedTokens(root).ToDictionary(t => t.FullSpan);
- spans.AddRange(tokensToReplace.Keys);
- }
-
- if (retryTrivia)
- {
- triviaToReplace = retryAnnotations.GetAnnotatedTrivia(root).ToDictionary(t => t.FullSpan);
- spans.AddRange(triviaToReplace.Keys);
- }
- }
-
- return root;
- }
-
-
- public static bool IsKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2)
- {
- if (node == null)
- {
- return false;
- }
-
- var csharpKind = node.Kind();
- return csharpKind == kind1 || csharpKind == kind2;
- }
-
- public static bool IsKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3)
- {
- if (node == null)
- {
- return false;
- }
-
- var csharpKind = node.Kind();
- return csharpKind == kind1 || csharpKind == kind2 || csharpKind == kind3;
- }
-
- public static bool IsKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3, SyntaxKind kind4)
- {
- if (node == null)
- {
- return false;
- }
-
- var csharpKind = node.Kind();
- return csharpKind == kind1 || csharpKind == kind2 || csharpKind == kind3 || csharpKind == kind4;
- }
-
- public static bool IsKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3, SyntaxKind kind4, SyntaxKind kind5)
- {
- if (node == null)
- {
- return false;
- }
-
- var csharpKind = node.Kind();
- return csharpKind == kind1 || csharpKind == kind2 || csharpKind == kind3 || csharpKind == kind4 || csharpKind == kind5;
- }
-
- /// <summary>
- /// Returns the list of using directives that affect <paramref name="node"/>. The list will be returned in
- /// top down order.
- /// </summary>
- public static IEnumerable<UsingDirectiveSyntax> GetEnclosingUsingDirectives(this SyntaxNode node)
- {
- return node.GetAncestorOrThis<CompilationUnitSyntax>().Usings
- .Concat(node.GetAncestorsOrThis<NamespaceDeclarationSyntax>()
- .Reverse()
- .SelectMany(n => n.Usings));
- }
-
- public static bool IsUnsafeContext(this SyntaxNode node)
- {
- if (node.GetAncestor<UnsafeStatementSyntax>() != null)
- {
- return true;
- }
-
- return node.GetAncestors<MemberDeclarationSyntax>().Any(
- m => m.GetModifiers().Any(SyntaxKind.UnsafeKeyword));
- }
-
- public static bool IsInStaticContext(this SyntaxNode node)
- {
- // this/base calls are always static.
- if (node.FirstAncestorOrSelf<ConstructorInitializerSyntax>() != null)
- {
- return true;
- }
-
- var memberDeclaration = node.FirstAncestorOrSelf<MemberDeclarationSyntax>();
- if (memberDeclaration == null)
- {
- return false;
- }
-
- switch (memberDeclaration.Kind())
- {
- case SyntaxKind.MethodDeclaration:
- case SyntaxKind.ConstructorDeclaration:
- case SyntaxKind.PropertyDeclaration:
- case SyntaxKind.EventDeclaration:
- case SyntaxKind.IndexerDeclaration:
- return memberDeclaration.GetModifiers().Any(SyntaxKind.StaticKeyword);
-
- case SyntaxKind.FieldDeclaration:
- // Inside a field one can only access static members of a type.
- return true;
-
- case SyntaxKind.DestructorDeclaration:
- return false;
- }
-
- // Global statements are not a static context.
- if (node.FirstAncestorOrSelf<GlobalStatementSyntax>() != null)
- {
- return false;
- }
-
- // any other location is considered static
- return true;
- }
-
- public static NamespaceDeclarationSyntax GetInnermostNamespaceDeclarationWithUsings(this SyntaxNode contextNode)
- {
- var usingDirectiveAncsestor = contextNode.GetAncestor<UsingDirectiveSyntax>();
- if (usingDirectiveAncsestor == null)
- {
- return contextNode.GetAncestorsOrThis<NamespaceDeclarationSyntax>().FirstOrDefault(n => n.Usings.Count > 0);
- }
- else
- {
- // We are inside a using directive. In this case, we should find and return the first 'parent' namespace with usings.
- var containingNamespace = usingDirectiveAncsestor.GetAncestor<NamespaceDeclarationSyntax>();
- if (containingNamespace == null)
- {
- // We are inside a top level using directive (i.e. one that's directly in the compilation unit).
- return null;
- }
- else
- {
- return containingNamespace.GetAncestors<NamespaceDeclarationSyntax>().FirstOrDefault(n => n.Usings.Count > 0);
- }
- }
- }
-
- // Matches the following:
- //
- // (whitespace* newline)+
- private static readonly Matcher<SyntaxTrivia> s_oneOrMoreBlankLines;
-
- // Matches the following:
- //
- // (whitespace* (single-comment|multi-comment) whitespace* newline)+ OneOrMoreBlankLines
- private static readonly Matcher<SyntaxTrivia> s_bannerMatcher;
-
- static SyntaxNodeExtensions()
- {
- var whitespace = Matcher.Repeat(Match(SyntaxKind.WhitespaceTrivia, "\\b"));
- var endOfLine = Match(SyntaxKind.EndOfLineTrivia, "\\n");
- var singleBlankLine = Matcher.Sequence(whitespace, endOfLine);
-
- var singleLineComment = Match(SyntaxKind.SingleLineCommentTrivia, "//");
- var multiLineComment = Match(SyntaxKind.MultiLineCommentTrivia, "/**/");
- var anyCommentMatcher = Matcher.Choice(singleLineComment, multiLineComment);
-
- var commentLine = Matcher.Sequence(whitespace, anyCommentMatcher, whitespace, endOfLine);
-
- s_oneOrMoreBlankLines = Matcher.OneOrMore(singleBlankLine);
- s_bannerMatcher =
- Matcher.Sequence(
- Matcher.OneOrMore(commentLine),
- s_oneOrMoreBlankLines);
-
- var typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.SyntaxNodeExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- containsInterleavedDirectiveMethod = typeInfo.GetMethod("ContainsInterleavedDirective", new[] { typeof(SyntaxNode), typeof (CancellationToken) });
- }
-
- private static Matcher<SyntaxTrivia> Match(SyntaxKind kind, string description)
- {
- return Matcher.Single<SyntaxTrivia>(t => t.Kind() == kind, description);
- }
-
- /// <summary>
- /// Returns all of the trivia to the left of this token up to the previous token (concatenates
- /// the previous token's trailing trivia and this token's leading trivia).
- /// </summary>
- public static IEnumerable<SyntaxTrivia> GetAllPrecedingTriviaToPreviousToken(this SyntaxToken token)
- {
- var prevToken = token.GetPreviousToken(includeSkipped: true);
- if (prevToken.Kind() == SyntaxKind.None)
- {
- return token.LeadingTrivia;
- }
-
- return prevToken.TrailingTrivia.Concat(token.LeadingTrivia);
- }
-
- public static bool IsBreakableConstruct(this SyntaxNode node)
- {
- switch (node.Kind())
- {
- case SyntaxKind.DoStatement:
- case SyntaxKind.WhileStatement:
- case SyntaxKind.SwitchStatement:
- case SyntaxKind.ForStatement:
- case SyntaxKind.ForEachStatement:
- return true;
- }
-
- return false;
- }
-
- public static bool IsContinuableConstruct(this SyntaxNode node)
- {
- switch (node.Kind())
- {
- case SyntaxKind.DoStatement:
- case SyntaxKind.WhileStatement:
- case SyntaxKind.ForStatement:
- case SyntaxKind.ForEachStatement:
- return true;
- }
-
- return false;
- }
-
- public static bool IsReturnableConstruct(this SyntaxNode node)
- {
- switch (node.Kind())
- {
- case SyntaxKind.AnonymousMethodExpression:
- case SyntaxKind.SimpleLambdaExpression:
- case SyntaxKind.ParenthesizedLambdaExpression:
- case SyntaxKind.MethodDeclaration:
- case SyntaxKind.ConstructorDeclaration:
- case SyntaxKind.DestructorDeclaration:
- case SyntaxKind.GetAccessorDeclaration:
- case SyntaxKind.SetAccessorDeclaration:
- case SyntaxKind.OperatorDeclaration:
- case SyntaxKind.AddAccessorDeclaration:
- case SyntaxKind.RemoveAccessorDeclaration:
- return true;
- }
-
- return false;
- }
-
- public static bool SpansPreprocessorDirective<TSyntaxNode>(
- this IEnumerable<TSyntaxNode> list)
- where TSyntaxNode : SyntaxNode
- {
- if (list == null || !list.Any())
- {
- return false;
- }
-
- var tokens = list.SelectMany(n => n.DescendantTokens());
-
- // todo: we need to dive into trivia here.
- return tokens.SpansPreprocessorDirective();
- }
-
- public static T WithPrependedLeadingTrivia<T>(
- this T node,
- params SyntaxTrivia[] trivia) where T : SyntaxNode
- {
- if (trivia.Length == 0)
- {
- return node;
- }
-
- return node.WithPrependedLeadingTrivia((IEnumerable<SyntaxTrivia>)trivia);
- }
-
- public static T WithPrependedLeadingTrivia<T>(
- this T node,
- SyntaxTriviaList trivia) where T : SyntaxNode
- {
- if (trivia.Count == 0)
- {
- return node;
- }
-
- return node.WithLeadingTrivia(trivia.Concat(node.GetLeadingTrivia()));
- }
-
- public static T WithPrependedLeadingTrivia<T>(
- this T node,
- IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode
- {
- return node.WithPrependedLeadingTrivia(trivia.ToSyntaxTriviaList());
- }
-
- public static T WithAppendedTrailingTrivia<T>(
- this T node,
- params SyntaxTrivia[] trivia) where T : SyntaxNode
- {
- if (trivia.Length == 0)
- {
- return node;
- }
-
- return node.WithAppendedTrailingTrivia((IEnumerable<SyntaxTrivia>)trivia);
- }
-
- public static T WithAppendedTrailingTrivia<T>(
- this T node,
- SyntaxTriviaList trivia) where T : SyntaxNode
- {
- if (trivia.Count == 0)
- {
- return node;
- }
-
- return node.WithTrailingTrivia(node.GetTrailingTrivia().Concat(trivia));
- }
-
- public static T WithAppendedTrailingTrivia<T>(
- this T node,
- IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode
- {
- return node.WithAppendedTrailingTrivia(trivia.ToSyntaxTriviaList());
- }
-
- public static T With<T>(
- this T node,
- IEnumerable<SyntaxTrivia> leadingTrivia,
- IEnumerable<SyntaxTrivia> trailingTrivia) where T : SyntaxNode
- {
- return node.WithLeadingTrivia(leadingTrivia).WithTrailingTrivia(trailingTrivia);
- }
-
- public static TNode ConvertToSingleLine<TNode>(this TNode node)
- where TNode : SyntaxNode
- {
- if (node == null)
- {
- return node;
- }
-
- var rewriter = new SingleLineRewriter();
- return (TNode)rewriter.Visit(node);
- }
-
- internal class SingleLineRewriter : CSharpSyntaxRewriter
- {
- private bool _lastTokenEndedInWhitespace;
-
- public override SyntaxToken VisitToken(SyntaxToken token)
- {
- if (_lastTokenEndedInWhitespace)
- {
- token = token.WithLeadingTrivia(Enumerable.Empty<SyntaxTrivia>());
- }
- else if (token.LeadingTrivia.Count > 0)
- {
- token = token.WithLeadingTrivia(SyntaxFactory.Space);
- }
-
- if (token.TrailingTrivia.Count > 0)
- {
- token = token.WithTrailingTrivia(SyntaxFactory.Space);
- _lastTokenEndedInWhitespace = true;
- }
- else
- {
- _lastTokenEndedInWhitespace = false;
- }
-
- return token;
- }
- }
-
- public static bool IsAnyArgumentList(this SyntaxNode node)
- {
- return node.IsKind(SyntaxKind.ArgumentList) ||
- node.IsKind(SyntaxKind.AttributeArgumentList) ||
- node.IsKind(SyntaxKind.BracketedArgumentList) ||
- node.IsKind(SyntaxKind.TypeArgumentList);
- }
-
- public static bool IsAnyLambda(this SyntaxNode node)
- {
- return
- node.IsKind(SyntaxKind.ParenthesizedLambdaExpression) ||
- node.IsKind(SyntaxKind.SimpleLambdaExpression);
- }
-
- public static bool IsAnyLambdaOrAnonymousMethod(this SyntaxNode node)
- {
- return node.IsAnyLambda() || node.IsKind(SyntaxKind.AnonymousMethodExpression);
- }
-
- readonly static MethodInfo containsInterleavedDirectiveMethod;
-
- /// <summary>
- /// Returns true if the passed in node contains an interleaved pp directive.
- ///
- /// i.e. The following returns false:
- ///
- /// void Foo() {
- /// #if true
- /// #endif
- /// }
- ///
- /// #if true
- /// void Foo() {
- /// }
- /// #endif
- ///
- /// but these return true:
- ///
- /// #if true
- /// void Foo() {
- /// #endif
- /// }
- ///
- /// void Foo() {
- /// #if true
- /// }
- /// #endif
- ///
- /// #if true
- /// void Foo() {
- /// #else
- /// }
- /// #endif
- ///
- /// i.e. the method returns true if it contains a PP directive that belongs to a grouping
- /// constructs (like #if/#endif or #region/#endregion), but the grouping construct isn't
- /// entirely contained within the span of the node.
- /// </summary>
- public static bool ContainsInterleavedDirective(
- this SyntaxNode syntaxNode,
- CancellationToken cancellationToken)
- {
- return (bool)containsInterleavedDirectiveMethod.Invoke (null, new object[] { syntaxNode, cancellationToken });
- }
-
-
-// /// <summary>
-// /// Breaks up the list of provided nodes, based on how they are interspersed with pp
-// /// directives, into groups. Within these groups nodes can be moved around safely, without
-// /// breaking any pp constructs.
-// /// </summary>
-// public static IList<IList<TSyntaxNode>> SplitNodesOnPreprocessorBoundaries<TSyntaxNode>(
-// this IEnumerable<TSyntaxNode> nodes,
-// CancellationToken cancellationToken)
-// where TSyntaxNode : SyntaxNode
-// {
-// var result = new List<IList<TSyntaxNode>>();
-//
-// var currentGroup = new List<TSyntaxNode>();
-// foreach (var node in nodes)
-// {
-// var hasUnmatchedInteriorDirective = node.ContainsInterleavedDirective(cancellationToken);
-// var hasLeadingDirective = node.GetLeadingTrivia().Any(t => SyntaxFacts.IsPreprocessorDirective(t.Kind()));
-//
-// if (hasUnmatchedInteriorDirective)
-// {
-// // we have a #if/#endif/#region/#endregion/#else/#elif in
-// // this node that belongs to a span of pp directives that
-// // is not entirely contained within the node. i.e.:
-// //
-// // void Foo() {
-// // #if ...
-// // }
-// //
-// // This node cannot be moved at all. It is in a group that
-// // only contains itself (and thus can never be moved).
-//
-// // add whatever group we've built up to now. And reset the
-// // next group to empty.
-// result.Add(currentGroup);
-// currentGroup = new List<TSyntaxNode>();
-//
-// result.Add(new List<TSyntaxNode> { node });
-// }
-// else if (hasLeadingDirective)
-// {
-// // We have a PP directive before us. i.e.:
-// //
-// // #if ...
-// // void Foo() {
-// //
-// // That means we start a new group that is contained between
-// // the above directive and the following directive.
-//
-// // add whatever group we've built up to now. And reset the
-// // next group to empty.
-// result.Add(currentGroup);
-// currentGroup = new List<TSyntaxNode>();
-//
-// currentGroup.Add(node);
-// }
-// else
-// {
-// // simple case. just add ourselves to the current group
-// currentGroup.Add(node);
-// }
-// }
-//
-// // add the remainder of the final group.
-// result.Add(currentGroup);
-//
-// // Now, filter out any empty groups.
-// result = result.Where(group => !group.IsEmpty()).ToList();
-// return result;
-// }
-//
-// public static IEnumerable<SyntaxTrivia> GetLeadingBlankLines<TSyntaxNode>(
-// this TSyntaxNode node)
-// where TSyntaxNode : SyntaxNode
-// {
-// IEnumerable<SyntaxTrivia> blankLines;
-// node.GetNodeWithoutLeadingBlankLines(out blankLines);
-// return blankLines;
-// }
-//
-// public static TSyntaxNode GetNodeWithoutLeadingBlankLines<TSyntaxNode>(
-// this TSyntaxNode node)
-// where TSyntaxNode : SyntaxNode
-// {
-// IEnumerable<SyntaxTrivia> blankLines;
-// return node.GetNodeWithoutLeadingBlankLines(out blankLines);
-// }
-//
-// public static TSyntaxNode GetNodeWithoutLeadingBlankLines<TSyntaxNode>(
-// this TSyntaxNode node, out IEnumerable<SyntaxTrivia> strippedTrivia)
-// where TSyntaxNode : SyntaxNode
-// {
-// var leadingTriviaToKeep = new List<SyntaxTrivia>(node.GetLeadingTrivia());
-//
-// var index = 0;
-// s_oneOrMoreBlankLines.TryMatch(leadingTriviaToKeep, ref index);
-//
-// strippedTrivia = new List<SyntaxTrivia>(leadingTriviaToKeep.Take(index));
-//
-// return node.WithLeadingTrivia(leadingTriviaToKeep.Skip(index));
-// }
-
- public static IEnumerable<SyntaxTrivia> GetLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(
- this TSyntaxNode node)
- where TSyntaxNode : SyntaxNode
- {
- IEnumerable<SyntaxTrivia> leadingTrivia;
- node.GetNodeWithoutLeadingBannerAndPreprocessorDirectives(out leadingTrivia);
- return leadingTrivia;
- }
-
- public static TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(
- this TSyntaxNode node)
- where TSyntaxNode : SyntaxNode
- {
- IEnumerable<SyntaxTrivia> strippedTrivia;
- return node.GetNodeWithoutLeadingBannerAndPreprocessorDirectives(out strippedTrivia);
- }
-
- public static TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(
- this TSyntaxNode node, out IEnumerable<SyntaxTrivia> strippedTrivia)
- where TSyntaxNode : SyntaxNode
- {
- var leadingTrivia = node.GetLeadingTrivia();
-
- // Rules for stripping trivia:
- // 1) If there is a pp directive, then it (and all preceding trivia) *must* be stripped.
- // This rule supersedes all other rules.
- // 2) If there is a doc comment, it cannot be stripped. Even if there is a doc comment,
- // followed by 5 new lines, then the doc comment still must stay with the node. This
- // rule does *not* supersede rule 1.
- // 3) Single line comments in a group (i.e. with no blank lines between them) belong to
- // the node *iff* there is no blank line between it and the following trivia.
-
- List<SyntaxTrivia> leadingTriviaToStrip, leadingTriviaToKeep;
-
- int ppIndex = -1;
- for (int i = leadingTrivia.Count - 1; i >= 0; i--)
- {
- if (SyntaxFacts.IsPreprocessorDirective(leadingTrivia[i].Kind()))
- {
- ppIndex = i;
- break;
- }
- }
-
- if (ppIndex != -1)
- {
- // We have a pp directive. it (and all all previous trivia) must be stripped.
- leadingTriviaToStrip = new List<SyntaxTrivia>(leadingTrivia.Take(ppIndex + 1));
- leadingTriviaToKeep = new List<SyntaxTrivia>(leadingTrivia.Skip(ppIndex + 1));
- }
- else
- {
- leadingTriviaToKeep = new List<SyntaxTrivia>(leadingTrivia);
- leadingTriviaToStrip = new List<SyntaxTrivia>();
- }
-
- // Now, consume as many banners as we can.
- var index = 0;
- while (
- s_oneOrMoreBlankLines.TryMatch(leadingTriviaToKeep, ref index) ||
- s_bannerMatcher.TryMatch(leadingTriviaToKeep, ref index))
- {
- }
-
- leadingTriviaToStrip.AddRange(leadingTriviaToKeep.Take(index));
-
- strippedTrivia = leadingTriviaToStrip;
- return node.WithLeadingTrivia(leadingTriviaToKeep.Skip(index));
- }
-
- public static bool IsAnyAssignExpression(this SyntaxNode node)
- {
- return SyntaxFacts.IsAssignmentExpression(node.Kind());
- }
-
- public static bool IsCompoundAssignExpression(this SyntaxNode node)
- {
- switch (node.Kind())
- {
- case SyntaxKind.AddAssignmentExpression:
- case SyntaxKind.SubtractAssignmentExpression:
- case SyntaxKind.MultiplyAssignmentExpression:
- case SyntaxKind.DivideAssignmentExpression:
- case SyntaxKind.ModuloAssignmentExpression:
- case SyntaxKind.AndAssignmentExpression:
- case SyntaxKind.ExclusiveOrAssignmentExpression:
- case SyntaxKind.OrAssignmentExpression:
- case SyntaxKind.LeftShiftAssignmentExpression:
- case SyntaxKind.RightShiftAssignmentExpression:
- return true;
- }
-
- return false;
- }
-
- public static bool IsLeftSideOfAssignExpression(this SyntaxNode node)
- {
- return node.IsParentKind(SyntaxKind.SimpleAssignmentExpression) &&
- ((AssignmentExpressionSyntax)node.Parent).Left == node;
- }
-
- public static bool IsLeftSideOfAnyAssignExpression(this SyntaxNode node)
- {
- return node.Parent.IsAnyAssignExpression() &&
- ((AssignmentExpressionSyntax)node.Parent).Left == node;
- }
-
- public static bool IsRightSideOfAnyAssignExpression(this SyntaxNode node)
- {
- return node.Parent.IsAnyAssignExpression() &&
- ((AssignmentExpressionSyntax)node.Parent).Right == node;
- }
-
- public static bool IsVariableDeclaratorValue(this SyntaxNode node)
- {
- return
- node.IsParentKind(SyntaxKind.EqualsValueClause) &&
- node.Parent.IsParentKind(SyntaxKind.VariableDeclarator) &&
- ((EqualsValueClauseSyntax)node.Parent).Value == node;
- }
-
- public static BlockSyntax FindInnermostCommonBlock(this IEnumerable<SyntaxNode> nodes)
- {
- return nodes.FindInnermostCommonNode<BlockSyntax>();
- }
-
- public static IEnumerable<SyntaxNode> GetAncestorsOrThis(this SyntaxNode node, Func<SyntaxNode, bool> predicate)
- {
- var current = node;
- while (current != null)
- {
- if (predicate(current))
- {
- yield return current;
- }
-
- current = current.Parent;
- }
- }
-
- /// <summary>
- /// Look inside a trivia list for a skipped token that contains the given position.
- /// </summary>
- private static readonly Func<SyntaxTriviaList, int, SyntaxToken> s_findSkippedTokenForward =
- (l, p) => FindTokenHelper.FindSkippedTokenForward(GetSkippedTokens(l), p);
-
- private static IEnumerable<SyntaxToken> GetSkippedTokens(SyntaxTriviaList list)
- {
- return list.Where(trivia => trivia.RawKind == (int)SyntaxKind.SkippedTokensTrivia)
- .SelectMany(t => ((SkippedTokensTriviaSyntax)t.GetStructure()).Tokens);
- }
-
- /// <summary>
- /// If the position is inside of token, return that token; otherwise, return the token to the right.
- /// </summary>
- public static SyntaxToken FindTokenOnRightOfPosition(
- this SyntaxNode root,
- int position,
- bool includeSkipped = true,
- bool includeDirectives = false,
- bool includeDocumentationComments = false)
- {
- var skippedTokenFinder = includeSkipped ? s_findSkippedTokenForward : (Func<SyntaxTriviaList, int, SyntaxToken>)null;
-
- return FindTokenHelper.FindTokenOnRightOfPosition<CompilationUnitSyntax>(
- root, position, skippedTokenFinder, includeSkipped, includeDirectives, includeDocumentationComments);
- }
-
-// /// <summary>
-// /// If the position is inside of token, return that token; otherwise, return the token to the left.
-// /// </summary>
-// public static SyntaxToken FindTokenOnLeftOfPosition(
-// this SyntaxNode root,
-// int position,
-// bool includeSkipped = true,
-// bool includeDirectives = false,
-// bool includeDocumentationComments = false)
-// {
-// var skippedTokenFinder = includeSkipped ? s_findSkippedTokenBackward : (Func<SyntaxTriviaList, int, SyntaxToken>)null;
-//
-// return FindTokenHelper.FindTokenOnLeftOfPosition<CompilationUnitSyntax>(
-// root, position, skippedTokenFinder, includeSkipped, includeDirectives, includeDocumentationComments);
-// }
-
- /// <summary>
- /// Returns child node or token that contains given position.
- /// </summary>
- /// <remarks>
- /// This is a copy of <see cref="SyntaxNode.ChildThatContainsPosition"/> that also returns the index of the child node.
- /// </remarks>
- internal static SyntaxNodeOrToken ChildThatContainsPosition(this SyntaxNode self, int position, out int childIndex)
- {
- var childList = self.ChildNodesAndTokens();
-
- int left = 0;
- int right = childList.Count - 1;
-
- while (left <= right)
- {
- int middle = left + ((right - left) / 2);
- SyntaxNodeOrToken node = childList.ElementAt(middle);
-
- var span = node.FullSpan;
- if (position < span.Start)
- {
- right = middle - 1;
- }
- else if (position >= span.End)
- {
- left = middle + 1;
- }
- else
- {
- childIndex = middle;
- return node;
- }
- }
-
- // we could check up front that index is within FullSpan,
- // but we wan to optimize for the common case where position is valid.
- Debug.Assert(!self.FullSpan.Contains(position), "Position is valid. How could we not find a child?");
- throw new ArgumentOutOfRangeException("position");
- }
-
- public static SyntaxNode GetParent(this SyntaxNode node)
- {
- return node != null ? node.Parent : null;
- }
-
- public static ValueTuple<SyntaxToken, SyntaxToken> GetBraces(this SyntaxNode node)
- {
- var namespaceNode = node as NamespaceDeclarationSyntax;
- if (namespaceNode != null)
- {
- return ValueTuple.Create(namespaceNode.OpenBraceToken, namespaceNode.CloseBraceToken);
- }
-
- var baseTypeNode = node as BaseTypeDeclarationSyntax;
- if (baseTypeNode != null)
- {
- return ValueTuple.Create(baseTypeNode.OpenBraceToken, baseTypeNode.CloseBraceToken);
- }
-
- var accessorListNode = node as AccessorListSyntax;
- if (accessorListNode != null)
- {
- return ValueTuple.Create(accessorListNode.OpenBraceToken, accessorListNode.CloseBraceToken);
- }
-
- var blockNode = node as BlockSyntax;
- if (blockNode != null)
- {
- return ValueTuple.Create(blockNode.OpenBraceToken, blockNode.CloseBraceToken);
- }
-
- var switchStatementNode = node as SwitchStatementSyntax;
- if (switchStatementNode != null)
- {
- return ValueTuple.Create(switchStatementNode.OpenBraceToken, switchStatementNode.CloseBraceToken);
- }
-
- var anonymousObjectCreationExpression = node as AnonymousObjectCreationExpressionSyntax;
- if (anonymousObjectCreationExpression != null)
- {
- return ValueTuple.Create(anonymousObjectCreationExpression.OpenBraceToken, anonymousObjectCreationExpression.CloseBraceToken);
- }
-
- var initializeExpressionNode = node as InitializerExpressionSyntax;
- if (initializeExpressionNode != null)
- {
- return ValueTuple.Create(initializeExpressionNode.OpenBraceToken, initializeExpressionNode.CloseBraceToken);
- }
-
- return new ValueTuple<SyntaxToken, SyntaxToken>();
- }
-
- public static ValueTuple<SyntaxToken, SyntaxToken> GetParentheses(this SyntaxNode node)
- {
- return node.TypeSwitch(
- (ParenthesizedExpressionSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (MakeRefExpressionSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (RefTypeExpressionSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (RefValueExpressionSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (CheckedExpressionSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (DefaultExpressionSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (TypeOfExpressionSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (SizeOfExpressionSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (ArgumentListSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (CastExpressionSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (WhileStatementSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (DoStatementSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (ForStatementSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (ForEachStatementSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (UsingStatementSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (FixedStatementSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (LockStatementSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (IfStatementSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (SwitchStatementSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (CatchDeclarationSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (AttributeArgumentListSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (ConstructorConstraintSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (ParameterListSyntax n) => ValueTuple.Create(n.OpenParenToken, n.CloseParenToken),
- (SyntaxNode n) => default(ValueTuple<SyntaxToken, SyntaxToken>));
- }
-
- public static ValueTuple<SyntaxToken, SyntaxToken> GetBrackets(this SyntaxNode node)
- {
- return node.TypeSwitch(
- (ArrayRankSpecifierSyntax n) => ValueTuple.Create(n.OpenBracketToken, n.CloseBracketToken),
- (BracketedArgumentListSyntax n) => ValueTuple.Create(n.OpenBracketToken, n.CloseBracketToken),
- (ImplicitArrayCreationExpressionSyntax n) => ValueTuple.Create(n.OpenBracketToken, n.CloseBracketToken),
- (AttributeListSyntax n) => ValueTuple.Create(n.OpenBracketToken, n.CloseBracketToken),
- (BracketedParameterListSyntax n) => ValueTuple.Create(n.OpenBracketToken, n.CloseBracketToken),
- (SyntaxNode n) => default(ValueTuple<SyntaxToken, SyntaxToken>));
- }
-
- public static bool IsEmbeddedStatementOwner(this SyntaxNode node)
- {
- return node is IfStatementSyntax ||
- node is ElseClauseSyntax ||
- node is WhileStatementSyntax ||
- node is ForStatementSyntax ||
- node is ForEachStatementSyntax ||
- node is UsingStatementSyntax ||
- node is DoStatementSyntax;
- }
-
- public static StatementSyntax GetEmbeddedStatement(this SyntaxNode node)
- {
- return node.TypeSwitch(
- (IfStatementSyntax n) => n.Statement,
- (ElseClauseSyntax n) => n.Statement,
- (WhileStatementSyntax n) => n.Statement,
- (ForStatementSyntax n) => n.Statement,
- (ForEachStatementSyntax n) => n.Statement,
- (UsingStatementSyntax n) => n.Statement,
- (DoStatementSyntax n) => n.Statement,
- (SyntaxNode n) => null);
- }
-
- public static SyntaxTokenList GetModifiers(this SyntaxNode member)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.EnumDeclaration:
- return ((EnumDeclarationSyntax)member).Modifiers;
- case SyntaxKind.ClassDeclaration:
- case SyntaxKind.InterfaceDeclaration:
- case SyntaxKind.StructDeclaration:
- return ((TypeDeclarationSyntax)member).Modifiers;
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).Modifiers;
- case SyntaxKind.FieldDeclaration:
- return ((FieldDeclarationSyntax)member).Modifiers;
- case SyntaxKind.EventFieldDeclaration:
- return ((EventFieldDeclarationSyntax)member).Modifiers;
- case SyntaxKind.ConstructorDeclaration:
- return ((ConstructorDeclarationSyntax)member).Modifiers;
- case SyntaxKind.DestructorDeclaration:
- return ((DestructorDeclarationSyntax)member).Modifiers;
- case SyntaxKind.PropertyDeclaration:
- return ((PropertyDeclarationSyntax)member).Modifiers;
- case SyntaxKind.EventDeclaration:
- return ((EventDeclarationSyntax)member).Modifiers;
- case SyntaxKind.IndexerDeclaration:
- return ((IndexerDeclarationSyntax)member).Modifiers;
- case SyntaxKind.OperatorDeclaration:
- return ((OperatorDeclarationSyntax)member).Modifiers;
- case SyntaxKind.ConversionOperatorDeclaration:
- return ((ConversionOperatorDeclarationSyntax)member).Modifiers;
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).Modifiers;
- case SyntaxKind.GetAccessorDeclaration:
- case SyntaxKind.SetAccessorDeclaration:
- case SyntaxKind.AddAccessorDeclaration:
- case SyntaxKind.RemoveAccessorDeclaration:
- return ((AccessorDeclarationSyntax)member).Modifiers;
- }
- }
-
- return default(SyntaxTokenList);
- }
-
- public static SyntaxNode WithModifiers(this SyntaxNode member, SyntaxTokenList modifiers)
- {
- if (member != null)
- {
- switch (member.Kind())
- {
- case SyntaxKind.EnumDeclaration:
- return ((EnumDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.ClassDeclaration:
- case SyntaxKind.InterfaceDeclaration:
- case SyntaxKind.StructDeclaration:
- return ((TypeDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.DelegateDeclaration:
- return ((DelegateDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.FieldDeclaration:
- return ((FieldDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.EventFieldDeclaration:
- return ((EventFieldDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.ConstructorDeclaration:
- return ((ConstructorDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.DestructorDeclaration:
- return ((DestructorDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.PropertyDeclaration:
- return ((PropertyDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.EventDeclaration:
- return ((EventDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.IndexerDeclaration:
- return ((IndexerDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.OperatorDeclaration:
- return ((OperatorDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.ConversionOperatorDeclaration:
- return ((ConversionOperatorDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.MethodDeclaration:
- return ((MethodDeclarationSyntax)member).WithModifiers(modifiers);
- case SyntaxKind.GetAccessorDeclaration:
- case SyntaxKind.SetAccessorDeclaration:
- case SyntaxKind.AddAccessorDeclaration:
- case SyntaxKind.RemoveAccessorDeclaration:
- return ((AccessorDeclarationSyntax)member).WithModifiers(modifiers);
- }
- }
-
- return null;
- }
-
- public static bool CheckTopLevel(this SyntaxNode node, TextSpan span)
- {
- var block = node as BlockSyntax;
- if (block != null)
- {
- return block.ContainsInBlockBody(span);
- }
-
- var field = node as FieldDeclarationSyntax;
- if (field != null)
- {
- foreach (var variable in field.Declaration.Variables)
- {
- if (variable.Initializer != null && variable.Initializer.Span.Contains(span))
- {
- return true;
- }
- }
- }
-
- var global = node as GlobalStatementSyntax;
- if (global != null)
- {
- return true;
- }
-
- var constructorInitializer = node as ConstructorInitializerSyntax;
- if (constructorInitializer != null)
- {
- return constructorInitializer.ContainsInArgument(span);
- }
-
- return false;
- }
-
- public static bool ContainsInArgument(this ConstructorInitializerSyntax initializer, TextSpan textSpan)
- {
- if (initializer == null)
- {
- return false;
- }
-
- return initializer.ArgumentList.Arguments.Any(a => a.Span.Contains(textSpan));
- }
-
- public static bool ContainsInBlockBody(this BlockSyntax block, TextSpan textSpan)
- {
- if (block == null)
- {
- return false;
- }
-
- var blockSpan = TextSpan.FromBounds(block.OpenBraceToken.Span.End, block.CloseBraceToken.SpanStart);
- return blockSpan.Contains(textSpan);
- }
-
- public static IEnumerable<MemberDeclarationSyntax> GetMembers(this SyntaxNode node)
- {
- var compilation = node as CompilationUnitSyntax;
- if (compilation != null)
- {
- return compilation.Members;
- }
-
- var @namespace = node as NamespaceDeclarationSyntax;
- if (@namespace != null)
- {
- return @namespace.Members;
- }
-
- var type = node as TypeDeclarationSyntax;
- if (type != null)
- {
- return type.Members;
- }
-
- var @enum = node as EnumDeclarationSyntax;
- if (@enum != null)
- {
- return @enum.Members;
- }
-
- return SpecializedCollections.EmptyEnumerable<MemberDeclarationSyntax>();
- }
-
- public static IEnumerable<SyntaxNode> GetBodies(this SyntaxNode node)
- {
- var constructor = node as ConstructorDeclarationSyntax;
- if (constructor != null)
- {
- var result = SpecializedCollections.SingletonEnumerable<SyntaxNode>(constructor.Body).WhereNotNull();
- var initializer = constructor.Initializer;
- if (initializer != null)
- {
- result = result.Concat(initializer.ArgumentList.Arguments.Select(a => (SyntaxNode)a.Expression).WhereNotNull());
- }
-
- return result;
- }
-
- var method = node as BaseMethodDeclarationSyntax;
- if (method != null)
- {
- return SpecializedCollections.SingletonEnumerable<SyntaxNode>(method.Body).WhereNotNull();
- }
-
- var property = node as BasePropertyDeclarationSyntax;
- if (property != null)
- {
- return property.AccessorList.Accessors.Select(a => a.Body).WhereNotNull();
- }
-
- var @enum = node as EnumMemberDeclarationSyntax;
- if (@enum != null)
- {
- if (@enum.EqualsValue != null)
- {
- return SpecializedCollections.SingletonEnumerable(@enum.EqualsValue.Value).WhereNotNull();
- }
- }
-
- var field = node as BaseFieldDeclarationSyntax;
- if (field != null)
- {
- return field.Declaration.Variables.Where(v => v.Initializer != null).Select(v => v.Initializer.Value).WhereNotNull();
- }
-
- return SpecializedCollections.EmptyEnumerable<SyntaxNode>();
- }
-
- public static ConditionalAccessExpressionSyntax GetParentConditionalAccessExpression(this SyntaxNode node)
- {
- var parent = node.Parent;
- while (parent != null)
- {
- // Because the syntax for conditional access is right associate, we cannot
- // simply take the first ancestor ConditionalAccessExpression. Instead, we
- // must walk upward until we find the ConditionalAccessExpression whose
- // OperatorToken appears left of the MemberBinding.
- if (parent.IsKind(SyntaxKind.ConditionalAccessExpression) &&
- ((ConditionalAccessExpressionSyntax)parent).OperatorToken.Span.End <= node.SpanStart)
- {
- return (ConditionalAccessExpressionSyntax)parent;
- }
-
- parent = parent.Parent;
- }
-
- return null;
- }
-
- public static bool IsDelegateOrConstructorOrMethodParameterList(this SyntaxNode node)
- {
- if (!node.IsKind(SyntaxKind.ParameterList))
- {
- return false;
- }
-
- return
- node.IsParentKind(SyntaxKind.MethodDeclaration) ||
- node.IsParentKind(SyntaxKind.ConstructorDeclaration) ||
- node.IsParentKind(SyntaxKind.DelegateDeclaration);
- }
-
- public static ConditionalAccessExpressionSyntax GetInnerMostConditionalAccessExpression(this SyntaxNode node)
- {
- if (!(node is ConditionalAccessExpressionSyntax))
- {
- return null;
- }
-
- var result = (ConditionalAccessExpressionSyntax)node;
- while (result.WhenNotNull is ConditionalAccessExpressionSyntax)
- {
- result = (ConditionalAccessExpressionSyntax)result.WhenNotNull;
- }
-
- return result;
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SyntaxTokenExtensions.cs b/main/src/addins/CSharpBinding/Util/SyntaxTokenExtensions.cs
deleted file mode 100644
index 79da3d46c6..0000000000
--- a/main/src/addins/CSharpBinding/Util/SyntaxTokenExtensions.cs
+++ /dev/null
@@ -1,1106 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.Text;
-using System.Threading;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SyntaxTokenExtensions
- {
- public static SyntaxNode GetAncestor(this SyntaxToken token, Func<SyntaxNode, bool> predicate)
- {
- return token.GetAncestor<SyntaxNode>(predicate);
- }
-
- public static T GetAncestor<T>(this SyntaxToken token, Func<T, bool> predicate = null)
- where T : SyntaxNode
- {
- return token.Parent != null
- ? token.Parent.FirstAncestorOrSelf(predicate)
- : default(T);
- }
-
- public static IEnumerable<T> GetAncestors<T>(this SyntaxToken token)
- where T : SyntaxNode
- {
- return token.Parent != null
- ? token.Parent.AncestorsAndSelf ().OfType<T> ()
- : Enumerable.Empty<T> ();
- }
-
- public static IEnumerable<SyntaxNode> GetAncestors(this SyntaxToken token, Func<SyntaxNode, bool> predicate)
- {
- return token.Parent != null
- ? token.Parent.AncestorsAndSelf().Where(predicate)
- : Enumerable.Empty<SyntaxNode>();
- }
-
- public static SyntaxNode GetCommonRoot(this SyntaxToken token1, SyntaxToken token2)
- {
- // Contract.ThrowIfTrue(token1.RawKind == 0 || token2.RawKind == 0);
-
- // find common starting node from two tokens.
- // as long as two tokens belong to same tree, there must be at least on common root (Ex, compilation unit)
- if (token1.Parent == null || token2.Parent == null)
- {
- return null;
- }
-
- return token1.Parent.GetCommonRoot(token2.Parent);
- }
-
- public static bool CheckParent<T>(this SyntaxToken token, Func<T, bool> valueChecker) where T : SyntaxNode
- {
- var parentNode = token.Parent as T;
- if (parentNode == null)
- {
- return false;
- }
-
- return valueChecker(parentNode);
- }
-
- public static int Width(this SyntaxToken token)
- {
- return token.Span.Length;
- }
-
- public static int FullWidth(this SyntaxToken token)
- {
- return token.FullSpan.Length;
- }
-
- public static SyntaxToken FindTokenFromEnd(this SyntaxNode root, int position, bool includeZeroWidth = true, bool findInsideTrivia = false)
- {
- var token = root.FindToken(position, findInsideTrivia);
- var previousToken = token.GetPreviousToken(
- includeZeroWidth, findInsideTrivia, findInsideTrivia, findInsideTrivia);
-
- if (token.SpanStart == position &&
- previousToken.RawKind != 0 &&
- previousToken.Span.End == position)
- {
- return previousToken;
- }
-
- return token;
- }
-
- public static bool IsUsingOrExternKeyword(this SyntaxToken token)
- {
- return
- token.Kind() == SyntaxKind.UsingKeyword ||
- token.Kind() == SyntaxKind.ExternKeyword;
- }
-
- public static bool IsUsingKeywordInUsingDirective(this SyntaxToken token)
- {
- if (token.IsKind(SyntaxKind.UsingKeyword))
- {
- var usingDirective = token.GetAncestor<UsingDirectiveSyntax>();
- if (usingDirective != null &&
- usingDirective.UsingKeyword == token)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsStaticKeywordInUsingDirective(this SyntaxToken token)
- {
- if (token.IsKind(SyntaxKind.StaticKeyword))
- {
- var usingDirective = token.GetAncestor<UsingDirectiveSyntax>();
- if (usingDirective != null &&
- usingDirective.StaticKeyword == token)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsBeginningOfStatementContext(this SyntaxToken token)
- {
- // cases:
- // {
- // |
-
- // }
- // |
-
- // Note, the following is *not* a legal statement context:
- // do { } |
-
- // ...;
- // |
-
- // case 0:
- // |
-
- // default:
- // |
-
- // label:
- // |
-
- // if (foo)
- // |
-
- // while (true)
- // |
-
- // do
- // |
-
- // for (;;)
- // |
-
- // foreach (var v in c)
- // |
-
- // else
- // |
-
- // using (expr)
- // |
-
- // lock (expr)
- // |
-
- // for ( ; ; Foo(), |
-
- if (token.Kind() == SyntaxKind.OpenBraceToken &&
- token.Parent.IsKind(SyntaxKind.Block))
- {
- return true;
- }
-
- if (token.Kind() == SyntaxKind.SemicolonToken)
- {
- var statement = token.GetAncestor<StatementSyntax>();
- if (statement != null && !statement.IsParentKind(SyntaxKind.GlobalStatement) &&
- statement.GetLastToken(includeZeroWidth: true) == token)
- {
- return true;
- }
- }
-
- if (token.Kind() == SyntaxKind.CloseBraceToken &&
- token.Parent.IsKind(SyntaxKind.Block))
- {
- if (token.Parent.Parent is StatementSyntax)
- {
- // Most blocks that are the child of statement are places
- // that we can follow with another statement. i.e.:
- // if { }
- // while () { }
- // There are two exceptions.
- // try {}
- // do {}
- if (!token.Parent.IsParentKind(SyntaxKind.TryStatement) &&
- !token.Parent.IsParentKind(SyntaxKind.DoStatement))
- {
- return true;
- }
- }
- else if (
- token.Parent.IsParentKind(SyntaxKind.ElseClause) ||
- token.Parent.IsParentKind(SyntaxKind.FinallyClause) ||
- token.Parent.IsParentKind(SyntaxKind.CatchClause) ||
- token.Parent.IsParentKind(SyntaxKind.SwitchSection))
- {
- return true;
- }
- }
-
- if (token.Kind() == SyntaxKind.CloseBraceToken &&
- token.Parent.IsKind(SyntaxKind.SwitchStatement))
- {
- return true;
- }
-
- if (token.Kind() == SyntaxKind.ColonToken)
- {
- if (token.Parent.IsKind(SyntaxKind.CaseSwitchLabel, SyntaxKind.DefaultSwitchLabel, SyntaxKind.LabeledStatement))
- {
- return true;
- }
- }
-
- if (token.Kind() == SyntaxKind.DoKeyword &&
- token.Parent.IsKind(SyntaxKind.DoStatement))
- {
- return true;
- }
-
- if (token.Kind() == SyntaxKind.CloseParenToken)
- {
- var parent = token.Parent;
- if (parent.IsKind(SyntaxKind.ForStatement) ||
- parent.IsKind(SyntaxKind.ForEachStatement) ||
- parent.IsKind(SyntaxKind.WhileStatement) ||
- parent.IsKind(SyntaxKind.IfStatement) ||
- parent.IsKind(SyntaxKind.LockStatement) ||
- parent.IsKind(SyntaxKind.UsingStatement))
- {
- return true;
- }
- }
-
- if (token.Kind() == SyntaxKind.ElseKeyword)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsBeginningOfGlobalStatementContext(this SyntaxToken token)
- {
- // cases:
- // }
- // |
-
- // ...;
- // |
-
- // extern alias Foo;
- // using System;
- // |
-
- // [assembly: Foo]
- // |
-
- if (token.Kind() == SyntaxKind.CloseBraceToken)
- {
- var memberDeclaration = token.GetAncestor<MemberDeclarationSyntax>();
- if (memberDeclaration != null && memberDeclaration.GetLastToken(includeZeroWidth: true) == token &&
- memberDeclaration.IsParentKind(SyntaxKind.CompilationUnit))
- {
- return true;
- }
- }
-
- if (token.Kind() == SyntaxKind.SemicolonToken)
- {
- var globalStatement = token.GetAncestor<GlobalStatementSyntax>();
- if (globalStatement != null && globalStatement.GetLastToken(includeZeroWidth: true) == token)
- {
- return true;
- }
-
- var memberDeclaration = token.GetAncestor<MemberDeclarationSyntax>();
- if (memberDeclaration != null && memberDeclaration.GetLastToken(includeZeroWidth: true) == token &&
- memberDeclaration.IsParentKind(SyntaxKind.CompilationUnit))
- {
- return true;
- }
-
- var compUnit = token.GetAncestor<CompilationUnitSyntax>();
- if (compUnit != null)
- {
- if (compUnit.Usings.Count > 0 && compUnit.Usings.Last().GetLastToken(includeZeroWidth: true) == token)
- {
- return true;
- }
-
- if (compUnit.Externs.Count > 0 && compUnit.Externs.Last().GetLastToken(includeZeroWidth: true) == token)
- {
- return true;
- }
- }
- }
-
- if (token.Kind() == SyntaxKind.CloseBracketToken)
- {
- var compUnit = token.GetAncestor<CompilationUnitSyntax>();
- if (compUnit != null)
- {
- if (compUnit.AttributeLists.Count > 0 && compUnit.AttributeLists.Last().GetLastToken(includeZeroWidth: true) == token)
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public static bool IsAfterPossibleCast(this SyntaxToken token)
- {
- if (token.Kind() == SyntaxKind.CloseParenToken)
- {
- if (token.Parent.IsKind(SyntaxKind.CastExpression))
- {
- return true;
- }
-
- if (token.Parent.IsKind(SyntaxKind.ParenthesizedExpression))
- {
- var parenExpr = token.Parent as ParenthesizedExpressionSyntax;
- var expr = parenExpr.Expression;
-
- if (expr is TypeSyntax)
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public static bool IsLastTokenOfNode<T>(this SyntaxToken token)
- where T : SyntaxNode
- {
- var node = token.GetAncestor<T>();
- return node != null && token == node.GetLastToken(includeZeroWidth: true);
- }
-
- public static bool IsLastTokenOfQueryClause(this SyntaxToken token)
- {
- if (token.IsLastTokenOfNode<QueryClauseSyntax>())
- {
- return true;
- }
-
- if (token.Kind() == SyntaxKind.IdentifierToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.IntoKeyword)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsPreProcessorExpressionContext(this SyntaxToken targetToken)
- {
- // cases:
- // #if |
- // #if foo || |
- // #if foo && |
- // #if ( |
- // #if ! |
- // Same for elif
-
- if (targetToken.GetAncestor<ConditionalDirectiveTriviaSyntax>() == null)
- {
- return false;
- }
-
- // #if
- // #elif
- if (targetToken.Kind() == SyntaxKind.IfKeyword ||
- targetToken.Kind() == SyntaxKind.ElifKeyword)
- {
- return true;
- }
-
- // ( |
- if (targetToken.Kind() == SyntaxKind.OpenParenToken &&
- targetToken.Parent.IsKind(SyntaxKind.ParenthesizedExpression))
- {
- return true;
- }
-
- // ! |
- if (targetToken.Parent is PrefixUnaryExpressionSyntax)
- {
- var prefix = targetToken.Parent as PrefixUnaryExpressionSyntax;
- return prefix.OperatorToken == targetToken;
- }
-
- // a &&
- // a ||
- if (targetToken.Parent is BinaryExpressionSyntax)
- {
- var binary = targetToken.Parent as BinaryExpressionSyntax;
- return binary.OperatorToken == targetToken;
- }
-
- return false;
- }
-
- public static bool IsOrderByDirectionContext(this SyntaxToken targetToken)
- {
- // cases:
- // orderby a |
- // orderby a a|
- // orderby a, b |
- // orderby a, b a|
-
- if (!targetToken.IsKind(SyntaxKind.IdentifierToken, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken))
- {
- return false;
- }
-
- var ordering = targetToken.GetAncestor<OrderingSyntax>();
- if (ordering == null)
- {
- return false;
- }
-
- // orderby a |
- // orderby a, b |
- var lastToken = ordering.Expression.GetLastToken(includeSkipped: true);
-
- if (targetToken == lastToken)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsSwitchLabelContext(this SyntaxToken targetToken)
- {
- // cases:
- // case X: |
- // default: |
- // switch (e) { |
- //
- // case X: Statement(); |
-
- if (targetToken.Kind() == SyntaxKind.OpenBraceToken &&
- targetToken.Parent.IsKind(SyntaxKind.SwitchStatement))
- {
- return true;
- }
-
- if (targetToken.Kind() == SyntaxKind.ColonToken)
- {
- if (targetToken.Parent.IsKind(SyntaxKind.CaseSwitchLabel, SyntaxKind.DefaultSwitchLabel))
- {
- return true;
- }
- }
-
- if (targetToken.Kind() == SyntaxKind.SemicolonToken ||
- targetToken.Kind() == SyntaxKind.CloseBraceToken)
- {
- var section = targetToken.GetAncestor<SwitchSectionSyntax>();
- if (section != null)
- {
- foreach (var statement in section.Statements)
- {
- if (targetToken == statement.GetLastToken(includeSkipped: true))
- {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- public static bool IsXmlCrefParameterModifierContext(this SyntaxToken targetToken)
- {
- return targetToken.IsKind(SyntaxKind.CommaToken, SyntaxKind.OpenParenToken)
- && targetToken.Parent.IsKind(SyntaxKind.CrefBracketedParameterList, SyntaxKind.CrefParameterList);
- }
-
- public static bool IsConstructorOrMethodParameterArgumentContext(this SyntaxToken targetToken)
- {
- // cases:
- // Foo( |
- // Foo(expr, |
- // Foo(bar: |
- // new Foo( |
- // new Foo(expr, |
- // new Foo(bar: |
- // Foo : base( |
- // Foo : base(bar: |
- // Foo : this( |
- // Foo : ths(bar: |
-
- // Foo(bar: |
- if (targetToken.Kind() == SyntaxKind.ColonToken &&
- targetToken.Parent.IsKind(SyntaxKind.NameColon) &&
- targetToken.Parent.IsParentKind(SyntaxKind.Argument) &&
- targetToken.Parent.GetParent().IsParentKind(SyntaxKind.ArgumentList))
- {
- var owner = targetToken.Parent.GetParent().GetParent().GetParent();
- if (owner.IsKind(SyntaxKind.InvocationExpression) ||
- owner.IsKind(SyntaxKind.ObjectCreationExpression) ||
- owner.IsKind(SyntaxKind.BaseConstructorInitializer) ||
- owner.IsKind(SyntaxKind.ThisConstructorInitializer))
- {
- return true;
- }
- }
-
- if (targetToken.Kind() == SyntaxKind.OpenParenToken ||
- targetToken.Kind() == SyntaxKind.CommaToken)
- {
- if (targetToken.Parent.IsKind(SyntaxKind.ArgumentList))
- {
- if (targetToken.Parent.IsParentKind(SyntaxKind.InvocationExpression) ||
- targetToken.Parent.IsParentKind(SyntaxKind.ObjectCreationExpression) ||
- targetToken.Parent.IsParentKind(SyntaxKind.BaseConstructorInitializer) ||
- targetToken.Parent.IsParentKind(SyntaxKind.ThisConstructorInitializer))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public static bool IsUnaryOperatorContext(this SyntaxToken targetToken)
- {
- if (targetToken.Kind() == SyntaxKind.OperatorKeyword &&
- targetToken.GetPreviousToken(includeSkipped: true).IsLastTokenOfNode<TypeSyntax>())
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsUnsafeContext(this SyntaxToken targetToken)
- {
- return
- targetToken.GetAncestors<StatementSyntax>().Any(s => s.IsKind(SyntaxKind.UnsafeStatement)) ||
- targetToken.GetAncestors<MemberDeclarationSyntax>().Any(m => m.GetModifiers().Any(SyntaxKind.UnsafeKeyword));
- }
-
- public static bool IsAfterYieldKeyword(this SyntaxToken targetToken)
- {
- // yield |
- // yield r|
-
- if (targetToken.IsKindOrHasMatchingText(SyntaxKind.YieldKeyword))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsAccessorDeclarationContext<TMemberNode>(this SyntaxToken targetToken, int position, SyntaxKind kind = SyntaxKind.None)
- where TMemberNode : SyntaxNode
- {
- if (!IsAccessorDeclarationContextWorker(targetToken))
- {
- return false;
- }
-
- var list = targetToken.GetAncestor<AccessorListSyntax>();
- if (list == null)
- {
- return false;
- }
-
- // Check if we already have this accessor. (however, don't count it
- // if the user is *on* that accessor.
- var existingAccessor = list.Accessors
- .Select(a => a.Keyword)
- .FirstOrDefault(a => !a.IsMissing && a.IsKindOrHasMatchingText(kind));
-
- if (existingAccessor.Kind() != SyntaxKind.None)
- {
- var existingAccessorSpan = existingAccessor.Span;
- if (!existingAccessorSpan.IntersectsWith(position))
- {
- return false;
- }
- }
-
- var decl = targetToken.GetAncestor<TMemberNode>();
- return decl != null;
- }
-
- private static bool IsAccessorDeclarationContextWorker(SyntaxToken targetToken)
- {
- // cases:
- // int Foo { |
- // int Foo { private |
- // int Foo { set { } |
- // int Foo { set; |
- // int Foo { [Bar]|
-
- // Consume all preceding access modifiers
- while (targetToken.Kind() == SyntaxKind.InternalKeyword ||
- targetToken.Kind() == SyntaxKind.PublicKeyword ||
- targetToken.Kind() == SyntaxKind.ProtectedKeyword ||
- targetToken.Kind() == SyntaxKind.PrivateKeyword)
- {
- targetToken = targetToken.GetPreviousToken(includeSkipped: true);
- }
-
- // int Foo { |
- // int Foo { private |
- if (targetToken.Kind() == SyntaxKind.OpenBraceToken &&
- targetToken.Parent.IsKind(SyntaxKind.AccessorList))
- {
- return true;
- }
-
- // int Foo { set { } |
- // int Foo { set { } private |
- if (targetToken.Kind() == SyntaxKind.CloseBraceToken &&
- targetToken.Parent.IsKind(SyntaxKind.Block) &&
- targetToken.Parent.GetParent() is AccessorDeclarationSyntax)
- {
- return true;
- }
-
- // int Foo { set; |
- if (targetToken.Kind() == SyntaxKind.SemicolonToken &&
- targetToken.Parent is AccessorDeclarationSyntax)
- {
- return true;
- }
-
- // int Foo { [Bar]|
- if (targetToken.Kind() == SyntaxKind.CloseBracketToken &&
- targetToken.Parent.IsKind(SyntaxKind.AttributeList) &&
- targetToken.Parent.GetParent() is AccessorDeclarationSyntax)
- {
- return true;
- }
-
- return false;
- }
-
- private static bool IsGenericInterfaceOrDelegateTypeParameterList(SyntaxNode node)
- {
- if (node.IsKind(SyntaxKind.TypeParameterList))
- {
- if (node.IsParentKind(SyntaxKind.InterfaceDeclaration))
- {
- var decl = node.Parent as TypeDeclarationSyntax;
- return decl.TypeParameterList == node;
- }
- else if (node.IsParentKind(SyntaxKind.DelegateDeclaration))
- {
- var decl = node.Parent as DelegateDeclarationSyntax;
- return decl.TypeParameterList == node;
- }
- }
-
- return false;
- }
-
- public static bool IsTypeParameterVarianceContext(this SyntaxToken targetToken)
- {
- // cases:
- // interface IFoo<|
- // interface IFoo<A,|
- // interface IFoo<[Bar]|
-
- // deletate X D<|
- // deletate X D<A,|
- // deletate X D<[Bar]|
- if (targetToken.Kind() == SyntaxKind.LessThanToken &&
- IsGenericInterfaceOrDelegateTypeParameterList(targetToken.Parent))
- {
- return true;
- }
-
- if (targetToken.Kind() == SyntaxKind.CommaToken &&
- IsGenericInterfaceOrDelegateTypeParameterList(targetToken.Parent))
- {
- return true;
- }
-
- if (targetToken.Kind() == SyntaxKind.CloseBracketToken &&
- targetToken.Parent.IsKind(SyntaxKind.AttributeList) &&
- targetToken.Parent.IsParentKind(SyntaxKind.TypeParameter) &&
- IsGenericInterfaceOrDelegateTypeParameterList(targetToken.Parent.GetParent().GetParent()))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsMandatoryNamedParameterPosition(this SyntaxToken token)
- {
- if (token.Kind() == SyntaxKind.CommaToken && token.Parent is BaseArgumentListSyntax)
- {
- var argumentList = (BaseArgumentListSyntax)token.Parent;
-
- foreach (var item in argumentList.Arguments.GetWithSeparators())
- {
- if (item.IsToken && item.AsToken() == token)
- {
- return false;
- }
-
- if (item.IsNode)
- {
- var node = item.AsNode() as ArgumentSyntax;
- if (node != null && node.NameColon != null)
- {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- public static bool IsKindOrHasMatchingText(this SyntaxToken token, SyntaxKind kind)
- {
- return token.Kind() == kind || token.HasMatchingText(kind);
- }
-
- public static bool HasMatchingText(this SyntaxToken token, SyntaxKind kind)
- {
- return token.ToString() == SyntaxFacts.GetText(kind);
- }
-
- public static bool IsKind(this SyntaxToken token, SyntaxKind kind1, SyntaxKind kind2)
- {
- return token.Kind() == kind1
- || token.Kind() == kind2;
- }
-
- public static bool IsKind(this SyntaxToken token, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3)
- {
- return token.Kind() == kind1
- || token.Kind() == kind2
- || token.Kind() == kind3;
- }
-
- public static bool IsKind(this SyntaxToken token, params SyntaxKind[] kinds)
- {
- return kinds.Contains(token.Kind());
- }
-
- public static bool IsLiteral(this SyntaxToken token)
- {
- switch (token.Kind())
- {
- case SyntaxKind.CharacterLiteralToken:
- case SyntaxKind.FalseKeyword:
- case SyntaxKind.NumericLiteralToken:
- case SyntaxKind.StringLiteralToken:
- case SyntaxKind.TrueKeyword:
- return true;
-
- default:
- return false;
- }
- }
-
- public static bool IntersectsWith(this SyntaxToken token, int position)
- {
- return token.Span.IntersectsWith(position);
- }
-
- public static SyntaxToken GetPreviousTokenIfTouchingWord(this SyntaxToken token, int position)
- {
- return token.IntersectsWith(position) && IsWord(token)
- ? token.GetPreviousToken(includeSkipped: true)
- : token;
- }
-
- public static bool IsWord(this SyntaxToken token)
- {
- return token.IsKind(SyntaxKind.IdentifierToken)
- || SyntaxFacts.IsKeywordKind(token.Kind())
- || SyntaxFacts.IsContextualKeyword(token.Kind())
- || SyntaxFacts.IsPreprocessorKeyword(token.Kind());
- }
-
- public static SyntaxToken GetNextNonZeroWidthTokenOrEndOfFile(this SyntaxToken token)
- {
- return token.GetNextTokenOrEndOfFile();
- }
-
- public static SyntaxToken GetNextTokenOrEndOfFile(
- this SyntaxToken token,
- bool includeZeroWidth = false,
- bool includeSkipped = false,
- bool includeDirectives = false,
- bool includeDocumentationComments = false)
- {
- var nextToken = token.GetNextToken(includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
-
- return nextToken.Kind() == SyntaxKind.None
- ? token.GetAncestor<CompilationUnitSyntax>().EndOfFileToken
- : nextToken;
- }
-
- public static SyntaxToken With(this SyntaxToken token, SyntaxTriviaList leading, SyntaxTriviaList trailing)
- {
- return token.WithLeadingTrivia(leading).WithTrailingTrivia(trailing);
- }
-
- /// <summary>
- /// Determines whether the given SyntaxToken is the first token on a line in the specified SourceText.
- /// </summary>
- public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
- {
- var previousToken = token.GetPreviousToken(includeSkipped: true, includeDirectives: true, includeDocumentationComments: true);
- if (previousToken.Kind() == SyntaxKind.None)
- {
- return true;
- }
-
- var tokenLine = text.Lines.IndexOf(token.SpanStart);
- var previousTokenLine = text.Lines.IndexOf(previousToken.SpanStart);
- return tokenLine > previousTokenLine;
- }
-
- public static bool SpansPreprocessorDirective(this IEnumerable<SyntaxToken> tokens)
- {
- // we want to check all leading trivia of all tokens (except the
- // first one), and all trailing trivia of all tokens (except the
- // last one).
-
- var first = true;
- var previousToken = default(SyntaxToken);
-
- foreach (var token in tokens)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- // check the leading trivia of this token, and the trailing trivia
- // of the previous token.
- if (SpansPreprocessorDirective(token.LeadingTrivia) ||
- SpansPreprocessorDirective(previousToken.TrailingTrivia))
- {
- return true;
- }
- }
-
- previousToken = token;
- }
-
- return false;
- }
-
- private static bool SpansPreprocessorDirective(SyntaxTriviaList list)
- {
- return list.Any(t => t.GetStructure() is DirectiveTriviaSyntax);
- }
-
- public static SyntaxToken WithoutTrivia(
- this SyntaxToken token,
- params SyntaxTrivia[] trivia)
- {
- if (!token.LeadingTrivia.Any() && !token.TrailingTrivia.Any())
- {
- return token;
- }
-
- return token.With(new SyntaxTriviaList(), new SyntaxTriviaList());
- }
-
- public static SyntaxToken WithPrependedLeadingTrivia(
- this SyntaxToken token,
- params SyntaxTrivia[] trivia)
- {
- if (trivia.Length == 0)
- {
- return token;
- }
-
- return token.WithPrependedLeadingTrivia((IEnumerable<SyntaxTrivia>)trivia);
- }
-
- public static SyntaxToken WithPrependedLeadingTrivia(
- this SyntaxToken token,
- SyntaxTriviaList trivia)
- {
- if (trivia.Count == 0)
- {
- return token;
- }
-
- return token.WithLeadingTrivia(trivia.Concat(token.LeadingTrivia));
- }
-
- public static SyntaxToken WithPrependedLeadingTrivia(
- this SyntaxToken token,
- IEnumerable<SyntaxTrivia> trivia)
- {
- return token.WithPrependedLeadingTrivia(trivia.ToSyntaxTriviaList());
- }
-
- public static SyntaxToken WithAppendedTrailingTrivia(
- this SyntaxToken token,
- IEnumerable<SyntaxTrivia> trivia)
- {
- return token.WithTrailingTrivia(token.TrailingTrivia.Concat(trivia));
- }
-
- /// <summary>
- /// Retrieves all trivia after this token, including it's trailing trivia and
- /// the leading trivia of the next token.
- /// </summary>
- public static IEnumerable<SyntaxTrivia> GetAllTrailingTrivia(this SyntaxToken token)
- {
- foreach (var trivia in token.TrailingTrivia)
- {
- yield return trivia;
- }
-
- var nextToken = token.GetNextTokenOrEndOfFile(includeZeroWidth: true, includeSkipped: true, includeDirectives: true, includeDocumentationComments: true);
-
- foreach (var trivia in nextToken.LeadingTrivia)
- {
- yield return trivia;
- }
- }
-
- public static bool TryParseGenericName(this SyntaxToken genericIdentifier, CancellationToken cancellationToken, out GenericNameSyntax genericName)
- {
- if (genericIdentifier.GetNextToken(includeSkipped: true).Kind() == SyntaxKind.LessThanToken)
- {
- var lastToken = genericIdentifier.FindLastTokenOfPartialGenericName();
-
- var syntaxTree = genericIdentifier.SyntaxTree;
- var name = SyntaxFactory.ParseName(syntaxTree.GetText(cancellationToken).ToString(TextSpan.FromBounds(genericIdentifier.SpanStart, lastToken.Span.End)));
-
- genericName = name as GenericNameSyntax;
- return genericName != null;
- }
-
- genericName = null;
- return false;
- }
-
- /// <summary>
- /// Lexically, find the last token that looks like it's part of this generic name.
- /// </summary>
- /// <param name="genericIdentifier">The "name" of the generic identifier, last token before
- /// the "&amp;"</param>
- /// <returns>The last token in the name</returns>
- /// <remarks>This is related to the code in <see cref="SyntaxTreeExtensions.IsInPartiallyWrittenGeneric(SyntaxTree, int, CancellationToken)"/></remarks>
- public static SyntaxToken FindLastTokenOfPartialGenericName(this SyntaxToken genericIdentifier)
- {
- //Contract.ThrowIfFalse(genericIdentifier.Kind() == SyntaxKind.IdentifierToken);
-
- // advance to the "<" token
- var token = genericIdentifier.GetNextToken(includeSkipped: true);
- //Contract.ThrowIfFalse(token.Kind() == SyntaxKind.LessThanToken);
-
- int stack = 0;
-
- do
- {
- // look forward one token
- {
- var next = token.GetNextToken(includeSkipped: true);
- if (next.Kind() == SyntaxKind.None)
- {
- return token;
- }
-
- token = next;
- }
-
- if (token.Kind() == SyntaxKind.GreaterThanToken)
- {
- if (stack == 0)
- {
- return token;
- }
- else
- {
- stack--;
- continue;
- }
- }
-
- switch (token.Kind())
- {
- case SyntaxKind.LessThanLessThanToken:
- stack++;
- goto case SyntaxKind.LessThanToken;
-
- // fall through
- case SyntaxKind.LessThanToken:
- stack++;
- break;
-
- case SyntaxKind.AsteriskToken: // for int*
- case SyntaxKind.QuestionToken: // for int?
- case SyntaxKind.ColonToken: // for global:: (so we don't dismiss help as you type the first :)
- case SyntaxKind.ColonColonToken: // for global::
- case SyntaxKind.CloseBracketToken:
- case SyntaxKind.OpenBracketToken:
- case SyntaxKind.DotToken:
- case SyntaxKind.IdentifierToken:
- case SyntaxKind.CommaToken:
- break;
-
- // If we see a member declaration keyword, we know we've gone too far
- case SyntaxKind.ClassKeyword:
- case SyntaxKind.StructKeyword:
- case SyntaxKind.InterfaceKeyword:
- case SyntaxKind.DelegateKeyword:
- case SyntaxKind.EnumKeyword:
- case SyntaxKind.PrivateKeyword:
- case SyntaxKind.PublicKeyword:
- case SyntaxKind.InternalKeyword:
- case SyntaxKind.ProtectedKeyword:
- case SyntaxKind.VoidKeyword:
- return token.GetPreviousToken(includeSkipped: true);
-
- default:
- // user might have typed "in" on the way to typing "int"
- // don't want to disregard this genericname because of that
- if (SyntaxFacts.IsKeywordKind(token.Kind()))
- {
- break;
- }
-
- // anything else and we're sunk. Go back to the token before.
- return token.GetPreviousToken(includeSkipped: true);
- }
- }
- while (true);
- }
-
- public static bool IsRegularStringLiteral(this SyntaxToken token)
- {
- return token.Kind() == SyntaxKind.StringLiteralToken && !token.IsVerbatimStringLiteral();
- }
-
- public static bool IsValidAttributeTarget(this SyntaxToken token)
- {
- switch (token.Kind())
- {
- case SyntaxKind.AssemblyKeyword:
- case SyntaxKind.ModuleKeyword:
- case SyntaxKind.FieldKeyword:
- case SyntaxKind.EventKeyword:
- case SyntaxKind.MethodKeyword:
- case SyntaxKind.ParamKeyword:
- case SyntaxKind.PropertyKeyword:
- case SyntaxKind.ReturnKeyword:
- case SyntaxKind.TypeKeyword:
- return true;
-
- default:
- return false;
- }
- }
-
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SyntaxTreeExtensions.cs b/main/src/addins/CSharpBinding/Util/SyntaxTreeExtensions.cs
deleted file mode 100644
index cb556b3996..0000000000
--- a/main/src/addins/CSharpBinding/Util/SyntaxTreeExtensions.cs
+++ /dev/null
@@ -1,3322 +0,0 @@
-//
-// SyntaxTreeExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis;
-using System.Threading;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis.Text;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SyntaxTreeExtensions
- {
-// /// <summary>
-// /// Returns the identifier, keyword, contextual keyword or preprocessor keyword touching this
-// /// position, or a token of Kind = None if the caret is not touching either.
-// /// </summary>
-// public static SyntaxToken GetTouchingWord(
-// this SyntaxTree syntaxTree,
-// int position,
-// ISyntaxFactsService syntaxFacts,
-// CancellationToken cancellationToken,
-// bool findInsideTrivia = false)
-// {
-// return GetTouchingToken(syntaxTree, position, syntaxFacts.IsWord, cancellationToken, findInsideTrivia);
-// }
-
- public static SyntaxToken GetTouchingToken(
- this SyntaxTree syntaxTree,
- int position,
- CancellationToken cancellationToken,
- bool findInsideTrivia = false)
- {
- return GetTouchingToken(syntaxTree, position, _ => true, cancellationToken, findInsideTrivia);
- }
-
- public static SyntaxToken GetTouchingToken(
- this SyntaxTree syntaxTree,
- int position,
- Predicate<SyntaxToken> predicate,
- CancellationToken cancellationToken,
- bool findInsideTrivia = false)
- {
- // Contract.ThrowIfNull(syntaxTree);
-
- if (position >= syntaxTree.Length)
- {
- return default(SyntaxToken);
- }
-
- var token = syntaxTree.GetRoot(cancellationToken).FindToken(position, findInsideTrivia);
-
- if ((token.Span.Contains(position) || token.Span.End == position) && predicate(token))
- {
- return token;
- }
-
- token = token.GetPreviousToken();
-
- if (token.Span.End == position && predicate(token))
- {
- return token;
- }
-
- // SyntaxKind = None
- return default(SyntaxToken);
- }
-
- public static bool OverlapsHiddenPosition(this SyntaxTree tree, TextSpan span, CancellationToken cancellationToken)
- {
- if (tree == null)
- {
- return false;
- }
-
- var text = tree.GetText(cancellationToken);
-
- return text.OverlapsHiddenPosition(span, (position, cancellationToken2) =>
- {
- // implements the ASP.Net IsHidden rule
- var lineVisibility = tree.GetLineVisibility(position, cancellationToken2);
- return lineVisibility == LineVisibility.Hidden || lineVisibility == LineVisibility.BeforeFirstLineDirective;
- },
- cancellationToken);
- }
-
- public static bool IsEntirelyHidden(this SyntaxTree tree, TextSpan span, CancellationToken cancellationToken)
- {
- if (!tree.HasHiddenRegions())
- {
- return false;
- }
-
- var text = tree.GetText(cancellationToken);
- var startLineNumber = text.Lines.IndexOf(span.Start);
- var endLineNumber = text.Lines.IndexOf(span.End);
-
- for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- var linePosition = text.Lines[lineNumber].Start;
- if (!tree.IsHiddenPosition(linePosition, cancellationToken))
- {
- return false;
- }
- }
-
- return true;
- }
-
- /// <summary>
- /// Returns <c>true</c> if the provided position is in a hidden region inaccessible to the user.
- /// </summary>
- public static bool IsHiddenPosition(this SyntaxTree tree, int position, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (!tree.HasHiddenRegions())
- {
- return false;
- }
-
- var lineVisibility = tree.GetLineVisibility(position, cancellationToken);
- return lineVisibility == LineVisibility.Hidden || lineVisibility == LineVisibility.BeforeFirstLineDirective;
- }
-
- public static bool IsInteractiveOrScript(this SyntaxTree syntaxTree)
- {
- return syntaxTree.Options.Kind != SourceCodeKind.Regular;
- }
-
- public static ISet<SyntaxKind> GetPrecedingModifiers(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- var result = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer);
- while (true)
- {
- switch (token.Kind())
- {
- case SyntaxKind.PublicKeyword:
- case SyntaxKind.InternalKeyword:
- case SyntaxKind.ProtectedKeyword:
- case SyntaxKind.PrivateKeyword:
- case SyntaxKind.SealedKeyword:
- case SyntaxKind.AbstractKeyword:
- case SyntaxKind.StaticKeyword:
- case SyntaxKind.VirtualKeyword:
- case SyntaxKind.ExternKeyword:
- case SyntaxKind.NewKeyword:
- case SyntaxKind.OverrideKeyword:
- case SyntaxKind.ReadOnlyKeyword:
- case SyntaxKind.VolatileKeyword:
- case SyntaxKind.UnsafeKeyword:
- case SyntaxKind.AsyncKeyword:
- result.Add(token.Kind());
- token = token.GetPreviousToken(includeSkipped: true);
- continue;
- case SyntaxKind.IdentifierToken:
- if (token.HasMatchingText(SyntaxKind.AsyncKeyword))
- {
- result.Add(SyntaxKind.AsyncKeyword);
- token = token.GetPreviousToken(includeSkipped: true);
- continue;
- }
-
- break;
- }
-
- break;
- }
-
- return result;
- }
-
- public static TypeDeclarationSyntax GetContainingTypeDeclaration(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- return syntaxTree.GetContainingTypeDeclarations(position, cancellationToken).FirstOrDefault();
- }
-
- public static BaseTypeDeclarationSyntax GetContainingTypeOrEnumDeclaration(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- return syntaxTree.GetContainingTypeOrEnumDeclarations(position, cancellationToken).FirstOrDefault();
- }
-
- public static IEnumerable<TypeDeclarationSyntax> GetContainingTypeDeclarations(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
-
- return token.GetAncestors<TypeDeclarationSyntax>().Where(t =>
- {
- return BaseTypeDeclarationContainsPosition(t, position);
- });
- }
-
- private static bool BaseTypeDeclarationContainsPosition(BaseTypeDeclarationSyntax declaration, int position)
- {
- if (position <= declaration.OpenBraceToken.SpanStart)
- {
- return false;
- }
-
- if (declaration.CloseBraceToken.IsMissing)
- {
- return true;
- }
-
- return position <= declaration.CloseBraceToken.SpanStart;
- }
-
- public static IEnumerable<BaseTypeDeclarationSyntax> GetContainingTypeOrEnumDeclarations(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
-
- return token.GetAncestors<BaseTypeDeclarationSyntax>().Where(t => BaseTypeDeclarationContainsPosition(t, position));
- }
-
-// /// <summary>
-// /// If the position is inside of token, return that token; otherwise, return the token to the right.
-// /// </summary>
-// public static SyntaxToken FindTokenOnRightOfPosition(
-// this SyntaxTree syntaxTree,
-// int position,
-// CancellationToken cancellationToken,
-// bool includeSkipped = true,
-// bool includeDirectives = false,
-// bool includeDocumentationComments = false)
-// {
-// return syntaxTree.GetRoot(cancellationToken).FindTokenOnRightOfPosition(
-// position, includeSkipped, includeDirectives, includeDocumentationComments);
-// }
-
- /// <summary>
- /// If the position is inside of token, return that token; otherwise, return the token to the left.
- /// </summary>
- public static SyntaxToken FindTokenOnLeftOfPosition(
- this SyntaxTree syntaxTree,
- int position,
- CancellationToken cancellationToken,
- bool includeSkipped = true,
- bool includeDirectives = false,
- bool includeDocumentationComments = false)
- {
- return syntaxTree.GetRoot(cancellationToken).FindTokenOnLeftOfPosition(
- position, includeSkipped, includeDirectives, includeDocumentationComments);
- }
-
- private static readonly Func<SyntaxKind, bool> s_isDotOrArrow = k => k == SyntaxKind.DotToken || k == SyntaxKind.MinusGreaterThanToken;
- private static readonly Func<SyntaxKind, bool> s_isDotOrArrowOrColonColon =
- k => k == SyntaxKind.DotToken || k == SyntaxKind.MinusGreaterThanToken || k == SyntaxKind.ColonColonToken;
-
- public static bool IsNamespaceDeclarationNameContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- var namespaceName = token.GetAncestor<NamespaceDeclarationSyntax>();
- if (namespaceName == null)
- {
- return false;
- }
-
- return namespaceName.Name.Span.IntersectsWith(position);
- }
-
- public static bool IsRightOfDotOrArrowOrColonColon(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- return syntaxTree.IsRightOf(position, s_isDotOrArrowOrColonColon, cancellationToken);
- }
-
- public static bool IsRightOfDotOrArrow(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- return syntaxTree.IsRightOf(position, s_isDotOrArrow, cancellationToken);
- }
-
- private static bool IsRightOf(
- this SyntaxTree syntaxTree, int position, Func<SyntaxKind, bool> predicate, CancellationToken cancellationToken)
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.None)
- {
- return false;
- }
-
- return predicate(token.Kind());
- }
-
- public static bool IsRightOfNumericLiteral(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- return token.Kind() == SyntaxKind.NumericLiteralToken;
- }
-
- public static bool IsPrimaryFunctionExpressionContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- return
- syntaxTree.IsTypeOfExpressionContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsDefaultExpressionContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsSizeOfExpressionContext(position, tokenOnLeftOfPosition, cancellationToken);
- }
-
- public static bool IsAfterKeyword(this SyntaxTree syntaxTree, int position, SyntaxKind kind, CancellationToken cancellationToken)
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- return token.Kind() == kind;
- }
-
- public static bool IsInNonUserCode(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- return
- syntaxTree.IsEntirelyWithinNonUserCodeComment(position, cancellationToken) ||
- syntaxTree.IsEntirelyWithinStringOrCharLiteral(position, cancellationToken) ||
- syntaxTree.IsInInactiveRegion(position, cancellationToken);
- }
-
- public static bool IsEntirelyWithinNonUserCodeComment(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var inNonUserSingleLineDocComment =
- syntaxTree.IsEntirelyWithinSingleLineDocComment(position, cancellationToken) && !syntaxTree.IsEntirelyWithinCrefSyntax(position, cancellationToken);
- return
- syntaxTree.IsEntirelyWithinTopLevelSingleLineComment(position, cancellationToken) ||
- syntaxTree.IsEntirelyWithinPreProcessorSingleLineComment(position, cancellationToken) ||
- syntaxTree.IsEntirelyWithinMultiLineComment(position, cancellationToken) ||
- syntaxTree.IsEntirelyWithinMultiLineDocComment(position, cancellationToken) ||
- inNonUserSingleLineDocComment;
- }
-
- public static bool IsEntirelyWithinComment(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- return
- syntaxTree.IsEntirelyWithinTopLevelSingleLineComment(position, cancellationToken) ||
- syntaxTree.IsEntirelyWithinPreProcessorSingleLineComment(position, cancellationToken) ||
- syntaxTree.IsEntirelyWithinMultiLineComment(position, cancellationToken) ||
- syntaxTree.IsEntirelyWithinMultiLineDocComment(position, cancellationToken) ||
- syntaxTree.IsEntirelyWithinSingleLineDocComment(position, cancellationToken);
- }
-
- public static bool IsCrefContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken, includeDocumentationComments: true);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Parent is XmlCrefAttributeSyntax)
- {
- var attribute = (XmlCrefAttributeSyntax)token.Parent;
- return token == attribute.StartQuoteToken;
- }
-
- return false;
- }
-
- public static bool IsEntirelyWithinCrefSyntax(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- if (syntaxTree.IsCrefContext(position, cancellationToken))
- {
- return true;
- }
-
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken, includeDocumentationComments: true);
- return token.GetAncestor<CrefSyntax>() != null;
- }
-
- public static bool IsEntirelyWithinSingleLineDocComment(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var root = syntaxTree.GetRoot(cancellationToken) as CompilationUnitSyntax;
- var trivia = root.FindTrivia(position);
-
- // If we ask right at the end of the file, we'll get back nothing.
- // So move back in that case and ask again.
- var eofPosition = root.FullWidth();
- if (position == eofPosition)
- {
- var eof = root.EndOfFileToken;
- if (eof.HasLeadingTrivia)
- {
- trivia = eof.LeadingTrivia.Last();
- }
- }
-
- if (trivia.IsSingleLineDocComment())
- {
- var span = trivia.Span;
- var fullSpan = trivia.FullSpan;
- var endsWithNewLine = trivia.GetStructure().GetLastToken(includeSkipped: true).Kind() == SyntaxKind.XmlTextLiteralNewLineToken;
-
- if (endsWithNewLine)
- {
- if (position > fullSpan.Start && position < fullSpan.End)
- {
- return true;
- }
- }
- else
- {
- if (position > fullSpan.Start && position <= fullSpan.End)
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public static bool IsEntirelyWithinMultiLineDocComment(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position);
-
- if (trivia.IsMultiLineDocComment())
- {
- var span = trivia.FullSpan;
-
- if (position > span.Start && position < span.End)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsEntirelyWithinMultiLineComment(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var trivia = FindTriviaAndAdjustForEndOfFile(syntaxTree, position, cancellationToken);
-
- if (trivia.IsMultiLineComment())
- {
- var span = trivia.FullSpan;
-
- return trivia.IsCompleteMultiLineComment()
- ? position > span.Start && position < span.End
- : position > span.Start && position <= span.End;
- }
-
- return false;
- }
-
- public static bool IsEntirelyWithinTopLevelSingleLineComment(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var trivia = FindTriviaAndAdjustForEndOfFile(syntaxTree, position, cancellationToken);
-
- if (trivia.Kind() == SyntaxKind.EndOfLineTrivia)
- {
- // Check if we're on the newline right at the end of a comment
- trivia = trivia.GetPreviousTrivia(syntaxTree, cancellationToken);
- }
-
- if (trivia.IsSingleLineComment())
- {
- var span = trivia.FullSpan;
-
- if (position > span.Start && position <= span.End)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsEntirelyWithinPreProcessorSingleLineComment(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- // Search inside trivia for directives to ensure that we recognize
- // single-line comments at the end of preprocessor directives.
- var trivia = FindTriviaAndAdjustForEndOfFile(syntaxTree, position, cancellationToken, findInsideTrivia: true);
-
- if (trivia.Kind() == SyntaxKind.EndOfLineTrivia)
- {
- // Check if we're on the newline right at the end of a comment
- trivia = trivia.GetPreviousTrivia(syntaxTree, cancellationToken, findInsideTrivia: true);
- }
-
- if (trivia.IsSingleLineComment())
- {
- var span = trivia.FullSpan;
-
- if (position > span.Start && position <= span.End)
- {
- return true;
- }
- }
-
- return false;
- }
-
- private static SyntaxTrivia FindTriviaAndAdjustForEndOfFile(
- SyntaxTree syntaxTree, int position, CancellationToken cancellationToken, bool findInsideTrivia = false)
- {
- var root = syntaxTree.GetRoot(cancellationToken) as CompilationUnitSyntax;
- var trivia = root.FindTrivia(position, findInsideTrivia);
-
- // If we ask right at the end of the file, we'll get back nothing.
- // We handle that case specially for now, though SyntaxTree.FindTrivia should
- // work at the end of a file.
- if (position == root.FullWidth())
- {
- var endOfFileToken = root.EndOfFileToken;
- if (endOfFileToken.HasLeadingTrivia)
- {
- trivia = endOfFileToken.LeadingTrivia.Last();
- }
- else
- {
- var token = endOfFileToken.GetPreviousToken(includeSkipped: true);
- if (token.HasTrailingTrivia)
- {
- trivia = token.TrailingTrivia.Last();
- }
- }
- }
-
- return trivia;
- }
-
- private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int position, char lastChar)
- {
- if (!token.IsKind(SyntaxKind.StringLiteralToken, SyntaxKind.CharacterLiteralToken))
- {
- throw new ArgumentException("Expected string or char literal.", "token");
- }
-
- int startLength = 1;
- if (token.IsVerbatimStringLiteral())
- {
- startLength = 2;
- }
-
- return position == token.Span.End &&
- (token.Span.Length == startLength || (token.Span.Length > startLength && token.ToString().Cast<char>().LastOrDefault() != lastChar));
- }
-
- public static bool IsEntirelyWithinStringOrCharLiteral(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- return
- syntaxTree.IsEntirelyWithinStringLiteral(position, cancellationToken) ||
- syntaxTree.IsEntirelyWithinCharLiteral(position, cancellationToken);
- }
-
- public static bool IsEntirelyWithinStringLiteral(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var token = syntaxTree.GetRoot(cancellationToken).FindToken(position, findInsideTrivia: true);
-
- // If we ask right at the end of the file, we'll get back nothing. We handle that case
- // specially for now, though SyntaxTree.FindToken should work at the end of a file.
- if (token.IsKind(SyntaxKind.EndOfDirectiveToken, SyntaxKind.EndOfFileToken))
- {
- token = token.GetPreviousToken(includeSkipped: true, includeDirectives: true);
- }
-
- if (token.IsKind(SyntaxKind.StringLiteralToken))
- {
- var span = token.Span;
-
- // cases:
- // "|"
- // "| (e.g. incomplete string literal)
- return (position > span.Start && position < span.End)
- || AtEndOfIncompleteStringOrCharLiteral(token, position, '"');
- }
-
- // TODO: Uncomment InterpolatedStringTextToken on roslyn update !!!
- if (token.IsKind(SyntaxKind.InterpolatedStringStartToken, /* SyntaxKind.InterpolatedStringTextToken, */SyntaxKind.InterpolatedStringEndToken))
- {
- return token.SpanStart < position && token.Span.End > position;
- }
-
- return false;
- }
-
- public static bool IsEntirelyWithinCharLiteral(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var root = syntaxTree.GetRoot(cancellationToken) as CompilationUnitSyntax;
- var token = root.FindToken(position, findInsideTrivia: true);
-
- // If we ask right at the end of the file, we'll get back nothing.
- // We handle that case specially for now, though SyntaxTree.FindToken should
- // work at the end of a file.
- if (position == root.FullWidth())
- {
- token = root.EndOfFileToken.GetPreviousToken(includeSkipped: true, includeDirectives: true);
- }
-
- if (token.Kind() == SyntaxKind.CharacterLiteralToken)
- {
- var span = token.Span;
-
- // cases:
- // '|'
- // '| (e.g. incomplete char literal)
- return (position > span.Start && position < span.End)
- || AtEndOfIncompleteStringOrCharLiteral(token, position, '\'');
- }
-
- return false;
- }
-
- public static bool IsInInactiveRegion(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- // Contract.ThrowIfNull(syntaxTree);
-
- // cases:
- // $ is EOF
-
- // #if false
- // |
-
- // #if false
- // |$
-
- // #if false
- // |
-
- // #if false
- // |$
-
- if (syntaxTree.IsPreProcessorKeywordContext(position, cancellationToken))
- {
- return false;
- }
-
- // The latter two are the hard cases we don't actually have an
- // DisabledTextTrivia yet.
- var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position, findInsideTrivia: false);
- if (trivia.Kind() == SyntaxKind.DisabledTextTrivia)
- {
- return true;
- }
-
- var token = syntaxTree.FindTokenOrEndToken(position, cancellationToken);
- var text = syntaxTree.GetText(cancellationToken);
- var lineContainingPosition = text.Lines.IndexOf(position);
- if (token.Kind() == SyntaxKind.EndOfFileToken)
- {
- var triviaList = token.LeadingTrivia;
- foreach (var triviaTok in triviaList.Reverse())
- {
- if (triviaTok.HasStructure)
- {
- var structure = triviaTok.GetStructure();
- if (structure is BranchingDirectiveTriviaSyntax)
- {
- var triviaLine = text.Lines.IndexOf(triviaTok.SpanStart);
- if (triviaLine < lineContainingPosition)
- {
- var branch = (BranchingDirectiveTriviaSyntax)structure;
- return !branch.IsActive || !branch.BranchTaken;
- }
- }
- }
- }
- }
-
- return false;
- }
-
- public static bool IsBeforeFirstToken(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var firstToken = syntaxTree.GetRoot(cancellationToken).GetFirstToken(includeZeroWidth: true, includeSkipped: true);
-
- return position <= firstToken.SpanStart;
- }
-
- public static SyntaxToken FindTokenOrEndToken(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- // Contract.ThrowIfNull(syntaxTree);
-
- var root = syntaxTree.GetRoot(cancellationToken) as CompilationUnitSyntax;
- var result = root.FindToken(position, findInsideTrivia: true);
- if (result.Kind() != SyntaxKind.None)
- {
- return result;
- }
-
- // Special cases. See if we're actually at the end of a:
- // a) doc comment
- // b) pp directive
- // c) file
-
- var triviaList = root.EndOfFileToken.LeadingTrivia;
- foreach (var trivia in triviaList.Reverse())
- {
- if (trivia.HasStructure)
- {
- var token = trivia.GetStructure().GetLastToken(includeZeroWidth: true);
- if (token.Span.End == position)
- {
- return token;
- }
- }
- }
-
- if (position == root.FullSpan.End)
- {
- return root.EndOfFileToken;
- }
-
- return default(SyntaxToken);
- }
-
- public static IList<MemberDeclarationSyntax> GetMembersInSpan(
- this SyntaxTree syntaxTree,
- TextSpan textSpan,
- CancellationToken cancellationToken)
- {
- var token = syntaxTree.GetRoot(cancellationToken).FindToken(textSpan.Start);
- var firstMember = token.GetAncestors<MemberDeclarationSyntax>().FirstOrDefault();
- if (firstMember != null)
- {
- var containingType = firstMember.Parent as TypeDeclarationSyntax;
- if (containingType != null)
- {
- var members = GetMembersInSpan(textSpan, containingType, firstMember);
- if (members != null)
- {
- return members;
- }
- }
- }
-
- return SpecializedCollections.EmptyList<MemberDeclarationSyntax>();
- }
-
- private static List<MemberDeclarationSyntax> GetMembersInSpan(
- TextSpan textSpan,
- TypeDeclarationSyntax containingType,
- MemberDeclarationSyntax firstMember)
- {
- List<MemberDeclarationSyntax> selectedMembers = null;
-
- var members = containingType.Members;
- var fieldIndex = members.IndexOf(firstMember);
- if (fieldIndex < 0)
- {
- return null;
- }
-
- for (var i = fieldIndex; i < members.Count; i++)
- {
- var member = members[i];
- if (textSpan.Contains(member.Span))
- {
- selectedMembers = selectedMembers ?? new List<MemberDeclarationSyntax>();
- selectedMembers.Add(member);
- }
- else if (textSpan.OverlapsWith(member.Span))
- {
- return null;
- }
- else
- {
- break;
- }
- }
-
- return selectedMembers;
- }
-
- public static bool IsInPartiallyWrittenGeneric(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- SyntaxToken genericIdentifier;
- SyntaxToken lessThanToken;
- return syntaxTree.IsInPartiallyWrittenGeneric(position, cancellationToken, out genericIdentifier, out lessThanToken);
- }
-
- public static bool IsInPartiallyWrittenGeneric(
- this SyntaxTree syntaxTree,
- int position,
- CancellationToken cancellationToken,
- out SyntaxToken genericIdentifier)
- {
- SyntaxToken lessThanToken;
- return syntaxTree.IsInPartiallyWrittenGeneric(position, cancellationToken, out genericIdentifier, out lessThanToken);
- }
-
- public static bool IsInPartiallyWrittenGeneric(
- this SyntaxTree syntaxTree,
- int position,
- CancellationToken cancellationToken,
- out SyntaxToken genericIdentifier,
- out SyntaxToken lessThanToken)
- {
- genericIdentifier = default(SyntaxToken);
- lessThanToken = default(SyntaxToken);
- int index = 0;
-
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- if (token.Kind() == SyntaxKind.None)
- {
- return false;
- }
-
- // check whether we are under type or member decl
- if (token.GetAncestor<TypeParameterListSyntax>() != null)
- {
- return false;
- }
-
- int stack = 0;
- while (true)
- {
- switch (token.Kind())
- {
- case SyntaxKind.LessThanToken:
- if (stack == 0)
- {
- // got here so we read successfully up to a < now we have to read the
- // name before that and we're done!
- lessThanToken = token;
- token = token.GetPreviousToken(includeSkipped: true);
- if (token.Kind() == SyntaxKind.None)
- {
- return false;
- }
-
- // ok
- // so we've read something like:
- // ~~~~~~~~~<a,b,...
- // but we need to know the simple name that precedes the <
- // it could be
- // ~~~~~~foo<a,b,...
- if (token.Kind() == SyntaxKind.IdentifierToken)
- {
- // okay now check whether it is actually partially written
- if (IsFullyWrittenGeneric(token, lessThanToken))
- {
- return false;
- }
-
- genericIdentifier = token;
- return true;
- }
-
- return false;
- }
- else
- {
- stack--;
- break;
- }
-
- case SyntaxKind.GreaterThanGreaterThanToken:
- stack++;
- goto case SyntaxKind.GreaterThanToken;
-
- // fall through
- case SyntaxKind.GreaterThanToken:
- stack++;
- break;
-
- case SyntaxKind.AsteriskToken: // for int*
- case SyntaxKind.QuestionToken: // for int?
- case SyntaxKind.ColonToken: // for global:: (so we don't dismiss help as you type the first :)
- case SyntaxKind.ColonColonToken: // for global::
- case SyntaxKind.CloseBracketToken:
- case SyntaxKind.OpenBracketToken:
- case SyntaxKind.DotToken:
- case SyntaxKind.IdentifierToken:
- break;
-
- case SyntaxKind.CommaToken:
- if (stack == 0)
- {
- index++;
- }
-
- break;
-
- default:
- // user might have typed "in" on the way to typing "int"
- // don't want to disregard this genericname because of that
- if (SyntaxFacts.IsKeywordKind(token.Kind()))
- {
- break;
- }
-
- // anything else and we're sunk.
- return false;
- }
-
- // look backward one token, include skipped tokens, because the parser frequently
- // does skip them in cases like: "Func<A, B", which get parsed as: expression
- // statement "Func<A" with missing semicolon, expression statement "B" with missing
- // semicolon, and the "," is skipped.
- token = token.GetPreviousToken(includeSkipped: true);
- if (token.Kind() == SyntaxKind.None)
- {
- return false;
- }
- }
- }
-
- private static bool IsFullyWrittenGeneric(SyntaxToken token, SyntaxToken lessThanToken)
- {
- var genericName = token.Parent as GenericNameSyntax;
-
- return genericName != null && genericName.TypeArgumentList != null &&
- genericName.TypeArgumentList.LessThanToken == lessThanToken && !genericName.TypeArgumentList.GreaterThanToken.IsMissing;
- }
-
-
- public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- // cases:
- // [ |
- if (token.Kind() == SyntaxKind.OpenBracketToken &&
- token.Parent.IsKind(SyntaxKind.AttributeList))
- {
- return true;
- }
-
- // cases:
- // [Foo(1), |
- if (token.Kind() == SyntaxKind.CommaToken &&
- token.Parent.IsKind(SyntaxKind.AttributeList))
- {
- return true;
- }
-
- // cases:
- // [specifier: |
- if (token.Kind() == SyntaxKind.ColonToken &&
- token.Parent.IsKind(SyntaxKind.AttributeTargetSpecifier))
- {
- return true;
- }
-
- // cases:
- // [Namespace.|
- if (token.Parent.IsKind(SyntaxKind.QualifiedName) &&
- token.Parent.IsParentKind(SyntaxKind.Attribute))
- {
- return true;
- }
-
- // cases:
- // [global::|
- if (token.Parent.IsKind(SyntaxKind.AliasQualifiedName) &&
- token.Parent.IsParentKind(SyntaxKind.Attribute))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsGlobalMemberDeclarationContext(
- this SyntaxTree syntaxTree,
- int position,
- ISet<SyntaxKind> validModifiers,
- CancellationToken cancellationToken)
- {
- if (!syntaxTree.IsInteractiveOrScript())
- {
- return false;
- }
-
- var tokenOnLeftOfPosition = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
-
- var modifierTokens = syntaxTree.GetPrecedingModifiers(position, tokenOnLeftOfPosition, cancellationToken);
- if (!modifierTokens.Any())
- {
- return false;
- }
-
- if (modifierTokens.IsSubsetOf(validModifiers))
- {
- // the parent is the member
- // the grandparent is the container of the member
- // in interactive, it's possible that there might be an intervening "incomplete" member for partially
- // typed declarations that parse ambiguously. For example, "internal e".
- if (token.Parent.IsKind(SyntaxKind.CompilationUnit) ||
- (token.Parent.IsKind(SyntaxKind.IncompleteMember) && token.Parent.IsParentKind(SyntaxKind.CompilationUnit)))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsMemberDeclarationContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- // cases:
- // class C {
- // |
-
- // class C {
- // void Foo() {
- // }
- // |
-
- // class C {
- // int i;
- // |
-
- // class C {
- // public |
-
- // class C {
- // [Foo]
- // |
-
- var originalToken = tokenOnLeftOfPosition;
- var token = originalToken;
-
- // If we're touching the right of an identifier, move back to
- // previous token.
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenBraceToken)
- {
- if (token.Parent is BaseTypeDeclarationSyntax)
- {
- return true;
- }
- }
-
- // class C {
- // int i;
- // |
- if (token.Kind() == SyntaxKind.SemicolonToken)
- {
- if (token.Parent is MemberDeclarationSyntax &&
- token.Parent.GetParent() is BaseTypeDeclarationSyntax)
- {
- return true;
- }
- }
-
- // class A {
- // class C {}
- // |
-
- // class C {
- // void Foo() {
- // }
- // |
- if (token.Kind() == SyntaxKind.CloseBraceToken)
- {
- if (token.Parent is BaseTypeDeclarationSyntax &&
- token.Parent.GetParent() is BaseTypeDeclarationSyntax)
- {
- // after a nested type
- return true;
- }
- else if (token.Parent is AccessorListSyntax)
- {
- // after a property
- return true;
- }
- else if (
- token.Parent.IsKind(SyntaxKind.Block) &&
- token.Parent.GetParent() is MemberDeclarationSyntax)
- {
- // after a method/operator/etc.
- return true;
- }
- }
-
- // namespace Foo {
- // [Bar]
- // |
-
- if (token.Kind() == SyntaxKind.CloseBracketToken &&
- token.Parent.IsKind(SyntaxKind.AttributeList))
- {
- // attributes belong to a member which itself is in a
- // container.
-
- // the parent is the attribute
- // the grandparent is the owner of the attribute
- // the great-grandparent is the container that the owner is in
- var container = token.Parent.GetParent().GetParent();
- if (container is BaseTypeDeclarationSyntax)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsMemberDeclarationContext(
- this SyntaxTree syntaxTree,
- int position,
- CSharpSyntaxContext contextOpt,
- ISet<SyntaxKind> validModifiers,
- ISet<SyntaxKind> validTypeDeclarations,
- bool canBePartial,
- CancellationToken cancellationToken)
- {
- var typeDecl = contextOpt != null
- ? contextOpt.ContainingTypeOrEnumDeclaration
- : syntaxTree.GetContainingTypeOrEnumDeclaration(position, cancellationToken);
-
- if (typeDecl == null)
- {
- return false;
- }
-
- if (!validTypeDeclarations.Contains(typeDecl.Kind()))
- {
- return false;
- }
-
- validTypeDeclarations = validTypeDeclarations ?? SpecializedCollections.EmptySet<SyntaxKind>();
-
- // Check many of the simple cases first.
- var leftToken = contextOpt != null
- ? contextOpt.LeftToken
- : syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
-
- if (syntaxTree.IsMemberDeclarationContext(position, leftToken, cancellationToken))
- {
- return true;
- }
-
- var token = contextOpt != null
- ? contextOpt.TargetToken
- : leftToken.GetPreviousTokenIfTouchingWord(position);
-
- // A member can also show up after certain types of modifiers
- if (canBePartial &&
- token.IsKindOrHasMatchingText(SyntaxKind.PartialKeyword))
- {
- return true;
- }
-
- var modifierTokens = contextOpt != null
- ? contextOpt.PrecedingModifiers
- : syntaxTree.GetPrecedingModifiers(position, leftToken, cancellationToken);
-
- if (!modifierTokens.Any())
- {
- return false;
- }
-
- validModifiers = validModifiers ?? SpecializedCollections.EmptySet<SyntaxKind>();
-
- if (modifierTokens.IsSubsetOf(validModifiers))
- {
- var member = token.Parent;
- if (token.HasMatchingText(SyntaxKind.AsyncKeyword))
- {
- // second appearance of "async", not followed by modifier: treat it as type
- if (syntaxTree.GetPrecedingModifiers(token.SpanStart, token, cancellationToken).Any(x => x == SyntaxKind.AsyncKeyword))
- {
- return false;
- }
-
- // rule out async lambdas inside a method
- if (token.GetAncestor<StatementSyntax>() == null)
- {
- member = token.GetAncestor<MemberDeclarationSyntax>();
- }
- }
-
- // cases:
- // public |
- // async |
- // public async |
- return member != null &&
- member.Parent is BaseTypeDeclarationSyntax;
- }
-
- return false;
- }
-
- public static bool IsTypeDeclarationContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- // cases:
- // root: |
-
- // extern alias a;
- // |
-
- // using Foo;
- // |
-
- // using Foo = Bar;
- // |
-
- // namespace N {}
- // |
-
- // namespace N {
- // |
-
- // class C {}
- // |
-
- // class C {
- // |
-
- // class C {
- // void Foo() {
- // }
- // |
-
- // class C {
- // int i;
- // |
-
- // class C {
- // public |
-
- // class C {
- // [Foo]
- // |
-
- var originalToken = tokenOnLeftOfPosition;
- var token = originalToken;
-
- // If we're touching the right of an identifier, move back to
- // previous token.
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- // a type decl can't come before usings/externs
- if (originalToken.GetNextToken(includeSkipped: true).IsUsingOrExternKeyword())
- {
- return false;
- }
-
- // root: |
- if (token.Kind() == SyntaxKind.None)
- {
- // root namespace
-
- // a type decl can't come before usings/externs
- var compilationUnit = syntaxTree.GetRoot(cancellationToken) as CompilationUnitSyntax;
- if (compilationUnit != null &&
- (compilationUnit.Externs.Count > 0 ||
- compilationUnit.Usings.Count > 0))
- {
- return false;
- }
-
- return true;
- }
-
- if (token.Kind() == SyntaxKind.OpenBraceToken)
- {
- if (token.Parent.IsKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration))
- {
- return true;
- }
- else if (token.Parent.IsKind(SyntaxKind.NamespaceDeclaration))
- {
- return true;
- }
- }
-
- // extern alias a;
- // |
-
- // using Foo;
- // |
-
- // class C {
- // int i;
- // |
- if (token.Kind() == SyntaxKind.SemicolonToken)
- {
- if (token.Parent.IsKind(SyntaxKind.ExternAliasDirective, SyntaxKind.UsingDirective))
- {
- return true;
- }
- else if (token.Parent is MemberDeclarationSyntax)
- {
- return true;
- }
- }
-
- // class C {}
- // |
-
- // namespace N {}
- // |
-
- // class C {
- // void Foo() {
- // }
- // |
- if (token.Kind() == SyntaxKind.CloseBraceToken)
- {
- if (token.Parent is BaseTypeDeclarationSyntax)
- {
- return true;
- }
- else if (token.Parent.IsKind(SyntaxKind.NamespaceDeclaration))
- {
- return true;
- }
- else if (token.Parent is AccessorListSyntax)
- {
- return true;
- }
- else if (
- token.Parent.IsKind(SyntaxKind.Block) &&
- token.Parent.GetParent() is MemberDeclarationSyntax)
- {
- return true;
- }
- }
-
- // namespace Foo {
- // [Bar]
- // |
-
- if (token.Kind() == SyntaxKind.CloseBracketToken &&
- token.Parent.IsKind(SyntaxKind.AttributeList))
- {
- // assembly attributes belong to the containing compilation unit
- if (token.Parent.IsParentKind(SyntaxKind.CompilationUnit))
- {
- return true;
- }
-
- // other attributes belong to a member which itself is in a
- // container.
-
- // the parent is the attribute
- // the grandparent is the owner of the attribute
- // the great-grandparent is the container that the owner is in
- var container = token.Parent.GetParent().GetParent();
- if (container.IsKind(SyntaxKind.CompilationUnit) ||
- container.IsKind(SyntaxKind.NamespaceDeclaration) ||
- container.IsKind(SyntaxKind.ClassDeclaration) ||
- container.IsKind(SyntaxKind.StructDeclaration))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsTypeDeclarationContext(
- this SyntaxTree syntaxTree,
- int position,
- CSharpSyntaxContext contextOpt,
- ISet<SyntaxKind> validModifiers,
- ISet<SyntaxKind> validTypeDeclarations,
- bool canBePartial,
- CancellationToken cancellationToken)
- {
- // We only allow nested types inside a class or struct, not inside a
- // an interface or enum.
- var typeDecl = contextOpt != null
- ? contextOpt.ContainingTypeDeclaration
- : syntaxTree.GetContainingTypeDeclaration(position, cancellationToken);
-
- validTypeDeclarations = validTypeDeclarations ?? SpecializedCollections.EmptySet<SyntaxKind>();
-
- if (typeDecl != null)
- {
- if (!validTypeDeclarations.Contains(typeDecl.Kind()))
- {
- return false;
- }
- }
-
- // Check many of the simple cases first.
- var leftToken = contextOpt != null
- ? contextOpt.LeftToken
- : syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
-
- if (syntaxTree.IsTypeDeclarationContext(position, leftToken, cancellationToken))
- {
- return true;
- }
-
- // If we're touching the right of an identifier, move back to
- // previous token.
- var token = contextOpt != null
- ? contextOpt.TargetToken
- : leftToken.GetPreviousTokenIfTouchingWord(position);
-
- // A type can also show up after certain types of modifiers
- if (canBePartial &&
- token.IsKindOrHasMatchingText(SyntaxKind.PartialKeyword))
- {
- return true;
- }
-
- // using static | is never a type declaration context
- if (token.IsStaticKeywordInUsingDirective())
- {
- return false;
- }
-
- var modifierTokens = contextOpt != null
- ? contextOpt.PrecedingModifiers
- : syntaxTree.GetPrecedingModifiers(position, leftToken, cancellationToken);
-
- if (!modifierTokens.Any())
- {
- return false;
- }
-
- validModifiers = validModifiers ?? SpecializedCollections.EmptySet<SyntaxKind>();
-
- if (modifierTokens.IsProperSubsetOf(validModifiers))
- {
- // the parent is the member
- // the grandparent is the container of the member
- var container = token.Parent.GetParent();
- if (container.IsKind(SyntaxKind.CompilationUnit) ||
- container.IsKind(SyntaxKind.NamespaceDeclaration) ||
- container.IsKind(SyntaxKind.ClassDeclaration) ||
- container.IsKind(SyntaxKind.StructDeclaration))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsNamespaceContext(
- this SyntaxTree syntaxTree,
- int position,
- CancellationToken cancellationToken,
- SemanticModel semanticModelOpt = null)
- {
- // first do quick exit check
- if (syntaxTree.IsInNonUserCode(position, cancellationToken) ||
- syntaxTree.IsRightOfDotOrArrow(position, cancellationToken))
- {
- return false;
- }
-
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken)
- .GetPreviousTokenIfTouchingWord(position);
-
- // global::
- if (token.Kind() == SyntaxKind.ColonColonToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.GlobalKeyword)
- {
- return true;
- }
-
- // using |
- // but not:
- // using | = Bar
-
- // Note: we take care of the using alias case in the IsTypeContext
- // call below.
-
- if (token.Kind() == SyntaxKind.UsingKeyword)
- {
- var usingDirective = token.GetAncestor<UsingDirectiveSyntax>();
- if (usingDirective != null)
- {
- if (token.GetNextToken(includeSkipped: true).Kind() != SyntaxKind.EqualsToken &&
- usingDirective.Alias == null)
- {
- return true;
- }
- }
- }
-
- // using static |
- if (token.IsStaticKeywordInUsingDirective())
- {
- return true;
- }
-
- // if it is not using directive location, most of places where
- // type can appear, namespace can appear as well
- return syntaxTree.IsTypeContext(position, cancellationToken, semanticModelOpt);
- }
-
- public static bool IsDefinitelyNotTypeContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- return
- syntaxTree.IsInNonUserCode(position, cancellationToken) ||
- syntaxTree.IsRightOfDotOrArrow(position, cancellationToken);
- }
-
- public static bool IsTypeContext(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken, SemanticModel semanticModelOpt = null)
- {
- // first do quick exit check
- if (syntaxTree.IsDefinitelyNotTypeContext(position, cancellationToken))
- {
- return false;
- }
-
- // okay, now it is a case where we can't use parse tree (valid or error recovery) to
- // determine whether it is a right place to put type. use lex based one Cyrus created.
-
- var tokenOnLeftOfPosition = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- return
- syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.CaseKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.EventKeyword, cancellationToken) ||
- syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
- syntaxTree.IsAttributeNameContext(position, cancellationToken) ||
- syntaxTree.IsBaseClassOrInterfaceContext(position, cancellationToken) ||
- syntaxTree.IsCatchVariableDeclarationContext(position, cancellationToken) ||
- syntaxTree.IsDefiniteCastTypeContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsDelegateReturnTypeContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsExpressionContext(position, tokenOnLeftOfPosition, attributes: true, cancellationToken: cancellationToken, semanticModelOpt: semanticModelOpt) ||
- syntaxTree.IsPrimaryFunctionExpressionContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsGenericTypeArgumentContext(position, tokenOnLeftOfPosition, cancellationToken, semanticModelOpt) ||
- syntaxTree.IsFixedVariableDeclarationContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsImplicitOrExplicitOperatorTypeContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsIsOrAsTypeContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsLocalVariableDeclarationContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsObjectCreationTypeContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsParameterTypeContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsPossibleLambdaOrAnonymousMethodParameterTypeContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsStatementContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsTypeParameterConstraintContext(position, tokenOnLeftOfPosition, cancellationToken) ||
- syntaxTree.IsUsingAliasContext(position, cancellationToken) ||
- syntaxTree.IsUsingStaticContext(position, cancellationToken) ||
- syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
- syntaxTree.IsMemberDeclarationContext(
- position,
- contextOpt: null,
- validModifiers: SyntaxKindSet.AllMemberModifiers,
- validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
- canBePartial: false,
- cancellationToken: cancellationToken);
- }
-
- public static bool IsBaseClassOrInterfaceContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- // class C : |
- // class C : Bar, |
-
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.ColonToken ||
- token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent.IsKind(SyntaxKind.BaseList))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsUsingAliasContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- // using Foo = |
-
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.EqualsToken &&
- token.GetAncestor<UsingDirectiveSyntax>() != null)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsUsingStaticContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- // using static |
-
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- return token.IsStaticKeywordInUsingDirective();
- }
-
- public static bool IsTypeArgumentOfConstraintClause(
- this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- // cases:
- // where |
- // class Foo<T> : Object where |
-
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.WhereKeyword &&
- token.Parent.IsKind(SyntaxKind.TypeParameterConstraintClause))
- {
- return true;
- }
-
- if (token.Kind() == SyntaxKind.IdentifierToken &&
- token.HasMatchingText(SyntaxKind.WhereKeyword) &&
- token.Parent.IsKind(SyntaxKind.IdentifierName) &&
- token.Parent.IsParentKind(SyntaxKind.SimpleBaseType) &&
- token.Parent.Parent.IsParentKind(SyntaxKind.BaseList))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsTypeParameterConstraintStartContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- // cases:
- // where T : |
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.ColonToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.IdentifierToken &&
- token.GetPreviousToken(includeSkipped: true).GetPreviousToken().Kind() == SyntaxKind.WhereKeyword)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsTypeParameterConstraintContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- if (syntaxTree.IsTypeParameterConstraintStartContext(position, tokenOnLeftOfPosition, cancellationToken))
- {
- return true;
- }
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- // Can't come after new()
- //
- // where T : |
- // where T : class, |
- // where T : struct, |
- // where T : Foo, |
- if (token.Kind() == SyntaxKind.CommaToken &&
- token.Parent.IsKind(SyntaxKind.TypeParameterConstraintClause))
- {
- var constraintClause = token.Parent as TypeParameterConstraintClauseSyntax;
-
- // Check if there's a 'new()' constraint. If there isn't, or we're before it, then
- // this is a type parameter constraint context.
- var firstConstructorConstraint = constraintClause.Constraints.FirstOrDefault(t => t is ConstructorConstraintSyntax);
- if (firstConstructorConstraint == null || firstConstructorConstraint.SpanStart > token.Span.End)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsTypeOfExpressionContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenParenToken && token.Parent.IsKind(SyntaxKind.TypeOfExpression))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsDefaultExpressionContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenParenToken && token.Parent.IsKind(SyntaxKind.DefaultExpression))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsSizeOfExpressionContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenParenToken && token.Parent.IsKind(SyntaxKind.SizeOfExpression))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsGenericTypeArgumentContext(
- this SyntaxTree syntaxTree,
- int position,
- SyntaxToken tokenOnLeftOfPosition,
- CancellationToken cancellationToken,
- SemanticModel semanticModelOpt = null)
- {
- // cases:
- // Foo<|
- // Foo<Bar,|
- // Foo<Bar<Baz<int[],|
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() != SyntaxKind.LessThanToken && token.Kind() != SyntaxKind.CommaToken)
- {
- return false;
- }
-
- if (token.Parent is TypeArgumentListSyntax)
- {
- // Easy case, it was known to be a generic name, so this is a type argument context.
- return true;
- }
-
- SyntaxToken nameToken;
- if (!syntaxTree.IsInPartiallyWrittenGeneric(position, cancellationToken, out nameToken))
- {
- return false;
- }
-
- var name = nameToken.Parent as NameSyntax;
- if (name == null)
- {
- return false;
- }
-
- // Looks viable! If they provided a binding, then check if it binds properly to
- // an actual generic entity.
- if (semanticModelOpt == null)
- {
- // No binding. Just make the decision based on the syntax tree.
- return true;
- }
-
- // '?' is syntactically ambiguous in incomplete top-level statements:
- //
- // T ? foo<|
- //
- // Might be an incomplete conditional expression or an incomplete declaration of a method returning a nullable type.
- // Bind T to see if it is a type. If it is we don't show signature help.
- if (name.IsParentKind(SyntaxKind.LessThanExpression) &&
- name.Parent.IsParentKind(SyntaxKind.ConditionalExpression) &&
- name.Parent.Parent.IsParentKind(SyntaxKind.ExpressionStatement) &&
- name.Parent.Parent.Parent.IsParentKind(SyntaxKind.GlobalStatement))
- {
- var conditionOrType = semanticModelOpt.GetSymbolInfo(
- ((ConditionalExpressionSyntax)name.Parent.Parent).Condition, cancellationToken);
- if (conditionOrType.GetBestOrAllSymbols().FirstOrDefault() != null &&
- conditionOrType.GetBestOrAllSymbols().FirstOrDefault().Kind == SymbolKind.NamedType)
- {
- return false;
- }
- }
-
- var symbols = semanticModelOpt.LookupName(nameToken, namespacesAndTypesOnly: SyntaxFacts.IsInNamespaceOrTypeContext(name), cancellationToken: cancellationToken);
- return symbols.Any(s =>
- s.TypeSwitch(
- (INamedTypeSymbol nt) => nt.Arity > 0,
- (IMethodSymbol m) => m.Arity > 0));
- }
-
- public static bool IsParameterModifierContext(
- this SyntaxTree syntaxTree,
- int position,
- SyntaxToken tokenOnLeftOfPosition,
- CancellationToken cancellationToken,
- int? allowableIndex = null)
- {
- // cases:
- // Foo(|
- // Foo(int i, |
- // Foo([Bar]|
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.Parent.IsDelegateOrConstructorOrMethodParameterList())
- {
- if (allowableIndex.HasValue)
- {
- if (allowableIndex.Value != 0)
- {
- return false;
- }
- }
-
- return true;
- }
-
- if (token.Kind() == SyntaxKind.CommaToken &&
- token.Parent.IsDelegateOrConstructorOrMethodParameterList())
- {
- if (allowableIndex.HasValue)
- {
- var parameterList = token.GetAncestor<ParameterListSyntax>();
- var commaIndex = parameterList.Parameters.GetWithSeparators().IndexOf(token);
- var index = commaIndex / 2 + 1;
- if (index != allowableIndex.Value)
- {
- return false;
- }
- }
-
- return true;
- }
-
- if (token.Kind() == SyntaxKind.CloseBracketToken &&
- token.Parent.IsKind(SyntaxKind.AttributeList) &&
- token.Parent.IsParentKind(SyntaxKind.Parameter) &&
- token.Parent.GetParent().GetParent().IsDelegateOrConstructorOrMethodParameterList())
- {
- if (allowableIndex.HasValue)
- {
- var parameter = token.GetAncestor<ParameterSyntax>();
- var parameterList = parameter.GetAncestorOrThis<ParameterListSyntax>();
-
- int parameterIndex = parameterList.Parameters.IndexOf(parameter);
- if (allowableIndex.Value != parameterIndex)
- {
- return false;
- }
- }
-
- return true;
- }
-
- return false;
- }
-
- public static bool IsDelegateReturnTypeContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.DelegateKeyword &&
- token.Parent.IsKind(SyntaxKind.DelegateDeclaration))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsImplicitOrExplicitOperatorTypeContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OperatorKeyword)
- {
- if (token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.ImplicitKeyword ||
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.ExplicitKeyword)
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsParameterTypeContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.RefKeyword ||
- token.Kind() == SyntaxKind.OutKeyword ||
- token.Kind() == SyntaxKind.ParamsKeyword ||
- token.Kind() == SyntaxKind.ThisKeyword)
- {
- position = token.SpanStart;
- tokenOnLeftOfPosition = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- }
-
- if (syntaxTree.IsParameterModifierContext(position, tokenOnLeftOfPosition, cancellationToken))
- {
- return true;
- }
-
- // int this[ |
- // int this[int i, |
- if (token.Kind() == SyntaxKind.OpenParenToken ||
- token.Kind() == SyntaxKind.OpenBracketToken ||
- token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent.IsKind(SyntaxKind.ParameterList, SyntaxKind.BracketedParameterList))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsPossibleLambdaParameterModifierContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenParenToken ||
- token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent.IsKind(SyntaxKind.ParameterList) &&
- token.Parent.IsParentKind(SyntaxKind.ParenthesizedLambdaExpression))
- {
- return true;
- }
-
- // TODO(cyrusn): Tie into semantic analysis system to only
- // consider this a lambda if this is a location where the
- // lambda's type would be inferred because of a delegate
- // or Expression<T> type.
- if (token.Parent.IsKind(SyntaxKind.ParenthesizedExpression))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsAnonymousMethodParameterModifierContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenParenToken ||
- token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent.IsKind(SyntaxKind.ParameterList) &&
- token.Parent.IsParentKind(SyntaxKind.AnonymousMethodExpression))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsPossibleLambdaOrAnonymousMethodParameterTypeContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.RefKeyword ||
- token.Kind() == SyntaxKind.OutKeyword)
- {
- position = token.SpanStart;
- tokenOnLeftOfPosition = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- }
-
- if (IsAnonymousMethodParameterModifierContext(syntaxTree, position, tokenOnLeftOfPosition, cancellationToken) ||
- IsPossibleLambdaParameterModifierContext(syntaxTree, position, tokenOnLeftOfPosition, cancellationToken))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsValidContextForFromClause(
- this SyntaxTree syntaxTree,
- int position,
- SyntaxToken tokenOnLeftOfPosition,
- CancellationToken cancellationToken,
- SemanticModel semanticModelOpt = null)
- {
- if (syntaxTree.IsExpressionContext(position, tokenOnLeftOfPosition, attributes: false, cancellationToken: cancellationToken, semanticModelOpt: semanticModelOpt) &&
- !syntaxTree.IsConstantExpressionContext(position, tokenOnLeftOfPosition, cancellationToken))
- {
- return true;
- }
-
- // cases:
- // var q = |
- // var q = f|
- //
- // var q = from x in y
- // |
- //
- // var q = from x in y
- // f|
- //
- // this list is *not* exhaustive.
- // the first two are handled by 'IsExpressionContext'
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- // var q = from x in y
- // |
- if (!token.IntersectsWith(position) &&
- token.IsLastTokenOfQueryClause())
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsValidContextForJoinClause(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- // var q = from x in y
- // |
- if (!token.IntersectsWith(position) &&
- token.IsLastTokenOfQueryClause())
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsDeclarationExpressionContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- // cases:
- // M(out var
- // var x = var
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.IsKind (SyntaxKind.OutKeyword) &&
- token.Parent.IsKind(SyntaxKind.Argument))
- {
- return true;
- }
-
- if (token.IsKind(SyntaxKind.EqualsToken) &&
- token.Parent.IsKind(SyntaxKind.EqualsValueClause) &&
- token.Parent.IsParentKind(SyntaxKind.VariableDeclarator))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsLocalVariableDeclarationContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- // cases:
- // const var
- // for (var
- // foreach (var
- // using (var
- // from var
- // join var
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.ConstKeyword &&
- token.Parent.IsKind(SyntaxKind.LocalDeclarationStatement))
- {
- return true;
- }
-
- if (token.Kind() == SyntaxKind.OpenParenToken)
- {
- var previous = token.GetPreviousToken(includeSkipped: true);
- if (previous.Kind() == SyntaxKind.ForKeyword ||
- previous.Kind() == SyntaxKind.ForEachKeyword ||
- previous.Kind() == SyntaxKind.UsingKeyword)
- {
- return true;
- }
- }
-
- var tokenOnLeftOfStart = syntaxTree.FindTokenOnLeftOfPosition(token.SpanStart, cancellationToken);
- if (token.IsKindOrHasMatchingText(SyntaxKind.FromKeyword) &&
- syntaxTree.IsValidContextForFromClause(token.SpanStart, tokenOnLeftOfStart, cancellationToken))
- {
- return true;
- }
-
- if (token.IsKind(SyntaxKind.JoinKeyword) &&
- syntaxTree.IsValidContextForJoinClause(token.SpanStart, tokenOnLeftOfStart, cancellationToken))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsFixedVariableDeclarationContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- // cases:
- // fixed (var
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.FixedKeyword)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsCatchVariableDeclarationContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- // cases:
- // catch (var
-
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.CatchKeyword)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsIsOrAsTypeContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.IsKeyword ||
- token.Kind() == SyntaxKind.AsKeyword)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsObjectCreationTypeContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.NewKeyword)
- {
- // we can follow a 'new' if it's the 'new' for an expression.
- var start = token.SpanStart;
- var tokenOnLeftOfStart = syntaxTree.FindTokenOnLeftOfPosition(start, cancellationToken);
- return
- IsNonConstantExpressionContext(syntaxTree, token.SpanStart, tokenOnLeftOfStart, cancellationToken) ||
- syntaxTree.IsStatementContext(token.SpanStart, tokenOnLeftOfStart, cancellationToken) ||
- syntaxTree.IsGlobalStatementContext(token.SpanStart, cancellationToken);
- }
-
- return false;
- }
-
- private static bool IsNonConstantExpressionContext(SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- return
- syntaxTree.IsExpressionContext(position, tokenOnLeftOfPosition, attributes: true, cancellationToken: cancellationToken) &&
- !syntaxTree.IsConstantExpressionContext(position, tokenOnLeftOfPosition, cancellationToken);
- }
-
- public static bool IsPreProcessorDirectiveContext(this SyntaxTree syntaxTree, int position, SyntaxToken preProcessorTokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = preProcessorTokenOnLeftOfPosition;
- var directive = token.GetAncestor<DirectiveTriviaSyntax>();
-
- // Directives contain the EOL, so if the position is within the full span of the
- // directive, then it is on that line, the only exception is if the directive is on the
- // last line, the position at the end if technically not contained by the directive but
- // its also not on a new line, so it should be considered part of the preprocessor
- // context.
- if (directive == null)
- {
- return false;
- }
-
- return
- directive.FullSpan.Contains(position) ||
- directive.FullSpan.End == syntaxTree.GetRoot(cancellationToken).FullSpan.End;
- }
-
- public static bool IsPreProcessorDirectiveContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var leftToken = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken, includeDirectives: true);
-
- return syntaxTree.IsPreProcessorDirectiveContext(position, leftToken, cancellationToken);
- }
-
- public static bool IsPreProcessorKeywordContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- return IsPreProcessorKeywordContext(
- syntaxTree, position,
- syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken, includeDirectives: true),
- cancellationToken);
- }
-
- public static bool IsPreProcessorKeywordContext(this SyntaxTree syntaxTree, int position, SyntaxToken preProcessorTokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- // cases:
- // #|
- // #d|
- // # |
- // # d|
-
- // note: comments are not allowed between the # and item.
- var token = preProcessorTokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.HashToken)
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsStatementContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- #if false
- // we're in a statement if the thing that comes before allows for
- // statements to follow. Or if we're on a just started identifier
- // in the first position where a statement can go.
- if (syntaxTree.IsInPreprocessorDirectiveContext(position, cancellationToken))
- {
- return false;
- }
- #endif
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- return token.IsBeginningOfStatementContext();
- }
-
- public static bool IsGlobalStatementContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- if (!syntaxTree.IsInteractiveOrScript())
- {
- return false;
- }
-
- #if false
- if (syntaxTree.IsInPreprocessorDirectiveContext(position, cancellationToken))
- {
- return false;
- }
- #endif
-
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken)
- .GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.None)
- {
- // global statements can't come before usings/externs
- var compilationUnit = syntaxTree.GetRoot(cancellationToken) as CompilationUnitSyntax;
- if (compilationUnit != null &&
- (compilationUnit.Externs.Count > 0 ||
- compilationUnit.Usings.Count > 0))
- {
- return false;
- }
-
- return true;
- }
-
- return token.IsBeginningOfGlobalStatementContext();
- }
-
- public static bool IsInstanceContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- #if false
- if (syntaxTree.IsInPreprocessorDirectiveContext(position, cancellationToken))
- {
- return false;
- }
- #endif
-
- var token = tokenOnLeftOfPosition;
-
- // We're in an instance context if we're in the body of an instance member
- var containingMember = token.GetAncestor<MemberDeclarationSyntax>();
- if (containingMember == null)
- {
- return false;
- }
-
- var modifiers = containingMember.GetModifiers();
- if (modifiers.Any(SyntaxKind.StaticKeyword))
- {
- return false;
- }
-
- // Must be a property or something method-like.
- if (containingMember.HasMethodShape())
- {
- var body = containingMember.GetBody();
- return IsInBlock(body, position);
- }
-
- var accessor = token.GetAncestor<AccessorDeclarationSyntax>();
- if (accessor != null)
- {
- return IsInBlock(accessor.Body, position);
- }
-
- return false;
- }
-
- private static bool IsInBlock(BlockSyntax bodyOpt, int position)
- {
- if (bodyOpt == null)
- {
- return false;
- }
-
- return bodyOpt.OpenBraceToken.Span.End <= position &&
- (bodyOpt.CloseBraceToken.IsMissing || position <= bodyOpt.CloseBraceToken.SpanStart);
- }
-
- public static bool IsPossibleCastTypeContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
-
- if (token.IsKind(SyntaxKind.OpenParenToken) &&
- syntaxTree.IsExpressionContext(token.SpanStart, syntaxTree.FindTokenOnLeftOfPosition(token.SpanStart, cancellationToken), false, cancellationToken))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsDefiniteCastTypeContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.Parent.IsKind(SyntaxKind.CastExpression))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsConstantExpressionContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
-
- // case |
- if (token.Kind() == SyntaxKind.CaseKeyword &&
- token.Parent.IsKind(SyntaxKind.CaseSwitchLabel))
- {
- return true;
- }
-
- // goto case |
- if (token.Kind() == SyntaxKind.CaseKeyword &&
- token.Parent.IsKind(SyntaxKind.GotoCaseStatement))
- {
- return true;
- }
-
- if (token.Kind() == SyntaxKind.EqualsToken &&
- token.Parent.IsKind(SyntaxKind.EqualsValueClause))
- {
- var equalsValue = (EqualsValueClauseSyntax)token.Parent;
-
- if (equalsValue.IsParentKind(SyntaxKind.VariableDeclarator) &&
- equalsValue.Parent.IsParentKind(SyntaxKind.VariableDeclaration))
- {
- // class C { const int i = |
- var fieldDeclaration = equalsValue.GetAncestor<FieldDeclarationSyntax>();
- if (fieldDeclaration != null)
- {
- return fieldDeclaration.Modifiers.Any(SyntaxKind.ConstKeyword);
- }
-
- // void M() { const int i = |
- var localDeclaration = equalsValue.GetAncestor<LocalDeclarationStatementSyntax>();
- if (localDeclaration != null)
- {
- return localDeclaration.Modifiers.Any(SyntaxKind.ConstKeyword);
- }
- }
-
- // enum E { A = |
- if (equalsValue.IsParentKind(SyntaxKind.EnumMemberDeclaration))
- {
- return true;
- }
-
- // void M(int i = |
- if (equalsValue.IsParentKind(SyntaxKind.Parameter))
- {
- return true;
- }
- }
-
- // [Foo( |
- // [Foo(x, |
- if (token.Parent.IsKind(SyntaxKind.AttributeArgumentList) &&
- (token.Kind() == SyntaxKind.CommaToken ||
- token.Kind() == SyntaxKind.OpenParenToken))
- {
- return true;
- }
-
- // [Foo(x: |
- if (token.Kind() == SyntaxKind.ColonToken &&
- token.Parent.IsKind(SyntaxKind.NameColon) &&
- token.Parent.IsParentKind(SyntaxKind.AttributeArgument))
- {
- return true;
- }
-
- // [Foo(X = |
- if (token.Kind() == SyntaxKind.EqualsToken &&
- token.Parent.IsKind(SyntaxKind.NameEquals) &&
- token.Parent.IsParentKind(SyntaxKind.AttributeArgument))
- {
- return true;
- }
-
- // TODO: Fixed-size buffer declarations
-
- return false;
- }
-
- public static bool IsLabelContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
-
- var gotoStatement = token.GetAncestor<GotoStatementSyntax>();
- if (gotoStatement != null)
- {
- if (gotoStatement.GotoKeyword == token)
- {
- return true;
- }
-
- if (gotoStatement.Expression != null &&
- !gotoStatement.Expression.IsMissing &&
- gotoStatement.Expression is IdentifierNameSyntax &&
- ((IdentifierNameSyntax)gotoStatement.Expression).Identifier == token &&
- token.IntersectsWith(position))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsExpressionContext(
- this SyntaxTree syntaxTree,
- int position,
- SyntaxToken tokenOnLeftOfPosition,
- bool attributes,
- CancellationToken cancellationToken,
- SemanticModel semanticModelOpt = null)
- {
- // cases:
- // var q = |
- // var q = a|
- // this list is *not* exhaustive.
-
- var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
-
- if (token.GetAncestor<ConditionalDirectiveTriviaSyntax>() != null)
- {
- return false;
- }
-
- if (!attributes)
- {
- if (token.GetAncestor<AttributeListSyntax>() != null)
- {
- return false;
- }
- }
-
- if (syntaxTree.IsConstantExpressionContext(position, tokenOnLeftOfPosition, cancellationToken))
- {
- return true;
- }
-
- // no expressions after . :: ->
- if (token.Kind() == SyntaxKind.DotToken ||
- token.Kind() == SyntaxKind.ColonColonToken ||
- token.Kind() == SyntaxKind.MinusGreaterThanToken)
- {
- return false;
- }
-
- // Normally you can have any sort of expression after an equals. However, this does not
- // apply to a "using Foo = ..." situation.
- if (token.Kind() == SyntaxKind.EqualsToken)
- {
- if (token.Parent.IsKind(SyntaxKind.NameEquals) &&
- token.Parent.IsParentKind(SyntaxKind.UsingDirective))
- {
- return false;
- }
- }
-
- // q = |
- // q -= |
- // q *= |
- // q += |
- // q /= |
- // q ^= |
- // q %= |
- // q &= |
- // q |= |
- // q <<= |
- // q >>= |
- if (token.Kind() == SyntaxKind.EqualsToken ||
- token.Kind() == SyntaxKind.MinusEqualsToken ||
- token.Kind() == SyntaxKind.AsteriskEqualsToken ||
- token.Kind() == SyntaxKind.PlusEqualsToken ||
- token.Kind() == SyntaxKind.SlashEqualsToken ||
- token.Kind() == SyntaxKind.ExclamationEqualsToken ||
- token.Kind() == SyntaxKind.CaretEqualsToken ||
- token.Kind() == SyntaxKind.AmpersandEqualsToken ||
- token.Kind() == SyntaxKind.BarEqualsToken ||
- token.Kind() == SyntaxKind.PercentEqualsToken ||
- token.Kind() == SyntaxKind.LessThanLessThanEqualsToken ||
- token.Kind() == SyntaxKind.GreaterThanGreaterThanEqualsToken)
- {
- return true;
- }
-
- // ( |
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.Parent.IsKind(SyntaxKind.ParenthesizedExpression))
- {
- return true;
- }
-
- // - |
- // + |
- // ~ |
- // ! |
- if (token.Parent is PrefixUnaryExpressionSyntax)
- {
- var prefix = token.Parent as PrefixUnaryExpressionSyntax;
- return prefix.OperatorToken == token;
- }
-
- // not sure about these:
- // ++ |
- // -- |
- #if false
- token.Kind == SyntaxKind.PlusPlusToken ||
- token.Kind == SyntaxKind.DashDashToken)
- #endif
- // await |
- if (token.Parent is AwaitExpressionSyntax)
- {
- var awaitExpression = token.Parent as AwaitExpressionSyntax;
- return awaitExpression.AwaitKeyword == token;
- }
-
- // Check for binary operators.
- // Note:
- // - We handle < specially as it can be ambiguous with generics.
- // - We handle * specially because it can be ambiguous with pointer types.
-
- // a *
- // a /
- // a %
- // a +
- // a -
- // a <<
- // a >>
- // a <
- // a >
- // a &&
- // a ||
- // a &
- // a |
- // a ^
- if (token.Parent is BinaryExpressionSyntax)
- {
- // If the client provided a binding, then check if this is actually generic. If so,
- // then this is not an expression context. i.e. if we have "Foo < |" then it could
- // be an expression context, or it could be a type context if Foo binds to a type or
- // method.
- if (semanticModelOpt != null && syntaxTree.IsGenericTypeArgumentContext(position, tokenOnLeftOfPosition, cancellationToken, semanticModelOpt))
- {
- return false;
- }
-
- var binary = token.Parent as BinaryExpressionSyntax;
- if (binary.OperatorToken == token)
- {
- // If this is a multiplication expression and a semantic model was passed in,
- // check to see if the expression to the left is a type name. If it is, treat
- // this as a pointer type.
- if (token.Kind() == SyntaxKind.AsteriskToken && semanticModelOpt != null)
- {
- var type = binary.Left as TypeSyntax;
- if (type != null && type.IsPotentialTypeName(semanticModelOpt, cancellationToken))
- {
- return false;
- }
- }
-
- return true;
- }
- }
-
- // Special case:
- // Foo * bar
- // Foo ? bar
- // This parses as a local decl called bar of type Foo* or Foo?
- if (tokenOnLeftOfPosition.IntersectsWith(position) &&
- tokenOnLeftOfPosition.Kind() == SyntaxKind.IdentifierToken)
- {
- var previousToken = tokenOnLeftOfPosition.GetPreviousToken(includeSkipped: true);
- if (previousToken.Kind() == SyntaxKind.AsteriskToken ||
- previousToken.Kind() == SyntaxKind.QuestionToken)
- {
- if (previousToken.Parent.IsKind(SyntaxKind.PointerType) ||
- previousToken.Parent.IsKind(SyntaxKind.NullableType))
- {
- var type = previousToken.Parent as TypeSyntax;
- if (type.IsParentKind(SyntaxKind.VariableDeclaration) &&
- type.Parent.IsParentKind(SyntaxKind.LocalDeclarationStatement))
- {
- // var declStatement = type.Parent.Parent as LocalDeclarationStatementSyntax;
-
- // note, this doesn't apply for cases where we know it
- // absolutely is not multiplcation or a conditional expression.
- var underlyingType = type is PointerTypeSyntax
- ? ((PointerTypeSyntax)type).ElementType
- : ((NullableTypeSyntax)type).ElementType;
-
- if (!underlyingType.IsPotentialTypeName(semanticModelOpt, cancellationToken))
- {
- return true;
- }
- }
- }
- }
- }
-
- // new int[|
- // new int[expr, |
- if (token.Kind() == SyntaxKind.OpenBracketToken ||
- token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent.IsKind(SyntaxKind.ArrayRankSpecifier))
- {
- return true;
- }
- }
-
- // foo ? |
- if (token.Kind() == SyntaxKind.QuestionToken &&
- token.Parent.IsKind(SyntaxKind.ConditionalExpression))
- {
- // If the condition is simply a TypeSyntax that binds to a type, treat this as a nullable type.
- var conditionalExpression = (ConditionalExpressionSyntax)token.Parent;
- var type = conditionalExpression.Condition as TypeSyntax;
-
- return type == null
- || !type.IsPotentialTypeName(semanticModelOpt, cancellationToken);
- }
-
- // foo ? bar : |
- if (token.Kind() == SyntaxKind.ColonToken &&
- token.Parent.IsKind(SyntaxKind.ConditionalExpression))
- {
- return true;
- }
-
- // typeof(|
- // default(|
- // sizeof(|
- if (token.Kind() == SyntaxKind.OpenParenToken)
- {
- if (token.Parent.IsKind(SyntaxKind.TypeOfExpression, SyntaxKind.DefaultExpression, SyntaxKind.SizeOfExpression))
- {
- return false;
- }
- }
-
- // Foo(|
- // Foo(expr, |
- // this[|
- if (token.Kind() == SyntaxKind.OpenParenToken ||
- token.Kind() == SyntaxKind.OpenBracketToken ||
- token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent.IsKind(SyntaxKind.ArgumentList, SyntaxKind.BracketedArgumentList))
- {
- return true;
- }
- }
-
- // [Foo(|
- // [Foo(expr, |
- if (attributes)
- {
- if (token.Kind() == SyntaxKind.OpenParenToken ||
- token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent.IsKind(SyntaxKind.AttributeArgumentList))
- {
- return true;
- }
- }
- }
-
- // Foo(ref |
- // Foo(bar |
- if (token.Kind() == SyntaxKind.RefKeyword ||
- token.Kind() == SyntaxKind.OutKeyword)
- {
- if (token.Parent.IsKind(SyntaxKind.Argument))
- {
- return true;
- }
- }
-
- // Foo(bar: |
- if (token.Kind() == SyntaxKind.ColonToken &&
- token.Parent.IsKind(SyntaxKind.NameColon) &&
- token.Parent.IsParentKind(SyntaxKind.Argument))
- {
- return true;
- }
-
- // a => |
- if (token.Kind() == SyntaxKind.EqualsGreaterThanToken)
- {
- return true;
- }
-
- // new List<int> { |
- // new List<int> { expr, |
- if (token.Kind() == SyntaxKind.OpenBraceToken ||
- token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent is InitializerExpressionSyntax)
- {
- // The compiler treats the ambiguous case as an object initializer, so we'll say
- // expressions are legal here
- if (token.Parent.Kind() == SyntaxKind.ObjectInitializerExpression && token.Kind() == SyntaxKind.OpenBraceToken)
- {
- // In this position { a$$ =, the user is trying to type an object initializer.
- if (!token.IntersectsWith(position) && token.GetNextToken().GetNextToken().Kind() == SyntaxKind.EqualsToken)
- {
- return false;
- }
-
- return true;
- }
-
- // Perform a semantic check to determine whether or not the type being created
- // can support a collection initializer. If not, this must be an object initializer
- // and can't be an expression context.
- if (semanticModelOpt != null &&
- token.Parent.IsParentKind(SyntaxKind.ObjectCreationExpression))
- {
- var objectCreation = (ObjectCreationExpressionSyntax)token.Parent.Parent;
- var type = semanticModelOpt.GetSymbolInfo(objectCreation.Type, cancellationToken).Symbol as ITypeSymbol;
- if (type != null && !type.CanSupportCollectionInitializer())
- {
- return false;
- }
- }
-
- return true;
- }
- }
-
- // for (; |
- // for (; ; |
- if (token.Kind() == SyntaxKind.SemicolonToken &&
- token.Parent.IsKind(SyntaxKind.ForStatement))
- {
- var forStatement = (ForStatementSyntax)token.Parent;
- if (token == forStatement.FirstSemicolonToken ||
- token == forStatement.SecondSemicolonToken)
- {
- return true;
- }
- }
-
- // for ( |
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.Parent.IsKind(SyntaxKind.ForStatement))
- {
- var forStatement = (ForStatementSyntax)token.Parent;
- if (token == forStatement.OpenParenToken)
- {
- return true;
- }
- }
-
- // for (; ; Foo(), |
- // for ( Foo(), |
- if (token.Kind() == SyntaxKind.CommaToken &&
- token.Parent.IsKind(SyntaxKind.ForStatement))
- {
- return true;
- }
-
- // foreach (var v in |
- // from a in |
- // join b in |
- if (token.Kind() == SyntaxKind.InKeyword)
- {
- if (token.Parent.IsKind(SyntaxKind.ForEachStatement, SyntaxKind.FromClause, SyntaxKind.JoinClause))
- {
- return true;
- }
- }
-
- // join x in y on |
- // join x in y on a equals |
- if (token.Kind() == SyntaxKind.OnKeyword ||
- token.Kind() == SyntaxKind.EqualsKeyword)
- {
- if (token.Parent.IsKind(SyntaxKind.JoinClause))
- {
- return true;
- }
- }
-
- // where |
- if (token.Kind() == SyntaxKind.WhereKeyword &&
- token.Parent.IsKind(SyntaxKind.WhereClause))
- {
- return true;
- }
-
- // orderby |
- // orderby a, |
- if (token.Kind() == SyntaxKind.OrderByKeyword ||
- token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent.IsKind(SyntaxKind.OrderByClause))
- {
- return true;
- }
- }
-
- // select |
- if (token.Kind() == SyntaxKind.SelectKeyword &&
- token.Parent.IsKind(SyntaxKind.SelectClause))
- {
- return true;
- }
-
- // group |
- // group expr by |
- if (token.Kind() == SyntaxKind.GroupKeyword ||
- token.Kind() == SyntaxKind.ByKeyword)
- {
- if (token.Parent.IsKind(SyntaxKind.GroupClause))
- {
- return true;
- }
- }
-
- // return |
- // yield return |
- // but not: [return |
- if (token.Kind() == SyntaxKind.ReturnKeyword)
- {
- if (token.GetPreviousToken(includeSkipped: true).Kind() != SyntaxKind.OpenBracketToken)
- {
- return true;
- }
- }
-
- // throw |
- if (token.Kind() == SyntaxKind.ThrowKeyword)
- {
- return true;
- }
-
- // while ( |
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.WhileKeyword)
- {
- return true;
- }
-
- // todo: handle 'for' cases.
-
- // using ( |
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.UsingKeyword)
- {
- return true;
- }
-
- // lock ( |
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.LockKeyword)
- {
- return true;
- }
-
- // lock ( |
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.IfKeyword)
- {
- return true;
- }
-
- // switch ( |
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.SwitchKeyword)
- {
- return true;
- }
-
- // checked ( |
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.CheckedKeyword)
- {
- return true;
- }
-
- // unchecked ( |
- if (token.Kind() == SyntaxKind.OpenParenToken &&
- token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.UncheckedKeyword)
- {
- return true;
- }
-
- // TODO: Uncomment on roslyn update when keyord currently missing.
- // when ( |
-// if (token.Kind() == SyntaxKind.OpenParenToken &&
-// token.GetPreviousToken(includeSkipped: true).Kind() == SyntaxKind.WhenKeyword)
-// {
-// return true;
-// }
-
- // (SomeType) |
- if (token.IsAfterPossibleCast())
- {
- return true;
- }
-
- // In anonymous type initializer.
- //
- // new { | We allow new inside of anonymous object member declarators, so that the user
- // can dot into a member afterward. For example:
- //
- // var a = new { new C().Foo };
- if (token.Kind() == SyntaxKind.OpenBraceToken || token.Kind() == SyntaxKind.CommaToken)
- {
- if (token.Parent.IsKind(SyntaxKind.AnonymousObjectCreationExpression))
- {
- return true;
- }
- }
-
- // $"{ |
- // $@"{ |
- // $"{x} { |
- // $@"{x} { |
- // TODO: Uncomment on roslyn update.
-// if (token.Kind() == SyntaxKind.OpenBraceToken)
-// {
-// return token.Parent.IsKind(SyntaxKind.Interpolation)
-// && ((InterpolationSyntax)token.Parent).OpenBraceToken == token;
-// }
-//
- return false;
- }
-
- public static bool IsNameOfContext(this SyntaxTree syntaxTree, int position, SemanticModel semanticModelOpt = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- // nameof(Foo.|
- // nameof(Foo.Bar.|
- // Locate the open paren.
- if (token.IsKind(SyntaxKind.DotToken))
- {
- // Could have been parsed as member access
- if (token.Parent.IsKind(SyntaxKind.SimpleMemberAccessExpression))
- {
- var parentMemberAccess = token.Parent;
- while (parentMemberAccess.IsParentKind(SyntaxKind.SimpleMemberAccessExpression))
- {
- parentMemberAccess = parentMemberAccess.Parent;
- }
-
- if (parentMemberAccess.IsParentKind(SyntaxKind.Argument) &&
- parentMemberAccess.Parent.IsChildNode<ArgumentListSyntax>(a => a.Arguments.FirstOrDefault()))
- {
- token = ((ArgumentListSyntax)parentMemberAccess.Parent.Parent).OpenParenToken;
- }
- }
-
- // Could have been parsed as a qualified name.
- if (token.Parent.IsKind(SyntaxKind.QualifiedName))
- {
- var parentQualifiedName = token.Parent;
- while (parentQualifiedName.IsParentKind(SyntaxKind.QualifiedName))
- {
- parentQualifiedName = parentQualifiedName.Parent;
- }
-
- if (parentQualifiedName.IsParentKind(SyntaxKind.Argument) &&
- parentQualifiedName.Parent.IsChildNode<ArgumentListSyntax>(a => a.Arguments.FirstOrDefault()))
- {
- token = ((ArgumentListSyntax)parentQualifiedName.Parent.Parent).OpenParenToken;
- }
- }
- }
-
- ExpressionSyntax parentExpression = null;
-
- // if the nameof expression has a missing close paren, it is parsed as an invocation expression.
- if (token.Parent.IsKind(SyntaxKind.ArgumentList) &&
- token.Parent.IsParentKind(SyntaxKind.InvocationExpression))
- {
- var invocationExpression = (InvocationExpressionSyntax)token.Parent.Parent;
- if (!invocationExpression.IsParentKind(SyntaxKind.ConditionalAccessExpression) &&
- !invocationExpression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) &&
- !invocationExpression.IsParentKind(SyntaxKind.PointerMemberAccessExpression) &&
- invocationExpression.Expression.IsKind(SyntaxKind.IdentifierName) &&
- ((IdentifierNameSyntax)invocationExpression.Expression).Identifier.IsKindOrHasMatchingText(SyntaxKind.NameOfKeyword))
- {
- parentExpression = invocationExpression;
- }
- }
-
- if (parentExpression != null)
- {
- if (semanticModelOpt == null)
- {
- return true;
- }
-
- return semanticModelOpt.GetSymbolInfo(parentExpression, cancellationToken).Symbol == null;
- }
-
- return false;
- }
-
- public static bool IsIsOrAsContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- // cases:
- // expr |
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.GetAncestor<BlockSyntax>() == null)
- {
- return false;
- }
-
- // is/as are valid after expressions.
- if (token.IsLastTokenOfNode<ExpressionSyntax>())
- {
- // However, many names look like expressions. For example:
- // foreach (var |
- // ('var' is a TypeSyntax which is an expression syntax.
-
- var type = token.GetAncestors<TypeSyntax>().LastOrDefault();
- if (type == null)
- {
- return true;
- }
-
- if (type.IsKind(SyntaxKind.GenericName) ||
- type.IsKind(SyntaxKind.AliasQualifiedName) ||
- type.IsKind(SyntaxKind.PredefinedType))
- {
- return false;
- }
-
- ExpressionSyntax nameExpr = type;
- if (IsRightSideName(nameExpr))
- {
- nameExpr = (ExpressionSyntax)nameExpr.Parent;
- }
-
- // If this name is the start of a local variable declaration context, we
- // shouldn't show is or as. For example: for(var |
- if (syntaxTree.IsLocalVariableDeclarationContext(token.SpanStart, syntaxTree.FindTokenOnLeftOfPosition(token.SpanStart, cancellationToken), cancellationToken))
- {
- return false;
- }
-
- // Not on the left hand side of an object initializer
- if (token.IsKind(SyntaxKind.IdentifierToken) &&
- token.Parent.IsKind(SyntaxKind.IdentifierName) &&
- (token.Parent.IsParentKind(SyntaxKind.ObjectInitializerExpression) || token.Parent.IsParentKind(SyntaxKind.CollectionInitializerExpression)))
- {
- return false;
- }
-
- // Not after an 'out' declaration expression. For example: M(out var |
- if (token.IsKind(SyntaxKind.IdentifierToken) &&
- token.Parent.IsKind(SyntaxKind.IdentifierName))
- {
- if (token.Parent.IsParentKind(SyntaxKind.Argument) &&
- ((ArgumentSyntax)token.Parent.Parent).RefOrOutKeyword.IsKind(SyntaxKind.OutKeyword))
- {
- return false;
- }
- }
-
- // Now, make sure the name was actually in a location valid for
- // an expression. If so, then we know we can follow it.
- if (syntaxTree.IsExpressionContext(nameExpr.SpanStart, syntaxTree.FindTokenOnLeftOfPosition(nameExpr.SpanStart, cancellationToken), attributes: false, cancellationToken: cancellationToken))
- {
- return true;
- }
-
- return false;
- }
-
- return false;
- }
-
- private static bool IsRightSideName(ExpressionSyntax name)
- {
- if (name.Parent != null)
- {
- switch (name.Parent.Kind())
- {
- case SyntaxKind.QualifiedName:
- return ((QualifiedNameSyntax)name.Parent).Right == name;
- case SyntaxKind.AliasQualifiedName:
- return ((AliasQualifiedNameSyntax)name.Parent).Name == name;
- case SyntaxKind.SimpleMemberAccessExpression:
- return ((MemberAccessExpressionSyntax)name.Parent).Name == name;
- }
- }
-
- return false;
- }
-
- public static bool IsCatchOrFinallyContext(
- this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- // cases:
- // try {
- // } |
-
- // try {
- // } c|
-
- // try {
- // } catch {
- // } |
-
- // try {
- // } catch {
- // } c|
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.Kind() == SyntaxKind.CloseBraceToken)
- {
- var block = token.GetAncestor<BlockSyntax>();
-
- if (block != null && token == block.GetLastToken(includeSkipped: true))
- {
- if (block.IsParentKind(SyntaxKind.TryStatement) ||
- block.IsParentKind(SyntaxKind.CatchClause))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public static bool IsCatchFilterContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
- {
- // cases:
- // catch |
- // catch i|
- // catch (declaration) |
- // catch (declaration) i|
-
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- if (token.IsKind(SyntaxKind.CatchKeyword))
- {
- return true;
- }
-
- if (token.IsKind(SyntaxKind.CloseParenToken) &&
- token.Parent.IsKind(SyntaxKind.CatchDeclaration))
- {
- return true;
- }
-
- return false;
- }
-
- public static bool IsEnumBaseListContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
- {
- var token = tokenOnLeftOfPosition;
- token = token.GetPreviousTokenIfTouchingWord(position);
-
- // Options:
- // enum E : |
- // enum E : i|
-
- return
- token.Kind() == SyntaxKind.ColonToken &&
- token.Parent.IsKind(SyntaxKind.BaseList) &&
- token.Parent.IsParentKind(SyntaxKind.EnumDeclaration);
- }
-
- public static bool IsEnumTypeMemberAccessContext(this SyntaxTree syntaxTree, SemanticModel semanticModel, int position, CancellationToken cancellationToken)
- {
- var token = syntaxTree
- .FindTokenOnLeftOfPosition(position, cancellationToken)
- .GetPreviousTokenIfTouchingWord(position);
-
- if (!token.IsKind(SyntaxKind.DotToken) ||
- !token.Parent.IsKind(SyntaxKind.SimpleMemberAccessExpression))
- {
- return false;
- }
-
- var memberAccess = (MemberAccessExpressionSyntax)token.Parent;
- var leftHandBinding = semanticModel.GetSymbolInfo(memberAccess.Expression, cancellationToken);
- var symbol = leftHandBinding.GetBestOrAllSymbols().FirstOrDefault();
-
- if (symbol == null)
- {
- return false;
- }
-
- switch (symbol.Kind)
- {
- case SymbolKind.NamedType:
- return ((INamedTypeSymbol)symbol).TypeKind == TypeKind.Enum;
- case SymbolKind.Alias:
- var target = ((IAliasSymbol)symbol).Target;
- return target.IsType && ((ITypeSymbol)target).TypeKind == TypeKind.Enum;
- }
-
- return false;
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/SyntaxTriviaExtensions.cs b/main/src/addins/CSharpBinding/Util/SyntaxTriviaExtensions.cs
deleted file mode 100644
index 6cf5554eee..0000000000
--- a/main/src/addins/CSharpBinding/Util/SyntaxTriviaExtensions.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class SyntaxTriviaExtensions
- {
- public static int Width(this SyntaxTrivia trivia)
- {
- return trivia.Span.Length;
- }
-
- public static int FullWidth(this SyntaxTrivia trivia)
- {
- return trivia.FullSpan.Length;
- }
-
- public static bool IsElastic(this SyntaxTrivia trivia)
- {
- return trivia.HasAnnotation(SyntaxAnnotation.ElasticAnnotation);
- }
-
- public static bool MatchesKind(this SyntaxTrivia trivia, SyntaxKind kind)
- {
- return trivia.Kind() == kind;
- }
-
- public static bool MatchesKind(this SyntaxTrivia trivia, SyntaxKind kind1, SyntaxKind kind2)
- {
- var triviaKind = trivia.Kind();
- return triviaKind == kind1 || triviaKind == kind2;
- }
-
- public static bool MatchesKind(this SyntaxTrivia trivia, params SyntaxKind[] kinds)
- {
- return kinds.Contains(trivia.Kind());
- }
-
- public static bool IsRegularComment(this SyntaxTrivia trivia)
- {
- return trivia.IsSingleLineComment() || trivia.IsMultiLineComment();
- }
-
- public static bool IsRegularOrDocComment(this SyntaxTrivia trivia)
- {
- return trivia.IsSingleLineComment() || trivia.IsMultiLineComment() || trivia.IsDocComment();
- }
-
- public static bool IsSingleLineComment(this SyntaxTrivia trivia)
- {
- return trivia.Kind() == SyntaxKind.SingleLineCommentTrivia;
- }
-
- public static bool IsMultiLineComment(this SyntaxTrivia trivia)
- {
- return trivia.Kind() == SyntaxKind.MultiLineCommentTrivia;
- }
-
- public static bool IsCompleteMultiLineComment(this SyntaxTrivia trivia)
- {
- if (trivia.Kind() != SyntaxKind.MultiLineCommentTrivia)
- {
- return false;
- }
-
- var text = trivia.ToFullString();
- return text.Length >= 4
- && text[text.Length - 1] == '/'
- && text[text.Length - 2] == '*';
- }
-
- public static bool IsDocComment(this SyntaxTrivia trivia)
- {
- return trivia.IsSingleLineDocComment() || trivia.IsMultiLineDocComment();
- }
-
- public static bool IsSingleLineDocComment(this SyntaxTrivia trivia)
- {
- return trivia.Kind() == SyntaxKind.SingleLineDocumentationCommentTrivia;
- }
-
- public static bool IsMultiLineDocComment(this SyntaxTrivia trivia)
- {
- return trivia.Kind() == SyntaxKind.MultiLineDocumentationCommentTrivia;
- }
-
- public static string GetCommentText(this SyntaxTrivia trivia)
- {
- var commentText = trivia.ToString();
- if (trivia.Kind() == SyntaxKind.SingleLineCommentTrivia)
- {
- if (commentText.StartsWith("//"))
- {
- commentText = commentText.Substring(2);
- }
-
- return commentText.TrimStart(null);
- }
- else if (trivia.Kind() == SyntaxKind.MultiLineCommentTrivia)
- {
- var textBuilder = new StringBuilder();
-
- if (commentText.EndsWith("*/"))
- {
- commentText = commentText.Substring(0, commentText.Length - 2);
- }
-
- if (commentText.StartsWith("/*"))
- {
- commentText = commentText.Substring(2);
- }
-
- commentText = commentText.Trim();
-
- var newLine = Environment.NewLine;
- var lines = commentText.Split(new[] { newLine }, StringSplitOptions.None);
- foreach (var line in lines)
- {
- var trimmedLine = line.Trim();
-
- // Note: we trim leading '*' characters in multi-line comments.
- // If the '*' was intentional, sorry, it's gone.
- if (trimmedLine.StartsWith("*"))
- {
- trimmedLine = trimmedLine.TrimStart('*');
- trimmedLine = trimmedLine.TrimStart(null);
- }
-
- textBuilder.AppendLine(trimmedLine);
- }
-
- // remove last line break
- textBuilder.Remove(textBuilder.Length - newLine.Length, newLine.Length);
-
- return textBuilder.ToString();
- }
- else
- {
- throw new InvalidOperationException();
- }
- }
-
- public static string AsString(this IEnumerable<SyntaxTrivia> trivia)
- {
- //Contract.ThrowIfNull(trivia);
-
- if (trivia.Any())
- {
- var sb = new StringBuilder();
- trivia.Select(t => t.ToFullString()).Do((s) => sb.Append(s));
- return sb.ToString();
- }
- else
- {
- return string.Empty;
- }
- }
-
- public static int GetFullWidth(this IEnumerable<SyntaxTrivia> trivia)
- {
- //Contract.ThrowIfNull(trivia);
- return trivia.Sum(t => t.FullWidth());
- }
-
- public static SyntaxTriviaList AsTrivia(this string s)
- {
- return SyntaxFactory.ParseLeadingTrivia(s ?? string.Empty);
- }
-
- public static bool IsWhitespaceOrEndOfLine(this SyntaxTrivia trivia)
- {
- return trivia.Kind() == SyntaxKind.WhitespaceTrivia || trivia.Kind() == SyntaxKind.EndOfLineTrivia;
- }
-
- public static SyntaxTrivia GetPreviousTrivia(
- this SyntaxTrivia trivia, SyntaxTree syntaxTree, CancellationToken cancellationToken, bool findInsideTrivia = false)
- {
- var span = trivia.FullSpan;
- if (span.Start == 0)
- {
- return default(SyntaxTrivia);
- }
-
- return syntaxTree.GetRoot(cancellationToken).FindTrivia(span.Start - 1, findInsideTrivia);
- }
-
- #if false
- public static int Width(this SyntaxTrivia trivia)
- {
- return trivia.Span.Length;
- }
-
- public static int FullWidth(this SyntaxTrivia trivia)
- {
- return trivia.FullSpan.Length;
- }
- #endif
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/SyntaxTriviaListExtensions.cs b/main/src/addins/CSharpBinding/Util/SyntaxTriviaListExtensions.cs
deleted file mode 100644
index b3c0723bcb..0000000000
--- a/main/src/addins/CSharpBinding/Util/SyntaxTriviaListExtensions.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal static class SyntaxTriviaListExtensions
- {
- public static bool Any(this SyntaxTriviaList triviaList, params SyntaxKind[] kinds)
- {
- foreach (var trivia in triviaList)
- {
- if (trivia.MatchesKind(kinds))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static SyntaxTrivia? GetFirstNewLine(this SyntaxTriviaList triviaList)
- {
- return triviaList
- .Where(t => t.Kind() == SyntaxKind.EndOfLineTrivia)
- .FirstOrNullable();
- }
-
- public static SyntaxTrivia? GetLastComment(this SyntaxTriviaList triviaList)
- {
- return triviaList
- .Where(t => t.MatchesKind(SyntaxKind.SingleLineCommentTrivia, SyntaxKind.MultiLineCommentTrivia))
- .LastOrNullable();
- }
-
- public static IEnumerable<SyntaxTrivia> SkipInitialWhitespace(this SyntaxTriviaList triviaList)
- {
- return triviaList.SkipWhile(t => t.Kind() == SyntaxKind.WhitespaceTrivia);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/TaskExtensions.cs b/main/src/addins/CSharpBinding/Util/TaskExtensions.cs
deleted file mode 100644
index 782c595650..0000000000
--- a/main/src/addins/CSharpBinding/Util/TaskExtensions.cs
+++ /dev/null
@@ -1,349 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.ErrorReporting;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- [SuppressMessage("ApiDesign", "RS0011", Justification = "Matching TPL Signatures")]
- static partial class TaskExtensions
- {
-
-
- // NOTE(cyrusn): Once we switch over to .Net 4.5 we can make our SafeContinueWith overloads
- // simply call into task.ContinueWith(..., TaskContinuationOptions.LazyCancellation, ...) as
- // that will have the semantics that we want. From the TPL guys:
- //
- // In this situation:
- #if false
- Task A = Task.Run(...);
- Task B = A.ContinueWith(..., cancellationToken);
- Task C = B.ContinueWith(...);
- #endif
- // If "cancellationToken" is signaled, B completes immediately (if it has not yet started).
- // Which means that C can start before A completes, which would seem to violate the rules of
- // the dependency chain.
- //
- // We've added TaskContinuationOptions.LazyCancellation option to signify "this continuation
- // will not complete due to cancellation until its antecedent has completed". We considered
- // simply changing the default underlying behavior, but rejected that idea because there was
- // a good chance that existing users had already drawn a dependency on the current behavior.
-
- public static Task SafeContinueWith(
- this Task task,
- Action<Task> continuationAction,
- CancellationToken cancellationToken,
- TaskContinuationOptions continuationOptions,
- TaskScheduler scheduler)
- {
- Func<Task, bool> continuationFunction = antecedent =>
- {
- continuationAction(antecedent);
- return true;
- };
-
- return task.SafeContinueWith(continuationFunction, cancellationToken, continuationOptions, scheduler);
- }
-
- public static Task<TResult> SafeContinueWith<TInput, TResult>(
- this Task<TInput> task,
- Func<Task<TInput>, TResult> continuationFunction,
- CancellationToken cancellationToken,
- TaskScheduler scheduler)
- {
- return SafeContinueWith<TInput, TResult>(
- task, continuationFunction, cancellationToken, TaskContinuationOptions.None, scheduler);
- }
-
- public static Task<TResult> SafeContinueWith<TInput, TResult>(
- this Task<TInput> task,
- Func<Task<TInput>, TResult> continuationFunction,
- CancellationToken cancellationToken,
- TaskContinuationOptions continuationOptions,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith<TResult>(
- (Task antecedent) => continuationFunction((Task<TInput>)antecedent), cancellationToken, continuationOptions, scheduler);
- }
-
- public static Task SafeContinueWith<TInput>(
- this Task<TInput> task,
- Action<Task<TInput>> continuationAction,
- CancellationToken cancellationToken,
- TaskContinuationOptions continuationOptions,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(
- (Task antecedent) => continuationAction((Task<TInput>)antecedent), cancellationToken, continuationOptions, scheduler);
- }
-
- public static Task<TResult> SafeContinueWith<TResult>(
- this Task task,
- Func<Task, TResult> continuationFunction,
- CancellationToken cancellationToken,
- TaskContinuationOptions continuationOptions,
- TaskScheduler scheduler)
- {
- // So here's the deal. Say you do the following:
- #if false
- // CancellationToken ct1 = ..., ct2 = ...;
-
- // Task A = Task.Factory.StartNew(..., ct1);
- // Task B = A.ContinueWith(..., ct1);
- // Task C = B.ContinueWith(..., ct2);
- #endif
- // If ct1 is cancelled then the following may occur:
- // 1) Task A can still be running (as it hasn't responded to the cancellation request
- // yet).
- // 2) Task C can start running. How? Well if B hasn't started running, it may
- // immediately transition to the 'Cancelled/Completed' state. Moving to that state will
- // immediately trigger C to run.
- //
- // We do not want this, so we pass the LazyCancellation flag to the TPL which implements
- // the behavior we want.
-
- Func<Task, TResult> outerFunction = t =>
- {
- try
- {
- return continuationFunction(t);
- }
- catch (Exception) //when (FatalError.ReportUnlessCanceled(e))
- {
- throw new InvalidOperationException ();
- }
- };
-
- // This is the only place in the code where we're allowed to call ContinueWith.
- return task.ContinueWith(outerFunction, cancellationToken, continuationOptions | TaskContinuationOptions.LazyCancellation, scheduler);
- }
-
- public static Task<TResult> SafeContinueWith<TResult>(
- this Task task,
- Func<Task, TResult> continuationFunction,
- CancellationToken cancellationToken,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(continuationFunction, cancellationToken, TaskContinuationOptions.None, scheduler);
- }
-
- public static Task SafeContinueWith(
- this Task task,
- Action<Task> continuationAction,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(continuationAction, CancellationToken.None, TaskContinuationOptions.None, scheduler);
- }
-
- public static Task SafeContinueWith<TInput>(
- this Task<TInput> task,
- Action<Task<TInput>> continuationFunction,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(continuationFunction, CancellationToken.None, TaskContinuationOptions.None, scheduler);
- }
-
- public static Task<TResult> SafeContinueWith<TInput, TResult>(
- this Task<TInput> task,
- Func<Task<TInput>, TResult> continuationFunction,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(continuationFunction, CancellationToken.None, TaskContinuationOptions.None, scheduler);
- }
-
- public static Task SafeContinueWith(
- this Task task,
- Action<Task> continuationAction,
- CancellationToken cancellationToken,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(continuationAction, cancellationToken, TaskContinuationOptions.None, scheduler);
- }
-
- // Code provided by Stephen Toub.
- public static Task<TResult> ContinueWithAfterDelay<TInput, TResult>(
- this Task<TInput> task,
- Func<Task<TInput>, TResult> continuationFunction,
- CancellationToken cancellationToken,
- int millisecondsDelay,
- TaskContinuationOptions taskContinuationOptions,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(t =>
- Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWith(
- _ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler),
- cancellationToken, taskContinuationOptions, scheduler).Unwrap();
- }
-
- public static Task<TNResult> ContinueWithAfterDelay<TNResult>(
- this Task task,
- Func<Task, TNResult> continuationFunction,
- CancellationToken cancellationToken,
- int millisecondsDelay,
- TaskContinuationOptions taskContinuationOptions,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(t =>
- Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWith(
- _ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler),
- cancellationToken, taskContinuationOptions, scheduler).Unwrap();
- }
-
- public static Task ContinueWithAfterDelay(
- this Task task,
- Action continuationAction,
- CancellationToken cancellationToken,
- int millisecondsDelay,
- TaskContinuationOptions taskContinuationOptions,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(t =>
- Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWith(
- _ => continuationAction(), cancellationToken, TaskContinuationOptions.None, scheduler),
- cancellationToken, taskContinuationOptions, scheduler).Unwrap();
- }
-
- public static Task<TResult> SafeContinueWithFromAsync<TInput, TResult>(
- this Task<TInput> task,
- Func<Task<TInput>, Task<TResult>> continuationFunction,
- CancellationToken cancellationToken,
- TaskContinuationOptions continuationOptions,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWithFromAsync<TResult>(
- (Task antecedent) => continuationFunction((Task<TInput>)antecedent), cancellationToken, continuationOptions, scheduler);
- }
-
- public static Task<TResult> SafeContinueWithFromAsync<TResult>(
- this Task task,
- Func<Task, Task<TResult>> continuationFunction,
- CancellationToken cancellationToken,
- TaskContinuationOptions continuationOptions,
- TaskScheduler scheduler)
- {
- // So here's the deal. Say you do the following:
- #if false
- // CancellationToken ct1 = ..., ct2 = ...;
-
- // Task A = Task.Factory.StartNew(..., ct1);
- // Task B = A.ContinueWith(..., ct1);
- // Task C = B.ContinueWith(..., ct2);
- #endif
- // If ct1 is cancelled then the following may occur:
- // 1) Task A can still be running (as it hasn't responded to the cancellation request
- // yet).
- // 2) Task C can start running. How? Well if B hasn't started running, it may
- // immediately transition to the 'Cancelled/Completed' state. Moving to that state will
- // immediately trigger C to run.
- //
- // We do not want this, so we pass the LazyCancellation flag to the TPL which implements
- // the behavior we want.
- // This is the only place in the code where we're allowed to call ContinueWith.
- var nextTask = task.ContinueWith(continuationFunction, cancellationToken, continuationOptions | TaskContinuationOptions.LazyCancellation, scheduler).Unwrap();
-
- nextTask.ContinueWith(ReportFatalError, continuationFunction,
- CancellationToken.None,
- TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
- TaskScheduler.Default);
-
- return nextTask;
- }
-
- public static Task SafeContinueWithFromAsync(
- this Task task,
- Func<Task, Task> continuationFunction,
- CancellationToken cancellationToken,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWithFromAsync(continuationFunction, cancellationToken, TaskContinuationOptions.None, scheduler);
- }
-
- public static Task SafeContinueWithFromAsync(
- this Task task,
- Func<Task, Task> continuationFunction,
- CancellationToken cancellationToken,
- TaskContinuationOptions continuationOptions,
- TaskScheduler scheduler)
- {
- // So here's the deal. Say you do the following:
- #if false
- // CancellationToken ct1 = ..., ct2 = ...;
-
- // Task A = Task.Factory.StartNew(..., ct1);
- // Task B = A.ContinueWith(..., ct1);
- // Task C = B.ContinueWith(..., ct2);
- #endif
- // If ct1 is cancelled then the following may occur:
- // 1) Task A can still be running (as it hasn't responded to the cancellation request
- // yet).
- // 2) Task C can start running. How? Well if B hasn't started running, it may
- // immediately transition to the 'Cancelled/Completed' state. Moving to that state will
- // immediately trigger C to run.
- //
- // We do not want this, so we pass the LazyCancellation flag to the TPL which implements
- // the behavior we want.
- // This is the only place in the code where we're allowed to call ContinueWith.
- var nextTask = task.ContinueWith(continuationFunction, cancellationToken, continuationOptions | TaskContinuationOptions.LazyCancellation, scheduler).Unwrap();
- ReportFatalError(nextTask, continuationFunction);
- return nextTask;
- }
-
- public static Task<TNResult> ContinueWithAfterDelayFromAsync<TNResult>(
- this Task task,
- Func<Task, Task<TNResult>> continuationFunction,
- CancellationToken cancellationToken,
- int millisecondsDelay,
- TaskContinuationOptions taskContinuationOptions,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(t =>
- Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWithFromAsync(
- _ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler),
- cancellationToken, taskContinuationOptions, scheduler).Unwrap();
- }
-
- public static Task ContinueWithAfterDelayFromAsync(
- this Task task,
- Func<Task, Task> continuationFunction,
- CancellationToken cancellationToken,
- int millisecondsDelay,
- TaskContinuationOptions taskContinuationOptions,
- TaskScheduler scheduler)
- {
- return task.SafeContinueWith(t =>
- Task.Delay(millisecondsDelay, cancellationToken).SafeContinueWithFromAsync(
- _ => continuationFunction(t), cancellationToken, TaskContinuationOptions.None, scheduler),
- cancellationToken, taskContinuationOptions, scheduler).Unwrap();
- }
-
- internal static void ReportFatalError(Task task, object continuationFunction)
- {
- task.ContinueWith(ReportFatalErrorWorker, continuationFunction,
- CancellationToken.None,
- TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
- TaskScheduler.Default);
- }
-
- [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
- private static void ReportFatalErrorWorker(Task task, object continuationFunction)
- {
- var exception = task.Exception;
- var methodInfo = ((Delegate)continuationFunction).GetMethodInfo();
- exception.Data["ContinuationFunction"] = methodInfo.DeclaringType.FullName + "::" + methodInfo.Name;
-
- // In case of a crash with ExecutionEngineException w/o call stack it might be possible to get the stack trace using WinDbg:
- // > !threads // find thread with System.ExecutionEngineException
- // ...
- // 67 65 4760 692b5d60 1029220 Preemptive CD9AE70C:FFFFFFFF 012ad0f8 0 MTA (Threadpool Worker) System.ExecutionEngineException 03c51108
- // ...
- // > ~67s // switch to thread 67
- // > !dso // dump stack objects
- //FatalError.Report(exception);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/TextLineExtension.cs b/main/src/addins/CSharpBinding/Util/TextLineExtension.cs
deleted file mode 100644
index 513df8fa98..0000000000
--- a/main/src/addins/CSharpBinding/Util/TextLineExtension.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal static class TextLineExtensions
- {
- /// <summary>
- /// Returns the first non-whitespace position on the given line, or null if
- /// the line is empty or contains only whitespace.
- /// </summary>
- public static int? GetFirstNonWhitespacePosition(this TextLine line)
- {
- var firstNonWhitespaceOffset = line.GetFirstNonWhitespaceOffset();
-
- return firstNonWhitespaceOffset.HasValue
- ? firstNonWhitespaceOffset + line.Start
- : null;
- }
-
- /// <summary>
- /// Returns the first non-whitespace position on the given line as an offset
- /// from the start of the line, or null if the line is empty or contains only
- /// whitespace.
- /// </summary>
- public static int? GetFirstNonWhitespaceOffset(this TextLine line)
- {
- return line.ToString().GetFirstNonWhitespaceOffset();
- }
-
- public static string GetLeadingWhitespace(this TextLine line)
- {
- return line.ToString().GetLeadingWhitespace();
- }
-
- /// <summary>
- /// Determines whether the specified line is empty or contains whitespace only.
- /// </summary>
- public static bool IsEmptyOrWhitespace(this TextLine line)
- {
- return string.IsNullOrWhiteSpace(line.ToString());
- }
-
- public static int GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine(this TextLine line, int tabSize)
- {
- return line.ToString().GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine(tabSize);
- }
-
- public static int GetColumnFromLineOffset(this TextLine line, int lineOffset, int tabSize)
- {
- return line.ToString().GetColumnFromLineOffset(lineOffset, tabSize);
- }
-
- public static int GetLineOffsetFromColumn(this TextLine line, int column, int tabSize)
- {
- return line.ToString().GetLineOffsetFromColumn(column, tabSize);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/TokenComparer.cs b/main/src/addins/CSharpBinding/Util/TokenComparer.cs
deleted file mode 100644
index 2fe8d6f412..0000000000
--- a/main/src/addins/CSharpBinding/Util/TokenComparer.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Globalization;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal class TokenComparer : IComparer<SyntaxToken>
- {
- private const string SystemNamespace = "System";
-
- public static readonly IComparer<SyntaxToken> NormalInstance = new TokenComparer(specialCaseSystem: false);
- public static readonly IComparer<SyntaxToken> SystemFirstInstance = new TokenComparer(specialCaseSystem: true);
-
- private readonly bool _specialCaseSystem;
-
- private TokenComparer(bool specialCaseSystem)
- {
- _specialCaseSystem = specialCaseSystem;
- }
-
- private static bool IsSystem(string s)
- {
- return s == SystemNamespace;
- }
-
- public int Compare(SyntaxToken x, SyntaxToken y)
- {
- if (_specialCaseSystem &&
- x.GetPreviousToken(includeSkipped: true).IsKind(SyntaxKind.UsingKeyword, SyntaxKind.StaticKeyword) &&
- y.GetPreviousToken(includeSkipped: true).IsKind(SyntaxKind.UsingKeyword, SyntaxKind.StaticKeyword))
- {
- var token1IsSystem = IsSystem(x.ValueText);
- var token2IsSystem = IsSystem(y.ValueText);
-
- if (token1IsSystem && !token2IsSystem)
- {
- return -1;
- }
- else if (!token1IsSystem && token2IsSystem)
- {
- return 1;
- }
- }
-
- return CompareWorker(x, y);
- }
-
- private int CompareWorker(SyntaxToken x, SyntaxToken y)
- {
- if (x == y)
- {
- return 0;
- }
-
- // By using 'ValueText' we get the value that is normalized. i.e.
- // @class will be 'class', and unicode escapes will be converted
- // to actual unicode. This allows sorting to work properly across
- // tokens that have different source representations, but which
- // mean the same thing.
- var string1 = x.ValueText;
- var string2 = y.ValueText;
-
- // First check in a case insensitive manner. This will put
- // everything that starts with an 'a' or 'A' above everything
- // that starts with a 'b' or 'B'.
- var compare = CultureInfo.InvariantCulture.CompareInfo.Compare(string1, string2,
- CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreWidth);
- if (compare != 0)
- {
- return compare;
- }
-
- // Now, once we've grouped such that 'a' words and 'A' words are
- // together, sort such that 'a' words come before 'A' words.
- return CultureInfo.InvariantCulture.CompareInfo.Compare(string1, string2,
- CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreWidth);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/TypeDeclarationSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/TypeDeclarationSyntaxExtensions.cs
deleted file mode 100644
index ee70daad0c..0000000000
--- a/main/src/addins/CSharpBinding/Util/TypeDeclarationSyntaxExtensions.cs
+++ /dev/null
@@ -1,321 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp;
-using System;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class TypeDeclarationSyntaxExtensions
- {
- public static TypeDeclarationSyntax AddMembers(
- this TypeDeclarationSyntax node, params MemberDeclarationSyntax[] members)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).AddMembers(members);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).AddMembers(members);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).AddMembers(members);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static TypeDeclarationSyntax WithMembers(
- this TypeDeclarationSyntax node, SyntaxList<MemberDeclarationSyntax> members)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).WithMembers(members);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).WithMembers(members);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).WithMembers(members);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static TypeDeclarationSyntax WithAttributeLists(
- this TypeDeclarationSyntax node, SyntaxList<AttributeListSyntax> attributes)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).WithAttributeLists(attributes);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).WithAttributeLists(attributes);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).WithAttributeLists(attributes);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static TypeDeclarationSyntax WithIdentifier(
- this TypeDeclarationSyntax node, SyntaxToken identifier)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).WithIdentifier(identifier);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).WithIdentifier(identifier);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).WithIdentifier(identifier);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static TypeDeclarationSyntax WithModifiers(
- this TypeDeclarationSyntax node, SyntaxTokenList modifiers)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).WithModifiers(modifiers);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).WithModifiers(modifiers);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).WithModifiers(modifiers);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static TypeDeclarationSyntax WithTypeParameterList(
- this TypeDeclarationSyntax node, TypeParameterListSyntax list)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).WithTypeParameterList(list);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).WithTypeParameterList(list);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).WithTypeParameterList(list);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static TypeDeclarationSyntax WithBaseList(
- this TypeDeclarationSyntax node, BaseListSyntax list)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).WithBaseList(list);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).WithBaseList(list);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).WithBaseList(list);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static TypeDeclarationSyntax WithConstraintClauses(
- this TypeDeclarationSyntax node, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).WithConstraintClauses(constraintClauses);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).WithConstraintClauses(constraintClauses);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).WithConstraintClauses(constraintClauses);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static TypeDeclarationSyntax WithOpenBraceToken(
- this TypeDeclarationSyntax node, SyntaxToken openBrace)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).WithOpenBraceToken(openBrace);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).WithOpenBraceToken(openBrace);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).WithOpenBraceToken(openBrace);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static TypeDeclarationSyntax WithCloseBraceToken(
- this TypeDeclarationSyntax node, SyntaxToken closeBrace)
- {
- switch (node.Kind())
- {
- case SyntaxKind.ClassDeclaration:
- return ((ClassDeclarationSyntax)node).WithCloseBraceToken(closeBrace);
- case SyntaxKind.InterfaceDeclaration:
- return ((InterfaceDeclarationSyntax)node).WithCloseBraceToken(closeBrace);
- case SyntaxKind.StructDeclaration:
- return ((StructDeclarationSyntax)node).WithCloseBraceToken(closeBrace);
- }
-
- throw new InvalidOperationException ();
- }
-
- public static IList<bool> GetInsertionIndices(this TypeDeclarationSyntax destination, CancellationToken cancellationToken)
- {
- var members = destination.Members;
-
- var indices = new List<bool>();
- if (members.Count == 0)
- {
- var start = destination.OpenBraceToken.Span.End;
- var end = GetEndToken(destination).SpanStart;
-
- indices.Add(!destination.OverlapsHiddenPosition(TextSpan.FromBounds(start, end), cancellationToken));
- }
- else
- {
- var start = destination.OpenBraceToken.Span.End;
- var end = destination.Members.First().SpanStart;
- indices.Add(!destination.OverlapsHiddenPosition(TextSpan.FromBounds(start, end), cancellationToken));
-
- for (int i = 0; i < members.Count - 1; i++)
- {
- var member1 = members[i];
- var member2 = members[i + 1];
-
- indices.Add(!destination.OverlapsHiddenPosition(member1, member2, cancellationToken));
- }
-
- start = members.Last().Span.End;
- end = GetEndToken(destination).SpanStart;
- indices.Add(!destination.OverlapsHiddenPosition(TextSpan.FromBounds(start, end), cancellationToken));
- }
-
- return indices;
- }
-
- private static SyntaxToken GetEndToken(SyntaxNode node)
- {
- var lastToken = node.GetLastToken(includeZeroWidth: true, includeSkipped: true);
-
- if (lastToken.IsMissing)
- {
- var nextToken = lastToken.GetNextToken(includeZeroWidth: true, includeSkipped: true);
- if (nextToken.RawKind != 0)
- {
- return nextToken;
- }
- }
-
- return lastToken;
- }
-
- public static IEnumerable<BaseTypeSyntax> GetAllBaseListTypes(this TypeDeclarationSyntax typeNode, SemanticModel model, CancellationToken cancellationToken)
- {
-
- IEnumerable<BaseTypeSyntax> baseListTypes = SpecializedCollections.EmptyEnumerable<BaseTypeSyntax>();
-
- var isPartialType = typeNode.Modifiers.Any(m => m.Kind() == SyntaxKind.PartialKeyword);
- if (isPartialType)
- {
- var typeSymbol = model.GetDeclaredSymbol(typeNode, cancellationToken);
- if (typeSymbol != null)
- {
- foreach (var syntaxRef in typeSymbol.DeclaringSyntaxReferences)
- {
- var typeDecl = syntaxRef.GetSyntax(cancellationToken) as TypeDeclarationSyntax;
- if (typeDecl != null && typeDecl.BaseList != null)
- {
- baseListTypes = baseListTypes.Concat(typeDecl.BaseList.Types);
- }
- }
- }
- }
- else if (typeNode.BaseList != null)
- {
- return typeNode.BaseList.Types;
- }
-
- return baseListTypes;
- }
-
- private static SyntaxToken EnsureToken(SyntaxToken token, bool prependNewLineIfMissing = false, bool appendNewLineIfMissing = false)
- {
- if (token.IsMissing)
- {
- var leadingTrivia = prependNewLineIfMissing ? token.LeadingTrivia.Insert(0, SyntaxFactory.CarriageReturnLineFeed) : token.LeadingTrivia;
- var trailingTrivia = appendNewLineIfMissing ? token.TrailingTrivia.Insert(0, SyntaxFactory.CarriageReturnLineFeed) : token.TrailingTrivia;
- return SyntaxFactory.Token(leadingTrivia, token.Kind(), trailingTrivia).WithAdditionalAnnotations(Formatter.Annotation);
- }
-
- return token;
- }
-
- private static void EnsureAndGetBraceTokens(
- BaseTypeDeclarationSyntax typeDeclaration,
- bool hasMembers,
- out SyntaxToken openBrace,
- out SyntaxToken closeBrace)
- {
- openBrace = EnsureToken(typeDeclaration.OpenBraceToken);
- closeBrace = EnsureToken(typeDeclaration.CloseBraceToken, appendNewLineIfMissing: true);
-
- if (!hasMembers)
- {
- // Bug 539673: If there are no members, take any trivia that
- // belongs to the end brace and attach it to the opening brace.
- int index = -1;
- var leadingTrivia = closeBrace.LeadingTrivia;
- for (int i = leadingTrivia.Count - 1; i >= 0; i--)
- {
- if (!leadingTrivia[i].IsWhitespaceOrEndOfLine())
- {
- index = i;
- break;
- }
- }
-
- if (index != -1)
- {
- openBrace = openBrace.WithTrailingTrivia(
- openBrace.TrailingTrivia.Concat(closeBrace.LeadingTrivia.Take(index + 1)));
- closeBrace = closeBrace.WithLeadingTrivia(
- closeBrace.LeadingTrivia.Skip(index + 1));
- }
- }
- }
-
- public static TypeDeclarationSyntax EnsureOpenAndCloseBraceTokens(
- this TypeDeclarationSyntax typeDeclaration)
- {
- SyntaxToken openBrace, closeBrace;
- EnsureAndGetBraceTokens(typeDeclaration, typeDeclaration.Members.Count > 0, out openBrace, out closeBrace);
- return typeDeclaration.WithOpenBraceToken(openBrace).WithCloseBraceToken(closeBrace);
- }
-
- public static EnumDeclarationSyntax EnsureOpenAndCloseBraceTokens(
- this EnumDeclarationSyntax typeDeclaration)
- {
- SyntaxToken openBrace, closeBrace;
- EnsureAndGetBraceTokens(typeDeclaration, typeDeclaration.Members.Count > 0, out openBrace, out closeBrace);
- return typeDeclaration.WithOpenBraceToken(openBrace).WithCloseBraceToken(closeBrace);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/TypeExtensions.cs b/main/src/addins/CSharpBinding/Util/TypeExtensions.cs
deleted file mode 100644
index 15c59836cc..0000000000
--- a/main/src/addins/CSharpBinding/Util/TypeExtensions.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-//
-// TypeExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Simplification;
-using System.Threading.Tasks;
-using System.Collections.Immutable;
-using System.Threading;
-using System.Text;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-using MonoDevelop.Ide.TypeSystem;
-using System.Runtime.CompilerServices;
-using System.Collections.Concurrent;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class TypeExtensions
- {
- readonly static MethodInfo generateTypeSyntaxMethod;
- readonly static MethodInfo findImplementingTypesAsync;
-
- static TypeExtensions()
- {
- var typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.ITypeSymbolExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true);
- generateTypeSyntaxMethod = typeInfo.GetMethod("GenerateTypeSyntax", new[] { typeof(ITypeSymbol) });
-
- typeInfo = Type.GetType("Microsoft.CodeAnalysis.FindSymbols.DependentTypeFinder" + ReflectionNamespaces.WorkspacesAsmName, true);
- findImplementingTypesAsync = typeInfo.GetMethod("FindTransitivelyImplementingTypesAsync", new[] { typeof(INamedTypeSymbol), typeof(Solution), typeof(IImmutableSet<Project>), typeof(CancellationToken) });
- if (findImplementingTypesAsync == null)
- throw new Exception ("Can't find FindTransitivelyImplementingTypesAsync");
- }
-
- public static TypeSyntax GenerateTypeSyntax(this ITypeSymbol typeSymbol, SyntaxAnnotation simplifierAnnotation = null)
- {
- var typeSyntax = (TypeSyntax)generateTypeSyntaxMethod.Invoke(null, new object[] { typeSymbol });
- if (simplifierAnnotation != null)
- return typeSyntax.WithAdditionalAnnotations(simplifierAnnotation);
- return typeSyntax;
- }
-
- #region GetDelegateInvokeMethod
- /// <summary>
- /// Gets the invoke method for a delegate type.
- /// </summary>
- /// <remarks>
- /// Returns null if the type is not a delegate type; or if the invoke method could not be found.
- /// </remarks>
- public static IMethodSymbol GetDelegateInvokeMethod(this ITypeSymbol type)
- {
- if (type == null)
- throw new ArgumentNullException("type");
- if (type.TypeKind == TypeKind.Delegate)
- return type.GetMembers ("Invoke").OfType<IMethodSymbol>().FirstOrDefault(m => m.MethodKind == MethodKind.DelegateInvoke);
- return null;
- }
- #endregion
-
- public static Task<IEnumerable<INamedTypeSymbol>> FindImplementingTypesAsync (this INamedTypeSymbol type, Solution solution, IImmutableSet<Project> projects = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- try {
- return (Task<IEnumerable<INamedTypeSymbol>>)findImplementingTypesAsync.Invoke(null, new object[] { type, solution, projects, cancellationToken });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public static bool IsNullableType(this ITypeSymbol type)
- {
- var original = type.OriginalDefinition;
- return original.SpecialType == SpecialType.System_Nullable_T;
- }
-
- public static ITypeSymbol GetNullableUnderlyingType(this ITypeSymbol type)
- {
- if (!IsNullableType(type))
- return null;
- return ((INamedTypeSymbol)type).TypeArguments[0];
- }
-
- /// <summary>
- /// Gets all base classes and interfaces.
- /// </summary>
- /// <returns>All classes and interfaces.</returns>
- /// <param name="type">Type.</param>
- public static IEnumerable<INamedTypeSymbol> GetAllBaseClassesAndInterfaces (this INamedTypeSymbol type, bool includeSuperType = false)
- {
- if (!includeSuperType)
- type = type.BaseType;
- var curType = type;
- while (curType != null) {
- yield return curType;
- curType = curType.BaseType;
- }
-
- foreach (var inter in type.AllInterfaces) {
- yield return inter;
- }
- }
-
- /// <summary>
- /// Determines if derived from baseType. Includes itself, all base classes and all interfaces.
- /// </summary>
- /// <returns><c>true</c> if is derived from the specified type baseType; otherwise, <c>false</c>.</returns>
- /// <param name="type">Type.</param>
- /// <param name="baseType">Base type.</param>
- public static bool IsDerivedFromClassOrInterface(this INamedTypeSymbol type, INamedTypeSymbol baseType)
- {
- //NR5 is returning true also for same type
- for (; type != null; type = type.BaseType) {
- if (type == baseType) {
- return true;
- }
- }
- //And interfaces
- foreach (var inter in type.AllInterfaces) {
- if (inter == baseType) {
- return true;
- }
- }
- return false;
- }
-
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/TypeGenerator.cs b/main/src/addins/CSharpBinding/Util/TypeGenerator.cs
deleted file mode 100644
index 6df4a4dd66..0000000000
--- a/main/src/addins/CSharpBinding/Util/TypeGenerator.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// TypeGenerator.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.LanguageServices;
-using Microsoft.CodeAnalysis.Shared.Utilities;
-using Roslyn.Utilities;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class TypeGenerator
- {
- readonly static Type typeInfo;
-
- object instance;
-
- readonly static MethodInfo createArrayTypeSymbolMethod;
- readonly static MethodInfo createPointerTypeSymbolMethod;
- readonly static MethodInfo constructMethod;
-
- internal object Instance {
- get {
- return instance;
- }
- }
-
- static TypeGenerator()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CodeGeneration.TypeGenerator" + ReflectionNamespaces.WorkspacesAsmName, true);
-
- createArrayTypeSymbolMethod = typeInfo.GetMethod ("CreateArrayTypeSymbol");
- createPointerTypeSymbolMethod = typeInfo.GetMethod ("CreatePointerTypeSymbol");
- constructMethod = typeInfo.GetMethod ("Construct");
-
- }
-
- public TypeGenerator ()
- {
- instance = Activator.CreateInstance (typeInfo);
- }
-
- public ITypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank)
- {
- try {
- return (ITypeSymbol)createArrayTypeSymbolMethod.Invoke(instance, new object[] { elementType, rank });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public ITypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
- {
- try {
- return (ITypeSymbol)createPointerTypeSymbolMethod.Invoke(instance, new object[] { pointedAtType });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
-
- public ITypeSymbol Construct(INamedTypeSymbol namedType, ITypeSymbol[] typeArguments)
- {
- try {
- return (ITypeSymbol)constructMethod.Invoke(instance, new object[] { namedType, typeArguments });
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- return null;
- }
- }
- }
-
-}
diff --git a/main/src/addins/CSharpBinding/Util/TypeSyntaxComparer.cs b/main/src/addins/CSharpBinding/Util/TypeSyntaxComparer.cs
deleted file mode 100644
index ec46567e7f..0000000000
--- a/main/src/addins/CSharpBinding/Util/TypeSyntaxComparer.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Symbols;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal class TypeSyntaxComparer : IComparer<TypeSyntax>
- {
- private readonly IComparer<SyntaxToken> _tokenComparer;
- internal IComparer<NameSyntax> NameComparer;
-
- internal TypeSyntaxComparer(IComparer<SyntaxToken> tokenComparer)
- {
- _tokenComparer = tokenComparer;
- }
-
- public int Compare(TypeSyntax x, TypeSyntax y)
- {
- if (x == y)
- {
- return 0;
- }
-
- x = UnwrapType(x);
- y = UnwrapType(y);
-
- if (x is NameSyntax && y is NameSyntax)
- {
- return NameComparer.Compare((NameSyntax)x, (NameSyntax)y);
- }
-
- // we have two predefined types, or a predefined type and a normal C# name. We only need
- // to compare the first tokens here.
- return _tokenComparer.Compare(x.GetFirstToken(includeSkipped: true), y.GetFirstToken());
- }
-
- private TypeSyntax UnwrapType(TypeSyntax type)
- {
- while (true)
- {
- switch (type.Kind())
- {
- case SyntaxKind.ArrayType:
- type = ((ArrayTypeSyntax)type).ElementType;
- break;
- case SyntaxKind.PointerType:
- type = ((PointerTypeSyntax)type).ElementType;
- break;
- case SyntaxKind.NullableType:
- type = ((NullableTypeSyntax)type).ElementType;
- break;
- default:
- return type;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/TypeSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/TypeSyntaxExtensions.cs
deleted file mode 100644
index 4f47c1d8d2..0000000000
--- a/main/src/addins/CSharpBinding/Util/TypeSyntaxExtensions.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-//
-// TypeSyntaxExtensions.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis;
-using System.Threading;
-using System.Linq;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class TypeSyntaxExtensions
- {
- public static bool IsPartial(this TypeSyntax typeSyntax)
- {
- return typeSyntax is IdentifierNameSyntax &&
- ((IdentifierNameSyntax)typeSyntax).Identifier.IsKind(SyntaxKind.PartialKeyword);
- }
-
- public static bool IsPotentialTypeName(this TypeSyntax typeSyntax, SemanticModel semanticModelOpt, CancellationToken cancellationToken)
- {
- if (typeSyntax == null)
- {
- return false;
- }
-
- if (typeSyntax is PredefinedTypeSyntax ||
- typeSyntax is ArrayTypeSyntax ||
- typeSyntax is GenericNameSyntax ||
- typeSyntax is PointerTypeSyntax ||
- typeSyntax is NullableTypeSyntax)
- {
- return true;
- }
-
- if (semanticModelOpt == null)
- {
- return false;
- }
-
- var nameSyntax = typeSyntax as NameSyntax;
- if (nameSyntax == null)
- {
- return false;
- }
-
- var nameToken = nameSyntax.GetNameToken();
-
- var symbols = semanticModelOpt.LookupName(nameToken, namespacesAndTypesOnly: true, cancellationToken: cancellationToken);
- var firstSymbol = symbols.FirstOrDefault();
-
- var typeSymbol = firstSymbol != null && firstSymbol.Kind == SymbolKind.Alias
- ? (firstSymbol as IAliasSymbol).Target
- : firstSymbol as ITypeSymbol;
-
- return typeSymbol != null
- && !typeSymbol.IsErrorType();
- }
-
- /// <summary>
- /// Determines whether the specified TypeSyntax is actually 'var'.
- /// </summary>
- public static bool IsTypeInferred(this TypeSyntax typeSyntax, SemanticModel semanticModel)
- {
- if (!typeSyntax.IsVar)
- {
- return false;
- }
-
- if (semanticModel.GetAliasInfo(typeSyntax) != null)
- {
- return false;
- }
-
- var type = semanticModel.GetTypeInfo(typeSyntax).Type;
- if (type == null)
- {
- return false;
- }
-
- if (type.Name == "var")
- {
- return false;
- }
-
- return true;
- }
- }
-
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/UsingsAndExternAliasesDirectiveComparer.cs b/main/src/addins/CSharpBinding/Util/UsingsAndExternAliasesDirectiveComparer.cs
deleted file mode 100644
index f7f3c623a8..0000000000
--- a/main/src/addins/CSharpBinding/Util/UsingsAndExternAliasesDirectiveComparer.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Roslyn.Utilities;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- class UsingsAndExternAliasesDirectiveComparer : IComparer<SyntaxNode>
- {
- public static readonly IComparer<SyntaxNode> NormalInstance = new UsingsAndExternAliasesDirectiveComparer(
- NameSyntaxComparer.Create(TokenComparer.NormalInstance),
- TokenComparer.NormalInstance);
-
- public static readonly IComparer<SyntaxNode> SystemFirstInstance = new UsingsAndExternAliasesDirectiveComparer(
- NameSyntaxComparer.Create(TokenComparer.SystemFirstInstance),
- TokenComparer.SystemFirstInstance);
-
- private readonly IComparer<NameSyntax> _nameComparer;
- private readonly IComparer<SyntaxToken> _tokenComparer;
-
- private UsingsAndExternAliasesDirectiveComparer(
- IComparer<NameSyntax> nameComparer,
- IComparer<SyntaxToken> tokenComparer)
- {
- _nameComparer = nameComparer;
- _tokenComparer = tokenComparer;
- }
-
- public int Compare(SyntaxNode directive1, SyntaxNode directive2)
- {
- if (directive1 == directive2)
- {
- return 0;
- }
-
- var using1 = directive1 as UsingDirectiveSyntax;
- var using2 = directive2 as UsingDirectiveSyntax;
- var extern1 = directive1 as ExternAliasDirectiveSyntax;
- var extern2 = directive2 as ExternAliasDirectiveSyntax;
-
- var directive1IsExtern = extern1 != null;
- var directive2IsExtern = extern2 != null;
-
- var directive1IsNamespace = using1 != null && using1.Alias == null && !using1.StaticKeyword.IsKind(SyntaxKind.StaticKeyword);
- var directive2IsNamespace = using2 != null && using2.Alias == null && !using2.StaticKeyword.IsKind(SyntaxKind.StaticKeyword);
-
- var directive1IsUsingStatic = using1 != null && using1.StaticKeyword.IsKind(SyntaxKind.StaticKeyword);
- var directive2IsUsingStatic = using2 != null && using2.StaticKeyword.IsKind(SyntaxKind.StaticKeyword);
-
- var directive1IsAlias = using1 != null && using1.Alias != null;
- var directive2IsAlias = using2 != null && using2.Alias != null;
-
- // different types of usings get broken up into groups.
- // * externs
- // * usings
- // * using statics
- // * aliases
-
- if (directive1IsExtern && !directive2IsExtern)
- {
- return -1;
- }
- else if (directive2IsExtern && !directive1IsExtern)
- {
- return 1;
- }
- else if (directive1IsNamespace && !directive2IsNamespace)
- {
- return -1;
- }
- else if (directive2IsNamespace && !directive1IsNamespace)
- {
- return 1;
- }
- else if (directive1IsUsingStatic && !directive2IsUsingStatic)
- {
- return -1;
- }
- else if (directive2IsUsingStatic && !directive1IsUsingStatic)
- {
- return 1;
- }
- else if (directive1IsAlias && !directive2IsAlias)
- {
- return -1;
- }
- else if (directive2IsAlias && !directive1IsAlias)
- {
- return 1;
- }
-
- // ok, it's the same type of using now.
- if (directive1IsExtern)
- {
- // they're externs, sort by the alias
- return _tokenComparer.Compare(extern1.Identifier, extern2.Identifier);
- }
- else if (directive1IsAlias)
- {
- var aliasComparisonResult = _tokenComparer.Compare(using1.Alias.Name.Identifier, using2.Alias.Name.Identifier);
-
- if (aliasComparisonResult == 0)
- {
- // They both use the same alias, so compare the names.
- return _nameComparer.Compare(using1.Name, using2.Name);
- }
- else
- {
- return aliasComparisonResult;
- }
- }
- else
- {
- return _nameComparer.Compare(using1.Name, using2.Name);
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/UsingsAndExternAliasesOrganizer.cs b/main/src/addins/CSharpBinding/Util/UsingsAndExternAliasesOrganizer.cs
deleted file mode 100644
index a4896cad84..0000000000
--- a/main/src/addins/CSharpBinding/Util/UsingsAndExternAliasesOrganizer.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// UsingsAndExternAliasesOrganizer.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Runtime.ExceptionServices;
-using System.Reflection;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- static class UsingsAndExternAliasesOrganizer
- {
- static UsingsAndExternAliasesOrganizer ()
- {
- var typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CSharp.Utilities.UsingsAndExternAliasesOrganizer" + ReflectionNamespaces.CSWorkspacesAsmName, true);
-
- organizeMethod = typeInfo.GetMethod ("Organize");
- }
-
- readonly static System.Reflection.MethodInfo organizeMethod;
-
- public static void Organize(
- SyntaxList<ExternAliasDirectiveSyntax> externAliasList,
- SyntaxList<UsingDirectiveSyntax> usingList,
- bool placeSystemNamespaceFirst,
- out SyntaxList<ExternAliasDirectiveSyntax> organizedExternAliasList,
- out SyntaxList<UsingDirectiveSyntax> organizedUsingList)
- {
- try {
- var args = new object[] { externAliasList, usingList, placeSystemNamespaceFirst, default(SyntaxList<ExternAliasDirectiveSyntax>), default(SyntaxList<UsingDirectiveSyntax>)};
- organizeMethod.Invoke (null, args);
- organizedExternAliasList = (SyntaxList<ExternAliasDirectiveSyntax>)args [3];
- organizedUsingList = (SyntaxList<UsingDirectiveSyntax>)args [4];
- } catch (TargetInvocationException ex) {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- }
- }
- }
-}
-
diff --git a/main/src/addins/CSharpBinding/Util/ValueTuple.cs b/main/src/addins/CSharpBinding/Util/ValueTuple.cs
deleted file mode 100644
index aedf5bca99..0000000000
--- a/main/src/addins/CSharpBinding/Util/ValueTuple.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- // tuple factory
- static class ValueTuple
- {
- public static ValueTuple<T1, T2> Create<T1, T2>(T1 item1, T2 item2)
- {
- return new ValueTuple<T1, T2>(item1, item2);
- }
-
-// public static ValueTuple<T1, T2, T3> Create<T1, T2, T3>(T1 item1, T2 item2, T3 item3)
-// {
-// return new ValueTuple<T1, T2, T3>(item1, item2, item3);
-// }
- }
-}
diff --git a/main/src/addins/CSharpBinding/Util/ValueTuple`2.cs b/main/src/addins/CSharpBinding/Util/ValueTuple`2.cs
deleted file mode 100644
index 96fcb2eb4b..0000000000
--- a/main/src/addins/CSharpBinding/Util/ValueTuple`2.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- // struct with two values
- struct ValueTuple<T1, T2> : IEquatable<ValueTuple<T1, T2>>
- {
- private static readonly EqualityComparer<T1> s_comparer1 = EqualityComparer<T1>.Default;
- private static readonly EqualityComparer<T2> s_comparer2 = EqualityComparer<T2>.Default;
-
- public readonly T1 Item1;
- public readonly T2 Item2;
-
- public ValueTuple(T1 item1, T2 item2)
- {
- this.Item1 = item1;
- this.Item2 = item2;
- }
-
- public bool Equals(ValueTuple<T1, T2> other)
- {
- return s_comparer1.Equals(this.Item1, other.Item1)
- && s_comparer2.Equals(this.Item2, other.Item2);
- }
-
- public override bool Equals(object obj)
- {
- if (obj is ValueTuple<T1, T2>)
- {
- var other = (ValueTuple<T1, T2>)obj;
- return this.Equals(other);
- }
-
- return false;
- }
-
- public override int GetHashCode()
- {
- return Hash.Combine(s_comparer1.GetHashCode(Item1), s_comparer2.GetHashCode(Item2));
- }
-
- public static bool operator ==(ValueTuple<T1, T2> left, ValueTuple<T1, T2> right)
- {
- return left.Equals(right);
- }
-
- public static bool operator !=(ValueTuple<T1, T2> left, ValueTuple<T1, T2> right)
- {
- return !left.Equals(right);
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/gtk-gui/gui.stetic b/main/src/addins/CSharpBinding/gtk-gui/gui.stetic
index ad4c8e592a..5f3d55580e 100644
--- a/main/src/addins/CSharpBinding/gtk-gui/gui.stetic
+++ b/main/src/addins/CSharpBinding/gtk-gui/gui.stetic
@@ -8,8 +8,8 @@
<widget-library name="../../../../build/bin/MonoDevelop.Ide.dll" />
<widget-library name="../../../../build/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll" />
<widget-library name="../../../../build/AddIns/MonoDevelop.Refactoring/MonoDevelop.Refactoring.dll" />
- <widget-library name="../../../../build/AddIns/NUnit/MonoDevelop.NUnit.dll" />
- <widget-library name="../../../../build/AddIns/BackendBindings/MonoDevelop.CSharpBinding.dll" internal="true" />
+ <widget-library name="../../../../build/AddIns/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.dll" />
+ <widget-library name="../../../../build/AddIns/CSharpBinding/MonoDevelop.CSharpBinding.dll" internal="true" />
</import>
<widget class="Gtk.Bin" id="MonoDevelop.CSharp.Project.CodeGenerationPanelWidget" design-size="428 473">
<property name="MemberName" />
@@ -512,7 +512,6 @@ None</property>
</widget>
<widget class="Gtk.Bin" id="MonoDevelop.CSharp.Project.CompilerOptionsPanelWidget" design-size="471 438">
<property name="MemberName" />
- <property name="GeneratePublic">False</property>
<child>
<widget class="Gtk.VBox" id="vbox1">
<property name="MemberName" />
@@ -620,7 +619,6 @@ None</property>
<child>
<widget class="MonoDevelop.Components.FileEntry" id="iconEntry">
<property name="MemberName" />
- <property name="DisplayAsRelativePath">False</property>
</widget>
<packing>
<property name="TopAttach">2</property>
@@ -1408,94 +1406,6 @@ None</property>
</widget>
</child>
</widget>
- <widget class="Gtk.Bin" id="MonoDevelop.CSharp.Diagnostics.InconsistentNaming.NameConventionPanelWidget" design-size="300 300">
- <property name="MemberName" />
- <property name="Visible">False</property>
- <property name="GeneratePublic">False</property>
- <child>
- <widget class="Gtk.HBox" id="hbox3">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow">
- <property name="MemberName" />
- <property name="ShadowType">In</property>
- <child>
- <widget class="Gtk.TreeView" id="treeviewConventions">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="ShowScrollbars">True</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.VBox" id="vbox3">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.Button" id="buttonEdit">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="UseStock">True</property>
- <property name="Type">StockItem</property>
- <property name="StockId">gtk-edit</property>
- <property name="label">gtk-edit</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Button" id="buttonAdd">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="UseStock">True</property>
- <property name="Type">StockItem</property>
- <property name="StockId">gtk-add</property>
- <property name="label">gtk-add</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Button" id="buttonRemove">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="UseStock">True</property>
- <property name="Type">StockItem</property>
- <property name="StockId">gtk-remove</property>
- <property name="label">gtk-remove</property>
- </widget>
- <packing>
- <property name="Position">2</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
<widget class="Gtk.Window" id="MonoDevelop.CodeGeneration.GenerateCodeWindow" design-size="288 369">
<property name="MemberName" />
<property name="Visible">False</property>
@@ -1578,530 +1488,6 @@ None</property>
</widget>
</child>
</widget>
- <widget class="Gtk.Dialog" id="MonoDevelop.CSharp.Diagnostics.InconsistentNaming.NameConventionEditRuleDialog" design-size="804 508">
- <property name="MemberName" />
- <property name="WidthRequest">640</property>
- <property name="HeightRequest">480</property>
- <property name="GeneratePublic">False</property>
- <property name="Title" translatable="yes">Edit Naming Rule</property>
- <property name="WindowPosition">CenterOnParent</property>
- <property name="Modal">True</property>
- <property name="Resizable">False</property>
- <property name="DestroyWithParent">True</property>
- <property name="SkipPagerHint">True</property>
- <property name="SkipTaskbarHint">True</property>
- <property name="Buttons">2</property>
- <property name="HelpButton">False</property>
- <child internal-child="VBox">
- <widget class="Gtk.VBox" id="dialog1_VBox">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <property name="BorderWidth">2</property>
- <child>
- <widget class="Gtk.VBox" id="vbox3">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <property name="BorderWidth">6</property>
- <child>
- <widget class="Gtk.HBox" id="hbox3">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.Label" id="label4">
- <property name="MemberName" />
- <property name="Xalign">1</property>
- <property name="LabelProp" translatable="yes">_Rule:</property>
- <property name="UseUnderline">True</property>
- <property name="MnemonicWidget">entry1</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- <property name="Padding">6</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Entry" id="entryRuleName">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="IsEditable">True</property>
- <property name="InvisibleChar">●</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.HBox" id="hbox1">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.Table" id="table1">
- <property name="MemberName" />
- <property name="NRows">4</property>
- <property name="NColumns">2</property>
- <property name="RowSpacing">6</property>
- <property name="ColumnSpacing">6</property>
- <property name="BorderWidth">6</property>
- <child>
- <placeholder />
- </child>
- <child>
- <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow">
- <property name="MemberName" />
- <property name="ShadowType">In</property>
- <child>
- <widget class="Gtk.TreeView" id="treeviewEntities">
- <property name="MemberName" />
- <property name="WidthRequest">0</property>
- <property name="CanFocus">True</property>
- <property name="ShowScrollbars">True</property>
- <property name="HeadersVisible">False</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="TopAttach">1</property>
- <property name="BottomAttach">2</property>
- <property name="RightAttach">2</property>
- <property name="YPadding">6</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">True</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow1">
- <property name="MemberName" />
- <property name="ShadowType">In</property>
- <child>
- <widget class="Gtk.TreeView" id="treeviewAccessibility">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="ShowScrollbars">True</property>
- <property name="HeadersVisible">False</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="TopAttach">3</property>
- <property name="BottomAttach">4</property>
- <property name="XPadding">6</property>
- <property name="YPadding">6</property>
- <property name="AutoSize">False</property>
- <property name="XExpand">True</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">True</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label5">
- <property name="MemberName" />
- <property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes">_Affected entities:</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label6">
- <property name="MemberName" />
- <property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes">_Accessibility:</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="TopAttach">2</property>
- <property name="BottomAttach">3</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Table" id="table2">
- <property name="MemberName" />
- <property name="NRows">5</property>
- <property name="NColumns">2</property>
- <property name="RowSpacing">6</property>
- <property name="ColumnSpacing">6</property>
- <child>
- <widget class="Gtk.Entry" id="entryPrefix">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="IsEditable">True</property>
- <property name="InvisibleChar">●</property>
- </widget>
- <packing>
- <property name="TopAttach">1</property>
- <property name="BottomAttach">2</property>
- <property name="LeftAttach">1</property>
- <property name="RightAttach">2</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Entry" id="entryPrefixAllowed">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="IsEditable">True</property>
- <property name="InvisibleChar">●</property>
- </widget>
- <packing>
- <property name="TopAttach">2</property>
- <property name="BottomAttach">3</property>
- <property name="LeftAttach">1</property>
- <property name="RightAttach">2</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Entry" id="entrySuffix">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="IsEditable">True</property>
- <property name="InvisibleChar">●</property>
- </widget>
- <packing>
- <property name="TopAttach">3</property>
- <property name="BottomAttach">4</property>
- <property name="LeftAttach">1</property>
- <property name="RightAttach">2</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label1">
- <property name="MemberName" />
- <property name="Xalign">1</property>
- <property name="LabelProp" translatable="yes">Prefix:</property>
- </widget>
- <packing>
- <property name="TopAttach">1</property>
- <property name="BottomAttach">2</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label2">
- <property name="MemberName" />
- <property name="Xalign">1</property>
- <property name="LabelProp" translatable="yes">Style:</property>
- </widget>
- <packing>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label3">
- <property name="MemberName" />
- <property name="Xalign">1</property>
- <property name="LabelProp" translatable="yes">Suffix:</property>
- </widget>
- <packing>
- <property name="TopAttach">3</property>
- <property name="BottomAttach">4</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label8">
- <property name="MemberName" />
- <property name="Xalign">1</property>
- <property name="LabelProp" translatable="yes">Optional Prefixes:</property>
- </widget>
- <packing>
- <property name="TopAttach">2</property>
- <property name="BottomAttach">3</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.ComboBox" id="styleComboBox">
- <property name="MemberName" />
- <property name="IsTextCombo">True</property>
- <property name="Items" translatable="yes" />
- </widget>
- <packing>
- <property name="LeftAttach">1</property>
- <property name="RightAttach">2</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.VBox" id="vbox1">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.CheckButton" id="checkbuttonStatic">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="Label" translatable="yes">_Static member and types</property>
- <property name="Active">True</property>
- <property name="DrawIndicator">True</property>
- <property name="HasLabel">True</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.CheckButton" id="checkbuttonInstanceMembers">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="Label" translatable="yes">_Instance members and locals</property>
- <property name="Active">True</property>
- <property name="DrawIndicator">True</property>
- <property name="HasLabel">True</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <placeholder />
- </child>
- </widget>
- <packing>
- <property name="TopAttach">4</property>
- <property name="BottomAttach">5</property>
- <property name="LeftAttach">1</property>
- <property name="RightAttach">2</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">True</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.VBox" id="vbox5">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.Label" id="label9">
- <property name="MemberName" />
- <property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes">Static/Non Static</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <placeholder />
- </child>
- <child>
- <placeholder />
- </child>
- </widget>
- <packing>
- <property name="TopAttach">4</property>
- <property name="BottomAttach">5</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">True</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="TopAttach">2</property>
- <property name="BottomAttach">4</property>
- <property name="LeftAttach">1</property>
- <property name="RightAttach">2</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">0</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">False</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">False</property>
- <property name="Padding">6</property>
- </packing>
- </child>
- </widget>
- </child>
- <child internal-child="ActionArea">
- <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
- <property name="MemberName" />
- <property name="Spacing">10</property>
- <property name="BorderWidth">5</property>
- <property name="Size">2</property>
- <property name="LayoutStyle">End</property>
- <child>
- <widget class="Gtk.Button" id="buttonCancel">
- <property name="MemberName" />
- <property name="CanDefault">True</property>
- <property name="CanFocus">True</property>
- <property name="UseStock">True</property>
- <property name="Type">StockItem</property>
- <property name="StockId">gtk-cancel</property>
- <property name="ResponseId">-6</property>
- <property name="label">gtk-cancel</property>
- </widget>
- <packing>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Button" id="buttonOk">
- <property name="MemberName" />
- <property name="CanDefault">True</property>
- <property name="CanFocus">True</property>
- <property name="UseStock">True</property>
- <property name="Type">StockItem</property>
- <property name="StockId">gtk-ok</property>
- <property name="ResponseId">-5</property>
- <property name="label">gtk-ok</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
<widget class="Gtk.Dialog" id="MonoDevelop.CSharp.ClassOutline.OutlineSortingPreferencesDialog" design-size="424 367">
<property name="MemberName" />
<property name="Visible">False</property>
diff --git a/main/src/addins/CSharpBinding/packages.config b/main/src/addins/CSharpBinding/packages.config
new file mode 100644
index 0000000000..8c56e0c54c
--- /dev/null
+++ b/main/src/addins/CSharpBinding/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="System.ValueTuple" version="4.3.0" targetFramework="net461" />
+</packages> \ No newline at end of file
diff --git a/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.csproj b/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.csproj
index c42bb4bead..47b98fa570 100644
--- a/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.csproj
+++ b/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>ChangeLogAddIn</AssemblyName>
<RootNamespace>ChangeLogAddIn</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj
index e9a5783a2e..bad7702a66 100644
--- a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj
+++ b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.Deployment.Linux</AssemblyName>
<RootNamespace>MonoDevelop.Deployment.Linux</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj
index 9907c60cd4..9c35776d70 100644
--- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj
+++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.Deployment</AssemblyName>
<RootNamespace>MonoDevelop.Deployment</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/GnomePlatform/GnomePlatform.csproj b/main/src/addins/GnomePlatform/GnomePlatform.csproj
index d5ca3ea229..68f543ad30 100644
--- a/main/src/addins/GnomePlatform/GnomePlatform.csproj
+++ b/main/src/addins/GnomePlatform/GnomePlatform.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>GnomePlatform</AssemblyName>
<RootNamespace>GnomePlatform</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/ILAsmBinding/ILAsmBinding.csproj b/main/src/addins/ILAsmBinding/ILAsmBinding.csproj
index 7eb5d92e8c..38f3dcebf6 100644
--- a/main/src/addins/ILAsmBinding/ILAsmBinding.csproj
+++ b/main/src/addins/ILAsmBinding/ILAsmBinding.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,13 +10,13 @@
<OutputType>Library</OutputType>
<AssemblyName>ILAsmBinding</AssemblyName>
<RootNamespace>ILAsmBinding</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\ILAsmBinding</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Execution>
@@ -28,7 +29,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\ILAsmBinding</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Execution>
diff --git a/main/src/addins/MacPlatform/AssemblyInfo.cs b/main/src/addins/MacPlatform/AssemblyInfo.cs
index 5ee6db3997..1c4dc02bf1 100644
--- a/main/src/addins/MacPlatform/AssemblyInfo.cs
+++ b/main/src/addins/MacPlatform/AssemblyInfo.cs
@@ -8,5 +8,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyDescription ("Mac Platform Support for MonoDevelop")]
[assembly: AssemblyVersion ("2.6")]
[assembly: AssemblyCopyright ("MIT X11")]
-
-[assembly: InternalsVisibleTo ("MacPlatform.Tests")]
diff --git a/main/src/addins/MacPlatform/MacPlatform.csproj b/main/src/addins/MacPlatform/MacPlatform.csproj
index 465136e6c0..8e0792776b 100644
--- a/main/src/addins/MacPlatform/MacPlatform.csproj
+++ b/main/src/addins/MacPlatform/MacPlatform.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MacPlatform</AssemblyName>
<RootNamespace>MacPlatform</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -232,6 +233,9 @@
<Folder Include="MainToolbar\" />
</ItemGroup>
<ItemGroup>
+ <InternalsVisibleTo Include="MacPlatform.Tests" />
+ </ItemGroup>
+ <ItemGroup>
<LibXammac Include="..\..\..\external\libxammac.dylib" />
</ItemGroup>
<Target Name="AfterBuild">
diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.csproj b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.csproj
index d1b368e757..4836c79078 100644
--- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.csproj
+++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.AssemblyBrowser</AssemblyName>
<RootNamespace>MonoDevelop.AssemblyBrowser</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -23,7 +24,6 @@
<Execution>
<Execution clr-version="Net_2_0" />
</Execution>
- <AssemblyOriginatorKeyFile>.</AssemblyOriginatorKeyFile>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NoWarn>1591;1573</NoWarn>
<DocumentationFile>..\..\..\build\AddIns\DisplayBindings\AssemblyBrowser\MonoDevelop.AssemblyBrowser.xml</DocumentationFile>
diff --git a/main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.csproj b/main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.csproj
index 0dbabd045e..81476ab810 100644
--- a/main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.csproj
+++ b/main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.Autotools</AssemblyName>
<RootNamespace>MonoDevelop.Autotools</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics.csproj b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics.csproj
index 51d63d046e..b81e4fa38d 100644
--- a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics.csproj
+++ b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
diff --git a/main/src/addins/MonoDevelop.ConnectedServices/MonoDevelop.ConnectedServices.csproj b/main/src/addins/MonoDevelop.ConnectedServices/MonoDevelop.ConnectedServices.csproj
index 95ba020707..a1b3d3ecce 100644
--- a/main/src/addins/MonoDevelop.ConnectedServices/MonoDevelop.ConnectedServices.csproj
+++ b/main/src/addins/MonoDevelop.ConnectedServices/MonoDevelop.ConnectedServices.csproj
@@ -1,5 +1,6 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.ConnectedServices</RootNamespace>
<AssemblyName>MonoDevelop.ConnectedServices</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -38,8 +39,8 @@
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="Mono.Cairo" />
- <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <Reference Include="System.Collections.Immutable">
+ <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <Reference Include="System.Collections.Immutable">
<HintPath>..\..\..\build\bin\System.Collections.Immutable.dll</HintPath>
<Private>False</Private>
</Reference>
@@ -79,12 +80,8 @@
<HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
<Private>False</Private>
</Reference>
- <Reference Include="RefactoringEssentials">
- <HintPath>..\..\..\..\build\bin\RefactoringEssentials.dll</HintPath>
- <Private>False</Private>
- </Reference>
<Reference Include="Newtonsoft.Json">
- <HintPath>..\..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ <HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
@@ -171,12 +168,7 @@
<LogicalName>MonoDevelop.ConnectedServices.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
- <ItemGroup>
- <Folder Include="Gui.SolutionPad\" />
- <Folder Include="DebugService\" />
- <Folder Include="CommandHandlers\" />
- <Folder Include="Gui.ServicesTab\" />
- </ItemGroup>
+ <ItemGroup />
<ItemGroup>
<None Include="ReadMe.md" />
<None Include="packages.config" />
diff --git a/main/src/addins/MonoDevelop.ConnectedServices/packages.config b/main/src/addins/MonoDevelop.ConnectedServices/packages.config
index 583acbdf9c..e1fae9c6a8 100644
--- a/main/src/addins/MonoDevelop.ConnectedServices/packages.config
+++ b/main/src/addins/MonoDevelop.ConnectedServices/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Debugger.Gdb/MonoDevelop.Debugger.Gdb.csproj b/main/src/addins/MonoDevelop.Debugger.Gdb/MonoDevelop.Debugger.Gdb.csproj
index 086d9ab809..e150dfee90 100644
--- a/main/src/addins/MonoDevelop.Debugger.Gdb/MonoDevelop.Debugger.Gdb.csproj
+++ b/main/src/addins/MonoDevelop.Debugger.Gdb/MonoDevelop.Debugger.Gdb.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.Debugger.Gdb</AssemblyName>
<RootNamespace>MonoDevelop.Debugger</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/MonoDevelop.Debugger.Soft.AspNet.csproj b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/MonoDevelop.Debugger.Soft.AspNet.csproj
index a5a7765718..72fd8e0eaa 100644
--- a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/MonoDevelop.Debugger.Soft.AspNet.csproj
+++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.AspNet/MonoDevelop.Debugger.Soft.AspNet.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.Debugger.Soft.AspNet</RootNamespace>
<AssemblyName>MonoDevelop.Debugger.Soft.AspNet</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.Moonlight/MonoDevelop.Debugger.Soft.Moonlight.csproj b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.Moonlight/MonoDevelop.Debugger.Soft.Moonlight.csproj
index d0b1b861ec..3829226f9b 100644
--- a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.Moonlight/MonoDevelop.Debugger.Soft.Moonlight.csproj
+++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.Moonlight/MonoDevelop.Debugger.Soft.Moonlight.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.csproj b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.csproj
index 36440aa08f..fbe189b2e5 100644
--- a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.csproj
+++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.Debugger.Soft</RootNamespace>
<AssemblyName>MonoDevelop.Debugger.Soft</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol.csproj b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol.csproj
index dfbbae1e14..3484cfba97 100644
--- a/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol.csproj
+++ b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.Debugger.VsCodeDebugProtocol</RootNamespace>
<AssemblyName>MonoDevelop.Debugger.VsCodeDebugProtocol</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -76,4 +77,4 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.csproj b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.csproj
index b4dbb42969..a337914663 100644
--- a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.csproj
+++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32.csproj
@@ -1,5 +1,6 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<RootNamespace>MonoDevelop.Debugger.Win32</RootNamespace>
<AssemblyName>MonoDevelop.Debugger.Win32</AssemblyName>
<FileAlignment>512</FileAlignment>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
@@ -130,4 +131,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj
index af25d9ef17..a1f9144212 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>MonoDevelop.Debugger.Tests</AssemblyName>
<TestRunnerCommand>..\..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj
index 0c0a67bcf8..5379281ee3 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.Debugger</AssemblyName>
<RootNamespace>MonoDevelop.Debugger</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/BreakpointPropertiesDialog.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/BreakpointPropertiesDialog.cs
index 735629c75f..e06d0e32df 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/BreakpointPropertiesDialog.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/BreakpointPropertiesDialog.cs
@@ -221,6 +221,9 @@ namespace MonoDevelop.Debugger
case BreakpointType.Catchpoint:
stopOnException.Active = true;
entryExceptionType.SetFocus ();
+ entryExceptionType.Text = "System.Exception";
+ entryExceptionType.SelectionStart = 0;
+ entryExceptionType.SelectionLength = entryExceptionType.TextLength;
break;
}
}
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.csproj b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.csproj
index 26d3751087..0930b08dc9 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.csproj
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.DesignerSupport</AssemblyName>
<RootNamespace>MonoDevelop.DesignerSupport</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/BindingService.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/BindingService.cs
index 445685d6b9..e956cd6926 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/BindingService.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/BindingService.cs
@@ -194,6 +194,15 @@ namespace MonoDevelop.DesignerSupport
return new IMethodSymbol[0];
return GetCompatibleMethodsInClass (cls, eveMeth);
}
+
+ static IEnumerable<INamedTypeSymbol> GetBaseTypes (ITypeSymbol type)
+ {
+ var current = type.BaseType;
+ while (current != null) {
+ yield return current;
+ current = current.BaseType;
+ }
+ }
//TODO: check accessibility
public static IEnumerable<IMethodSymbol> GetCompatibleMethodsInClass (ITypeSymbol cls, IMethodSymbol matchMeth)
@@ -202,7 +211,7 @@ namespace MonoDevelop.DesignerSupport
List<ITypeSymbol>[] baseTypes = new List<ITypeSymbol>[matchMeth.Parameters.Length];
for (int i = 0; i < matchMeth.Parameters.Length; i++) {
pars[i] = matchMeth.Parameters[i].Type;
- baseTypes[i] = new List<ITypeSymbol> (pars[i].GetBaseTypes ());
+ baseTypes[i] = new List<ITypeSymbol> ( (GetBaseTypes (pars[i])));
}
var matchMethType = matchMeth.ReturnType;
diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj
index 17067a9c3a..ccaa624974 100644
--- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj
+++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.DocFood</RootNamespace>
<AssemblyName>MonoDevelop.DocFood</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs
index 00fa6eca7f..77f36c6617 100644
--- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs
+++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs
@@ -34,6 +34,7 @@ using Microsoft.CodeAnalysis;
using ICSharpCode.NRefactory6.CSharp;
using MonoDevelop.Ide.Editor;
using MonoDevelop.Ide.TypeSystem;
+using System.Collections.Immutable;
namespace MonoDevelop.DocFood
{
@@ -260,11 +261,11 @@ namespace MonoDevelop.DocFood
}
break;
case "paramCount":
- var parameters = member.GetParameters ();
+ var parameters = GetParameters (member);
result |= Int32.Parse (val) == parameters.Length;
break;
case "parameter":
- parameters = member.GetParameters ();
+ parameters = GetParameters (member);
string[] par = val.Split(':');
int idx = Int32.Parse (par[0]);
string name = par[1];
@@ -330,7 +331,7 @@ namespace MonoDevelop.DocFood
if (member is IPropertySymbol || member is IMethodSymbol) {
this.currentType = "parameter";
- foreach (var p in member.GetParameters ()) {
+ foreach (var p in GetParameters (member)) {
curName = p.Name;
this.member = member;
SplitWords (p, p.Name);
@@ -439,9 +440,11 @@ namespace MonoDevelop.DocFood
tags ["ReturnType"] = returnType != null ? "<see cref=\"" + returnType.GetDocumentationCommentId () + "\"/>" : "";
tags ["Member"] = "<see cref=\"" + member.Name + "\"/>";
-
- if (member is IPropertySymbol || member is IMethodSymbol) {
- var parameters = member.GetParameters ();
+
+ var property = member as IPropertySymbol;
+ var method = member as IMethodSymbol;
+ if (property != null || method != null) {
+ var parameters = property != null? property.Parameters : method.Parameters;
var parameterNames = new List<string> (from p in parameters select p.Name);
tags ["ParameterSentence"] = string.Join (" ", parameterNames.ToArray ());
StringBuilder paramList = new StringBuilder ();
@@ -461,7 +464,6 @@ namespace MonoDevelop.DocFood
tags ["Parameter" + i + ".Name"] = "<c>" + parameters [i].Name + "</c>";
}
- var property = member as IPropertySymbol;
if (property != null) {
var hasPublicGetter = property.GetMethod != null && property.GetMethod.DeclaredAccessibility != Accessibility.Private;
var hasPublicSetter = property.SetMethod != null && property.SetMethod.DeclaredAccessibility != Accessibility.Private;
@@ -976,11 +978,17 @@ namespace MonoDevelop.DocFood
return result.ToString ();
}
+ static ImmutableArray<IParameterSymbol> GetParameters (ISymbol symbol)
+ {
+ return (symbol as IPropertySymbol)?.Parameters
+ ?? (symbol as IMethodSymbol)?.Parameters
+ ?? ImmutableArray<IParameterSymbol>.Empty;
+ }
public void Set (string name, string parameterName, string doc)
{
if (name.StartsWith ("param", StringComparison.Ordinal) && name.Length > "param".Length) {
- var parameters = member.GetParameters ();
+ var parameters = GetParameters (member);
var idx = int.Parse (name.Substring ("param".Length));
parameterName = idx < parameters.Length ? parameters [idx].Name : "unknown";
name = "param";
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests.csproj b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests.csproj
index 900e4c85dd..b96ea93eeb 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests.csproj
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.DotNetCore.Tests</RootNamespace>
<AssemblyName>MonoDevelop.DotNetCore.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TestRunnerCommand>..\..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
</PropertyGroup>
@@ -72,4 +73,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.csproj b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.csproj
index 54b542b0da..daa4a8dc61 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.csproj
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.DotNetCore</RootNamespace>
<AssemblyName>MonoDevelop.DotNetCore</AssemblyName>
- <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<MonoLauncher Condition=" '$(VisualStudioVersion)' == '' ">mono </MonoLauncher>
<NuGetUrl>https://dotnet.myget.org/F/templating/api/v2/package/</NuGetUrl>
<TemplatesVersion>1.0.0-beta1-20170223-126</TemplatesVersion>
@@ -200,6 +201,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
+ <InternalsVisibleTo Include="DotNetCore.Debugger" />
+ <InternalsVisibleTo Include="MonoDevelop.DotNetCore.Tests" />
+ </ItemGroup>
+ <ItemGroup>
<None Include="packages.config" />
<None Include="pull-package.cs" />
</ItemGroup>
@@ -236,4 +241,4 @@
</ItemGroup>
<Exec Command="$(MonoLauncher)$(MSBuildProjectDirectory)\pull-package.exe %(NuGetPackage.Url) %(NuGetPackage.OutputPackage)" Condition="!Exists('%(NuGetPackage.OutputPackage)')" WorkingDirectory="$(MSBuildProjectDirectory)" />
</Target>
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs
index 772da93343..6040a85958 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs
@@ -100,7 +100,10 @@ namespace MonoDevelop.DotNetCore
protected override void OnReadProjectHeader (ProgressMonitor monitor, MSBuildProject msproject)
{
- dotNetCoreMSBuildProject.ReadProjectHeader (msproject);
+ // Do not read the project header when re-evaluating to prevent the
+ // ToolsVersion that was initially read from the project being changed.
+ if (!Project.IsReevaluating)
+ dotNetCoreMSBuildProject.ReadProjectHeader (msproject);
base.OnReadProjectHeader (monitor, msproject);
}
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreRunConfiguration.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreRunConfiguration.cs
index cc5e05bd78..2c199c5523 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreRunConfiguration.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreRunConfiguration.cs
@@ -43,6 +43,7 @@ namespace MonoDevelop.DotNetCore
protected override void Initialize (Project project)
{
base.Initialize (project);
+ ExternalConsole = true;
if (project.GetFlavor<DotNetCoreProjectExtension> ()?.IsWeb ?? false && string.IsNullOrEmpty (ApplicationURL)) {
var tcpListner = new TcpListener (IPAddress.Loopback, 0);
tcpListner.Start ();
diff --git a/main/src/addins/MonoDevelop.DotNetCore/Properties/AssemblyInfo.cs b/main/src/addins/MonoDevelop.DotNetCore/Properties/AssemblyInfo.cs
index 147c0f6c7b..23ad5b8db7 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/Properties/AssemblyInfo.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/Properties/AssemblyInfo.cs
@@ -43,6 +43,3 @@ using System.Runtime.CompilerServices;
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.0.0")]
-
-[assembly: InternalsVisibleTo ("MonoDevelop.DotNetCore.Tests")]
-[assembly: InternalsVisibleTo ("DotNetCore.Debugger")]
diff --git a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj
index f28071c231..59f17bf2a0 100644
--- a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj
+++ b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,7 +11,7 @@
<AssemblyName>MonoDevelop.Gettext</AssemblyName>
<CodePage>65001</CodePage>
<RootNamespace>MonoDevelop.Gettext</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -262,8 +263,8 @@
<EmbeddedResource Include="templates\Makefile.template">
<LogicalName>Makefile.template</LogicalName>
</EmbeddedResource>
- <EmbeddedResource Include="templates\Makefile.am.template">
- <LogicalName>Makefile.am.template</LogicalName>
+ <EmbeddedResource Include="templates\Makefile_am.template">
+ <LogicalName>Makefile.am_template</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="icons\prefs-language-16.png">
<LogicalName>prefs-language-16.png</LogicalName>
diff --git a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/MakefileHandler.cs b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/MakefileHandler.cs
index 72ddc7c24e..e4cf95da77 100644
--- a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/MakefileHandler.cs
+++ b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/MakefileHandler.cs
@@ -74,7 +74,7 @@ namespace MonoDevelop.Gettext
string mt;
if (ctx.MakefileType == MakefileType.AutotoolsMakefile)
- mt = "Makefile.am.template";
+ mt = "Makefile_am.template";
else
mt = "Makefile.template";
diff --git a/main/src/addins/MonoDevelop.Gettext/templates/Makefile.am.template b/main/src/addins/MonoDevelop.Gettext/templates/Makefile_am.template
index 3962478646..68e4ee49f0 100644
--- a/main/src/addins/MonoDevelop.Gettext/templates/Makefile.am.template
+++ b/main/src/addins/MonoDevelop.Gettext/templates/Makefile_am.template
@@ -26,7 +26,7 @@ uninstall:
$(GMO_FILES): $(BUILD_DIR)/%.gmo: %.po
mkdir -p $(BUILD_DIR)
msgfmt '$<' -o '$@'
-
+
$(MO_FILES): $(INSTALL_DIR)/%/LC_MESSAGES/$(PACKAGE).mo : $(BUILD_DIR)/%.gmo
mkdir -p $(dir $@)
@INSTALL_DATA@ '$<' '$@'
diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj
index 6bb77ba3cf..0fabe1791d 100644
--- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj
+++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.GtkCore</AssemblyName>
<RootNamespace>MonoDevelop.GtkCore</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.GtkCore/libstetic/libstetic.csproj b/main/src/addins/MonoDevelop.GtkCore/libstetic/libstetic.csproj
index 43a845d8f2..f740c0ff65 100644
--- a/main/src/addins/MonoDevelop.GtkCore/libstetic/libstetic.csproj
+++ b/main/src/addins/MonoDevelop.GtkCore/libstetic/libstetic.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -458,4 +459,4 @@
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/libsteticui.csproj b/main/src/addins/MonoDevelop.GtkCore/libsteticui/libsteticui.csproj
index 07386f8269..d125a29dab 100644
--- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/libsteticui.csproj
+++ b/main/src/addins/MonoDevelop.GtkCore/libsteticui/libsteticui.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/AssemblyInfo.cs b/main/src/addins/MonoDevelop.GtkCore2/AssemblyInfo.cs
deleted file mode 100644
index d123b0eb9e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/AssemblyInfo.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-// Autogenerated from MonoDevelop.GtkCore.addin.xml
-
-using System.Reflection;
-
-[assembly: AssemblyProduct ("MonoDevelop")]
-[assembly: AssemblyTitle ("GTK# Visual Designer")]
-[assembly: AssemblyDescription ("Provides support for visual design of GTK# windows, dialogs and widgets.")]
-[assembly: AssemblyVersion ("2.6")]
-[assembly: AssemblyCopyright ("X11")]
diff --git a/main/src/addins/MonoDevelop.GtkCore2/Makefile.am b/main/src/addins/MonoDevelop.GtkCore2/Makefile.am
deleted file mode 100644
index bf3218efd0..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/Makefile.am
+++ /dev/null
@@ -1,3 +0,0 @@
-SUBDIRS = libstetic libsteticui
-
-include $(top_srcdir)/xbuild.include
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Commands/GtkCommands.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Commands/GtkCommands.cs
deleted file mode 100644
index e8772a0680..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Commands/GtkCommands.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// GtkCommands.cs
-//
-// Author:
-// Lluis Sanchez Gual
-// Krzysztof Marecki
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2010 Krzysztof Marecki
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace MonoDevelop.GtkCore
-{
- public enum GtkCommands
- {
- AddNewDialog,
- AddNewWindow,
- AddNewWidget,
- AddNewActionGroup,
- ImportGladeFile,
- EditIcons,
- GtkSettings,
- GenerateCode,
- ReloadDesigner
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/BindDesignDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/BindDesignDialog.cs
deleted file mode 100644
index 04bd159640..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/BindDesignDialog.cs
+++ /dev/null
@@ -1,186 +0,0 @@
-//
-// BindDesignDialog.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-
-using Glade;
-using Gtk;
-using MonoDevelop.Core;
-using MonoDevelop.Components;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.Dialogs
-{
- class BindDesignDialog: IDisposable
- {
- [Glade.Widget ("BindDesignDialog")] protected Gtk.Dialog dialog;
- [Glade.Widget] protected Gtk.Label labelMessage;
- [Glade.Widget] protected Gtk.ComboBox comboClasses;
- [Glade.Widget] protected Gtk.Entry entryClassName;
- [Glade.Widget] protected Gtk.Entry entryNamespace;
- [Glade.Widget] protected Gtk.RadioButton radioSelect;
- [Glade.Widget] protected Gtk.RadioButton radioCreate;
- [Glade.Widget] protected Gtk.Table tableNewClass;
- [Glade.Widget] protected Gtk.Button okButton;
- [Glade.Widget] protected Gtk.EventBox fileEntryBox;
-
- FolderEntry fileEntry;
-
- ListStore store;
- static string lastNamespace = "";
-
- public BindDesignDialog (string id, ArrayList validClasses, string baseFolder)
- {
- XML glade = new XML (null, "gui.glade", "BindDesignDialog", null);
- glade.Autoconnect (this);
- labelMessage.Text = GettextCatalog.GetString ("The widget design {0} is not currently bound to a class.", id);
-
- fileEntry = new FolderEntry ();
- fileEntryBox.Add (fileEntry);
- fileEntry.ShowAll ();
-
- if (validClasses.Count > 0) {
-
- store = new ListStore (typeof (string));
- foreach (string cname in validClasses)
- store.AppendValues (cname);
- comboClasses.Model = store;
- CellRendererText cr = new CellRendererText ();
- comboClasses.PackStart (cr, true);
- comboClasses.AddAttribute (cr, "text", 0);
- comboClasses.Active = 0;
-
- } else {
- radioSelect.Sensitive = false;
- radioCreate.Active = true;
- }
-
- fileEntry.Path = baseFolder;
-
- // Initialize the class name using the widget name
- int i = id.IndexOf ('.');
- if (i != -1) {
- entryClassName.Text = id.Substring (i+1);
- entryNamespace.Text = id.Substring (0,i);
- } else {
- entryClassName.Text = id;
- entryNamespace.Text = lastNamespace;
- }
-
- dialog.Response += new Gtk.ResponseHandler (OnResponse);
- UpdateStatus ();
- }
-
- void OnResponse (object ob, Gtk.ResponseArgs args)
- {
- dialog.Response -= new Gtk.ResponseHandler (OnResponse);
- if (args.ResponseId == ResponseType.Ok && radioCreate.Active)
- lastNamespace = Namespace;
- }
-
- public bool Run ()
- {
- dialog.TransientFor = IdeApp.Workbench.RootWindow;
- return dialog.Run () == (int) ResponseType.Ok;
- }
-
- public bool CreateNew {
- get { return radioCreate.Active; }
- }
-
- public string ClassName {
- get {
- if (radioCreate.Active) {
- return entryClassName.Text;
- } else {
- Gtk.TreeIter it;
- if (!comboClasses.GetActiveIter (out it))
- return "";
- string s = (string) store.GetValue (it, 0);
- int i = s.IndexOf ('.');
- if (i != -1)
- return s.Substring (i+1);
- else
- return s;
- }
- }
- }
-
- public string Namespace {
- get {
- if (radioCreate.Active) {
- return entryNamespace.Text;
- } else {
- Gtk.TreeIter it;
- if (!comboClasses.GetActiveIter (out it))
- return "";
- string s = (string) store.GetValue (it, 0);
- int i = s.IndexOf ('.');
- if (i != -1)
- return s.Substring (0, i);
- else
- return "";
- }
- }
- }
-
- public string Folder {
- get { return fileEntry.Path; }
- }
-
- protected void OnSelectToggled (object ob, EventArgs args)
- {
- UpdateStatus ();
- }
-
- protected void OnEntryChanged (object ob, EventArgs a)
- {
- UpdateStatus ();
- }
-
- void UpdateStatus ()
- {
- if (radioSelect.Active) {
- tableNewClass.Sensitive = false;
- comboClasses.Sensitive = true;
- okButton.Sensitive = true;
- } else {
- tableNewClass.Sensitive = true;
- comboClasses.Sensitive = false;
- okButton.Sensitive = ClassName != "" && Folder != "";
- }
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/ConfirmWindowDeleteDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/ConfirmWindowDeleteDialog.cs
deleted file mode 100644
index b0c8031ba5..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/ConfirmWindowDeleteDialog.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// ConfirmWindowDeleteDialog.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using Glade;
-using Gtk;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.Dialogs
-{
- class ConfirmWindowDeleteDialog: IDisposable
- {
- [Glade.Widget ("ConfirmWindowDeleteDialog")] protected Gtk.Dialog dialog;
- [Glade.Widget] protected Gtk.Label label;
- [Glade.Widget] protected Gtk.CheckButton checkbox;
-
- public ConfirmWindowDeleteDialog (string windowName, string fileName, Stetic.ProjectItemInfo obj)
- {
- XML glade = new XML (null, "gui.glade", "ConfirmWindowDeleteDialog", null);
- glade.Autoconnect (this);
-
- if (obj is Stetic.WidgetInfo && ((Stetic.WidgetInfo)obj).IsWindow) {
- label.Text = GettextCatalog.GetString ("Are you sure you want to delete the window '{0}'?", windowName);
- } else if (obj is Stetic.WidgetInfo) {
- label.Text = GettextCatalog.GetString ("Are you sure you want to delete the widget '{0}'?", windowName);
- } else if (obj is Stetic.ActionGroupInfo) {
- label.Text = GettextCatalog.GetString ("Are you sure you want to delete the action group '{0}'?", windowName);
- } else
- label.Text = GettextCatalog.GetString ("Are you sure you want to delete '{0}'?", windowName);
-
- if (fileName != null) {
- checkbox.Label = string.Format (checkbox.Label, fileName);
- checkbox.Active = true;
- } else
- checkbox.Hide ();
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
-
- public int Run ()
- {
- dialog.TransientFor = IdeApp.Workbench.RootWindow;
- return dialog.Run ();
- }
-
- public bool DeleteFile {
- get { return checkbox.Active; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/GtkDesignerOptionsPanelWidget.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/GtkDesignerOptionsPanelWidget.cs
deleted file mode 100644
index cce24542b0..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/GtkDesignerOptionsPanelWidget.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// GtkDesignerOptionPanelWidget.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using MonoDevelop.GtkCore.GuiBuilder;
-using Gtk;
-using MonoDevelop.Ide.Gui.Dialogs;
-
-namespace MonoDevelop.GtkCore.Dialogs
-{
- public class GtkDesignerOptionPanel: OptionsPanel
- {
- GtkDesignerOptionsPanelWidget widget;
-
- public override Widget CreatePanelWidget ()
- {
- widget = new GtkDesignerOptionsPanelWidget ();
- widget.AutoSwitchLayout = GuiBuilderService.AutoSwitchGuiLayout;
- return widget;
- }
-
- public override void ApplyChanges ()
- {
- GuiBuilderService.AutoSwitchGuiLayout = widget.AutoSwitchLayout;
- }
- }
-
- [System.ComponentModel.ToolboxItem(true)]
- public partial class GtkDesignerOptionsPanelWidget : Gtk.Bin
- {
- public GtkDesignerOptionsPanelWidget()
- {
- this.Build();
- }
-
- public bool AutoSwitchLayout {
- get { return checkSwitchLayout.Active; }
- set { checkSwitchLayout.Active = value; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs
deleted file mode 100644
index 133a6a4a22..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-
-using System;
-using MonoDevelop.Ide.Templates;
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using Gtk;
-
-namespace MonoDevelop.GtkCore.Dialogs
-{
- class GtkFeatureWidget : Gtk.VBox
- {
- ComboBox versionCombo;
-
- public GtkFeatureWidget (DotNetProject project)
- {
- Spacing = 6;
-
- versionCombo = Gtk.ComboBox.NewText ();
- ReferenceManager refmgr = new ReferenceManager (project);
- foreach (string v in refmgr.SupportedGtkVersions)
- versionCombo.AppendText (v);
- versionCombo.Active = 0;
- refmgr.Dispose ();
-
- // GTK# version selector
- HBox box = new HBox (false, 6);
- Gtk.Label vlab = new Label (GettextCatalog.GetString ("Target GTK# version:"));
- box.PackStart (vlab, false, false, 0);
- box.PackStart (versionCombo, false, false, 0);
- box.PackStart (new Label (GettextCatalog.GetString ("(or upper)")), false, false, 0);
- PackStart (box, false, false, 0);
-
- ShowAll ();
- }
-
- public string SelectedVersion {
- get { return versionCombo.ActiveText; }
- }
- }
-
- class GtkProjectFeature: ISolutionItemFeature
- {
- public string Title {
- get { return GettextCatalog.GetString ("GTK# Support"); }
- }
-
- public string Description {
- get { return GettextCatalog.GetString ("Enables support for GTK# in the project. Allows the visual design of GTK# windows, and the creation of a GTK# widget library."); }
- }
-
- public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionItem entry)
- {
- if (!(entry is DotNetProject) || !GtkDesignInfo.SupportsRefactoring (entry as DotNetProject))
- return FeatureSupportLevel.NotSupported;
- else if (GtkDesignInfo.SupportsDesigner ((Project)entry))
- return FeatureSupportLevel.Enabled;
- else if (entry is DotNetAssemblyProject)
- return FeatureSupportLevel.SupportedByDefault;
- else
- return FeatureSupportLevel.Supported;
- }
-
- public Widget CreateFeatureEditor (SolutionFolder parentCombine, SolutionItem entry)
- {
- return new GtkFeatureWidget ((DotNetProject) entry);
- }
-
- public void ApplyFeature (SolutionFolder parentCombine, SolutionItem entry, Widget editor)
- {
- GtkFeatureWidget fw = (GtkFeatureWidget) editor;
- ReferenceManager refmgr = new ReferenceManager ((DotNetProject) entry);
- refmgr.GtkPackageVersion = fw.SelectedVersion;
- refmgr.Dispose ();
- }
-
- public string Validate (SolutionFolder parentCombine, SolutionItem entry, Gtk.Widget editor)
- {
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/ProjectConversionDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/ProjectConversionDialog.cs
deleted file mode 100644
index c7b091c6aa..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/ProjectConversionDialog.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using Gtk;
-
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.GtkCore.Dialogs
-{
- public partial class ProjectConversionDialog : Gtk.Dialog
- {
- public ProjectConversionDialog (IntPtr raw)
- : base (raw)
- {
- }
-
- public string GuiFolderName { get; private set; }
-
- public bool MakeBackup { get; private set; }
-
-
- public ProjectConversionDialog (Project project, string guiFolderName)
- {
- this.Build ();
-
- entryFolder.Text = guiFolderName;
- Title = project.Name;
- entryFolder.Position = -1;
-
- buttonConvert.Clicked += HandleButtonConvertClicked;
- }
-
- void HandleButtonConvertClicked (object sender, EventArgs e)
- {
- GuiFolderName = entryFolder.Text;
- MakeBackup = checkBackup.Active;
-
- Respond (ResponseType.Yes);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/SelectRenamedClassDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/SelectRenamedClassDialog.cs
deleted file mode 100644
index 323a98ba19..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/SelectRenamedClassDialog.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// SelectRenamedClassDialog.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-using Gtk;
-using Gdk;
-using Glade;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.Dialogs
-{
- public class SelectRenamedClassDialog: IDisposable
- {
- [Glade.Widget ("SelectRenamedClassDialog")] protected Gtk.Dialog dialog;
- [Glade.Widget] protected Gtk.TreeView treeClasses;
- ListStore store;
-
- public SelectRenamedClassDialog (IEnumerable<IType> classes)
- {
- XML glade = new XML (null, "gui.glade", "SelectRenamedClassDialog", null);
- glade.Autoconnect (this);
-
- store = new ListStore (typeof(Pixbuf), typeof(string));
- treeClasses.Model = store;
-
- TreeViewColumn column = new TreeViewColumn ();
-
- var pr = new CellRendererPixbuf ();
- column.PackStart (pr, false);
- column.AddAttribute (pr, "pixbuf", 0);
-
- CellRendererText crt = new CellRendererText ();
- column.PackStart (crt, true);
- column.AddAttribute (crt, "text", 1);
-
- treeClasses.AppendColumn (column);
-
- foreach (IType cls in classes) {
- Pixbuf pic = ImageService.GetPixbuf (cls.StockIcon);
- store.AppendValues (pic, cls.FullName);
- }
- }
-
- public bool Run ()
- {
- dialog.TransientFor = IdeApp.Workbench.RootWindow;
- return dialog.Run () == (int) ResponseType.Ok;
- }
-
- public string SelectedClass {
- get {
- Gtk.TreeModel foo;
- Gtk.TreeIter iter;
- if (!treeClasses.Selection.GetSelected (out foo, out iter))
- return null;
- return (string) store.GetValue (iter, 1);
- }
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs
deleted file mode 100644
index fae7e91e7b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-//
-// WidgetBuilderOptionPanel.cs
-//
-// Author:
-// Lluis Sanchez Gual
-// Mike Kestner
-//
-// Copyright (C) 2006, 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using Gtk;
-
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Dialogs;
-
-namespace MonoDevelop.GtkCore.Dialogs
-{
- class WidgetBuilderOptionPanel: ItemOptionsPanel
- {
- class WidgetBuilderOptionPanelWidget : Gtk.VBox
- {
- Gtk.CheckButton checkGettext;
- Gtk.Entry entryGettext;
- Gtk.ComboBox comboVersions;
- Gtk.Entry entryFolderName;
- Gtk.CheckButton checkHideFiles;
-
- DotNetProject project;
-
- public WidgetBuilderOptionPanelWidget (Project project) : base (false, 6)
- {
- this.project = project as DotNetProject;
-
- Gtk.HBox box = new Gtk.HBox (false, 3);
- Gtk.Label lbl = new Gtk.Label (GettextCatalog.GetString ("Target Gtk# version:"));
- box.PackStart (lbl, false, false, 0);
- comboVersions = ComboBox.NewText ();
- ReferenceManager refmgr = new ReferenceManager (project as DotNetProject);
- foreach (string v in refmgr.SupportedGtkVersions)
- comboVersions.AppendText (v);
- comboVersions.Active = refmgr.SupportedGtkVersions.IndexOf (refmgr.GtkPackageVersion);
- refmgr.Dispose ();
- box.PackStart (comboVersions, false, false, 0);
- box.ShowAll ();
- PackStart (box, false, false, 0);
-
- HSeparator sep = new HSeparator ();
- sep.Show ();
- PackStart (sep, false, false, 0);
-
- if (!GtkDesignInfo.HasDesignedObjects (project))
- return;
-
- GtkDesignInfo designInfo = GtkDesignInfo.FromProject (project);
- checkGettext = new CheckButton (GettextCatalog.GetString ("Enable gettext support"));
- checkGettext.Active = designInfo.GenerateGettext;
- checkGettext.Show ();
- PackStart (checkGettext, false, false, 0);
- box = new Gtk.HBox (false, 3);
- box.PackStart (new Label (GettextCatalog.GetString ("Gettext class:")), false, false, 0);
- entryGettext = new Gtk.Entry ();
- entryGettext.Text = designInfo.GettextClass;
- entryGettext.Sensitive = checkGettext.Active;
- box.PackStart (entryGettext, false, false, 0);
- box.ShowAll ();
- PackStart (box, false, false, 0);
-
- sep= new HSeparator ();
- sep.Show ();
- PackStart (sep, false, false, 0);
-
- box = new Gtk.HBox (false, 3);
- box.PackStart (new Label (GettextCatalog.GetString ("Stetic folder name :")), false, false, 0);
- entryFolderName = new Gtk.Entry ();
- entryFolderName.Text = designInfo.SteticFolderName;
- entryFolderName.Sensitive = false;
- box.PackStart (entryFolderName, false, false, 0);
- box.ShowAll ();
- PackStart (box, false, false, 0);
-
- checkHideFiles = new CheckButton (GettextCatalog.GetString ("Hide designer files"));
- checkHideFiles.Active = designInfo.HideGtkxFiles;
- checkHideFiles.Show ();
- PackStart (checkHideFiles, false, false, 0);
- }
-
- public void Store ()
- {
- ReferenceManager refmgr = new ReferenceManager (project);
- if (!string.IsNullOrEmpty (comboVersions.ActiveText))
- refmgr.GtkPackageVersion = comboVersions.ActiveText;
- if (GtkDesignInfo.HasDesignedObjects (project)) {
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- info.GenerateGettext = checkGettext.Active;
- info.GettextClass = entryGettext.Text;
- info.GuiBuilderProject.SteticProject.TargetGtkVersion = comboVersions.ActiveText;
- info.SteticFolderName = entryFolderName.Text;
- info.HideGtkxFiles = checkHideFiles.Active;
- info.GuiBuilderProject.Save (false);
- }
- refmgr.Dispose ();
- }
- }
-
- WidgetBuilderOptionPanelWidget widget;
-
- public override Widget CreatePanelWidget()
- {
- return (widget = new WidgetBuilderOptionPanelWidget (ConfiguredProject));
- }
-
- public override bool IsVisible ()
- {
- return GtkDesignInfo.SupportsDesigner (DataObject as Project);
- }
-
- public override void ApplyChanges ()
- {
- widget.Store ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs
deleted file mode 100644
index dd8bb93383..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs
+++ /dev/null
@@ -1,206 +0,0 @@
-//
-// ActionGroupDisplayBinding.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System.Collections;
-using System.CodeDom;
-
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Projects.CodeGeneration;
-using MonoDevelop.GtkCore.Dialogs;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class ActionGroupDisplayBinding : DisplayBinding
- {
- bool excludeThis = false;
-
- public override string Name {
- get { return "Action Group Editor"; }
- }
-
- public override bool CanCreateContentForUri (string fileName)
- {
- Project project = IdeApp.Workspace.GetProjectContainingFile (fileName);
- GtkDesignInfo info = GtkDesignInfo.FromProject ((DotNetProject) project);
-
- if (excludeThis)
- return false;
-
- if (fileName.Contains (info.BuildFileExtension))
- return false;
-
- if (!IdeApp.Workspace.IsOpen)
- return false;
-
- if (GetActionGroup (fileName) == null)
- return false;
-
-
- excludeThis = true;
- var db = DisplayBindingService.GetDefaultBindingForUri (fileName);
- excludeThis = false;
- return db != null;
- }
-
- public override IViewContent CreateContentForUri (string fileName)
- {
- excludeThis = true;
- var db = DisplayBindingService.GetDefaultBindingForUri (fileName);
-
- Project project = IdeApp.Workspace.GetProjectContainingFile (fileName);
- GtkDesignInfo info = GtkDesignInfo.FromProject ((DotNetProject) project);
-
- ActionGroupView view = new ActionGroupView (db.CreateContentForUri (fileName), GetActionGroup (fileName), info.GuiBuilderProject);
- excludeThis = false;
- return view;
- }
- Stetic.ActionGroupInfo GetActionGroup (string file)
- {
- Project project = IdeApp.Workspace.GetProjectContainingFile (file);
- if (!GtkDesignInfo.HasDesignedObjects (project))
- return null;
-
- return GtkDesignInfo.FromProject (project).GuiBuilderProject.GetActionGroupForFile (file);
- }
-
- internal static string BindToClass (Project project, Stetic.ActionGroupInfo group)
- {
- GuiBuilderProject gproject = GtkDesignInfo.FromProject (project).GuiBuilderProject;
- string file = gproject.GetSourceCodeFile (group);
- if (file != null)
- return file;
-
- // Find the classes that could be bound to this design
-
- ArrayList list = new ArrayList ();
- ProjectDom ctx = gproject.GetParserContext ();
- foreach (IType cls in ctx.Types)
- if (IsValidClass (ctx, cls))
- list.Add (cls.FullName);
-
- // Ask what to do
-
- using (BindDesignDialog dialog = new BindDesignDialog (group.Name, list, project.BaseDirectory)) {
- if (!dialog.Run ())
- return null;
-
- if (dialog.CreateNew)
- CreateClass (project, (Stetic.ActionGroupComponent) group.Component, dialog.ClassName, dialog.Namespace, dialog.Folder);
-
- string fullName = dialog.Namespace.Length > 0 ? dialog.Namespace + "." + dialog.ClassName : dialog.ClassName;
- group.Name = fullName;
- }
- return gproject.GetSourceCodeFile (group);
- }
-
- static IType CreateClass (Project project, Stetic.ActionGroupComponent group, string name, string namspace, string folder)
- {
- string fullName = namspace.Length > 0 ? namspace + "." + name : name;
-
- CodeRefactorer gen = new CodeRefactorer (project.ParentSolution);
-
- CodeTypeDeclaration type = new CodeTypeDeclaration ();
- type.Name = name;
- type.IsClass = true;
- type.BaseTypes.Add (new CodeTypeReference ("Gtk.ActionGroup"));
-
- // Generate the constructor. It contains the call that builds the widget.
-
- CodeConstructor ctor = new CodeConstructor ();
- ctor.Attributes = MemberAttributes.Public | MemberAttributes.Final;
- ctor.BaseConstructorArgs.Add (new CodePrimitiveExpression (fullName));
-
- CodeMethodInvokeExpression call = new CodeMethodInvokeExpression (
- new CodeMethodReferenceExpression (
- new CodeTypeReferenceExpression ("Stetic.Gui"),
- "Build"
- ),
- new CodeThisReferenceExpression (),
- new CodeTypeOfExpression (fullName)
- );
- ctor.Statements.Add (call);
- type.Members.Add (ctor);
-
- // Add signal handlers
-
- foreach (Stetic.ActionComponent action in group.GetActions ()) {
- foreach (Stetic.Signal signal in action.GetSignals ()) {
- CodeMemberMethod met = new CodeMemberMethod ();
- met.Name = signal.Handler;
- met.Attributes = MemberAttributes.Family;
- met.ReturnType = new CodeTypeReference (signal.SignalDescriptor.HandlerReturnTypeName);
-
- foreach (Stetic.ParameterDescriptor pinfo in signal.SignalDescriptor.HandlerParameters)
- met.Parameters.Add (new CodeParameterDeclarationExpression (pinfo.TypeName, pinfo.Name));
-
- type.Members.Add (met);
- }
- }
-
- // Create the class
-
- IType cls = null;
- cls = gen.CreateClass (project, ((DotNetProject)project).LanguageName, folder, namspace, type);
- if (cls == null)
- throw new UserException ("Could not create class " + fullName);
-
- project.AddFile (cls.CompilationUnit.FileName, BuildAction.Compile);
- IdeApp.ProjectOperations.Save (project);
-
-#if TRUNK
- // Make sure the database is up-to-date
- ProjectDomService.Parse (project, cls.CompilationUnit.FileName);
-#else
- ProjectDomService.Parse (project, cls.CompilationUnit.FileName, null);
-
-#endif
- return cls;
- }
-
- internal static bool IsValidClass (ProjectDom ctx, IType cls)
- {
- if (cls.BaseTypes != null) {
- foreach (IReturnType bt in cls.BaseTypes) {
- if (bt.FullName == "Gtk.ActionGroup")
- return true;
-
- IType baseCls = ctx.GetType (bt);
- if (baseCls != null && IsValidClass (ctx, baseCls))
- return true;
- }
- }
- return false;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs
deleted file mode 100644
index 0be5db765f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs
+++ /dev/null
@@ -1,316 +0,0 @@
-//
-// ActionGroupView.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Commands;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.DesignerSupport;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class ActionGroupView: CombinedDesignView
- {
- Stetic.ActionGroupDesigner designer;
- CodeBinder codeBinder;
- GuiBuilderProject project;
- Stetic.ActionGroupComponent group;
- Stetic.ActionGroupInfo groupInfo;
- string groupName;
-
- public ActionGroupView (IViewContent content, Stetic.ActionGroupInfo group, GuiBuilderProject project): base (content)
- {
- groupName = group.Name;
- this.project = project;
- LoadDesigner ();
- }
-
- void LoadDesigner ()
- {
- groupInfo = project.GetActionGroup (groupName);
- if (groupInfo == null)
- // Group not found
- return;
-
- group = (Stetic.ActionGroupComponent) groupInfo.Component;
- project.Unloaded += OnDisposeProject;
-
- designer = project.SteticProject.CreateActionGroupDesigner (groupInfo, false);
- designer.AllowActionBinding = project.Project.UsePartialTypes;
- designer.BindField += new EventHandler (OnBindField);
-
- ActionGroupPage actionsPage = new ActionGroupPage ();
- actionsPage.PackStart (designer, true, true, 0);
- actionsPage.ShowAll ();
-
- AddButton (GettextCatalog.GetString ("Actions"), actionsPage);
-
- designer.ModifiedChanged += OnGroupModified;
- designer.SignalAdded += OnSignalAdded;
- designer.SignalChanged += OnSignalChanged;
- designer.RootComponentChanged += OnRootComponentChanged;
-
- codeBinder = new CodeBinder (project.Project, new OpenDocumentFileProvider (), designer.RootComponent);
- }
-
- public void CloseDesigner ()
- {
- if (designer == null)
- return;
- project.Unloaded -= OnDisposeProject;
- designer.BindField -= OnBindField;
- designer.RootComponentChanged -= OnRootComponentChanged;
- designer.ModifiedChanged -= OnGroupModified;
- designer.SignalAdded -= OnSignalAdded;
- designer.SignalChanged -= OnSignalChanged;
- designer.Destroy ();
- designer = null;
-
- project.Reloaded += OnReloadProject;
- }
-
- public override Stetic.Designer Designer {
- get { return designer; }
- }
-
- void OnDisposeProject (object s, EventArgs args)
- {
- RemoveButton (1);
- CloseDesigner ();
- }
-
- void OnReloadProject (object s, EventArgs args)
- {
- if (designer == null)
- LoadDesigner ();
- }
-
- public Stetic.ActionGroupComponent ActionGroup {
- get { return group; }
- set { Load (value.Name); }
- }
-
- public override void ShowPage (int npage)
- {
- if (designer != null && group != null) {
- // At every page switch update the generated code, to make sure code completion works
- // for the generated fields. The call to GenerateSteticCodeStructure will generate
- // the code for the window (only the fields in fact) and update the parser database, it
- // will not save the code to disk.
- if (project.Project.UsePartialTypes)
- GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)project.Project, designer.RootComponent, null, false, false);
- }
- base.ShowPage (npage);
- }
-
- void OnRootComponentChanged (object s, EventArgs args)
- {
- codeBinder.TargetObject = designer.RootComponent;
- }
-
- public override void Save (string fileName)
- {
- string oldBuildFile = GuiBuilderService.GetBuildCodeFileName (project.Project, groupInfo.Name);
-
- base.Save (fileName);
- if (designer == null)
- return;
-
- codeBinder.UpdateBindings (fileName);
-
- designer.Save ();
-
- string newBuildFile = GuiBuilderService.GetBuildCodeFileName (project.Project, groupInfo.Name);
- if (oldBuildFile != newBuildFile && oldBuildFile != null && newBuildFile != null)
- FileService.MoveFile (oldBuildFile, newBuildFile);
-
- project.Save (true);
- OnDirtyChanged (EventArgs.Empty);
- }
-
- public override void Dispose ()
- {
- CloseDesigner ();
- project.Reloaded -= OnReloadProject;
- base.Dispose ();
- }
-
- public void ShowDesignerView ()
- {
- ShowPage (1);
- }
-
- public void SelectAction (Stetic.ActionComponent action)
- {
- if (designer != null)
- designer.SelectedAction = action;
- }
-
- public override void JumpToSignalHandler (Stetic.Signal signal)
- {
- IType cls = codeBinder.GetClass ();
- foreach (IMethod met in cls.Methods) {
- if (met.Name == signal.Handler) {
- ShowPage (1);
- JumpTo (met.Location.Line, met.Location.Column);
- break;
- }
- }
- }
-
- void OnGroupModified (object s, EventArgs a)
- {
- if (designer.Modified)
- OnContentChanged (a);
- IsDirty = designer.Modified;
- }
-
- void OnSignalAdded (object s, Stetic.ComponentSignalEventArgs a)
- {
- codeBinder.BindSignal (a.Signal);
- }
-
- void OnSignalChanged (object s, Stetic.ComponentSignalEventArgs a)
- {
- codeBinder.UpdateSignal (a.OldSignal, a.Signal);
- }
-
- void OnBindField (object s, EventArgs args)
- {
- if (designer.SelectedAction != null) {
- codeBinder.BindToField (designer.SelectedAction);
- }
- }
- }
-
- class ActionGroupPage: Gtk.VBox, ICustomPropertyPadProvider
- {
- public ActionGroupPage ()
- {
- }
-
- Gtk.Widget ICustomPropertyPadProvider.GetCustomPropertyWidget ()
- {
- return PropertiesWidget.Instance;
- }
-
- void ICustomPropertyPadProvider.DisposeCustomPropertyWidget ()
- {
- }
-
- public void ClearChild ()
- {
- if (Children.Length > 0) {
- Gtk.Widget w = Children [0];
- Remove (w);
- w.Destroy ();
- }
- }
-
- Stetic.ActionGroupDesigner actionsBox {
- get { return Children[0] as Stetic.ActionGroupDesigner; }
- }
-
- [CommandHandler (EditCommands.Delete)]
- protected void OnDelete ()
- {
- actionsBox.DeleteSelection ();
- }
-
- [CommandUpdateHandler (EditCommands.Delete)]
- protected void OnUpdateDelete (CommandInfo cinfo)
- {
- cinfo.Enabled = actionsBox != null && actionsBox.SelectedAction != null;
- }
-
- [CommandHandler (EditCommands.Copy)]
- protected void OnCopy ()
- {
- actionsBox.CopySelection ();
- }
-
- [CommandUpdateHandler (EditCommands.Copy)]
- protected void OnUpdateCopy (CommandInfo cinfo)
- {
- cinfo.Enabled = actionsBox != null && actionsBox.SelectedAction != null;
- }
-
- [CommandHandler (EditCommands.Cut)]
- protected void OnCut ()
- {
- actionsBox.CutSelection ();
- }
-
- [CommandUpdateHandler (EditCommands.Cut)]
- protected void OnUpdateCut (CommandInfo cinfo)
- {
- cinfo.Enabled = actionsBox != null && actionsBox.SelectedAction != null;
- }
-
- [CommandHandler (EditCommands.Paste)]
- protected void OnPaste ()
- {
- actionsBox.PasteToSelection ();
- }
-
- [CommandUpdateHandler (EditCommands.Paste)]
- protected void OnUpdatePaste (CommandInfo cinfo)
- {
- cinfo.Enabled = false;
- }
-
- [CommandHandler (EditCommands.Undo)]
- protected void OnUndo ()
- {
- actionsBox.UndoQueue.Undo ();
- }
-
- [CommandHandler (EditCommands.Redo)]
- protected void OnRedo ()
- {
- actionsBox.UndoQueue.Redo ();
- }
-
- [CommandUpdateHandler (EditCommands.Undo)]
- protected void OnUpdateUndo (CommandInfo cinfo)
- {
- cinfo.Enabled = actionsBox != null && actionsBox.UndoQueue.CanUndo;
- }
-
- [CommandUpdateHandler (EditCommands.Redo)]
- protected void OnUpdateRedo (CommandInfo cinfo)
- {
- cinfo.Enabled = actionsBox != null && actionsBox.UndoQueue.CanRedo;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs
deleted file mode 100644
index ec5c5ea988..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// ClassUtils.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using Gtk;
-using System;
-using System.Collections;
-using System.CodeDom;
-using MonoDevelop.Projects.Dom;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- internal class ClassUtils
- {
- public static IField FindWidgetField (IType cls, string name)
- {
- foreach (IField field in cls.Fields) {
- if (name == GetWidgetFieldName (field))
- return field;
- }
- return null;
- }
-
- public static string GetWidgetFieldName (IField field)
- {
- foreach (IAttribute att in field.Attributes) {
- if (att.Name == "Glade.Widget" || att.Name == "Widget" || att.Name == "Glade.WidgetAttribute" || att.Name == "WidgetAttribute") {
- if (att.PositionalArguments != null && att.PositionalArguments.Count > 0) {
- CodePrimitiveExpression exp = att.PositionalArguments [0] as CodePrimitiveExpression;
- if (exp != null)
- return exp.Value.ToString ();
- } else {
- return field.Name;
- }
- }
- }
- return field.Name;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs
deleted file mode 100644
index fc19797521..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs
+++ /dev/null
@@ -1,360 +0,0 @@
-//
-// CodeBinder.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System.CodeDom;
-using System.Collections;
-
-using MonoDevelop.Core;
-using MonoDevelop.Core.ProgressMonitoring;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Text;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Projects.CodeGeneration;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.GtkCore.Dialogs;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- /// This class provides several methods for managing the relation
- /// between an object (e.g. a window) and the source code that will implement the
- /// code for that object.
- ///
- /// Once created, a CodeBinder object will keep track of the class bound to the
- /// object. If the class is renamed, it will properly update the object name.
-
- public class CodeBinder
- {
- ITextFileProvider textFileProvider;
- Stetic.Component targetObject;
- Project project;
- GuiBuilderProject gproject;
- string className;
- string classFile;
-
- public CodeBinder (Project project, ITextFileProvider textFileProvider, Stetic.Component targetObject)
- {
- this.project = project;
- this.textFileProvider = textFileProvider;
-
- gproject = GtkDesignInfo.FromProject (project).GuiBuilderProject;
-
- TargetObject = targetObject;
- }
-
- public Stetic.Component TargetObject {
- get { return targetObject; }
- set {
- this.targetObject = value;
- if (targetObject != null) {
- IType cls = gproject.FindClass (GetClassName (targetObject));
- if (cls != null) {
- className = cls.FullName;
- classFile = cls.CompilationUnit.FileName;
- }
- }
- }
- }
-
- /// Synchronizes the bindings between the object and the source code
- public void UpdateBindings (string fileName)
- {
- if (targetObject == null)
- return;
-#if TRUNK
- ParsedDocument doc = ProjectDomService.Parse (project, fileName);
-#else
- ParsedDocument doc = ProjectDomService.Parse (project, fileName, null);
-#endif
- classFile = fileName;
-
- if (doc != null && doc.CompilationUnit != null) {
- IType cls = GetClass ();
- UpdateBindings (targetObject, cls);
-
- if (cls != null)
- targetObject.GeneratePublic = cls.IsPublic;
- }
- }
-
- void UpdateBindings (Stetic.Component obj, IType cls)
- {
- if (targetObject == null)
- return;
-
- // Remove signals for which there isn't a handler in the class
-
- Stetic.SignalCollection objectSignals = obj.GetSignals ();
- if (objectSignals != null) {
- Stetic.Signal[] signals = new Stetic.Signal [objectSignals.Count];
- objectSignals.CopyTo (signals, 0);
-
- foreach (Stetic.Signal signal in signals) {
- if (FindSignalHandler (cls, signal) == null) {
- obj.RemoveSignal (signal);
- }
- }
- }
-
- // Update children
-
- foreach (Stetic.Component ob in obj.GetChildren ())
- UpdateBindings (ob, cls);
- }
-
- IMethod FindSignalHandler (IType cls, Stetic.Signal signal)
- {
- foreach (IMethod met in cls.Methods) {
- if (met.Name == signal.Handler) {
- return met;
- }
- }
- return null;
- }
-
- public void UpdateField (Stetic.Component obj, string oldName)
- {
- if (targetObject == null)
- return;
-
- CodeRefactorer cr = GetCodeGenerator ();
-
- IType cls;
-
- if (obj == targetObject)
- return; // The root widget name can only be changed internally.
- else
- cls = GetClass (false);
-
- string newName = GetObjectName (obj);
- if (newName.Length == 0)
- return;
-
- if (cls != null) {
- IField f = ClassUtils.FindWidgetField (cls, oldName);
- if (f != null) {
- cr.RenameMember (new NullProgressMonitor (), cls, f, newName, RefactoryScope.File);
- }
- }
- }
-
- /// Adds a signal handler to the class
- public void BindSignal (Stetic.Signal signal)
- {
- if (targetObject == null)
- return;
-
- IType cls = GetClass ();
- if (cls == null)
- return;
-
- if (FindSignalHandler (cls, signal) != null)
- return;
-
- CodeMemberMethod met = new CodeMemberMethod ();
- met.Name = signal.Handler;
- met.Attributes = MemberAttributes.Family;
- met.ReturnType = new CodeTypeReference (signal.SignalDescriptor.HandlerReturnTypeName);
-
- foreach (Stetic.ParameterDescriptor pinfo in signal.SignalDescriptor.HandlerParameters)
- met.Parameters.Add (new CodeParameterDeclarationExpression (pinfo.TypeName, pinfo.Name));
- CodeRefactorer gen = GetCodeGenerator ();
- gen.AddMember (cls, met);
- }
-
- public void UpdateSignal (Stetic.Signal oldSignal, Stetic.Signal newSignal)
- {
- if (targetObject == null)
- return;
-
- if (oldSignal.Handler == newSignal.Handler)
- return;
-
- IType cls = GetClass ();
- if (cls == null) return;
-
- IMethod met = FindSignalHandler (cls, oldSignal);
- if (met == null) return;
- CodeRefactorer gen = GetCodeGenerator ();
- gen.RenameMember (new NullProgressMonitor (), cls, met, newSignal.Handler, RefactoryScope.File);
- }
-
- /// Adds a field to the class
- public void BindToField (Stetic.Component obj)
- {
- if (targetObject == null)
- return;
-
- string name = GetMemberName (obj);
- IType cls = GetClass ();
-
- if (FindField (cls, name) != null)
- return;
-
- Document doc = IdeApp.Workbench.OpenDocument (cls.CompilationUnit.FileName, true);
-
- IEditableTextFile editor = doc.GetContent<IEditableTextFile> ();
- if (editor != null) {
- CodeRefactorer gen = GetCodeGenerator ();
- gen.AddMember (cls, GetFieldCode (obj, name));
- }
- }
-
- CodeMemberField GetFieldCode (Stetic.Component obj, string name)
- {
- string type = obj.Type.ClassName;
- CodeMemberField field = new CodeMemberField (type, name);
- field.Attributes = MemberAttributes.Family;
- return field;
- }
-
- IField FindField (IType cls, string name)
- {
- foreach (IField field in cls.Fields)
- if (field.Name == name)
- return field;
- return null;
- }
-
- CodeRefactorer GetCodeGenerator ()
- {
- CodeRefactorer cr = new CodeRefactorer (project.ParentSolution);
- cr.TextFileProvider = textFileProvider;
- return cr;
- }
-
- public IType GetClass ()
- {
- return GetClass (true);
- }
-
- public IType GetClass (bool getUserClass)
- {
- if (targetObject == null)
- return null;
-
- IType cls = gproject.FindClass (className, getUserClass);
- if (cls != null)
- return cls;
-
- // The class name may have changed. Try to guess the new name.
-
- ArrayList matches = new ArrayList ();
- ICompilationUnit unit = null;
- ProjectDom ctx = gproject.GetParserContext ();
-#if TRUNK
- ParsedDocument doc = ProjectDomService.Parse (project, classFile);
-#else
- ParsedDocument doc = ProjectDomService.Parse (project, classFile, null);
-#endif
-
- if (doc != null && doc.CompilationUnit != null) {
- unit = doc.CompilationUnit;
- foreach (IType fcls in unit.Types) {
- if (IsValidClass (ctx, fcls, targetObject))
- matches.Add (fcls);
- }
- }
-
- // If found the class, just return it
- if (matches.Count == 1) {
- cls = (IType) matches [0];
- className = cls.FullName;
- targetObject.Name = className;
- gproject.Save (true);
- return cls;
- }
-
- // If not found, warn the user.
-
- if (unit != null && unit.Types.Count > 0) {
- using (SelectRenamedClassDialog dialog = new SelectRenamedClassDialog (unit.Types)) {
- if (dialog.Run ()) {
- className = dialog.SelectedClass;
- if (className == null)
- return null;
- else {
- targetObject.Name = className;
- gproject.Save (true);
- return gproject.FindClass (className);
- }
- }
- }
- } else {
- MessageService.ShowError (GettextCatalog.GetString ("The class bound to the component '{0}' could not be found. This may be due to syntax errors in the source code file.", GetObjectName(targetObject)));
- }
-
- return null;
- }
-
- static bool IsValidClass (ProjectDom ctx, IType cls, Stetic.Component obj)
- {
- if (cls.BaseTypes != null) {
- string typeName = obj.Type.ClassName;
-
- foreach (IReturnType bt in cls.BaseTypes) {
- System.Console.WriteLine("tn:" + typeName + " bt:" + bt.FullName);
- if (bt.FullName == typeName)
- return true;
-
- IType baseCls = ctx.GetType (bt);
- if (baseCls != null && IsValidClass (ctx, baseCls, obj))
- return true;
- }
- }
- return false;
- }
-
- internal static string GetClassName (Stetic.Component obj)
- {
- return GetObjectName (obj);
- }
-
- internal static string GetMemberName (Stetic.Component obj)
- {
- return obj.Name;
- }
-
- internal static string GetObjectName (Stetic.Component obj)
- {
- return obj.Name;
- }
-
- internal static string GetClassName (Stetic.ProjectItemInfo obj)
- {
- return GetObjectName (obj);
- }
-
- internal static string GetObjectName (Stetic.ProjectItemInfo obj)
- {
- return obj.Name;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/CombinedDesignView.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/CombinedDesignView.cs
deleted file mode 100644
index b7e3313317..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/CombinedDesignView.cs
+++ /dev/null
@@ -1,307 +0,0 @@
-//
-// CombinedDesignView.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System;
-using Gtk;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui.Content;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class CombinedDesignView : AbstractViewContent
- {
- IViewContent content;
- Gtk.Notebook notebook;
- VBox box;
- Toolbar toolbar;
-
- bool updating;
-
- public CombinedDesignView (IViewContent content)
- {
- this.content = content;
- if (content is IEditableTextBuffer) {
- ((IEditableTextBuffer)content).CaretPositionSet += delegate {
- ShowPage (0);
- };
- }
- content.ContentChanged += new EventHandler (OnTextContentChanged);
- content.DirtyChanged += new EventHandler (OnTextDirtyChanged);
-
- notebook = new Gtk.Notebook ();
-
- // Main notebook
-
- notebook.TabPos = Gtk.PositionType.Bottom;
- notebook.ShowTabs = false;
- notebook.ShowBorder = false;
- notebook.Show ();
- box = new VBox ();
-
- // Bottom toolbar
-
- toolbar = new Toolbar ();
- toolbar.IconSize = IconSize.SmallToolbar;
- toolbar.ToolbarStyle = ToolbarStyle.BothHoriz;
- toolbar.ShowArrow = false;
-
- CommandRouterContainer crc = new CommandRouterContainer (content.Control, content, true);
- crc.Show ();
- AddButton (GettextCatalog.GetString ("Source Code"), crc).Active = true;
-
- toolbar.ShowAll ();
-
- box.PackStart (notebook, true, true, 0);
- box.PackStart (toolbar, false, false, 0);
-
- box.Show ();
-
- IdeApp.Workbench.ActiveDocumentChanged += new EventHandler (OnActiveDocumentChanged);
- content.Control.Realized += delegate {
- if (content != null && content.WorkbenchWindow != null)
- content.WorkbenchWindow.ActiveViewContent = notebook.CurrentPageWidget == content.Control ? content : this;
- };
- notebook.SwitchPage += delegate {
- if (content != null && content.WorkbenchWindow != null)
- content.WorkbenchWindow.ActiveViewContent = notebook.CurrentPageWidget == content.Control ? content : this;
- };
- }
-
- public virtual Stetic.Designer Designer {
- get { return null; }
- }
-
- protected ToggleToolButton AddButton (string label, Gtk.Widget page)
- {
- updating = true;
- ToggleToolButton button = new ToggleToolButton ();
- button.Label = label;
- button.IsImportant = true;
- button.Clicked += new EventHandler (OnButtonToggled);
- button.ShowAll ();
- toolbar.Insert (button, -1);
- notebook.AppendPage (page, new Gtk.Label ());
- updating = false;
- return button;
- }
-
- public bool HasPage (Gtk.Widget page)
- {
- return notebook.PageNum (page) != -1;
- }
-
- public void RemoveButton (Gtk.Widget page)
- {
- int i = notebook.PageNum (page);
- if (i != -1)
- RemoveButton (i);
- }
-
- public void RemoveButton (int npage)
- {
- if (npage >= toolbar.Children.Length)
- return;
- notebook.RemovePage (npage);
- Gtk.Widget cw = toolbar.Children [npage];
- toolbar.Remove (cw);
- cw.Destroy ();
- ShowPage (0);
- }
-
- public override MonoDevelop.Projects.Project Project {
- get { return base.Project; }
- set {
- base.Project = value;
- content.Project = value;
- }
- }
-
- protected override void OnWorkbenchWindowChanged (EventArgs e)
- {
- base.OnWorkbenchWindowChanged (e);
- content.WorkbenchWindow = WorkbenchWindow;
- }
-
- void OnButtonToggled (object s, EventArgs args)
- {
- int i = Array.IndexOf (toolbar.Children, s);
- if (i != -1)
- ShowPage (i);
- }
-
- public virtual void ShowPage (int npage)
- {
- if (notebook.CurrentPage == npage)
- return;
-
- if (updating) return;
- updating = true;
-
- notebook.CurrentPage = npage;
- Gtk.Widget[] buttons = toolbar.Children;
- for (int n=0; n<buttons.Length; n++) {
- ToggleToolButton b = (ToggleToolButton) buttons [n];
- b.Active = (n == npage);
- }
- updating = false;
- }
-
- public override void Dispose ()
- {
- content.ContentChanged -= new EventHandler (OnTextContentChanged);
- content.DirtyChanged -= new EventHandler (OnTextDirtyChanged);
- IdeApp.Workbench.ActiveDocumentChanged -= new EventHandler (OnActiveDocumentChanged);
- content.Dispose ();
-
- // Remove and destroy the contents of the Notebook, since the destroy event is
- // not propagated to pages in some gtk versions.
-
- foreach (Gtk.Widget cw in notebook.Children) {
- Gtk.Widget lw = notebook.GetTabLabel (cw);
- notebook.Remove (cw);
- cw.Destroy ();
- if (lw != null)
- lw.Destroy ();
- }
- content = null;
- box = null;
-
- base.Dispose ();
- }
-
- public override void Load (string fileName)
- {
- ShowPage (1);
- ContentName = fileName;
- content.Load (fileName);
- }
-
- public override Gtk.Widget Control {
- get { return box; }
- }
-
- public override void Save (string fileName)
- {
- content.Save (fileName);
- }
-
- public override bool IsDirty {
- get {
- return content.IsDirty;
- }
- set {
- content.IsDirty = value;
- }
- }
-
- public override bool IsReadOnly
- {
- get {
- return content.IsReadOnly;
- }
- }
-
- public virtual void AddCurrentWidgetToClass ()
- {
- }
-
- public virtual void JumpToSignalHandler (Stetic.Signal signal)
- {
- }
-
- void OnTextContentChanged (object s, EventArgs args)
- {
- OnContentChanged (args);
- }
-
- void OnTextDirtyChanged (object s, EventArgs args)
- {
- OnDirtyChanged (args);
- }
-
- void OnActiveDocumentChanged (object s, EventArgs args)
- {
- if (IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.GetContent<CombinedDesignView>() == this)
- OnDocumentActivated ();
- }
-
- protected virtual void OnDocumentActivated ()
- {
- }
-
-#if TRUNK
- public override T GetContent<T> ()
- {
-// if (type == typeof(IEditableTextBuffer)) {
-// // Intercept the IPositionable interface, since we need to
-// // switch to the text editor when jumping to a line
-// if (content.GetContent (type) != null)
-// return this;
-// else
-// return null;
-// }
-//
- return base.GetContent<T> () ?? content.GetContent<T> ();
- }
-
- public void JumpTo (int line, int column)
- {
- IEditableTextBuffer ip = content.GetContent<IEditableTextBuffer> ();
- if (ip != null) {
- ShowPage (0);
- ip.SetCaretTo (line, column);
- }
- }
-#else
- public override object GetContent (Type contentType)
- {
- object ob = base.GetContent (contentType);
- if (ob != null)
- return ob;
- else if (content != null)
- return content.GetContent (contentType);
- else
- return null;
- }
-
- public void JumpTo (int line, int column)
- {
- IEditableTextBuffer ip = (IEditableTextBuffer) content.GetContent (typeof (IEditableTextBuffer));
- if (ip != null) {
- ShowPage (0);
- ip.SetCaretTo (line, column);
- }
- }
-#endif
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs
deleted file mode 100644
index 2570dc6d09..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-
-using System;
-using System.Threading;
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class GtkProjectServiceExtension: ProjectServiceExtension
- {
- public override bool SupportsItem (IBuildTarget item)
- {
- if (!IdeApp.IsInitialized)
- return false;
-
- DotNetProject project = item as DotNetProject;
- return project != null && GtkDesignInfo.HasDesignedObjects (project);
- }
-
- protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
- {
- DotNetProject project = (DotNetProject) entry;
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-
- // The code generator must run in the GUI thread since it needs to
- // access to Gtk classes
- Generator gen = new Generator ();
- lock (gen) {
- Gtk.Application.Invoke (delegate { gen.Run (monitor, project, configuration); });
- Monitor.Wait (gen);
- }
-
- BuildResult res = base.Build (monitor, entry, configuration);
-
- if (gen.Messages != null) {
- foreach (string s in gen.Messages)
-// res.AddWarning (info.GuiBuilderProject.File, 0, 0, null, s);
-// TODO: Add gtkx file name in the Generator
- res.AddWarning ("", 0, 0, null, s);
-
- if (gen.Messages.Length > 0)
- info.ForceCodeGenerationOnBuild ();
- }
- return res;
- }
-
-
- }
-
- class Generator
- {
- public void Run (IProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration)
- {
- lock (this) {
- try {
- Stetic.CodeGenerationResult res = GuiBuilderService.GenerateSteticCode (monitor, project, configuration);
- if (res != null)
- Messages = res.Warnings;
- } catch (Exception ex) {
- Error = ex;
- LoggingService.LogError (ex.ToString ());
- Messages = new string [] { Error.Message };
- }
- Monitor.PulseAll (this);
- }
- }
- public string[] Messages;
- public Exception Error;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDisplayBinding.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDisplayBinding.cs
deleted file mode 100644
index b496919221..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDisplayBinding.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-// GuiBuilderDisplayBinding.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class GuiBuilderDisplayBinding : DisplayBinding
- {
- bool excludeThis = false;
-
- public override string Name {
- get { return "Window Designer"; }
- }
-
- public override bool CanCreateContentForUri (string fileName)
- {
- Project project = IdeApp.Workspace.GetProjectContainingFile (fileName);
- GtkDesignInfo info = GtkDesignInfo.FromProject ((DotNetProject) project);
-
- if (excludeThis) return false;
-
- if (fileName.Contains (info.BuildFileExtension))
- return false;
-
- if (GetWindow (fileName) == null)
- return false;
-
- excludeThis = true;
- var db = DisplayBindingService.GetDefaultBindingForUri (fileName);
- excludeThis = false;
- return db != null;
- }
-
- public override IViewContent CreateContentForUri (string fileName)
- {
- excludeThis = true;
- var db = DisplayBindingService.GetDefaultBindingForUri (fileName);
- GuiBuilderView view = new GuiBuilderView (db.CreateContentForUri (fileName), GetWindow (fileName));
- excludeThis = false;
- return view;
- }
-
- internal static GuiBuilderWindow GetWindow (string file)
- {
- if (!IdeApp.Workspace.IsOpen)
- return null;
-
- Project project = null;
- foreach (Project p in IdeApp.Workspace.GetAllProjects ()) {
- if (p.IsFileInProject (file)) {
- project = p;
- break;
- }
- }
-
- if (!GtkDesignInfo.HasDesignedObjects (project))
- return null;
-
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- if (file.StartsWith (info.SteticFolder))
- return null;
-
- ParsedDocument doc = ProjectDomService.GetParsedDocument (null, file);
- if (doc == null || doc.CompilationUnit == null)
- return null;
-
- foreach (IType t in doc.CompilationUnit.Types) {
- GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass (t.FullName);
- if (win != null)
- return win;
- }
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDocumentOutline.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDocumentOutline.cs
deleted file mode 100644
index 8cbf2677bb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDocumentOutline.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// GuiBuilderProjectPad.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System;
-using Gtk;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Commands;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.DesignerSupport;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- internal class GuiBuilderDocumentOutline: Alignment, ICustomPropertyPadProvider
- {
- static GuiBuilderDocumentOutline instance;
-
- GuiBuilderDocumentOutline () : base (0, 0, 1, 1)
- {
- BorderWidth = 0;
- GuiBuilderService.SteticApp.WidgetTreeWidget.BorderWidth = 0;
- Add (GuiBuilderService.SteticApp.WidgetTreeWidget);
- ShowAll ();
- }
-
- internal static GuiBuilderDocumentOutline Instance {
- get {
- if (instance == null)
- instance = new GuiBuilderDocumentOutline ();
- return instance;
- }
- }
-
- Gtk.Widget ICustomPropertyPadProvider.GetCustomPropertyWidget ()
- {
- return PropertiesWidget.Instance;
- }
-
- void ICustomPropertyPadProvider.DisposeCustomPropertyWidget ()
- {
- }
-
- [CommandHandler (EditCommands.Undo)]
- protected void OnUndo ()
- {
-// GuiBuilderService.App.CommandUndo ();
- }
-
- [CommandHandler (EditCommands.Redo)]
- protected void OnRedo ()
- {
-// GuiBuilderService.App.CommandRedo ();
- }
-
- [CommandHandler (EditCommands.Copy)]
- protected void OnCopy ()
- {
-// GuiBuilderService.App.CommandCopy ();
- }
-
- [CommandHandler (EditCommands.Cut)]
- protected void OnCut ()
- {
-// GuiBuilderService.App.CommandCut ();
- }
-
- [CommandHandler (EditCommands.Paste)]
- protected void OnPaste ()
- {
-// GuiBuilderService.App.CommandPaste ();
- }
-
- [CommandHandler (EditCommands.Delete)]
- protected void OnDelete ()
- {
-// GuiBuilderService.App.CommandDelete ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
deleted file mode 100644
index 5dd66c5b6d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
+++ /dev/null
@@ -1,743 +0,0 @@
-//
-// GuiBuilderProject.cs
-//
-// Author:
-// Lluis Sanchez Gual
-// Krzysztof Marecki
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Xml;
-using System.IO;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.CodeDom.Compiler;
-
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class GuiBuilderProject
- {
- //to save temporarily GuiBuilderWindow while files are being moved between projects
- static List<GuiBuilderWindow> formInfosRemoved;
-
- internal object MemoryProbe = Counters.GuiProjectsInMemory.CreateMemoryProbe ();
-
- List<GuiBuilderWindow> formInfos;
- Stetic.Project gproject;
- DotNetProject project;
- string folderName;
- bool hasError;
- bool needsUpdate = true;
-
- FileSystemWatcher watcher;
- DateTime lastSaveTime;
- object fileSaveLock = new object ();
- bool disposed;
- bool librariesUpdated;
-
- public event WindowEventHandler WindowAdded;
- public event WindowEventHandler WindowRemoved;
- public event EventHandler Reloaded;
- public event EventHandler Unloaded;
- public event EventHandler Changed;
-
- static GuiBuilderProject ()
- {
- formInfosRemoved = new List<GuiBuilderWindow> ();
- }
-
- public GuiBuilderProject (DotNetProject project, string folderName)
- {
- this.folderName = folderName;
- this.project = project;
- Counters.GuiProjectsLoaded++;
- }
-
- public void Convert (string guiFolderName, bool makeBackup)
- {
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- Stetic.Project gproject = GuiBuilderService.SteticApp.CreateProject (info);
- //Stetic.Project does not implement IDisposable
- try {
- string newGuiFolderName = project.BaseDirectory.Combine (guiFolderName);
- gproject.ConvertProject (info.SteticFile, newGuiFolderName);
- info.ConvertGtkFolder (guiFolderName, makeBackup);
- info.UpdateGtkFolder ();
- folderName = newGuiFolderName;
- IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor ();
- try {
- ConfigurationSelector configuration = IdeApp.Workspace.ActiveConfiguration;
- Generator generator = new Generator ();
- generator.Run (monitor, project, configuration);
- monitor.ReportSuccess ("Converting was succesfull");
- } finally {
- monitor.Dispose ();
- }
- } finally {
- gproject.Dispose ();
- }
- }
-
- public void GenerateCode (string componentFile)
- {
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- string gtkxFile = info.GetDesignerFileFromComponent (componentFile);
- if (gtkxFile != null && File.Exists (gtkxFile)) {
-
- Save (false);
- FileInfo fi = new FileInfo (gtkxFile);
- fi.LastWriteTime = DateTime.Now;
-
- IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor ();
- try {
- ConfigurationSelector configuration = IdeApp.Workspace.ActiveConfiguration;
- Generator generator = new Generator ();
- generator.Run (monitor, project, configuration);
- } finally {
- monitor.Dispose ();
- }
- }
- }
-
- void Load ()
- {
- if (gproject != null || disposed || folderName == null)
- return;
-
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- gproject = GuiBuilderService.SteticApp.CreateProject (info);
- formInfos = new List<GuiBuilderWindow> ();
-
-// TODO : when expanding project, UpdateGtkFolder causes in throwing exception by gtk
-// info.UpdateGtkFolder ();
-
- try {
- gproject.Load (folderName);
- } catch (Exception ex) {
- MessageService.ShowException (ex, GettextCatalog.GetString ("The GUI designer project folder '{0}' could not be loaded.", folderName));
- hasError = true;
- }
-
- Counters.SteticProjectsLoaded++;
- gproject.ResourceProvider = GtkDesignInfo.FromProject (project).ResourceProvider;
-// gproject.DesignInfo = info;
- gproject.WidgetAdded += OnAddWidget;
- gproject.WidgetRemoved += OnRemoveWidget;
- gproject.ActionGroupsChanged += OnGroupsChanged;
- project.FileAddedToProject += OnFileAdded;
- project.FileRemovedFromProject += OnFileRemoved;
- project.ReferenceAddedToProject += OnReferenceAdded;
- project.ReferenceRemovedFromProject += OnReferenceRemoved;
-
- foreach (Stetic.WidgetInfo ob in gproject.Widgets)
- RegisterWindow (ob, false);
- }
-
- void Unload ()
- {
- if (gproject == null)
- return;
-
- Counters.SteticProjectsLoaded--;
-
- if (Unloaded != null)
- Unloaded (this, EventArgs.Empty);
- if (formInfos != null) {
- foreach (GuiBuilderWindow win in formInfos)
- win.Dispose ();
- formInfos = null;
- }
- if (gproject != null) {
- gproject.WidgetAdded -= OnAddWidget;
- gproject.WidgetRemoved -= OnRemoveWidget;
- gproject.ActionGroupsChanged -= OnGroupsChanged;
- gproject.Dispose ();
- gproject = null;
- }
- if (project != null) {
- project.FileAddedToProject -= OnFileAdded;
- project.FileRemovedFromProject -= OnFileRemoved;
- project.ReferenceAddedToProject -= OnReferenceAdded;
- project.ReferenceRemovedFromProject -= OnReferenceRemoved;
- }
- needsUpdate = true;
- hasError = false;
- librariesUpdated = false;
- if (watcher != null) {
- watcher.Dispose ();
- watcher = null;
- }
- NotifyChanged ();
- }
-
- void OnSteticFileChanged (object s, FileSystemEventArgs args)
- {
- lock (fileSaveLock) {
- if (lastSaveTime == System.IO.File.GetLastWriteTime (folderName))
- return;
- }
-
- if (GuiBuilderService.HasOpenDesigners (project, true)) {
- if (MessageService.AskQuestion (GettextCatalog.GetString ("The project '{0}' has been modified by an external application. Do you want to reload it?", project.Name), GettextCatalog.GetString ("Unsaved changes in the open GTK designers will be lost."), AlertButton.Cancel, AlertButton.Reload) != AlertButton.Reload)
- return;
- }
- if (!disposed)
- Reload ();
- }
-
- public void Reload ()
- {
- if (disposed)
- return;
- Unload ();
- if (Reloaded != null)
- Reloaded (this, EventArgs.Empty);
- NotifyChanged ();
- }
-
- public void ReloadFile (string fileName)
- {
- GuiBuilderWindow window = GetWindowForFile (fileName);
- if (window != null) {
- var root = window.RootWidget;
- UnregisterWindow (window);
- gproject.ReloadComponent (window.Name);
- RegisterWindow (root, false);
- }
- }
-
- public bool HasError {
- get { return hasError; }
- }
-
- public bool IsEmpty {
- get {
- // If the project is not loaded, assume not empty
- return gproject != null && Windows != null && Windows.Count == 0;
- }
- }
-
- public void Save (bool saveMdProject)
- {
- if (disposed)
- return;
-
- if (gproject != null && !hasError) {
- lock (fileSaveLock) {
- gproject.Save (folderName);
- lastSaveTime = System.IO.File.GetLastWriteTime (folderName);
- }
- }
-
- if (GtkDesignInfo.FromProject (project).UpdateGtkFolder () && saveMdProject)
- IdeApp.ProjectOperations.Save (project);
- }
-
- public Stetic.Project SteticProject {
- get {
- Load ();
- return gproject;
-
- }
- }
-
- public ICollection<GuiBuilderWindow> Windows {
- get {
- Load ();
- return formInfos;
- }
- }
-
- public DotNetProject Project {
- get { return project; }
- }
-
- public void Dispose ()
- {
- if (disposed)
- return;
- Counters.GuiProjectsLoaded--;
- disposed = true;
- if (watcher != null)
- watcher.Dispose ();
- Unload ();
- }
-
- public Stetic.WidgetInfo AddNewComponent (Stetic.ComponentType type, string name)
- {
- Stetic.WidgetInfo c = SteticProject.AddNewComponent (type, name);
- RegisterWindow (c, true);
- return c;
- }
-
- public Stetic.WidgetInfo AddNewComponent (XmlElement element)
- {
- Stetic.WidgetInfo c = SteticProject.AddNewComponent (element);
- // Register the window now, don't wait for the WidgetAdded event since
- // it may take some time, and the GuiBuilderWindow object is needed
- // just after this call
- RegisterWindow (c, true);
- return c;
- }
-
- public void AddNewComponent (string fileName)
- {
- object ob = SteticProject.AddNewComponent (fileName);
-
- if (ob is Stetic.WidgetInfo) {
- var c = (Stetic.WidgetInfo) ob;
- RegisterWindow (c, true);
- }
- }
-
- public void RegisterWindow (Stetic.WidgetInfo widget, bool notify)
- {
- if (formInfos != null) {
- foreach (GuiBuilderWindow w in formInfos)
- if (w.RootWidget == widget)
- return;
-
- GuiBuilderWindow win = new GuiBuilderWindow (this, gproject, widget);
- formInfos.Add (win);
-
- GuiBuilderWindow winToRemove = null;
- foreach (GuiBuilderWindow form in formInfosRemoved)
- if (form.RootWidget == widget) {
- winToRemove = form;
- break;
- }
-
- if (winToRemove != null)
- formInfosRemoved.Remove (winToRemove);
-
- if (notify) {
- if (WindowAdded != null)
- WindowAdded (this, new WindowEventArgs (win));
- NotifyChanged ();
- }
- }
- }
-
- public void UnregisterWindow (GuiBuilderWindow win)
- {
- if (!formInfos.Contains (win))
- return;
-
- formInfos.Remove (win);
- formInfosRemoved.Add (win);
-
- if (WindowRemoved != null)
- WindowRemoved (this, new WindowEventArgs (win));
-
- win.Dispose ();
- NotifyChanged ();
- }
-
- public void Remove (GuiBuilderWindow win)
- {
- gproject.RemoveComponent (win.RootWidget);
- UnregisterWindow (win);
- }
-
- public void RemoveActionGroup (Stetic.ActionGroupInfo group)
- {
- gproject.RemoveActionGroup (group);
- }
-
- void OnAddWidget (object s, Stetic.WidgetInfoEventArgs args)
- {
- if (!disposed)
- RegisterWindow (args.WidgetInfo, true);
- }
-
- void OnRemoveWidget (object s, Stetic.WidgetInfoEventArgs args)
- {
- if (disposed || Windows == null)
- return;
- foreach (GuiBuilderWindow form in Windows) {
- if (form.RootWidget.Name == args.WidgetInfo.Name) {
- UnregisterWindow (form);
- break;
- }
- }
- }
-
- void OnFileAdded (object sender, ProjectFileEventArgs args)
- {
- FilePath path = args.ProjectFile.FilePath;
-
- if (path.Extension == ".gtkx") {
- AddNewComponent (path);
- }
- }
-
- void OnFileRemoved (object sender, ProjectFileEventArgs args)
- {
- ArrayList toDelete = new ArrayList ();
- ArrayList toDeleteGroups = new ArrayList ();
-
- ParsedDocument doc = ProjectDomService.GetParsedDocument (ProjectDomService.GetProjectDom (args.Project), args.ProjectFile.Name);
- if (doc == null || doc.CompilationUnit == null)
- return;
-
- foreach (IType t in doc.CompilationUnit.Types) {
- GuiBuilderWindow win = GetWindowForClass (t.FullName);
- if (win != null) {
- toDelete.Add (win);
- continue;
- }
-
- Stetic.ActionGroupInfo group = GetActionGroup (t.FullName);
- if (group != null) {
- toDeleteGroups.Add (group);
- }
- }
-
- foreach (GuiBuilderWindow win in toDelete)
- Remove (win);
-
- foreach (Stetic.ActionGroupInfo group in toDeleteGroups)
- RemoveActionGroup (group);
- }
-
- void OnGroupsChanged (object s, EventArgs a)
- {
- if (!disposed)
- NotifyChanged ();
- }
-
- void OnReferenceAdded (object ob, ProjectReferenceEventArgs args)
- {
- if (disposed || !librariesUpdated)
- return;
- string pref = GetReferenceLibraryPath (args.ProjectReference);
- if (pref != null) {
- gproject.AddWidgetLibrary (pref);
- Save (false);
- }
- }
-
- void OnReferenceRemoved (object ob, ProjectReferenceEventArgs args)
- {
- if (disposed || !librariesUpdated)
- return;
- string pref = GetReferenceLibraryPath (args.ProjectReference);
- if (pref != null) {
- gproject.RemoveWidgetLibrary (pref);
- Save (false);
- }
- }
-
- string GetReferenceLibraryPath (ProjectReference pref)
- {
- string path = null;
-
- if (pref.ReferenceType == ReferenceType.Project) {
- DotNetProject p = project.ParentSolution.FindProjectByName (pref.Reference) as DotNetProject;
- if (p != null)
- path = p.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration);
- } else if (pref.ReferenceType == ReferenceType.Assembly) {
- path = pref.Reference;
- } else if (pref.ReferenceType == ReferenceType.Gac) {
- path = pref.Reference;
- }
- if (path != null && GuiBuilderService.SteticApp.IsWidgetLibrary (path))
- return path;
- else
- return null;
- }
-
- public void ImportGladeFile ()
- {
- var dlg = new MonoDevelop.Components.SelectFileDialog (GettextCatalog.GetString ("Open Glade File"));
- dlg.AddFilter (GettextCatalog.GetString ("Glade files"), "*.glade");
- dlg.AddAllFilesFilter ();
- if (dlg.Run ()) {
- SteticProject.ImportGlade (dlg.SelectedFile);
- Save (true);
- }
- }
-
- public GuiBuilderWindow GetWindowForClass (string className)
- {
- if (Windows != null) {
- foreach (GuiBuilderWindow form in Windows) {
- if (CodeBinder.GetObjectName (form.RootWidget) == className)
- return form;
- }
- }
-
- if (formInfosRemoved != null) {
- foreach (GuiBuilderWindow form in formInfosRemoved) {
- if (CodeBinder.GetObjectName (form.RootWidget) == className)
- return form;
- }
- }
- return null;
- }
-
- public GuiBuilderWindow GetWindowForFile (FilePath fileName)
- {
- if (Windows != null) {
- foreach (GuiBuilderWindow win in Windows) {
- if (fileName == win.SourceCodeFile)
- return win;
- }
- }
- return null;
- }
-
- public GuiBuilderWindow GetWindow (string name)
- {
- if (Windows != null) {
- foreach (GuiBuilderWindow win in Windows) {
- if (name == win.Name)
- return win;
- }
- }
- return null;
- }
-
- public Stetic.ActionGroupInfo GetActionGroupForFile (FilePath fileName)
- {
- foreach (Stetic.ActionGroupInfo group in SteticProject.ActionGroups) {
- if (fileName == GetSourceCodeFile (group, true))
- return group;
- }
- return null;
- }
-
- public Stetic.ActionGroupInfo GetActionGroup (string name)
- {
- return (SteticProject != null) ? SteticProject.GetActionGroup (name) : null;
- }
-
- public FilePath GetSourceCodeFile (Stetic.ProjectItemInfo obj)
- {
- return GetSourceCodeFile (obj, true);
- }
-
- public FilePath GetSourceCodeFile (Stetic.ProjectItemInfo obj, bool getUserClass)
- {
- IType cls = GetClass (obj, getUserClass);
- if (cls != null && cls.CompilationUnit != null)
- return cls.CompilationUnit.FileName;
- return null;
- }
-
- IType GetClass (Stetic.ProjectItemInfo obj, bool getUserClass)
- {
- string name = CodeBinder.GetClassName (obj);
- return FindClass (name, getUserClass);
- }
-
- public IType FindClass (string className)
- {
- return FindClass (className, true);
- }
-
- public IType FindClass (string className, bool getUserClass)
- {
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- FilePath gui_folder = info.SteticFolder;
- ProjectDom ctx = GetParserContext ();
-
- if (ctx == null)
- return null;
- IEnumerable<IType> classes = ctx.Types;
- if (classes == null)
- return null;
- foreach (IType cls in classes) {
- if (cls.FullName == className) {
- if (getUserClass) {
- // Return this class only if it is declared outside the gtk-gui
- // folder. Generated partial classes will be ignored.
- foreach (IType part in cls.Parts) {
- if (part.CompilationUnit.FileName.FullPath.IsChildPathOf (gui_folder))
- continue;
- if (part.CompilationUnit != null && !part.CompilationUnit.FileName.IsNullOrEmpty && !part.CompilationUnit.FileName.FileName.Contains (info.BuildFileExtension)) {
- return part;
- }
- }
- continue;
- }
- if (getUserClass && cls.CompilationUnit != null && !string.IsNullOrEmpty (cls.CompilationUnit.FileName) && cls.CompilationUnit.FileName.IsChildPathOf (gui_folder))
- continue;
- return cls;
- }
- }
- return null;
- }
-
- public ProjectDom GetParserContext ()
- {
- ProjectDom dom = ProjectDomService.GetProjectDom (Project);
- if (dom != null && needsUpdate) {
- needsUpdate = false;
- dom.ForceUpdate ();
- }
- return dom;
- }
-
- public WidgetParser WidgetParser {
- get {
- return new WidgetParser (GetParserContext ());
- }
- }
-
- public void UpdateLibraries ()
- {
- if (hasError || disposed || gproject == null)
- return;
-
- bool needsSave = false;
- librariesUpdated = true;
-
- string[] oldLibs = gproject.WidgetLibraries;
-
- ArrayList libs = new ArrayList ();
- string[] internalLibs;
-
- foreach (ProjectReference pref in project.References) {
- string wref = GetReferenceLibraryPath (pref);
- if (wref != null)
- libs.Add (wref);
- }
-
- ReferenceManager refmgr = new ReferenceManager (project);
- string target_version = refmgr.TargetGtkVersion;
- refmgr.Dispose ();
-
- // Make sure the target gtk version is properly set
- if (gproject.TargetGtkVersion != target_version) {
- if (gproject.TargetGtkVersion != string.Empty) {
- needsSave = true;
- }
- gproject.TargetGtkVersion = target_version;
- }
-
- string outLib = project.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration);
- if (!string.IsNullOrEmpty (outLib))
- internalLibs = new string [] { outLib };
- else
- internalLibs = new string [0];
-
- string[] newLibs = (string[]) libs.ToArray (typeof(string));
-
- // See if something has changed
- if (LibrariesChanged (oldLibs, internalLibs, newLibs)) {
- // If oldLibs is empty, gproject was uninitialized, so there are no changes to save
- if (oldLibs.Length > 0) {
- needsSave = true;
- }
- gproject.SetWidgetLibraries (newLibs, internalLibs);
- } else {
- GuiBuilderService.SteticApp.UpdateWidgetLibraries (false);
- }
-
- if (needsSave)
- Save (true);
- }
-
- bool LibrariesChanged (string[] oldLibs, string[] internalLibs, string[] newLibs)
- {
- if (oldLibs.Length == newLibs.Length + internalLibs.Length) {
- foreach (string s in newLibs) {
- if (!((IList)oldLibs).Contains (s))
- return true;
- }
- foreach (string s in internalLibs) {
- if (!((IList)oldLibs).Contains (s))
- return true;
- }
- return false;
- } else
- return true;
- }
-
- void NotifyChanged ()
- {
- if (Changed != null && !disposed)
- Changed (this, EventArgs.Empty);
- }
-
- public StringCollection GenerateFiles (string guiFolder)
- {
- StringCollection files = new StringCollection ();
-
- if (hasError)
- return files;
-
- IDotNetLanguageBinding binding = LanguageBindingService.GetBindingPerLanguageName (project.LanguageName) as IDotNetLanguageBinding;
- CodeDomProvider provider = binding.GetCodeDomProvider ();
-
- if (provider == null)
- throw new UserException ("Code generation not supported for language: " + project.LanguageName);
-// string path = Path.Combine (guiFolder, binding.GetFileName ("generated"));
-// if (!System.IO.File.Exists (path)) {
-// GuiBuilderService.SteticApp.GenerateProjectCode (path, "Stetic", provider, null);
-// }
-// files.Add (path);
-//
-// if (Windows != null) {
-// foreach (GuiBuilderWindow win in Windows)
-// files.Add (GuiBuilderService.GenerateSteticCodeStructure (project, win.RootWidget, true, false));
-// }
-//
-// foreach (Stetic.ActionGroupInfo ag in SteticProject.ActionGroups)
-// files.Add (GuiBuilderService.GenerateSteticCodeStructure (project, ag, true, false));
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- string extension = string.Format("{0}.{1}",info.BuildFileExtension, provider.FileExtension);
- foreach (string file in Directory.GetFiles (guiFolder)) {
- if (file.Contains (extension))
- files.Add (file);
- }
-
- return files;
- }
- }
-
- public delegate void WindowEventHandler (object s, WindowEventArgs args);
-
- public class WindowEventArgs: EventArgs
- {
- GuiBuilderWindow win;
-
- public WindowEventArgs (GuiBuilderWindow win)
- {
- this.win = win;
- }
-
- public GuiBuilderWindow Window {
- get { return win; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
deleted file mode 100644
index de0d2692ae..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
+++ /dev/null
@@ -1,635 +0,0 @@
-//
-// GuiBuilderService.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-using System.Collections;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Projects.Text;
-using MonoDevelop.Core;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Deployment;
-using MonoDevelop.Projects.Policies;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- class GuiBuilderService
- {
- static string GuiBuilderLayout = "Visual Design";
-
-#if DUMMY_STRINGS_FOR_TRANSLATION_DO_NOT_COMPILE
- private void DoNotCompile ()
- {
- //The default GUI Builder layout, translated indirectly because it's used as an ID
- GettextCatalog.GetString ("GUI Builder");
- }
-#endif
-
- static string defaultLayout;
-
- static Stetic.Application steticApp;
-
- static bool generating;
-
- static Stetic.IsolationMode IsolationMode = Stetic.IsolationMode.None;
-// static Stetic.IsolationMode IsolationMode = Stetic.IsolationMode.ProcessUnix;
-
- static GuiBuilderService ()
- {
- if (IdeApp.Workbench == null)
- return;
- IdeApp.Workbench.ActiveDocumentChanged += new EventHandler (OnActiveDocumentChanged);
- IdeApp.ProjectOperations.EndBuild += OnProjectCompiled;
-// IdeApp.Workspace.ParserDatabase.AssemblyInformationChanged += (AssemblyInformationEventHandler) DispatchService.GuiDispatch (new AssemblyInformationEventHandler (OnAssemblyInfoChanged));
-
- IdeApp.Exited += delegate {
- if (steticApp != null) {
- StoreConfiguration ();
- steticApp.Dispose ();
- }
- };
- }
-
- public static Stetic.Application SteticApp {
- get {
- // Stetic is not thread safe, so all has to be done in the gui thread
- DispatchService.AssertGuiThread ();
- if (steticApp == null) {
- steticApp = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None);
- steticApp.AllowInProcLibraries = false;
- steticApp.ShowNonContainerWarning = PropertyService.Get ("MonoDevelop.GtkCore.ShowNonContainerWarning", true);
- steticApp.MimeResolver = OnMimeResolve;
- steticApp.ShowUrl = OnShowUrl;
- steticApp.WidgetLibraryResolver = OnAssemblyResolve;
- }
- return steticApp;
- }
- }
-
- static string OnAssemblyResolve (string assemblyName)
- {
- return Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblyLocation (assemblyName, null);
- }
-
- static string OnMimeResolve (string url)
- {
- return DesktopService.GetMimeTypeForUri (url);
- }
-
- static void OnShowUrl (string url)
- {
- DesktopService.ShowUrl (url);
- }
-
- internal static void StoreConfiguration ()
- {
- PropertyService.Set ("MonoDevelop.GtkCore.ShowNonContainerWarning", steticApp.ShowNonContainerWarning);
- PropertyService.SaveProperties ();
- }
-
- public static bool AutoSwitchGuiLayout {
- get {
- return PropertyService.Get ("MonoDevelop.GtkCore.AutoSwitchGuiLayout", false);
- }
- set {
- PropertyService.Set ("MonoDevelop.GtkCore.AutoSwitchGuiLayout", value);
- }
- }
-
- public static ActionGroupView OpenActionGroup (Project project, Stetic.ActionGroupInfo group)
- {
- GuiBuilderProject p = GtkDesignInfo.FromProject (project).GuiBuilderProject ;
- string file = p != null ? p.GetSourceCodeFile (group) : null;
- if (file == null) {
- file = ActionGroupDisplayBinding.BindToClass (project, group);
- }
-
- Document doc = IdeApp.Workbench.OpenDocument (file, true);
- if (doc != null) {
- ActionGroupView view = doc.GetContent<ActionGroupView> ();
- if (view != null) {
- view.ShowDesignerView ();
- return view;
- }
- }
- return null;
- }
-
- static void OnActiveDocumentChanged (object s, EventArgs args)
- {
- if (IdeApp.Workbench.ActiveDocument == null) {
- if (SteticApp.ActiveDesigner != null) {
- SteticApp.ActiveDesigner = null;
- RestoreLayout ();
- }
- return;
- }
-
- CombinedDesignView view = IdeApp.Workbench.ActiveDocument.GetContent<CombinedDesignView> ();
- if (view != null) {
- SteticApp.ActiveDesigner = view.Designer;
- SetDesignerLayout ();
- return;
- }
- else if (SteticApp.ActiveDesigner != null) {
- SteticApp.ActiveDesigner = null;
- RestoreLayout ();
- }
- }
-
- static void SetDesignerLayout ()
- {
- if (AutoSwitchGuiLayout && IdeApp.Workbench.CurrentLayout != GuiBuilderLayout) {
- bool exists = IdeApp.Workbench.Layouts.Contains (GuiBuilderLayout);
- defaultLayout = IdeApp.Workbench.CurrentLayout;
- IdeApp.Workbench.CurrentLayout = GuiBuilderLayout;
- if (!exists) {
- Pad p = IdeApp.Workbench.GetPad<MonoDevelop.DesignerSupport.ToolboxPad> ();
- if (p != null) p.Visible = true;
- p = IdeApp.Workbench.GetPad<MonoDevelop.DesignerSupport.PropertyPad> ();
- if (p != null) p.Visible = true;
- }
- }
- }
-
- static void RestoreLayout ()
- {
- if (AutoSwitchGuiLayout && defaultLayout != null) {
- IdeApp.Workbench.CurrentLayout = defaultLayout;
- defaultLayout = null;
- }
- }
-
- static void OnProjectCompiled (object s, BuildEventArgs args)
- {
- if (args.Success) {
- // Unload stetic projects which are not currently
- // being used by the IDE. This will avoid unnecessary updates.
- if (IdeApp.Workspace.IsOpen) {
- foreach (Project prj in IdeApp.Workspace.GetAllProjects ()) {
- GtkDesignInfo info = GtkDesignInfo.FromProject (prj);
- if (!HasOpenDesigners (prj, false)) {
- info.ReloadGuiBuilderProject ();
- }
- }
- }
-
- SteticApp.UpdateWidgetLibraries (false);
- }
- else {
- // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel
- if (Runtime.SystemAssemblyService.DefaultAssemblyContext.GetPackage ("gtk-sharp-2.0") == null) {
- string msg = GettextCatalog.GetString ("ERROR: MonoDevelop could not find the Gtk# 2.0 development package. Compilation of projects depending on Gtk# libraries will fail. You may need to install development packages for gtk-sharp-2.0.");
- args.ProgressMonitor.Log.WriteLine ();
- args.ProgressMonitor.Log.WriteLine (msg);
- }
- }
- }
-
- internal static bool HasOpenDesigners (Project project, bool modifiedOnly)
- {
- foreach (Document doc in IdeApp.Workbench.Documents) {
- if ((doc.GetContent<GuiBuilderView>() != null || doc.GetContent<ActionGroupView>() != null) && doc.Project == project && (!modifiedOnly || doc.IsDirty))
- return true;
- }
- return false;
- }
-
- //static void OnAssemblyInfoChanged (object s, AssemblyInformationEventArgs args)
-// {
- //SteticApp.UpdateWidgetLibraries (false);
-// }
-
- internal static void AddCurrentWidgetToClass ()
- {
- if (IdeApp.Workbench.ActiveDocument != null) {
- GuiBuilderView view = IdeApp.Workbench.ActiveDocument.GetContent<GuiBuilderView> ();
- if (view != null)
- view.AddCurrentWidgetToClass ();
- }
- }
-
- internal static void JumpToSignalHandler (Stetic.Signal signal)
- {
- if (IdeApp.Workbench.ActiveDocument != null) {
- CombinedDesignView view = IdeApp.Workbench.ActiveDocument.GetContent<CombinedDesignView> ();
- if (view != null)
- view.JumpToSignalHandler (signal);
- }
- }
-
- public static void ImportGladeFile (Project project)
- {
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- info.GuiBuilderProject.ImportGladeFile ();
- }
-
- public static string GetBuildCodeFileName (Project project, string componentName)
- {
- return GetBuildCodeFileName (project, componentName, string.Empty);
- }
-
- public static string GetBuildCodeFileName (Project project, string componentName, string nameSpace)
- {
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- string componentFile = info.GetComponentFile (componentName);
-
- if (componentFile == null) {
- if (nameSpace == "Stetic") {
- return info.GetBuildFileInSteticFolder (componentName);
- }
-// else
-// throw new UserException ("Cannot find component file for " + componentName);
- } else
- return info.GetBuildFileFromComponent (componentFile);
-
- return null;
- }
-
- public static void GenerateSteticCodeStructure (DotNetProject project, Stetic.ProjectItemInfo item, bool saveToFile, bool overwrite)
- {
- GenerateSteticCodeStructure (project, item, null, null, saveToFile, overwrite);
- }
-
- public static void GenerateSteticCodeStructure (DotNetProject project, Stetic.Component component, Stetic.ComponentNameEventArgs args, bool saveToFile, bool overwrite)
- {
- GenerateSteticCodeStructure (project, null, component, args, saveToFile, overwrite);
- }
-
- static void GenerateSteticCodeStructure (DotNetProject project, Stetic.ProjectItemInfo item, Stetic.Component component, Stetic.ComponentNameEventArgs args, bool saveToFile, bool overwrite)
- {
- // Generate a class which contains fields for all bound widgets of the component
-
- string name = item != null ? item.Name : component.Name;
- string fileName = GetBuildCodeFileName (project, name);
- if (fileName == null)
- return;
-
- string ns = "";
- int i = name.LastIndexOf ('.');
- if (i != -1) {
- ns = name.Substring (0, i);
- name = name.Substring (i+1);
- }
-
- if (saveToFile && !overwrite && File.Exists (fileName))
- return;
-
- if (item != null)
- component = item.Component;
-
- CodeCompileUnit cu = new CodeCompileUnit ();
-
- if (project.UsePartialTypes) {
- CodeNamespace cns = new CodeNamespace (ns);
- cu.Namespaces.Add (cns);
-
- CodeTypeDeclaration type = new CodeTypeDeclaration (name);
- type.IsPartial = true;
- type.Attributes = MemberAttributes.Public;
- type.TypeAttributes = System.Reflection.TypeAttributes.Public;
- cns.Types.Add (type);
-
- foreach (Stetic.ObjectBindInfo binfo in component.GetObjectBindInfo ()) {
- // When a component is being renamed, we have to generate the
- // corresponding field using the old name, since it will be renamed
- // later using refactory
- string nname = args != null && args.NewName == binfo.Name ? args.OldName : binfo.Name;
- type.Members.Add (
- new CodeMemberField (
- binfo.TypeName,
- nname
- )
- );
- }
- }
- else {
- if (!saveToFile)
- return;
- CodeNamespace cns = new CodeNamespace ();
- cns.Comments.Add (new CodeCommentStatement ("Generated code for component " + component.Name));
- cu.Namespaces.Add (cns);
- }
-
- CodeDomProvider provider = project.LanguageBinding.GetCodeDomProvider ();
- if (provider == null)
- throw new UserException ("Code generation not supported for language: " + project.LanguageName);
-
- TextWriter fileStream;
- if (saveToFile)
- fileStream = new StreamWriter (fileName);
- else
- fileStream = new StringWriter ();
-
- try {
- provider.GenerateCodeFromCompileUnit (cu, fileStream, new CodeGeneratorOptions ());
- } finally {
- fileStream.Close ();
- }
-
- if (ProjectDomService.HasDom (project)) {
- // Only update the parser database if the project is actually loaded in the IDE.
- if (saveToFile) {
- ProjectDomService.Parse (project, fileName, "");
- FileService.NotifyFileChanged (fileName);
- }
- else
- ProjectDomService.Parse (project, fileName, ((StringWriter)fileStream).ToString ());
- }
- }
-
- public static Stetic.CodeGenerationResult GenerateSteticCode (IProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration)
- {
- if (generating || !GtkDesignInfo.HasDesignedObjects (project))
- return null;
-
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- info.CheckGtkFolder ();
-
- DateTime last_gen_time = File.Exists (info.SteticGeneratedFile) ? File.GetLastWriteTime (info.SteticGeneratedFile) : DateTime.MinValue;
-
- bool ref_changed = false;
- foreach (ProjectReference pref in project.References) {
- if (!pref.IsValid)
- continue;
- foreach (string filename in pref.GetReferencedFileNames (configuration)) {
- if (File.GetLastWriteTime (filename) > last_gen_time) {
- ref_changed = true;
- break;
- }
- }
- if (ref_changed)
- break;
- }
-
- // Check if generated code is already up to date.
-// if (!ref_changed && last_gen_time >= File.GetLastWriteTime (info.SteticFile))
-// return null;
-
- if (info.GuiBuilderProject.HasError) {
- monitor.ReportError (GettextCatalog.GetString ("GUI code generation failed for project '{0}'. The file '{1}' could not be loaded.", project.Name, info.SteticFile), null);
- monitor.AsyncOperation.Cancel ();
- return null;
- }
-
- if (info.GuiBuilderProject.IsEmpty)
- return null;
-
- monitor.Log.WriteLine (GettextCatalog.GetString ("Generating GUI code for project '{0}'...", project.Name));
-
- // Make sure the referenced assemblies are up to date. It is necessary to do
- // it now since they may contain widget libraries.
- project.CopySupportFiles (monitor, configuration);
-
- info.GuiBuilderProject.UpdateLibraries ();
-
- ArrayList projectFolders = new ArrayList ();
- projectFolders.Add (info.SteticFolder.FullPath);
-
- generating = true;
- Stetic.CodeGenerationResult generationResult = null;
- Exception generatedException = null;
-
- bool canGenerateInProcess = IsolationMode != Stetic.IsolationMode.None || info.GuiBuilderProject.SteticProject.CanGenerateCode;
-
- if (!canGenerateInProcess) {
- // Run the generation in another thread to avoid freezing the GUI
- System.Threading.ThreadPool.QueueUserWorkItem ( delegate {
- try {
- // Generate the code in another process if stetic is not isolated
- CodeGeneratorProcess cob = (CodeGeneratorProcess) Runtime.ProcessService.CreateExternalProcessObject (typeof (CodeGeneratorProcess), false);
- using (cob) {
- generationResult = cob.GenerateCode (projectFolders, info.GenerateGettext, info.GettextClass, project.UsePartialTypes, info);
- }
- } catch (Exception ex) {
- generatedException = ex;
- } finally {
- generating = false;
- }
- });
-
- while (generating) {
- DispatchService.RunPendingEvents ();
- System.Threading.Thread.Sleep (100);
- }
- } else {
- // No need to create another process, since stetic has its own backend process
- // or the widget libraries have no custom wrappers
- try {
- Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
- options.UseGettext = info.GenerateGettext;
- options.GettextClass = info.GettextClass;
- generationResult = SteticApp.GenerateProjectCode (options, info.GuiBuilderProject.SteticProject);
- } catch (Exception ex) {
- generatedException = ex;
- }
- generating = false;
- }
-
- if (generatedException != null) {
- string msg = string.Empty;
-
- if (generatedException.InnerException != null) {
- msg = string.Format("{0}\n{1}\nInner Exception {2}\n{3}",
- generatedException.Message,
- generatedException.StackTrace,
- generatedException.InnerException.Message,
- generatedException.InnerException.StackTrace);
- } else {
- msg = string.Format("{0}\n{1}",
- generatedException.Message,
- generatedException.StackTrace);
- }
-
-// LoggingService.LogError ("GUI code generation failed", generatedException);
- LoggingService.LogError ("GUI code generation failed: " + msg);
- throw new UserException ("GUI code generation failed: " + msg);
- }
-
- if (generationResult == null)
- return null;
-
- CodeDomProvider provider = project.LanguageBinding.GetCodeDomProvider ();
- if (provider == null)
- throw new UserException ("Code generation not supported for language: " + project.LanguageName);
-
- foreach (Stetic.SteticCompilationUnit unit in generationResult.Units) {
- string fname;
- if (unit.Name.Length == 0)
- fname = info.SteticGeneratedFile;
- else
- fname = GetBuildCodeFileName (project,
- unit.Name,
- (unit.Namespace != null) ? unit.Namespace.Name : string.Empty);
-
- StringWriter sw = new StringWriter ();
- try {
- foreach (CodeNamespace ns in unit.Namespaces)
- ns.Comments.Add (new CodeCommentStatement ("This file has been generated by the GUI designer. Do not modify."));
- provider.GenerateCodeFromCompileUnit (unit, sw, new CodeGeneratorOptions ());
- string content = sw.ToString ();
- content = FormatGeneratedFile (fname, content, provider);
- File.WriteAllText (fname, content);
- } finally {
- FileService.NotifyFileChanged (fname);
- }
- }
-
- // Make sure the generated files are added to the project
- if (info.UpdateGtkFolder ()) {
- Gtk.Application.Invoke (delegate {
- IdeApp.ProjectOperations.Save (project);
- });
- }
-
- return generationResult;
- }
-
- internal static string ImportFile (Project prj, string file)
- {
- ProjectFile pfile = prj.Files.GetFile (file);
- if (pfile == null) {
- var files = IdeApp.ProjectOperations.AddFilesToProject (prj, new string[] { file }, prj.BaseDirectory);
- if (files.Count == 0 || files[0] == null)
- return null;
- pfile = files [0];
- }
- if (pfile.BuildAction == BuildAction.EmbeddedResource) {
- AlertButton embedButton = new AlertButton (GettextCatalog.GetString ("_Use as Source"));
- if (MessageService.AskQuestion (GettextCatalog.GetString ("You are requesting the file '{0}' to be used as source for an image. However, this file is already added to the project as a resource. Are you sure you want to continue (the file will have to be removed from the resource list)?"), AlertButton.Cancel, embedButton) == embedButton)
- return null;
- }
- pfile.BuildAction = BuildAction.Content;
- DeployProperties props = DeployService.GetDeployProperties (pfile);
- props.UseProjectRelativePath = true;
- return pfile.FilePath;
- }
-
- static string FormatGeneratedFile (string file, string content, CodeDomProvider provider)
- {
- //TODO : Wait for a fix for Mono.TextEditor.Document in the trunk
- //content = StripHeaderAndBlankLines (content, provider);
- string mt = DesktopService.GetMimeTypeForUri (file);
- Formatter formatter = TextFileService.GetFormatter (mt);
- if (formatter != null)
- content = formatter.FormatText (PolicyService.InvariantPolicies, content);
- return content;
- }
-
- static string StripHeaderAndBlankLines (string text, CodeDomProvider provider)
- {
- Mono.TextEditor.Document doc = new Mono.TextEditor.Document ();
- doc.Text = text;
- int realStartLine = 0;
- for (int i = 0; i < doc.LineCount; i++) {
- var lineSegment = doc.GetLine (i);
- if (lineSegment == null)
- continue;
- string lineText = doc.GetTextAt (lineSegment);
- // Microsoft.NET generates "auto-generated" tags where Mono generates "autogenerated" tags.
- if (lineText.Contains ("</autofgenerated>") || lineText.Contains ("</auto-generated>")) {
- realStartLine = i + 2;
- break;
- }
- }
-
- // The Mono provider inserts additional blank lines, so strip them out
- // But blank lines might actually be significant in other languages.
- // We reformat the C# generated output to the user's coding style anyway, but the reformatter preserves blank lines
- if (provider is Microsoft.CSharp.CSharpCodeProvider) {
- bool previousWasBlank = false;
- for (int i = 0; i < doc.LineCount; i++) {
- Mono.TextEditor.LineSegment line = doc.GetLine (i);
- bool isBlank, isBracket;
- CheckLine (doc, line, out isBlank, out isBracket);
- if (isBlank && previousWasBlank && line.Length > 0) {
- ((Mono.TextEditor.IBuffer)doc).Remove (line.Offset, line.Length);
- i--;
- }
- previousWasBlank = isBlank || isBracket;
- }
- }
-
- int offset = doc.GetLine (realStartLine).Offset;
- return doc.GetTextAt (offset, doc.Length - offset);
- }
-
- static void CheckLine (Mono.TextEditor.Document doc, Mono.TextEditor.LineSegment line, out bool isBlank, out bool isBracket)
- {
- isBlank = true;
- isBracket = false;
- if (line == null)
- return;
-
- for (int i = 0; i < line.Length; i++) {
- char c = doc.GetCharAt (line.Offset + i);
- if (c == '{') {
- isBracket = true;
- isBlank = false;
- }
- else if (!Char.IsWhiteSpace (c)) {
- isBlank = false;
- if (isBracket) {
- isBracket = false;
- break;
- }
- }
- }
- }
- }
-
-
- public class CodeGeneratorProcess: RemoteProcessObject
- {
- public Stetic.CodeGenerationResult GenerateCode (ArrayList projectFolders, bool useGettext, string gettextClass, bool usePartialClasses, GtkDesignInfo info)
- {
- Gtk.Application.Init ();
-
- Stetic.Application app = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None);
-
- Stetic.Project[] projects = new Stetic.Project [projectFolders.Count];
- for (int n=0; n < projectFolders.Count; n++) {
- projects [n] = app.CreateProject (info);
- projects [n].Load ((string) projectFolders [n]);
- }
-
- Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
- options.UseGettext = useGettext;
- options.GettextClass = gettextClass;
-
- return app.GenerateProjectCode (options, projects);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs
deleted file mode 100644
index 6bff298a7c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs
+++ /dev/null
@@ -1,613 +0,0 @@
-//
-// GuiBuilderView.cs
-//
-// Author:
-// Lluis Sanchez Gual
-// Krzysztof Marecki
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System;
-using System.ComponentModel;
-
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui.Content;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Commands;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.DesignerSupport.Toolbox;
-using MonoDevelop.DesignerSupport;
-
-using Gtk;
-using Gdk;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class GuiBuilderView : CombinedDesignView, IToolboxConsumer, MonoDevelop.DesignerSupport.IOutlinedDocument, ISupportsProjectReload
- {
- Stetic.WidgetDesigner designer;
- Stetic.ActionGroupDesigner actionsBox;
- GuiBuilderWindow window;
-
- DesignerPage designerPage;
- ActionGroupPage actionsPage;
-
-
- CodeBinder codeBinder;
- GuiBuilderProject gproject;
- string rootName;
- object designerStatus;
-
- public GuiBuilderView (IViewContent content, GuiBuilderWindow window): base (content)
- {
- rootName = window.Name;
-
- designerPage = new DesignerPage ();
- designerPage.Show ();
- AddButton (GettextCatalog.GetString ("Designer"), designerPage);
-
- actionsPage = new ActionGroupPage ();
- actionsPage.Show ();
-
- AttachWindow (window);
- }
-
- void AttachWindow (GuiBuilderWindow window)
- {
- gproject = window.Project;
- GtkDesignInfo info = GtkDesignInfo.FromProject (gproject.Project);
- gproject.SteticProject.ImagesRootPath = FileService.AbsoluteToRelativePath (info.SteticFolder, gproject.Project.BaseDirectory);
- gproject.UpdateLibraries ();
- LoadDesigner ();
- }
-
- ProjectReloadCapability ISupportsProjectReload.ProjectReloadCapability {
- get {
- return ProjectReloadCapability.Full;
- }
- }
-
- void ISupportsProjectReload.Update (Project project)
- {
- if (gproject != null && gproject.Project == project)
- return;
-
- ReloadDesigner (project);
- }
-
- void LoadDesigner ()
- {
- this.window = gproject.GetWindow (rootName);
- if (window == null) {
- // The window doesn't exist anymore
- return;
- }
-
- gproject.Unloaded += OnDisposeProject;
-
- designer = gproject.SteticProject.CreateWidgetDesigner (window.RootWidget);
-
- // Designer page
- designerPage.ClearChild ();
- designerPage.Add (designer);
-
- if (designer.RootComponent == null) {
- // Something went wrong while creating the designer. Show it, but don't do aything else.
- designer.ShowAll ();
- return;
- }
-
- designer.AllowWidgetBinding = !gproject.Project.UsePartialTypes;
-
- codeBinder = new CodeBinder (gproject.Project, new OpenDocumentFileProvider (), designer.RootComponent);
-
- designer.BindField += OnBindWidgetField;
- designer.Changed += OnChanged;
- designer.SignalAdded += OnSignalAdded;
- designer.SignalRemoved += OnSignalRemoved;
- designer.SignalChanged += OnSignalChanged;
- designer.ComponentNameChanged += OnComponentNameChanged;
- designer.RootComponentChanged += OnRootComponentChanged;
- designer.ComponentTypesChanged += OnComponentTypesChanged;
- designer.ImportFileCallback = ImportFile;
-
- // Actions designer
- actionsBox = designer.CreateActionGroupDesigner ();
- actionsBox.AllowActionBinding = !gproject.Project.UsePartialTypes;
- actionsBox.BindField += new EventHandler (OnBindActionField);
- actionsBox.ModifiedChanged += new EventHandler (OnActionshanged);
-
- actionsPage.ClearChild ();
- actionsPage.PackStart (actionsBox, true, true, 0);
- actionsPage.ShowAll ();
-
- if (actionsBox.HasData) {
- if (!HasPage (actionsPage))
- AddButton (GettextCatalog.GetString ("Actions"), actionsPage);
- } else {
- RemoveButton (actionsPage);
- }
-
- designer.ShowAll ();
- GuiBuilderService.SteticApp.ActiveDesigner = designer;
- }
-
- public void ReloadDesigner (Project project)
- {
- if (designer != null)
- designerStatus = designer.SaveStatus ();
-
- CloseDesigner ();
- CloseProject ();
- if (project != null) {
- GuiBuilderWindow w = GuiBuilderDisplayBinding.GetWindow (this.ContentName);
- if (w != null) {
- AttachWindow (w);
- if (designerStatus != null)
- designer.LoadStatus (designerStatus);
- designerStatus = null;
- }
- }
- }
-
- public override Stetic.Designer Designer {
- get { return designer; }
- }
-
- void OnDisposeProject (object s, EventArgs args)
- {
- CloseDesigner ();
- }
-
- void OnReloadProject (object s, EventArgs args)
- {
- if (designer == null)
- LoadDesigner ();
- }
-
- public GuiBuilderWindow Window {
- get { return window; }
- }
-
- void CloseDesigner ()
- {
- if (designer == null)
- return;
-
- gproject.Unloaded -= OnDisposeProject;
- designer.BindField -= OnBindWidgetField;
- designer.Changed -= OnChanged;
- designer.SignalAdded -= OnSignalAdded;
- designer.SignalRemoved -= OnSignalRemoved;
- designer.SignalChanged -= OnSignalChanged;
- designer.ComponentNameChanged -= OnComponentNameChanged;
- designer.RootComponentChanged -= OnRootComponentChanged;
- designer.ComponentTypesChanged -= OnComponentTypesChanged;
-
- if (actionsBox != null) {
- actionsBox.BindField -= OnBindActionField;
- actionsBox.ModifiedChanged -= OnActionshanged;
- actionsBox = null;
- }
-
- actionsPage.ClearChild ();
- designerPage.ClearChild ();
-
- designerPage.Add (CreateDesignerNotAvailableWidget ());
- actionsPage.Add (CreateDesignerNotAvailableWidget ());
-
- designer = null;
-
- gproject.Reloaded += OnReloadProject;
- }
-
- void CloseProject ()
- {
- gproject.Reloaded -= OnReloadProject;
- }
-
- public override void Dispose ()
- {
- CloseDesigner ();
- CloseProject ();
- codeBinder = null;
- base.Dispose ();
- }
-
- Gtk.Widget CreateDesignerNotAvailableWidget ()
- {
- Gtk.Label label = new Gtk.Label (GettextCatalog.GetString ("Designer not available"));
- label.Show ();
- return label;
- }
-
- public override void ShowPage (int npage)
- {
- if (npage == 0 && designer != null && window != null && !ErrorMode) {
- // At every page switch update the generated code, to make sure code completion works
- // for the generated fields. The call to GenerateSteticCodeStructure will generate
- // the code for the window (only the fields in fact) and update the parser database, it
- // will not save the code to disk.
- if (gproject.Project.UsePartialTypes)
- GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)gproject.Project, designer.RootComponent, null, false, false);
- }
- base.ShowPage (npage);
- }
-
- string ImportFile (string file)
- {
- return GuiBuilderService.ImportFile (gproject.Project, file);
- }
-
- void OnRootComponentChanged (object s, EventArgs args)
- {
- codeBinder.TargetObject = designer.RootComponent;
- }
-
- void OnComponentNameChanged (object s, Stetic.ComponentNameEventArgs args)
- {
- try {
- // Make sure the fields in the partial class are up to date.
- // Provide the args parameter to GenerateSteticCodeStructure, in this
- // way the component that has been renamed will be generated with the
- // old name, and UpdateField will be able to find it (to rename the
- // references to the field, it needs to have the old name).
- if (gproject.Project.UsePartialTypes)
- GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)gproject.Project, designer.RootComponent, args, false, false);
-
- codeBinder.UpdateField (args.Component, args.OldName);
- }
- catch (Exception ex) {
- MessageService.ShowException (ex);
- }
- }
-
- void OnComponentTypesChanged (object s, EventArgs a)
- {
- if (ToolboxProvider.Instance != null)
- ToolboxProvider.Instance.NotifyItemsChanged ();
- }
-
- void OnActionshanged (object s, EventArgs args)
- {
- if (designer != null && !HasPage (actionsPage) && !ErrorMode)
- AddButton (GettextCatalog.GetString ("Actions"), actionsPage);
- }
-
- void OnChanged (object s, EventArgs args)
- {
- if (IsDirty)
- OnContentChanged (args);
- OnDirtyChanged (args);
- }
-
- void OnBindWidgetField (object o, EventArgs a)
- {
- if (designer.Selection != null)
- codeBinder.BindToField (designer.Selection);
- }
-
- void OnBindActionField (object o, EventArgs a)
- {
- if (actionsBox.SelectedAction != null)
- codeBinder.BindToField (actionsBox.SelectedAction);
- }
-
- void OnSignalAdded (object sender, Stetic.ComponentSignalEventArgs args)
- {
- codeBinder.BindSignal (args.Signal);
- }
-
- void OnSignalRemoved (object sender, Stetic.ComponentSignalEventArgs args)
- {
- }
-
- void OnSignalChanged (object sender, Stetic.ComponentSignalEventArgs args)
- {
- codeBinder.UpdateSignal (args.OldSignal, args.Signal);
- }
-
- public override void Save (string fileName)
- {
- base.Save (fileName);
-
- if (designer == null)
- return;
-
- string oldBuildFile = GuiBuilderService.GetBuildCodeFileName (gproject.Project, window.RootWidget.Name);
- codeBinder.UpdateBindings (fileName);
-
- if (!ErrorMode) {
- if (designer != null)
- designer.Save ();
- if (actionsBox != null)
- actionsBox.Save ();
- }
-
- string newBuildFile = GuiBuilderService.GetBuildCodeFileName (gproject.Project, window.RootWidget.Name);
-
- if (oldBuildFile != newBuildFile && oldBuildFile != null && newBuildFile != null) {
- if (System.IO.File.Exists (newBuildFile))
- FileService.DeleteFile (newBuildFile);
- if (System.IO.File.Exists (oldBuildFile))
- FileService.MoveFile (oldBuildFile, newBuildFile);
- }
-
- gproject.Save (true);
- OnDirtyChanged (EventArgs.Empty);
- }
-
- public override bool IsDirty {
- get {
- // There is no need to check if the action group designer is modified
- // since changes in the action group are as well changes in the designed widget
- return base.IsDirty || (designer != null && designer.Modified);
- }
- set {
- base.IsDirty = value;
- }
- }
-
- public override void JumpToSignalHandler (Stetic.Signal signal)
- {
- IType cls = codeBinder.GetClass ();
- if (cls == null)
- return;
- foreach (IMethod met in cls.Methods) {
- if (met.Name == signal.Handler) {
- ShowPage (0);
- JumpTo (met.Location.Line, met.Location.Column);
- break;
- }
- }
- }
-
- public void ShowDesignerView ()
- {
- if (designer != null)
- ShowPage (1);
- }
-
- public void ShowActionDesignerView (string name)
- {
- if (designer != null) {
- ShowPage (2);
- if (!ErrorMode)
- actionsBox.ActiveGroup = name;
- }
- }
-
- bool ErrorMode {
- get { return designer.RootComponent == null; }
- }
-
- public Stetic.ComponentType[] GetComponentTypes ()
- {
- if (designer != null)
- return designer.GetComponentTypes ();
- else
- return null;
- }
-
- void IToolboxConsumer.ConsumeItem (ItemToolboxNode item)
- {
- }
-
- //Toolbox service uses this to filter toolbox items.
- ToolboxItemFilterAttribute[] IToolboxConsumer.ToolboxFilterAttributes {
- get {
- return new ToolboxItemFilterAttribute [] {
- new ToolboxItemFilterAttribute ("gtk-sharp", ToolboxItemFilterType.Custom)
- };
- }
- }
-
- //Used if ToolboxItemFilterAttribute demands ToolboxItemFilterType.Custom
- //If not expecting it, should just return false
- bool IToolboxConsumer.CustomFilterSupports (ItemToolboxNode item)
- {
- ComponentToolboxNode cnode = item as ComponentToolboxNode;
- if (cnode != null && gproject.SteticProject != null) {
- if (cnode.GtkVersion == null || Mono.Addins.Addin.CompareVersions (gproject.SteticProject.TargetGtkVersion, cnode.GtkVersion) <= 0)
- return true;
- }
- return false;
- }
-
- string IToolboxConsumer.DefaultItemDomain {
- get { return ComponentToolboxNode.GtkWidgetDomain; }
- }
-
- void IToolboxConsumer.DragItem (ItemToolboxNode item, Gtk.Widget source, Gdk.DragContext ctx)
- {
- if (designer != null) {
- ComponentToolboxNode node = item as ComponentToolboxNode;
- if (node != null) {
- if (node.Reference == null)
- designer.BeginComponentDrag (node.ComponentType, source, ctx);
- else
- designer.BeginComponentDrag (node.Name, node.ClassName, source, ctx, delegate { CheckReference (node); });
- }
- }
- }
-
- void CheckReference (ComponentToolboxNode node)
- {
- if (node.Reference == null)
- return;
-
- ProjectReference pref;
-
- // If the class name includes an assembly name it means that the
- // widget is implemented in another assembly, not in the one that
- // has the objects.xml file.
- int i = node.ClassName.IndexOf (',');
- if (i != -1) {
- string asm = node.ClassName.Substring (i+1).Trim ();
- if (asm == "gtk-sharp")
- // If we are adding a widget to a window, the project must already have a gtk# reference
- return;
-
- asm = gproject.Project.AssemblyContext.GetAssemblyFullName (asm, gproject.Project.TargetFramework);
- if (asm == null)
- return;
- if (gproject.Project.AssemblyContext.GetPackagesFromFullName (asm).Length > 0) {
- pref = new ProjectReference (ReferenceType.Gac, asm);
- } else {
- asm = gproject.Project.AssemblyContext.GetAssemblyLocation (asm, gproject.Project.TargetFramework);
- pref = new ProjectReference (ReferenceType.Assembly, asm);
- }
- }
- else
- pref = new ProjectReference (node.ReferenceType, node.Reference);
-
- foreach (ProjectReference pr in gproject.Project.References) {
- if (pr.Reference == pref.Reference)
- return;
- }
- gproject.Project.References.Add (pref);
- }
-
- Widget MonoDevelop.DesignerSupport.IOutlinedDocument.GetOutlineWidget ()
- {
- return GuiBuilderDocumentOutline.Instance;
- }
-
- void MonoDevelop.DesignerSupport.IOutlinedDocument.ReleaseOutlineWidget ()
- {
- //Do nothing. We keep the instance to avoid creation cost when switching documents.
- }
-
- TargetEntry[] IToolboxConsumer.DragTargets {
- get { return Stetic.DND.Targets; }
- }
- }
-
- class DesignerPage: Gtk.EventBox, ICustomPropertyPadProvider
- {
- public DesignerPage ()
- {
- }
-
- Gtk.Widget ICustomPropertyPadProvider.GetCustomPropertyWidget ()
- {
- return PropertiesWidget.Instance;
- }
-
- void ICustomPropertyPadProvider.DisposeCustomPropertyWidget ()
- {
- }
-
- Stetic.WidgetDesigner Designer {
- get {
- return Child as Stetic.WidgetDesigner;
- }
- }
-
- public void ClearChild ()
- {
- if (Child != null) {
- Gtk.Widget w = Child;
- Remove (w);
- w.Destroy ();
- }
- }
-
- [CommandHandler (EditCommands.Delete)]
- protected void OnDelete ()
- {
- Designer.DeleteSelection ();
- }
-
- [CommandUpdateHandler (EditCommands.Delete)]
- protected void OnUpdateDelete (CommandInfo cinfo)
- {
- cinfo.Bypass = Designer != null && !Designer.CanDeleteSelection;
- }
-
- [CommandHandler (EditCommands.Copy)]
- protected void OnCopy ()
- {
- Designer.CopySelection ();
- }
-
- [CommandUpdateHandler (EditCommands.Copy)]
- protected void OnUpdateCopy (CommandInfo cinfo)
- {
- cinfo.Enabled = Designer != null && Designer.CanCopySelection;
- }
-
- [CommandHandler (EditCommands.Cut)]
- protected void OnCut ()
- {
- Designer.CutSelection ();
- }
-
- [CommandUpdateHandler (EditCommands.Cut)]
- protected void OnUpdateCut (CommandInfo cinfo)
- {
- cinfo.Enabled = Designer != null && Designer.CanCutSelection;
- }
-
- [CommandHandler (EditCommands.Paste)]
- protected void OnPaste ()
- {
- Designer.PasteToSelection ();
- }
-
- [CommandHandler (EditCommands.Undo)]
- protected void OnUndo ()
- {
- Designer.UndoQueue.Undo ();
- }
-
- [CommandHandler (EditCommands.Redo)]
- protected void OnRedo ()
- {
- Designer.UndoQueue.Redo ();
- }
-
- [CommandUpdateHandler (EditCommands.Paste)]
- protected void OnUpdatePaste (CommandInfo cinfo)
- {
- cinfo.Enabled = Designer != null && Designer.CanPasteToSelection;
- }
-
- [CommandUpdateHandler (EditCommands.Undo)]
- protected void OnUpdateUndo (CommandInfo cinfo)
- {
- cinfo.Enabled = Designer != null && Designer.UndoQueue.CanUndo;
- }
-
- [CommandUpdateHandler (EditCommands.Redo)]
- protected void OnUpdateRedo (CommandInfo cinfo)
- {
- cinfo.Enabled = Designer != null && Designer.UndoQueue.CanRedo;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs
deleted file mode 100644
index 9b4fc06ed8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs
+++ /dev/null
@@ -1,260 +0,0 @@
-//
-// GuiBuilderWindow.cs
-//
-// Author:
-// Lluis Sanchez Gual
-// Krzysztof Marecki
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.CodeDom;
-
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Projects.CodeGeneration;
-using MonoDevelop.Projects.Text;
-using MonoDevelop.GtkCore.Dialogs;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class GuiBuilderWindow: IDisposable
- {
- Stetic.WidgetInfo rootWidget;
- GuiBuilderProject fproject;
- Stetic.Project gproject;
- string name;
-
- public event WindowEventHandler Changed;
-
- internal GuiBuilderWindow (GuiBuilderProject fproject, Stetic.Project gproject, Stetic.WidgetInfo rootWidget)
- {
- this.fproject = fproject;
- this.rootWidget = rootWidget;
- this.gproject = gproject;
- name = rootWidget.Name;
- gproject.ProjectReloaded += OnProjectReloaded;
- rootWidget.Changed += OnChanged;
- }
-
- public Stetic.WidgetInfo RootWidget {
- get { return rootWidget; }
- }
-
- public GuiBuilderProject Project {
- get { return fproject; }
- }
-
- public string Name {
- get { return rootWidget.Name; }
- }
-
- public FilePath SourceCodeFile {
- get { return fproject.GetSourceCodeFile (rootWidget); }
- }
-
- public void Dispose ()
- {
- gproject.ProjectReloaded -= OnProjectReloaded;
- rootWidget.Changed -= OnChanged;
- }
-
- void OnProjectReloaded (object s, EventArgs args)
- {
- rootWidget.Changed -= OnChanged;
- rootWidget = gproject.GetWidget (name);
- if (rootWidget != null)
- rootWidget.Changed += OnChanged;
- }
-
- void OnChanged (object o, EventArgs args)
- {
- // Update the name, it may have changed
- name = rootWidget.Name;
-
- if (Changed != null)
- Changed (this, new WindowEventArgs (this));
- }
-
- public bool BindToClass ()
- {
- if (SourceCodeFile != FilePath.Null)
- return true;
-
- // Find the classes that could be bound to this design
- ProjectDom ctx = fproject.GetParserContext ();
- ArrayList list = new ArrayList ();
- foreach (IType cls in ctx.Types) {
- if (IsValidClass (ctx, cls))
- list.Add (cls.FullName);
- }
-
- // Ask what to do
-
- try {
- using (BindDesignDialog dialog = new BindDesignDialog (Name, list, Project.Project.BaseDirectory)) {
- if (!dialog.Run ())
- return false;
-
- if (dialog.CreateNew)
- CreateClass (dialog.ClassName, dialog.Namespace, dialog.Folder);
-
- string fullName = dialog.Namespace.Length > 0 ? dialog.Namespace + "." + dialog.ClassName : dialog.ClassName;
- rootWidget.Name = fullName;
- fproject.Save (true);
- }
- return true;
- } catch (Exception ex) {
- MessageService.ShowException (ex);
- return false;
- }
- }
-
- void CreateClass (string name, string namspace, string folder)
- {
- string fullName = namspace.Length > 0 ? namspace + "." + name : name;
-
- CodeRefactorer gen = new CodeRefactorer (fproject.Project.ParentSolution);
- bool partialSupport = fproject.Project.UsePartialTypes;
- Stetic.WidgetComponent component = (Stetic.WidgetComponent) rootWidget.Component;
-
- CodeTypeDeclaration type = new CodeTypeDeclaration ();
- type.Name = name;
- type.IsClass = true;
- type.IsPartial = partialSupport;
- type.BaseTypes.Add (new CodeTypeReference (component.Type.ClassName));
-
- // Generate the constructor. It contains the call that builds the widget.
-
- CodeConstructor ctor = new CodeConstructor ();
- ctor.Attributes = MemberAttributes.Public | MemberAttributes.Final;
-
- foreach (object val in component.Type.InitializationValues) {
- if (val is Enum) {
- ctor.BaseConstructorArgs.Add (
- new CodeFieldReferenceExpression (
- new CodeTypeReferenceExpression (val.GetType ()),
- val.ToString ()
- )
- );
- }
- else
- ctor.BaseConstructorArgs.Add (new CodePrimitiveExpression (val));
- }
-
- if (partialSupport) {
- CodeMethodInvokeExpression call = new CodeMethodInvokeExpression (
- new CodeMethodReferenceExpression (
- new CodeThisReferenceExpression (),
- "Build"
- )
- );
- ctor.Statements.Add (call);
- } else {
- CodeMethodInvokeExpression call = new CodeMethodInvokeExpression (
- new CodeMethodReferenceExpression (
- new CodeTypeReferenceExpression ("Stetic.Gui"),
- "Build"
- ),
- new CodeThisReferenceExpression (),
- new CodeTypeOfExpression (fullName)
- );
- ctor.Statements.Add (call);
- }
- type.Members.Add (ctor);
-
- // Add signal handlers
-
- AddSignalsRec (type, component);
- foreach (Stetic.Component ag in component.GetActionGroups ())
- AddSignalsRec (type, ag);
-
- // Create the class
- IType cls = gen.CreateClass (Project.Project, ((DotNetProject)Project.Project).LanguageName, folder, namspace, type);
- if (cls == null)
- throw new UserException ("Could not create class " + fullName);
-
- Project.Project.AddFile (cls.CompilationUnit.FileName, BuildAction.Compile);
- IdeApp.ProjectOperations.Save (Project.Project);
-
-#if TRUNK
- // Make sure the database is up-to-date
- ProjectDomService.Parse (Project.Project, cls.CompilationUnit.FileName);
-#else
- ProjectDomService.Parse (Project.Project, cls.CompilationUnit.FileName, null);
-#endif
- }
-
- void AddSignalsRec (CodeTypeDeclaration type, Stetic.Component comp)
- {
- foreach (Stetic.Signal signal in comp.GetSignals ()) {
- CodeMemberMethod met = new CodeMemberMethod ();
- met.Name = signal.Handler;
- met.Attributes = MemberAttributes.Family;
- met.ReturnType = new CodeTypeReference (signal.SignalDescriptor.HandlerReturnTypeName);
-
- foreach (Stetic.ParameterDescriptor pinfo in signal.SignalDescriptor.HandlerParameters)
- met.Parameters.Add (new CodeParameterDeclarationExpression (pinfo.TypeName, pinfo.Name));
-
- type.Members.Add (met);
- }
- foreach (Stetic.Component cc in comp.GetChildren ()) {
- AddSignalsRec (type, cc);
- }
- }
-
- internal bool IsValidClass (ProjectDom ctx, IType cls)
- {
- if (cls.BaseTypes != null) {
- foreach (IReturnType bt in cls.BaseTypes) {
- if (bt.FullName == rootWidget.Component.Type.ClassName)
- return true;
-
- IType baseCls = ctx.GetType (bt);
- if (baseCls != null && IsValidClass (ctx, baseCls))
- return true;
- }
- }
- return false;
- }
- }
-
- class OpenDocumentFileProvider: ITextFileProvider
- {
- public IEditableTextFile GetEditableTextFile (FilePath filePath)
- {
- foreach (Document doc in IdeApp.Workbench.Documents) {
- if (doc.FileName == filePath) {
- IEditableTextFile ef = doc.GetContent<IEditableTextFile> ();
- if (ef != null) return ef;
- }
- }
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/PropertiesWidget.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/PropertiesWidget.cs
deleted file mode 100644
index 6cedb0f4b2..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/PropertiesWidget.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-//
-// GuiBuilderPropertiesPad.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System;
-using Gtk;
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Ide.Commands;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- class PropertiesWidget: Gtk.VBox
- {
- public static PropertiesWidget Instance;
-
- Stetic.SignalsEditor signalsEditor;
-
- static PropertiesWidget ()
- {
- Instance = new PropertiesWidget ();
- }
-
- public PropertiesWidget ()
- {
- Stetic.WidgetPropertyTree grid = GuiBuilderService.SteticApp.PropertiesWidget;
-
- Notebook tabs = new Notebook ();
-
- tabs.AppendPage (grid, new Label (GettextCatalog.GetString ("Properties")));
-
- signalsEditor = GuiBuilderService.SteticApp.SignalsWidget;
- signalsEditor.SignalActivated += new EventHandler (OnSignalActivated);
- tabs.AppendPage (signalsEditor, new Label (GettextCatalog.GetString ("Signals")));
-
- Gtk.EventBox infoBox = new Gtk.EventBox ();
- tabs.AppendPage (infoBox, new Gtk.Label (""));
-
- PackStart (tabs, true, true, 0);
-
- ShowAll ();
- infoBox.Hide ();
-
- tabs.Page = 0;
- }
-
- void OnSignalActivated (object s, EventArgs a)
- {
- GuiBuilderService.JumpToSignalHandler (signalsEditor.SelectedSignal);
- }
- }
-
-/* public class GuiBuilderPropertiesPad: AbstractPadContent
- {
- Stetic.WidGetTree grid;
- Stetic.SignalsEditor signalsEditor;
- Gtk.EventBox infoBox;
- Gtk.Widget widget;
- Stetic.Wrapper.Action currentAction;
- Notebook tabs;
-
- public GuiBuilderPropertiesPad (): base ("")
- {
- grid = GuiBuilderService.SteticApp.PropertiesWidget;
-
- DefaultPlacement = "MonoDevelop.GtkCore.GuiBuilder.GuiBuilderPalettePad/bottom; right";
-
- tabs = new Notebook ();
-
- tabs.AppendPage (grid, new Label (GettextCatalog.GetString ("Properties")));
-
- signalsEditor = GuiBuilderService.SteticApp.SignalsWidget;
- signalsEditor.SignalActivated += new EventHandler (OnSignalActivated);
- tabs.AppendPage (signalsEditor, new Label (GettextCatalog.GetString ("Signals")));
-
- infoBox = new Gtk.EventBox ();
- tabs.AppendPage (infoBox, new Gtk.Label (""));
-
- widget = tabs;
-
- widget.ShowAll ();
- infoBox.Hide ();
-
- tabs.Page = 0;
- }
-
- public override Gtk.Widget Control {
- get { return widget; }
- }
-
- void OnSignalActivated (object s, EventArgs a)
- {
- GuiBuilderService.JumpToSignalHandler (signalsEditor.SelectedSignal);
- }
-
- public object TargetObject {
- get {
- return grid.TargetObject;
- }
- set {
- Stetic.Wrapper.Action action = Stetic.ObjectWrapper.Lookup (value) as Stetic.Wrapper.Action;
- if (action != null) {
- // Don't allow editing of global actions
- if (grid.Project != null && grid.Project.ActionGroups.IndexOf (action.ActionGroup) != -1) {
- if (infoBox.Child != null)
- infoBox.Remove (infoBox.Child);
- infoBox.Add (CreateGlobalActionInfo (action));
- infoBox.ShowAll ();
- tabs.Page = 2;
- tabs.ShowTabs = false;
- grid.Hide ();
- signalsEditor.Hide ();
- return;
- }
- }
-
- if (!grid.Visible) {
- tabs.ShowTabs = true;
- grid.Show ();
- signalsEditor.Show ();
- tabs.Page = 0;
- infoBox.Hide ();
- }
-
- grid.TargetObject = value;
- signalsEditor.TargetObject = value;
- }
- }
-
- Gtk.Widget CreateGlobalActionInfo (Stetic.Wrapper.Action action)
- {
- currentAction = action;
-
- Gtk.HBox hbox = new Gtk.HBox ();
- hbox.BorderWidth = 12;
- Gtk.Image img = new Gtk.Image (Gtk.Stock.DialogInfo, Gtk.IconSize.Menu);
- img.Yalign = 0;
- hbox.PackStart (img, false, false, 0);
-
- Gtk.VBox box = new Gtk.VBox ();
- Gtk.Label info = new Gtk.Label (GettextCatalog.GetString ("The action '{0}' belongs to the global action group '{1}'. To modify it, open the action group file.", action.MenuLabel, action.ActionGroup.Name));
- info.Xalign = 0;
- info.WidthRequest = 200;
- info.LineWrap = true;
- box.PackStart (info, false, false, 0);
-
- HBox bb = new HBox ();
- Gtk.Button but = new Gtk.Button (GettextCatalog.GetString ("Open Action Group"));
- but.Clicked += new EventHandler (OnOpenGroup);
- bb.PackStart (but, false, false, 0);
- box.PackStart (bb, false, false, 12);
-
- hbox.PackStart (box, true, true, 12);
- hbox.ShowAll ();
- return hbox;
- }
-
- void OnOpenGroup (object s, EventArgs args)
- {
- Project prj = GetProjectFromDesign (currentAction.ActionGroup);
- if (prj != null) {
- ActionGroupView view = GuiBuilderService.OpenActionGroup (prj, currentAction.ActionGroup);
- if (view != null)
- view.SelectAction (currentAction);
- }
- }
-
-
- public static Project GetProjectFromDesign (Stetic.Wrapper.ActionGroup group)
- {
- if (IdeApp.ProjectOperations.CurrentOpenCombine == null)
- return null;
-
- foreach (Project prj in IdeApp.ProjectOperations.CurrentOpenCombine.GetAllProjects ()) {
- GtkDesignInfo info = GtkCoreService.GetGtkInfo (prj);
- if (info != null && info.GuiBuilderProject != null && info.GuiBuilderProject.SteticProject.ActionGroups.IndexOf (group) != -1)
- return prj;
- }
- return null;
- }
-
- }
-*/
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs
deleted file mode 100644
index 9e62498e33..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// ToolboxLoader.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-using MonoDevelop.DesignerSupport.Toolbox;
-using MonoDevelop.Projects;
-using MonoDevelop.Core;
-using MonoDevelop.Core.Assemblies;
-using Stetic;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class ToolboxLoader: IToolboxLoader
- {
- public virtual string[] FileTypes {
- get { return new string [] { "dll", "exe" }; }
- }
-
- public virtual IList<ItemToolboxNode> Load (LoaderContext ctx, string filename)
- {
- SystemPackage sp = Runtime.SystemAssemblyService.DefaultAssemblyContext.GetPackageFromPath (filename);
- ReferenceType rt;
- string rname;
-
- if (sp != null) {
- rt = ReferenceType.Gac;
- rname = Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblyFullName (filename, null);
- } else {
- rt = ReferenceType.Assembly;
- rname = filename;
- }
-
- List<ItemToolboxNode> list = new List<ItemToolboxNode> ();
- ComponentType[] types = null;
- DispatchService.GuiSyncDispatch (delegate {
- // Stetic is not thread safe, it has to be used from the gui thread
- types = GuiBuilderService.SteticApp.GetComponentTypes (filename);
- });
- foreach (ComponentType ct in types) {
- if (ct.Category == "window")
- continue;
- ComponentToolboxNode cn = new ComponentToolboxNode (ct);
- cn.ReferenceType = rt;
- cn.Reference = rname;
- list.Add (cn);
- }
- return list;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ToolboxProvider.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ToolboxProvider.cs
deleted file mode 100644
index 9d46b89d04..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.GuiBuilder/ToolboxProvider.cs
+++ /dev/null
@@ -1,201 +0,0 @@
-
-using System;
-using System.ComponentModel;
-using System.Collections;
-using System.Collections.Generic;
-
-using MonoDevelop.DesignerSupport.Toolbox;
-using MonoDevelop.Projects;
-using MonoDevelop.Core.Serialization;
-using Stetic;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.GuiBuilder
-{
- public class ToolboxProvider: IToolboxDynamicProvider, IToolboxDefaultProvider
- {
- internal static ToolboxProvider Instance;
-
- public ToolboxProvider ()
- {
- Instance = this;
- }
-
- public IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer)
- {
- GuiBuilderView view = consumer as GuiBuilderView;
- if (view == null)
- return null;
-
- ComponentType[] types = view.GetComponentTypes ();
- if (types == null)
- return null;
-
- Hashtable refs = new Hashtable ();
- Hashtable projects = new Hashtable ();
- string of = FileService.GetFullPath (view.Project.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration));
- projects [of] = view.Project.Name;
- foreach (ProjectReference pr in ((DotNetProject)view.Project).References)
- foreach (string f in pr.GetReferencedFileNames (IdeApp.Workspace.ActiveConfiguration)) {
- if (pr.ReferenceType == ReferenceType.Project)
- projects[FileService.GetFullPath (f)] = pr.Reference;
- else
- refs[FileService.GetFullPath (f)] = f;
- }
-
- List<ItemToolboxNode> list = new List<ItemToolboxNode> ();
- foreach (ComponentType type in types) {
- if (type.Category == "window")
- continue;
-
- string fullName = null;
- if (!String.IsNullOrEmpty (type.Library))
- fullName = FileService.GetFullPath (type.Library);
-
- if (type.ClassName == "Gtk.Action" || (fullName != null && refs.Contains (fullName))) {
- ComponentToolboxNode node = new ComponentToolboxNode (type);
- list.Add (node);
- } else if (fullName != null && projects.Contains (fullName)) {
- ComponentToolboxNode node = new ComponentToolboxNode (type);
- node.Category = (string) projects [fullName];
- list.Add (node);
- }
- }
- list.Sort ();
- return list;
- }
-
- public void NotifyItemsChanged ()
- {
- if (ItemsChanged != null)
- ItemsChanged (this, EventArgs.Empty);
- }
-
- public virtual IEnumerable<ItemToolboxNode> GetDefaultItems ()
- {
- return null;
- }
-
- public virtual IEnumerable<string> GetDefaultFiles ()
- {
- yield return typeof(Stetic.Wrapper.Widget).Assembly.Location;
- }
-
- public event EventHandler ItemsChanged;
- }
-
- class ComponentToolboxNode: ItemToolboxNode
- {
- public ComponentType componentType;
-
- [ItemProperty]
- ReferenceType refType;
- [ItemProperty]
- string reference;
- [ItemProperty]
- string className;
- [ItemProperty]
- string gtkVersion;
-
- static ToolboxItemFilterAttribute[] attributes = new ToolboxItemFilterAttribute[] {
- new ToolboxItemFilterAttribute ("gtk-sharp", ToolboxItemFilterType.Require)
- };
-
- internal static readonly string GtkWidgetDomain = GettextCatalog.GetString ("GTK# Widgets");
-
- public ComponentToolboxNode ()
- {
- }
-
- public ComponentToolboxNode (ComponentType type)
- {
- if (type.Description.Length > 0)
- Name = type.Description;
- else {
- int i = type.Name.LastIndexOf ('.');
- if (i == -1)
- Name = type.Name;
- else
- Name = type.Name.Substring (i+1);
- }
-
- componentType = type;
- className = type.ClassName;
- Category = GetCategoryName (type.Category);
- Icon = type.Icon;
- gtkVersion = type.TargetGtkVersion;
- }
-
- [Browsable (false)]
- public override IList<ToolboxItemFilterAttribute> ItemFilters {
- get { return attributes; }
- }
-
- [Browsable (false)]
- public Stetic.ComponentType ComponentType {
- get {
- return componentType;
- }
- }
-
- [ReadOnly (true)]
- [LocalizedCategory ("Misc")]
- [LocalizedDisplayName ("Reference Type")]
- [LocalizedDescription ("The type of the project or assembly from which this component originates.")]
- public ReferenceType ReferenceType {
- get {
- return refType;
- }
- set {
- refType = value;
- }
- }
-
- [ReadOnly (true)]
- [LocalizedCategory ("Misc")]
- [LocalizedDisplayName ("Reference Path")]
- [LocalizedDescription ("The project or assembly from which this component originates.")]
- public string Reference {
- get {
- return reference;
- }
- set {
- reference = value;
- }
- }
-
- [LocalizedCategory ("Misc")]
- [LocalizedDisplayName ("Class Name")]
- [LocalizedDescription ("The name of the component class.")]
- public string ClassName {
- get {
- return className;
- }
- }
-
- [LocalizedCategory ("Misc")]
- [LocalizedDisplayName ("GTK# Version")]
- [LocalizedDescription ("The minimum GTK# version required to use this component.")]
- public string GtkVersion {
- get {
- return gtkVersion;
- }
- }
-
- string GetCategoryName (string cat)
- {
- if (cat == "container")
- return GettextCatalog.GetString ("Containers");
- else if (cat == "widget")
- return GettextCatalog.GetString ("Widgets");
- else
- return cat;
- }
-
- [Browsable (false)]
- public override string ItemDomain {
- get { return GtkWidgetDomain; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs
deleted file mode 100644
index 0a3436e189..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-//
-// ActionGroupNodeBuilder.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.GtkCore.GuiBuilder;
-using MonoDevelop.GtkCore.Dialogs;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.NodeBuilders
-{
- public class ActionGroupNodeBuilder: TypeNodeBuilder
- {
- public override Type CommandHandlerType {
- get { return typeof(ActionGroupCommandHandler); }
- }
-
- public override string ContextMenuAddinPath {
- get { return "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.ActionGroup"; }
- }
-
- public override Type NodeDataType {
- get { return typeof(Stetic.ActionGroupInfo); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) dataObject;
- return group.Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
- {
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) dataObject;
- label = group.Name;
- icon = ImageService.GetPixbuf ("md-gtkcore-actiongroup", Gtk.IconSize.Menu);
- }
-
- public override void OnNodeAdded (object dataObject)
- {
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) dataObject;
- group.Changed += new EventHandler (OnChanged);
- }
-
- public override void OnNodeRemoved (object dataObject)
- {
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) dataObject;
- group.Changed -= new EventHandler (OnChanged);
- }
-
- void OnChanged (object s, EventArgs a)
- {
- ITreeBuilder tb = Context.GetTreeBuilder (s);
- if (tb != null)
- tb.Update ();
- }
- }
-
- class ActionGroupCommandHandler: NodeCommandHandler
- {
- public override void ActivateItem ()
- {
- GuiBuilderWindow w = (GuiBuilderWindow) CurrentNode.GetParentDataItem (typeof(GuiBuilderWindow), false);
- if (w != null) {
- if (w.SourceCodeFile == FilePath.Null && !w.BindToClass ())
- return;
-
- Document doc = IdeApp.Workbench.OpenDocument (w.SourceCodeFile, true);
- if (doc != null) {
- GuiBuilderView view = doc.GetContent<GuiBuilderView> ();
- if (view != null)
- view.ShowActionDesignerView (((Stetic.ActionGroupInfo) CurrentNode.DataItem).Name);
- }
- }
- else {
- Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), false);
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) CurrentNode.DataItem;
- GuiBuilderService.OpenActionGroup (project, group);
- }
- }
-
- public override bool CanDeleteItem ()
- {
- // Don't allow deleting action groups local to a window
- GuiBuilderWindow w = (GuiBuilderWindow) CurrentNode.GetParentDataItem (typeof(GuiBuilderWindow), false);
- return (w == null);
- }
-
- public override void DeleteItem ()
- {
- // Don't allow deleting action groups local to a window
- GuiBuilderWindow w = (GuiBuilderWindow) CurrentNode.GetParentDataItem (typeof(GuiBuilderWindow), false);
- if (w != null)
- return;
-
- Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), false);
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) CurrentNode.DataItem;
- GuiBuilderProject gproject = GtkDesignInfo.FromProject (project).GuiBuilderProject;
- string sfile = gproject.GetSourceCodeFile (group);
-
- if (sfile != null) {
- using (ConfirmWindowDeleteDialog dialog = new ConfirmWindowDeleteDialog (group.Name, sfile, group)) {
- if (dialog.Run () == (int) Gtk.ResponseType.Yes) {
- if (dialog.DeleteFile) {
- ProjectFile file = project.GetProjectFile (sfile);
- if (file != null)
- project.Files.Remove (file);
- }
- gproject.RemoveActionGroup (group);
- gproject.Save (false);
- IdeApp.ProjectOperations.Save (project);
- }
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolder.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolder.cs
deleted file mode 100644
index 3324cee3d2..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolder.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// GuiProjectFolder.cs
-//
-// Author:
-// Krzysztof Marecki <marecki.krzysztof@gmail.com>
-//
-// Copyright (c) 2010 KrzysztofMarecki
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui.Pads.ProjectPad;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-
-namespace MonoDevelop.GtkCore.NodeBuilders
-{
- public class GuiProjectFolder : ProjectFolder
- {
- public GuiProjectFolder (FilePath absolutePath, IWorkspaceObject parentWorkspaceObject, object parent)
- : base (absolutePath, parentWorkspaceObject, parent)
- {
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolderNodeBuilder.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolderNodeBuilder.cs
deleted file mode 100644
index a5e9b46dec..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolderNodeBuilder.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-//
-// GuiProjectFolderNodeBuilder.cs
-//
-// Author:
-// Krzysztof Marecki <marecki.krzysztof@gmail.com>
-//
-// Copyright (c) 2010 KrzysztofMarecki
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-using System;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Commands;
-using MonoDevelop.Ide;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Components;
-using MonoDevelop.Ide.Gui.Pads.ProjectPad;
-using MonoDevelop.Projects;
-
-using MonoDevelop.GtkCore.GuiBuilder;
-
-namespace MonoDevelop.GtkCore.NodeBuilders
-{
- public class GuiProjectFolderNodeBuilder : ProjectFolderNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(GuiProjectFolder); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(GuiProjectFolderCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- //nodes are sorted alphabetically and we want to have gui folder on the top
- return string.Empty;
- }
-
-
- public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
- {
- GuiProjectFolder folder = (GuiProjectFolder) dataObject;
-
- icon = Context.GetIcon (Stock.OpenResourceFolder);
- closedIcon = Context.GetIcon (Stock.ClosedResourceFolder);
- label = folder.Name;
- }
- }
-
- public class GuiProjectFolderCommandHandler : ProjectFolderCommandHandler
- {
- [CommandHandler (GtkCommands.ImportGladeFile)]
- protected void OnImportGladeFile ()
- {
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
- GuiBuilderService.ImportGladeFile (project);
- }
-
- [CommandUpdateHandler (GtkCommands.ImportGladeFile)]
- protected void UpdateImportGladeFile (CommandInfo cinfo)
- {
- cinfo.Visible = CanAddWindow ();
- }
-
- [CommandHandler (GtkCommands.EditIcons)]
- protected void OnEditIcons ()
- {
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
- GuiBuilderProject gp = GtkDesignInfo.FromProject (project).GuiBuilderProject;
- Stetic.Project sp = gp.SteticProject;
- sp.EditIcons ();
- gp.Save (true);
- }
-
- [CommandUpdateHandler (GtkCommands.EditIcons)]
- protected void UpdateEditIcons (CommandInfo cinfo)
- {
- cinfo.Visible = CanAddWindow ();
- }
-
- [CommandHandler (GtkCommands.GtkSettings)]
- protected void OnGtkSettings ()
- {
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
- IdeApp.ProjectOperations.ShowOptions (project, "SteticOptionsPanel");
- }
-
- [CommandUpdateHandler (GtkCommands.EditIcons)]
- protected void UpdateGtkSettings (CommandInfo cinfo)
- {
- cinfo.Visible = CanAddWindow ();
- }
-
- [CommandUpdateHandler (EditCommands.Delete)]
- [CommandUpdateHandler (EditCommands.Rename)]
- [CommandUpdateHandler (ProjectCommands.AddNewFiles)]
- [CommandUpdateHandler (ProjectCommands.AddFiles)]
- [CommandUpdateHandler (ProjectCommands.AddSolutionFolder)]
- [CommandUpdateHandler (ProjectCommands.AddItem)]
- [CommandUpdateHandler (ProjectCommands.NewFolder)]
- [CommandUpdateHandler ("MonoDevelop.Refactoring.RefactoryCommands.Rename")]
- protected void UpdateDisabledCommands (CommandInfo cinfo)
- {
- cinfo.Visible = false;
- cinfo.Enabled = false;
- }
-
- bool CanAddWindow ()
- {
- DotNetProject project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
- return GtkDesignInfo.SupportsDesigner (project);
- }
-
- public override DragOperation CanDragNode ()
- {
- return DragOperation.None;
- }
-
- public override bool CanDeleteItem ()
- {
- return false;
- }
-
- public override bool CanDropMultipleNodes (object[] dataObjects, DragOperation operation)
- {
- return false;
- }
-
- public override bool CanDropMultipleNodes (object[] dataObjects, DragOperation operation, DropPosition position)
- {
- return false;
- }
-
- public override bool CanDeleteMultipleItems ()
- {
- return false;
- }
-
- public override bool CanDropNode (object dataObject, DragOperation operation)
- {
- return false;
- }
-
- public override bool CanDropNode (object dataObject, DragOperation operation, DropPosition position)
- {
- return false;
- }
-
- public override void RenameItem (string newName)
- {
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- info.SteticFolderName = newName;
-
- base.RenameItem (newName);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs
deleted file mode 100644
index 9919981679..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using MonoDevelop.GtkCore.GuiBuilder;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-
-namespace MonoDevelop.GtkCore.NodeBuilders
-{
- public enum GtkComponentType
- {
- Dialog,
- Widget,
- ActionGroup,
- IconFactory,
- None
- }
-
- public static class ProjectFileExtension
- {
- public static bool IsComponentFile (this ProjectFile pf)
- {
- return pf.GetComponentType () != GtkComponentType.None;
- }
-
- public static GtkComponentType GetComponentType (this ProjectFile pf)
- {
- GtkDesignInfo info = GtkDesignInfo.FromProject (pf.Project);
- ParsedDocument doc = ProjectDomService.GetParsedDocument (ProjectDomService.GetProjectDom (pf.Project), pf.Name);
- //ParsedDocument doc = ProjectDomService.ParseFile (ProjectDomService.GetProjectDom (pf.Project), pf.FilePath.ToString ());
- if (doc != null && doc.CompilationUnit != null) {
- foreach (IType t in doc.CompilationUnit.Types) {
- string className = t.FullName;
- if (className != null) {
- GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass (className);
- if (win != null)
- return win.RootWidget.IsWindow ? GtkComponentType.Dialog : GtkComponentType.Widget;
-
- Stetic.ActionGroupInfo action = info.GuiBuilderProject.GetActionGroup (className);
- if (action != null)
- return GtkComponentType.ActionGroup;
-
- }
- }
- }
- if (pf.Name.Contains ("IconFactory.gtkx"))
- return GtkComponentType.IconFactory;
-
- return GtkComponentType.None;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs
deleted file mode 100644
index 8e449efcd1..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs
+++ /dev/null
@@ -1,179 +0,0 @@
-using System;
-
-using MonoDevelop.Components.Commands;
-using MonoDevelop.GtkCore.GuiBuilder;
-using MonoDevelop.Ide;
-using MonoDevelop.Ide.Commands;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Components;
-using MonoDevelop.Ide.Gui.Content;
-using MonoDevelop.Ide.Gui.Pads.ProjectPad;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-
-namespace MonoDevelop.GtkCore.NodeBuilders
-{
- public class ProjectFileBuilder : ProjectFileNodeBuilder
- {
-
- }
-
- public class ProjectFileNodeBuilderExtension : NodeBuilderExtension
- {
- public override bool CanBuildNode (Type dataType)
- {
- return typeof(ProjectFile).IsAssignableFrom (dataType);
- }
-
- public override Type CommandHandlerType {
- get { return typeof (ComponentCommandHandler); }
- }
-
- public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
- {
- if (treeNavigator.Options ["ShowAllFiles"])
- return;
-
- ProjectFile pf = (ProjectFile) dataObject;
- GtkDesignInfo info = GtkDesignInfo.FromProject (pf.Project);
- //Designer files in the designer folder like IconFactory.gtkx should be always visible
- if (info.HideGtkxFiles &&
- pf.FilePath.Extension == ".gtkx" &&
- !pf.FilePath.IsChildPathOf (info.SteticFolder))
- attributes |= NodeAttributes.Hidden;
- }
-
-
- public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
- {
- ProjectFile pf = (ProjectFile) dataObject;
-
- //do not show custom icon for generated source files
- if (pf.DependsOn == null) {
- GtkComponentType type = pf.GetComponentType ();
-
- switch (type) {
- case GtkComponentType.Dialog :
- icon = ImageService.GetPixbuf ("md-gtkcore-dialog", Gtk.IconSize.Menu);
- break;
- case GtkComponentType.Widget :
- icon = ImageService.GetPixbuf ("md-gtkcore-widget", Gtk.IconSize.Menu);
- break;
- case GtkComponentType.ActionGroup :
- icon = ImageService.GetPixbuf ("md-gtkcore-actiongroup", Gtk.IconSize.Menu);
- break;
- case GtkComponentType.IconFactory :
- icon = ImageService.GetPixbuf ("md-gtkcore-iconfactory", Gtk.IconSize.Menu);
- label = "Stock icons";
- break;
- }
- }
- }
-
- //override
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return base.HasChildNodes (builder, dataObject);
- }
- }
-
- public class ComponentCommandHandler : NodeCommandHandler
- {
- /*public override void ActivateItem ()
- {
- ProjectFile pf = (ProjectFile) CurrentNode.DataItem;
-
- if (pf.IsComponentFile ()) {
- Document doc = IdeApp.Workbench.OpenDocument (pf.FilePath, true);
-
- if (doc != null) {
- GuiBuilderView view = doc.GetContent<GuiBuilderView> ();
- if (view != null) {
- GtkComponentType type = pf.GetComponentType ();
-
- switch (type) {
- case GtkComponentType.Dialog :
- case GtkComponentType.Widget :
- view.ShowDesignerView ();
- break;
- case GtkComponentType.ActionGroup :
- view.ShowActionDesignerView (((Stetic.ActionGroupInfo) CurrentNode.DataItem).Name);
- break;
- }
- }
- }
- return;
- }
- base.ActivateItem ();
- }
- */
-
- [CommandHandler (GtkCommands.GenerateCode)]
- protected void OnGenerateCode ()
- {
- ProjectFile pf = CurrentNode.DataItem as ProjectFile;
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- GuiBuilderProject gproject = info.GuiBuilderProject;
-
- gproject.GenerateCode (pf.FilePath);
- }
-
- [CommandHandler (GtkCommands.ReloadDesigner)]
- protected void OnReloadDesigner ()
- {
- ProjectFile pf = CurrentNode.DataItem as ProjectFile;
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- GuiBuilderProject gproject = info.GuiBuilderProject;
-
- Document doc = IdeApp.Workbench.GetDocument (pf.FilePath);
- if (doc != null) {
- gproject.ReloadFile(pf.FilePath);
- GuiBuilderView view = doc.ActiveView as GuiBuilderView;
- if (view != null)
- view.ReloadDesigner (project);
- }
- }
-
- [CommandUpdateHandler (GtkCommands.GenerateCode)]
- [CommandUpdateHandler (GtkCommands.ReloadDesigner)]
- protected void UpdateGenerateCode (CommandInfo cinfo)
- {
- ProjectFile pf = CurrentNode.DataItem as ProjectFile;
-
- if (pf.DependsOn == null && pf.HasChildren)
- cinfo.Visible = pf.IsComponentFile ();
- else
- cinfo.Visible = false;
- }
-
- [CommandUpdateHandler (EditCommands.Copy)]
- [CommandUpdateHandler (EditCommands.Delete)]
- [CommandUpdateHandler (EditCommands.Rename)]
- protected void UpdateDisabledCommands (CommandInfo cinfo)
- {
- //disable operations for generated files in designer folder
- cinfo.Visible = false;//(CurrentNode.GetParentDataItem (typeof (GuiProjectFolder), true) == null);
- }
-
- public override DragOperation CanDragNode ()
- {
- return DragOperation.None;
- }
-
- public override void RenameItem (string newName)
- {
- base.RenameItem (newName);
-
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
- if (project != null) {
- ProjectFile pf = CurrentNode.DataItem as ProjectFile;
- if (pf.IsComponentFile ()) {
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- info.RenameComponentFile (pf);
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs
deleted file mode 100644
index 6a20ae85de..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs
+++ /dev/null
@@ -1,156 +0,0 @@
-//
-// ProjectFolderNodeBuilderExtension.cs
-//
-// Author:
-// Lluis Sanchez Gual, Krzysztof Marecki
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2010 Krzysztof Marecki
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-using System;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Pads.ProjectPad;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.GtkCore.GuiBuilder;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Components;
-using MonoDevelop.Ide;
-using MonoDevelop.Ide.Commands;
-
-namespace MonoDevelop.GtkCore.NodeBuilders
-{
- class ProjectFolderNodeBuilderExtension: NodeBuilderExtension
- {
- public override bool CanBuildNode (Type dataType)
- {
- return typeof(ProjectFolder).IsAssignableFrom (dataType) && !(dataType is GuiProjectFolder);
- }
-
- public override Type CommandHandlerType {
- get { return typeof(UserInterfaceCommandHandler); }
- }
-
- public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
- {
- if (dataObject is GuiProjectFolder)
- return;
-
- ProjectFolder folder = dataObject as ProjectFolder;
- if (folder != null && folder.Project is DotNetProject) {
- GtkDesignInfo info = GtkDesignInfo.FromProject (folder.Project);
- if (info.SteticFolder == folder.Path)
- attributes |= NodeAttributes.Hidden;
- }
- }
- }
-
- class UserInterfaceCommandHandler: NodeCommandHandler
- {
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewDialog)]
- public void AddNewDialogToProject()
- {
- AddNewWindow ("DialogFileTemplate");
- }
-
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewDialog)]
- public void UpdateAddNewDialogToProject (CommandInfo cinfo)
- {
- cinfo.Visible = CanAddWindow () && !(CurrentNode.DataItem is GuiProjectFolder);
- }
-
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWindow)]
- public void AddNewWindowToProject()
- {
- AddNewWindow ("WindowFileTemplate");
- }
-
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWindow)]
- public void UpdateAddNewWindowToProject (CommandInfo cinfo)
- {
- cinfo.Visible = CanAddWindow () && !(CurrentNode.DataItem is GuiProjectFolder);
- }
-
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWidget)]
- public void AddNewWidgetToProject()
- {
- AddNewWindow ("WidgetFileTemplate");
- }
-
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWidget)]
- public void UpdateAddNewWidgetToProject (CommandInfo cinfo)
- {
- cinfo.Visible = CanAddWindow () && !(CurrentNode.DataItem is GuiProjectFolder);
- }
-
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewActionGroup)]
- public void AddNewActionGroupToProject()
- {
- AddNewWindow ("ActionGroupFileTemplate");
- }
-
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewActionGroup)]
- public void UpdateAddNewActionGroupToProject(CommandInfo cinfo)
- {
- cinfo.Visible = CanAddWindow () && !(CurrentNode.DataItem is GuiProjectFolder);
- }
-
- public override bool CanDropMultipleNodes (object[] dataObjects, DragOperation operation, DropPosition position)
- {
- foreach (object dataObject in dataObjects)
- if (dataObjects is GuiProjectFolder)
- return false;
-
- return base.CanDropMultipleNodes (dataObjects, operation, position);
- }
-
- bool CanAddWindow ()
- {
- DotNetProject project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
- return GtkDesignInfo.SupportsDesigner (project);
- }
-
- public void AddNewWindow (string id)
- {
- DotNetProject project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
- if (project == null)
- return;
-
- object dataItem = CurrentNode.DataItem;
-
- ProjectFolder folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder;
- id = "Partial" + id;
-
- string path;
- if (folder != null)
- path = folder.Path;
- else
- path = project.BaseDirectory;
-
- IdeApp.ProjectOperations.CreateProjectFile (project, path, id);
- IdeApp.ProjectOperations.Save (project);
-
- ITreeNavigator nav = Tree.GetNodeAtObject (dataItem);
- if (nav != null)
- nav.Expanded = true;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs
deleted file mode 100644
index 20de8ff9f4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-//
-// ProjectNodeBuilder.cs
-//
-// Author:
-// Lluis Sanchez Gual, Krzysztof Marecki
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2010 Krzysztof Marecki
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-using System;
-using System.Collections;
-using System.IO;
-
-using Gtk;
-
-using MonoDevelop.Projects;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Components;
-using MonoDevelop.Ide.Gui.Pads.ProjectPad;
-using MonoDevelop.GtkCore.Dialogs;
-using MonoDevelop.GtkCore.GuiBuilder;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore.NodeBuilders
-{
- public class ProjectNodeBuilder: NodeBuilderExtension
- {
- static ProjectNodeBuilder instance;
-
- public override bool CanBuildNode (Type dataType)
- {
- return typeof(DotNetProject).IsAssignableFrom (dataType);
- }
-
- public override Type CommandHandlerType {
- get {
- return typeof (UserInterfaceCommandHandler);
- }
- }
-
- protected override void Initialize ()
- {
- lock (typeof (ProjectNodeBuilder))
- instance = this;
- }
-
- public override void Dispose ()
- {
- lock (typeof (ProjectNodeBuilder))
- instance = null;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
- {
- Project project = dataObject as Project;
-
- if (project is DotNetProject) {
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-
- if (info.NeedsConversion) {
- ProjectConversionDialog dialog = new ProjectConversionDialog (project, info.SteticFolderName);
-
- try
- {
- if (dialog.Run () == (int)ResponseType.Yes) {
- info.GuiBuilderProject.Convert (dialog.GuiFolderName, dialog.MakeBackup);
- IdeApp.ProjectOperations.Save (project);
- }
- } finally {
- dialog.Destroy ();
- }
- }
-
- project.FileAddedToProject += HandleProjectFileAddedToProject;
- }
- }
-
- void HandleProjectFileAddedToProject (object sender, ProjectFileEventArgs e)
- {
- Project project = e.Project;
- ProjectFile pf = e.ProjectFile;
- string fileName = pf.FilePath.FullPath.ToString ();
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-
- string buildFile = info.GetBuildFileFromComponent (fileName);
- if (!project.IsFileInProject(buildFile) && File.Exists (buildFile)) {
- ProjectFile pf2 = project.AddFile (buildFile, BuildAction.Compile);
- pf2.DependsOn = pf.FilePath.FileName;
- }
-
- string gtkxFile = info.GetDesignerFileFromComponent (fileName);
- if (!project.IsFileInProject(gtkxFile) && File.Exists (gtkxFile)) {
- ProjectFile pf3 = project.AddFile (gtkxFile, BuildAction.EmbeddedResource);
- pf3.DependsOn = pf.FilePath.FileName;
- }
- }
-
- public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
- {
- Project project = (Project)dataObject;
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-
- if (GtkDesignInfo.HasDesignedObjects (project)) {
- GuiProjectFolder folder = new GuiProjectFolder(info.SteticFolder.FullPath, project, null);
- builder.AddChild (folder);
- }
- }
-
- public static void OnSupportChanged (Project p)
- {
- if (instance == null)
- return;
-
- ITreeBuilder tb = instance.Context.GetTreeBuilder (p);
- if (tb != null)
- tb.UpdateAll ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs
deleted file mode 100644
index 862112d5ff..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-
-using System;
-using Gdk;
-
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.GtkCore.GuiBuilder;
-using MonoDevelop.Ide.Gui.Components;
-
-namespace MonoDevelop.GtkCore.NodeBuilders
-{
- class StockIconsNode
- {
- public StockIconsNode (Project project)
- {
- this.Project = project;
- }
-
- public Project Project;
- }
-
- public class StockIconsNodeBuilder: TypeNodeBuilder
- {
- Pixbuf iconsIcon;
-
- public override Type NodeDataType {
- get { return typeof(StockIconsNode); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(StockIconsNodeCommandHandler); }
- }
-
- public override string ContextMenuAddinPath {
- get { return "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.StockIcons"; }
- }
- public StockIconsNodeBuilder ()
- {
- try {
- iconsIcon = Pixbuf.LoadFromResource ("image-x-generic.png");
- } catch (Exception e) {
- Console.WriteLine ("Error while loading pixbuf 'image-x-generic.png': " + e);
- }
- }
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- return -1;
- }
-
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return "StockIcons";
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Pixbuf icon, ref Pixbuf closedIcon)
- {
- label = GettextCatalog.GetString ("Stock Icons");
- icon = iconsIcon;
- }
- }
-
- public class StockIconsNodeCommandHandler: NodeCommandHandler
- {
- public override void ActivateItem ()
- {
- StockIconsNode node = (StockIconsNode) CurrentNode.DataItem;
- GtkDesignInfo info = GtkDesignInfo.FromProject (node.Project);
- GuiBuilderProject gp = info.GuiBuilderProject;
- Stetic.Project sp = gp.SteticProject;
- sp.ImagesRootPath = FileService.AbsoluteToRelativePath (info.SteticFolder, gp.Project.BaseDirectory);
- sp.ImportFileCallback = delegate (string file) {
- return GuiBuilderService.ImportFile (gp.Project, file);
- };
- sp.EditIcons ();
- gp.Save (true);
- }
-
- [CommandHandler (GtkCommands.EditIcons)]
- protected void OnEditIcons ()
- {
- ActivateItem ();
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/Counters.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/Counters.cs
deleted file mode 100644
index 970caa63d0..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/Counters.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Counters.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using MonoDevelop.Core.Instrumentation;
-
-namespace MonoDevelop.GtkCore
-{
- internal static class Counters
- {
- public static Counter GuiProjectsInMemory = InstrumentationService.CreateCounter ("GUI Projects in Memory", "GTK# Designer");
- public static Counter GuiProjectsLoaded = InstrumentationService.CreateCounter ("GUI Projects Loaded", "GTK# Designer");
- public static Counter SteticProjectsLoaded = InstrumentationService.CreateCounter ("Stetic Projects Loaded", "GTK# Designer");
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/GtkCoreService.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/GtkCoreService.cs
deleted file mode 100644
index ce3bf3268a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/GtkCoreService.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// GtkCoreService.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-using MonoDevelop.Core;
-using MonoDevelop.Components.Commands;
-
-namespace MonoDevelop.GtkCore
-{
- class GtkCoreStartupCommand: CommandHandler
- {
- protected override void Run()
- {
- ReferenceManager.Initialize ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/GtkDesignInfo.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/GtkDesignInfo.cs
deleted file mode 100644
index 1a5d790644..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/GtkDesignInfo.cs
+++ /dev/null
@@ -1,676 +0,0 @@
-//
-// GtkDesignInfo.cs
-//
-// Authors:
-// Lluis Sanchez Gual
-// Mike Kestner
-// Krzysztof Marecki
-//
-// Copyright (C) 2006-2008 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2010 Krzysztof Marecki
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.CodeGeneration;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Core.Serialization;
-using MonoDevelop.GtkCore.GuiBuilder;
-using MonoDevelop.GtkCore.NodeBuilders;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore
-{
- public class GtkDesignInfo: IDisposable, Stetic.IProjectDesignInfo
- {
- DotNetProject project;
- GuiBuilderProject builderProject;
- IDotNetLanguageBinding binding;
- ProjectResourceProvider resourceProvider;
- ReferenceManager referenceManager;
- string langExtension;
-
- [ItemProperty (DefaultValue = true)]
- bool generateGettext = true;
-
- [ItemProperty (DefaultValue = "Mono.Unix.Catalog")]
- string gettextClass = "Mono.Unix.Catalog";
-
- [ItemProperty (DefaultValue = "Designer")]
- string steticFolderName = "Designer";
-
- [ItemProperty (DefaultValue = true)]
- bool hideGtkxFiles = true;
-
- GtkDesignInfo ()
- {
- }
-
- GtkDesignInfo (DotNetProject project)
- {
- IExtendedDataItem item = (IExtendedDataItem) project;
- item.ExtendedProperties ["GtkDesignInfo"] = this;
- Project = project;
- }
-
- DotNetProject Project {
- get { return project; }
- set {
- if (project == value)
- return;
-
- if (project != null) {
- project.FileAddedToProject -= OnFileEvent;
- project.FileChangedInProject -= OnFileEvent;
- project.FileRemovedFromProject -= OnFileEvent;
- binding = null;
- if (referenceManager != null)
- referenceManager.Dispose ();
- referenceManager = null;
- }
- project = value;
-
- if (project != null) {
- binding = LanguageBindingService.GetBindingPerLanguageName (project.LanguageName) as IDotNetLanguageBinding;
-
- CodeDomProvider provider = binding.GetCodeDomProvider ();
- if (provider == null)
- throw new UserException ("Code generation not supported for language: " + project.LanguageName);
- langExtension = "." + provider.FileExtension;
-
- project.FileAddedToProject += OnFileEvent;
- project.FileChangedInProject += OnFileEvent;
- project.FileRemovedFromProject += OnFileEvent;
- }
- }
- }
-
- void OnFileEvent (object o, ProjectFileEventArgs args)
- {
- if (!IdeApp.Workspace.IsOpen || !File.Exists (ObjectsFile))
- return;
-
- UpdateObjectsFile ();
- }
-
- public void Dispose ()
- {
- if (resourceProvider != null)
- System.Runtime.Remoting.RemotingServices.Disconnect (resourceProvider);
- resourceProvider = null;
- if (builderProject != null)
- builderProject.Dispose ();
- builderProject = null;
- if (referenceManager != null)
- referenceManager.Dispose ();
- referenceManager = null;
- Project = null;
- }
-
- public GuiBuilderProject GuiBuilderProject {
- get {
- if (builderProject == null) {
- if (SupportsDesigner (project)) {
- builderProject = new GuiBuilderProject (project, SteticFolder.FullPath.FullPath);
- } else
- builderProject = new GuiBuilderProject (project, null);
- }
- return builderProject;
- }
- }
-
- public ReferenceManager ReferenceManager {
- get {
- if (referenceManager == null)
- referenceManager = new ReferenceManager (project);
- return referenceManager;
- }
- }
-
- public void ReloadGuiBuilderProject ()
- {
- if (builderProject != null)
- builderProject.Reload ();
- }
-
- public ProjectResourceProvider ResourceProvider {
- get {
- if (resourceProvider == null) {
- resourceProvider = new ProjectResourceProvider (project);
- System.Runtime.Remoting.RemotingServices.Marshal (resourceProvider, null, typeof(Stetic.IResourceProvider));
- }
- return resourceProvider;
- }
- }
-
- public bool NeedsConversion {
- get { return project.IsFileInProject (SteticFile); }
- }
-
- FilePath ObjectsFile {
- get { return SteticFolder.Combine ("objects.xml"); }
- }
-
- [Obsolete]
- public FilePath SteticGeneratedFile {
- get { return SteticFolder.Combine (binding.GetFileName ("generated")); }
- }
-
- [Obsolete]
- public FilePath SteticFile {
- get { return SteticFolder.Combine ("gui.stetic"); }
- }
-
- public string BuildFileExtension {
- get { return ".designer"; }
- }
-
- public string DesignerFileExtension {
- get { return ".gtkx"; }
- }
-
- public FilePath SteticFolder {
- get {
- FilePath oldfolder = project.BaseDirectory.Combine ("gtk-gui");
- if (Directory.Exists (oldfolder))
- return oldfolder;
-
- return project.BaseDirectory.Combine (steticFolderName);
- }
- }
-
- public bool GenerateGettext {
- get { return generateGettext; }
- set {
- generateGettext = value;
- // Set to default value if gettext is not enabled
- if (!generateGettext)
- gettextClass = "Mono.Unix.Catalog";
- }
- }
-
- public string GettextClass {
- get { return gettextClass; }
- set { gettextClass = value; }
- }
-
- public string SteticFolderName {
- get { return steticFolderName; }
- set { steticFolderName = value; }
- }
-
- public bool HideGtkxFiles {
- get { return hideGtkxFiles; }
- set { hideGtkxFiles = value; }
- }
-
- public static bool HasDesignedObjects (Project project)
- {
- if (project == null)
- return false;
-
- return SupportsDesigner (project);
- }
-
- public static bool SupportsDesigner (Project project)
- {
- DotNetProject dnp = project as DotNetProject;
- return dnp != null && HasGtkReference (dnp) && SupportsRefactoring (dnp);
- }
-
- public static bool SupportsRefactoring (DotNetProject project)
- {
- if (project == null || project.LanguageBinding == null || project.LanguageBinding.GetCodeDomProvider () == null)
- return false;
- RefactorOperations ops = RefactorOperations.AddField | RefactorOperations.AddMethod | RefactorOperations.RenameField | RefactorOperations.AddAttribute;
- CodeRefactorer cref = IdeApp.Workspace.GetCodeRefactorer (project.ParentSolution);
- return cref.LanguageSupportsOperation (project.LanguageBinding.Language, ops);
- }
-
- static bool IsGtkReference (ProjectReference pref)
- {
- if (pref.ReferenceType != ReferenceType.Gac)
- return false;
-
- int idx = pref.StoredReference.IndexOf (",");
- if (idx == -1)
- return false;
-
- string name = pref.StoredReference.Substring (0, idx).Trim ();
- return name == "gtk-sharp";
- }
-
- static bool HasGtkReference (DotNetProject project)
- {
- foreach (ProjectReference pref in project.References)
- if (IsGtkReference (pref))
- return true;
- return false;
- }
-
- public void ForceCodeGenerationOnBuild ()
- {
- if (!SupportsDesigner (project))
- return;
- try {
- FileInfo fi = new FileInfo (SteticFile);
- fi.LastWriteTime = DateTime.Now;
- project.SetNeedsBuilding (true);
- } catch {
- // Ignore errors here
- }
- }
-
- public void CheckGtkFolder ()
- {
- foreach (string designerFile in GetDesignerFiles ()) {
- string componentFile = GetComponentFileFromDesigner (designerFile);
- if (componentFile != null) {
- string buildFile = GetBuildFileFromComponent (componentFile);
- if (buildFile != null) {
- // if build file is missing, force to generate it again
- if ((project.GetProjectFile (buildFile) == null) || !File.Exists (buildFile)) {
- FileInfo fi = new FileInfo (designerFile);
- fi.LastWriteTime = DateTime.Now;
- }
- }
- }
- }
- }
-
- bool CleanGtkFolder (StringCollection remaining_files)
- {
- bool projectModified = false;
- // Remove all project files which are not in the generated list
- foreach (ProjectFile pf in project.Files.GetFilesInPath (SteticFolder)) {
- if (remaining_files.Contains (pf.FilePath))
- continue;
-
- project.Files.Remove (pf);
- FileService.DeleteFile (pf.FilePath);
- projectModified = true;
- }
-
- if (remaining_files.Count == 0)
- FileService.DeleteDirectory (SteticFolder);
-
- return projectModified;
- }
-
- public void ConvertGtkFolder (string guiFolderName, bool makeBackup)
- {
- foreach (ProjectFile pf in project.Files.GetFilesInPath (SteticFolder)) {
- FilePath path = pf.FilePath;
-
- if (path != SteticGeneratedFile) {
- project.Files.Remove (path);
-
- if (path != SteticFile)
- FileService.DeleteFile (path.FullPath);
- }
- }
-
- string oldGuiFolder = SteticFolder.FullPath;
- string oldSteticFile = SteticFile;
- string oldGeneratedFile = SteticGeneratedFile;
- SteticFolderName = guiFolderName;
-
- if (!Directory.Exists (SteticFolder))
- FileService.CreateDirectory (SteticFolder);
-
- if (makeBackup && File.Exists (oldSteticFile)) {
- string backupFile = SteticFolder.Combine ("old.stetic");
- FileService.MoveFile (oldSteticFile, backupFile);
- }
-
- if (File.Exists (oldGeneratedFile))
- FileService.DeleteFile (oldGeneratedFile);
-
- if (Directory.Exists (oldGuiFolder))
- FileService.DeleteDirectory (oldGuiFolder);
- }
-
- public bool UpdateGtkFolder ()
- {
- if (!SupportsDesigner (project))
- return false;
-
- // This method synchronizes the current gtk project configuration info
- // with the needed support files in the gtk-gui folder.
-
- FileService.CreateDirectory (SteticFolder);
- bool projectModified = false;
-
- foreach (string filename in GetDesignerFiles ()) {
- ProjectFile pf = project.AddFile (filename, BuildAction.EmbeddedResource);
- pf.ResourceId = Path.GetFileName (filename);
-
- string componentFile = GetComponentFileFromDesigner (filename);
-
- if (componentFile != null && File.Exists (componentFile)) {
- pf.DependsOn = componentFile;
-
- string buildFile = GetBuildFileFromComponent (componentFile);
- if (buildFile != null && File.Exists (buildFile)) {
- ProjectFile pf2 = project.AddFile (buildFile, BuildAction.Compile);
- pf2.ResourceId = Path.GetFileName (buildFile);
- pf2.DependsOn = componentFile;
- }
- }
-
- projectModified = true;
- }
-
- StringCollection files = GuiBuilderProject.GenerateFiles (SteticFolder);
- foreach (string filename in files) {
- if (!project.IsFileInProject (filename)) {
- project.AddFile (filename, BuildAction.Compile);
- projectModified = true;
- }
-
- }
-
- UpdateObjectsFile ();
-
- return ReferenceManager.Update () || projectModified;
- }
-
-// public bool UpdateGtkFolder ()
-// {
-// if (!SupportsDesigner (project))
-// return false;
-//
-// // This method synchronizes the current gtk project configuration info
-// // with the needed support files in the gtk-gui folder.
-//
-// FileService.CreateDirectory (GtkGuiFolder);
-// bool projectModified = false;
-// bool initialGeneration = false;
-//
-// if (!File.Exists (SteticFile)) {
-// initialGeneration = true;
-// StreamWriter sw = new StreamWriter (SteticFile);
-// sw.WriteLine ("<stetic-interface />");
-// sw.Close ();
-// FileService.NotifyFileChanged (SteticFile);
-// }
-//
-// if (!project.IsFileInProject (SteticFile)) {
-// ProjectFile pf = project.AddFile (SteticFile, BuildAction.EmbeddedResource);
-// pf.ResourceId = "gui.stetic";
-// projectModified = true;
-// }
-//
-// StringCollection files = GuiBuilderProject.GenerateFiles (GtkGuiFolder);
-// DateTime generatedTime = File.GetLastWriteTime (SteticFile).Subtract (TimeSpan.FromSeconds (2));
-//
-// foreach (string filename in files) {
-// if (initialGeneration) {
-// // Ensure that the generation date of this file is < the date of the .stetic file
-// // In this way the code will be properly regenerated when building the project.
-// File.SetLastWriteTime (filename, generatedTime);
-// }
-// if (!project.IsFileInProject (filename)) {
-// project.AddFile (filename, BuildAction.Compile);
-// projectModified = true;
-// }
-// }
-//
-// UpdateObjectsFile ();
-// files.Add (ObjectsFile);
-// files.Add (SteticFile);
-//
-// if (CleanGtkFolder (files))
-// projectModified = true;
-//
-// return ReferenceManager.Update () || projectModified;
-// return true;
-// }
-
- public void RenameComponentFile (ProjectFile pfComponent)
- {
- foreach (ProjectFile pf in pfComponent.DependentChildren) {
- if (pf.FilePath.FileName.Contains (BuildFileExtension)) {
- FileService.RenameFile (pf.FilePath,
- GetBuildFileNameFromComponent (pfComponent.FilePath));
- }
- if (pf.FilePath.FileName.Contains (DesignerFileExtension)) {
- FileService.RenameFile (pf.FilePath,
- GetDesignerFileNameFromComponent (pfComponent.FilePath));
- }
- }
- }
-
- public string GetComponentFile (string componentName)
- {
- IType type = GuiBuilderProject.FindClass (componentName);
- if (type != null) {
- foreach (IType part in type.Parts) {
- string componentFile = part.CompilationUnit.FileName.FullPath;
- if (componentFile.Contains (BuildFileExtension))
- componentFile = componentFile.Replace (BuildFileExtension, string.Empty);
-
- return componentFile;
- }
- }
-
- //If ProjectDom does not exist, assume that project is being created
- //and return component file path that is located in the project root folder
- ProjectDom ctx = ProjectDomService.GetProjectDom (project);
- if (ctx == null) {
- string componentFile = Path.Combine (project.BaseDirectory, componentName + langExtension);
- if (File.Exists (componentFile))
- return componentFile;
- }
-
- return null;
- }
-
- public string GetBuildFileInSteticFolder (string componentName)
- {
- string name = string.Format ("{0}{1}{2}", componentName, BuildFileExtension, langExtension);
- string buildFile = Path.Combine (SteticFolder, name);
-
- return buildFile;
- }
-
- public string GetBuildFileFromComponent (string componentFile)
- {
- if (componentFile != null) {
- ProjectFile pf = project.Files.GetFile (componentFile);
- if (pf != null) {
- foreach (var child in pf.DependentChildren) {
- if (child.Name.Contains (BuildFileExtension))
- return child.FilePath;
- }
- }
- return GetBuildFileNameFromComponent (componentFile);
- }
- return null;
- }
-
- public string GetBuildFileNameFromComponent (string componentFile)
- {
- string buildFile = componentFile.Replace
- (langExtension, BuildFileExtension + langExtension);
- return buildFile;
- }
-
- public string GetDesignerFileFromComponent (string componentFile)
- {
- if (componentFile != null) {
- ProjectFile pf = project.Files.GetFile (componentFile);
- if (pf != null) {
- foreach (var child in pf.DependentChildren) {
- if (child.Name.Contains (DesignerFileExtension))
- return child.FilePath;
- }
- }
- return GetDesignerFileNameFromComponent (componentFile);
- }
- return null;
- }
-
- public string GetDesignerFileNameFromComponent (string componentFile)
- {
- string gtkxFile = componentFile.Replace (langExtension, DesignerFileExtension);
- return gtkxFile;
- }
-
- public string GetComponentFileFromDesigner (string gtkxFile)
- {
- if (gtkxFile != null) {
- ProjectFile pf = project.Files.GetFile (gtkxFile);
- if (pf != null) {
- if (pf.DependsOn != null)
- return pf.DependsOn;
- }
- string componentFile = gtkxFile.Replace (DesignerFileExtension, langExtension);
- return componentFile;
- }
-
- return null;
- }
-
-// public string GetBuildFileFromDesigner (string gtkxFile)
-// {
-// string buildFile = gtkxFile.Replace (DesignerFileExtension, BuildFileExtension + langExtension);
-// return buildFile;
-// }
-
-
- public string GetComponentFolder (string componentName)
- {
- IType type = GuiBuilderProject.FindClass (componentName);
-
- if (type != null) {
- FilePath folder = type.CompilationUnit.FileName.ParentDirectory;
- return folder.FullPath.ToString ();
- }
-
- return null;
- }
-
- public string[] GetComponentFolders ()
- {
- List<string> folders = new List<string> ();
- ProjectDom ctx = GuiBuilderProject.GetParserContext ();
-
- if (ctx != null) {
- foreach (IType type in ctx.Types)
- foreach (IType part in type.Parts) {
- FilePath folder = part.CompilationUnit.FileName.ParentDirectory;
- string folderName = folder.FullPath.ToString ();
-
- if (!folders.Contains (folderName))
- folders.Add (folder);
- }
- }
-
- return folders.ToArray ();
- }
-
- public string[] GetDesignerFiles ()
- {
- List<string> files = new List<string> ();
-
- foreach (string folder in GetComponentFolders ()) {
- DirectoryInfo dir = new DirectoryInfo (folder);
-
- foreach (FileInfo file in dir.GetFiles ())
- if (file.Extension == DesignerFileExtension)
- files.Add (file.ToString ());
- }
-
- return files.ToArray ();
- }
-
- public bool HasComponentFile (string componentName)
- {
- return (GetComponentFile (componentName) != null);
- }
-
- public bool ComponentNeedsCodeGeneration (string componentName)
- {
- string componentFile = GetComponentFile (componentName);
- string gtkxFile = GetDesignerFileFromComponent (componentFile);
- string buildFile = GetBuildFileFromComponent (componentFile);
- FileInfo gtkxFileInfo = File.Exists (gtkxFile) ? new FileInfo (gtkxFile) : null;
- FileInfo buildFileInfo = File.Exists (buildFile) ? new FileInfo (buildFile) : null;
- if (gtkxFileInfo == null)
- return false;
- //file does not exist
- if (buildFileInfo == null)
- return true;
-
- return gtkxFileInfo.LastWriteTime > buildFileInfo.LastWriteTime;
- }
-
- void UpdateObjectsFile ()
- {
- if (!File.Exists (ObjectsFile))
- return;
-
- ObjectsDocument doc = new ObjectsDocument (ObjectsFile);
- doc.Update (GuiBuilderProject.WidgetParser, GuiBuilderProject.SteticProject, IdeApp.Workspace.GetCodeRefactorer (project.ParentSolution));
- }
-
- public static void DisableProject (Project project)
- {
- if (HasDesignedObjects (project))
- return;
-
- GtkDesignInfo info = FromProject (project);
- StringCollection saveFiles = new StringCollection ();
- saveFiles.AddRange (new string[] {info.ObjectsFile, info.SteticFile});
- info.CleanGtkFolder (saveFiles);
- project.Files.Remove (info.ObjectsFile);
- project.Files.Remove (info.SteticFile);
- IExtendedDataItem item = (IExtendedDataItem) project;
- item.ExtendedProperties.Remove ("GtkDesignInfo");
- info.Dispose ();
- ProjectNodeBuilder.OnSupportChanged (project);
- }
-
- public static GtkDesignInfo FromProject (Project project)
- {
- if (!(project is DotNetProject))
- return new GtkDesignInfo ();
-
- IExtendedDataItem item = (IExtendedDataItem) project;
- GtkDesignInfo info = item.ExtendedProperties ["GtkDesignInfo"] as GtkDesignInfo;
- if (info == null)
- info = new GtkDesignInfo ((DotNetProject) project);
- else
- info.Project = (DotNetProject) project;
- return info;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ObjectsDocument.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ObjectsDocument.cs
deleted file mode 100644
index 90e7deb7be..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ObjectsDocument.cs
+++ /dev/null
@@ -1,301 +0,0 @@
-//
-// ObjectsDocument.cs
-//
-// Authors:
-// Lluis Sanchez Gual
-// Mike Kestner
-//
-// Copyright (C) 2006-2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Xml;
-using System.CodeDom;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.CodeGeneration;
-
-namespace MonoDevelop.GtkCore
-{
-
-
- public class ObjectsDocument : XmlDocument
- {
- string path;
-
- public ObjectsDocument (string path) : base ()
- {
- this.path = path;
- Load (path);
- }
-
- public StringCollection ObjectNames {
- get {
- StringCollection names = new StringCollection ();
- foreach (XmlNode node in DocumentElement) {
- if (node.Name != "object")
- continue;
- XmlElement elem = node as XmlElement;
- names.Add (elem.GetAttribute ("type"));
- }
- return names;
- }
- }
-
- enum SyncState
- {
- Unspecified,
- Off,
- On,
- }
-
- SyncState AttrSyncState {
- get {
- if (DocumentElement.HasAttribute ("attr-sync")) {
- if (DocumentElement.GetAttribute ("attr-sync").ToLower () == "off")
- return SyncState.Off;
- else
- return SyncState.On;
- } else
- return SyncState.Unspecified;
- }
- set {
- switch (value) {
- case SyncState.Unspecified:
- DocumentElement.RemoveAttribute ("attr-sync");
- break;
- case SyncState.Off:
- DocumentElement.SetAttribute ("attr-sync", "off");
- break;
- case SyncState.On:
- DocumentElement.SetAttribute ("attr-sync", "on");
- break;
- default:
- throw new ArgumentOutOfRangeException ("value");
- }
- Save ();
- }
- }
-
- public void Save ()
- {
- Save (path);
- }
-
- void InsertToolboxItemAttributes (WidgetParser parser, CodeRefactorer cref)
- {
- Dictionary<string, IType> tb_items = parser.GetToolboxItems ();
- foreach (string clsname in ObjectNames) {
- if (tb_items.ContainsKey (clsname))
- continue;
-
- IType cls = parser.GetClass (clsname);
- if (cls == null)
- continue;
-
- cref.AddAttribute (cls, "System.ComponentModel.ToolboxItem", true);
- XmlElement elem = DocumentElement.SelectSingleNode ("object[@type='" + clsname + "']") as XmlElement;
- if (elem != null && elem.HasAttribute ("palette-category"))
- cref.AddAttribute (cls, "System.ComponentModel.Category", elem.GetAttribute ("palette-category"));
- }
- }
-
- public void Update (WidgetParser parser, Stetic.Project stetic, CodeRefactorer refactorer)
- {
- if (AttrSyncState == SyncState.Unspecified) {
- if (refactorer != null) {
- InsertToolboxItemAttributes (parser, refactorer);
- AttrSyncState = SyncState.On;
- }
- return;
- } else if (AttrSyncState == SyncState.Off)
- return;
-
- StringCollection tb_names = new StringCollection ();
- foreach (IType cls in parser.GetToolboxItems().Values) {
- UpdateClass (parser, stetic, cls, null);
- tb_names.Add (cls.FullName);
- }
-
- List<XmlElement> toDelete = new List<XmlElement> ();
-
- foreach (XmlElement elem in SelectNodes ("objects/object")) {
- string name = elem.GetAttribute ("type");
- if (!tb_names.Contains (name))
- toDelete.Add (elem);
- }
-
- foreach (XmlElement elem in toDelete)
- elem.ParentNode.RemoveChild (elem);
-
- Save ();
- }
-
- void UpdateClass (WidgetParser parser, Stetic.Project stetic, IType widgetClass, IType wrapperClass)
- {
- string typeName = widgetClass.FullName;
- string basetypeName = GetBaseType (parser, widgetClass, stetic);
- XmlElement objectElem = (XmlElement) SelectSingleNode ("objects/object[@type='" + typeName + "']");
-
- if (objectElem == null) {
-
- // The widget class is not yet in the XML file. Create an element for it.
- objectElem = CreateElement ("object");
- objectElem.SetAttribute ("type", typeName);
- string category = parser.GetCategory (widgetClass);
- if (category == String.Empty)
- objectElem.SetAttribute ("palette-category", "General");
- else
- objectElem.SetAttribute ("palette-category", category);
- objectElem.SetAttribute ("allow-children", "false");
- if (wrapperClass != null)
- objectElem.SetAttribute ("wrapper", wrapperClass.FullName);
-
- // By default add a reference to Gtk.Widget properties and events
- XmlElement itemGroups = objectElem.OwnerDocument.CreateElement ("itemgroups");
- objectElem.AppendChild (itemGroups);
-
- itemGroups = objectElem.OwnerDocument.CreateElement ("signals");
- objectElem.AppendChild (itemGroups);
-
- objectElem.SetAttribute ("base-type", basetypeName);
- DocumentElement.AppendChild (objectElem);
- }
-
- UpdateObject (parser, basetypeName, objectElem, widgetClass, wrapperClass);
- }
-
- string GetBaseType (WidgetParser parser, IType widgetClass, Stetic.Project stetic)
- {
- string[] types = stetic.GetWidgetTypes ();
- Hashtable typesHash = new Hashtable ();
- foreach (string t in types)
- typesHash [t] = t;
-
- string ret = parser.GetBaseType (widgetClass, typesHash);
- return ret ?? "Gtk.Widget";
- }
-
- void UpdateObject (WidgetParser parser, string topType, XmlElement objectElem, IType widgetClass, IType wrapperClass)
- {
- if (widgetClass.IsPublic)
- objectElem.RemoveAttribute ("internal");
- else
- objectElem.SetAttribute ("internal", "true");
-
- ListDictionary properties = new ListDictionary ();
- ListDictionary events = new ListDictionary ();
-
- parser.CollectMembers (widgetClass, true, topType, properties, events);
- if (wrapperClass != null)
- parser.CollectMembers (wrapperClass, false, null, properties, events);
-
- foreach (IProperty prop in properties.Values)
- MergeProperty (parser, objectElem, prop);
-
- foreach (IEvent ev in events.Values)
- MergeEvent (parser, objectElem, ev);
-
- // Remove old properties
- ArrayList toDelete = new ArrayList ();
- foreach (XmlElement xprop in objectElem.SelectNodes ("itemgroups/itemgroup/property")) {
- if (!properties.Contains (xprop.GetAttribute ("name")))
- toDelete.Add (xprop);
- }
-
- // Remove old signals
- foreach (XmlElement xevent in objectElem.SelectNodes ("signals/itemgroup/signal")) {
- if (!events.Contains (xevent.GetAttribute ("name")))
- toDelete.Add (xevent);
- }
-
- foreach (XmlElement el in toDelete) {
- XmlElement pe = (XmlElement) el.ParentNode;
- pe.RemoveChild (el);
- if (pe.ChildNodes.Count == 0)
- pe.ParentNode.RemoveChild (pe);
- }
- }
-
- void MergeProperty (WidgetParser parser, XmlElement objectElem, IProperty prop)
- {
- XmlElement itemGroups = objectElem ["itemgroups"];
- if (itemGroups == null) {
- itemGroups = objectElem.OwnerDocument.CreateElement ("itemgroups");
- objectElem.AppendChild (itemGroups);
- }
-
- string cat = parser.GetCategory (prop);
- XmlElement itemGroup = GetItemGroup (prop.DeclaringType, itemGroups, cat, "Properties");
-
- XmlElement propElem = (XmlElement) itemGroup.SelectSingleNode ("property[@name='" + prop.Name + "']");
- if (propElem == null) {
- propElem = itemGroup.OwnerDocument.CreateElement ("property");
- propElem.SetAttribute ("name", prop.Name);
- itemGroup.AppendChild (propElem);
- }
- }
-
- void MergeEvent (WidgetParser parser, XmlElement objectElem, IEvent evnt)
- {
- XmlElement itemGroups = objectElem ["signals"];
- if (itemGroups == null) {
- itemGroups = objectElem.OwnerDocument.CreateElement ("signals");
- objectElem.AppendChild (itemGroups);
- }
-
- string cat = parser.GetCategory (evnt);
- XmlElement itemGroup = GetItemGroup (evnt.DeclaringType, itemGroups, cat, "Signals");
-
- XmlElement signalElem = (XmlElement) itemGroup.SelectSingleNode ("signal[@name='" + evnt.Name + "']");
- if (signalElem == null) {
- signalElem = itemGroup.OwnerDocument.CreateElement ("signal");
- signalElem.SetAttribute ("name", evnt.Name);
- itemGroup.AppendChild (signalElem);
- }
- }
-
- XmlElement GetItemGroup (IType cls, XmlElement itemGroups, string cat, string groupName)
- {
- XmlElement itemGroup;
-
- if (cat != "")
- itemGroup = (XmlElement) itemGroups.SelectSingleNode ("itemgroup[@name='" + cat + "']");
- else
- itemGroup = (XmlElement) itemGroups.SelectSingleNode ("itemgroup[(not(@name) or @name='') and not(@ref)]");
-
- if (itemGroup == null) {
- itemGroup = itemGroups.OwnerDocument.CreateElement ("itemgroup");
- if (cat != null && cat != "") {
- itemGroup.SetAttribute ("name", cat);
- itemGroup.SetAttribute ("label", cat);
- } else
- itemGroup.SetAttribute ("label", cls.Name + " " + groupName);
- itemGroups.AppendChild (itemGroup);
- }
- return itemGroup;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ProjectResourceProvider.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ProjectResourceProvider.cs
deleted file mode 100644
index e1c46517d8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ProjectResourceProvider.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-// ProjectResourceProvider.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.IO;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore
-{
- public class ProjectResourceProvider: MarshalByRefObject, Stetic.IResourceProvider
- {
- Project project;
-
- public ProjectResourceProvider (Project project)
- {
- this.project = project;
- }
-
- public Stetic.ResourceInfo[] GetResources ()
- {
- ArrayList list = new ArrayList ();
- foreach (ProjectFile file in project.Files) {
- if (file.BuildAction == BuildAction.EmbeddedResource)
- list.Add (new Stetic.ResourceInfo (file.ResourceId, file.Name, DesktopService.GetMimeTypeForUri (file.Name)));
- }
- return (Stetic.ResourceInfo[]) list.ToArray (typeof(Stetic.ResourceInfo));
- }
-
- public Stream GetResourceStream (string resourceName)
- {
- foreach (ProjectFile file in project.Files) {
- if (resourceName == file.ResourceId)
- return File.OpenRead (file.Name);
- }
- return null;
- }
-
- public Stetic.ResourceInfo AddResource (string fileName)
- {
- ProjectFile file = project.AddFile (fileName, BuildAction.EmbeddedResource);
- IdeApp.ProjectOperations.Save (project);
- return new Stetic.ResourceInfo (file.ResourceId, fileName);
- }
-
- public void RemoveResource (string resourceName)
- {
- foreach (ProjectFile file in project.Files) {
- if (resourceName == file.ResourceId) {
- project.Files.Remove (file);
- IdeApp.ProjectOperations.Save (project);
- return;
- }
- }
- }
-
- public override object InitializeLifetimeService ()
- {
- return null;
- }
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ReferenceManager.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ReferenceManager.cs
deleted file mode 100644
index 920df75a88..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/ReferenceManager.cs
+++ /dev/null
@@ -1,291 +0,0 @@
-// ReferenceManager.cs
-//
-// Author: Mike Kestner <mkestner@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-using System;
-using System.Collections.Generic;
-
-using MonoDevelop.Core;
-using MonoDevelop.Core.Assemblies;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore {
-
- public class ReferenceManager : IDisposable {
-
- DotNetProject project;
-
- public ReferenceManager (DotNetProject project)
- {
- this.project = project;
- project.AssemblyContext.Changed += ResetSupportedVersions;
- }
-
- public void Dispose ()
- {
- project.AssemblyContext.Changed -= ResetSupportedVersions;
- project = null;
- }
-
- void ResetSupportedVersions (object o, EventArgs a)
- {
- supported_versions = null;
- }
-
- string CurrentAssemblyVersion {
- get {
- foreach (ProjectReference pref in project.References) {
- if (!IsGtkReference (pref))
- continue;
- string val = pref.StoredReference;
- int idx = val.IndexOf (",") + 1;
- return val.Substring (idx).Trim ();
- }
- return String.Empty;
- }
- }
-
- public string GtkPackageVersion {
- get { return GetGtkPackageVersion (CurrentAssemblyVersion); }
- set {
- if (String.IsNullOrEmpty (value))
- throw new ArgumentException ("value");
-
- Update (GetGtkAssemblyVersion (value));
- }
- }
-
- public string TargetGtkVersion {
- get {
- string assm_version = CurrentAssemblyVersion;
- if (String.IsNullOrEmpty (assm_version))
- return String.Empty;
- int idx = assm_version.IndexOf (",");
- if (idx > 0)
- assm_version = assm_version.Substring (0, idx);
- idx = assm_version.IndexOf ("=");
- if (idx > 0)
- assm_version = assm_version.Substring (idx + 1);
- string[] toks = assm_version.Split ('.');
- if (toks.Length > 1)
- return toks[0] + "." + toks[1];
- return String.Empty;
- }
- }
-
- string GetGtkAssemblyVersion (string pkg_version)
- {
- if (String.IsNullOrEmpty (pkg_version))
- return String.Empty;
-
- pkg_version = pkg_version + ".";
- foreach (SystemAssembly asm in project.AssemblyContext.GetAssemblies ()) {
- if (asm.Name == "gtk-sharp" && asm.Version.StartsWith (pkg_version)) {
- int i = asm.FullName.IndexOf (',');
- return asm.FullName.Substring (i+1).Trim ();
- }
- }
- return string.Empty;
- }
-
- string GetGtkPackageVersion (string assembly_version)
- {
- if (String.IsNullOrEmpty (assembly_version))
- return String.Empty;
-
- return GetVersionPrefix (assembly_version);
- }
-
- public bool Update ()
- {
- return Update (CurrentAssemblyVersion);
- }
-
- bool Update (string assm_version)
- {
- if (assm_version == null)
- throw new ArgumentException (assm_version);
-
- bool changed = false;
- updating = true;
-
- bool gdk = false, gtk = false, posix = false;
-
- foreach (ProjectReference r in new List<ProjectReference> (project.References)) {
- if (r.ReferenceType != ReferenceType.Gac)
- continue;
- string name = GetReferenceName (r);
- if (name == "gdk-sharp")
- gdk = true;
- if (name == "gtk-sharp")
- gtk = true;
- else if (name == "Mono.Posix")
- posix = true;
-
- // Is a gtk-sharp-2.0 assembly?
- if (Array.IndexOf (gnome_assemblies, name) == -1)
- continue;
-
- string sr = r.StoredReference;
- string version = sr.Substring (sr.IndexOf (",") + 1).Trim ();
- if (version != assm_version) {
- project.References.Remove (r);
- if (name == "gnome-sharp" && assm_version == "Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f") {
- project.References.Add (new ProjectReference (ReferenceType.Gac, name + ", Version=2.24.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"));
- } else {
- project.References.Add (new ProjectReference (ReferenceType.Gac, name + ", " + assm_version));
- }
- changed = true;
- }
- }
-
- if (!gtk) {
- project.References.Add (new ProjectReference (ReferenceType.Gac, "gtk-sharp" + ", " + assm_version));
- changed = true;
- }
-
- if (!GtkDesignInfo.HasDesignedObjects (project))
- return changed;
-
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- if (!gdk) {
- project.References.Add (new ProjectReference (ReferenceType.Gac, "gdk-sharp" + ", " + assm_version));
- changed = true;
- }
-
- if (!posix && info.GenerateGettext && info.GettextClass == "Mono.Unix.Catalog") {
- // Add a reference to Mono.Posix. Use the version for the selected project's runtime version.
- string aname = project.AssemblyContext.FindInstalledAssembly ("Mono.Posix, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756", null, project.TargetFramework);
- aname = project.AssemblyContext.GetAssemblyNameForVersion (aname, project.TargetFramework);
- project.References.Add (new ProjectReference (ReferenceType.Gac, aname));
- changed = true;
- }
- updating = false;
- return changed;
- }
-
- static bool updating;
- static string[] gnome_assemblies = new string [] {
- "art-sharp", "atk-sharp", "gconf-sharp", "gdk-sharp",
- "glade-sharp","glib-sharp", "gnome-sharp",
- "gnome-vfs-sharp", "gtk-dotnet", "gtkhtml-sharp",
- "gtk-sharp", "pango-sharp", "rsvg-sharp"
- };
-
- public static void Initialize ()
- {
- IdeApp.Workspace.ReferenceAddedToProject += OnReferenceAdded;
- IdeApp.Workspace.ReferenceRemovedFromProject += OnReferenceRemoved;
- }
-
- static void OnReferenceAdded (object o, ProjectReferenceEventArgs args)
- {
- if (updating || !IsGtkReference (args.ProjectReference))
- return;
-
- string sr = args.ProjectReference.StoredReference;
- string version = sr.Substring (sr.IndexOf (",") + 1).Trim ();
- ReferenceManager rm = new ReferenceManager (args.Project as DotNetProject);
- rm.Update (version);
- }
-
- static void OnReferenceRemoved (object o, ProjectReferenceEventArgs args)
- {
- if (updating || !IsGtkReference (args.ProjectReference))
- return;
-
- DotNetProject dnp = args.Project as DotNetProject;
-
- if (MessageService.Confirm (GettextCatalog.GetString ("The Gtk# User Interface designer will be disabled by removing the gtk-sharp reference."), new AlertButton (GettextCatalog.GetString ("Disable Designer"))))
- GtkDesignInfo.DisableProject (dnp);
- else
- dnp.References.Add (new ProjectReference (ReferenceType.Gac, args.ProjectReference.StoredReference));
- }
-
- static string GetReferenceName (ProjectReference pref)
- {
- string stored = pref.StoredReference;
- int idx =stored.IndexOf (",");
- if (idx == -1)
- return stored.Trim ();
-
- return stored.Substring (0, idx).Trim ();
- }
-
- static bool IsGtkReference (ProjectReference pref)
- {
- if (pref.ReferenceType != ReferenceType.Gac)
- return false;
-
- return GetReferenceName (pref) == "gtk-sharp";
- }
-
- public static bool HasGtkReference (DotNetProject project)
- {
- foreach (ProjectReference pref in project.References)
- if (IsGtkReference (pref))
- return true;
- return false;
- }
-
- List<string> supported_versions;
- string default_version;
-
- public string DefaultGtkVersion {
- get {
- if (SupportedGtkVersions.Count > 0 && default_version == null)
- default_version = SupportedGtkVersions [0];
- return default_version;
- }
- }
-
- public List<string> SupportedGtkVersions {
- get {
- if (supported_versions == null) {
- supported_versions = new List<string> ();
- foreach (SystemAssembly asm in project.AssemblyContext.GetAssemblies ()) {
- if (asm.Name == "gtk-sharp") {
- string v = GetVersionPrefix (asm.Version);
- if (!supported_versions.Contains (v))
- supported_versions.Add (v);
- if (v == "2.8")
- default_version = v;
- }
- }
- supported_versions.Sort ();
- }
- return supported_versions;
- }
- }
-
- string GetVersionPrefix (string version)
- {
- int i = version.IndexOf ('.');
- i = version.IndexOf ('.', i + 1);
- return version.Substring (0, i);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs
deleted file mode 100644
index abb9198654..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs
+++ /dev/null
@@ -1,172 +0,0 @@
-//
-// WidgetFileDescriptionTemplate.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System;
-using System.Xml;
-using System.IO;
-
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Ide.Templates;
-using MonoDevelop.GtkCore.GuiBuilder;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.GtkCore
-{
- public class WidgetFileDescriptionTemplate: FileDescriptionTemplate
- {
- SingleFileDescriptionTemplate fileTemplate;
- XmlElement steticTemplate;
-
- public override string Name {
- get { return "Widget"; }
- }
-#if TRUNK
- public override void Load (XmlElement filenode, FilePath baseDirectory)
- {
- foreach (XmlNode node in filenode.ChildNodes) {
- XmlElement elem = node as XmlElement;
- if (elem == null) continue;
-
- if (elem.Name == "SteticTemplate") {
- if (steticTemplate != null)
- throw new InvalidOperationException ("Widget templates can't contain more than one SteticTemplate element");
- steticTemplate = elem;
- } else if (fileTemplate == null) {
- fileTemplate = FileDescriptionTemplate.CreateTemplate (elem, baseDirectory) as SingleFileDescriptionTemplate;
- if (fileTemplate == null)
- throw new InvalidOperationException ("Widget templates can only contain single-file and stetic templates.");
- }
- }
- if (fileTemplate == null)
- throw new InvalidOperationException ("File template not found in widget template.");
- if (steticTemplate == null)
- throw new InvalidOperationException ("Stetic template not found in widget template.");
- }
-#else
- public override void Load (XmlElement filenode)
- {
- foreach (XmlNode node in filenode.ChildNodes) {
- XmlElement elem = node as XmlElement;
- if (elem == null) continue;
-
- if (elem.Name == "SteticTemplate") {
- if (steticTemplate != null)
- throw new InvalidOperationException ("Widget templates can't contain more than one SteticTemplate element");
- steticTemplate = elem;
- } else if (fileTemplate == null) {
- fileTemplate = FileDescriptionTemplate.CreateTemplate (elem) as SingleFileDescriptionTemplate;
- if (fileTemplate == null)
- throw new InvalidOperationException ("Widget templates can only contain single-file and stetic templates.");
- }
- }
- if (fileTemplate == null)
- throw new InvalidOperationException ("File template not found in widget template.");
- if (steticTemplate == null)
- throw new InvalidOperationException ("Stetic template not found in widget template.");
- }
-#endif
-
- public override bool SupportsProject (Project project, string projectPath)
- {
- return (project is DotNetProject) && GtkDesignInfo.SupportsRefactoring (project as DotNetProject);
- }
-
- public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name)
- {
- if (!GtkDesignInfo.SupportsDesigner (project)) {
- ReferenceManager mgr = new ReferenceManager (project as DotNetProject);
- mgr.GtkPackageVersion = mgr.DefaultGtkVersion;
- mgr.Dispose ();
- }
-
- GtkDesignInfo info = GtkDesignInfo.FromProject ((DotNetProject) project);
-
- GuiBuilderProject gproject = info.GuiBuilderProject;
-
- string fileName = fileTemplate.GetFileName (policyParent, project, language, directory, name);
- fileTemplate.AddToProject (policyParent, project, language, directory, name);
-
-#if TRUNK
- ProjectDomService.Parse (project, fileName);
-#else
- ProjectDomService.Parse (project, fileName, null);
-#endif
-
- DotNetProject netProject = project as DotNetProject;
- string ns = netProject != null ? netProject.GetDefaultNamespace (fileName) : "";
- string cname = Path.GetFileNameWithoutExtension (fileName);
- string fullName = ns.Length > 0 ? ns + "." + cname : cname;
- string[,] tags = {
- {"Name", cname},
- {"Namespace", ns},
- {"FullName", fullName}
- };
-
- XmlElement widgetElem = steticTemplate ["widget"];
- if (widgetElem != null) {
- string content = widgetElem.OuterXml;
- content = StringParserService.Parse (content, tags);
-
- XmlDocument doc = new XmlDocument ();
- doc.LoadXml (content);
-
- gproject.AddNewComponent (doc.DocumentElement);
- gproject.Save (false);
- gproject.GenerateCode (fileName);
- IdeApp.ProjectOperations.Save (project);
- return true;
- }
-
- widgetElem = steticTemplate ["action-group"];
- if (widgetElem != null) {
- string content = widgetElem.OuterXml;
- content = StringParserService.Parse (content, tags);
-
- XmlDocument doc = new XmlDocument ();
- doc.LoadXml (content);
-
- Stetic.Project sproject = gproject.SteticProject;
- sproject.AddNewActionGroup (doc.DocumentElement);
- gproject.Save (false);
- gproject.GenerateCode (fileName);
- IdeApp.ProjectOperations.Save (project);
- return true;
- }
-
- throw new InvalidOperationException ("<widget> or <action-group> element not found in widget template.");
- }
-
- public override void Show ()
- {
- fileTemplate.Show ();
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/WidgetParser.cs b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/WidgetParser.cs
deleted file mode 100644
index c846970e5e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore/WidgetParser.cs
+++ /dev/null
@@ -1,226 +0,0 @@
-//
-// ObjectsDocument.cs
-//
-// Authors:
-// Lluis Sanchez Gual
-// Mike Kestner
-//
-// Copyright (C) 2006-2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Xml;
-using System.CodeDom;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-
-namespace MonoDevelop.GtkCore
-{
-
- public class WidgetParser
- {
-
- ProjectDom ctx;
-
- public WidgetParser (ProjectDom ctx)
- {
- this.ctx = ctx;
- }
-
- public Dictionary<string, IType> GetToolboxItems ()
- {
- Dictionary<string, IType> tb_items = new Dictionary<string, IType> ();
-
- IType wt = ctx.GetType ("Gtk.Widget", true);
- if (wt != null) {
- foreach (IType t in ctx.GetSubclasses (wt, true)) {
- if (t.SourceProjectDom == ctx && IsToolboxWidget (t))
- tb_items [t.FullName] = t;
- }
- }
-
- return tb_items;
- }
-
- public void CollectMembers (IType cls, bool inherited, string topType, ListDictionary properties, ListDictionary events)
- {
- if (cls.FullName == topType)
- return;
-
- foreach (IProperty prop in cls.Properties)
- if (IsBrowsable (prop))
- properties [prop.Name] = prop;
-
- foreach (IEvent ev in cls.Events)
- if (IsBrowsable (ev))
- events [ev.Name] = ev;
-
- if (inherited) {
- foreach (IReturnType bt in cls.BaseTypes) {
- IType bcls = ctx.GetType (bt);
- if (bcls != null && bcls.ClassType != ClassType.Interface)
- CollectMembers (bcls, true, topType, properties, events);
- }
- }
- }
-
- public string GetBaseType (IType cls, Hashtable knownTypes)
- {
- foreach (IReturnType bt in cls.BaseTypes) {
- if (knownTypes.Contains (bt.FullName))
- return bt.FullName;
- }
-
- foreach (IReturnType bt in cls.BaseTypes) {
- IType bcls = ctx.GetType (bt);
- if (bcls != null) {
- string ret = GetBaseType (bcls, knownTypes);
- if (ret != null)
- return ret;
- }
- }
- return null;
- }
-
- public string GetCategory (IMember decoration)
- {
-// foreach (IAttributeSection section in decoration.Attributes) {
- foreach (IAttribute at in decoration.Attributes) {
- switch (at.Name) {
- case "Category":
- case "CategoryAttribute":
- case "System.ComponentModel.Category":
- case "System.ComponentModel.CategoryAttribute":
- break;
- default:
- continue;
- }
- if (at.PositionalArguments != null && at.PositionalArguments.Count > 0) {
- CodePrimitiveExpression exp = at.PositionalArguments [0] as CodePrimitiveExpression;
- if (exp != null && exp.Value != null)
- return exp.Value.ToString ();
- }
- }
- // }
- return "";
- }
-
- public IType GetClass (string classname)
- {
- return ctx.GetType (classname);
- }
-
- public bool IsBrowsable (IMember member)
- {
- if (!member.IsPublic)
- return false;
-
- IProperty prop = member as IProperty;
- if (prop != null) {
- if (!prop.HasGet || !prop.HasSet)
- return false;
- if (Array.IndexOf (supported_types, prop.ReturnType.FullName) == -1)
- return false;
- }
-
- // foreach (IAttributeSection section in member.Attributes) {
- foreach (IAttribute at in member.Attributes) {
- switch (at.Name) {
- case "Browsable":
- case "BrowsableAttribute":
- case "System.ComponentModel.Browsable":
- case "System.ComponentModel.BrowsableAttribute":
- break;
- default:
- continue;
- }
- if (at.PositionalArguments != null && at.PositionalArguments.Count > 0) {
- CodePrimitiveExpression exp = at.PositionalArguments [0] as CodePrimitiveExpression;
- if (exp != null && exp.Value != null && exp.Value is bool) {
- return (bool) exp.Value;
- }
- }
- }
- // }
- return true;
- }
-
- public bool IsToolboxWidget (IType cls)
- {
- if (!cls.IsPublic)
- return false;
-
- foreach (IAttribute at in cls.Attributes) {
- switch (at.Name) {
- case "ToolboxItem":
- case "ToolboxItemAttribute":
- case "System.ComponentModel.ToolboxItem":
- case "System.ComponentModel.ToolboxItemAttribute":
- break;
- default:
- continue;
- }
- if (at.PositionalArguments != null && at.PositionalArguments.Count > 0) {
- CodePrimitiveExpression exp = at.PositionalArguments [0] as CodePrimitiveExpression;
- if (exp == null || exp.Value == null)
- return false;
- else if (exp.Value is bool)
- return (bool) exp.Value;
- else
- return exp.Value != null;
- }
- }
-
- foreach (IReturnType bt in cls.BaseTypes) {
- IType bcls = ctx.GetType (bt);
- if (bcls != null && bcls.ClassType != ClassType.Interface)
- return IsToolboxWidget (bcls);
- }
-
- return false;
- }
-
- static string[] supported_types = new string[] {
- "System.Boolean",
- "System.Char",
- "System.SByte",
- "System.Byte",
- "System.Int16",
- "System.UInt16",
- "System.Int32",
- "System.UInt32",
- "System.Int64",
- "System.UInt64",
- "System.Decimal",
- "System.Single",
- "System.Double",
- "System.DateTime",
- "System.String",
- "System.TimeSpan",
- "Gtk.Adjustment",
- };
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.addin.xml b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.addin.xml
deleted file mode 100644
index 68333ec2a5..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.addin.xml
+++ /dev/null
@@ -1,210 +0,0 @@
-<Addin id = "GtkCore2"
- namespace = "MonoDevelop"
- name = "GTK# Visual Designer (GSOC)"
- author = "Lluis Sanchez Gual, Krzysztof Marecki"
- copyright = "X11"
- url = ""
- description = "Experimental GTK# visual designer developed during GSOC 2010 as a fork of stetic"
- category = "IDE extensions"
- version = "4.2.3">
-
- <Runtime>
- <Import assembly="libstetic2.dll"/>
- <Import file="libstetic2.dll.config"/>
- <Import assembly="libsteticui2.dll"/>
- <Import file="libsteticui2.dll.config"/>
- <Import assembly="MonoDevelop.GtkCore2.dll"/>
- </Runtime>
-
- <Dependencies>
- <Addin id="Core" version="4.2.3"/>
- <Addin id="Ide" version="4.2.3"/>
- <Addin id="DesignerSupport" version="4.2.3"/>
- <Addin id="XmlEditor" version="4.2.3"/>
- <Addin id="Refactoring" version="4.2.3"/>
- </Dependencies>
-
- <ExtensionPoint path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.ActionGroup">
- <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/>
- </ExtensionPoint>
-
- <ExtensionPoint path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.UserInterfaceFolder">
- <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/>
- </ExtensionPoint>
-
- <ExtensionPoint path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.Component">
- <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/>
- </ExtensionPoint>
-
- <ExtensionPoint path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.StockIcons">
- <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/>
- </ExtensionPoint>
-
- <Extension path = "/MonoDevelop/Ide/WorkbenchContexts/Edit">
- <ContextPad id = "MonoDevelop.GtkCore.GuiBuilder.GuiBuilderProjectPad" />
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/Pads/ProjectPad">
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.GuiProjectFolderNodeBuilder"/>
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.ProjectFolderNodeBuilderExtension"/>
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.ProjectFileNodeBuilderExtension"/>
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.ProjectNodeBuilder"/>
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.StockIconsNodeBuilder"/>
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.ProjectFileNodeBuilderExtension" />
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/FileTemplates">
- <FileTemplate id = "DialogFileTemplate" resource = "Dialog.xft.xml"/>
- <FileTemplate id = "DrawingAreaFileTemplate" resource = "DrawingArea.xft.xml"/>
- <FileTemplate id = "WindowFileTemplate" resource = "Window.xft.xml"/>
- <FileTemplate id = "WidgetFileTemplate" resource = "Widget.xft.xml"/>
- <FileTemplate id = "ActionGroupFileTemplate" resource = "ActionGroup.xft.xml"/>
- <FileTemplate id = "PartialDialogFileTemplate" resource = "DialogPartial.xft.xml"/>
- <FileTemplate id = "PartialWindowFileTemplate" resource = "WindowPartial.xft.xml"/>
- <FileTemplate id = "PartialWidgetFileTemplate" resource = "WidgetPartial.xft.xml"/>
- <FileTemplate id = "PartialActionGroupFileTemplate" resource = "ActionGroupPartial.xft.xml"/>
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/DisplayBindings">
- <DisplayBinding insertbefore = "DefaultDisplayBinding"
- class = "MonoDevelop.GtkCore.GuiBuilder.GuiBuilderDisplayBinding" />
- <DisplayBinding
- class = "MonoDevelop.GtkCore.GuiBuilder.ActionGroupDisplayBinding" />
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/Commands">
- <Category _name = "Gtk# Designer" id = "GtkCore">
- <Command id = "MonoDevelop.GtkCore.GtkCommands.AddNewDialog"
- icon = "md-gtkcore-dialog"
- _label = "New Dialog..." />
- <Command id = "MonoDevelop.GtkCore.GtkCommands.AddNewWindow"
- icon = "md-gtkcore-window"
- _label = "New Window..." />
- <Command id = "MonoDevelop.GtkCore.GtkCommands.AddNewWidget"
- icon = "md-gtkcore-widget"
- _label = "New Widget..." />
- <Command id = "MonoDevelop.GtkCore.GtkCommands.AddNewActionGroup"
- icon = "md-gtkcore-actiongroup"
- _label = "New Action Group..." />
- <Command id = "MonoDevelop.GtkCore.GtkCommands.ImportGladeFile"
- _label = "Import Glade file..." />
- <Command id = "MonoDevelop.GtkCore.GtkCommands.EditIcons"
- icon = "md-gtkcore-iconfactory"
- _label = "Edit Project Icons..." />
- <Command id = "MonoDevelop.GtkCore.GtkCommands.GtkSettings"
- _label = "GTK# support settings..."
- icon = "md-gtkcore-gtk-logo"/>
- <Command id = "MonoDevelop.GtkCore.GtkCommands.GenerateCode"
- _label = "Generate designer code..."
- icon="md-gtkcore-gtkx"/>
- <Command id = "MonoDevelop.GtkCore.GtkCommands.ReloadDesigner"
- _label = "Reload designer..."/>
- </Category>
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/ContextMenu/ProjectPad/Add">
- <Condition id="ItemType" value="Project|ProjectFolder">
- <SeparatorItem insertafter = "MonoDevelop.Ide.Commands.ProjectCommands.AddFiles" />
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.AddNewDialog" />
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.AddNewWindow" />
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.AddNewWidget" />
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.AddNewActionGroup" />
- </Condition>
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/ContextMenu/ProjectPad">
- <Condition id="ItemType" value="MonoDevelop.GtkCore.NodeBuilders.GuiProjectFolder">
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.EditIcons" insertafter="BuildSectionEnd"/>
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.ImportGladeFile" />
- <SeparatorItem/>
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.GtkSettings" />
- </Condition>
- <Condition id="ItemType" value="ProjectFile">
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.GenerateCode" insertafter="BuildSectionEnd"/>
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.ReloadDesigner"/>
- </Condition>
- </Extension>
-
- <Extension path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.Component">
- <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.Open" />
- <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.Delete" />
- </Extension>
-
- <Extension path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.ActionGroup">
- <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.Open" />
- <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.Delete" />
- </Extension>
-
- <Extension path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.StockIcons">
- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.EditIcons" />
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/ExtendedProperties">
- <ItemProperty class = "MonoDevelop.Projects.Project"
- name = "GtkDesignInfo"
- skipEmpty = "True"
- type = "MonoDevelop.GtkCore.GtkDesignInfo" />
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/StartupHandlers">
- <Class class="MonoDevelop.GtkCore.GtkCoreStartupCommand" />
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/Gui/ItemOptionPanels/Common">
- <Condition id="ItemType" value ="DotNetProject">
- <Section id = "SteticOptionsPanel"
- _label = "GTK# Settings"
- fill="true"
- class = "MonoDevelop.GtkCore.Dialogs.WidgetBuilderOptionPanel"
- icon = "md-gtkcore-gtk-logo"/>
- </Condition>
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/FileTemplateTypes">
- <FileTemplateType name = "Widget" class = "MonoDevelop.GtkCore.WidgetFileDescriptionTemplate"/>
- </Extension>
-
- <Extension path = "/MonoDevelop/Core/StockIcons">
- <StockIcon stockid = "md-gtkcore-window" resource = "window.png" />
- <StockIcon stockid = "md-gtkcore-dialog" resource = "dialog.png" />
- <StockIcon stockid = "md-gtkcore-widget" resource = "widget.png" />
- <StockIcon stockid = "md-gtkcore-actiongroup" resource = "actiongroup.png" />
- <StockIcon stockid = "md-gtkcore-iconfactory" resource = "image-x-generic.png" />
- <StockIcon stockid = "md-gtkcore-gtkx" resource = "gtkx.png" />
- <StockIcon stockid = "md-gtkcore-gtk-logo" resource = "gtk-logo.png"/>
- </Extension>
-
- <Extension path = "/MonoDevelop/Core/MimeTypes">
- <MimeType id="text/x-gtkx" _description="Gtk# designer file" isText="true">
- <File pattern="*.gtkx" />
- </MimeType>
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/ProjectServiceExtensions">
- <Class class = "MonoDevelop.GtkCore.GuiBuilder.GtkProjectServiceExtension" insertafter="MidStep"/>
- </Extension>
-
- <Extension path = "/MonoDevelop/DesignerSupport/ToolboxProviders">
- <Class class = "MonoDevelop.GtkCore.GuiBuilder.ToolboxProvider" />
- </Extension>
-
- <Extension path = "/MonoDevelop/DesignerSupport/ToolboxLoaders">
- <Class id="ToolboxItemLoader" class="MonoDevelop.GtkCore.GuiBuilder.ToolboxLoader"/>
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/SerializableClasses">
- <DataType class = "MonoDevelop.GtkCore.GuiBuilder.ComponentToolboxNode" />
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/ProjectFeatures">
- <Class class = "MonoDevelop.GtkCore.Dialogs.GtkProjectFeature" />
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/GlobalOptionsDialog/Projects">
- <Panel _label = "GTK# Designer" class = "MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionPanel" />
- </Extension>
-
- <Extension path = "/MonoDevelop/XmlEditor/XmlFileExtensions">
- <XmlFileExtension extension = ".gtkx"/>
- </Extension>
-</Addin>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.csproj b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.csproj
deleted file mode 100644
index 5e20063f0d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.csproj
+++ /dev/null
@@ -1,206 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{4F2E994F-E4F5-407A-8D80-80E3377DEF6E}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AssemblyName>MonoDevelop.GtkCore2</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <RootNamespace>MonoDevelop.GtkCore</RootNamespace>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\build\AddIns\MonoDevelop.GtkCore2</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- <DefineConstants>TRUNK</DefineConstants>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\build\AddIns\MonoDevelop.GtkCore2 </OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- <DefineConstants>TRUNK</DefineConstants>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Xml" />
- <Reference Include="Mono.Posix" />
- <Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="System.Core" />
- <Reference Include="NRefactory, Version=2.1.1.0, Culture=neutral, PublicKeyToken=efe927acf176eea2">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="Mono.Addins, Version=0.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
- <Reference Include="Mono.Cecil, Version=0.6.9.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="Mono.Debugging, Version=0.0.0.0, Culture=neutral, PublicKeyToken=9307d64546e0580d">
- <Package>monodevelop</Package>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="libsteticui\libsteticui2.csproj">
- <Project>{8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}</Project>
- <Name>libsteticui2</Name>
- </ProjectReference>
- <ProjectReference Include="libstetic\libstetic2.csproj">
- <Project>{90CBA7FD-CB46-4711-97BB-2420DC01F016}</Project>
- <Name>libstetic2</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
- <Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
- <Name>MonoDevelop.Core</Name>
- </ProjectReference>
- <ProjectReference Include="..\Deployment\MonoDevelop.Deployment\MonoDevelop.Deployment.csproj">
- <Project>{9BC670A8-1851-40EC-9685-279F4C98433D}</Project>
- <Name>MonoDevelop.Deployment</Name>
- </ProjectReference>
- <ProjectReference Include="..\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.csproj">
- <Project>{2C24D515-4A2C-445C-8419-C09231913CFA}</Project>
- <Name>MonoDevelop.DesignerSupport</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\core\MonoDevelop.Ide\MonoDevelop.Ide.csproj">
- <Project>{27096E7F-C91C-4AC6-B289-6897A701DF21}</Project>
- <Name>MonoDevelop.Ide</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\core\Mono.Texteditor\Mono.TextEditor.csproj">
- <Project>{A2329308-3751-4DBD-9A75-5F7B8B024625}</Project>
- <Name>Mono.TextEditor</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="ChangeLog" />
- <None Include="Makefile.am" />
- <None Include="icons\window.png" />
- <None Include="icons\dialog.png" />
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="templates\Dialog.xft.xml">
- <LogicalName>Dialog.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\Window.xft.xml">
- <LogicalName>Window.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\Widget.xft.xml">
- <LogicalName>Widget.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\ActionGroup.xft.xml">
- <LogicalName>ActionGroup.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="gui.glade">
- <LogicalName>gui.glade</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\ActionGroupPartial.xft.xml">
- <LogicalName>ActionGroupPartial.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\DialogPartial.xft.xml">
- <LogicalName>DialogPartial.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\WidgetPartial.xft.xml">
- <LogicalName>WidgetPartial.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\DrawingArea.xft.xml">
- <LogicalName>DrawingArea.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\WindowPartial.xft.xml">
- <LogicalName>WindowPartial.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\widget.png">
- <LogicalName>widget.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\actiongroup.png">
- <LogicalName>actiongroup.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\image-x-generic.png">
- <LogicalName>image-x-generic.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="gtk-gui\gui.stetic">
- <LogicalName>gui.stetic</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\gtkx.png">
- <LogicalName>gtkx.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\gtk-logo.png">
- <LogicalName>gtk-logo.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="MonoDevelop.GtkCore2.addin.xml">
- <LogicalName>MonoDevelop.GtkCore.addin.xml</LogicalName>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ClassUtils.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderDisplayBinding.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderProject.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderDocumentOutline.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\PropertiesWidget.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderService.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderView.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderWindow.cs" />
- <Compile Include="MonoDevelop.GtkCore\GtkDesignInfo.cs" />
- <Compile Include="MonoDevelop.GtkCore\GtkCoreService.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\WidgetBuilderOptionPanel.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectNodeBuilder.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectFolderNodeBuilderExtension.cs" />
- <Compile Include="MonoDevelop.GtkCore\WidgetFileDescriptionTemplate.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\SelectRenamedClassDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\BindDesignDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\ConfirmWindowDeleteDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore\ProjectResourceProvider.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ActionGroupView.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ActionGroupDisplayBinding.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\CombinedDesignView.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\CodeBinder.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GtkProjectServiceExtension.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ToolboxProvider.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\StockIconsNodeBuilder.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\GtkFeatureWidget.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ToolboxLoader.cs" />
- <Compile Include="gtk-gui\generated.cs" />
- <Compile Include="MonoDevelop.GtkCore\ObjectsDocument.cs" />
- <Compile Include="MonoDevelop.GtkCore\WidgetParser.cs" />
- <Compile Include="MonoDevelop.GtkCore\ReferenceManager.cs" />
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\GtkDesignerOptionsPanelWidget.cs" />
- <Compile Include="gtk-gui\MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.cs" />
- <Compile Include="MonoDevelop.GtkCore\Counters.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectFileNodeBuilderExtension.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectFileExtension.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\ProjectConversionDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\GuiProjectFolder.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\GuiProjectFolderNodeBuilder.cs" />
- <Compile Include="gtk-gui\MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore.Commands\GtkCommands.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="$(MSBuildExtensionsPath)\Mono.Addins.targets" />
-</Project>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.sln b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.sln
deleted file mode 100644
index 3f7850226d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.sln
+++ /dev/null
@@ -1,32 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libstetic2", "libstetic\libstetic2.csproj", "{90CBA7FD-CB46-4711-97BB-2420DC01F016}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsteticui2", "libsteticui\libsteticui2.csproj", "{8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GtkCore2.xbuild", "MonoDevelop.GtkCore2.xbuild.csproj", "{4F2E994F-E4F5-407A-8D80-80E3377DEF6E}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Release|Any CPU.Build.0 = Release|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Release|Any CPU.Build.0 = Release|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = MonoDevelop.GtkCore2.xbuild.csproj
- EndGlobalSection
-EndGlobal
diff --git a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.xbuild.csproj b/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.xbuild.csproj
deleted file mode 100644
index 168fe13ffb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.xbuild.csproj
+++ /dev/null
@@ -1,215 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{4F2E994F-E4F5-407A-8D80-80E3377DEF6E}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AssemblyName>MonoDevelop.GtkCore2</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <RootNamespace>MonoDevelop.GtkCore</RootNamespace>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>build\debug\</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>build\release\ </OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- <DefineConstants>TRUNK</DefineConstants>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Xml" />
- <Reference Include="Mono.Posix" />
- <Reference Include="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="System.Core" />
- <Reference Include="MonoDevelop.Core, Version=2.4.0.0, Culture=neutral">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="MonoDevelop.Ide, Version=2.4.0.0, Culture=neutral">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="Mono.TextEditor, Version=1.0.0.0, Culture=neutral">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="Mono.Cecil, Version=0.6.9.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="NRefactory, Version=2.1.1.0, Culture=neutral, PublicKeyToken=efe927acf176eea2">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="Mono.Debugging, Version=0.0.0.0, Culture=neutral, PublicKeyToken=9307d64546e0580d">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="MonoDevelop.Deployment, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\build\AddIns\MonoDevelop.Deployment\MonoDevelop.Deployment.dll</HintPath>
- </Reference>
- <Reference Include="MonoDevelop.DesignerSupport, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\build\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll</HintPath>
- </Reference>
- <Reference Include="Mono.TextEditor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\build\bin\Mono.TextEditor.dll</HintPath>
- </Reference>
- <Reference Include="MonoDevelop.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\build\bin\MonoDevelop.Core.dll</HintPath>
- </Reference>
- <Reference Include="MonoDevelop.Ide, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\build\bin\MonoDevelop.Ide.dll</HintPath>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="libsteticui\libsteticui2.csproj">
- <Project>{8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}</Project>
- <Name>libsteticui2</Name>
- </ProjectReference>
- <ProjectReference Include="libstetic\libstetic2.csproj">
- <Project>{90CBA7FD-CB46-4711-97BB-2420DC01F016}</Project>
- <Name>libstetic2</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="ChangeLog" />
- <None Include="Makefile.am" />
- <None Include="icons\window.png" />
- <None Include="icons\dialog.png" />
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="templates\Dialog.xft.xml">
- <LogicalName>Dialog.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\Window.xft.xml">
- <LogicalName>Window.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\Widget.xft.xml">
- <LogicalName>Widget.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\ActionGroup.xft.xml">
- <LogicalName>ActionGroup.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="gui.glade">
- <LogicalName>gui.glade</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\ActionGroupPartial.xft.xml">
- <LogicalName>ActionGroupPartial.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\DialogPartial.xft.xml">
- <LogicalName>DialogPartial.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\WidgetPartial.xft.xml">
- <LogicalName>WidgetPartial.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\DrawingArea.xft.xml">
- <LogicalName>DrawingArea.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\WindowPartial.xft.xml">
- <LogicalName>WindowPartial.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\widget.png">
- <LogicalName>widget.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\actiongroup.png">
- <LogicalName>actiongroup.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\image-x-generic.png">
- <LogicalName>image-x-generic.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="gtk-gui\gui.stetic">
- <LogicalName>gui.stetic</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\gtkx.png">
- <LogicalName>gtkx.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="icons\gtk-logo.png">
- <LogicalName>gtk-logo.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="MonoDevelop.GtkCore2.addin.xml">
- <LogicalName>MonoDevelop.GtkCore.addin.xml</LogicalName>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="MonoDevelop.GtkCore.Commands\GladeCommands.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ClassUtils.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderDisplayBinding.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderProject.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderDocumentOutline.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\PropertiesWidget.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderService.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderView.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GuiBuilderWindow.cs" />
- <Compile Include="MonoDevelop.GtkCore\GtkDesignInfo.cs" />
- <Compile Include="MonoDevelop.GtkCore\GtkCoreService.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\WidgetBuilderOptionPanel.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectNodeBuilder.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectFolderNodeBuilderExtension.cs" />
- <Compile Include="MonoDevelop.GtkCore\WidgetFileDescriptionTemplate.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\SelectRenamedClassDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\BindDesignDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\ConfirmWindowDeleteDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore\ProjectResourceProvider.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ActionGroupView.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ActionGroupDisplayBinding.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\CombinedDesignView.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\CodeBinder.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\GtkProjectServiceExtension.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ToolboxProvider.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\StockIconsNodeBuilder.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\GtkFeatureWidget.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ToolboxLoader.cs" />
- <Compile Include="gtk-gui\generated.cs" />
- <Compile Include="MonoDevelop.GtkCore\ObjectsDocument.cs" />
- <Compile Include="MonoDevelop.GtkCore\WidgetParser.cs" />
- <Compile Include="MonoDevelop.GtkCore\ReferenceManager.cs" />
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\GtkDesignerOptionsPanelWidget.cs" />
- <Compile Include="gtk-gui\MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.cs" />
- <Compile Include="MonoDevelop.GtkCore\Counters.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectFileNodeBuilderExtension.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectFileExtension.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\ProjectConversionDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\GuiProjectFolder.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\GuiProjectFolderNodeBuilder.cs" />
- <Compile Include="gtk-gui\MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/README b/main/src/addins/MonoDevelop.GtkCore2/README
deleted file mode 100644
index 3c12c0b5ec..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/README
+++ /dev/null
@@ -1,14 +0,0 @@
-To build and test experimental GTK# visual designer :
-- checkout and build MonoDevelop trunk
-- copy entire MonoDevelop.GtkCore2 folder into monodevelop-trunk/main/src/
-- create monodevelop-slim folder in the monodevelop-trunk,
-- copy monodevelop-slim.sln into monodevelop-trunk/monodevelop-slim
-- open solution in MonoDevelop
-- build and run
-
-Remarks :
- - monodevelop-trunk is the name of folder where MonoDevelop was checkouted
- - old stetic designer should be disabled
-
-
-Krzysztof Marecki <marecki.krzysztof@gmail.com>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/addin-project.xml b/main/src/addins/MonoDevelop.GtkCore2/addin-project.xml
deleted file mode 100644
index 8b3e1e4863..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/addin-project.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<AddinProject appVersion="2.4">
- <Project platforms="Linux Win32 Mac">
- <AddinFile>build/debug/MonoDevelop.GtkCore2.dll</AddinFile>
- <BuildFile>MonoDevelop.GtkCore2.sln</BuildFile>
- <BuildConfiguration>Debug</BuildConfiguration>
- </Project>
-</AddinProject>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/build/debug/Mono.TextEditor.dll.config b/main/src/addins/MonoDevelop.GtkCore2/build/debug/Mono.TextEditor.dll.config
deleted file mode 100644
index 3fd1526914..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/build/debug/Mono.TextEditor.dll.config
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <dllmap os="!windows,osx" dll="libglib-2.0-0.dll" target="libglib-2.0.so.0"/>
- <dllmap os="!windows,osx" dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0"/>
- <dllmap os="!windows,osx" dll="libatk-1.0-0.dll" target="libatk-1.0.so.0"/>
- <dllmap os="!windows,osx" dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0"/>
- <dllmap os="!windows,osx" dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0"/>
- <dllmap os="!windows,osx" dll="libpango-1.0-0.dll" target="libpango-1.0.so.0"/>
- <dllmap os="!windows,osx" dll="libpangocairo-1.0-0.dll" target="libpangocairo-1.0.so.0"/>
-
- <dllmap os="osx" dll="libglib-2.0-0.dll" target="libglib-2.0.0.dylib"/>
- <dllmap os="osx" dll="libgobject-2.0-0.dll" target="libgobject-2.0.0.dylib"/>
- <dllmap os="osx" dll="libatk-1.0-0.dll" target="libatk-1.0.0.dylib"/>
- <dllmap os="osx" dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.0.dylib"/>
- <dllmap os="osx" dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.0.dylib"/>
- <dllmap os="osx" dll="libpango-1.0-0.dll" target="libpango-1.0.0.dylib"/>
- <dllmap os="osx" dll="libpangocairo-1.0-0.dll" target="libpangocairo-1.0.0.dylib"/>
-</configuration> \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Core.dll.config b/main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Core.dll.config
deleted file mode 100644
index 9551af1543..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Core.dll.config
+++ /dev/null
@@ -1,4 +0,0 @@
-<configuration>
- <dllmap dll="libglib-2.0-0.dll" target="libglib-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libglib-2.0-0.dll" target="libglib-2.0.dylib" os="osx" />
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Projects.Formats.MSBuild.exe b/main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Projects.Formats.MSBuild.exe
deleted file mode 100755
index 1b37b819d1..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Projects.Formats.MSBuild.exe
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Projects.Formats.MSBuild.exe.config b/main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Projects.Formats.MSBuild.exe.config
deleted file mode 100644
index 4e4303ebdf..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/build/debug/MonoDevelop.Projects.Formats.MSBuild.exe.config
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <runtime>
- <generatePublisherEvidence enabled="false" />
- <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
- <dependentAssembly>
- <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="2.0.0.0" />
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="2.0.0.0" />
- </dependentAssembly>
- </assemblyBinding>
- </runtime>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/build/debug/libstetic2.dll.config b/main/src/addins/MonoDevelop.GtkCore2/build/debug/libstetic2.dll.config
deleted file mode 100644
index 8c4c6ab9a9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/build/debug/libstetic2.dll.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<configuration>
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.dylib" os="osx" />
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.dylib" os="osx"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.dylib" os="osx"/>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/build/debug/libsteticui2.dll.config b/main/src/addins/MonoDevelop.GtkCore2/build/debug/libsteticui2.dll.config
deleted file mode 100644
index 8c4c6ab9a9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/build/debug/libsteticui2.dll.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<configuration>
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.dylib" os="osx" />
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.dylib" os="osx"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.dylib" os="osx"/>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/changes.patch b/main/src/addins/MonoDevelop.GtkCore2/changes.patch
deleted file mode 100644
index 9857ba3bd7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/changes.patch
+++ /dev/null
@@ -1,6455 +0,0 @@
-Index: libsteticui/ProjectBackend.cs
-===================================================================
---- libsteticui/ProjectBackend.cs (revision 17)
-+++ libsteticui/ProjectBackend.cs (working copy)
-@@ -16,7 +16,7 @@
- bool modified;
- Gtk.Widget selection;
- string id;
-- string fileName;
-+ string folderName;
- XmlDocument tempDoc;
- bool loading;
- IResourceProvider resourceProvider;
-@@ -33,7 +33,9 @@
- AssemblyResolver resolver;
- string imagesRootPath;
- string targetGtkVersion;
-- //version of stetic xml files
-+ List<string> modifiedTopLevels;
-+ //During project conversion flag is set
-+ bool converting;
-
- // The action collection of the last selected widget
- Stetic.Wrapper.ActionGroupCollection oldTopActionCollection;
-@@ -49,8 +51,7 @@
- public event SignalChangedEventHandler SignalChanged;
-
- public event Wrapper.WidgetEventHandler SelectionChanged;
-- public event EventHandler ModifiedChanged;
-- public event EventHandler Changed;
-+ public event ProjectChangedEventHandler Changed;
-
- // Fired when the project has been reloaded, due for example to
- // a change in the registry
-@@ -70,6 +71,7 @@
- iconFactory = new ProjectIconFactory ();
- widgetLibraries = new ArrayList ();
- internalLibs = new ArrayList ();
-+ modifiedTopLevels = new List<string> ();
- }
-
- public void Dispose ()
-@@ -95,12 +97,18 @@
- return null;
- }
-
-+
- public string FileName {
-- get { return fileName; }
-+ get { throw new Exception("FileName is obsolete"); }
-+ set { throw new Exception("FileName is obsolete"); }
-+ }
-+
-+ public string FolderName {
-+ get { return folderName; }
- set {
-- this.fileName = value;
-- if (fileName != null)
-- Id = System.IO.Path.GetFileName (fileName);
-+ this.folderName = value;
-+ if (folderName != null )
-+ Id = System.IO.Path.GetFullPath (folderName);
- else
- Id = null;
- }
-@@ -134,7 +142,7 @@
- }
-
- public string TargetGtkVersion {
-- get { return targetGtkVersion != null ? targetGtkVersion : "2.4"; }
-+ get { return targetGtkVersion ?? string.Empty; }
- set {
- if (TargetGtkVersion == value)
- return;
-@@ -149,16 +157,16 @@
- public string ImagesRootPath {
- get {
- if (string.IsNullOrEmpty (imagesRootPath)) {
-- if (string.IsNullOrEmpty (fileName))
-+ if (string.IsNullOrEmpty (folderName))
- return ".";
- else
-- return Path.GetDirectoryName (fileName);
-+ return Path.GetFullPath (folderName);
- }
- else {
- if (Path.IsPathRooted (imagesRootPath))
- return imagesRootPath;
-- else if (!string.IsNullOrEmpty (fileName))
-- return Path.GetFullPath (Path.Combine (Path.GetDirectoryName (fileName), imagesRootPath));
-+ else if (!string.IsNullOrEmpty (folderName))
-+ return Path.GetFullPath (Path.Combine (folderName, imagesRootPath));
- else
- return imagesRootPath;
- }
-@@ -190,7 +198,7 @@
- widgetLibraries.Remove (lib);
- internalLibs.Remove (lib);
- }
--
-+
- public ArrayList GetComponentTypes ()
- {
- ArrayList list = new ArrayList ();
-@@ -257,20 +265,13 @@
- set { iconFactory = value; }
- }
-
-- internal void SetFileName (string fileName)
-- {
-- this.fileName = fileName;
-- }
--
- internal void SetFrontend (Project project)
- {
- frontend = project;
- }
-
- public void Close ()
-- {
-- fileName = null;
--
-+ {
- if (actionGroups != null && ownedGlobalActionGroups) {
- foreach (Stetic.Wrapper.ActionGroup ag in actionGroups)
- ag.Dispose ();
-@@ -284,24 +285,35 @@
-
- selection = null;
- topLevels.Clear ();
-- widgetLibraries.Clear ();
-+ //widgetLibraries.Clear ();
-+
-
- iconFactory = new ProjectIconFactory ();
- }
-
-- public void Load (string fileName)
-+ public void Load (string folderName)
- {
-- Load (fileName, fileName);
-+ this.folderName = folderName;
-+ XmlDocument doc = new XmlDocument ();
-+ doc.PreserveWhitespace = true;
-+ XmlElement toplevel = doc.CreateElement ("stetic-interface");
-+ doc.AppendChild (toplevel);
-+ modifiedTopLevels.Clear ();
-+
-+ ReadIconFactory (doc);
-+ ReadActionGroups (doc);
-+ ReadTopLevels (doc);
-+ Read (doc);
-+
-+ Id = System.IO.Path.GetFullPath (folderName);
- }
-
-- public void Load (string xmlFile, string fileName)
-+ public void LoadOldVersion (string fileName)
- {
-- this.fileName = fileName;
- XmlDocument doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
-- doc.Load (xmlFile);
-- ReadIconFactory (doc);
-- ReadSplitFiles (doc);
-+ doc.Load (fileName);
-+
- Read (doc);
-
- Id = System.IO.Path.GetFileName (fileName);
-@@ -313,7 +325,7 @@
- if (node == null)
- return;
-
-- string basePath = fileName != null ? Path.GetDirectoryName (fileName) : null;
-+ string basePath = folderName;
- string xmlfile = Path.Combine(basePath, "IconFactory.gtkx");
-
- if (File.Exists (xmlfile)) {
-@@ -331,8 +343,18 @@
- }
- }
-
-- void ReadSplitFiles (XmlDocument doc)
-+ void ReadActionGroups (XmlDocument doc)
- {
-+ ReadSplitFiles (doc, "action-group", "name");
-+ }
-+
-+ void ReadTopLevels (XmlDocument doc)
-+ {
-+ ReadSplitFiles (doc, "widget", "id");
-+ }
-+
-+ void ReadSplitFiles (XmlDocument doc, string splitElement, string idAttribute)
-+ {
- XmlNode node = doc.SelectSingleNode ("/stetic-interface");
- if (node == null)
- return;
-@@ -349,88 +371,59 @@
-
- XmlNode wnode = wdoc.SelectSingleNode ("/stetic-interface");
-
-- foreach (XmlNode toplevel in wnode.SelectNodes ("widget | action-group")) {
-- XmlNode imported = doc.ImportNode (toplevel, true);
-- node.AppendChild (imported);
-+ foreach (XmlElement toplevel in wnode.SelectNodes (splitElement)) {
-+ string id = toplevel.GetAttribute (idAttribute);
-+
-+ if (frontend.DesignInfo.HasComponentFile (id)) {
-+ XmlNode imported = doc.ImportNode (toplevel, true);
-+ node.AppendChild (imported);
-+ }
- }
- }
- }
- }
- }
-
-+ void AddActionGroup (XmlElement groupElem)
-+ {
-+ ObjectReader reader = new ObjectReader (this, FileFormat.Native);
-+
-+ Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup ();
-+ actionGroup.Read (reader, groupElem);
-+ actionGroups.Add (actionGroup);
-+ }
-+
-+ void AddWidget (XmlElement toplevel)
-+ {
-+ topLevels.Add (new WidgetData (toplevel.GetAttribute ("id"), toplevel, null));
-+ }
-+
- void Read (XmlDocument doc)
- {
- loading = true;
-- string basePath = fileName != null ? Path.GetDirectoryName (fileName) : null;
--
-+
- try {
-- string fn = fileName;
- Close ();
-- fileName = fn;
-
- XmlNode node = doc.SelectSingleNode ("/stetic-interface");
- if (node == null)
- throw new ApplicationException (Catalog.GetString ("Not a Stetic file according to node name."));
-
-- // Load configuration options
-- foreach (XmlNode configNode in node.SelectNodes ("configuration/*")) {
-- XmlElement config = configNode as XmlElement;
-- if (config == null) continue;
--
-- if (config.LocalName == "images-root-path")
-- imagesRootPath = config.InnerText;
-- else if (config.LocalName == "target-gtk-version")
-- targetGtkVersion = config.InnerText;
-- }
--
- // Load the assembly directories
- resolver = new AssemblyResolver (app);
-- foreach (XmlElement libElem in node.SelectNodes ("import/assembly-directory")) {
-- string dir = libElem.GetAttribute ("path");
-- if (dir.Length > 0) {
-- if (basePath != null && !Path.IsPathRooted (dir)) {
-- dir = Path.Combine (basePath, dir);
-- if (Directory.Exists (dir))
-- dir = Path.GetFullPath (dir);
-- }
-- resolver.Directories.Add (dir);
-- }
-- }
--
-- // Import the referenced libraries
-- foreach (XmlElement libElem in node.SelectNodes ("import/widget-library")) {
-- string libname = libElem.GetAttribute ("name");
-- if (libname.EndsWith (".dll") || libname.EndsWith (".exe")) {
-- if (basePath != null && !Path.IsPathRooted (libname)) {
-- libname = Path.Combine (basePath, libname);
-- if (File.Exists (libname))
-- libname = Path.GetFullPath (libname);
-- }
-- }
-- widgetLibraries.Add (libname);
-- if (libElem.GetAttribute ("internal") == "true")
-- internalLibs.Add (libname);
-- }
--
- app.LoadLibraries (resolver, widgetLibraries);
-
-- ObjectReader reader = new ObjectReader (this, FileFormat.Native);
--
- if (ownedGlobalActionGroups) {
-- foreach (XmlElement groupElem in node.SelectNodes ("action-group")) {
-- Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup ();
-- actionGroup.Read (reader, groupElem);
-- actionGroups.Add (actionGroup);
-- }
-+ foreach (XmlElement groupElem in node.SelectNodes ("action-group"))
-+ AddActionGroup (groupElem);
- }
-
- XmlElement iconsElem = node.SelectSingleNode ("icon-factory") as XmlElement;
- if (iconsElem != null)
- iconFactory.Read (this, iconsElem);
-
-- foreach (XmlElement toplevel in node.SelectNodes ("widget")) {
-- topLevels.Add (new WidgetData (toplevel.GetAttribute ("id"), toplevel, null));
-- }
-+ foreach (XmlElement toplevel in node.SelectNodes ("widget"))
-+ AddWidget (toplevel);
-
- } finally {
- loading = false;
-@@ -443,8 +436,9 @@
- try {
- loading = true;
- ObjectReader reader = new ObjectReader (this, FileFormat.Native);
-- Wrapper.Container wrapper = Stetic.ObjectWrapper.ReadObject (reader, data.XmlData) as Wrapper.Container;
-+ Wrapper.Container wrapper = Stetic.ObjectWrapper.ReadObject (reader, data.XmlData, null) as Wrapper.Container;
- data.Widget = wrapper.Wrapped;
-+ data.Widget.Destroyed += (s,e) => data.Widget = null;
- } finally {
- loading = false;
- }
-@@ -453,9 +447,62 @@
- return data.Widget;
- }
-
-- public void Save (string fileName)
-+ public bool ReloadTopLevel (string topLevelName)
- {
-- this.fileName = fileName;
-+ XmlElement topLevelElem = ReadDesignerFile (topLevelName, "widget");
-+ if (topLevelName != null) {
-+ WidgetData data = GetWidgetData (topLevelName);
-+
-+ if (data != null) {
-+ //Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup (data.Widget);
-+ data.SetXmlData (topLevelName, topLevelElem);
-+ GetWidget (data);
-+ return true;
-+ }
-+ }
-+ return false;
-+ }
-+
-+ public void ReloadActionGroup (string groupName)
-+ {
-+
-+ }
-+
-+ XmlElement ReadDesignerFile (string componentName, string elementName)
-+ {
-+ string gtkxFile = GetDesignerFileName (componentName);
-+ if (gtkxFile != null) {
-+ XmlDocument wdoc = new XmlDocument ();
-+ wdoc.PreserveWhitespace = true;
-+ wdoc.Load (gtkxFile);
-+
-+ XmlNode wnode = wdoc.SelectSingleNode ("/stetic-interface");
-+ foreach (XmlElement toplevel in wnode.SelectNodes (elementName)) {
-+ return toplevel;
-+ }
-+
-+ string msg = string.Format (@"Cannot find /stetic-interface/{0} element in {1} file.",
-+ elementName, gtkxFile);
-+ throw new InvalidOperationException (msg);
-+ }
-+
-+ return null;
-+ }
-+
-+ public void ConvertProject (string oldSteticFileName, string newGuiFolderName)
-+ {
-+ converting = true;
-+ try {
-+ LoadOldVersion (oldSteticFileName);
-+ Save (newGuiFolderName);
-+ } finally {
-+ converting = false;
-+ }
-+ }
-+
-+ public void Save (string folderName)
-+ {
-+ this.folderName = folderName;
- XmlDocument doc = Write (false);
-
- XmlTextWriter writer = null;
-@@ -463,15 +510,7 @@
- WriteIconFactory (doc);
- WriteActionGroups (doc);
- WriteTopLevels (doc);
-- // Write to a temporary file first, just in case something fails
-- writer = new XmlTextWriter (fileName + "~", System.Text.Encoding.UTF8);
-- writer.Formatting = Formatting.Indented;
-- doc.Save (writer);
-- writer.Close ();
--
-- File.Copy (fileName + "~", fileName, true);
-- File.Delete (fileName + "~");
--
-+
- } finally {
- if (writer != null)
- writer.Close ();
-@@ -497,7 +536,7 @@
- XmlNode ifnode2 = doc2.ImportNode (ifnode, true);
- node2.AppendChild (ifnode2);
-
-- string basePath = this.fileName != null ? Path.GetDirectoryName (this.fileName) : null;
-+ string basePath = this.folderName;
- string xmlFile = Path.Combine (basePath, "IconFactory.gtkx");
- WriteXmlFile (xmlFile, doc2);
-
-@@ -520,34 +559,35 @@
- if (node == null)
- return;
-
-- List<XmlElement> toplevels = new List<XmlElement> ();
- foreach (XmlElement toplevel in node.SelectNodes (splitElement)) {
-
- string id = toplevel.GetAttribute (idAttribute);
-- string basePath = frontend.DesignInfo.GetComponentFolder (id);
-- string xmlFile = Path.Combine (basePath, id + ".gtkx");
--
-- XmlDocument doc2 = new XmlDocument ();
-- doc2.PreserveWhitespace = true;
--
-- XmlElement node2 = doc2.CreateElement ("stetic-interface");
-- doc2.AppendChild (node2);
--
-- XmlNode wnode2 = doc2.ImportNode (toplevel, true);
-- node2.AppendChild (wnode2);
--
-- //after saving component need to remove its xml element definition,
-- //otherwise it would be saved in gui.stetic
-- toplevels.Add (toplevel);
--
-- WriteXmlFile (xmlFile, doc2);
-+ if (modifiedTopLevels.Contains (id) || converting) {
-+ string xmlFile = GetDesignerFileName (id);
-+ if (xmlFile != null) {
-+ XmlDocument doc2 = new XmlDocument ();
-+ doc2.PreserveWhitespace = true;
-+
-+ XmlElement node2 = doc2.CreateElement ("stetic-interface");
-+ doc2.AppendChild (node2);
-+
-+ XmlNode wnode2 = doc2.ImportNode (toplevel, true);
-+ node2.AppendChild (wnode2);
-+
-+ WriteXmlFile (xmlFile, doc2);
-+ if (modifiedTopLevels.Contains (id))
-+ modifiedTopLevels.Remove (id);
-+ }
-+ }
- }
--
-- foreach (XmlElement toplevel in toplevels)
-- //now it is safe to remove
-- node.RemoveChild (toplevel);
- }
-
-+ private string GetDesignerFileName (string componentName)
-+ {
-+ string componentFile = frontend.DesignInfo.GetComponentFile (componentName);
-+ return frontend.DesignInfo.GetGtkxFile (componentFile);
-+ }
-+
- void WriteXmlFile (string xmlFile, XmlDocument doc)
- {
- XmlTextWriter writer = null;
-@@ -574,52 +614,6 @@
- XmlElement toplevel = doc.CreateElement ("stetic-interface");
- doc.AppendChild (toplevel);
-
-- XmlElement config = doc.CreateElement ("configuration");
-- if (!string.IsNullOrEmpty (imagesRootPath)) {
-- XmlElement iroot = doc.CreateElement ("images-root-path");
-- iroot.InnerText = imagesRootPath;
-- config.AppendChild (iroot);
-- }
-- if (!string.IsNullOrEmpty (targetGtkVersion)) {
-- XmlElement iroot = doc.CreateElement ("target-gtk-version");
-- iroot.InnerText = targetGtkVersion;
-- config.AppendChild (iroot);
-- }
--
-- if (config.ChildNodes.Count > 0)
-- toplevel.AppendChild (config);
--
-- if (widgetLibraries.Count > 0 || (resolver != null && resolver.Directories.Count > 0)) {
-- XmlElement importElem = doc.CreateElement ("import");
-- toplevel.AppendChild (importElem);
-- string basePath = Path.GetDirectoryName (fileName);
--
-- if (resolver != null && resolver.Directories.Count > 0) {
-- foreach (string dir in resolver.Directories) {
-- XmlElement dirElem = doc.CreateElement ("assembly-directory");
-- if (basePath != null)
-- dirElem.SetAttribute ("path", AbsoluteToRelativePath (basePath, dir));
-- else
-- dirElem.SetAttribute ("path", dir);
-- toplevel.AppendChild (dirElem);
-- }
-- }
--
-- foreach (string wlib in widgetLibraries) {
-- string libName = wlib;
-- XmlElement libElem = doc.CreateElement ("widget-library");
-- if (wlib.EndsWith (".dll") || wlib.EndsWith (".exe")) {
-- if (basePath != null)
-- libName = AbsoluteToRelativePath (basePath, wlib);
-- }
--
-- libElem.SetAttribute ("name", libName);
-- if (IsInternalLibrary (wlib))
-- libElem.SetAttribute ("internal", "true");
-- importElem.AppendChild (libElem);
-- }
-- }
--
- ObjectWriter writer = new ObjectWriter (doc, FileFormat.Native);
- writer.CreateUndoInfo = includeUndoInfo;
- if (ownedGlobalActionGroups) {
-@@ -670,9 +664,14 @@
- }
- }
-
-- internal WidgetEditSession CreateWidgetDesignerSession (WidgetDesignerFrontend frontend, string windowName, Stetic.ProjectBackend editingBackend, bool autoCommitChanges)
-+// internal WidgetEditSession CreateWidgetDesignerSession (WidgetDesignerFrontend frontend, string windowName, Stetic.ProjectBackend editingBackend, bool autoCommitChanges)
-+// {
-+// return new WidgetEditSession (this, frontend, windowName, editingBackend, autoCommitChanges);
-+// }
-+
-+ internal WidgetEditSession CreateWidgetDesignerSession (WidgetDesignerFrontend frontend, string windowName)
- {
-- return new WidgetEditSession (this, frontend, windowName, editingBackend, autoCommitChanges);
-+ return new WidgetEditSession (this, frontend, windowName);
- }
-
- internal ActionGroupEditSession CreateGlobalActionGroupDesignerSession (ActionGroupDesignerFrontend frontend, string groupName, bool autoCommitChanges)
-@@ -687,7 +686,7 @@
-
- public Wrapper.Container GetTopLevelWrapper (string name, bool throwIfNotFound)
- {
-- Gtk.Widget w = GetTopLevel (name);
-+ Gtk.Widget w = GetWidget (name);
- if (w != null) {
- Wrapper.Container ww = Wrapper.Container.Lookup (w);
- if (ww != null)
-@@ -698,6 +697,23 @@
- return null;
- }
-
-+ public object AddNewComponent (string fileName)
-+ {
-+ XmlDocument doc = new XmlDocument();
-+ doc.PreserveWhitespace = true;
-+ doc.Load (fileName);
-+
-+ XmlElement toplevel = (XmlElement)doc.SelectSingleNode ("/stetic-interface/widget");
-+ if (toplevel != null)
-+ return AddNewWidgetFromTemplate (toplevel.OuterXml);
-+
-+ XmlElement groupElem = (XmlElement)doc.SelectSingleNode ("/stetic-interface/action-group");
-+ if (groupElem != null)
-+ return AddNewActionGroupFromTemplate (groupElem.OuterXml);
-+
-+ return null;
-+ }
-+
- public object AddNewWidget (string type, string name)
- {
- ClassDescriptor cls = Registry.LookupClassByName (type);
-@@ -724,22 +740,9 @@
-
- if (frontend != null)
- frontend.NotifyWidgetRemoved (data.Name);
--
-- XmlElement elem;
-- if (data.Widget != null)
-- elem = Stetic.WidgetUtils.ExportWidget (data.Widget);
-- else
-- elem = (XmlElement) data.XmlData.Clone ();
-- XmlDocument doc = new XmlDocument ();
-- XmlNode node = doc.ImportNode (elem, true);
-- doc.AppendChild (node);
-- string dir = Path.Combine (Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "stetic"), "deleted-designs");
-- if (!Directory.Exists (dir))
-- Directory.CreateDirectory (dir);
-- doc.Save (Path.Combine (dir, name + ".xml"));
-- topLevels.Remove (data);
-- if (data.Widget != null)
-- data.Widget.Destroy ();
-+
-+ if (modifiedTopLevels.Contains (name))
-+ modifiedTopLevels.Remove (name);
- }
-
- public Stetic.Wrapper.ActionGroup AddNewActionGroup (string name)
-@@ -747,6 +750,7 @@
- Stetic.Wrapper.ActionGroup group = new Stetic.Wrapper.ActionGroup ();
- group.Name = name;
- ActionGroups.Add (group);
-+ this.modifiedTopLevels.Add (name);
- return group;
- }
-
-@@ -758,12 +762,16 @@
- Stetic.Wrapper.ActionGroup group = new Stetic.Wrapper.ActionGroup ();
- group.Read (or, doc.DocumentElement);
- ActionGroups.Add (group);
-+ this.modifiedTopLevels.Add (group.Name);
- return group;
- }
-
- public void RemoveActionGroup (Stetic.Wrapper.ActionGroup group)
- {
- ActionGroups.Remove (group);
-+ string name = group.Name;
-+ if (modifiedTopLevels.Contains (name))
-+ modifiedTopLevels.Remove (name);
- }
-
- public Wrapper.ActionGroup[] GetActionGroups ()
-@@ -771,40 +779,7 @@
- // Needed since ActionGroupCollection can't be made serializable
- return ActionGroups.ToArray ();
- }
--
-- public void CopyWidgetToProject (string name, ProjectBackend other, string replacedName)
-- {
-- WidgetData wdata = GetWidgetData (name);
-- if (name == null)
-- throw new InvalidOperationException ("Component not found: " + name);
-
-- XmlElement data;
-- if (wdata.Widget != null)
-- data = Stetic.WidgetUtils.ExportWidget (wdata.Widget);
-- else
-- data = (XmlElement) wdata.XmlData.Clone ();
--
-- // If widget already exist, replace it
-- wdata = other.GetWidgetData (replacedName);
-- if (wdata == null) {
-- wdata = new WidgetData (name, data, null);
-- other.topLevels.Add (wdata);
-- } else {
-- if (wdata.Widget != null) {
-- // If a widget instance already exist, load the new data on it
-- Wrapper.Widget sw = Wrapper.Widget.Lookup (wdata.Widget);
-- sw.Read (new ObjectReader (other, FileFormat.Native), data);
-- sw.NotifyChanged ();
-- if (name != replacedName)
-- other.OnWidgetNameChanged (new Wrapper.WidgetNameChangedArgs (sw, replacedName, name), true);
-- } else {
-- wdata.SetXmlData (name, data);
-- if (name != replacedName)
-- other.OnWidgetNameChanged (new Wrapper.WidgetNameChangedArgs (null, replacedName, name), true);
-- }
-- }
-- }
--
- void CleanUndoData (XmlElement elem)
- {
- elem.RemoveAttribute ("undoId");
-@@ -861,10 +836,19 @@
- NotifyComponentTypesChanged ();
- }
-
-+ bool preserveWidgetLibraries;
-+
- public void Reload ()
- {
-- OnRegistryChanging (null, null);
-- OnRegistryChanged (null, null);
-+ try {
-+ preserveWidgetLibraries = true;
-+ OnRegistryChanging (null, null);
-+ OnRegistryChanged (null, null);
-+ }
-+ finally
-+ {
-+ preserveWidgetLibraries = false;
-+ }
- }
-
- public string Id {
-@@ -872,18 +856,16 @@
- set { id = value; }
- }
-
-- public bool Modified {
-- get { return modified; }
-- set {
-- if (modified != value) {
-- modified = value;
-- if (frontend != null)
-- frontend.NotifyModifiedChanged ();
-- OnModifiedChanged (EventArgs.Empty);
-- }
-- }
-+ public bool WasModified (string topLevel)
-+ {
-+ return modifiedTopLevels.Contains (topLevel);
- }
-
-+ public bool ComponentNeedsCodeGeneration (string topLevel)
-+ {
-+ return frontend.DesignInfo.ComponentNeedsCodeGeneration (topLevel);
-+ }
-+
- public AssemblyResolver Resolver {
- get { return resolver; }
- }
-@@ -913,6 +895,7 @@
-
- if (!loading) {
- Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup (widget);
-+
- if (ww == null)
- throw new InvalidOperationException ("Widget not wrapped");
- if (frontend != null)
-@@ -925,7 +908,7 @@
- {
- if (loading)
- return;
-- NotifyChanged ();
-+ NotifyChanged (args.Wrapper.RootWrapperName);
- if (ObjectChanged != null)
- ObjectChanged (this, args);
- }
-@@ -934,7 +917,7 @@
- {
- if (loading)
- return;
-- NotifyChanged ();
-+ NotifyChanged (args.WidgetWrapper.RootWrapperName);
- OnWidgetNameChanged (args, args.WidgetWrapper.IsTopLevel);
- }
-
-@@ -1027,7 +1010,7 @@
- }
- }
-
-- public Gtk.Widget GetTopLevel (string name)
-+ public Gtk.Widget GetWidget (string name)
- {
- WidgetData w = GetWidgetData (name);
- if (w != null)
-@@ -1174,24 +1157,19 @@
- OnComponentTypesChanged (null, null);
- }
-
-- void NotifyChanged ()
-+ void NotifyChanged (string rootWidgetName)
- {
-- Modified = true;
-+ if (!modifiedTopLevels.Contains (rootWidgetName))
-+ modifiedTopLevels.Add (rootWidgetName);
- if (frontend != null)
-- frontend.NotifyChanged ();
-+ frontend.NotifyChanged (rootWidgetName);
- if (Changed != null)
-- Changed (this, EventArgs.Empty);
-+ Changed (this, new ProjectChangedEventArgs (rootWidgetName));
- }
-
-- protected virtual void OnModifiedChanged (EventArgs args)
-- {
-- if (ModifiedChanged != null)
-- ModifiedChanged (this, args);
-- }
--
- protected virtual void OnWidgetAdded (Stetic.Wrapper.WidgetEventArgs args)
- {
-- NotifyChanged ();
-+ NotifyChanged (args.WidgetWrapper.RootWrapperName);
- if (WidgetAdded != null)
- WidgetAdded (this, args);
- }
-@@ -1226,4 +1204,16 @@
- }
- }
- }
-+
-+ public class ProjectChangedEventArgs : EventArgs
-+ {
-+ public string ChangedTopLevelName { get; private set; }
-+
-+ public ProjectChangedEventArgs (string changedTopLevel)
-+ {
-+ ChangedTopLevelName = changedTopLevel;
-+ }
-+ }
-+
-+ public delegate void ProjectChangedEventHandler (object sender, ProjectChangedEventArgs args);
- }
-Index: libsteticui/IProjectDesignInfo.cs
-===================================================================
---- libsteticui/IProjectDesignInfo.cs (revision 17)
-+++ libsteticui/IProjectDesignInfo.cs (working copy)
-@@ -2,14 +2,21 @@
-
- namespace Stetic
- {
-- //Provides access to informations menaged by ide
-+ //Provides access to informations managed by ide
- public interface IProjectDesignInfo
- {
-- //Returns component source file folder
-- string GetComponentFolder(string componentName);
-+ //Returns component source file for given component
-+ string GetComponentFile (string componentName);
-+ bool HasComponentFile (string componentFile);
-
-+ //Returns gtkx file name for given component file
-+ string GetGtkxFile (string componentFile);
-+
- //Search for all components source file folders
- string[] GetComponentFolders ();
-+
-+ // Checks if code generation for a component is needed
-+ bool ComponentNeedsCodeGeneration (string componentName);
- }
- }
-
-Index: libsteticui/WidgetEditSession.cs
-===================================================================
---- libsteticui/WidgetEditSession.cs (revision 17)
-+++ libsteticui/WidgetEditSession.cs (working copy)
-@@ -39,14 +39,12 @@
- internal class WidgetEditSession: MarshalByRefObject, IDisposable
- {
- string sourceWidget;
-- Stetic.ProjectBackend sourceProject;
-+ Stetic.ProjectBackend project;
-
-- Stetic.ProjectBackend gproject;
- Stetic.Wrapper.Container rootWidget;
- Stetic.WidgetDesignerBackend widget;
- Gtk.VBox designer;
- Gtk.Plug plug;
-- bool autoCommitChanges;
- WidgetActionBar toolbar;
- WidgetDesignerFrontend frontend;
- bool allowBinding;
-@@ -55,61 +53,27 @@
- ContainerUndoRedoManager undoManager;
- UndoQueue undoQueue;
-
-- public event EventHandler ModifiedChanged;
- public event EventHandler RootWidgetChanged;
- public event Stetic.Wrapper.WidgetEventHandler SelectionChanged;
-
-- public WidgetEditSession (ProjectBackend sourceProject, WidgetDesignerFrontend frontend, string windowName, Stetic.ProjectBackend editingBackend, bool autoCommitChanges)
-+ public WidgetEditSession (ProjectBackend sourceProject, WidgetDesignerFrontend frontend, string windowName)
- {
- this.frontend = frontend;
-- this.autoCommitChanges = autoCommitChanges;
- undoManager = new ContainerUndoRedoManager ();
- undoQueue = new UndoQueue ();
- undoManager.UndoQueue = undoQueue;
-
- sourceWidget = windowName;
-- this.sourceProject = sourceProject;
--
-- if (!autoCommitChanges) {
-- // Reuse the action groups and icon factory of the main project
-- gproject = editingBackend;
--
-- // Attach will prevent the destruction of the action group list by gproject
-- gproject.AttachActionGroups (sourceProject.ActionGroups);
--
-- gproject.IconFactory = sourceProject.IconFactory;
-- gproject.FileName = sourceProject.FileName;
-- gproject.ImagesRootPath = sourceProject.ImagesRootPath;
-- gproject.ResourceProvider = sourceProject.ResourceProvider;
-- gproject.WidgetLibraries = (ArrayList) sourceProject.WidgetLibraries.Clone ();
-- gproject.InternalWidgetLibraries = (ArrayList) sourceProject.InternalWidgetLibraries.Clone ();
-- gproject.TargetGtkVersion = sourceProject.TargetGtkVersion;
-- sourceProject.ComponentTypesChanged += OnSourceProjectLibsChanged;
-- sourceProject.ProjectReloaded += OnSourceProjectReloaded;
--
-- rootWidget = editingBackend.GetTopLevelWrapper (sourceWidget, false);
-- if (rootWidget == null) {
-- // Copy the widget to edit from the source project
-- // When saving the file, this project will be merged with the main project.
-- sourceProject.CopyWidgetToProject (windowName, gproject, windowName);
-- rootWidget = gproject.GetTopLevelWrapper (windowName, true);
-- }
--
-- gproject.Modified = false;
-- }
-- else {
-- rootWidget = sourceProject.GetTopLevelWrapper (windowName, true);
-- gproject = sourceProject;
-- }
--
-+ this.project = sourceProject;
-+
-+ rootWidget = sourceProject.GetTopLevelWrapper (windowName, true);
- rootWidget.Select ();
- undoManager.RootObject = rootWidget;
-
-- gproject.ModifiedChanged += new EventHandler (OnModifiedChanged);
-- gproject.Changed += new EventHandler (OnChanged);
-- gproject.ProjectReloaded += new EventHandler (OnProjectReloaded);
-- gproject.ProjectReloading += new EventHandler (OnProjectReloading);
--// gproject.WidgetMemberNameChanged += new Stetic.Wrapper.WidgetNameChangedHandler (OnWidgetNameChanged);
-+ this.project.Changed += new ProjectChangedEventHandler (OnChanged);
-+ this.project.ProjectReloaded += new EventHandler (OnProjectReloaded);
-+ this.project.ProjectReloading += new EventHandler (OnProjectReloading);
-+// this.project.WidgetMemberNameChanged += new Stetic.Wrapper.WidgetNameChangedHandler (OnWidgetNameChanged);
- }
-
- public bool AllowWidgetBinding {
-@@ -144,7 +108,8 @@
- designer.BorderWidth = 3;
- designer.PackStart (toolbar, false, false, 0);
- designer.PackStart (widget, true, true, 3);
-- widget.DesignArea.SetSelection (gproject.Selection, gproject.Selection, false);
-+ widget.DesignArea.SetSelection (project.Selection, project.Selection, false);
-+
- widget.SelectionChanged += OnSelectionChanged;
-
- }
-@@ -173,42 +138,24 @@
- }
-
- public void Save ()
-- {
-- if (!autoCommitChanges) {
-- gproject.CopyWidgetToProject (rootWidget.Wrapped.Name, sourceProject, sourceWidget);
-- sourceWidget = rootWidget.Wrapped.Name;
-- gproject.Modified = false;
-- }
-+ {
- }
-
- public ProjectBackend EditingBackend {
-- get { return gproject; }
-+ get { return project; }
- }
-
- public void Dispose ()
- {
-- sourceProject.ComponentTypesChanged -= OnSourceProjectLibsChanged;
-- sourceProject.ProjectReloaded -= OnSourceProjectReloaded;
-+ project.ComponentTypesChanged -= OnSourceProjectLibsChanged;
-+ project.ProjectReloaded -= OnSourceProjectReloaded;
-+ project.Changed -= new ProjectChangedEventHandler (OnChanged);
-+ project.ProjectReloaded -= OnProjectReloaded;
-+ project.ProjectReloading -= OnProjectReloading;
-+// project.WidgetMemberNameChanged -= new Stetic.Wrapper.WidgetNameChangedHandler (OnWidgetNameChanged);
-
-- gproject.ModifiedChanged -= new EventHandler (OnModifiedChanged);
-- gproject.Changed -= new EventHandler (OnChanged);
-- gproject.ProjectReloaded -= OnProjectReloaded;
-- gproject.ProjectReloading -= OnProjectReloading;
--// gproject.WidgetMemberNameChanged -= new Stetic.Wrapper.WidgetNameChangedHandler (OnWidgetNameChanged);
--
-- if (!autoCommitChanges) {
-- // Don't dispose the project here! it will be disposed by the frontend
-- if (widget != null) {
-- widget.SelectionChanged -= OnSelectionChanged;
-- // Don't dispose the widget. It will be disposed when destroyed together
-- // with the container
-- widget = null;
-- }
-- }
--
- if (plug != null)
- plug.Destroy ();
-- gproject = null;
- rootWidget = null;
- frontend = null;
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
-@@ -231,7 +178,7 @@
- }
-
- public bool Modified {
-- get { return gproject.Modified; }
-+ get { return project.WasModified (RootWidget.Name); }
- }
-
- public UndoQueue UndoQueue {
-@@ -243,32 +190,22 @@
- }
- }
-
-- void OnModifiedChanged (object s, EventArgs a)
-+ void OnChanged (object s, ProjectChangedEventArgs a)
- {
-+ if (a.ChangedTopLevelName != RootWidget.Name)
-+ return;
-+
- if (frontend != null)
-- frontend.NotifyModifiedChanged ();
-- }
--
-- void OnChanged (object s, EventArgs a)
-- {
-- if (frontend != null)
- frontend.NotifyChanged ();
- }
-
- void OnSourceProjectReloaded (object s, EventArgs a)
- {
-- // Propagate gtk version change
-- if (sourceProject.TargetGtkVersion != gproject.TargetGtkVersion)
-- gproject.TargetGtkVersion = sourceProject.TargetGtkVersion;
-+
- }
-
- void OnSourceProjectLibsChanged (object s, EventArgs a)
- {
-- // If component types have changed in the source project, they must also change
-- // in this project.
-- gproject.WidgetLibraries = (ArrayList) sourceProject.WidgetLibraries.Clone ();
-- gproject.InternalWidgetLibraries = (ArrayList) sourceProject.InternalWidgetLibraries.Clone ();
-- gproject.NotifyComponentTypesChanged ();
- }
-
- void OnProjectReloading (object s, EventArgs a)
-@@ -279,16 +216,10 @@
-
- void OnProjectReloaded (object s, EventArgs a)
- {
-- // Update the actions group list
-- if (!autoCommitChanges) {
-- gproject.AttachActionGroups (sourceProject.ActionGroups);
-- gproject.WidgetLibraries = (ArrayList) sourceProject.WidgetLibraries.Clone ();
-- gproject.InternalWidgetLibraries = (ArrayList) sourceProject.InternalWidgetLibraries.Clone ();
-- }
-+ Gtk.Widget topWidget = project.GetWidget (sourceWidget);
-
-- Gtk.Widget[] tops = gproject.Toplevels;
-- if (tops.Length > 0) {
-- rootWidget = Stetic.Wrapper.Container.Lookup (tops[0]);
-+ if (topWidget != null) {
-+ rootWidget = Stetic.Wrapper.Container.Lookup (topWidget);
- undoManager.RootObject = rootWidget;
- if (rootWidget != null) {
- Gtk.Widget oldWidget = designer;
-@@ -305,8 +236,8 @@
- return false;
- });
- }
--
-- gproject.NotifyComponentTypesChanged ();
-+
-+ project.NotifyComponentTypesChanged ();
- return;
- }
- }
-@@ -375,7 +306,7 @@
- public object SaveState ()
- {
- return new object[] {
-- gproject.SaveStatus (),
-+ project.SaveStatus (),
- undoQueue
- };
- }
-@@ -383,7 +314,7 @@
- public void RestoreState (object sessionData)
- {
- object[] status = (object[]) sessionData;
-- gproject.LoadStatus (status [0]);
-+ project.LoadStatus (status [0]);
- undoQueue = (UndoQueue) status [1];
- foreach (UndoRedoChange ch in undoQueue.Changes) {
- ObjectWrapperUndoRedoChange och = ch as ObjectWrapperUndoRedoChange;
-Index: libsteticui/ChangeLog
-===================================================================
---- libsteticui/ChangeLog (revision 17)
-+++ libsteticui/ChangeLog (working copy)
-@@ -1,3 +1,155 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * CodeGenerator.cs:
-+ * ProjectBackend.cs:
-+ * WidgetEditSession.cs:
-+ * CodeGeneratorPartialClass.cs:
-+
-+2010-08-13 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * Project.cs:
-+ * Makefile.am:
-+ * CodeGenerator.cs:
-+ * libsteticui2.csproj:
-+ * ActionGroupEditSession.cs:
-+ * CodeGeneratorPartialClass.cs:
-+ * CodeGeneratorInternalClass.cs: Remove class
-+
-+2010-08-09 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * Project.cs: Add ComponentNeedsCodeGeneration method
-+ * ProjectBackend.cs:
-+ * IProjectDesignInfo.cs:
-+ * CodeGeneratorPartialClass.cs: Only generate code for components that
-+ have been changed
-+
-+2010-08-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Project.cs: Remove Modifies property
-+ * ProjectBackend.cs: Add modifiedTopLevel list, handled on project loading, saving.
-+ * libsteticui2.csproj:
-+ * WidgetEditSession.cs: Use ProjectBackend.WasModified to determine if it was modified
-+
-+2010-08-05 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * WidgetDesigner.cs:
-+ * ProjectBackend.cs:
-+
-+2010-08-05 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+ Remove ModifiedChanged event,
-+ change Changed event to ProjectChangedEventHandler (pass name of changed widget)
-+ * Project.cs:
-+ * WidgetDesigner.cs:
-+ * ProjectBackend.cs:
-+ * WidgetEditSession.cs:
-+
-+2010-08-04 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * Project.cs: Pass root widget name in NotifyChanged
-+ * Makefile.am:
-+ * ProjectBackend.cs:
-+ * libsteticui2.csproj:
-+
-+2010-08-03 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Glade.cs:
-+ * Makefile.am:
-+ * ProjectBackend.cs:
-+
-+2010-08-03 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * ProjectBackend.cs: Return empty string when GtktargetVersion
-+ is not initialized
-+
-+2010-07-27 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Project.cs: Remove autoCommit argument
-+ * Makefile.am:
-+ * WidgetDesigner.cs: Remove temporary project
-+ * ProjectBackend.cs: Do not clear libraries on Close
-+ * WidgetEditSession.cs: Remove temporary project
-+
-+2010-07-27 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Project.cs:
-+ * WidgetDesigner.cs:
-+ * ProjectBackend.cs:
-+
-+2010-07-06 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Project.cs: Add parameter to Convert method for passing
-+ a new gtk gui folder name.
-+ * ProjectBackend.cs:
-+
-+2010-07-05 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Glade.cs:
-+ * Project.cs: AddComponent method
-+ * Makefile.am:
-+ * ProjectBackend.cs:
-+ * libsteticui2.csproj:
-+
-+2010-06-28 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Project.cs: Find class name for given .gtkx file
-+ * Makefile.am:
-+ * ProjectBackend.cs:
-+ * IProjectDesignInfo.cs:
-+
-+2010-06-28 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * ProjectBackend.cs:
-+ * libsteticui2.csproj:
-+
-+2010-06-23 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * libsteticui2.csproj:
-+
-+2010-06-23 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * libsteticui2.csproj:
-+
-+2010-06-22 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+
-+2010-06-16 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+
-+2010-06-15 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Project.cs: Create backend for Convert
-+
-+2010-06-09 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * libsteticui2.csproj:
-+
-+2010-06-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Project.cs: Transition from project file name to project folder.
-+ * Makefile.am:
-+ * Application.cs:
-+ * ProjectBackend.cs:
-+ * WidgetEditSession.cs:
-+
-+2010-06-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Project.cs:
-+ * Makefile.am:
-+ * ProjectBackend.cs:
-+ * IProjectDesignInfo.cs:
-+
-+2010-06-02 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * libsteticui2.csproj:
-+
- 2010-04-16 Lluis Sanchez Gual <lluis@novell.com>
-
- * CecilSignalDescriptor.cs: Cecil uses '/' as separator for
-Index: libsteticui/libsteticui2.csproj
-===================================================================
---- libsteticui/libsteticui2.csproj (revision 17)
-+++ libsteticui/libsteticui2.csproj (working copy)
-@@ -60,17 +60,34 @@
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="System.Core" />
-+ <Reference Include="NRefactory, Version=2.1.1.0, Culture=neutral, PublicKeyToken=efe927acf176eea2">
-+ <Package>monodevelop</Package>
-+ </Reference>
-+ <Reference Include="Mono.TextEditor, Version=1.0.0.0, Culture=neutral">
-+ <Package>monodevelop</Package>
-+ </Reference>
-+ <Reference Include="MonoDevelop.Core, Version=2.4.0.0, Culture=neutral">
-+ <Package>monodevelop</Package>
-+ </Reference>
-+ <Reference Include="MonoDevelop.Ide, Version=2.4.0.0, Culture=neutral">
-+ <Package>monodevelop</Package>
-+ </Reference>
-+ <Reference Include="Mono.Debugging, Version=0.0.0.0, Culture=neutral, PublicKeyToken=9307d64546e0580d">
-+ <Package>monodevelop</Package>
-+ </Reference>
-+ <Reference Include="Mono.Cecil, Version=0.6.9.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
-+ <Package>monodevelop</Package>
-+ </Reference>
- </ItemGroup>
- <ItemGroup>
-+ <ProjectReference Include="..\libstetic\libstetic2.csproj">
-+ <Project>{90CBA7FD-CB46-4711-97BB-2420DC01F016}</Project>
-+ <Name>libstetic2</Name>
-+ </ProjectReference>
- <ProjectReference Include="..\..\..\..\contrib\Mono.Cecil\Mono.Cecil.csproj">
- <Project>{3EC06433-F168-4C5B-A885-99CE4AB617E1}</Project>
- <Name>Mono.Cecil</Name>
-- <Private>False</Private>
- </ProjectReference>
-- <ProjectReference Include="..\libstetic\libstetic2.csproj">
-- <Project>{90CBA7FD-CB46-4711-97BB-2420DC01F016}</Project>
-- <Name>libstetic2</Name>
-- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ActionComponent.cs" />
-@@ -90,7 +107,6 @@
- <Compile Include="CecilWidgetLibrary.cs" />
- <Compile Include="CodeGenerationResult.cs" />
- <Compile Include="CodeGenerator.cs" />
-- <Compile Include="CodeGeneratorInternalClass.cs" />
- <Compile Include="CodeGeneratorPartialClass.cs" />
- <Compile Include="Component.cs" />
- <Compile Include="ComponentEventHandler.cs" />
-Index: libsteticui/ActionGroupEditSession.cs
-===================================================================
---- libsteticui/ActionGroupEditSession.cs (revision 17)
-+++ libsteticui/ActionGroupEditSession.cs (working copy)
-@@ -197,6 +197,9 @@
- get { return modified; }
- set { modified = value; frontend.NotifyModified (); }
- }
-+// public bool Modified {
-+// get { return project.WasModified (); }
-+// }
-
- public string ActiveGroup {
- get {
-Index: libsteticui/CodeGenerator.cs
-===================================================================
---- libsteticui/CodeGenerator.cs (revision 17)
-+++ libsteticui/CodeGenerator.cs (working copy)
-@@ -36,13 +36,13 @@
- ArrayList warningList = new ArrayList ();
-
- List<SteticCompilationUnit> units = new List<SteticCompilationUnit> ();
-- SteticCompilationUnit globalUnit = new SteticCompilationUnit ("");
-- units.Add (globalUnit);
-+// SteticCompilationUnit globalUnit = new SteticCompilationUnit ("");
-+// units.Add (globalUnit);
-
- if (options == null)
- options = new GenerationOptions ();
- CodeNamespace globalNs = new CodeNamespace (options.GlobalNamespace);
-- globalUnit.Namespaces.Add (globalNs);
-+// globalUnit.Namespaces.Add (globalNs);
-
- // Global class
-
-@@ -73,11 +73,7 @@
- warningList.AddRange (initContext.Warnings);
-
- // Generate the code
--
-- if (options.UsePartialClasses)
-- CodeGeneratorPartialClass.GenerateProjectGuiCode (globalUnit, globalNs, globalType, options, units, projects, warningList);
-- else
-- CodeGeneratorInternalClass.GenerateProjectGuiCode (globalUnit, globalNs, globalType, options, units, projects, warningList);
-+ CodeGeneratorPartialClass.GenerateProjectGuiCode (globalNs, globalType, options, units, projects, warningList);
-
- GenerateProjectActionsCode (globalNs, options, projects);
-
-@@ -108,6 +104,19 @@
- initMethod.Statements.Clear ();
- initMethod.Statements.Add (initCondition);
-
-+ //create separate compilation unit for each type in the global namespace
-+ //and insert them at the begining of the units list.
-+ int index = 0;
-+ foreach (CodeTypeDeclaration type in globalNs.Types)
-+ {
-+ SteticCompilationUnit unit = new SteticCompilationUnit (type.Name);
-+ CodeNamespace ns = new CodeNamespace (globalNs.Name);
-+
-+ ns.Types.Add (type);
-+ unit.Namespaces.Add (ns);
-+ units.Insert (index++, unit);
-+ }
-+
- return new CodeGenerationResult (units.ToArray (), (string[]) warningList.ToArray (typeof(string)));
- }
-
-@@ -116,26 +125,11 @@
- foreach (Signal signal in wrapper.Signals) {
- SignalDescriptor descriptor = signal.SignalDescriptor;
-
-- CodeExpression createDelegate;
-+ CodeExpression createDelegate = new CodeDelegateCreateExpression (
-+ new CodeTypeReference (descriptor.HandlerTypeName, CodeTypeReferenceOptions.GlobalReference),
-+ new CodeThisReferenceExpression (),
-+ signal.Handler);
-
-- if (options.UsePartialClasses) {
-- createDelegate =
-- new CodeDelegateCreateExpression (
-- new CodeTypeReference (descriptor.HandlerTypeName, CodeTypeReferenceOptions.GlobalReference),
-- new CodeThisReferenceExpression (),
-- signal.Handler);
-- } else {
-- createDelegate =
-- new CodeMethodInvokeExpression (
-- new CodeTypeReferenceExpression (new CodeTypeReference (typeof(Delegate), CodeTypeReferenceOptions.GlobalReference)),
-- "CreateDelegate",
-- new CodeTypeOfExpression (descriptor.HandlerTypeName),
-- targetObjectVar,
-- new CodePrimitiveExpression (signal.Handler));
--
-- createDelegate = new CodeCastExpression (descriptor.HandlerTypeName.ToGlobalTypeRef (), createDelegate);
-- }
--
- CodeAttachEventStatement cevent = new CodeAttachEventStatement (
- new CodeEventReferenceExpression (
- map.GetWidgetExp (wrapper),
-@@ -374,7 +368,7 @@
- if (memberName == null)
- return base.GenerateInstanceExpression (wrapper, newObject);
-
-- if (Options.UsePartialClasses) {
-+// if (Options.UsePartialClasses) {
- // Don't generate fields for top level widgets and for widgets accessible
- // through other widget's properties
- Wrapper.Widget ww = wrapper as Wrapper.Widget;
-@@ -399,19 +393,19 @@
- return var;
- } else
- return base.GenerateInstanceExpression (wrapper, newObject);
-- } else {
-- CodeExpression var = base.GenerateInstanceExpression (wrapper, newObject);
-- Statements.Add (
-- new CodeAssignStatement (
-- new CodeIndexerExpression (
-- new CodeVariableReferenceExpression ("bindings"),
-- new CodePrimitiveExpression (memberName)
-- ),
-- var
-- )
-- );
-- return var;
-- }
-+// } else {
-+// CodeExpression var = base.GenerateInstanceExpression (wrapper, newObject);
-+// Statements.Add (
-+// new CodeAssignStatement (
-+// new CodeIndexerExpression (
-+// new CodeVariableReferenceExpression ("bindings"),
-+// new CodePrimitiveExpression (memberName)
-+// ),
-+// var
-+// )
-+// );
-+// return var;
-+// }
- }
- }
-
-@@ -429,5 +423,10 @@
- get { return name; }
- internal set { name = value; }
- }
-+
-+ public CodeNamespace Namespace
-+ {
-+ get { return (Namespaces.Count > 0) ? Namespaces [0] : null; }
-+ }
- }
- }
-Index: libsteticui/CodeGeneratorPartialClass.cs
-===================================================================
---- libsteticui/CodeGeneratorPartialClass.cs (revision 17)
-+++ libsteticui/CodeGeneratorPartialClass.cs (working copy)
-@@ -11,32 +11,47 @@
- {
- internal static class CodeGeneratorPartialClass
- {
-- public static void GenerateProjectGuiCode (SteticCompilationUnit globalUnit, CodeNamespace globalNs, CodeTypeDeclaration globalType, GenerationOptions options, List<SteticCompilationUnit> units, ProjectBackend[] projects, ArrayList warnings)
-+ public static void GenerateProjectGuiCode (CodeNamespace globalNs, CodeTypeDeclaration globalType, GenerationOptions options, List<SteticCompilationUnit> units, ProjectBackend[] projects, ArrayList warnings)
- {
- // Generate code for each project
- foreach (ProjectBackend gp in projects) {
-
- // Generate top levels
-- foreach (Gtk.Widget w in gp.Toplevels)
-- GenerateWidgetCode (globalUnit, globalNs, options, units, w, warnings);
-+ foreach (Gtk.Widget w in gp.Toplevels) {
-+ Stetic.Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup (w);
-+ string topLevelName = wwidget.Name;
-+ if (gp.ComponentNeedsCodeGeneration (topLevelName)) {
-+ //designer file for widget could be changed beyond stetic process
-+ //and we nead update wrapper before code generation
-+ //during reloading wrappered widget w could be changed;
-+ Gtk.Widget currentw = w;
-+ if (gp.ReloadTopLevel (topLevelName)) {
-+ currentw = gp.GetWidget (topLevelName);
-+ }
-+ GenerateWidgetCode (globalNs, options, units, currentw, warnings);
-+ }
-+ }
-
- // Generate global action groups
-- foreach (Wrapper.ActionGroup agroup in gp.ActionGroups)
-- GenerateGlobalActionGroupCode (globalUnit, globalNs, options, units, agroup, warnings);
-+ foreach (Wrapper.ActionGroup agroup in gp.ActionGroups) {
-+ string groupName = agroup.Name;
-+ if (gp.ComponentNeedsCodeGeneration (groupName)) {
-+ //designer file for action group could be changed beyond stetic process
-+ //and we nead update wrapper
-+ gp.ReloadActionGroup (groupName);
-+ GenerateGlobalActionGroupCode (globalNs, options, units, agroup, warnings);
-+ }
-+ }
- }
- }
-
-- static CodeTypeDeclaration CreatePartialClass (SteticCompilationUnit globalUnit, List<SteticCompilationUnit> units, GenerationOptions options, string name)
-+ static CodeTypeDeclaration CreatePartialClass (List<SteticCompilationUnit> units, GenerationOptions options, string name)
- {
- SteticCompilationUnit unit;
--
-- if (options.GenerateSingleFile)
-- unit = globalUnit;
-- else {
-- unit = new SteticCompilationUnit (name);
-- units.Add (unit);
-- }
--
-+
-+ unit = new SteticCompilationUnit (name);
-+ units.Add (unit);
-+
- string ns = "";
- int i = name.LastIndexOf ('.');
- if (i != -1) {
-@@ -56,11 +71,11 @@
- }
-
-
-- static void GenerateWidgetCode (SteticCompilationUnit globalUnit, CodeNamespace globalNs, GenerationOptions options, List<SteticCompilationUnit> units, Gtk.Widget w, ArrayList warnings)
-+ static void GenerateWidgetCode (CodeNamespace globalNs, GenerationOptions options, List<SteticCompilationUnit> units, Gtk.Widget w, ArrayList warnings)
- {
- // Generate the build method
-
-- CodeTypeDeclaration type = CreatePartialClass (globalUnit, units, options, w.Name);
-+ CodeTypeDeclaration type = CreatePartialClass (units, options, w.Name);
- CodeMemberMethod met = new CodeMemberMethod ();
- met.Name = "Build";
- type.Members.Add (met);
-@@ -107,9 +122,9 @@
- }
-
-
-- static void GenerateGlobalActionGroupCode (SteticCompilationUnit globalUnit, CodeNamespace globalNs, GenerationOptions options, List<SteticCompilationUnit> units, Wrapper.ActionGroup agroup, ArrayList warnings)
-+ static void GenerateGlobalActionGroupCode (CodeNamespace globalNs, GenerationOptions options, List<SteticCompilationUnit> units, Wrapper.ActionGroup agroup, ArrayList warnings)
- {
-- CodeTypeDeclaration type = CreatePartialClass (globalUnit, units, options, agroup.Name);
-+ CodeTypeDeclaration type = CreatePartialClass (units, options, agroup.Name);
-
- // Generate the build method
-
-Index: libsteticui/WidgetDesigner.cs
-===================================================================
---- libsteticui/WidgetDesigner.cs (revision 17)
-+++ libsteticui/WidgetDesigner.cs (working copy)
-@@ -1,4 +1,3 @@
--
- using System;
- using System.Collections;
-
-@@ -14,17 +13,14 @@
- Component rootWidget;
-
- Project project;
-- Project editedProject;
- int reloadCount;
-
- string componentName;
-- bool autoCommitChanges;
- bool disposed;
-
- bool canCut, canCopy, canPaste, canDelete;
-
- public event EventHandler BindField;
-- public event EventHandler ModifiedChanged;
- public event EventHandler Changed;
- public event EventHandler SelectionChanged;
- public event EventHandler RootComponentChanged;
-@@ -34,26 +30,18 @@
- public event ComponentNameEventHandler ComponentNameChanged;
- public event EventHandler ComponentTypesChanged;
-
-- internal WidgetDesigner (Project project, string componentName, bool autoCommitChanges): base (project.App)
-+ internal WidgetDesigner (Project project, string componentName): base (project.App)
- {
- this.componentName = componentName;
-- this.autoCommitChanges = autoCommitChanges;
- this.project = project;
- frontend = new WidgetDesignerFrontend (this);
-
-- if (autoCommitChanges)
-- editedProject = project;
-- else
-- editedProject = new Project (project.App, project.DesignInfo);
--
-- editedProject.SignalAdded += OnSignalAdded;
-- editedProject.SignalRemoved += OnSignalRemoved;
-- editedProject.SignalChanged += OnSignalChanged;
-- editedProject.ComponentNameChanged += OnComponentNameChanged;
-- editedProject.ComponentTypesChanged += OnComponentTypesChanged;
--
-+ project.SignalAdded += OnSignalAdded;
-+ project.SignalRemoved += OnSignalRemoved;
-+ project.SignalChanged += OnSignalChanged;
-+ project.ComponentNameChanged += OnComponentNameChanged;
-+ project.ComponentTypesChanged += OnComponentTypesChanged;
- project.BackendChanged += OnProjectBackendChanged;
-- editedProject.BackendChanged += OnProjectBackendChanged;
-
- CreateSession ();
- }
-@@ -70,8 +58,8 @@
- {
- if (!disposed) {
- ArrayList types = new ArrayList ();
-- types.AddRange (editedProject.GetComponentTypes ());
--
-+ types.AddRange (project.GetComponentTypes ());
-+
- // Add actions from the local action groups
-
- WidgetComponent c = rootWidget as WidgetComponent;
-@@ -90,12 +78,14 @@
- public void BeginComponentDrag (ComponentType type, Gtk.Widget source, Gdk.DragContext ctx)
- {
- Stetic.ObjectWrapper wrapper = type.Action != null ? (Stetic.ObjectWrapper) type.Action.Backend : null;
-- app.Backend.BeginComponentDrag (editedProject.ProjectBackend, type.Description, type.ClassName, wrapper, source, ctx, null);
-+ app.Backend.BeginComponentDrag (project.ProjectBackend, type.Description, type.ClassName, wrapper, source, ctx, null);
-+
- }
-
- public void BeginComponentDrag (string title, string className, Gtk.Widget source, Gdk.DragContext ctx, ComponentDropCallback callback)
- {
-- app.Backend.BeginComponentDrag (editedProject.ProjectBackend, title, className, null, source, ctx, callback);
-+ app.Backend.BeginComponentDrag (project.ProjectBackend, title, className, null, source, ctx, callback);
-+
- }
-
- // Creates an action group designer for the widget being edited by this widget designer
-@@ -103,7 +93,8 @@
- {
- if (disposed)
- throw new ObjectDisposedException ("WidgetDesigner");
-- return new ActionGroupDesigner (editedProject, componentName, null, this, true);
-+ return new ActionGroupDesigner (project, componentName, null, this, true);
-+
- }
-
- public bool Modified {
-@@ -113,7 +104,7 @@
- internal override void SetActive ()
- {
- if (!disposed)
-- project.App.SetActiveDesignSession (editedProject, session);
-+ project.App.SetActiveDesignSession (project, session);
- }
-
- public bool AllowWidgetBinding {
-@@ -125,8 +116,8 @@
- }
-
- public ImportFileDelegate ImportFileCallback {
-- get { return editedProject.ImportFileCallback; }
-- set { editedProject.ImportFileCallback = value; }
-+ get { return project.ImportFileCallback; }
-+ set { project.ImportFileCallback = value; }
- }
-
- public object SaveStatus ()
-@@ -142,7 +133,7 @@
- void CreateSession ()
- {
- try {
-- session = project.ProjectBackend.CreateWidgetDesignerSession (frontend, componentName, editedProject.ProjectBackend, autoCommitChanges);
-+ session = project.ProjectBackend.CreateWidgetDesignerSession (frontend, componentName);
- ResetCustomWidget ();
- rootWidget = app.GetComponent (session.RootWidget, null, null);
- } catch (Exception ex) {
-@@ -232,27 +223,23 @@
- if (disposed)
- return;
-
-- if (project.App.ActiveProject == editedProject)
-+ if (project.App.ActiveProject == project)
- project.App.ActiveProject = null;
-
- disposed = true;
- frontend.disposed = true;
-- editedProject.SignalAdded -= OnSignalAdded;
-- editedProject.SignalRemoved -= OnSignalRemoved;
-- editedProject.SignalChanged -= OnSignalChanged;
-- editedProject.ComponentNameChanged -= OnComponentNameChanged;
-- editedProject.BackendChanged -= OnProjectBackendChanged;
-- editedProject.ComponentTypesChanged -= OnComponentTypesChanged;
-+ project.SignalAdded -= OnSignalAdded;
-+ project.SignalRemoved -= OnSignalRemoved;
-+ project.SignalChanged -= OnSignalChanged;
-+ project.ComponentNameChanged -= OnComponentNameChanged;
-+ project.ComponentTypesChanged -= OnComponentTypesChanged;
- project.BackendChanged -= OnProjectBackendChanged;
-
- if (session != null) {
- session.Dispose ();
- session = null;
- }
--
-- if (!autoCommitChanges)
-- editedProject.Dispose ();
--
-+
- System.Runtime.Remoting.RemotingServices.Disconnect (frontend);
- frontend = null;
- rootWidget = null;
-@@ -309,10 +296,10 @@
- if (++reloadCount == 2) {
- object sessionData = null;
-
-- if (oldBackend != null && !autoCommitChanges) {
-- sessionData = session.SaveState ();
-- session.DestroyWrapperWidgetPlug ();
-- }
-+// if (oldBackend != null && !autoCommitChanges) {
-+// sessionData = session.SaveState ();
-+// session.DestroyWrapperWidgetPlug ();
-+// }
-
- // Don't dispose the session here, since it will dispose
- // the underlying project, and we can't do it because
-@@ -359,12 +346,6 @@
- BindField (this, EventArgs.Empty);
- }
-
-- internal void NotifyModifiedChanged ()
-- {
-- if (ModifiedChanged != null)
-- ModifiedChanged (this, EventArgs.Empty);
-- }
--
- internal void NotifyChanged ()
- {
- if (Changed != null)
-@@ -405,13 +386,6 @@
- );
- }
-
-- public void NotifyModifiedChanged ()
-- {
-- GuiDispatch.InvokeSync (
-- delegate { if (!disposed) designer.NotifyModifiedChanged (); }
-- );
-- }
--
- public void NotifyChanged ()
- {
- GuiDispatch.InvokeSync (
-Index: libsteticui/Makefile.am
-===================================================================
---- libsteticui/Makefile.am (revision 17)
-+++ libsteticui/Makefile.am (working copy)
-@@ -21,7 +21,6 @@
- CecilWidgetLibrary.cs \
- CodeGenerationResult.cs \
- CodeGenerator.cs \
-- CodeGeneratorInternalClass.cs \
- CodeGeneratorPartialClass.cs \
- Component.cs \
- ComponentEventHandler.cs \
-@@ -83,6 +82,7 @@
- $(GLADE_SHARP_LIBS) \
- $(GLIB_SHARP_LIBS) \
- $(GTK_SHARP_LIBS) \
-+ -pkg:monodevelop \
- -r:Mono.Posix \
- -r:System \
- -r:System.Core \
-Index: libsteticui/Project.cs
-===================================================================
---- libsteticui/Project.cs (revision 17)
-+++ libsteticui/Project.cs (working copy)
-@@ -12,7 +12,8 @@
- {
- Application app;
- ProjectBackend backend;
-- string fileName;
-+ //string fileName;
-+ string folderName;
- IResourceProvider resourceProvider;
- Component selection;
- string tmpProjectFile;
-@@ -72,8 +73,8 @@
- backend.SetFrontend (this);
- if (resourceProvider != null)
- backend.ResourceProvider = resourceProvider;
-- if (fileName != null)
-- backend.Load (fileName);
-+ if (folderName != null)
-+ backend.Load (folderName);
- }
- return backend;
- }
-@@ -114,9 +115,9 @@
- return null;
- }
-
-- public string FileName {
-- get { return fileName; }
-- }
-+// public string FileName {
-+// get { return fileName; }
-+// }
-
- public IResourceProvider ResourceProvider {
- get { return resourceProvider; }
-@@ -161,41 +162,16 @@
- backend.Close ();
- }
-
-- public void Load (string fileName)
-+ public void Load (string folderName)
- {
-- this.fileName = fileName;
-+ this.folderName = folderName;
- if (backend != null)
-- backend.Load (fileName);
-+ backend.Load (folderName);
-
-- using (StreamReader sr = new StreamReader (fileName)) {
-- XmlTextReader reader = new XmlTextReader (sr);
-+ foreach (string basePath in DesignInfo.GetComponentFolders ()) {
-+ if (!Directory.Exists (basePath))
-+ continue;
-
-- reader.MoveToContent ();
-- if (reader.IsEmptyElement)
-- return;
--
-- reader.ReadStartElement ("stetic-interface");
-- if (reader.IsEmptyElement)
-- return;
-- while (reader.NodeType != XmlNodeType.EndElement) {
-- if (reader.NodeType == XmlNodeType.Element) {
-- if (reader.LocalName == "widget")
-- ReadWidget (reader);
-- else if (reader.LocalName == "action-group")
-- ReadActionGroup (reader);
-- else
-- reader.Skip ();
-- }
-- else {
-- reader.Skip ();
-- }
-- reader.MoveToContent ();
-- }
-- }
--
--// string basePath = fileName != null ? Path.GetDirectoryName (fileName) : null;
--
-- foreach (string basePath in DesignInfo.GetComponentFolders ()) {
- DirectoryInfo dir = new DirectoryInfo (basePath);
-
- foreach (FileInfo file in dir.GetFiles ()) {
-@@ -257,11 +233,21 @@
- reader.Skip ();
- }
-
-- public void Save (string fileName)
-+ public void ConvertProject (string oldSteticFileName, string newGuiFolderName)
- {
-- this.fileName = fileName;
-+ //ProjectBackend property when created invokes Load method which is not valid
-+ //for old file layout
-+
-+ ProjectBackend backend = app.Backend.CreateProject ();
-+ backend.SetFrontend (this);
-+ backend.ConvertProject (oldSteticFileName, newGuiFolderName);
-+ }
-+
-+ public void Save (string folderName)
-+ {
-+ this.folderName = folderName;
- if (backend != null)
-- backend.Save (fileName);
-+ backend.Save (folderName);
- }
-
- public void ImportGlade (string fileName)
-@@ -274,31 +260,6 @@
- ProjectBackend.ExportGlade (fileName);
- }
-
-- public object SaveStatus ()
-- {
-- return ProjectBackend.SaveStatus ();
-- }
--
-- public void LoadStatus (object status)
-- {
-- ProjectBackend.LoadStatus (status);
-- }
--
-- public bool Modified {
-- get {
-- if (backend != null)
-- return backend.Modified;
-- else
-- return modified;
-- }
-- set {
-- if (backend != null)
-- backend.Modified = value;
-- else
-- modified = true;
-- }
-- }
--
- public IEnumerable<WidgetInfo> Widgets {
- get { return widgets; }
- }
-@@ -323,9 +284,14 @@
- return null;
- }
-
-- public WidgetDesigner CreateWidgetDesigner (WidgetInfo widgetInfo, bool autoCommitChanges)
-+// public WidgetDesigner CreateWidgetDesigner (WidgetInfo widgetInfo, bool autoCommitChanges)
-+// {
-+// return new WidgetDesigner (this, widgetInfo.Name, autoCommitChanges);
-+// }
-+
-+ public WidgetDesigner CreateWidgetDesigner (WidgetInfo widgetInfo)
- {
-- return new WidgetDesigner (this, widgetInfo.Name, autoCommitChanges);
-+ return new WidgetDesigner (this, widgetInfo.Name);
- }
-
- public ActionGroupDesigner CreateActionGroupDesigner (ActionGroupInfo actionGroup, bool autoCommitChanges)
-@@ -341,7 +307,7 @@
- if (wi == null) {
- wi = new WidgetInfo (this, wc);
- widgets.Add (wi);
-- }
-+ }
- return wi;
- }
-
-@@ -357,6 +323,36 @@
- return wi;
- }
-
-+ public object AddNewComponent (string fileName)
-+ {
-+ object ob = ProjectBackend.AddNewComponent (fileName);
-+ object component = App.GetComponent (ob, null, null);
-+
-+ if (component is WidgetComponent) {
-+ var wc = (WidgetComponent) component;
-+ WidgetInfo wi = GetWidget (wc.Name);
-+ if (wi == null) {
-+ wi = new WidgetInfo (this, wc);
-+ widgets.Add (wi);
-+ }
-+ return wi;
-+ }
-+
-+ if (component is ActionGroupComponent) {
-+ var ac = (ActionGroupComponent) component;
-+ // Don't wait for the group added event to come to update the groups list since
-+ // it may be too late.
-+ ActionGroupInfo gi = GetActionGroup (ac.Name);
-+ if (gi == null) {
-+ gi = new ActionGroupInfo (this, ac.Name);
-+ groups.Add (gi);
-+ }
-+ return gi;
-+ }
-+
-+ return null;
-+ }
-+
- public ComponentType[] GetComponentTypes ()
- {
- ArrayList types = new ArrayList ();
-@@ -574,7 +570,7 @@
- );
- }
-
-- internal void NotifyChanged ()
-+ internal void NotifyChanged (string rootWidgetName)
- {
- GuiDispatch.InvokeSync (
- delegate {
-@@ -582,10 +578,14 @@
- Changed (this, EventArgs.Empty);
-
- // TODO: Optimize
-- foreach (ProjectItemInfo it in widgets)
-- it.NotifyChanged ();
-- foreach (ProjectItemInfo it in groups)
-- it.NotifyChanged ();
-+ foreach (ProjectItemInfo it in widgets) {
-+ if (it.Name == rootWidgetName)
-+ it.NotifyChanged ();
-+ }
-+ foreach (ProjectItemInfo it in groups) {
-+ if (it.Name == rootWidgetName)
-+ it.NotifyChanged ();
-+ }
- }
- );
- }
-@@ -732,11 +732,12 @@
- backend.SetFrontend (this);
-
- if (tmpProjectFile != null && File.Exists (tmpProjectFile)) {
-- backend.Load (tmpProjectFile, fileName);
-+// backend.Load (tmpProjectFile, fileName);
-+ throw new NotImplementedException ("OnBackendChanged");
- File.Delete (tmpProjectFile);
- tmpProjectFile = null;
-- } else if (fileName != null) {
-- backend.Load (fileName);
-+ } else if (folderName != null) {
-+ backend.Load (folderName);
- }
-
- if (resourceProvider != null)
-Index: libsteticui/Application.cs
-===================================================================
---- libsteticui/Application.cs (revision 17)
-+++ libsteticui/Application.cs (working copy)
-@@ -308,14 +308,14 @@
- UpdateWidgetLibraries (false, false);
- }
-
-- public Project LoadProject (string path, IProjectDesignInfo info)
-- {
-- Project p = new Project (this, info);
-- p.Load (path);
-- projects.Add (p);
-- p.Disposed += ProjectDisposed;
-- return p;
-- }
-+// public Project LoadProject (string path, IProjectDesignInfo info)
-+// {
-+// Project p = new Project (this, info);
-+// p.Load (path);
-+// projects.Add (p);
-+// p.Disposed += ProjectDisposed;
-+// return p;
-+// }
-
- public Project CreateProject (IProjectDesignInfo info)
- {
-Index: libsteticui/CodeGeneratorInternalClass.cs
-===================================================================
---- libsteticui/CodeGeneratorInternalClass.cs (revision 17)
-+++ libsteticui/CodeGeneratorInternalClass.cs (working copy)
-@@ -1,319 +0,0 @@
--
--using System;
--using System.Reflection;
--using System.CodeDom;
--using System.CodeDom.Compiler;
--using System.Collections.Generic;
--using System.IO;
--using System.Xml.Serialization;
--using System.Collections;
--
--namespace Stetic
--{
-- internal static class CodeGeneratorInternalClass
-- {
-- static CodeExpression bindingFlags;
--
-- static CodeGeneratorInternalClass ()
-- {
-- CodeTypeReferenceExpression flagsType = new CodeTypeReferenceExpression (new CodeTypeReference ("System.Reflection.BindingFlags", CodeTypeReferenceOptions.GlobalReference));
-- bindingFlags = new CodeBinaryOperatorExpression (
-- new CodeFieldReferenceExpression (flagsType, "Public"),
-- CodeBinaryOperatorType.BitwiseOr,
-- new CodeFieldReferenceExpression (flagsType, "NonPublic")
-- );
--
-- bindingFlags = new CodeBinaryOperatorExpression (
-- bindingFlags,
-- CodeBinaryOperatorType.BitwiseOr,
-- new CodeFieldReferenceExpression (flagsType, "Instance")
-- );
-- }
--
-- public static void GenerateProjectGuiCode (SteticCompilationUnit globalUnit, CodeNamespace globalNs, CodeTypeDeclaration globalType, GenerationOptions options, List<SteticCompilationUnit> units, ProjectBackend[] projects, ArrayList warnings)
-- {
-- bool multiProject = projects.Length > 1;
--
-- // Build method overload that takes a type as parameter.
--
-- CodeMemberMethod met = new CodeMemberMethod ();
-- met.Name = "Build";
-- globalType.Members.Add (met);
-- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object), "cobj"));
-- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(Type), "type"));
-- if (multiProject)
-- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(string), "file"));
-- met.ReturnType = new CodeTypeReference (typeof(void));
-- met.Attributes = MemberAttributes.Public | MemberAttributes.Static;
--
-- CodeMethodInvokeExpression call = new CodeMethodInvokeExpression (
-- new CodeMethodReferenceExpression (
-- new CodeTypeReferenceExpression (new CodeTypeReference (globalNs.Name + ".Gui", CodeTypeReferenceOptions.GlobalReference)),
-- "Build"
-- ),
-- new CodeArgumentReferenceExpression ("cobj"),
-- new CodePropertyReferenceExpression (
-- new CodeArgumentReferenceExpression ("type"),
-- "FullName"
-- )
-- );
-- if (multiProject)
-- call.Parameters.Add (new CodeArgumentReferenceExpression ("file"));
--
-- met.Statements.Add (call);
--
-- // Generate the build method
--
-- met = new CodeMemberMethod ();
-- met.Name = "Build";
-- globalType.Members.Add (met);
--
-- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object), "cobj"));
-- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(string), "id"));
-- if (multiProject)
-- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(string), "file"));
-- met.ReturnType = new CodeTypeReference (typeof(void));
-- met.Attributes = MemberAttributes.Public | MemberAttributes.Static;
--
-- if (options.GenerateEmptyBuildMethod)
-- return;
--
-- CodeArgumentReferenceExpression cobj = new CodeArgumentReferenceExpression ("cobj");
-- CodeArgumentReferenceExpression cfile = new CodeArgumentReferenceExpression ("file");
-- CodeArgumentReferenceExpression cid = new CodeArgumentReferenceExpression ("id");
--
-- CodeStatementCollection projectCol = met.Statements;
--
-- CodeConditionStatement tcond = new CodeConditionStatement ();
-- tcond.Condition = new CodeMethodInvokeExpression (new CodeTypeOfExpression (typeof(Gtk.Widget)), "IsAssignableFrom", cobj);
--
-- tcond.TrueStatements.Add (
-- new CodeMethodInvokeExpression (
-- new CodeTypeReferenceExpression (new CodeTypeReference (globalNs.Name + ".Gui", CodeTypeReferenceOptions.GlobalReference)),
-- "Initialize",
-- cobj
-- )
-- );
--
-- // Generate code for each project
--
-- foreach (ProjectBackend gp in projects) {
--
-- CodeStatementCollection widgetCol;
--
-- if (multiProject) {
-- CodeConditionStatement pcond = new CodeConditionStatement ();
-- pcond.Condition = new CodeBinaryOperatorExpression (
-- cfile,
-- CodeBinaryOperatorType.IdentityEquality,
-- new CodePrimitiveExpression (gp.Id)
-- );
-- projectCol.Add (pcond);
--
-- widgetCol = pcond.TrueStatements;
-- projectCol = pcond.FalseStatements;
-- } else {
-- widgetCol = projectCol;
-- }
--
-- // Generate top levels
--
-- CodeIdentifiers ids = new CodeIdentifiers ();
--
-- foreach (Gtk.Widget w in gp.Toplevels) {
-- CodeConditionStatement cond = new CodeConditionStatement ();
-- cond.Condition = new CodeBinaryOperatorExpression (
-- cid,
-- CodeBinaryOperatorType.IdentityEquality,
-- new CodePrimitiveExpression (w.Name)
-- );
-- widgetCol.Add (cond);
--
-- GenerateComponentCode (w, globalUnit, globalNs, cobj, cond.TrueStatements, globalType, options, units, ids, warnings);
--
-- widgetCol = cond.FalseStatements;
-- }
--
-- // Generate action groups
--
-- foreach (Wrapper.ActionGroup agroup in gp.ActionGroups) {
-- CodeConditionStatement cond = new CodeConditionStatement ();
-- cond.Condition = new CodeBinaryOperatorExpression (
-- cid,
-- CodeBinaryOperatorType.IdentityEquality,
-- new CodePrimitiveExpression (agroup.Name)
-- );
-- widgetCol.Add (cond);
--
-- GenerateComponentCode (agroup, globalUnit, globalNs, cobj, cond.TrueStatements, globalType, options, units, ids, warnings);
--
-- widgetCol = cond.FalseStatements;
-- }
-- }
-- }
--
-- static CodeMemberMethod GetBuildMethod (string name, string internalClassName, string typeName, SteticCompilationUnit globalUnit, GenerationOptions options, List<SteticCompilationUnit> units)
-- {
-- SteticCompilationUnit unit;
--
-- if (options.GenerateSingleFile)
-- unit = globalUnit;
-- else {
-- unit = new SteticCompilationUnit (name);
-- units.Add (unit);
-- }
--
-- CodeTypeDeclaration type = new CodeTypeDeclaration (internalClassName);
-- type.Attributes = MemberAttributes.Private;
-- type.TypeAttributes = TypeAttributes.NestedAssembly;
--
-- CodeNamespace cns = new CodeNamespace (options.GlobalNamespace + ".SteticGenerated");
-- cns.Types.Add (type);
-- unit.Namespaces.Add (cns);
--
-- // Create the build method for the component
--
-- CodeMemberMethod met = new CodeMemberMethod ();
-- met.Name = "Build";
-- type.Members.Add (met);
--
-- met.Parameters.Add (new CodeParameterDeclarationExpression (new CodeTypeReference (typeName), "cobj"));
-- met.ReturnType = new CodeTypeReference (typeof(void));
-- met.Attributes = MemberAttributes.Public | MemberAttributes.Static;
--
-- return met;
-- }
--
-- static void GenerateComponentCode (object component, SteticCompilationUnit globalUnit, CodeNamespace globalNs, CodeExpression cobj, CodeStatementCollection statements, CodeTypeDeclaration globalType, GenerationOptions options, List<SteticCompilationUnit> units, CodeIdentifiers ids, ArrayList warnings)
-- {
-- Gtk.Widget widget = component as Gtk.Widget;
-- Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup (widget);
-- Wrapper.ActionGroup agroup = component as Wrapper.ActionGroup;
--
-- string name = widget != null ? widget.Name : agroup.Name;
-- string internalClassName = ids.MakeUnique (CodeIdentifier.MakeValid (name));
--
-- string typeName = widget != null ? wwidget.WrappedTypeName : "Gtk.ActionGroup";
-- // Create the build method for the top level
--
-- CodeMemberMethod met;
-- met = GetBuildMethod (name, internalClassName, typeName, globalUnit, options, units);
--
-- // Generate the build code
--
-- CodeVariableDeclarationStatement varDecHash = new CodeVariableDeclarationStatement (typeof(System.Collections.Hashtable).ToGlobalTypeRef (), "bindings");
-- met.Statements.Add (varDecHash);
-- varDecHash.InitExpression = new CodeObjectCreateExpression (
-- typeof(System.Collections.Hashtable),
-- new CodeExpression [0]
-- );
--
-- CodeVariableReferenceExpression targetObjectVar = new CodeVariableReferenceExpression ("cobj");
-- Stetic.WidgetMap map;
--
-- if (widget != null) {
-- map = Stetic.CodeGenerator.GenerateCreationCode (globalNs, globalType, widget, targetObjectVar, met.Statements, options, warnings);
-- CodeGenerator.BindSignalHandlers (targetObjectVar, wwidget, map, met.Statements, options);
-- } else {
-- map = Stetic.CodeGenerator.GenerateCreationCode (globalNs, globalType, agroup, targetObjectVar, met.Statements, options, warnings);
-- foreach (Wrapper.Action ac in agroup.Actions)
-- CodeGenerator.BindSignalHandlers (targetObjectVar, ac, map, met.Statements, options);
-- }
--
-- GenerateBindFieldCode (met.Statements, cobj);
--
-- // Add a method call to the build method
--
-- statements.Add (
-- new CodeMethodInvokeExpression (
-- new CodeTypeReferenceExpression (new CodeTypeReference (options.GlobalNamespace + ".SteticGenerated." + internalClassName, CodeTypeReferenceOptions.GlobalReference)),
-- "Build",
-- new CodeCastExpression (typeName.ToGlobalTypeRef (), cobj)
-- )
-- );
-- }
--
-- static void GenerateBindFieldCode (CodeStatementCollection statements, CodeExpression cobj)
-- {
-- // Bind the fields
--
-- CodeVariableDeclarationStatement varDecIndex = new CodeVariableDeclarationStatement (typeof(int), "n");
-- varDecIndex.InitExpression = new CodePrimitiveExpression (0);
-- CodeExpression varIndex = new CodeVariableReferenceExpression ("n");
--
-- CodeVariableDeclarationStatement varDecArray = new CodeVariableDeclarationStatement (typeof(FieldInfo[]).ToGlobalTypeRef (), "fields");
-- varDecArray.InitExpression = new CodeMethodInvokeExpression (
-- new CodeMethodInvokeExpression (
-- cobj,
-- "GetType",
-- new CodeExpression [0]
-- ),
-- "GetFields",
-- bindingFlags
-- );
-- statements.Add (varDecArray);
-- CodeVariableReferenceExpression varArray = new CodeVariableReferenceExpression ("fields");
--
-- CodeIterationStatement iteration = new CodeIterationStatement ();
-- statements.Add (iteration);
--
-- iteration.InitStatement = varDecIndex;
--
-- iteration.TestExpression = new CodeBinaryOperatorExpression (
-- varIndex,
-- CodeBinaryOperatorType.LessThan,
-- new CodePropertyReferenceExpression (varArray, "Length")
-- );
-- iteration.IncrementStatement = new CodeAssignStatement (
-- varIndex,
-- new CodeBinaryOperatorExpression (
-- varIndex,
-- CodeBinaryOperatorType.Add,
-- new CodePrimitiveExpression (1)
-- )
-- );
--
-- CodeVariableDeclarationStatement varDecField = new CodeVariableDeclarationStatement (typeof(FieldInfo).ToGlobalTypeRef (), "field");
-- varDecField.InitExpression = new CodeArrayIndexerExpression (varArray, new CodeExpression [] {varIndex});
-- CodeVariableReferenceExpression varField = new CodeVariableReferenceExpression ("field");
-- iteration.Statements.Add (varDecField);
--
-- CodeVariableDeclarationStatement varDecWidget = new CodeVariableDeclarationStatement (typeof(object), "widget");
-- iteration.Statements.Add (varDecWidget);
-- varDecWidget.InitExpression = new CodeIndexerExpression (
-- new CodeVariableReferenceExpression ("bindings"),
-- new CodePropertyReferenceExpression (varField, "Name")
-- );
-- CodeVariableReferenceExpression varWidget = new CodeVariableReferenceExpression ("widget");
--
-- // Make sure the type of the field matches the type of the widget
--
-- CodeConditionStatement fcond = new CodeConditionStatement ();
-- iteration.Statements.Add (fcond);
-- fcond.Condition = new CodeBinaryOperatorExpression (
-- new CodeBinaryOperatorExpression (
-- varWidget,
-- CodeBinaryOperatorType.IdentityInequality,
-- new CodePrimitiveExpression (null)
-- ),
-- CodeBinaryOperatorType.BooleanAnd,
-- new CodeMethodInvokeExpression (
-- new CodePropertyReferenceExpression (varField, "FieldType"),
-- "IsInstanceOfType",
-- varWidget
-- )
-- );
--
-- // Set the variable value
--
-- fcond.TrueStatements.Add (
-- new CodeMethodInvokeExpression (
-- varField,
-- "SetValue",
-- cobj,
-- varWidget
-- )
-- );
-- }
-- }
--}
-Index: libsteticui/Glade.cs
-===================================================================
---- libsteticui/Glade.cs (revision 17)
-+++ libsteticui/Glade.cs (working copy)
-@@ -17,7 +17,6 @@
- doc.PreserveWhitespace = true;
- doc.XmlResolver = null;
- doc.Load (filename);
-- project.SetFileName (filename);
- project.Id = System.IO.Path.GetFileName (filename);
- doc = GladeUtils.XslImportTransform (doc);
-
-@@ -27,7 +26,7 @@
-
- ObjectReader reader = new ObjectReader (project, FileFormat.Glade);
- foreach (XmlElement toplevel in node.SelectNodes ("widget")) {
-- Wrapper.Container wrapper = Stetic.ObjectWrapper.ReadObject (reader, toplevel) as Wrapper.Container;
-+ Wrapper.Container wrapper = Stetic.ObjectWrapper.ReadObject (reader, toplevel, null) as Wrapper.Container;
- if (wrapper != null)
- project.AddWidget ((Gtk.Widget)wrapper.Wrapped);
- }
-Index: libstetic/IProject.cs
-===================================================================
---- libstetic/IProject.cs (revision 17)
-+++ libstetic/IProject.cs (working copy)
-@@ -4,15 +4,16 @@
- {
- public interface IProject
- {
-- string FileName { get; }
-+ //string FileName { get; }
-+ string FolderName { get; }
- Gtk.Widget[] Toplevels { get; }
-- Gtk.Widget GetTopLevel (string name);
-+ Gtk.Widget GetWidget (string name);
- Gtk.Widget Selection { get; set; }
- Wrapper.ActionGroupCollection ActionGroups { get; }
- ProjectIconFactory IconFactory { get; }
- string ImagesRootPath { get; }
- string TargetGtkVersion { get; }
-- bool Modified { get; set; }
-+// bool Modified { get; set; }
- IResourceProvider ResourceProvider { get; set; }
-
- void PopupContextMenu (Stetic.Wrapper.Widget wrapper);
-Index: libstetic/editor/ChangeLog
-===================================================================
---- libstetic/editor/ChangeLog (revision 0)
-+++ libstetic/editor/ChangeLog (revision 111)
-@@ -0,0 +1,16 @@
-+2010-08-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * SelectIconDialog.cs: Remove setting Project.Modified property
-+ * EditIconFactoryDialog.cs: Remove setting Project.Modified property
-+
-+2010-08-03 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ActionMenu.cs: Pass root wrapper as an argument for ObjectWrapper.Create
-+ * ActionToolbar.cs:
-+ * ActionMenuBar.cs:
-+ * ActionGroupEditor.cs:
-+
-+2010-06-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * SelectImageDialog.cs:
-+
-Index: libstetic/editor/EditIconFactoryDialog.cs
-===================================================================
---- libstetic/editor/EditIconFactoryDialog.cs (revision 17)
-+++ libstetic/editor/EditIconFactoryDialog.cs (working copy)
-@@ -53,7 +53,7 @@
- iconFactory.Icons.Add (icon);
- customIconList.Refresh ();
- customIconList.Selection = icon.Name;
-- project.Modified = true;
-+// project.Modified = true;
- }
- }
- }
-@@ -69,7 +69,7 @@
- if (md.Run () == (int) Gtk.ResponseType.Yes) {
- iconFactory.Icons.Remove (icon);
- customIconList.Refresh ();
-- project.Modified = true;
-+// project.Modified = true;
- }
- md.Destroy ();
- }
-@@ -86,7 +86,7 @@
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
- customIconList.Refresh ();
- customIconList.Selection = icon.Name;
-- project.Modified = true;
-+// project.Modified = true;
- }
- }
- }
-Index: libstetic/editor/SelectIconDialog.cs
-===================================================================
---- libstetic/editor/SelectIconDialog.cs (revision 17)
-+++ libstetic/editor/SelectIconDialog.cs (working copy)
-@@ -137,7 +137,7 @@
- project.IconFactory.Icons.Add (icon);
- customIconList.Refresh ();
- customIconList.Selection = icon.Name;
-- project.Modified = true;
-+// project.Modified = true;
- }
- }
- }
-@@ -153,7 +153,7 @@
- if (md.Run () == (int) Gtk.ResponseType.Yes) {
- project.IconFactory.Icons.Remove (icon);
- customIconList.Refresh ();
-- project.Modified = true;
-+// project.Modified = true;
- }
- md.Destroy ();
- }
-@@ -170,7 +170,7 @@
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
- customIconList.Refresh ();
- customIconList.Selection = icon.Name;
-- project.Modified = true;
-+// project.Modified = true;
- }
- }
- }
-Index: libstetic/editor/ActionMenuBar.cs
-===================================================================
---- libstetic/editor/ActionMenuBar.cs (revision 17)
-+++ libstetic/editor/ActionMenuBar.cs (working copy)
-@@ -258,7 +258,9 @@
- {
- Widget wrapper = Widget.Lookup (this);
- using (wrapper.UndoManager.AtomicChange) {
-- Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project, new Gtk.Action ("", "", null, null));
-+ Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project,
-+ new Gtk.Action ("", "", null, null),
-+ wrapper);
- ActionTreeNode node = new ActionTreeNode (Gtk.UIManagerItemType.Menu, "", ac);
- actionTree.Children.Insert (pos, node);
-
-Index: libstetic/editor/ActionMenu.cs
-===================================================================
---- libstetic/editor/ActionMenu.cs (revision 17)
-+++ libstetic/editor/ActionMenu.cs (working copy)
-@@ -196,7 +196,9 @@
- ActionTreeNode InsertAction (int pos)
- {
- using (wrapper.UndoManager.AtomicChange) {
-- Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project, new Gtk.Action ("", "", null, null));
-+ Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project,
-+ new Gtk.Action ("", "", null, null),
-+ wrapper);
- ActionTreeNode newNode = new ActionTreeNode (Gtk.UIManagerItemType.Menuitem, null, ac);
- nodes.Insert (pos, newNode);
- ActionMenuItem item = FindMenuItem (newNode);
-Index: libstetic/editor/SelectImageDialog.cs
-===================================================================
---- libstetic/editor/SelectImageDialog.cs (revision 17)
-+++ libstetic/editor/SelectImageDialog.cs (working copy)
-@@ -80,7 +80,7 @@
- FillResources ();
- resourceList.Selection.Changed += OnResourceSelectionChanged;
-
-- if (project.FileName != null)
-+ if (project.FolderName != null)
- fileChooser.SetCurrentFolder (project.ImagesRootPath);
-
- fileChooser.SelectionChanged += delegate (object s, EventArgs a) {
-Index: libstetic/editor/ActionToolbar.cs
-===================================================================
---- libstetic/editor/ActionToolbar.cs (revision 17)
-+++ libstetic/editor/ActionToolbar.cs (working copy)
-@@ -237,7 +237,9 @@
- {
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (this);
- using (wrapper.UndoManager.AtomicChange) {
-- Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project, new Gtk.Action ("", "", null, null));
-+ Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project,
-+ new Gtk.Action ("", "", null, null),
-+ wrapper);
- ActionTreeNode node = new ActionTreeNode (Gtk.UIManagerItemType.Toolitem, "", ac);
- actionTree.Children.Insert (pos, node);
-
-Index: libstetic/editor/ActionGroupEditor.cs
-===================================================================
---- libstetic/editor/ActionGroupEditor.cs (revision 17)
-+++ libstetic/editor/ActionGroupEditor.cs (working copy)
-@@ -275,7 +275,9 @@
-
- void OnAddClicked (object s, Gtk.ButtonPressEventArgs args)
- {
-- Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (project, new Gtk.Action ("", "", null, null));
-+ Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (project,
-+ new Gtk.Action ("", "", null, null),
-+ ActionGroup);
- ActionMenuItem item = InsertAction (ac, actionGroup.Actions.Count);
- item.EditingDone += OnEditDone;
- item.Select ();
-Index: libstetic/ChangeLog
-===================================================================
---- libstetic/ChangeLog (revision 17)
-+++ libstetic/ChangeLog (working copy)
-@@ -1,3 +1,40 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * DND.cs:
-+ * IProject.cs:
-+
-+2010-08-13 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GeneratorContext.cs:
-+
-+2010-08-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * IProject.cs: Remove Modified property, add WasModified method which check state of a given top level
-+
-+2010-08-03 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GladeUtils.cs: Set ObjectWrapper.RootWrapperName when reading from xml
-+ * WidgetUtils.cs:
-+ * ObjectReader.cs:
-+ * ObjectWrapper.cs:
-+ * wrapper/Frame.cs:
-+ * wrapper/Window.cs:
-+ * wrapper/MenuItem.cs:
-+ * wrapper/Expander.cs:
-+ * undo/UndoManager.cs:
-+ * wrapper/Notebook.cs:
-+ * wrapper/Container.cs:
-+ * wrapper/OptionMenu.cs:
-+
-+2010-08-03 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ObjectWrapper.cs: Save a root wrapper name
-+
-+2010-06-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * IProject.cs:
-+ * ErrorWidget.cs:
-+
- 2010-04-30 Lluis Sanchez Gual <lluis@novell.com>
-
- * editor/ActionMenu.cs: Explicit destroy of children should
-Index: libstetic/GeneratorContext.cs
-===================================================================
---- libstetic/GeneratorContext.cs (revision 17)
-+++ libstetic/GeneratorContext.cs (working copy)
-@@ -522,11 +522,6 @@
- set { gettextClass = value; }
- }
-
-- public bool UsePartialClasses {
-- get { return partialClasses; }
-- set { partialClasses = value; }
-- }
--
- public string Path {
- get { return path; }
- set { path = value; }
-@@ -537,11 +532,6 @@
- set { generateEmptyBuildMethod = value; }
- }
-
-- public bool GenerateSingleFile {
-- get { return generateSingleFile; }
-- set { generateSingleFile = value; }
-- }
--
- public string GlobalNamespace {
- get { return globalNamespace; }
- set { globalNamespace = value; }
-Index: libstetic/DND.cs
-===================================================================
---- libstetic/DND.cs (revision 17)
-+++ libstetic/DND.cs (working copy)
-@@ -181,7 +181,7 @@
-
- if (targetWrapper.IsDisposed) {
- // The project has been reloaded. Find the wrapper again.
-- Gtk.Widget twidget = project.GetTopLevel (tname);
-+ Gtk.Widget twidget = project.GetWidget (tname);
- ObjectWrapper ow = ObjectWrapper.Lookup (twidget);
- if (ow != null)
- targetWrapper = ow.FindObjectByUndoId (uid);
-Index: libstetic/ObjectReader.cs
-===================================================================
---- libstetic/ObjectReader.cs (revision 17)
-+++ libstetic/ObjectReader.cs (working copy)
-@@ -25,14 +25,14 @@
- get { return proj; }
- }
-
-- public virtual ObjectWrapper ReadObject (XmlElement elem)
-+ public virtual ObjectWrapper ReadObject (XmlElement elem, ObjectWrapper root)
- {
-- return Stetic.ObjectWrapper.ReadObject (this, elem);
-+ return Stetic.ObjectWrapper.ReadObject (this, elem, root);
- }
-
-- public virtual void ReadObject (ObjectWrapper wrapper, XmlElement elem)
-+ public virtual void ReadExistingObject (ObjectWrapper wrapper, XmlElement elem)
- {
-- Stetic.ObjectWrapper.ReadObject (this, elem, wrapper);
-+ Stetic.ObjectWrapper.ReadExistingObject (this, elem, wrapper);
- }
- }
- }
-Index: libstetic/undo/UndoManager.cs
-===================================================================
---- libstetic/undo/UndoManager.cs (revision 17)
-+++ libstetic/undo/UndoManager.cs (working copy)
-@@ -227,17 +227,17 @@
- this.undoManager = undoManager;
- }
-
-- public override ObjectWrapper ReadObject (XmlElement elem)
-+ public override ObjectWrapper ReadObject (XmlElement elem, ObjectWrapper root)
- {
-- ObjectWrapper ww = base.ReadObject (elem);
-+ ObjectWrapper ww = base.ReadObject (elem, root);
- if (ww is Widget)
- undoManager.RegisterObject ((Widget)ww, elem);
- return ww;
- }
-
-- public override void ReadObject (ObjectWrapper wrapper, XmlElement elem)
-+ public override void ReadExistingObject (ObjectWrapper wrapper, XmlElement elem)
- {
-- base.ReadObject (wrapper, elem);
-+ base.ReadExistingObject (wrapper, elem);
- if (wrapper is Widget)
- undoManager.RegisterObject ((Widget)wrapper, elem);
- }
-Index: libstetic/ObjectWrapper.cs
-===================================================================
---- libstetic/ObjectWrapper.cs (revision 17)
-+++ libstetic/ObjectWrapper.cs (working copy)
-@@ -149,10 +149,13 @@
- get { return disposed; }
- }
-
-- public static ObjectWrapper Create (IProject proj, object wrapped)
-+ public static ObjectWrapper Create (IProject proj, object wrapped, ObjectWrapper root)
- {
- ClassDescriptor klass = Registry.LookupClassByName (wrapped.GetType ().FullName);
- ObjectWrapper wrapper = klass.CreateWrapper ();
-+ if (root != null) {
-+ wrapper.RootWrapperName = (root.RootWrapperName != null) ? root.RootWrapperName : root.Name;
-+ }
- wrapper.Loading = true;
- wrapper.proj = proj;
- wrapper.classDescriptor = klass;
-@@ -180,7 +183,7 @@
- throw new System.NotImplementedException ();
- }
-
-- public static ObjectWrapper ReadObject (ObjectReader reader, XmlElement elem)
-+ public static ObjectWrapper ReadObject (ObjectReader reader, XmlElement elem, ObjectWrapper root)
- {
- string className = elem.GetAttribute ("class");
- ClassDescriptor klass;
-@@ -191,24 +194,29 @@
-
- if (klass == null) {
- ErrorWidget we = new ErrorWidget (className, elem.GetAttribute ("id"));
-- ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we);
-+ ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we, null);
- wrap.Read (reader, elem);
- return wrap;
- }
- if (!klass.SupportsGtkVersion (reader.Project.TargetGtkVersion)) {
- ErrorWidget we = new ErrorWidget (className, klass.TargetGtkVersion, reader.Project.TargetGtkVersion, elem.GetAttribute ("id"));
-- ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we);
-+ ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we, null);
- wrap.Read (reader, elem);
- return wrap;
- }
-
- ObjectWrapper wrapper = klass.CreateWrapper ();
-+ if (root != null) {
-+ if (root.RootWrapperName != null) {
-+ wrapper.RootWrapperName = root.RootWrapperName;
-+ }
-+ }
- wrapper.classDescriptor = klass;
- wrapper.proj = reader.Project;
-- return ReadObject (reader, elem, wrapper);
-+ return ReadExistingObject (reader, elem, wrapper);
- }
-
-- public static ObjectWrapper ReadObject (ObjectReader reader, XmlElement elem, ObjectWrapper wrapper)
-+ public static ObjectWrapper ReadExistingObject (ObjectReader reader, XmlElement elem, ObjectWrapper wrapper)
- {
- try {
- wrapper.OnBeginRead (reader.Format);
-@@ -218,7 +226,7 @@
- catch (Exception ex) {
- Console.WriteLine (ex);
- ErrorWidget we = new ErrorWidget (ex, elem.GetAttribute ("id"));
-- ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we);
-+ ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we, null);
- wrap.Read (reader, elem);
- return wrap;
- }
-@@ -329,6 +337,10 @@
- OnObjectChanged (new ObjectWrapperEventArgs (this));
- }
-
-+ public abstract string Name { get; set; }
-+
-+ public string RootWrapperName { get; protected set; }
-+
- static object GetIndentityObject (object ob)
- {
- if (ob is Gtk.Container.ContainerChild) {
-Index: libstetic/wrapper/ChangeLog
-===================================================================
---- libstetic/wrapper/ChangeLog (revision 0)
-+++ libstetic/wrapper/ChangeLog (revision 107)
-@@ -0,0 +1,12 @@
-+2010-08-03 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Frame.cs: Pass root wrapper as an argument for ObjectWrapper.Create
-+ * Action.cs:
-+ * Window.cs:
-+ * Button.cs:
-+ * Widget.cs:
-+ * Expander.cs:
-+ * Container.cs:
-+ * ActionGroup.cs:
-+ * ScrolledWindow.cs:
-+
-Index: libstetic/wrapper/Button.cs
-===================================================================
---- libstetic/wrapper/Button.cs (revision 17)
-+++ libstetic/wrapper/Button.cs (working copy)
-@@ -208,11 +208,12 @@
- Gtk.Alignment alignment = new Gtk.Alignment (button.Xalign, button.Yalign, 0.0f, 0.0f);
- alignment.Add (box);
-
-- Widget wrapper = (Widget)ObjectWrapper.Create (proj, labelWidget);
-+ ObjectWrapper buttonWrapper = ObjectWrapper.Lookup (this);
-+ Widget wrapper = (Widget)ObjectWrapper.Create (proj, labelWidget, buttonWrapper);
- wrapper.Unselectable = true;
-- wrapper = (Widget)ObjectWrapper.Create (proj, box);
-+ wrapper = (Widget)ObjectWrapper.Create (proj, box, buttonWrapper);
- wrapper.Unselectable = true;
-- wrapper = (Widget)ObjectWrapper.Create (proj, alignment);
-+ wrapper = (Widget)ObjectWrapper.Create (proj, alignment, buttonWrapper);
- wrapper.Unselectable = true;
-
- alignment.ShowAll ();
-Index: libstetic/wrapper/Action.cs
-===================================================================
---- libstetic/wrapper/Action.cs (revision 17)
-+++ libstetic/wrapper/Action.cs (working copy)
-@@ -43,7 +43,7 @@
- get { return (Gtk.Action) Wrapped; }
- }
-
-- public string Name {
-+ public override string Name {
- get {
- if (name == null || name.Length == 0) {
- name = nameRoot = oldDefaultName = GetDefaultName ();
-@@ -250,7 +250,7 @@
-
- public Action Clone ()
- {
-- Action a = (Action) ObjectWrapper.Create (Project, new Gtk.Action ("", ""));
-+ Action a = (Action) ObjectWrapper.Create (Project, new Gtk.Action ("", ""), this);
- a.CopyFrom (this);
- return a;
- }
-Index: libstetic/wrapper/Container.cs
-===================================================================
---- libstetic/wrapper/Container.cs (revision 17)
-+++ libstetic/wrapper/Container.cs (working copy)
-@@ -41,7 +41,7 @@
- Gtk.Widget child = prop.GetValue (container) as Gtk.Widget;
- if (child == null)
- continue;
-- Widget wrapper = ObjectWrapper.Create (proj, child) as Stetic.Wrapper.Widget;
-+ Widget wrapper = ObjectWrapper.Create (proj, child, this) as Stetic.Wrapper.Widget;
- wrapper.InternalChildProperty = prop;
- if (child.Name == ((GLib.GType)child.GetType ()).ToString ())
- child.Name = container.Name + "_" + prop.Name;
-@@ -361,7 +361,7 @@
-
- protected virtual ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
-- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"]);
-+ ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- Container.ContainerChild childwrapper = null;
-
- try {
-@@ -414,7 +414,7 @@
- Gtk.Widget child = prop.GetValue (container) as Gtk.Widget;
- Widget wrapper = Widget.Lookup (child);
- if (wrapper != null) {
-- reader.ReadObject (wrapper, child_elem["widget"]);
-+ reader.ReadExistingObject (wrapper, child_elem["widget"]);
- if (reader.Format == FileFormat.Glade)
- GladeUtils.SetPacking (ChildWrapper (wrapper), child_elem);
- else
-@@ -770,7 +770,7 @@
- if (cwrap != null)
- return cwrap;
- else
-- return Stetic.ObjectWrapper.Create (parentWrapper.proj, cc) as ContainerChild;
-+ return Stetic.ObjectWrapper.Create (parentWrapper.proj, cc, parentWrapper) as ContainerChild;
- }
-
- protected Gtk.Container.ContainerChild ContextChildProps (Gtk.Widget context)
-@@ -1449,6 +1449,8 @@
- EmitNotify ("AutoSize");
- }
- }
-+
-+ public override string Name { get; set; }
- }
- }
- }
-Index: libstetic/wrapper/Widget.cs
-===================================================================
---- libstetic/wrapper/Widget.cs (revision 17)
-+++ libstetic/wrapper/Widget.cs (working copy)
-@@ -241,7 +241,7 @@
- Wrapped.Name = name;
- }
-
-- public string Name {
-+ public override string Name {
- get { return Wrapped.Name; }
- set { Wrapped.Name = value; EmitNotify ("Name"); }
- }
-@@ -806,7 +806,7 @@
- Gtk.ScrolledWindow scw = new Gtk.ScrolledWindow ();
- scw.HscrollbarPolicy = scw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
- scw.ShadowType = Gtk.ShadowType.In;
-- ScrolledWindow wrapper = (ScrolledWindow) ObjectWrapper.Create (Project, scw);
-+ ScrolledWindow wrapper = (ScrolledWindow) ObjectWrapper.Create (Project, scw, ParentWrapper);
- ParentWrapper.ReplaceChild (Wrapped, scw, false);
- if (Wrapped.SetScrollAdjustments (null, null))
- scw.Add (Wrapped);
-Index: libstetic/wrapper/Frame.cs
-===================================================================
---- libstetic/wrapper/Frame.cs (revision 17)
-+++ libstetic/wrapper/Frame.cs (working copy)
-@@ -17,21 +17,21 @@
- if (AllowPlaceholders) {
- Gtk.Alignment align = new Gtk.Alignment (0, 0, 1, 1);
- align.LeftPadding = 12;
-- Container align_wrapper = (Container)ObjectWrapper.Create (proj, align);
-+ Container align_wrapper = (Container)ObjectWrapper.Create (proj, align, this);
- align_wrapper.AddPlaceholder ();
- ReplaceChild (frame.Child, (Gtk.Widget)align_wrapper.Wrapped, true);
- }
- }
-
- if (frame.LabelWidget != null)
-- ObjectWrapper.Create (proj, frame.LabelWidget);
-+ ObjectWrapper.Create (proj, frame.LabelWidget, this);
- frame.AddNotification ("label-widget", LabelWidgetChanged);
- }
-
- void LabelWidgetChanged (object obj, GLib.NotifyArgs args)
- {
- if (!IsDisposed && frame.LabelWidget != null && !(frame.LabelWidget is Stetic.Placeholder))
-- ObjectWrapper.Create (proj, frame.LabelWidget);
-+ ObjectWrapper.Create (proj, frame.LabelWidget, this);
- }
-
- Gtk.Frame frame {
-@@ -43,7 +43,7 @@
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- if ((string)GladeUtils.GetChildProperty (child_elem, "type", "") == "label_item") {
-- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"]);
-+ ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- frame.LabelWidget = (Gtk.Widget)wrapper.Wrapped;
- return wrapper;
- } else
-Index: libstetic/wrapper/ActionGroup.cs
-===================================================================
---- libstetic/wrapper/ActionGroup.cs (revision 17)
-+++ libstetic/wrapper/ActionGroup.cs (working copy)
-@@ -39,7 +39,7 @@
- get { return actions; }
- }
-
-- public string Name {
-+ public override string Name {
- get { return name; }
- set {
- name = value;
-Index: libstetic/wrapper/OptionMenu.cs
-===================================================================
---- libstetic/wrapper/OptionMenu.cs (revision 17)
-+++ libstetic/wrapper/OptionMenu.cs (working copy)
-@@ -50,7 +50,7 @@
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (optionmenu.Menu);
-- reader.ReadObject (wrapper, child_elem["widget"]);
-+ reader.ReadExistingObject (wrapper, child_elem["widget"]);
- return wrapper;
- }
-
-Index: libstetic/wrapper/ScrolledWindow.cs
-===================================================================
---- libstetic/wrapper/ScrolledWindow.cs (revision 17)
-+++ libstetic/wrapper/ScrolledWindow.cs (working copy)
-@@ -55,7 +55,7 @@
- internal void AddWithViewport (Gtk.Widget child)
- {
- Gtk.Viewport viewport = new Gtk.Viewport (scrolled.Hadjustment, scrolled.Vadjustment);
-- ObjectWrapper.Create (proj, viewport);
-+ ObjectWrapper.Create (proj, viewport, this);
- viewport.ShadowType = Gtk.ShadowType.None;
- viewport.Add (child);
- viewport.Show ();
-Index: libstetic/wrapper/Window.cs
-===================================================================
---- libstetic/wrapper/Window.cs (revision 17)
-+++ libstetic/wrapper/Window.cs (working copy)
-@@ -10,7 +10,9 @@
- public override void Wrap (object obj, bool initialized)
- {
- TopLevelWindow window = (TopLevelWindow) obj;
-+ RootWrapperName = window.Name;
-
-+ //during Wrap RootWrapperName will be set in the children widgets
- base.Wrap (obj, initialized);
-
- if (!initialized) {
-Index: libstetic/wrapper/Notebook.cs
-===================================================================
---- libstetic/wrapper/Notebook.cs (revision 17)
-+++ libstetic/wrapper/Notebook.cs (working copy)
-@@ -31,7 +31,7 @@
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- if ((string)GladeUtils.GetChildProperty (child_elem, "type", "") == "tab") {
-- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"]);
-+ ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- Gtk.Widget widget = (Gtk.Widget)wrapper.Wrapped;
- notebook.SetTabLabel (notebook.GetNthPage (notebook.NPages - 1), widget);
- tabs.Add (widget);
-Index: libstetic/wrapper/MenuItem.cs
-===================================================================
---- libstetic/wrapper/MenuItem.cs (revision 17)
-+++ libstetic/wrapper/MenuItem.cs (working copy)
-@@ -18,7 +18,7 @@
-
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
-- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"]);
-+ ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- menuitem.Submenu = (Gtk.Menu)wrapper.Wrapped;
- return wrapper;
- }
-Index: libstetic/wrapper/objects.xml
-===================================================================
---- libstetic/wrapper/objects.xml (revision 17)
-+++ libstetic/wrapper/objects.xml (working copy)
-@@ -104,17 +104,17 @@
- <!-- "events" property has extra spaces around "|"s -->
- <import>
- <xsl:template match="widget/property[@name='events']/text()">
-- <xsl:call-template name="GtkWidget_fixevents">
-+ <xsl:call-template name="GtkWidget_fixevents2">
- <xsl:with-param name="string" select="." />
- </xsl:call-template>
- </xsl:template>
-- <xsl:template name="GtkWidget_fixevents">
-+ <xsl:template name="GtkWidget_fixevents2">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' | ')">
- <xsl:value-of select="substring-before($string, ' | ')"/>
- <xsl:text>|</xsl:text>
-- <xsl:call-template name="GtkWidget_fixevents">
-+ <xsl:call-template name="GtkWidget_fixevents2">
- <xsl:with-param name="string" select="substring-after($string, ' | ')"/>
- </xsl:call-template>
- </xsl:when>
-@@ -126,17 +126,17 @@
- </import>
- <export>
- <xsl:template match="widget/property[@name='events']/text()">
-- <xsl:call-template name="GtkWidget_breakevents">
-+ <xsl:call-template name="GtkWidget_breakevents2">
- <xsl:with-param name="string" select="." />
- </xsl:call-template>
- </xsl:template>
-- <xsl:template name="GtkWidget_breakevents">
-+ <xsl:template name="GtkWidget_breakevents2">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, '|')">
- <xsl:value-of select="substring-before($string, '|')"/>
- <xsl:text> | </xsl:text>
-- <xsl:call-template name="GtkWidget_breakevents">
-+ <xsl:call-template name="GtkWidget_breakevents2">
- <xsl:with-param name="string" select="substring-after($string, '|')"/>
- </xsl:call-template>
- </xsl:when>
-@@ -1316,19 +1316,19 @@
- <!-- Child packing options are non-standard ("expand" instead of "GTK_EXPAND") -->
- <import>
- <xsl:template match="widget[@class='GtkTable']/child/packing/property[@name='x_options' or @name='y_options']/text()">
-- <xsl:call-template name="GtkTable_fixoptions">
-+ <xsl:call-template name="GtkTable_fixoptions2">
- <xsl:with-param name="string" select="." />
- </xsl:call-template>
- </xsl:template>
-- <xsl:template name="GtkTable_fixoptions">
-+ <xsl:template name="GtkTable_fixoptions2">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, '|')">
-- <xsl:call-template name="GtkTable_fixoptions">
-+ <xsl:call-template name="GtkTable_fixoptions2">
- <xsl:with-param name="string" select="substring-before($string, '|')"/>
- </xsl:call-template>
- <xsl:text>|</xsl:text>
-- <xsl:call-template name="GtkTable_fixoptions">
-+ <xsl:call-template name="GtkTable_fixoptions2">
- <xsl:with-param name="string" select="substring-after($string, '|')"/>
- </xsl:call-template>
- </xsl:when>
-@@ -1341,19 +1341,19 @@
- </import>
- <export>
- <xsl:template match="widget[@class='GtkTable']/child/packing/property[@name='x_options' or @name='y_options']/text()">
-- <xsl:call-template name="GtkTable_breakoptions">
-+ <xsl:call-template name="GtkTable_breakoptions2">
- <xsl:with-param name="options" select="." />
- </xsl:call-template>
- </xsl:template>
-- <xsl:template name="GtkTable_breakoptions">
-+ <xsl:template name="GtkTable_breakoptions2">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, '|')">
-- <xsl:call-template name="GtkTable_breakoptions">
-+ <xsl:call-template name="GtkTable_breakoptions2">
- <xsl:with-param name="string" select="substring-before($string, '|')"/>
- </xsl:call-template>
- <xsl:text>|</xsl:text>
-- <xsl:call-template name="GtkTable_breakoptions">
-+ <xsl:call-template name="GtkTable_breakoptions2">
- <xsl:with-param name="string" select="substring-after($string, '|')"/>
- </xsl:call-template>
- </xsl:when>
-Index: libstetic/wrapper/Expander.cs
-===================================================================
---- libstetic/wrapper/Expander.cs (revision 17)
-+++ libstetic/wrapper/Expander.cs (working copy)
-@@ -21,13 +21,13 @@
- AddPlaceholder ();
- }
- if (expander.LabelWidget != null)
-- ObjectWrapper.Create (proj, expander.LabelWidget);
-+ ObjectWrapper.Create (proj, expander.LabelWidget, this);
- }
-
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- if ((string)GladeUtils.GetChildProperty (child_elem, "type", "") == "label_item") {
-- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"]);
-+ ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- expander.LabelWidget = (Gtk.Widget)wrapper.Wrapped;
- return wrapper;
- } else
-Index: libstetic/GladeUtils.cs
-===================================================================
---- libstetic/GladeUtils.cs (revision 17)
-+++ libstetic/GladeUtils.cs (working copy)
-@@ -104,31 +104,31 @@
- return doc;
- }
-
-- public static Stetic.Wrapper.Widget Import (IProject project, XmlDocument doc)
-- {
-- try {
-- doc = XslImportTransform (doc);
-- } catch {
-- return null;
-- }
--
-- ObjectReader reader = new ObjectReader (project, FileFormat.Glade);
--
-- XmlElement elem = (XmlElement)doc.SelectSingleNode ("glade-interface/widget");
-- if (elem.GetAttribute ("class") != "GtkWindow" ||
-- elem.GetAttribute ("id") != "glade-dummy-container") {
-- // Creating a new toplevel
-- Stetic.Wrapper.Widget toplevel = (Stetic.Wrapper.Widget)
-- Stetic.ObjectWrapper.ReadObject (reader, elem);
-- if (toplevel != null) {
-- project.AddWindow ((Gtk.Window)toplevel.Wrapped);
-- }
-- return toplevel;
-- }
--
-- return (Stetic.Wrapper.Widget)
-- Stetic.ObjectWrapper.ReadObject (reader, (XmlElement)elem.SelectSingleNode ("child/widget"));
-- }
-+// public static Stetic.Wrapper.Widget Import (IProject project, XmlDocument doc)
-+// {
-+// try {
-+// doc = XslImportTransform (doc);
-+// } catch {
-+// return null;
-+// }
-+//
-+// ObjectReader reader = new ObjectReader (project, FileFormat.Glade);
-+//
-+// XmlElement elem = (XmlElement)doc.SelectSingleNode ("glade-interface/widget");
-+// if (elem.GetAttribute ("class") != "GtkWindow" ||
-+// elem.GetAttribute ("id") != "glade-dummy-container") {
-+// // Creating a new toplevel
-+// Stetic.Wrapper.Widget toplevel = (Stetic.Wrapper.Widget)
-+// Stetic.ObjectWrapper.ReadObject (reader, elem);
-+// if (toplevel != null) {
-+// project.AddWindow ((Gtk.Window)toplevel.Wrapped);
-+// }
-+// return toplevel;
-+// }
-+//
-+// return (Stetic.Wrapper.Widget)
-+// Stetic.ObjectWrapper.ReadObject (reader, (XmlElement)elem.SelectSingleNode ("child/widget"));
-+// }
-
- public static void Copy (Gtk.Widget widget, Gtk.SelectionData seldata, bool copyAsText)
- {
-@@ -142,23 +142,23 @@
- seldata.Set (ApplicationXGladeAtom, 8, System.Text.Encoding.UTF8.GetBytes (doc.OuterXml));
- }
-
-- public static Stetic.Wrapper.Widget Paste (IProject project, Gtk.SelectionData seldata)
-- {
-- if (seldata.Type != ApplicationXGladeAtom)
-- return null;
-- string data = System.Text.Encoding.UTF8.GetString (seldata.Data);
-+// public static Stetic.Wrapper.Widget Paste (IProject project, Gtk.SelectionData seldata)
-+// {
-+// if (seldata.Type != ApplicationXGladeAtom)
-+// return null;
-+// string data = System.Text.Encoding.UTF8.GetString (seldata.Data);
-+//
-+// XmlDocument doc = new XmlDocument ();
-+// doc.PreserveWhitespace = true;
-+// try {
-+// doc.LoadXml (data);
-+// } catch {
-+// return null;
-+// }
-+//
-+// return Import (project, doc);
-+// }
-
-- XmlDocument doc = new XmlDocument ();
-- doc.PreserveWhitespace = true;
-- try {
-- doc.LoadXml (data);
-- } catch {
-- return null;
-- }
--
-- return Import (project, doc);
-- }
--
- static object GetProperty (XmlElement elem, string selector, object defaultValue, bool extract)
- {
- XmlElement prop = (XmlElement)elem.SelectSingleNode (selector);
-Index: libstetic/ErrorWidget.cs
-===================================================================
---- libstetic/ErrorWidget.cs (revision 17)
-+++ libstetic/ErrorWidget.cs (working copy)
-@@ -96,9 +96,9 @@
- ErrorWidget ew = (ErrorWidget) Wrapped;
- string msg;
- if (ew.Exception != null)
-- msg = Project.FileName + ": Could not generate code for an invalid widget. The widget failed to load: " + ew.Exception.Message + ". The generated code may be invalid.";
-+ msg = Project.FolderName + ": Could not generate code for an invalid widget. The widget failed to load: " + ew.Exception.Message + ". The generated code may be invalid.";
- else
-- msg = Project.FileName + ": Could not generate code for widgets of type: " + ew.ClassName + ". The widget could not be found in any referenced library. The generated code may be invalid.";
-+ msg = Project.FolderName + ": Could not generate code for widgets of type: " + ew.ClassName + ". The widget could not be found in any referenced library. The generated code may be invalid.";
-
- if (ctx.Options.FailForUnknownWidgets) {
- throw new InvalidOperationException (msg);
-Index: libstetic/WidgetUtils.cs
-===================================================================
---- libstetic/WidgetUtils.cs (revision 17)
-+++ libstetic/WidgetUtils.cs (working copy)
-@@ -37,7 +37,7 @@
- public static Gtk.Widget ImportWidget (IProject project, XmlElement element)
- {
- ObjectReader reader = new ObjectReader (project, FileFormat.Native);
-- ObjectWrapper wrapper = Stetic.ObjectWrapper.ReadObject (reader, element);
-+ ObjectWrapper wrapper = Stetic.ObjectWrapper.ReadObject (reader, element, null);
- return wrapper.Wrapped as Gtk.Widget;
- }
-
-@@ -126,11 +126,14 @@
- Gtk.Widget widget = (Gtk.Widget) wrapper.Wrapped;
- if (widget == null) {
- widget = (Gtk.Widget) klass.CreateInstance (wrapper.Project);
-+ //set name before binding to ensure
-+ //that ObjectWrapper.RootWrapperName will be valid
-+ widget.Name = elem.GetAttribute ("id");
- ObjectWrapper.Bind (wrapper.Project, klass, wrapper, widget, true);
-+ } else {
-+ widget.Name = elem.GetAttribute ("id");
- }
-
-- widget.Name = elem.GetAttribute ("id");
--
- ReadMembers (klass, wrapper, widget, elem);
-
- if (!(widget is Gtk.Window))
-Index: MonoDevelop.GtkCore.Commands/GladeCommands.cs
-===================================================================
---- MonoDevelop.GtkCore.Commands/GladeCommands.cs (revision 17)
-+++ MonoDevelop.GtkCore.Commands/GladeCommands.cs (working copy)
-@@ -36,6 +36,7 @@
- AddNewActionGroup,
- ImportGladeFile,
- EditIcons,
-- GtkSettings
-+ GtkSettings,
-+ GenerateCode
- }
- }
-Index: MonoDevelop.GtkCore.Commands/ChangeLog
-===================================================================
---- MonoDevelop.GtkCore.Commands/ChangeLog (revision 0)
-+++ MonoDevelop.GtkCore.Commands/ChangeLog (revision 124)
-@@ -0,0 +1,4 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GladeCommands.cs:
-+
-Index: MonoDevelop.GtkCore/GtkDesignInfo.cs
-===================================================================
---- MonoDevelop.GtkCore/GtkDesignInfo.cs (revision 17)
-+++ MonoDevelop.GtkCore/GtkDesignInfo.cs (working copy)
-@@ -29,6 +29,8 @@
-
- using System;
- using System.IO;
-+using System.CodeDom;
-+using System.CodeDom.Compiler;
- using System.Collections.Generic;
- using System.Collections.Specialized;
-
-@@ -51,13 +53,23 @@
- IDotNetLanguageBinding binding;
- ProjectResourceProvider resourceProvider;
- ReferenceManager referenceManager;
-+ string langExtension;
-
-- [ItemProperty (DefaultValue=true)]
-+ [ItemProperty (DefaultValue = true)]
- bool generateGettext = true;
-
-- [ItemProperty (DefaultValue="Mono.Unix.Catalog")]
-+ [ItemProperty (DefaultValue = "Mono.Unix.Catalog")]
- string gettextClass = "Mono.Unix.Catalog";
-
-+ [ItemProperty (DefaultValue = "Stetic")]
-+ string steticFolderName = "Stetic";
-+
-+ [ItemProperty (DefaultValue = false)]
-+ bool wasConverted;
-+
-+ [ItemProperty (DefaultValue = true)]
-+ bool hideGtkxFiles = true;
-+
- GtkDesignInfo ()
- {
- }
-@@ -85,8 +97,15 @@
- referenceManager = null;
- }
- project = value;
-+
- if (project != null) {
- binding = LanguageBindingService.GetBindingPerLanguageName (project.LanguageName) as IDotNetLanguageBinding;
-+
-+ CodeDomProvider provider = binding.GetCodeDomProvider ();
-+ if (provider == null)
-+ throw new UserException ("Code generation not supported for language: " + project.LanguageName);
-+ langExtension = "." + provider.FileExtension;
-+
- project.FileAddedToProject += OnFileEvent;
- project.FileChangedInProject += OnFileEvent;
- project.FileRemovedFromProject += OnFileEvent;
-@@ -120,11 +139,7 @@
- get {
- if (builderProject == null) {
- if (SupportsDesigner (project)) {
-- if (!File.Exists (SteticFile)) {
-- UpdateGtkFolder ();
-- ProjectNodeBuilder.OnSupportChanged (project);
-- }
-- builderProject = new GuiBuilderProject (project, SteticFile);
-+ builderProject = new GuiBuilderProject (project, SteticFolder.FullPath.FullPath);
- } else
- builderProject = new GuiBuilderProject (project, null);
- }
-@@ -156,20 +171,27 @@
- }
- }
-
-+ public bool OldVersion {
-+ get { return project.IsFileInProject (SteticFile); }
-+ }
-+
- FilePath ObjectsFile {
-- get { return GtkGuiFolder.Combine ("objects.xml"); }
-+ get { return SteticFolder.Combine ("objects.xml"); }
- }
-
-+ [Obsolete]
- public FilePath SteticGeneratedFile {
-- get { return GtkGuiFolder.Combine (binding.GetFileName ("generated")); }
-+ get { return SteticFolder.Combine (binding.GetFileName ("generated")); }
- }
-
-+ [Obsolete]
- public FilePath SteticFile {
-- get { return GtkGuiFolder.Combine ("gui.stetic"); }
-+ get { return SteticFolder.Combine ("gui.stetic"); }
- }
-
-- public FilePath GtkGuiFolder {
-- get { return project.BaseDirectory.Combine ("gtk-gui"); }
-+ public FilePath SteticFolder {
-+// get { return project.BaseDirectory.Combine ("gtk-gui"); }
-+ get { return project.BaseDirectory.Combine (!wasConverted ? "gtk-gui" : steticFolderName); }
- }
-
- public bool GenerateGettext {
-@@ -187,13 +209,22 @@
- set { gettextClass = value; }
- }
-
-+ public string SteticFolderName {
-+ get { return steticFolderName; }
-+ set { steticFolderName = value; }
-+ }
-+
-+ public bool HideGtkxFiles {
-+ get { return hideGtkxFiles; }
-+ set { hideGtkxFiles = value; }
-+ }
-+
- public static bool HasDesignedObjects (Project project)
- {
- if (project == null)
- return false;
-
-- string stetic_file = Path.Combine (Path.Combine (project.BaseDirectory, "gtk-gui"), "gui.stetic");
-- return SupportsDesigner (project) && File.Exists (stetic_file);
-+ return SupportsDesigner (project);
- }
-
- public static bool SupportsDesigner (Project project)
-@@ -250,7 +281,7 @@
- bool projectModified = false;
-
- // Remove all project files which are not in the generated list
-- foreach (ProjectFile pf in project.Files.GetFilesInPath (GtkGuiFolder)) {
-+ foreach (ProjectFile pf in project.Files.GetFilesInPath (SteticFolder)) {
- if (remaining_files.Contains (pf.FilePath))
- continue;
-
-@@ -260,68 +291,218 @@
- }
-
- if (remaining_files.Count == 0)
-- FileService.DeleteDirectory (GtkGuiFolder);
-+ FileService.DeleteDirectory (SteticFolder);
-
- return projectModified;
- }
-
-+ public void ConvertGtkFolder (string guiFolderName, bool makeBackup)
-+ {
-+ foreach (ProjectFile pf in project.Files.GetFilesInPath (SteticFolder)) {
-+ FilePath path = pf.FilePath;
-+
-+ if (path != SteticGeneratedFile) {
-+ project.Files.Remove (path);
-+
-+ if (path != SteticFile)
-+ FileService.DeleteFile (path.FullPath);
-+ }
-+ }
-+
-+ string oldGuiFolder = SteticFolder.FullPath;
-+ string oldSteticFile = SteticFile;
-+ string oldGeneratedFile = SteticGeneratedFile;
-+ SteticFolderName = guiFolderName;
-+ wasConverted = true;
-+
-+ if (!Directory.Exists (SteticFolder))
-+ FileService.CreateDirectory (SteticFolder);
-+
-+ if (makeBackup && File.Exists (oldSteticFile)) {
-+ string backupFile = SteticFolder.Combine ("old.stetic");
-+ FileService.MoveFile (oldSteticFile, backupFile);
-+ }
-+
-+ if (File.Exists (oldGeneratedFile))
-+ FileService.DeleteFile (oldGeneratedFile);
-+
-+ FileService.DeleteDirectory (oldGuiFolder);
-+ }
-+
- public bool UpdateGtkFolder ()
- {
- if (!SupportsDesigner (project))
- return false;
--
-+
- // This method synchronizes the current gtk project configuration info
- // with the needed support files in the gtk-gui folder.
-
-- FileService.CreateDirectory (GtkGuiFolder);
-+ FileService.CreateDirectory (SteticFolder);
- bool projectModified = false;
-- bool initialGeneration = false;
-
-- if (!File.Exists (SteticFile)) {
-- initialGeneration = true;
-- StreamWriter sw = new StreamWriter (SteticFile);
-- sw.WriteLine ("<stetic-interface />");
-- sw.Close ();
-- FileService.NotifyFileChanged (SteticFile);
-- }
-+ foreach (string filename in GetComponentsFiles ()) {
-+ ProjectFile pf = project.AddFile (filename, BuildAction.EmbeddedResource);
-+ pf.ResourceId = Path.GetFileName (filename);
-+
-+ string componentFile = GetComponentFileFromGtkx (filename);
-
-- if (!project.IsFileInProject (SteticFile)) {
-- ProjectFile pf = project.AddFile (SteticFile, BuildAction.EmbeddedResource);
-- pf.ResourceId = "gui.stetic";
-+ if (componentFile != null && File.Exists (componentFile)) {
-+ pf.DependsOn = componentFile;
-+
-+ string buildFile = GetBuildFileFromGtkx (filename);
-+ if (buildFile != null && File.Exists (buildFile)) {
-+ ProjectFile pf2 = project.AddFile (buildFile, BuildAction.Compile);
-+ pf2.ResourceId = Path.GetFileName (buildFile);
-+ pf2.DependsOn = componentFile;
-+ }
-+ }
-+
- projectModified = true;
- }
--
-- StringCollection files = GuiBuilderProject.GenerateFiles (GtkGuiFolder);
-- DateTime generatedTime = File.GetLastWriteTime (SteticFile).Subtract (TimeSpan.FromSeconds (2));
--
-+
-+ StringCollection files = GuiBuilderProject.GenerateFiles (SteticFolder);
- foreach (string filename in files) {
-- if (initialGeneration) {
-- // Ensure that the generation date of this file is < the date of the .stetic file
-- // In this way the code will be properly regenerated when building the project.
-- File.SetLastWriteTime (filename, generatedTime);
-- }
- if (!project.IsFileInProject (filename)) {
- project.AddFile (filename, BuildAction.Compile);
- projectModified = true;
- }
-+
- }
--
-+
- UpdateObjectsFile ();
-- files.Add (ObjectsFile);
-- files.Add (SteticFile);
--
-- if (CleanGtkFolder (files))
-- projectModified = true;
--
-+
- return ReferenceManager.Update () || projectModified;
- }
-
-+// public bool UpdateGtkFolder ()
-+// {
-+// if (!SupportsDesigner (project))
-+// return false;
-+//
-+// // This method synchronizes the current gtk project configuration info
-+// // with the needed support files in the gtk-gui folder.
-+//
-+// FileService.CreateDirectory (GtkGuiFolder);
-+// bool projectModified = false;
-+// bool initialGeneration = false;
-+//
-+// if (!File.Exists (SteticFile)) {
-+// initialGeneration = true;
-+// StreamWriter sw = new StreamWriter (SteticFile);
-+// sw.WriteLine ("<stetic-interface />");
-+// sw.Close ();
-+// FileService.NotifyFileChanged (SteticFile);
-+// }
-+//
-+// if (!project.IsFileInProject (SteticFile)) {
-+// ProjectFile pf = project.AddFile (SteticFile, BuildAction.EmbeddedResource);
-+// pf.ResourceId = "gui.stetic";
-+// projectModified = true;
-+// }
-+//
-+// StringCollection files = GuiBuilderProject.GenerateFiles (GtkGuiFolder);
-+// DateTime generatedTime = File.GetLastWriteTime (SteticFile).Subtract (TimeSpan.FromSeconds (2));
-+//
-+// foreach (string filename in files) {
-+// if (initialGeneration) {
-+// // Ensure that the generation date of this file is < the date of the .stetic file
-+// // In this way the code will be properly regenerated when building the project.
-+// File.SetLastWriteTime (filename, generatedTime);
-+// }
-+// if (!project.IsFileInProject (filename)) {
-+// project.AddFile (filename, BuildAction.Compile);
-+// projectModified = true;
-+// }
-+// }
-+//
-+// UpdateObjectsFile ();
-+// files.Add (ObjectsFile);
-+// files.Add (SteticFile);
-+//
-+// if (CleanGtkFolder (files))
-+// projectModified = true;
-+//
-+// return ReferenceManager.Update () || projectModified;
-+// return true;
-+// }
-+
-+
-+ public string GetComponentFile (string componentName)
-+ {
-+ IType type = GuiBuilderProject.FindClass (componentName);
-+
-+ if (type != null) {
-+
-+ foreach (IType part in type.Parts) {
-+ string componentFile = part.CompilationUnit.FileName.FullPath.ToString ();
-+// if (!componentFile.Contains (".generated"))
-+// return componentFile;
-+ if (componentFile.Contains (".generated"))
-+ componentFile = componentFile.Replace (".generated", string.Empty);
-+
-+ return componentFile;
-+ }
-+ }
-+
-+ return null;
-+ }
-+
-+ public string GetBuildFile (string componentFile)
-+ {
-+ if (componentFile != null) {
-+ string buildFile = componentFile.Replace
-+ (Path.GetExtension (SteticGeneratedFile), ".generated" + langExtension);
-+ return buildFile;
-+ }
-+
-+ return null;
-+ }
-+
-+ public string GetBuildFileInSteticFolder (string componentName)
-+ {
-+ string name = string.Format ("{0}.generated{1}", componentName, langExtension);
-+ string buildFile = Path.Combine (SteticFolder, name);
-+
-+ return buildFile;
-+ }
-+
-+ public string GetGtkxFile (string componentFile)
-+ {
-+ if (componentFile != null) {
-+ string gtkxFile = componentFile.Replace (langExtension, ".gtkx");
-+ return gtkxFile;
-+ }
-+
-+ return null;
-+ }
-+
-+ public string GetComponentFileFromGtkx (string gtkxFile)
-+ {
-+ if (gtkxFile != null) {
-+ string componentFile = gtkxFile.Replace (".gtkx", langExtension);
-+ return componentFile;
-+ }
-+
-+ return null;
-+ }
-+
-+ public string GetBuildFileFromGtkx (string gtkxFile)
-+ {
-+ string buildFile = gtkxFile.Replace (".gtkx", ".generated" + langExtension);
-+ return buildFile;
-+ }
-+
-+
- public string GetComponentFolder (string componentName)
- {
- IType type = GuiBuilderProject.FindClass (componentName);
-- FilePath folder = type.CompilationUnit.FileName.ParentDirectory;
-
-- return folder.FullPath.ToString ();
-+ if (type != null) {
-+ FilePath folder = type.CompilationUnit.FileName.ParentDirectory;
-+ return folder.FullPath.ToString ();
-+ }
-+
-+ return null;
- }
-
- public string[] GetComponentFolders ()
-@@ -329,17 +510,54 @@
- List<string> folders = new List<string> ();
- ProjectDom ctx = GuiBuilderProject.GetParserContext ();
-
-- foreach (IType type in ctx.Types) {
-- FilePath folder = type.CompilationUnit.FileName.ParentDirectory;
-- string folderName = folder.FullPath.ToString ();
-+ foreach (IType type in ctx.Types)
-+ foreach (IType part in type.Parts) {
-+ FilePath folder = part.CompilationUnit.FileName.ParentDirectory;
-+ string folderName = folder.FullPath.ToString ();
-
-- if (!folders.Contains (folderName))
-- folders.Add (folder);
-+ if (!folders.Contains (folderName))
-+ folders.Add (folder);
- }
-
- return folders.ToArray ();
- }
-+
-+ public string[] GetComponentsFiles ()
-+ {
-+ List<string> files = new List<string> ();
-+
-+ foreach (string folder in GetComponentFolders ()) {
-+ DirectoryInfo dir = new DirectoryInfo (folder);
-+
-+ foreach (FileInfo file in dir.GetFiles ())
-+ if (file.Extension == ".gtkx")
-+ files.Add (file.ToString ());
-+ }
-+
-+ return files.ToArray ();
-+ }
-
-+ public bool HasComponentFile (string componentName)
-+ {
-+ return (GetComponentFile (componentName) != null);
-+ }
-+
-+ public bool ComponentNeedsCodeGeneration (string componentName)
-+ {
-+ string componentFile = GetComponentFile (componentName);
-+ string gtkxFile = GetGtkxFile (componentFile);
-+ string buildFile = GetBuildFile (componentFile);
-+ FileInfo gtkxFileInfo = File.Exists (gtkxFile) ? new FileInfo (gtkxFile) : null;
-+ FileInfo buildFileInfo = File.Exists (buildFile) ? new FileInfo (buildFile) : null;
-+ Console.WriteLine(gtkxFile);
-+ if (gtkxFileInfo == null)
-+ return false;
-+ if (buildFileInfo == null)
-+ //file does not exist
-+ return true;
-+ return gtkxFileInfo.LastWriteTime > buildFileInfo.LastWriteTime;
-+ }
-+
- void UpdateObjectsFile ()
- {
- if (!File.Exists (ObjectsFile))
-Index: MonoDevelop.GtkCore/ChangeLog
-===================================================================
---- MonoDevelop.GtkCore/ChangeLog (revision 0)
-+++ MonoDevelop.GtkCore/ChangeLog (revision 125)
-@@ -0,0 +1,36 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * WidgetFileDescriptionTemplate.cs:
-+
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GtkDesignInfo.cs:
-+
-+2010-08-13 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GtkDesignInfo.cs:
-+
-+2010-08-09 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GtkDesignInfo.cs: Add ComponentNeedsCodeGeneration method,
-+
-+2010-08-04 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * WidgetFileDescriptionTemplate.cs: Bump Api
-+
-+2010-07-06 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GtkDesignInfo.cs: Remove gtk-gui folder after project conversion
-+
-+2010-06-23 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GtkDesignInfo.cs:
-+
-+2010-06-16 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GtkDesignInfo.cs:
-+
-+2010-06-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GtkDesignInfo.cs: Transition from project file name to project folder.
-+
-Index: MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs
-===================================================================
---- MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs (revision 17)
-+++ MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs (working copy)
-@@ -91,7 +91,7 @@
- string fileName = fileTemplate.GetFileName (policyParent, project, language, directory, name);
- fileTemplate.AddToProject (policyParent, project, language, directory, name);
-
-- ProjectDomService.Parse (project, fileName, null);
-+ ProjectDomService.Parse (project, fileName);
-
- DotNetProject netProject = project as DotNetProject;
- string ns = netProject != null ? netProject.GetDefaultNamespace (fileName) : "";
-@@ -125,7 +125,8 @@
- XmlDocument doc = new XmlDocument ();
- doc.LoadXml (content);
-
-- gproject.SteticProject.AddNewActionGroup (doc.DocumentElement);
-+ Stetic.Project sproject = gproject.SteticProject;
-+ sproject.AddNewActionGroup (doc.DocumentElement);
- gproject.Save (false);
- IdeApp.ProjectOperations.Save (project);
- return true;
-Index: ChangeLog
-===================================================================
---- ChangeLog (revision 17)
-+++ ChangeLog (working copy)
-@@ -1,3 +1,117 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * MonoDevelop.GtkCore.addin.xml:
-+
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * Makefile.am:
-+ * MonoDevelop.GtkCore2.csproj:
-+ * MonoDevelop.GtkCore.addin.xml:
-+
-+2010-08-09 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * Makefile.am:
-+ * MonoDevelop.GtkCore2.csproj:
-+ * MonoDevelop.GtkCore.addin.xml: Add GuiFolderBuilderNode extension
-+
-+2010-08-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * MonoDevelop.GtkCore2.csproj:
-+
-+2010-08-04 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * MonoDevelop.GtkCore2.csproj:
-+
-+2010-07-27 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs:
-+ Remove autoCommit argument
-+
-+2010-07-05 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * MonoDevelop.GtkCore2.csproj:
-+ * MonoDevelop.GtkCore.addin.xml:
-+
-+2010-06-28 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * MonoDevelop.GtkCore/GtkDesignInfo.cs:
-+ * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs:
-+ * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs:
-+ Fixes fo better file grouping in the project pad
-+
-+
-+2010-06-28 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * MonoDevelop.GtkCore2.csproj:
-+
-+2010-06-23 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+ Draw action group icon
-+ * gtk-gui/gui.stetic:
-+ * MonoDevelop.GtkCore2.csproj:
-+ * MonoDevelop.GtkCore/GtkDesignInfo.cs:
-+ * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs:
-+
-+2010-06-23 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * MonoDevelop.GtkCore2.csproj:
-+
-+2010-06-22 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * MonoDevelop.GtkCore2.csproj:
-+ * MonoDevelop.GtkCore.addin.xml:
-+ * MonoDevelop.GtkCore/GtkDesignInfo.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs:
-+
-+
-+2010-06-16 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * MonoDevelop.GtkCore.addin.xml:
-+
-+2010-06-15 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+ Changes in the project pad for displaying grouped component files
-+
-+ * Makefile.am:
-+ * MonoDevelop.GtkCore2.csproj:
-+ * MonoDevelop.GtkCore.addin.xml:
-+ * MonoDevelop.GtkCore/GtkDesignInfo.cs:
-+ * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/WindowsFolderNodeBuilder.cs:
-+ * MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs:
-+
-+
-+2010-06-09 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * gtk-gui/gui.stetic:
-+ * MonoDevelop.GtkCore2.csproj:
-+ * MonoDevelop.GtkCore/GtkDesignInfo.cs: Add gtkx files to project
-+ * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs:
-+
-+2010-06-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * gtk-gui/gui.stetic:
-+ * MonoDevelop.GtkCore/GtkDesignInfo.cs:
-+ * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs:
-+
-+2010-06-02 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * Makefile.am:
-+ * MonoDevelop.GtkCore2.csproj:
-+ * MonoDevelop.GtkCore/GtkDesignInfo.cs:
-+ * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs:
-+ Move generated partial class for components from gtk-gui.
-+
- 2010-04-29 Michael Hutchinson <mhutchinson@novell.com>
-
- * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs: Track
-Index: MonoDevelop.GtkCore.addin.xml
-===================================================================
---- MonoDevelop.GtkCore.addin.xml (revision 17)
-+++ MonoDevelop.GtkCore.addin.xml (working copy)
-@@ -1,6 +1,6 @@
- <Addin id = "GtkCore2"
- namespace = "MonoDevelop"
-- name = "GTK# Visual Designer 2"
-+ name = "GTK# Visual Designer (experimental)"
- author = "Lluis Sanchez Gual, Krzysztof Marecki"
- copyright = "X11"
- url = ""
-@@ -20,6 +20,7 @@
- <Addin id="Core" version="2.4"/>
- <Addin id="Ide" version="2.4"/>
- <Addin id="DesignerSupport" version="2.4"/>
-+ <Addin id="XmlEditor" version="2.4"/>
- </Dependencies>
-
- <ExtensionPoint path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.ActionGroup">
-@@ -43,12 +44,13 @@
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/Pads/ProjectPad">
-+ <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.GuiProjectFolderNodeBuilder"/>
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.ProjectFolderNodeBuilderExtension"/>
-+ <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.ProjectFileNodeBuilderExtension"/>
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.ProjectNodeBuilder"/>
-- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.WidgetNodeBuilder"/>
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.WindowsFolderNodeBuilder"/>
-- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.ActionGroupNodeBuilder"/>
- <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.StockIconsNodeBuilder"/>
-+ <NodeBuilder class = "MonoDevelop.GtkCore.NodeBuilders.ProjectFileNodeBuilderExtension" />
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/FileTemplates">
-@@ -87,9 +89,13 @@
- <Command id = "MonoDevelop.GtkCore.GtkCommands.ImportGladeFile"
- _label = "Import Glade file..." />
- <Command id = "MonoDevelop.GtkCore.GtkCommands.EditIcons"
-+ icon = "md-gtkcore-iconfactory"
- _label = "Edit Project Icons..." />
- <Command id = "MonoDevelop.GtkCore.GtkCommands.GtkSettings"
-- _label = "GTK# support settings..." />
-+ _label = "GTK# support settings..."
-+ icon = "md-gtkcore-gtk-logo"/>
-+ <Command id = "MonoDevelop.GtkCore.GtkCommands.GenerateCode"
-+ _label = "Generate code..."/>
- </Category>
- </Extension>
-
-@@ -103,16 +109,16 @@
- </Condition>
- </Extension>
-
-- <Extension path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.UserInterfaceFolder">
-- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.AddNewDialog" />
-- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.AddNewWindow" />
-- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.AddNewWidget" />
-- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.AddNewActionGroup" />
-- <SeparatorItem />
-- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.EditIcons" />
-- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.ImportGladeFile" />
-- <SeparatorItem />
-- <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.GtkSettings" />
-+ <Extension path = "/MonoDevelop/Ide/ContextMenu/ProjectPad">
-+ <Condition id="ItemType" value="Project|MonoDevelop.GtkCore.NodeBuilders.GuiProjectFolder">
-+ <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.EditIcons" insertafter="BuildSectionEnd"/>
-+ <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.ImportGladeFile" />
-+ <SeparatorItem/>
-+ <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.GtkSettings" />
-+ </Condition>
-+ <Condition id="ItemType" value="ProjectFile">
-+ <CommandItem id = "MonoDevelop.GtkCore.GtkCommands.GenerateCode" insertafter="BuildSectionEnd"/>
-+ </Condition>
- </Extension>
-
- <Extension path = "/MonoDevelop/GtkCore/ContextMenu/ProjectPad.Component">
-@@ -145,7 +151,8 @@
- <Section id = "SteticOptionsPanel"
- _label = "GTK# Settings"
- fill="true"
-- class = "MonoDevelop.GtkCore.Dialogs.WidgetBuilderOptionPanel"/>
-+ class = "MonoDevelop.GtkCore.Dialogs.WidgetBuilderOptionPanel"
-+ icon = "md-gtkcore-gtk-logo"/>
- </Condition>
- </Extension>
-
-@@ -158,8 +165,17 @@
- <StockIcon stockid = "md-gtkcore-dialog" resource = "dialog.png" />
- <StockIcon stockid = "md-gtkcore-widget" resource = "widget.png" />
- <StockIcon stockid = "md-gtkcore-actiongroup" resource = "actiongroup.png" />
-+ <StockIcon stockid = "md-gtkcore-iconfactory" resource = "image-x-generic.png" />
-+ <StockIcon stockid = "md-gtkcore-gtkx" resource = "gtkx.png" />
-+ <StockIcon stockid = "md-gtkcore-gtk-logo" resource = "gtk-logo.png"/>
- </Extension>
-
-+ <Extension path = "/MonoDevelop/Core/MimeTypes">
-+ <MimeType id="text/x-gtkx" _description="Gtk# designer file" isText="true">
-+ <File pattern="*.gtkx" />
-+ </MimeType>
-+ </Extension>
-+
- <Extension path = "/MonoDevelop/ProjectModel/ProjectServiceExtensions">
- <Class class = "MonoDevelop.GtkCore.GuiBuilder.GtkProjectServiceExtension" insertafter="MidStep"/>
- </Extension>
-@@ -181,6 +197,10 @@
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/GlobalOptionsDialog/Preferences/Style">
-- <Panel _label = "GTK# Designer" class = "MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionPanel" />
-+ <Panel _label = "GTK# Designer" class = "MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionPanel" />
- </Extension>
-+
-+ <Extension path = "/MonoDevelop/XmlEditor/XmlFileExtensions">
-+ <XmlFileExtension extension = ".gtkx"/>
-+ </Extension>
- </Addin>
-Index: MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs
-===================================================================
---- MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs (revision 17)
-+++ MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs (working copy)
-@@ -25,15 +25,15 @@
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
--
--
- using System;
- using MonoDevelop.Projects;
- using MonoDevelop.Ide.Gui.Pads.ProjectPad;
- using MonoDevelop.Components.Commands;
- using MonoDevelop.GtkCore.GuiBuilder;
-+using MonoDevelop.Ide.Gui;
- using MonoDevelop.Ide.Gui.Components;
- using MonoDevelop.Ide;
-+using MonoDevelop.Ide.Commands;
-
- namespace MonoDevelop.GtkCore.NodeBuilders
- {
-@@ -41,8 +41,9 @@
- {
- public override bool CanBuildNode (Type dataType)
- {
-- return typeof(ProjectFolder).IsAssignableFrom (dataType) ||
-- typeof(DotNetProject).IsAssignableFrom (dataType);
-+ return typeof(ProjectFolder).IsAssignableFrom (dataType) && !(dataType is GuiProjectFolder);
-+// typeof(DotNetProject).IsAssignableFrom (dataType);
-+ return false;
- }
-
- public override Type CommandHandlerType {
-@@ -51,13 +52,13 @@
-
- public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
- {
-- if (treeNavigator.Options ["ShowAllFiles"])
-+ if (dataObject is GuiProjectFolder)
- return;
--
-+
- ProjectFolder folder = dataObject as ProjectFolder;
- if (folder != null && folder.Project is DotNetProject) {
- GtkDesignInfo info = GtkDesignInfo.FromProject (folder.Project);
-- if (info.GtkGuiFolder == folder.Path)
-+ if (info.SteticFolder == folder.Path)
- attributes |= NodeAttributes.Hidden;
- }
- }
-@@ -74,7 +75,7 @@
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewDialog)]
- public void UpdateAddNewDialogToProject (CommandInfo cinfo)
- {
-- cinfo.Visible = CanAddWindow ();
-+ cinfo.Visible = CanAddWindow () && !(CurrentNode.DataItem is GuiProjectFolder);
- }
-
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWindow)]
-@@ -86,7 +87,7 @@
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWindow)]
- public void UpdateAddNewWindowToProject (CommandInfo cinfo)
- {
-- cinfo.Visible = CanAddWindow ();
-+ cinfo.Visible = CanAddWindow () && !(CurrentNode.DataItem is GuiProjectFolder);
- }
-
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWidget)]
-@@ -98,8 +99,8 @@
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWidget)]
- public void UpdateAddNewWidgetToProject (CommandInfo cinfo)
- {
-- cinfo.Visible = CanAddWindow ();
-- }
-+ cinfo.Visible = CanAddWindow () && !(CurrentNode.DataItem is GuiProjectFolder);
-+ }
-
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewActionGroup)]
- public void AddNewActionGroupToProject()
-@@ -110,51 +111,20 @@
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewActionGroup)]
- public void UpdateAddNewActionGroupToProject(CommandInfo cinfo)
- {
-- cinfo.Visible = CanAddWindow ();
-+ cinfo.Visible = CanAddWindow () && !(CurrentNode.DataItem is GuiProjectFolder);
- }
-
-- [CommandHandler (GtkCommands.ImportGladeFile)]
-- protected void OnImportGladeFile ()
-+ public override bool CanDropMultipleNodes (object[] dataObjects, DragOperation operation, DropPosition position)
- {
-- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
-- GuiBuilderService.ImportGladeFile (project);
-+ return false;
-+
-+ foreach (object dataObject in dataObjects)
-+ if (dataObjects is GuiProjectFolder)
-+ return false;
-+
-+ return base.CanDropMultipleNodes (dataObjects, operation, position);
- }
--
-- [CommandUpdateHandler (GtkCommands.ImportGladeFile)]
-- protected void UpdateImportGladeFile (CommandInfo cinfo)
-- {
-- cinfo.Visible = CanAddWindow ();
-- }
--
-- [CommandHandler (GtkCommands.EditIcons)]
-- protected void OnEditIcons ()
-- {
-- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
-- GuiBuilderProject gp = GtkDesignInfo.FromProject (project).GuiBuilderProject;
-- Stetic.Project sp = gp.SteticProject;
-- sp.EditIcons ();
-- gp.Save (true);
-- }
--
-- [CommandUpdateHandler (GtkCommands.EditIcons)]
-- protected void UpdateEditIcons (CommandInfo cinfo)
-- {
-- cinfo.Visible = CanAddWindow ();
-- }
--
-- [CommandHandler (GtkCommands.GtkSettings)]
-- protected void OnGtkSettings ()
-- {
-- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
-- IdeApp.ProjectOperations.ShowOptions (project, "SteticOptionsPanel");
-- }
--
-- [CommandUpdateHandler (GtkCommands.EditIcons)]
-- protected void UpdateGtkSettings (CommandInfo cinfo)
-- {
-- cinfo.Visible = CanAddWindow ();
-- }
--
-+
- bool CanAddWindow ()
- {
- DotNetProject project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
-Index: MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs
-===================================================================
---- MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs (revision 17)
-+++ MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs (working copy)
-@@ -70,7 +70,7 @@
- GtkDesignInfo info = GtkDesignInfo.FromProject (node.Project);
- GuiBuilderProject gp = info.GuiBuilderProject;
- Stetic.Project sp = gp.SteticProject;
-- sp.ImagesRootPath = FileService.AbsoluteToRelativePath (info.GtkGuiFolder, gp.Project.BaseDirectory);
-+ sp.ImagesRootPath = FileService.AbsoluteToRelativePath (info.SteticFolder, gp.Project.BaseDirectory);
- sp.ImportFileCallback = delegate (string file) {
- return GuiBuilderService.ImportFile (gp.Project, file);
- };
-Index: MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs
-===================================================================
---- MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs (revision 0)
-+++ MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs (revision 124)
-@@ -0,0 +1,144 @@
-+using System;
-+
-+using MonoDevelop.Components.Commands;
-+using MonoDevelop.GtkCore.GuiBuilder;
-+using MonoDevelop.Ide;
-+using MonoDevelop.Ide.Commands;
-+using MonoDevelop.Ide.Gui;
-+using MonoDevelop.Ide.Gui.Components;
-+using MonoDevelop.Ide.Gui.Pads.ProjectPad;
-+using MonoDevelop.Projects;
-+using MonoDevelop.Projects.Dom;
-+
-+namespace MonoDevelop.GtkCore.NodeBuilders
-+{
-+ public class ProjectFileBuilder : ProjectFileNodeBuilder
-+ {
-+
-+ }
-+
-+ public class ProjectFileNodeBuilderExtension : NodeBuilderExtension
-+ {
-+ public override bool CanBuildNode (Type dataType)
-+ {
-+ return typeof(ProjectFile).IsAssignableFrom (dataType);
-+ }
-+
-+ public override Type CommandHandlerType {
-+ get { return typeof (ComponentCommandHandler); }
-+ }
-+
-+ public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
-+ {
-+ if (treeNavigator.Options ["ShowAllFiles"])
-+ return;
-+
-+ ProjectFile pf = (ProjectFile) dataObject;
-+ GtkDesignInfo info = GtkDesignInfo.FromProject (pf.Project);
-+ if (info.HideGtkxFiles && pf.FilePath.Extension == ".gtkx")
-+ attributes |= NodeAttributes.Hidden;
-+ }
-+
-+
-+ public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
-+ {
-+ ProjectFile pf = (ProjectFile) dataObject;
-+
-+ //do not show custom icon for generated source files
-+ if (pf.DependsOn == null) {
-+ GtkComponentType type = pf.GetComponentType ();
-+
-+ switch (type) {
-+ case GtkComponentType.Dialog :
-+ icon = ImageService.GetPixbuf ("md-gtkcore-dialog", Gtk.IconSize.Menu);
-+ break;
-+ case GtkComponentType.Widget :
-+ icon = ImageService.GetPixbuf ("md-gtkcore-widget", Gtk.IconSize.Menu);
-+ break;
-+ case GtkComponentType.ActionGroup :
-+ icon = ImageService.GetPixbuf ("md-gtkcore-actiongroup", Gtk.IconSize.Menu);
-+ break;
-+ case GtkComponentType.IconFactory :
-+ icon = ImageService.GetPixbuf ("md-gtkcore-iconfactory", Gtk.IconSize.Menu);
-+ label = "Stock icons";
-+ break;
-+ }
-+ }
-+ }
-+
-+ //override
-+ public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
-+ {
-+ return base.HasChildNodes (builder, dataObject);
-+ }
-+ }
-+
-+ public class ComponentCommandHandler : NodeCommandHandler
-+ {
-+ /*public override void ActivateItem ()
-+ {
-+ ProjectFile pf = (ProjectFile) CurrentNode.DataItem;
-+
-+ if (pf.IsComponentFile ()) {
-+ Document doc = IdeApp.Workbench.OpenDocument (pf.FilePath, true);
-+
-+ if (doc != null) {
-+ GuiBuilderView view = doc.GetContent<GuiBuilderView> ();
-+ if (view != null) {
-+ GtkComponentType type = pf.GetComponentType ();
-+
-+ switch (type) {
-+ case GtkComponentType.Dialog :
-+ case GtkComponentType.Widget :
-+ view.ShowDesignerView ();
-+ break;
-+ case GtkComponentType.ActionGroup :
-+ view.ShowActionDesignerView (((Stetic.ActionGroupInfo) CurrentNode.DataItem).Name);
-+ break;
-+ }
-+ }
-+ }
-+ return;
-+ }
-+ base.ActivateItem ();
-+ }
-+ */
-+
-+ [CommandHandler (GtkCommands.GenerateCode)]
-+ protected void OnGenerateCode ()
-+ {
-+ ProjectFile pf = CurrentNode.DataItem as ProjectFile;
-+ Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
-+ GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-+ GuiBuilderProject gproject = info.GuiBuilderProject;
-+
-+ gproject.GenerateCode (pf.FilePath);
-+ }
-+
-+ [CommandUpdateHandler (GtkCommands.GenerateCode)]
-+ protected void UpdateGenerateCode (CommandInfo cinfo)
-+ {
-+ ProjectFile pf = CurrentNode.DataItem as ProjectFile;
-+
-+ if (pf.DependsOn == null && pf.HasChildren)
-+ cinfo.Visible = pf.IsComponentFile ();
-+ else
-+ cinfo.Visible = false;
-+ }
-+
-+ [CommandUpdateHandler (EditCommands.Copy)]
-+ [CommandUpdateHandler (EditCommands.Delete)]
-+ [CommandUpdateHandler (EditCommands.Rename)]
-+ protected void UpdateDisabledCommands (CommandInfo cinfo)
-+ {
-+ //disable operations for generated files in designer folder
-+ cinfo.Visible = false;//(CurrentNode.GetParentDataItem (typeof (GuiProjectFolder), true) == null);
-+ }
-+
-+ public override DragOperation CanDragNode ()
-+ {
-+ return DragOperation.None;
-+ }
-+
-+ }
-+}
-\ No newline at end of file
-Index: MonoDevelop.GtkCore.NodeBuilders/ChangeLog
-===================================================================
---- MonoDevelop.GtkCore.NodeBuilders/ChangeLog (revision 0)
-+++ MonoDevelop.GtkCore.NodeBuilders/ChangeLog (revision 125)
-@@ -0,0 +1,58 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * ProjectNodeBuilder.cs:
-+ * GuiProjectFolderNodeBuilder.cs:
-+
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * ProjectFileExtension.cs:
-+ * GuiProjectFolderNodeBuilder.cs:
-+ * ProjectFileNodeBuilderExtension.cs:
-+ * ProjectFolderNodeBuilderExtension.cs:
-+
-+2010-08-13 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * ProjectNodeBuilder.cs:
-+ * StockIconsNodeBuilder.cs:
-+ * ProjectFileNodeBuilderExtension.cs:
-+ * ProjectFolderNodeBuilderExtension.cs:
-+
-+2010-08-09 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GuiProjectFolder.cs: Put gui project folder directly below References
-+ in the project pad
-+ * ProjectNodeBuilder.cs:
-+ * GuiProjectFolderNodeBuilder.cs:
-+ * ProjectFolderNodeBuilderExtension.cs:
-+
-+2010-07-06 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ProjectFileExtension.cs: Move cursor in entryFolder to the end.
-+
-+2010-07-05 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ProjectFileExtension.cs: Better approach for obtaining GtkComponentType
-+ * ProjectFileNodeBuilderExtension.cs:
-+ * ProjectFolderNodeBuilderExtension.cs:
-+
-+2010-06-28 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ProjectNodeBuilder.cs:
-+ * ProjectFileNodeBuilderExtension.cs:
-+ * ProjectFolderNodeBuilderExtension.cs:
-+
-+2010-06-23 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ProjectNodeBuilder.cs:
-+ * ProjectFileNodeBuilderExtension.cs: Show ProjectConversionDialog before
-+ conversion
-+
-+2010-06-21 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ProjectNodeBuilder.cs: Convert a project file layout on open
-+ * ProjectFileNodeBuilderExtension.cs: Group components files
-+
-+2010-06-16 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ProjectFileNodeBuilderExtension.cs:
-+
-Index: MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs
-===================================================================
---- MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs (revision 17)
-+++ MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs (working copy)
-@@ -28,14 +28,19 @@
-
- using System;
- using System.Collections;
-+using System.IO;
-
-+using Gtk;
-+
- using MonoDevelop.Projects;
- using MonoDevelop.Core;
- using MonoDevelop.Ide.Gui.Pads;
- using MonoDevelop.Ide.Gui;
- using MonoDevelop.Ide.Gui.Components;
--
-+using MonoDevelop.Ide.Gui.Pads.ProjectPad;
-+using MonoDevelop.GtkCore.Dialogs;
- using MonoDevelop.GtkCore.GuiBuilder;
-+using MonoDevelop.Ide;
-
- namespace MonoDevelop.GtkCore.NodeBuilders
- {
-@@ -48,6 +53,12 @@
- return typeof(DotNetProject).IsAssignableFrom (dataType);
- }
-
-+ public override Type CommandHandlerType {
-+ get {
-+ return typeof (GuiProjectFolderCommandHandler);
-+ }
-+ }
-+
- protected override void Initialize ()
- {
- lock (typeof (ProjectNodeBuilder))
-@@ -60,10 +71,62 @@
- instance = null;
- }
-
-+ public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
-+ {
-+ Project project = dataObject as Project;
-+
-+ if (project is DotNetProject) {
-+ GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-+
-+ if (info.OldVersion) {
-+ ProjectConversionDialog dialog = new ProjectConversionDialog (project, info.SteticFolderName);
-+
-+ try
-+ {
-+ if (dialog.Run () == (int)ResponseType.Yes) {
-+ info.GuiBuilderProject.Convert (dialog.GuiFolderName, dialog.MakeBackup);
-+ IdeApp.ProjectOperations.Save (project);
-+ }
-+ } finally {
-+ dialog.Destroy ();
-+ }
-+ }
-+
-+ project.FileAddedToProject += HandleProjectFileAddedToProject;
-+ }
-+ }
-+
-+ void HandleProjectFileAddedToProject (object sender, ProjectFileEventArgs e)
-+ {
-+ Project project = e.Project;
-+ ProjectFile pf = e.ProjectFile;
-+ string fileName = pf.FilePath.FullPath.ToString ();
-+ GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-+
-+ string buildFile = info.GetBuildFile (fileName);
-+ if (!project.IsFileInProject(buildFile) && File.Exists (buildFile)) {
-+ ProjectFile pf2 = project.AddFile (buildFile, BuildAction.Compile);
-+ pf2.DependsOn = pf.FilePath.FileName;
-+ }
-+
-+ string gtkxFile = info.GetGtkxFile (fileName);
-+ if (!project.IsFileInProject(gtkxFile) && File.Exists (gtkxFile)) {
-+ ProjectFile pf3 = project.AddFile (gtkxFile, BuildAction.EmbeddedResource);
-+ pf3.DependsOn = pf.FilePath.FileName;
-+ }
-+ }
-+
- public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
- {
-- if (GtkDesignInfo.HasDesignedObjects ((Project)dataObject))
-- builder.AddChild (new WindowsFolder ((Project)dataObject));
-+ Project project = (Project)dataObject;
-+ GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-+
-+ if (GtkDesignInfo.HasDesignedObjects (project)) {
-+ GuiProjectFolder folder = new GuiProjectFolder(info.SteticFolder.FullPath, project, null);
-+
-+ builder.AddChild (new WindowsFolder (project));
-+ builder.AddChild (folder);
-+ }
- }
-
- public static void OnSupportChanged (Project p)
-Index: MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs
-===================================================================
---- MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs (revision 0)
-+++ MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs (revision 124)
-@@ -0,0 +1,52 @@
-+using System;
-+using MonoDevelop.GtkCore.GuiBuilder;
-+using MonoDevelop.Projects;
-+using MonoDevelop.Projects.Dom;
-+using MonoDevelop.Projects.Dom.Parser;
-+
-+namespace MonoDevelop.GtkCore.NodeBuilders
-+{
-+ public enum GtkComponentType
-+ {
-+ Dialog,
-+ Widget,
-+ ActionGroup,
-+ IconFactory,
-+ None
-+ }
-+
-+ public static class ProjectFileExtension
-+ {
-+ public static bool IsComponentFile (this ProjectFile pf)
-+ {
-+ return pf.GetComponentType () != GtkComponentType.None;
-+ }
-+
-+ public static GtkComponentType GetComponentType (this ProjectFile pf)
-+ {
-+ GtkDesignInfo info = GtkDesignInfo.FromProject (pf.Project);
-+ ParsedDocument doc = ProjectDomService.GetParsedDocument (ProjectDomService.GetProjectDom (pf.Project), pf.Name);
-+ //ParsedDocument doc = ProjectDomService.ParseFile (ProjectDomService.GetProjectDom (pf.Project), pf.FilePath.ToString ());
-+ if (doc != null && doc.CompilationUnit != null) {
-+ foreach (IType t in doc.CompilationUnit.Types) {
-+ string className = t.FullName;
-+ if (className != null) {
-+ GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass (className);
-+ if (win != null)
-+ return win.RootWidget.IsWindow ? GtkComponentType.Dialog : GtkComponentType.Widget;
-+
-+ Stetic.ActionGroupInfo action = info.GuiBuilderProject.GetActionGroup (className);
-+ if (action != null)
-+ return GtkComponentType.ActionGroup;
-+
-+ }
-+ }
-+ }
-+ if (pf.Name.Contains ("IconFactory.gtkx"))
-+ return GtkComponentType.IconFactory;
-+
-+ return GtkComponentType.None;
-+ }
-+ }
-+}
-+
-Index: MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolderNodeBuilder.cs
-===================================================================
---- MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolderNodeBuilder.cs (revision 0)
-+++ MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolderNodeBuilder.cs (revision 125)
-@@ -0,0 +1,176 @@
-+//
-+// GuiProjectFolderNodeBuilder.cs
-+//
-+// Author:
-+// Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+//
-+// Copyright (c) 2010 KrzysztofMarecki
-+//
-+// Permission is hereby granted, free of charge, to any person obtaining
-+// a copy of this software and associated documentation files (the
-+// "Software"), to deal in the Software without restriction, including
-+// without limitation the rights to use, copy, modify, merge, publish,
-+// distribute, sublicense, and/or sell copies of the Software, and to
-+// permit persons to whom the Software is furnished to do so, subject to
-+// the following conditions:
-+//
-+// The above copyright notice and this permission notice shall be
-+// included in all copies or substantial portions of the Software.
-+//
-+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+using System;
-+using MonoDevelop.Components.Commands;
-+using MonoDevelop.Core;
-+using MonoDevelop.Ide.Commands;
-+using MonoDevelop.Ide;
-+using MonoDevelop.Ide.Gui;
-+using MonoDevelop.Ide.Gui.Components;
-+using MonoDevelop.Ide.Gui.Pads.ProjectPad;
-+using MonoDevelop.Projects;
-+
-+using MonoDevelop.GtkCore.GuiBuilder;
-+
-+namespace MonoDevelop.GtkCore.NodeBuilders
-+{
-+ public class GuiProjectFolderNodeBuilder : ProjectFolderNodeBuilder
-+ {
-+ public override Type NodeDataType {
-+ get { return typeof(GuiProjectFolder); }
-+ }
-+
-+ public override Type CommandHandlerType {
-+ get { return typeof(GuiProjectFolderCommandHandler); }
-+ }
-+
-+ public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
-+ {
-+ //nodes are sorted alphabetically and we want to have gui folder on the top
-+ return string.Empty;
-+ }
-+
-+
-+ public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
-+ {
-+ GuiProjectFolder folder = (GuiProjectFolder) dataObject;
-+
-+ icon = Context.GetIcon (Stock.OpenResourceFolder);
-+ closedIcon = Context.GetIcon (Stock.ClosedResourceFolder);
-+ label = folder.Name;
-+ }
-+ }
-+
-+ public class GuiProjectFolderCommandHandler : ProjectFolderCommandHandler
-+ {
-+ [CommandHandler (GtkCommands.ImportGladeFile)]
-+ protected void OnImportGladeFile ()
-+ {
-+ Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
-+ GuiBuilderService.ImportGladeFile (project);
-+ }
-+
-+ [CommandUpdateHandler (GtkCommands.ImportGladeFile)]
-+ protected void UpdateImportGladeFile (CommandInfo cinfo)
-+ {
-+ cinfo.Visible = CanAddWindow ();
-+ }
-+
-+ [CommandHandler (GtkCommands.EditIcons)]
-+ protected void OnEditIcons ()
-+ {
-+ Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
-+ GuiBuilderProject gp = GtkDesignInfo.FromProject (project).GuiBuilderProject;
-+ Stetic.Project sp = gp.SteticProject;
-+ sp.EditIcons ();
-+ gp.Save (true);
-+ }
-+
-+ [CommandUpdateHandler (GtkCommands.EditIcons)]
-+ protected void UpdateEditIcons (CommandInfo cinfo)
-+ {
-+ cinfo.Visible = CanAddWindow ();
-+ }
-+
-+ [CommandHandler (GtkCommands.GtkSettings)]
-+ protected void OnGtkSettings ()
-+ {
-+ Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
-+ IdeApp.ProjectOperations.ShowOptions (project, "SteticOptionsPanel");
-+ }
-+
-+ [CommandUpdateHandler (GtkCommands.EditIcons)]
-+ protected void UpdateGtkSettings (CommandInfo cinfo)
-+ {
-+ //cinfo.Visible = CanAddWindow ();
-+ }
-+
-+ [CommandUpdateHandler (EditCommands.Delete)]
-+ [CommandUpdateHandler (EditCommands.Rename)]
-+ [CommandUpdateHandler (ProjectCommands.AddNewFiles)]
-+ [CommandUpdateHandler (ProjectCommands.AddFiles)]
-+ [CommandUpdateHandler (ProjectCommands.AddSolutionFolder)]
-+ [CommandUpdateHandler (ProjectCommands.AddItem)]
-+ [CommandUpdateHandler (ProjectCommands.NewFolder)]
-+ protected void UpdateDisabledCommands (CommandInfo cinfo)
-+ {
-+ cinfo.Visible = false;
-+ cinfo.Enabled = false;
-+ }
-+
-+ bool CanAddWindow ()
-+ {
-+ DotNetProject project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
-+ return GtkDesignInfo.SupportsDesigner (project);
-+ }
-+
-+ public override DragOperation CanDragNode ()
-+ {
-+ return DragOperation.None;
-+ }
-+
-+ public override bool CanDeleteItem ()
-+ {
-+ return false;
-+ }
-+
-+ public override bool CanDropMultipleNodes (object[] dataObjects, DragOperation operation)
-+ {
-+ return false;
-+ }
-+
-+ public override bool CanDropMultipleNodes (object[] dataObjects, DragOperation operation, DropPosition position)
-+ {
-+ return false;
-+ }
-+
-+ public override bool CanDeleteMultipleItems ()
-+ {
-+ return false;
-+ }
-+
-+ public override bool CanDropNode (object dataObject, DragOperation operation)
-+ {
-+ return false;
-+ }
-+
-+ public override bool CanDropNode (object dataObject, DragOperation operation, DropPosition position)
-+ {
-+ return false;
-+ }
-+
-+ public override void RenameItem (string newName)
-+ {
-+ Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
-+ GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-+ info.SteticFolderName = newName;
-+
-+ base.RenameItem (newName);
-+ }
-+ }
-+}
-+
-Index: MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolder.cs
-===================================================================
---- MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolder.cs (revision 0)
-+++ MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolder.cs (revision 112)
-@@ -0,0 +1,42 @@
-+//
-+// GuiProjectFolder.cs
-+//
-+// Author:
-+// Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+//
-+// Copyright (c) 2010 KrzysztofMarecki
-+//
-+// Permission is hereby granted, free of charge, to any person obtaining
-+// a copy of this software and associated documentation files (the
-+// "Software"), to deal in the Software without restriction, including
-+// without limitation the rights to use, copy, modify, merge, publish,
-+// distribute, sublicense, and/or sell copies of the Software, and to
-+// permit persons to whom the Software is furnished to do so, subject to
-+// the following conditions:
-+//
-+// The above copyright notice and this permission notice shall be
-+// included in all copies or substantial portions of the Software.
-+//
-+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+using MonoDevelop.Core;
-+using MonoDevelop.Ide.Gui.Pads.ProjectPad;
-+using MonoDevelop.Projects;
-+using MonoDevelop.Projects.Dom;
-+
-+namespace MonoDevelop.GtkCore.NodeBuilders
-+{
-+ public class GuiProjectFolder : ProjectFolder
-+ {
-+ public GuiProjectFolder (FilePath absolutePath, IWorkspaceObject parentWorkspaceObject, object parent)
-+ : base (absolutePath, parentWorkspaceObject, parent)
-+ {
-+ }
-+ }
-+}
-+
-Index: MonoDevelop.GtkCore.NodeBuilders/WindowsFolderNodeBuilder.cs
-===================================================================
---- MonoDevelop.GtkCore.NodeBuilders/WindowsFolderNodeBuilder.cs (revision 17)
-+++ MonoDevelop.GtkCore.NodeBuilders/WindowsFolderNodeBuilder.cs (working copy)
-@@ -82,10 +82,10 @@
- GtkDesignInfo info = GtkDesignInfo.FromProject (p);
- if (!info.GuiBuilderProject.HasError) {
- builder.AddChild (new StockIconsNode (p));
-- foreach (GuiBuilderWindow fi in info.GuiBuilderProject.Windows)
-- builder.AddChild (fi);
-- foreach (Stetic.ActionGroupInfo group in info.GuiBuilderProject.SteticProject.ActionGroups)
-- builder.AddChild (group);
-+// foreach (GuiBuilderWindow fi in info.GuiBuilderProject.Windows)
-+// builder.AddChild (fi);
-+// foreach (Stetic.ActionGroupInfo group in info.GuiBuilderProject.SteticProject.ActionGroups)
-+// builder.AddChild (group);
- }
- }
-
-Index: MonoDevelop.GtkCore.Dialogs/ProjectConversionDialog.cs
-===================================================================
---- MonoDevelop.GtkCore.Dialogs/ProjectConversionDialog.cs (revision 0)
-+++ MonoDevelop.GtkCore.Dialogs/ProjectConversionDialog.cs (revision 124)
-@@ -0,0 +1,40 @@
-+using System;
-+using Gtk;
-+
-+using MonoDevelop.Projects;
-+
-+namespace MonoDevelop.GtkCore.Dialogs
-+{
-+ public partial class ProjectConversionDialog : Gtk.Dialog
-+ {
-+ public ProjectConversionDialog (IntPtr raw)
-+ : base (raw)
-+ {
-+ }
-+
-+ public string GuiFolderName { get; private set; }
-+
-+ public bool MakeBackup { get; private set; }
-+
-+
-+ public ProjectConversionDialog (Project project, string guiFolderName)
-+ {
-+ this.Build ();
-+
-+ entryFolder.Text = guiFolderName;
-+ Title = project.Name;
-+ entryFolder.Position = -1;
-+
-+ buttonConvert.Clicked += HandleButtonConvertClicked;
-+ }
-+
-+ void HandleButtonConvertClicked (object sender, EventArgs e)
-+ {
-+ GuiFolderName = entryFolder.Text;
-+ MakeBackup = checkBackup.Active;
-+
-+ Respond (ResponseType.Yes);
-+ }
-+ }
-+}
-+
-Index: MonoDevelop.GtkCore.Dialogs/ChangeLog
-===================================================================
---- MonoDevelop.GtkCore.Dialogs/ChangeLog (revision 0)
-+++ MonoDevelop.GtkCore.Dialogs/ChangeLog (revision 124)
-@@ -0,0 +1,18 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * ProjectConversionDialog.cs:
-+
-+2010-08-13 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * ProjectConversionDialog.cs:
-+ * WidgetBuilderOptionPanel.cs:
-+
-+2010-07-06 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ProjectConversionDialog.cs:
-+
-+2010-06-23 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * ProjectConversionDialog.cs: Initial commit
-+ * WidgetBuilderOptionPanel.cs:
-+
-Index: MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs
-===================================================================
---- MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs (revision 17)
-+++ MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs (working copy)
-@@ -43,6 +43,8 @@
- Gtk.CheckButton checkGettext;
- Gtk.Entry entryGettext;
- Gtk.ComboBox comboVersions;
-+ Gtk.Entry entryFolderName;
-+ Gtk.CheckButton checkHideFiles;
-
- DotNetProject project;
-
-@@ -84,11 +86,23 @@
- box.ShowAll ();
- PackStart (box, false, false, 0);
-
-- checkGettext.Clicked += delegate {
-- box.Sensitive = checkGettext.Active;
-- if (checkGettext.Active)
-- entryGettext.Text = "Mono.Unix.Catalog";
-- };
-+ sep= new HSeparator ();
-+ sep.Show ();
-+ PackStart (sep, false, false, 0);
-+
-+ box = new Gtk.HBox (false, 3);
-+ box.PackStart (new Label (GettextCatalog.GetString ("Stetic folder name :")), false, false, 0);
-+ entryFolderName = new Gtk.Entry ();
-+ entryFolderName.Text = designInfo.SteticFolderName;
-+ entryFolderName.Sensitive = false;
-+ box.PackStart (entryFolderName, false, false, 0);
-+ box.ShowAll ();
-+ PackStart (box, false, false, 0);
-+
-+ checkHideFiles = new CheckButton (GettextCatalog.GetString ("Hide designer files"));
-+ checkHideFiles.Active = designInfo.HideGtkxFiles;
-+ checkHideFiles.Show ();
-+ PackStart (checkHideFiles, false, false, 0);
- }
-
- public void Store ()
-@@ -101,6 +115,8 @@
- info.GenerateGettext = checkGettext.Active;
- info.GettextClass = entryGettext.Text;
- info.GuiBuilderProject.SteticProject.TargetGtkVersion = comboVersions.ActiveText;
-+ info.SteticFolderName = entryFolderName.Text;
-+ info.HideGtkxFiles = checkHideFiles.Active;
- info.GuiBuilderProject.Save (false);
- }
- refmgr.Dispose ();
-Index: MonoDevelop.GtkCore2.csproj
-===================================================================
---- MonoDevelop.GtkCore2.csproj (revision 17)
-+++ MonoDevelop.GtkCore2.csproj (working copy)
-@@ -59,12 +59,21 @@
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
-+ <Reference Include="System.Core" />
-+ <Reference Include="Mono.Cecil, Version=0.6.9.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
-+ <Package>monodevelop</Package>
-+ </Reference>
-+ <Reference Include="NRefactory, Version=2.1.1.0, Culture=neutral, PublicKeyToken=efe927acf176eea2">
-+ <Package>monodevelop</Package>
-+ </Reference>
-+ <Reference Include="Mono.Debugging, Version=0.0.0.0, Culture=neutral, PublicKeyToken=9307d64546e0580d">
-+ <Package>monodevelop</Package>
-+ </Reference>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
- <Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
- <Name>MonoDevelop.Core</Name>
-- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\..\core\MonoDevelop.Ide\MonoDevelop.Ide.csproj">
- <Project>{27096E7F-C91C-4AC6-B289-6897A701DF21}</Project>
-@@ -76,11 +85,6 @@
- <Name>MonoDevelop.DesignerSupport</Name>
- <Private>False</Private>
- </ProjectReference>
-- <ProjectReference Include="..\..\..\contrib\Mono.Cecil\Mono.Cecil.csproj">
-- <Project>{3EC06433-F168-4C5B-A885-99CE4AB617E1}</Project>
-- <Name>Mono.Cecil</Name>
-- <Private>False</Private>
-- </ProjectReference>
- <ProjectReference Include="..\Deployment\MonoDevelop.Deployment\MonoDevelop.Deployment.csproj">
- <Project>{9BC670A8-1851-40EC-9685-279F4C98433D}</Project>
- <Name>MonoDevelop.Deployment</Name>
-@@ -151,6 +155,12 @@
- <EmbeddedResource Include="gtk-gui\gui.stetic">
- <LogicalName>gui.stetic</LogicalName>
- </EmbeddedResource>
-+ <EmbeddedResource Include="icons\gtkx.png">
-+ <LogicalName>gtkx.png</LogicalName>
-+ </EmbeddedResource>
-+ <EmbeddedResource Include="icons\gtk-logo.png">
-+ <LogicalName>gtk-logo.png</LogicalName>
-+ </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="MonoDevelop.GtkCore.Commands\GladeCommands.cs" />
-@@ -166,7 +176,6 @@
- <Compile Include="MonoDevelop.GtkCore\GtkCoreService.cs" />
- <Compile Include="MonoDevelop.GtkCore.Dialogs\WidgetBuilderOptionPanel.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectNodeBuilder.cs" />
-- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\WidgetNodeBuilder.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectFolderNodeBuilderExtension.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\WindowsFolderNodeBuilder.cs" />
- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\WindowsFolder.cs" />
-@@ -176,7 +185,6 @@
- <Compile Include="MonoDevelop.GtkCore.Dialogs\ConfirmWindowDeleteDialog.cs" />
- <Compile Include="MonoDevelop.GtkCore\ProjectResourceProvider.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ActionGroupView.cs" />
-- <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ActionGroupNodeBuilder.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\ActionGroupDisplayBinding.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\CombinedDesignView.cs" />
- <Compile Include="MonoDevelop.GtkCore.GuiBuilder\CodeBinder.cs" />
-@@ -193,8 +201,15 @@
- <Compile Include="MonoDevelop.GtkCore.Dialogs\GtkDesignerOptionsPanelWidget.cs" />
- <Compile Include="gtk-gui\MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.cs" />
- <Compile Include="MonoDevelop.GtkCore\Counters.cs" />
-+ <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectFileNodeBuilderExtension.cs" />
-+ <Compile Include="MonoDevelop.GtkCore.NodeBuilders\ProjectFileExtension.cs" />
-+ <Compile Include="MonoDevelop.GtkCore.Dialogs\ProjectConversionDialog.cs" />
-+ <Compile Include="MonoDevelop.GtkCore.NodeBuilders\GuiProjectFolder.cs" />
-+ <Compile Include="MonoDevelop.GtkCore.NodeBuilders\GuiProjectFolderNodeBuilder.cs" />
-+ <Compile Include="gtk-gui\MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-+ <Import Project="$(MSBuildExtensionsPath)\Mono.Addins.targets" />
- <ProjectExtensions>
- <MonoDevelop>
- <Properties>
-Index: gtk-gui/MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs
-===================================================================
---- gtk-gui/MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs (revision 0)
-+++ gtk-gui/MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs (revision 124)
-@@ -0,0 +1,183 @@
-+// ------------------------------------------------------------------------------
-+// <autogenerated>
-+// This code was generated by a tool.
-+// Mono Runtime Version: 2.0.50727.1433
-+//
-+// Changes to this file may cause incorrect behavior and will be lost if
-+// the code is regenerated.
-+// </autogenerated>
-+// ------------------------------------------------------------------------------
-+
-+
-+// This file has been generated by the GUI designer. Do not modify.
-+namespace MonoDevelop.GtkCore.Dialogs
-+{
-+ public partial class ProjectConversionDialog
-+ {
-+ private global::Gtk.HBox hbox;
-+
-+ private global::Gtk.Alignment alignmentLogo;
-+
-+ private global::Gtk.Image imageLogo;
-+
-+ private global::Gtk.VBox vbox2;
-+
-+ private global::Gtk.Label labelProject;
-+
-+ private global::Gtk.Label labelInfo;
-+
-+ private global::Gtk.HSeparator hseparator1;
-+
-+ private global::Gtk.HBox hbox1;
-+
-+ private global::Gtk.Label labelFolder;
-+
-+ private global::Gtk.Entry entryFolder;
-+
-+ private global::Gtk.CheckButton checkBackup;
-+
-+ private global::Gtk.Button buttonConvert;
-+
-+ protected virtual void Build ()
-+ {
-+ global::Stetic.Gui.Initialize (this);
-+ // Widget MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog
-+ this.Name = "MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog";
-+ this.Title = global::Mono.Unix.Catalog.GetString ("Project Name");
-+ this.WindowPosition = ((global::Gtk.WindowPosition)(4));
-+ this.Modal = true;
-+ this.SkipTaskbarHint = true;
-+ // Internal child MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.VBox
-+ global::Gtk.VBox w1 = this.VBox;
-+ w1.Name = "dialog1_VBox";
-+ w1.BorderWidth = ((uint)(2));
-+ // Container child dialog1_VBox.Gtk.Box+BoxChild
-+ this.hbox = new global::Gtk.HBox ();
-+ this.hbox.Name = "hbox";
-+ this.hbox.Spacing = 6;
-+ // Container child hbox.Gtk.Box+BoxChild
-+ this.alignmentLogo = new global::Gtk.Alignment (1f, 0.15f, 1f, 0f);
-+ this.alignmentLogo.Name = "alignmentLogo";
-+ // Container child alignmentLogo.Gtk.Container+ContainerChild
-+ this.imageLogo = new global::Gtk.Image ();
-+ this.imageLogo.WidthRequest = 180;
-+ this.imageLogo.Name = "imageLogo";
-+ this.imageLogo.Yalign = 0f;
-+ this.imageLogo.Pixbuf = global::Gdk.Pixbuf.LoadFromResource ("gtk-logo.png");
-+ this.alignmentLogo.Add (this.imageLogo);
-+ this.hbox.Add (this.alignmentLogo);
-+ global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox[this.alignmentLogo]));
-+ w3.Position = 0;
-+ w3.Expand = false;
-+ w3.Fill = false;
-+ // Container child hbox.Gtk.Box+BoxChild
-+ this.vbox2 = new global::Gtk.VBox ();
-+ this.vbox2.Name = "vbox2";
-+ this.vbox2.Spacing = 6;
-+ // Container child vbox2.Gtk.Box+BoxChild
-+ this.labelProject = new global::Gtk.Label ();
-+ this.labelProject.Name = "labelProject";
-+ this.labelProject.LabelProp = global::Mono.Unix.Catalog.GetString ("<b><big>GTK# Project Conversion</big></b>");
-+ this.labelProject.UseMarkup = true;
-+ this.vbox2.Add (this.labelProject);
-+ global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.labelProject]));
-+ w4.Position = 0;
-+ w4.Expand = false;
-+ w4.Fill = false;
-+ // Container child vbox2.Gtk.Box+BoxChild
-+ this.labelInfo = new global::Gtk.Label ();
-+ this.labelInfo.Name = "labelInfo";
-+ this.labelInfo.Xalign = 0f;
-+ this.labelInfo.Yalign = 0f;
-+ this.labelInfo.LabelProp = global::Mono.Unix.Catalog.GetString ("This project has been created in the previous\nversion of GTK# addin and must be converted. \n\n<b>Following changes will be made :</b>\n\t- split gui.stetic into separate .gtkx files\n\t- split generated.cs into separate helper classes\n\t- remove gtk-gui folder.\n\t- create a designer folder for stock icons\n\t and generated helper classes. ");
-+ this.labelInfo.UseMarkup = true;
-+ this.labelInfo.Wrap = true;
-+ this.vbox2.Add (this.labelInfo);
-+ global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.labelInfo]));
-+ w5.Position = 1;
-+ w5.Expand = false;
-+ w5.Fill = false;
-+ // Container child vbox2.Gtk.Box+BoxChild
-+ this.hseparator1 = new global::Gtk.HSeparator ();
-+ this.hseparator1.Name = "hseparator1";
-+ this.vbox2.Add (this.hseparator1);
-+ global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hseparator1]));
-+ w6.Position = 2;
-+ w6.Expand = false;
-+ w6.Fill = false;
-+ // Container child vbox2.Gtk.Box+BoxChild
-+ this.hbox1 = new global::Gtk.HBox ();
-+ this.hbox1.Name = "hbox1";
-+ this.hbox1.Spacing = 6;
-+ // Container child hbox1.Gtk.Box+BoxChild
-+ this.labelFolder = new global::Gtk.Label ();
-+ this.labelFolder.Name = "labelFolder";
-+ this.labelFolder.LabelProp = global::Mono.Unix.Catalog.GetString ("Designer folder name:");
-+ this.hbox1.Add (this.labelFolder);
-+ global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.labelFolder]));
-+ w7.Position = 0;
-+ w7.Expand = false;
-+ w7.Fill = false;
-+ // Container child hbox1.Gtk.Box+BoxChild
-+ this.entryFolder = new global::Gtk.Entry ();
-+ this.entryFolder.CanFocus = true;
-+ this.entryFolder.Name = "entryFolder";
-+ this.entryFolder.IsEditable = true;
-+ this.entryFolder.InvisibleChar = '●';
-+ this.hbox1.Add (this.entryFolder);
-+ global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.entryFolder]));
-+ w8.Position = 1;
-+ this.vbox2.Add (this.hbox1);
-+ global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hbox1]));
-+ w9.Position = 3;
-+ w9.Expand = false;
-+ w9.Fill = false;
-+ // Container child vbox2.Gtk.Box+BoxChild
-+ this.checkBackup = new global::Gtk.CheckButton ();
-+ this.checkBackup.CanFocus = true;
-+ this.checkBackup.Name = "checkBackup";
-+ this.checkBackup.Label = global::Mono.Unix.Catalog.GetString ("Make a backup before converting");
-+ this.checkBackup.Active = true;
-+ this.checkBackup.DrawIndicator = true;
-+ this.checkBackup.UseUnderline = true;
-+ this.vbox2.Add (this.checkBackup);
-+ global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.checkBackup]));
-+ w10.Position = 4;
-+ w10.Expand = false;
-+ w10.Fill = false;
-+ this.hbox.Add (this.vbox2);
-+ global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.hbox[this.vbox2]));
-+ w11.Position = 1;
-+ w11.Expand = false;
-+ w11.Fill = false;
-+ w1.Add (this.hbox);
-+ global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(w1[this.hbox]));
-+ w12.Position = 0;
-+ w12.Expand = false;
-+ w12.Fill = false;
-+ // Internal child MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.ActionArea
-+ global::Gtk.HButtonBox w13 = this.ActionArea;
-+ w13.Name = "dialog1_ActionArea";
-+ w13.Spacing = 10;
-+ w13.BorderWidth = ((uint)(5));
-+ w13.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
-+ // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
-+ this.buttonConvert = new global::Gtk.Button ();
-+ this.buttonConvert.CanDefault = true;
-+ this.buttonConvert.CanFocus = true;
-+ this.buttonConvert.Name = "buttonConvert";
-+ this.buttonConvert.UseUnderline = true;
-+ this.buttonConvert.Label = global::Mono.Unix.Catalog.GetString ("_Convert");
-+ this.AddActionWidget (this.buttonConvert, -5);
-+ global::Gtk.ButtonBox.ButtonBoxChild w14 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w13[this.buttonConvert]));
-+ w14.Expand = false;
-+ w14.Fill = false;
-+ if ((this.Child != null)) {
-+ this.Child.ShowAll ();
-+ }
-+ this.DefaultWidth = 532;
-+ this.DefaultHeight = 292;
-+ this.Show ();
-+ }
-+ }
-+}
-Index: gtk-gui/ChangeLog
-===================================================================
---- gtk-gui/ChangeLog (revision 0)
-+++ gtk-gui/ChangeLog (revision 124)
-@@ -0,0 +1,46 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * gui.stetic:
-+ * MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs:
-+
-+2010-08-13 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * gui.stetic:
-+
-+2010-08-09 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * gui.stetic:
-+
-+2010-08-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * gui.stetic:
-+
-+2010-08-05 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * gui.stetic:
-+
-+2010-08-04 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * gui.stetic:
-+
-+2010-08-03 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * gui.stetic:
-+
-+2010-07-05 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * gui.stetic:
-+
-+2010-06-23 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * gui.stetic:
-+ * MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs:
-+
-+2010-06-16 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * gui.stetic:
-+
-+2010-06-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * gui.stetic:
-+
-Index: gtk-gui/gui.stetic
-===================================================================
---- gtk-gui/gui.stetic (revision 17)
-+++ gtk-gui/gui.stetic (working copy)
-@@ -8,10 +8,11 @@
- <widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <widget-library name="../../../../build/bin/MonoDevelop.Ide.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll" />
-- <widget-library name="../../../../build/AddIns/MonoDevelop.Deployment/MonoDevelop.Deployment.dll" />
- <widget-library name="../../../../build/bin/Mono.TextEditor.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.GtkCore2/libsteticui2.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.GtkCore2/libstetic2.dll" />
-+ <widget-library name="MonoDevelop.Ide, Version=2.4.0.0, Culture=neutral" />
-+ <widget-library name="Mono.TextEditor, Version=1.0.0.0, Culture=neutral" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.dll" internal="true" />
- </import>
- <widget class="Gtk.Bin" id="MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget" design-size="503 22">
-@@ -40,4 +41,190 @@
- </widget>
- </child>
- </widget>
-+ <widget class="Gtk.Dialog" id="MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog" design-size="532 308">
-+ <property name="MemberName" />
-+ <property name="Title" translatable="yes">Project Name</property>
-+ <property name="WindowPosition">CenterOnParent</property>
-+ <property name="Modal">True</property>
-+ <property name="SkipTaskbarHint">True</property>
-+ <property name="Buttons">1</property>
-+ <property name="HelpButton">False</property>
-+ <child internal-child="VBox">
-+ <widget class="Gtk.VBox" id="dialog1_VBox">
-+ <property name="MemberName" />
-+ <property name="BorderWidth">2</property>
-+ <child>
-+ <widget class="Gtk.HBox" id="hbox">
-+ <property name="MemberName" />
-+ <property name="Spacing">6</property>
-+ <child>
-+ <widget class="Gtk.Alignment" id="alignmentLogo">
-+ <property name="MemberName" />
-+ <property name="Yscale">0</property>
-+ <property name="Xalign">1</property>
-+ <property name="Yalign">0.15</property>
-+ <child>
-+ <widget class="Gtk.Image" id="imageLogo">
-+ <property name="MemberName" />
-+ <property name="WidthRequest">180</property>
-+ <property name="Yalign">0</property>
-+ <property name="Pixbuf">resource:gtk-logo.png</property>
-+ </widget>
-+ </child>
-+ </widget>
-+ <packing>
-+ <property name="Position">0</property>
-+ <property name="AutoSize">True</property>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ <child>
-+ <widget class="Gtk.VBox" id="vbox2">
-+ <property name="MemberName" />
-+ <property name="Spacing">6</property>
-+ <child>
-+ <widget class="Gtk.Label" id="labelProject">
-+ <property name="MemberName" />
-+ <property name="LabelProp" translatable="yes">&lt;b&gt;&lt;big&gt;GTK# Project Conversion&lt;/big&gt;&lt;/b&gt;</property>
-+ <property name="UseMarkup">True</property>
-+ </widget>
-+ <packing>
-+ <property name="Position">0</property>
-+ <property name="AutoSize">True</property>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ <child>
-+ <widget class="Gtk.Label" id="labelInfo">
-+ <property name="MemberName" />
-+ <property name="Xalign">0</property>
-+ <property name="Yalign">0</property>
-+ <property name="LabelProp" translatable="yes">This project has been created in the previous
-+version of GTK# addin and must be converted.
-+
-+&lt;b&gt;Following changes will be made :&lt;/b&gt;
-+ - split gui.stetic into separate .gtkx files
-+ - split generated.cs into separate helper classes
-+ - remove gtk-gui folder.
-+ - create a designer folder for stock icons
-+ and generated helper classes.</property>
-+ <property name="UseMarkup">True</property>
-+ <property name="Wrap">True</property>
-+ </widget>
-+ <packing>
-+ <property name="Position">1</property>
-+ <property name="AutoSize">True</property>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ <child>
-+ <widget class="Gtk.HSeparator" id="hseparator1">
-+ <property name="MemberName" />
-+ </widget>
-+ <packing>
-+ <property name="Position">2</property>
-+ <property name="AutoSize">True</property>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ <child>
-+ <widget class="Gtk.HBox" id="hbox1">
-+ <property name="MemberName" />
-+ <property name="Spacing">6</property>
-+ <child>
-+ <widget class="Gtk.Label" id="labelFolder">
-+ <property name="MemberName" />
-+ <property name="LabelProp" translatable="yes">Designer folder name:</property>
-+ </widget>
-+ <packing>
-+ <property name="Position">0</property>
-+ <property name="AutoSize">True</property>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ <child>
-+ <widget class="Gtk.Entry" id="entryFolder">
-+ <property name="MemberName" />
-+ <property name="CanFocus">True</property>
-+ <property name="IsEditable">True</property>
-+ <property name="InvisibleChar">●</property>
-+ </widget>
-+ <packing>
-+ <property name="Position">1</property>
-+ <property name="AutoSize">True</property>
-+ </packing>
-+ </child>
-+ </widget>
-+ <packing>
-+ <property name="Position">3</property>
-+ <property name="AutoSize">True</property>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ <child>
-+ <widget class="Gtk.CheckButton" id="checkBackup">
-+ <property name="MemberName" />
-+ <property name="CanFocus">True</property>
-+ <property name="Label" translatable="yes">Make a backup before converting</property>
-+ <property name="Active">True</property>
-+ <property name="DrawIndicator">True</property>
-+ <property name="HasLabel">True</property>
-+ <property name="UseUnderline">True</property>
-+ </widget>
-+ <packing>
-+ <property name="Position">4</property>
-+ <property name="AutoSize">True</property>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ </widget>
-+ <packing>
-+ <property name="Position">1</property>
-+ <property name="AutoSize">True</property>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ </widget>
-+ <packing>
-+ <property name="Position">0</property>
-+ <property name="AutoSize">True</property>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ </widget>
-+ </child>
-+ <child internal-child="ActionArea">
-+ <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
-+ <property name="MemberName" />
-+ <property name="Spacing">10</property>
-+ <property name="BorderWidth">5</property>
-+ <property name="Size">1</property>
-+ <property name="LayoutStyle">End</property>
-+ <child>
-+ <widget class="Gtk.Button" id="buttonConvert">
-+ <property name="MemberName" />
-+ <property name="CanDefault">True</property>
-+ <property name="CanFocus">True</property>
-+ <property name="Type">TextOnly</property>
-+ <property name="Label" translatable="yes">_Convert</property>
-+ <property name="UseUnderline">True</property>
-+ <property name="ResponseId">-5</property>
-+ </widget>
-+ <packing>
-+ <property name="Expand">False</property>
-+ <property name="Fill">False</property>
-+ </packing>
-+ </child>
-+ </widget>
-+ </child>
-+ </widget>
- </stetic-interface>
-\ No newline at end of file
-Index: Makefile.am
-===================================================================
---- Makefile.am (revision 17)
-+++ Makefile.am (working copy)
-@@ -1,14 +1,13 @@
- SUBDIRS = libstetic libsteticui
-
--ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.GtkCore
--ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.GtkCore.dll
-+ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.GtkCore2
-+ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.GtkCore2.dll
-
- DEPS = \
- $(top_builddir)/build/AddIns/MonoDevelop.Deployment/MonoDevelop.Deployment.dll \
- $(top_builddir)/build/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll \
- $(top_builddir)/build/AddIns/MonoDevelop.GtkCore2/libstetic2.dll \
- $(top_builddir)/build/AddIns/MonoDevelop.GtkCore2/libsteticui2.dll \
-- $(top_builddir)/build/bin/Mono.Cecil.dll \
- $(top_builddir)/build/bin/Mono.TextEditor.dll \
- $(top_builddir)/build/bin/MonoDevelop.Core.dll \
- $(top_builddir)/build/bin/MonoDevelop.Ide.dll
-@@ -18,19 +17,23 @@
- $(GLIB_SHARP_LIBS) \
- $(GTK_SHARP_LIBS) \
- $(MONO_ADDINS_LIBS) \
-+ -pkg:monodevelop \
- -r:Mono.Posix \
- -r:System \
-+ -r:System.Core \
- -r:System.Xml
-
- FILES = \
- AssemblyInfo.cs \
- gtk-gui/generated.cs \
- gtk-gui/MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.cs \
-+ gtk-gui/MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs \
- MonoDevelop.GtkCore.Commands/GladeCommands.cs \
- MonoDevelop.GtkCore.Dialogs/BindDesignDialog.cs \
- MonoDevelop.GtkCore.Dialogs/ConfirmWindowDeleteDialog.cs \
- MonoDevelop.GtkCore.Dialogs/GtkDesignerOptionsPanelWidget.cs \
- MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs \
-+ MonoDevelop.GtkCore.Dialogs/ProjectConversionDialog.cs \
- MonoDevelop.GtkCore.Dialogs/SelectRenamedClassDialog.cs \
- MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs \
- MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs \
-@@ -48,11 +51,13 @@
- MonoDevelop.GtkCore.GuiBuilder/PropertiesWidget.cs \
- MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs \
- MonoDevelop.GtkCore.GuiBuilder/ToolboxProvider.cs \
-- MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs \
-+ MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolder.cs \
-+ MonoDevelop.GtkCore.NodeBuilders/GuiProjectFolderNodeBuilder.cs \
-+ MonoDevelop.GtkCore.NodeBuilders/ProjectFileExtension.cs \
-+ MonoDevelop.GtkCore.NodeBuilders/ProjectFileNodeBuilderExtension.cs \
- MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs \
- MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs \
- MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs \
-- MonoDevelop.GtkCore.NodeBuilders/WidgetNodeBuilder.cs \
- MonoDevelop.GtkCore.NodeBuilders/WindowsFolder.cs \
- MonoDevelop.GtkCore.NodeBuilders/WindowsFolderNodeBuilder.cs \
- MonoDevelop.GtkCore/Counters.cs \
-@@ -68,6 +73,8 @@
- gtk-gui/gui.stetic \
- gui.glade \
- icons/actiongroup.png \
-+ icons/gtk-logo.png \
-+ icons/gtkx.png \
- icons/image-x-generic.png \
- icons/widget.png \
- MonoDevelop.GtkCore.addin.xml \
-@@ -99,7 +106,7 @@
- $(CSC) $(CSC_FLAGS) -debug -out:$@ -target:library \
- $(build_resources:%=/resource:%) $(build_sources) $(REFS) $(build_deps)
-
--assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.GtkCore
-+assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.GtkCore2
- assembly_DATA = $(ASSEMBLY) $(ASSEMBLY).mdb
-
- CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb
-Index: icons/gtkx.png
-===================================================================
-Cannot display: file marked as a binary type.
-svn:mime-type = application/octet-stream
-
-Property changes on: icons/gtkx.png
-___________________________________________________________________
-Added: svn:mime-type
- + application/octet-stream
-
-Index: icons/gtk-logo.png
-===================================================================
-Cannot display: file marked as a binary type.
-svn:mime-type = application/octet-stream
-
-Property changes on: icons/gtk-logo.png
-___________________________________________________________________
-Added: svn:mime-type
- + application/octet-stream
-
-Index: icons/ChangeLog
-===================================================================
---- icons/ChangeLog (revision 0)
-+++ icons/ChangeLog (revision 124)
-@@ -0,0 +1,5 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * gtkx.png:
-+ * gtk-logo.png:
-+
-Index: MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs (revision 17)
-+++ MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs (working copy)
-@@ -53,12 +53,17 @@
- {
- if (excludeThis)
- return false;
-+
-+ if (fileName.Contains ("generated"))
-+ return false;
-+
- if (!IdeApp.Workspace.IsOpen)
- return false;
-
- if (GetActionGroup (fileName) == null)
- return false;
-
-+
- excludeThis = true;
- var db = DisplayBindingService.GetDefaultBindingForUri (fileName);
- excludeThis = false;
-@@ -171,7 +176,7 @@
- IdeApp.ProjectOperations.Save (project);
-
- // Make sure the database is up-to-date
-- ProjectDomService.Parse (project, cls.CompilationUnit.FileName, null);
-+ ProjectDomService.Parse (project, cls.CompilationUnit.FileName);
- return cls;
- }
-
-Index: MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs (revision 17)
-+++ MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs (working copy)
-@@ -34,6 +34,7 @@
-
- using MonoDevelop.Ide.Gui;
- using MonoDevelop.Projects;
-+using MonoDevelop.Projects.Dom;
- using MonoDevelop.Projects.Dom.Parser;
- using MonoDevelop.Projects.Text;
- using MonoDevelop.Core;
-@@ -257,12 +258,21 @@
-
- public static string GetBuildCodeFileName (Project project, string componentName)
- {
-+ return GetBuildCodeFileName (project, componentName, string.Empty);
-+ }
-+
-+ public static string GetBuildCodeFileName (Project project, string componentName, string nameSpace)
-+ {
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
--// var type=info.GuiBuilderProject.FindClass(componentName);
-- var folder = info.GtkGuiFolder;
-+ string componentFile = info.GetComponentFile (componentName);
-
--// folder=type.CompilationUnit.FileName.ParentDirectory;
-- return Path.Combine (folder, componentName + Path.GetExtension (info.SteticGeneratedFile));
-+ if (componentFile == null) {
-+ if (nameSpace == "Stetic") {
-+ return info.GetBuildFileInSteticFolder (componentName);
-+ } else
-+ throw new UserException ("Cannot find component file for " + componentName);
-+ } else
-+ return info.GetBuildFile (componentFile);
- }
-
- public static string GenerateSteticCodeStructure (DotNetProject project, Stetic.ProjectItemInfo item, bool saveToFile, bool overwrite)
-@@ -351,13 +361,12 @@
- FileService.NotifyFileChanged (fileName);
- }
- else
-- ProjectDomService.Parse (project, fileName, "", ((StringWriter)fileStream).ToString ());
-+ ProjectDomService.Parse (project, fileName, ((StringWriter)fileStream).ToString ());
- }
-
- return fileName;
- }
-
--
- public static Stetic.CodeGenerationResult GenerateSteticCode (IProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration)
- {
- if (generating || !GtkDesignInfo.HasDesignedObjects (project))
-@@ -382,8 +391,8 @@
- }
-
- // Check if generated code is already up to date.
-- if (!ref_changed && last_gen_time >= File.GetLastWriteTime (info.SteticFile))
-- return null;
-+// if (!ref_changed && last_gen_time >= File.GetLastWriteTime (info.SteticFile))
-+// return null;
-
- if (info.GuiBuilderProject.HasError) {
- monitor.ReportError (GettextCatalog.GetString ("GUI code generation failed for project '{0}'. The file '{1}' could not be loaded.", project.Name, info.SteticFile), null);
-@@ -402,8 +411,8 @@
-
- info.GuiBuilderProject.UpdateLibraries ();
-
-- ArrayList projects = new ArrayList ();
-- projects.Add (info.GuiBuilderProject.File);
-+ ArrayList projectFolders = new ArrayList ();
-+ projectFolders.Add (info.SteticFolder.FullPath);
-
- generating = true;
- Stetic.CodeGenerationResult generationResult = null;
-@@ -418,7 +427,7 @@
- // Generate the code in another process if stetic is not isolated
- CodeGeneratorProcess cob = (CodeGeneratorProcess) Runtime.ProcessService.CreateExternalProcessObject (typeof (CodeGeneratorProcess), false);
- using (cob) {
-- generationResult = cob.GenerateCode (projects, info.GenerateGettext, info.GettextClass, project.UsePartialTypes, info);
-+ generationResult = cob.GenerateCode (projectFolders, info.GenerateGettext, info.GettextClass, project.UsePartialTypes, info);
- }
- } catch (Exception ex) {
- generatedException = ex;
-@@ -438,8 +447,6 @@
- Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
- options.UseGettext = info.GenerateGettext;
- options.GettextClass = info.GettextClass;
-- options.UsePartialClasses = project.UsePartialTypes;
-- options.GenerateSingleFile = false;
- generationResult = SteticApp.GenerateProjectCode (options, info.GuiBuilderProject.SteticProject);
- } catch (Exception ex) {
- generatedException = ex;
-@@ -448,8 +455,23 @@
- }
-
- if (generatedException != null) {
-- LoggingService.LogError ("GUI code generation failed", generatedException);
-- throw new UserException ("GUI code generation failed: " + generatedException.Message);
-+ string msg = string.Empty;
-+
-+ if (generatedException.InnerException != null) {
-+ msg = string.Format("{0}\n{1}\nInner Exception {2}\n{3}",
-+ generatedException.Message,
-+ generatedException.StackTrace,
-+ generatedException.InnerException.Message,
-+ generatedException.InnerException.StackTrace);
-+ } else {
-+ msg = string.Format("{0}\n{1}",
-+ generatedException.Message,
-+ generatedException.StackTrace);
-+ }
-+
-+// LoggingService.LogError ("GUI code generation failed", generatedException);
-+ LoggingService.LogError ("GUI code generation failed: " + msg);
-+ throw new UserException ("GUI code generation failed: " + msg);
- }
-
- if (generationResult == null)
-@@ -459,15 +481,15 @@
- if (provider == null)
- throw new UserException ("Code generation not supported for language: " + project.LanguageName);
-
-- string basePath = Path.GetDirectoryName (info.SteticGeneratedFile);
-- string ext = Path.GetExtension (info.SteticGeneratedFile);
--
- foreach (Stetic.SteticCompilationUnit unit in generationResult.Units) {
- string fname;
- if (unit.Name.Length == 0)
- fname = info.SteticGeneratedFile;
- else
-- fname = Path.Combine (basePath, unit.Name) + ext;
-+ fname = GetBuildCodeFileName (project,
-+ unit.Name,
-+ (unit.Namespace != null) ? unit.Namespace.Name : string.Empty);
-+
- StringWriter sw = new StringWriter ();
- try {
- foreach (CodeNamespace ns in unit.Namespaces)
-@@ -476,6 +498,12 @@
- string content = sw.ToString ();
- content = FormatGeneratedFile (fname, content, provider);
- File.WriteAllText (fname, content);
-+// if (File.Exists (fname)) {
-+// FileInfo file = new FileInfo (fname);
-+// DateTime now = DateTime.Now;
-+// file.LastWriteTime = now;
-+// file.LastWriteTimeUtc = now;
-+// }
- } finally {
- FileService.NotifyFileChanged (fname);
- }
-@@ -580,23 +608,21 @@
-
- public class CodeGeneratorProcess: RemoteProcessObject
- {
-- public Stetic.CodeGenerationResult GenerateCode (ArrayList projectFiles, bool useGettext, string gettextClass, bool usePartialClasses, GtkDesignInfo info)
-+ public Stetic.CodeGenerationResult GenerateCode (ArrayList projectFolders, bool useGettext, string gettextClass, bool usePartialClasses, GtkDesignInfo info)
- {
- Gtk.Application.Init ();
-
- Stetic.Application app = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None);
-
-- Stetic.Project[] projects = new Stetic.Project [projectFiles.Count];
-- for (int n=0; n < projectFiles.Count; n++) {
-+ Stetic.Project[] projects = new Stetic.Project [projectFolders.Count];
-+ for (int n=0; n < projectFolders.Count; n++) {
- projects [n] = app.CreateProject (info);
-- projects [n].Load ((string) projectFiles [n]);
-+ projects [n].Load ((string) projectFolders [n]);
- }
-
- Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
- options.UseGettext = useGettext;
- options.GettextClass = gettextClass;
-- options.UsePartialClasses = usePartialClasses;
-- options.GenerateSingleFile = false;
-
- return app.GenerateProjectCode (options, projects);
- }
-Index: MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDisplayBinding.cs
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDisplayBinding.cs (revision 17)
-+++ MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDisplayBinding.cs (working copy)
-@@ -46,6 +46,9 @@
- {
- if (excludeThis) return false;
-
-+ if (fileName.Contains ("generated"))
-+ return false;
-+
- if (GetWindow (fileName) == null)
- return false;
-
-@@ -81,7 +84,7 @@
- return null;
-
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-- if (file.StartsWith (info.GtkGuiFolder))
-+ if (file.StartsWith (info.SteticFolder))
- return null;
-
- ParsedDocument doc = ProjectDomService.GetParsedDocument (null, file);
-Index: MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs (revision 17)
-+++ MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs (working copy)
-@@ -44,12 +44,15 @@
- {
- public class GuiBuilderProject
- {
-+ //to save temporarily GuiBuilderWindow while files are being moved between projects
-+ static List<GuiBuilderWindow> formInfosRemoved;
-+
- internal object MemoryProbe = Counters.GuiProjectsInMemory.CreateMemoryProbe ();
-
- List<GuiBuilderWindow> formInfos;
- Stetic.Project gproject;
- DotNetProject project;
-- string fileName;
-+ string folderName;
- bool hasError;
- bool needsUpdate = true;
-
-@@ -64,38 +67,87 @@
- public event EventHandler Reloaded;
- public event EventHandler Unloaded;
- public event EventHandler Changed;
-+
-+ static GuiBuilderProject ()
-+ {
-+ formInfosRemoved = new List<GuiBuilderWindow> ();
-+ }
-
-- public GuiBuilderProject (DotNetProject project, string fileName)
-+ public GuiBuilderProject (DotNetProject project, string folderName)
- {
-- this.fileName = fileName;
-+ this.folderName = folderName;
- this.project = project;
- Counters.GuiProjectsLoaded++;
- }
-
-+ public void Convert (string guiFolderName, bool makeBackup)
-+ {
-+ GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-+ Stetic.Project gproject = GuiBuilderService.SteticApp.CreateProject (info);
-+ //Stetic.Project does not implement IDisposable
-+ try {
-+ string newGuiFolderName = project.BaseDirectory.Combine (guiFolderName);
-+ gproject.ConvertProject (info.SteticFile, newGuiFolderName);
-+ info.ConvertGtkFolder (guiFolderName, makeBackup);
-+ info.UpdateGtkFolder ();
-+ folderName = newGuiFolderName;
-+ IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor ();
-+ try {
-+ ConfigurationSelector configuration = IdeApp.Workspace.ActiveConfiguration;
-+ Generator generator = new Generator ();
-+ generator.Run (monitor, project, configuration);
-+ monitor.ReportSuccess ("Converting was succesfull");
-+ } finally {
-+ monitor.Dispose ();
-+ }
-+ } finally {
-+ gproject.Dispose ();
-+ }
-+ }
-+
-+ public void GenerateCode (string componentFile)
-+ {
-+ GtkDesignInfo info = GtkDesignInfo.FromProject (project);
-+ string gtkxFile = info.GetGtkxFile (componentFile);
-+ if (gtkxFile != null && File.Exists (gtkxFile)) {
-+
-+ Save (false);
-+ FileInfo fi = new FileInfo (gtkxFile);
-+ fi.LastWriteTime = DateTime.Now;
-+
-+ IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor ();
-+ try {
-+ ConfigurationSelector configuration = IdeApp.Workspace.ActiveConfiguration;
-+ Generator generator = new Generator ();
-+ generator.Run (monitor, project, configuration);
-+ } finally {
-+ monitor.Dispose ();
-+ }
-+ }
-+ }
-+
- void Load ()
- {
-- if (gproject != null || disposed || fileName == null)
-+ if (gproject != null || disposed || folderName == null)
- return;
-
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- gproject = GuiBuilderService.SteticApp.CreateProject (info);
- formInfos = new List<GuiBuilderWindow> ();
--
-- if (!System.IO.File.Exists (fileName)) {
-- // Regenerate the gtk-gui folder if the stetic project
-- // doesn't exist.
-- info.UpdateGtkFolder ();
-- }
-+
-+// TODO : when expanding project, UpdateGtkFolder causes in throwing exception by gtk
-+// info.UpdateGtkFolder ();
-
- try {
-- gproject.Load (fileName);
-+ gproject.Load (folderName);
- } catch (Exception ex) {
-- MessageService.ShowException (ex, GettextCatalog.GetString ("The GUI designer project file '{0}' could not be loaded.", fileName));
-+ MessageService.ShowException (ex, GettextCatalog.GetString ("The GUI designer project folder '{0}' could not be loaded.", folderName));
- hasError = true;
- }
-
- Counters.SteticProjectsLoaded++;
- gproject.ResourceProvider = GtkDesignInfo.FromProject (project).ResourceProvider;
-+// gproject.DesignInfo = info;
- gproject.WidgetAdded += OnAddWidget;
- gproject.WidgetRemoved += OnRemoveWidget;
- gproject.ActionGroupsChanged += OnGroupsChanged;
-@@ -108,14 +160,14 @@
- RegisterWindow (ob, false);
-
- // Monitor changes in the file
-- lastSaveTime = System.IO.File.GetLastWriteTime (fileName);
-- watcher = new FileSystemWatcher ();
-- if (System.IO.File.Exists (fileName)) {
-- watcher.Path = Path.GetDirectoryName (fileName);
-- watcher.Filter = Path.GetFileName (fileName);
-- watcher.Changed += (FileSystemEventHandler) DispatchService.GuiDispatch (new FileSystemEventHandler (OnSteticFileChanged));
-- watcher.EnableRaisingEvents = true;
-- }
-+// lastSaveTime = System.IO.File.GetLastWriteTime (fileName);
-+// watcher = new FileSystemWatcher ();
-+// if (System.IO.File.Exists (fileName)) {
-+// watcher.Path = Path.GetDirectoryName (fileName);
-+// watcher.Filter = Path.GetFileName (fileName);
-+// watcher.Changed += (FileSystemEventHandler) DispatchService.GuiDispatch (new FileSystemEventHandler (OnSteticFileChanged));
-+// watcher.EnableRaisingEvents = true;
-+// }
- }
-
- void Unload ()
-@@ -158,7 +210,7 @@
- void OnSteticFileChanged (object s, FileSystemEventArgs args)
- {
- lock (fileSaveLock) {
-- if (lastSaveTime == System.IO.File.GetLastWriteTime (fileName))
-+ if (lastSaveTime == System.IO.File.GetLastWriteTime (folderName))
- return;
- }
-
-@@ -198,8 +250,8 @@
-
- if (gproject != null && !hasError) {
- lock (fileSaveLock) {
-- gproject.Save (fileName);
-- lastSaveTime = System.IO.File.GetLastWriteTime (fileName);
-+ gproject.Save (folderName);
-+ lastSaveTime = System.IO.File.GetLastWriteTime (folderName);
- }
- }
-
-@@ -207,14 +259,11 @@
- IdeApp.ProjectOperations.Save (project);
- }
-
-- public string File {
-- get { return fileName; }
-- }
--
- public Stetic.Project SteticProject {
- get {
- Load ();
- return gproject;
-+
- }
- }
-
-@@ -256,6 +305,16 @@
- RegisterWindow (c, true);
- return c;
- }
-+
-+ public void AddNewComponent (string fileName)
-+ {
-+ object ob = SteticProject.AddNewComponent (fileName);
-+
-+ if (ob is Stetic.WidgetInfo) {
-+ var c = (Stetic.WidgetInfo) ob;
-+ RegisterWindow (c, true);
-+ }
-+ }
-
- void RegisterWindow (Stetic.WidgetInfo widget, bool notify)
- {
-@@ -266,6 +325,16 @@
-
- GuiBuilderWindow win = new GuiBuilderWindow (this, gproject, widget);
- formInfos.Add (win);
-+
-+ GuiBuilderWindow winToRemove = null;
-+ foreach (GuiBuilderWindow form in formInfosRemoved)
-+ if (form.RootWidget == widget) {
-+ winToRemove = form;
-+ break;
-+ }
-+
-+ if (winToRemove != null)
-+ formInfosRemoved.Remove (winToRemove);
-
- if (notify) {
- if (WindowAdded != null)
-@@ -281,6 +350,7 @@
- return;
-
- formInfos.Remove (win);
-+ formInfosRemoved.Add (win);
-
- if (WindowRemoved != null)
- WindowRemoved (this, new WindowEventArgs (win));
-@@ -319,30 +389,18 @@
- }
-
- void OnFileAdded (object sender, ProjectFileEventArgs args)
-- {
-+ {
-+ FilePath path = args.ProjectFile.FilePath;
-
-- ParsedDocument doc = ProjectDomService.GetParsedDocument (ProjectDomService.GetProjectDom (args.Project), args.ProjectFile.Name);
-- if (doc == null || doc.CompilationUnit == null)
-- return;
--
-- string dir = Path.Combine (Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "stetic"), "deleted-designs");
-- if (!Directory.Exists (dir) || Directory.GetFiles (dir).Length == 0)
-- return;
--
-- foreach (IType t in doc.CompilationUnit.Types) {
-- string path = Path.Combine (dir, t.FullName + ".xml");
-- if (!System.IO.File.Exists (path))
-- continue;
-- XmlDocument xmldoc = new XmlDocument ();
-- xmldoc.Load (path);
-- AddNewComponent (xmldoc.DocumentElement);
-- System.IO.File.Delete (path);
-+ if (path.Extension == ".gtkx") {
-+ AddNewComponent (path);
- }
- }
-
- void OnFileRemoved (object sender, ProjectFileEventArgs args)
- {
- ArrayList toDelete = new ArrayList ();
-+ ArrayList toDeleteGroups = new ArrayList ();
-
- ParsedDocument doc = ProjectDomService.GetParsedDocument (ProjectDomService.GetProjectDom (args.Project), args.ProjectFile.Name);
- if (doc == null || doc.CompilationUnit == null)
-@@ -350,12 +408,22 @@
-
- foreach (IType t in doc.CompilationUnit.Types) {
- GuiBuilderWindow win = GetWindowForClass (t.FullName);
-- if (win != null)
-+ if (win != null) {
- toDelete.Add (win);
-+ continue;
-+ }
-+
-+ Stetic.ActionGroupInfo group = GetActionGroup (t.FullName);
-+ if (group != null) {
-+ toDeleteGroups.Add (group);
-+ }
- }
--
-+
- foreach (GuiBuilderWindow win in toDelete)
- Remove (win);
-+
-+ foreach (Stetic.ActionGroupInfo group in toDeleteGroups)
-+ RemoveActionGroup (group);
- }
-
- void OnGroupsChanged (object s, EventArgs a)
-@@ -424,6 +492,13 @@
- return form;
- }
- }
-+
-+ if (formInfosRemoved != null) {
-+ foreach (GuiBuilderWindow form in formInfosRemoved) {
-+ if (CodeBinder.GetObjectName (form.RootWidget) == className)
-+ return form;
-+ }
-+ }
- return null;
- }
-
-@@ -460,7 +535,7 @@
-
- public Stetic.ActionGroupInfo GetActionGroup (string name)
- {
-- return SteticProject.GetActionGroup (name);
-+ return (SteticProject != null) ? SteticProject.GetActionGroup (name) : null;
- }
-
- public FilePath GetSourceCodeFile (Stetic.ProjectItemInfo obj)
-@@ -489,8 +564,9 @@
-
- public IType FindClass (string className, bool getUserClass)
- {
-- FilePath gui_folder = GtkDesignInfo.FromProject (project).GtkGuiFolder;
-+ FilePath gui_folder = GtkDesignInfo.FromProject (project).SteticFolder;
- ProjectDom ctx = GetParserContext ();
-+
- if (ctx == null)
- return null;
- IEnumerable<IType> classes = ctx.Types;
-@@ -502,7 +578,9 @@
- // Return this class only if it is declared outside the gtk-gui
- // folder. Generated partial classes will be ignored.
- foreach (IType part in cls.Parts) {
-- if (part.CompilationUnit != null && !part.CompilationUnit.FileName.IsNullOrEmpty && !part.CompilationUnit.FileName.IsChildPathOf (gui_folder)) {
-+ if (part.CompilationUnit.FileName.FullPath.IsChildPathOf (gui_folder))
-+ continue;
-+ if (part.CompilationUnit != null && !part.CompilationUnit.FileName.IsNullOrEmpty && !part.CompilationUnit.FileName.FileName.Contains ("generated")) {
- return part;
- }
- }
-@@ -557,8 +635,10 @@
-
- // Make sure the target gtk version is properly set
- if (gproject.TargetGtkVersion != target_version) {
-+ if (gproject.TargetGtkVersion != string.Empty) {
-+ needsSave = true;
-+ }
- gproject.TargetGtkVersion = target_version;
-- needsSave = true;
- }
-
- string outLib = project.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration);
-@@ -571,8 +651,11 @@
-
- // See if something has changed
- if (LibrariesChanged (oldLibs, internalLibs, newLibs)) {
-+ // If oldLibs is empty, gproject was uninitialized, so there are no changes to save
-+ if (oldLibs.Length > 0) {
-+ needsSave = true;
-+ }
- gproject.SetWidgetLibraries (newLibs, internalLibs);
-- needsSave = true;
- } else {
- GuiBuilderService.SteticApp.UpdateWidgetLibraries (false);
- }
-@@ -611,24 +694,30 @@
- return files;
-
- IDotNetLanguageBinding binding = LanguageBindingService.GetBindingPerLanguageName (project.LanguageName) as IDotNetLanguageBinding;
-- string path = Path.Combine (guiFolder, binding.GetFileName ("generated"));
-- if (!System.IO.File.Exists (path)) {
-- // Generate an empty build class
-- CodeDomProvider provider = binding.GetCodeDomProvider ();
-- if (provider == null)
-- throw new UserException ("Code generation not supported for language: " + project.LanguageName);
-- GuiBuilderService.SteticApp.GenerateProjectCode (path, "Stetic", provider, null);
-+ CodeDomProvider provider = binding.GetCodeDomProvider ();
-+
-+ if (provider == null)
-+ throw new UserException ("Code generation not supported for language: " + project.LanguageName);
-+// string path = Path.Combine (guiFolder, binding.GetFileName ("generated"));
-+// if (!System.IO.File.Exists (path)) {
-+// GuiBuilderService.SteticApp.GenerateProjectCode (path, "Stetic", provider, null);
-+// }
-+// files.Add (path);
-+//
-+// if (Windows != null) {
-+// foreach (GuiBuilderWindow win in Windows)
-+// files.Add (GuiBuilderService.GenerateSteticCodeStructure (project, win.RootWidget, true, false));
-+// }
-+//
-+// foreach (Stetic.ActionGroupInfo ag in SteticProject.ActionGroups)
-+// files.Add (GuiBuilderService.GenerateSteticCodeStructure (project, ag, true, false));
-+
-+ string extension = "generated." + provider.FileExtension;
-+ foreach (string file in Directory.GetFiles (guiFolder)) {
-+ if (file.Contains (extension))
-+ files.Add (file);
- }
-- files.Add (path);
-
-- if (Windows != null) {
-- foreach (GuiBuilderWindow win in Windows)
-- files.Add (GuiBuilderService.GenerateSteticCodeStructure (project, win.RootWidget, true, false));
-- }
--
-- foreach (Stetic.ActionGroupInfo ag in SteticProject.ActionGroups)
-- files.Add (GuiBuilderService.GenerateSteticCodeStructure (project, ag, true, false));
--
- return files;
- }
- }
-Index: MonoDevelop.GtkCore.GuiBuilder/ChangeLog
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/ChangeLog (revision 0)
-+++ MonoDevelop.GtkCore.GuiBuilder/ChangeLog (revision 125)
-@@ -0,0 +1,75 @@
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GuiBuilderProject.cs:
-+
-+2010-08-15 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GuiBuilderProject.cs:
-+ * GuiBuilderService.cs:
-+
-+2010-08-13 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GuiBuilderView.cs:
-+ * GuiBuilderProject.cs:
-+ * GuiBuilderService.cs:
-+ * GuiBuilderDisplayBinding.cs:
-+ * ActionGroupDisplayBinding.cs:
-+
-+2010-08-09 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GuiBuilderProject.cs: Generate stetic code after a project converting
-+ * GuiBuilderService.cs:
-+ * GuiBuilderDisplayBinding.cs: Don't use component display binding for
-+ generated partial files
-+
-+2010-08-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GuiBuilderView.cs: Raise OnDirtyChanged after saving.
-+ * CombinedDesignView.cs: Track Api Changes.
-+
-+2010-08-05 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * GuiBuilderView.cs: Remove ModifiedChanged handler
-+
-+2010-08-04 Krzysztof Marecki <freefirma@gmail.com>
-+
-+ * CodeBinder.cs: Bump Api
-+ * GuiBuilderWindow.cs:
-+ * GuiBuilderService.cs:
-+ * CombinedDesignView.cs:
-+ * ActionGroupDisplayBinding.cs:
-+
-+2010-08-03 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GuiBuilderProject.cs: When Updatinglibraries don't save
-+ if Stetic.Project was uninitialized
-+
-+2010-07-27 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GuiBuilderView.cs:
-+ * CombinedDesignView.cs:
-+
-+2010-07-06 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GuiBuilderProject.cs:
-+ * GuiBuilderService.cs:
-+
-+2010-07-05 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GuiBuilderProject.cs:
-+ * CombinedDesignView.cs:
-+
-+2010-06-23 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GuiBuilderProject.cs:
-+
-+2010-06-21 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GuiBuilderProject.cs: Add Convert method
-+
-+2010-06-07 Krzysztof Marecki <marecki.krzysztof@gmail.com>
-+
-+ * GuiBuilderProject.cs:
-+ * GuiBuilderService.cs:
-+ * GtkProjectServiceExtension.cs:
-+
-Index: MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs (revision 17)
-+++ MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs (working copy)
-@@ -203,7 +203,7 @@
- IdeApp.ProjectOperations.Save (Project.Project);
-
- // Make sure the database is up-to-date
-- ProjectDomService.Parse (Project.Project, cls.CompilationUnit.FileName, null);
-+ ProjectDomService.Parse (Project.Project, cls.CompilationUnit.FileName);
- }
-
- void AddSignalsRec (CodeTypeDeclaration type, Stetic.Component comp)
-Index: MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs (revision 17)
-+++ MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs (working copy)
-@@ -79,7 +79,7 @@
- {
- gproject = window.Project;
- GtkDesignInfo info = GtkDesignInfo.FromProject (gproject.Project);
-- gproject.SteticProject.ImagesRootPath = FileService.AbsoluteToRelativePath (info.GtkGuiFolder, gproject.Project.BaseDirectory);
-+ gproject.SteticProject.ImagesRootPath = FileService.AbsoluteToRelativePath (info.SteticFolder, gproject.Project.BaseDirectory);
- gproject.UpdateLibraries ();
- LoadDesigner ();
- }
-@@ -121,7 +121,7 @@
-
- gproject.Unloaded += OnDisposeProject;
-
-- designer = gproject.SteticProject.CreateWidgetDesigner (window.RootWidget, false);
-+ designer = gproject.SteticProject.CreateWidgetDesigner (window.RootWidget);
-
- // Designer page
- designerPage.ClearChild ();
-@@ -138,7 +138,7 @@
- codeBinder = new CodeBinder (gproject.Project, new OpenDocumentFileProvider (), designer.RootComponent);
-
- designer.BindField += OnBindWidgetField;
-- designer.ModifiedChanged += OnWindowModifiedChanged;
-+ designer.Changed += OnChanged;
- designer.SignalAdded += OnSignalAdded;
- designer.SignalRemoved += OnSignalRemoved;
- designer.SignalChanged += OnSignalChanged;
-@@ -194,7 +194,7 @@
-
- gproject.Unloaded -= OnDisposeProject;
- designer.BindField -= OnBindWidgetField;
-- designer.ModifiedChanged -= OnWindowModifiedChanged;
-+ designer.Changed -= OnChanged;
- designer.SignalAdded -= OnSignalAdded;
- designer.SignalRemoved -= OnSignalRemoved;
- designer.SignalChanged -= OnSignalChanged;
-@@ -292,7 +292,7 @@
- AddButton (GettextCatalog.GetString ("Actions"), actionsPage);
- }
-
-- void OnWindowModifiedChanged (object s, EventArgs args)
-+ void OnChanged (object s, EventArgs args)
- {
- if (IsDirty)
- OnContentChanged (args);
-@@ -351,6 +351,7 @@
- }
-
- gproject.Save (true);
-+ OnDirtyChanged (EventArgs.Empty);
- }
-
- public override bool IsDirty {
-Index: MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs (revision 17)
-+++ MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs (working copy)
-@@ -89,7 +89,7 @@
- if (targetObject == null)
- return;
-
-- ParsedDocument doc = ProjectDomService.Parse (project, fileName, null);
-+ ParsedDocument doc = ProjectDomService.Parse (project, fileName);
- classFile = fileName;
-
- if (doc != null && doc.CompilationUnit != null) {
-@@ -266,7 +266,7 @@
- ArrayList matches = new ArrayList ();
- ICompilationUnit unit = null;
- ProjectDom ctx = gproject.GetParserContext ();
-- ParsedDocument doc = ProjectDomService.Parse (project, classFile, null);
-+ ParsedDocument doc = ProjectDomService.Parse (project, classFile);
- if (doc != null && doc.CompilationUnit != null) {
- unit = doc.CompilationUnit;
- foreach (IType fcls in unit.Types) {
-Index: MonoDevelop.GtkCore.GuiBuilder/CombinedDesignView.cs
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/CombinedDesignView.cs (revision 17)
-+++ MonoDevelop.GtkCore.GuiBuilder/CombinedDesignView.cs (working copy)
-@@ -200,6 +200,7 @@
-
- public override void Load (string fileName)
- {
-+ ShowPage (1);
- ContentName = fileName;
- content.Load (fileName);
- }
-@@ -257,7 +258,9 @@
- {
- }
-
-- public override object GetContent (Type type)
-+// public override object GetContent (Type type)
-+// public override T GetContent<T> ()
-+ public override T GetContent<T> ()
- {
- // if (type == typeof(IEditableTextBuffer)) {
- // // Intercept the IPositionable interface, since we need to
-@@ -268,18 +271,12 @@
- // return null;
- // }
- //
-- object ob = base.GetContent (type);
-- if (ob != null)
-- return ob;
-- else if (content != null)
-- return content.GetContent (type);
-- else
-- return null;
-+ return base.GetContent<T> () ?? content.GetContent<T> ();
- }
-
- public void JumpTo (int line, int column)
- {
-- IEditableTextBuffer ip = (IEditableTextBuffer) content.GetContent (typeof(IEditableTextBuffer));
-+ IEditableTextBuffer ip = (IEditableTextBuffer) content.GetContent<IEditableTextBuffer> ();
- if (ip != null) {
- ShowPage (0);
- ip.SetCaretTo (line, column);
-Index: MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs
-===================================================================
---- MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs (revision 17)
-+++ MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs (working copy)
-@@ -35,7 +35,9 @@
-
- if (gen.Messages != null) {
- foreach (string s in gen.Messages)
-- res.AddWarning (info.GuiBuilderProject.File, 0, 0, null, s);
-+// res.AddWarning (info.GuiBuilderProject.File, 0, 0, null, s);
-+// TODO: Add gtkx file name in the Generator
-+ res.AddWarning ("", 0, 0, null, s);
-
- if (gen.Messages.Length > 0)
- info.ForceCodeGenerationOnBuild ();
diff --git a/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.cs b/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.cs
deleted file mode 100644
index 0af9212faa..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-
-// This file has been generated by the GUI designer. Do not modify.
-namespace MonoDevelop.GtkCore.Dialogs
-{
- public partial class GtkDesignerOptionsPanelWidget
- {
- private global::Gtk.VBox vbox2;
-
- private global::Gtk.CheckButton checkSwitchLayout;
-
- protected virtual void Build ()
- {
- global::Stetic.Gui.Initialize (this);
- // Widget MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget
- global::Stetic.BinContainer.Attach (this);
- this.Name = "MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget";
- // Container child MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget.Gtk.Container+ContainerChild
- this.vbox2 = new global::Gtk.VBox ();
- this.vbox2.Name = "vbox2";
- this.vbox2.Spacing = 6;
- // Container child vbox2.Gtk.Box+BoxChild
- this.checkSwitchLayout = new global::Gtk.CheckButton ();
- this.checkSwitchLayout.CanFocus = true;
- this.checkSwitchLayout.Name = "checkSwitchLayout";
- this.checkSwitchLayout.Label = global::Mono.Unix.Catalog.GetString ("Automatically switch to the \"GUI Builder\" layout when opening the designer");
- this.checkSwitchLayout.DrawIndicator = true;
- this.checkSwitchLayout.UseUnderline = true;
- this.vbox2.Add (this.checkSwitchLayout);
- global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.checkSwitchLayout]));
- w1.Position = 0;
- w1.Expand = false;
- w1.Fill = false;
- this.Add (this.vbox2);
- if ((this.Child != null)) {
- this.Child.ShowAll ();
- }
- this.Hide ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs
deleted file mode 100644
index b7650fd16e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.cs
+++ /dev/null
@@ -1,183 +0,0 @@
-// ------------------------------------------------------------------------------
-// <autogenerated>
-// This code was generated by a tool.
-// Mono Runtime Version: 2.0.50727.1433
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </autogenerated>
-// ------------------------------------------------------------------------------
-
-
-// This file has been generated by the GUI designer. Do not modify.
-namespace MonoDevelop.GtkCore.Dialogs
-{
- public partial class ProjectConversionDialog
- {
- private global::Gtk.HBox hbox;
-
- private global::Gtk.Alignment alignmentLogo;
-
- private global::Gtk.Image imageLogo;
-
- private global::Gtk.VBox vbox2;
-
- private global::Gtk.Label labelProject;
-
- private global::Gtk.Label labelInfo;
-
- private global::Gtk.HSeparator hseparator1;
-
- private global::Gtk.HBox hbox1;
-
- private global::Gtk.Label labelFolder;
-
- private global::Gtk.Entry entryFolder;
-
- private global::Gtk.CheckButton checkBackup;
-
- private global::Gtk.Button buttonConvert;
-
- protected virtual void Build ()
- {
- global::Stetic.Gui.Initialize (this);
- // Widget MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog
- this.Name = "MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog";
- this.Title = global::Mono.Unix.Catalog.GetString ("Project Name");
- this.WindowPosition = ((global::Gtk.WindowPosition)(4));
- this.Modal = true;
- this.SkipTaskbarHint = true;
- // Internal child MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.VBox
- global::Gtk.VBox w1 = this.VBox;
- w1.Name = "dialog1_VBox";
- w1.BorderWidth = ((uint)(2));
- // Container child dialog1_VBox.Gtk.Box+BoxChild
- this.hbox = new global::Gtk.HBox ();
- this.hbox.Name = "hbox";
- this.hbox.Spacing = 6;
- // Container child hbox.Gtk.Box+BoxChild
- this.alignmentLogo = new global::Gtk.Alignment (1f, 0.15f, 1f, 0f);
- this.alignmentLogo.Name = "alignmentLogo";
- // Container child alignmentLogo.Gtk.Container+ContainerChild
- this.imageLogo = new global::Gtk.Image ();
- this.imageLogo.WidthRequest = 180;
- this.imageLogo.Name = "imageLogo";
- this.imageLogo.Yalign = 0f;
- this.imageLogo.Pixbuf = global::Gdk.Pixbuf.LoadFromResource ("gtk-logo.png");
- this.alignmentLogo.Add (this.imageLogo);
- this.hbox.Add (this.alignmentLogo);
- global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox[this.alignmentLogo]));
- w3.Position = 0;
- w3.Expand = false;
- w3.Fill = false;
- // Container child hbox.Gtk.Box+BoxChild
- this.vbox2 = new global::Gtk.VBox ();
- this.vbox2.Name = "vbox2";
- this.vbox2.Spacing = 6;
- // Container child vbox2.Gtk.Box+BoxChild
- this.labelProject = new global::Gtk.Label ();
- this.labelProject.Name = "labelProject";
- this.labelProject.LabelProp = global::Mono.Unix.Catalog.GetString ("<b><big>GTK# Project Conversion</big></b>");
- this.labelProject.UseMarkup = true;
- this.vbox2.Add (this.labelProject);
- global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.labelProject]));
- w4.Position = 0;
- w4.Expand = false;
- w4.Fill = false;
- // Container child vbox2.Gtk.Box+BoxChild
- this.labelInfo = new global::Gtk.Label ();
- this.labelInfo.Name = "labelInfo";
- this.labelInfo.Xalign = 0f;
- this.labelInfo.Yalign = 0f;
- this.labelInfo.LabelProp = global::Mono.Unix.Catalog.GetString ("This project has been created in the previous\nversion of GTK# addin and must be converted. \n\n<b>Following changes will be made :</b>\n\t- split gui.stetic into separate .gtkx files\n\t- split generated.cs into separate helper classes\n\t- remove gtk-gui folder.\n\t- create a designer folder for stock icons\n\t and generated helper classes. ");
- this.labelInfo.UseMarkup = true;
- this.labelInfo.Wrap = true;
- this.vbox2.Add (this.labelInfo);
- global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.labelInfo]));
- w5.Position = 1;
- w5.Expand = false;
- w5.Fill = false;
- // Container child vbox2.Gtk.Box+BoxChild
- this.hseparator1 = new global::Gtk.HSeparator ();
- this.hseparator1.Name = "hseparator1";
- this.vbox2.Add (this.hseparator1);
- global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hseparator1]));
- w6.Position = 2;
- w6.Expand = false;
- w6.Fill = false;
- // Container child vbox2.Gtk.Box+BoxChild
- this.hbox1 = new global::Gtk.HBox ();
- this.hbox1.Name = "hbox1";
- this.hbox1.Spacing = 6;
- // Container child hbox1.Gtk.Box+BoxChild
- this.labelFolder = new global::Gtk.Label ();
- this.labelFolder.Name = "labelFolder";
- this.labelFolder.LabelProp = global::Mono.Unix.Catalog.GetString ("Designer folder name:");
- this.hbox1.Add (this.labelFolder);
- global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.labelFolder]));
- w7.Position = 0;
- w7.Expand = false;
- w7.Fill = false;
- // Container child hbox1.Gtk.Box+BoxChild
- this.entryFolder = new global::Gtk.Entry ();
- this.entryFolder.CanFocus = true;
- this.entryFolder.Name = "entryFolder";
- this.entryFolder.IsEditable = true;
-
- this.hbox1.Add (this.entryFolder);
- global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.entryFolder]));
- w8.Position = 1;
- this.vbox2.Add (this.hbox1);
- global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hbox1]));
- w9.Position = 3;
- w9.Expand = false;
- w9.Fill = false;
- // Container child vbox2.Gtk.Box+BoxChild
- this.checkBackup = new global::Gtk.CheckButton ();
- this.checkBackup.CanFocus = true;
- this.checkBackup.Name = "checkBackup";
- this.checkBackup.Label = global::Mono.Unix.Catalog.GetString ("Make a backup before converting");
- this.checkBackup.Active = true;
- this.checkBackup.DrawIndicator = true;
- this.checkBackup.UseUnderline = true;
- this.vbox2.Add (this.checkBackup);
- global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.checkBackup]));
- w10.Position = 4;
- w10.Expand = false;
- w10.Fill = false;
- this.hbox.Add (this.vbox2);
- global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.hbox[this.vbox2]));
- w11.Position = 1;
- w11.Expand = false;
- w11.Fill = false;
- w1.Add (this.hbox);
- global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(w1[this.hbox]));
- w12.Position = 0;
- w12.Expand = false;
- w12.Fill = false;
- // Internal child MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog.ActionArea
- global::Gtk.HButtonBox w13 = this.ActionArea;
- w13.Name = "dialog1_ActionArea";
- w13.Spacing = 10;
- w13.BorderWidth = ((uint)(5));
- w13.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
- // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
- this.buttonConvert = new global::Gtk.Button ();
- this.buttonConvert.CanDefault = true;
- this.buttonConvert.CanFocus = true;
- this.buttonConvert.Name = "buttonConvert";
- this.buttonConvert.UseUnderline = true;
- this.buttonConvert.Label = global::Mono.Unix.Catalog.GetString ("_Convert");
- this.AddActionWidget (this.buttonConvert, -5);
- global::Gtk.ButtonBox.ButtonBoxChild w14 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w13[this.buttonConvert]));
- w14.Expand = false;
- w14.Fill = false;
- if ((this.Child != null)) {
- this.Child.ShowAll ();
- }
- this.DefaultWidth = 532;
- this.DefaultHeight = 292;
- this.Show ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/generated.cs b/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/generated.cs
deleted file mode 100644
index aa96390c4a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/generated.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-
-// This file has been generated by the GUI designer. Do not modify.
-namespace Stetic
-{
- internal class Gui
- {
- private static bool initialized;
-
- static internal void Initialize (Gtk.Widget iconRenderer)
- {
- if ((Stetic.Gui.initialized == false)) {
- Stetic.Gui.initialized = true;
- }
- }
- }
-
- internal class BinContainer
- {
- private Gtk.Widget child;
-
- private Gtk.UIManager uimanager;
-
- public static BinContainer Attach (Gtk.Bin bin)
- {
- BinContainer bc = new BinContainer ();
- bin.SizeRequested += new Gtk.SizeRequestedHandler (bc.OnSizeRequested);
- bin.SizeAllocated += new Gtk.SizeAllocatedHandler (bc.OnSizeAllocated);
- bin.Added += new Gtk.AddedHandler (bc.OnAdded);
- return bc;
- }
-
- private void OnSizeRequested (object sender, Gtk.SizeRequestedArgs args)
- {
- if ((this.child != null)) {
- args.Requisition = this.child.SizeRequest ();
- }
- }
-
- private void OnSizeAllocated (object sender, Gtk.SizeAllocatedArgs args)
- {
- if ((this.child != null)) {
- this.child.Allocation = args.Allocation;
- }
- }
-
- private void OnAdded (object sender, Gtk.AddedArgs args)
- {
- this.child = args.Widget;
- }
-
- public void SetUiManager (Gtk.UIManager uim)
- {
- this.uimanager = uim;
- this.child.Realized += new System.EventHandler (this.OnRealized);
- }
-
- private void OnRealized (object sender, System.EventArgs args)
- {
- if ((this.uimanager != null)) {
- Gtk.Widget w;
- w = this.child.Toplevel;
- if (((w != null) && typeof(Gtk.Window).IsInstanceOfType (w))) {
- ((Gtk.Window)(w)).AddAccelGroup (this.uimanager.AccelGroup);
- this.uimanager = null;
- }
- }
- }
- }
-
- internal class ActionGroups
- {
- public static Gtk.ActionGroup GetActionGroup (System.Type type)
- {
- return Stetic.ActionGroups.GetActionGroup (type.FullName);
- }
-
- public static Gtk.ActionGroup GetActionGroup (string name)
- {
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/gui.stetic b/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/gui.stetic
deleted file mode 100644
index 819d4c1aa8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/gtk-gui/gui.stetic
+++ /dev/null
@@ -1,231 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<stetic-interface>
- <configuration>
- <images-root-path>..</images-root-path>
- <target-gtk-version>2.12</target-gtk-version>
- </configuration>
- <import>
- <widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.GtkCore2/libsteticui2.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.GtkCore2/libstetic2.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.Deployment/MonoDevelop.Deployment.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll" />
- <widget-library name="../../../../build/bin/MonoDevelop.Ide.dll" />
- <widget-library name="../../../../build/bin/Mono.TextEditor.dll" />
- <widget-library name="MonoDevelop.Ide, Version=2.4.0.0, Culture=neutral" />
- <widget-library name="Mono.TextEditor, Version=1.0.0.0, Culture=neutral" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.GtkCore2/MonoDevelop.GtkCore2.dll" internal="true" />
- </import>
- <widget class="Gtk.Bin" id="MonoDevelop.GtkCore.Dialogs.GtkDesignerOptionsPanelWidget" design-size="503 22">
- <property name="MemberName" />
- <property name="Visible">False</property>
- <child>
- <widget class="Gtk.VBox" id="vbox2">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.CheckButton" id="checkSwitchLayout">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="Label" translatable="yes">Automatically switch to the "GUI Builder" layout when opening the designer</property>
- <property name="DrawIndicator">True</property>
- <property name="HasLabel">True</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- <widget class="Gtk.Dialog" id="MonoDevelop.GtkCore.Dialogs.ProjectConversionDialog" design-size="532 308">
- <property name="MemberName" />
- <property name="Title" translatable="yes">Project Name</property>
- <property name="WindowPosition">CenterOnParent</property>
- <property name="Modal">True</property>
- <property name="SkipTaskbarHint">True</property>
- <property name="Buttons">1</property>
- <property name="HelpButton">False</property>
- <child internal-child="VBox">
- <widget class="Gtk.VBox" id="dialog1_VBox">
- <property name="MemberName" />
- <property name="BorderWidth">2</property>
- <child>
- <widget class="Gtk.HBox" id="hbox">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.Alignment" id="alignmentLogo">
- <property name="MemberName" />
- <property name="Yscale">0</property>
- <property name="Xalign">1</property>
- <property name="Yalign">0.15</property>
- <child>
- <widget class="Gtk.Image" id="imageLogo">
- <property name="MemberName" />
- <property name="WidthRequest">180</property>
- <property name="Yalign">0</property>
- <property name="Pixbuf">resource:gtk-logo.png</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.VBox" id="vbox2">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.Label" id="labelProject">
- <property name="MemberName" />
- <property name="LabelProp" translatable="yes">&lt;b&gt;&lt;big&gt;GTK# Project Conversion&lt;/big&gt;&lt;/b&gt;</property>
- <property name="UseMarkup">True</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="labelInfo">
- <property name="MemberName" />
- <property name="Xalign">0</property>
- <property name="Yalign">0</property>
- <property name="LabelProp" translatable="yes">This project has been created in the previous
-version of GTK# addin and must be converted.
-
-&lt;b&gt;Following changes will be made :&lt;/b&gt;
- - split gui.stetic into separate .gtkx files
- - split generated.cs into separate helper classes
- - remove gtk-gui folder.
- - create a designer folder for stock icons
- and generated helper classes.</property>
- <property name="UseMarkup">True</property>
- <property name="Wrap">True</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.HSeparator" id="hseparator1">
- <property name="MemberName" />
- </widget>
- <packing>
- <property name="Position">2</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.HBox" id="hbox1">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.Label" id="labelFolder">
- <property name="MemberName" />
- <property name="LabelProp" translatable="yes">Designer folder name:</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Entry" id="entryFolder">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="IsEditable">True</property>
- <property name="InvisibleChar">●</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">3</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.CheckButton" id="checkBackup">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="Label" translatable="yes">Make a backup before converting</property>
- <property name="Active">True</property>
- <property name="DrawIndicator">True</property>
- <property name="HasLabel">True</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="Position">4</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
- <child internal-child="ActionArea">
- <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
- <property name="MemberName" />
- <property name="Spacing">10</property>
- <property name="BorderWidth">5</property>
- <property name="Size">1</property>
- <property name="LayoutStyle">End</property>
- <child>
- <widget class="Gtk.Button" id="buttonConvert">
- <property name="MemberName" />
- <property name="CanDefault">True</property>
- <property name="CanFocus">True</property>
- <property name="Type">TextOnly</property>
- <property name="Label" translatable="yes">_Convert</property>
- <property name="UseUnderline">True</property>
- <property name="ResponseId">-5</property>
- </widget>
- <packing>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
-</stetic-interface> \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.GtkCore2/gui.glade b/main/src/addins/MonoDevelop.GtkCore2/gui.glade
deleted file mode 100644
index 92f5740b91..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/gui.glade
+++ /dev/null
@@ -1,710 +0,0 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
-<glade-interface>
-<requires lib="gnome"/>
-
-<widget class="GtkDialog" id="SelectRenamedClassDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">GUI Designer</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okbutton1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox2">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="labelMessage">
- <property name="width_request">549</property>
- <property name="visible">True</property>
- <property name="label" translatable="yes">The class that was bound to the design currently edited could not be found. Please select the class you want to bind to the design:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">True</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
- <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="treeClasses">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">False</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">True</property>
- <property name="fixed_height_mode">False</property>
- <property name="hover_selection">False</property>
- <property name="hover_expand">False</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-<widget class="GtkDialog" id="BindDesignDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Bind Widget Design</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox2">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area2">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton2">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okButton">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox3">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="labelMessage">
- <property name="visible">True</property>
- <property name="label" translatable="yes">The widget design {0} is not currently bound to a class.</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkRadioButton" id="radioSelect">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Bind the design to an existing class</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="OnSelectToggled" last_modification_time="Mon, 27 Feb 2006 15:28:25 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <widget class="GtkLabel" id="label8">
- <property name="width_request">24</property>
- <property name="visible">True</property>
- <property name="label" translatable="yes"></property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label7">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Select a class: </property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkComboBox" id="comboClasses">
- <property name="visible">True</property>
- <property name="add_tearoffs">False</property>
- <property name="focus_on_click">True</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkRadioButton" id="radioCreate">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Create a new class</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- <property name="group">radioSelect</property>
- <signal name="toggled" handler="OnSelectToggled" last_modification_time="Mon, 27 Feb 2006 15:28:54 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkTable" id="tableNewClass">
- <property name="visible">True</property>
- <property name="n_rows">3</property>
- <property name="n_columns">3</property>
- <property name="homogeneous">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Name:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Namespace:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label6">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Location:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label9">
- <property name="width_request">24</property>
- <property name="visible">True</property>
- <property name="label" translatable="yes"></property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEntry" id="entryClassName">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- <signal name="changed" handler="OnEntryChanged" last_modification_time="Mon, 27 Feb 2006 18:53:06 GMT"/>
- </widget>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEntry" id="entryNamespace">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- <signal name="changed" handler="OnEntryChanged" last_modification_time="Mon, 27 Feb 2006 18:53:28 GMT"/>
- </widget>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEventBox" id="fileEntryBox">
- <property name="visible">True</property>
- <property name="visible_window">True</property>
- <property name="above_child">False</property>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">fill</property>
- <property name="y_options">fill</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-<widget class="GtkDialog" id="ConfirmWindowDeleteDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">MonoDevelop</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox3">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area3">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton3">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-no</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-9</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okbutton2">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-yes</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-8</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox2">
- <property name="border_width">12</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">12</property>
-
- <child>
- <widget class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="stock">gtk-dialog-question</property>
- <property name="icon_size">6</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox4">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label">
- <property name="visible">True</property>
- <property name="label">Are you sure you want to delete the window '{0}'?</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">True</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkCheckButton" id="checkbox">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Also remove the file '{0}'</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-</glade-interface>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/icons/actiongroup.png b/main/src/addins/MonoDevelop.GtkCore2/icons/actiongroup.png
deleted file mode 100644
index de43e0a5c4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/icons/actiongroup.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/icons/dialog.png b/main/src/addins/MonoDevelop.GtkCore2/icons/dialog.png
deleted file mode 100644
index 6e81b2fd60..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/icons/dialog.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/icons/gtk-logo-orig.png b/main/src/addins/MonoDevelop.GtkCore2/icons/gtk-logo-orig.png
deleted file mode 100644
index 9809fa4e09..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/icons/gtk-logo-orig.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/icons/gtk-logo.png b/main/src/addins/MonoDevelop.GtkCore2/icons/gtk-logo.png
deleted file mode 100644
index 5ebee707d9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/icons/gtk-logo.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/icons/gtkx.png b/main/src/addins/MonoDevelop.GtkCore2/icons/gtkx.png
deleted file mode 100644
index 87a1d7946d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/icons/gtkx.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/icons/image-x-generic.png b/main/src/addins/MonoDevelop.GtkCore2/icons/image-x-generic.png
deleted file mode 100644
index 68da5027cf..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/icons/image-x-generic.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/icons/widget.png b/main/src/addins/MonoDevelop.GtkCore2/icons/widget.png
deleted file mode 100644
index 7f5844bbfc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/icons/widget.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/icons/window.png b/main/src/addins/MonoDevelop.GtkCore2/icons/window.png
deleted file mode 100644
index 8f82250f04..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/icons/window.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ClassDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ClassDescriptor.cs
deleted file mode 100644
index 29a1f9a593..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ClassDescriptor.cs
+++ /dev/null
@@ -1,344 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Xml;
-
-namespace Stetic {
-
-
- public abstract class ClassDescriptor
- {
- protected string label, category, cname;
- protected bool deprecated, hexpandable, vexpandable, allowChildren = true;
-
- protected ItemGroupCollection groups = new ItemGroupCollection ();
- protected ItemGroupCollection signals = new ItemGroupCollection ();
-
- protected int importantGroups;
- protected ItemGroup contextMenu;
- protected ItemGroup internalChildren;
- protected string baseType;
- protected bool isInternal;
- protected string targetGtkVersion;
-
- WidgetLibrary library;
- PropertyDescriptor[] initializationProperties;
- static PropertyDescriptor[] emptyPropArray = new PropertyDescriptor[0];
-
- int counter;
-
- protected void Load (XmlElement elem)
- {
- if (elem.HasAttribute ("cname"))
- cname = elem.GetAttribute ("cname");
- else if (cname == null)
- cname = elem.GetAttribute ("type");
-
- label = elem.GetAttribute ("label");
- if (label == "") {
- label = WrappedTypeName;
- int i = label.LastIndexOf ('.');
- if (i != -1)
- label = label.Substring (i+1);
- }
-
- if (elem.HasAttribute ("allow-children"))
- allowChildren = elem.GetAttribute ("allow-children") == "yes" || elem.GetAttribute ("allow-children") == "true";
-
- category = elem.GetAttribute ("palette-category");
-
- if (elem.HasAttribute ("deprecated"))
- deprecated = true;
- if (elem.HasAttribute ("hexpandable"))
- hexpandable = true;
- if (elem.HasAttribute ("vexpandable"))
- vexpandable = true;
- if (elem.GetAttribute ("internal") == "true")
- isInternal = true;
-
- contextMenu = ItemGroup.Empty;
-
- baseType = elem.GetAttribute ("base-type");
- if (baseType.Length > 0) {
- ClassDescriptor basec = Registry.LookupClassByName (baseType);
- if (basec == null)
- throw new InvalidOperationException ("Base type '" + baseType + "' not found.");
- foreach (ItemGroup group in basec.ItemGroups)
- groups.Add (group);
- foreach (ItemGroup group in basec.SignalGroups)
- signals.Add (group);
- contextMenu = basec.ContextMenu;
- } else
- baseType = null;
-
- XmlElement groupsElem = elem["itemgroups"];
- if (groupsElem != null) {
- foreach (XmlElement groupElem in groupsElem.SelectNodes ("itemgroup")) {
- ItemGroup itemgroup;
-
- if (groupElem.HasAttribute ("ref")) {
- string refname = groupElem.GetAttribute ("ref");
- itemgroup = Registry.LookupItemGroup (refname);
- } else
- itemgroup = new ItemGroup (groupElem, this);
- groups.Add (itemgroup);
-
- if (groupElem.HasAttribute ("important")) {
- if (groupElem.GetAttribute ("important") == "true")
- importantGroups++;
- } else if (groups.Count == 1)
- importantGroups++;
- }
- }
-
- XmlElement signalsElem = elem["signals"];
- if (signalsElem != null) {
- foreach (XmlElement groupElem in signalsElem.SelectNodes ("itemgroup")) {
- ItemGroup itemgroup;
- if (groupElem.HasAttribute ("ref")) {
- string refname = groupElem.GetAttribute ("ref");
- itemgroup = Registry.LookupSignalGroup (refname);
- } else
- itemgroup = new ItemGroup (groupElem, this);
- signals.Add (itemgroup);
- }
- }
-
- XmlElement contextElem = elem["contextmenu"];
- if (contextElem != null) {
- if (contextElem.HasAttribute ("ref")) {
- string refname = contextElem.GetAttribute ("ref");
- contextMenu = Registry.LookupContextMenu (refname);
- } else
- contextMenu = new ItemGroup (contextElem, this);
- }
-
- XmlElement ichildElem = elem["internal-children"];
- if (ichildElem != null)
- internalChildren = new ItemGroup (ichildElem, this);
- else
- internalChildren = ItemGroup.Empty;
-
- string initProps = elem.GetAttribute ("init-properties");
- if (initProps.Length > 0) {
- string[] props = initProps.Split (' ');
- ArrayList list = new ArrayList ();
- foreach (string prop in props) {
- PropertyDescriptor idesc = this [prop] as PropertyDescriptor;
- if (idesc == null)
- throw new InvalidOperationException ("Initialization property not found: " + prop);
- list.Add (idesc);
- }
- initializationProperties = (PropertyDescriptor[]) list.ToArray (typeof(PropertyDescriptor));
- } else
- initializationProperties = emptyPropArray;
-
- targetGtkVersion = elem.GetAttribute ("gtk-version");
- if (targetGtkVersion.Length == 0)
- targetGtkVersion = null;
- }
-
- public virtual string Name {
- get {
- return WrappedTypeName;
- }
- }
-
- public virtual bool IsInternal {
- get { return isInternal; }
- }
-
- public abstract string WrappedTypeName {
- get;
- }
-
- public string CName {
- get {
- return cname;
- }
- }
-
- public bool Deprecated {
- get {
- return deprecated;
- }
- }
-
- public bool HExpandable {
- get {
- return hexpandable;
- }
- }
-
- public bool VExpandable {
- get {
- return vexpandable;
- }
- }
-
- public string Label {
- get {
- return label;
- }
- }
-
- public abstract Gdk.Pixbuf Icon {
- get;
- }
-
- public string Category {
- get {
- return category;
- }
- }
-
- public virtual string TargetGtkVersion {
- get {
- if (targetGtkVersion == null)
- return library.TargetGtkVersion;
- else
- return targetGtkVersion;
- }
- }
-
- public bool SupportsGtkVersion (string targetVersion)
- {
- return WidgetUtils.CompareVersions (TargetGtkVersion, targetVersion) >= 0;
- }
-
- public PropertyDescriptor[] InitializationProperties {
- get { return initializationProperties; }
- }
-
- public object NewInstance (IProject proj)
- {
- return NewInstance (proj, true);
- }
-
- public object NewInstance (IProject proj, bool initialize)
- {
- object ob = CreateInstance (proj);
-
- string name = WrappedTypeName.ToLower () + (++counter).ToString ();
- int i = name.LastIndexOf ('.');
- if (i != -1) {
- if (i < name.Length)
- name = name.Substring (i+1);
- else
- name = name.Replace (".", "");
- }
-
- ObjectWrapper ow = CreateWrapper ();
- try {
- ow.Loading = true;
- ObjectWrapper.Bind (proj, this, ow, ob, !initialize);
-
- // Initialize the properties after creating the wrapper, since some properties
- // may be implemented in the wrapper
-
- foreach (ItemGroup group in groups) {
- foreach (ItemDescriptor item in group) {
- PropertyDescriptor prop = item as PropertyDescriptor;
- if (prop != null && prop.InitWithName) {
- prop.SetValue (ob, name);
- }
- }
- }
- }
- finally {
- ow.Loading = false;
- }
-
- return ob;
- }
-
- // Sets the default values for an instance
- public virtual void ResetInstance (object obj)
- {
- foreach (ItemGroup group in groups) {
- foreach (ItemDescriptor item in group) {
- PropertyDescriptor prop = item as PropertyDescriptor;
- if (prop != null) {
- try {
- prop.ResetValue (obj);
- } catch (Exception ex) {
- // Ignore. ResetInstance should never crash since it can
- // leave a widget half initialized
- Console.WriteLine (ex);
- }
- }
- }
- }
- }
-
- public abstract object CreateInstance (IProject proj);
-
- public abstract ObjectWrapper CreateWrapper ();
-
- public ItemDescriptor this[string name] {
- get {
- if (groups != null) {
- foreach (ItemGroup group in groups) {
- ItemDescriptor item = group[name];
- if (item != null)
- return item;
- }
- }
-
- return null;
- }
- }
-
- public ItemGroupCollection ItemGroups {
- get {
- return groups;
- }
- }
-
- public ItemGroupCollection SignalGroups {
- get {
- return signals;
- }
- }
-
- public int ImportantGroups {
- get {
- return importantGroups;
- }
- }
-
- public ItemGroup ContextMenu {
- get {
- return contextMenu;
- }
- }
-
- public ItemGroup InternalChildren {
- get {
- return internalChildren;
- }
- }
-
- public WidgetLibrary Library {
- get { return library; }
- }
-
- public virtual bool AllowChildren {
- get { return allowChildren; }
- }
-
- internal protected virtual ItemDescriptor CreateItemDescriptor (XmlElement elem, ItemGroup group)
- {
- if (elem.Name == "command")
- return new CommandDescriptor (elem, group, this);
- else
- throw new ApplicationException ("Bad item name " + elem.Name + " in " + WrappedTypeName);
- }
-
- internal void SetLibrary (WidgetLibrary library)
- {
- this.library = library;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Clipboard.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/Clipboard.cs
deleted file mode 100644
index 9c27ceec40..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Clipboard.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using Gtk;
-using System;
-using System.Xml;
-
-namespace Stetic {
-
- internal static class Clipboard {
-
- const int SteticType = 0;
- const int TextType = 1;
-
- static Gtk.TargetEntry[] targets;
- static Gtk.TargetEntry[] Targets {
- get {
- if (targets == null) {
-#if GTK_SHARP_2_6
- Gtk.TargetList list = new Gtk.TargetList ();
- list.Add ((string)WidgetUtils.ApplicationXSteticAtom, 0, SteticType);
- list.AddTextTargets (TextType);
- targets = (Gtk.TargetEntry[])list;
-#else
- targets = new Gtk.TargetEntry[] {
- new Gtk.TargetEntry ((string)WidgetUtils.ApplicationXSteticAtom, 0, SteticType)
- };
-#endif
- }
- return targets;
- }
- }
-
- static Gtk.Clipboard MainClipboard {
- get {
- return Gtk.Clipboard.Get (Gdk.Selection.Clipboard);
- }
- }
-
- static XmlElement selection;
-
- static void ClipboardGet (Gtk.Clipboard clipboard, Gtk.SelectionData seldata, uint info)
- {
- if (selection == null)
- return;
-
- if (info == TextType)
- seldata.Text = selection.OuterXml;
- else
- seldata.Set (WidgetUtils.ApplicationXSteticAtom, 8, System.Text.Encoding.UTF8.GetBytes (selection.OuterXml));
- }
-
- static void ClipboardClear (Gtk.Clipboard clipboard)
- {
- selection = null;
- }
-
- public static void Copy (Gtk.Widget widget)
- {
- MainClipboard.SetWithData (Targets, ClipboardGet, ClipboardClear);
- selection = widget != null ? WidgetUtils.ExportWidget (widget) : null;
- }
-
- public static void Cut (Gtk.Widget widget)
- {
- Copy (widget);
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (widget);
- if (wrapper != null)
- wrapper.Delete ();
- }
-
- static Placeholder target;
-
- static void ClipboardPaste (Gtk.Clipboard clipboard, Gtk.SelectionData seldata)
- {
- Stetic.Wrapper.Container parent = Stetic.Wrapper.Container.LookupParent (target);
- if (parent == null)
- return;
-
- Stetic.Wrapper.Widget wrapper = WidgetUtils.Paste (parent.Project, seldata);
- if (wrapper == null)
- return;
-
- parent.PasteChild (target, wrapper.Wrapped);
- target = null;
- }
-
- public static void Paste (Placeholder target)
- {
- Clipboard.target = target;
- MainClipboard.RequestContents (WidgetUtils.ApplicationXSteticAtom, ClipboardPaste);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/CommandDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/CommandDescriptor.cs
deleted file mode 100644
index eadd8b3970..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/CommandDescriptor.cs
+++ /dev/null
@@ -1,152 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Xml;
-
-namespace Stetic {
-
- public class CommandDescriptor : ItemDescriptor {
-
- string name, checkName, label, description, icon;
-
- const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
-
- public CommandDescriptor (XmlElement elem, ItemGroup group, ClassDescriptor klass) : base (elem, group, klass)
- {
- name = elem.GetAttribute ("name");
- label = elem.GetAttribute ("label");
- description = elem.GetAttribute ("description");
- checkName = elem.GetAttribute ("check");
- icon = elem.GetAttribute ("icon");
- }
-
- public override string Name {
- get {
- return name;
- }
- }
-
- public string Label {
- get {
- return label;
- }
- }
-
- public string Description {
- get {
- return description;
- }
- }
-
- public bool IsToggleCommand (object obj)
- {
- object target;
- return (FindBoolProperty (obj, out target) != null);
- }
-
- public bool IsToogled (object obj)
- {
- object target;
- PropertyInfo prop = FindBoolProperty (obj, out target);
- return prop != null && (bool) prop.GetValue (target, null);
- }
-
- PropertyInfo FindBoolProperty (object obj, out object target)
- {
- PropertyInfo prop = obj.GetType().GetProperty (name, flags);
- if (prop != null && prop.PropertyType == typeof(bool)) {
- target = obj;
- return prop;
- }
-
- ObjectWrapper wrap = ObjectWrapper.Lookup (obj);
- if (wrap != null) {
- prop = wrap.GetType().GetProperty (name, flags);
- if (prop != null && prop.PropertyType == typeof(bool)) {
- target = wrap;
- return prop;
- }
- }
- target = null;
- return null;
- }
-
- public Gtk.Image GetImage ()
- {
- if (icon == null || icon.Length == 0)
- return null;
- if (icon.StartsWith ("res:")) {
- System.IO.Stream s = this.ClassDescriptor.Library.GetResource (icon.Substring (4));
- if (s == null)
- return null;
- using (s) {
- Gdk.Pixbuf pixbuf;
- try {
- pixbuf = new Gdk.Pixbuf (s);
- } catch (Exception e) {
- Console.WriteLine ("Error while loading pixbuf '" + icon.Substring (4) + "': " + e);
- return null;
- }
- return new Gtk.Image (pixbuf);
- }
- } else {
- return new Gtk.Image (icon, Gtk.IconSize.Menu);
- }
- }
-
- public bool Enabled (object obj)
- {
- if (checkName == "")
- return EnabledFor (obj);
- else
- return (bool) InvokeMethod (ObjectWrapper.Lookup (obj), checkName, null, false);
- }
-
- public bool Enabled (object obj, Gtk.Widget context)
- {
- if (checkName == "")
- return EnabledFor (obj);
-
- ObjectWrapper wrapper = ObjectWrapper.Lookup (obj);
- return (bool) InvokeMethod (wrapper, checkName, context, true);
- }
-
- public void Run (object obj)
- {
- ObjectWrapper ww = ObjectWrapper.Lookup (obj);
- using (ww.UndoManager.AtomicChange) {
- InvokeMethod (ww, name, null, false);
- }
- }
-
- public void Run (object obj, Gtk.Widget context)
- {
- ObjectWrapper ww = ObjectWrapper.Lookup (obj);
- using (ww.UndoManager.AtomicChange) {
- InvokeMethod (ww, name, context, true);
- }
- }
-
- object InvokeMethod (object target, string name, object context, bool withContext)
- {
- object ptarget;
- PropertyInfo prop = FindBoolProperty (target, out ptarget);
- if (prop != null) {
- prop.SetValue (ptarget, !(bool)prop.GetValue (ptarget, null), null);
- return null;
- }
-
- if (withContext) {
- MethodInfo metc = target.GetType().GetMethod (name, flags, null, new Type[] {typeof(Gtk.Widget)}, null);
- if (metc != null)
- return metc.Invoke (target, new object[] { context });
- }
-
- MethodInfo met = target.GetType().GetMethod (name, flags, null, Type.EmptyTypes, null);
- if (met != null)
- return met.Invoke (target, new object[0]);
-
- throw new ArgumentException ("Invalid command or checker name. Method '" + name +"' not found in class '" + target.GetType() + "'");
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/CustomWidget.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/CustomWidget.cs
deleted file mode 100644
index f9f3934343..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/CustomWidget.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- // This widget is used at design-time to represent a Gtk.Bin container.
- // Gtk.Bin is the base class for custom widgets.
-
- public class CustomWidget: Gtk.EventBox
- {
- public CustomWidget (IntPtr ptr): base (ptr)
- {
- }
-
- public CustomWidget ()
- {
- this.VisibleWindow = false;
- this.Events |= Gdk.EventMask.ButtonPressMask;
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton ev)
- {
- // Avoid forwarding event to parent widget
- return true;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/DND.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/DND.cs
deleted file mode 100644
index a1e58fc21a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/DND.cs
+++ /dev/null
@@ -1,630 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Stetic {
-
- public static class DND {
- static Gtk.TargetEntry[] targets;
- static Gtk.TargetList targetList;
- static Gdk.Atom steticWidgetType;
- static Gdk.Pixbuf widgetIcon;
-
- const int SteticType = 0;
- const int GladeType = 1;
-
- static DND ()
- {
- try {
- widgetIcon = Gdk.Pixbuf.LoadFromResource ("widget.png");
- } catch (Exception e) {
- Console.WriteLine ("Error while loading pixbuf 'widget.png': " + e);
- }
-
- steticWidgetType = Gdk.Atom.Intern ("application/x-stetic-widget", false);
-
- targets = new Gtk.TargetEntry[2];
- targets[0] = new Gtk.TargetEntry (steticWidgetType, 0, SteticType);
- targets[1] = new Gtk.TargetEntry ((string) GladeUtils.ApplicationXGladeAtom, 0, GladeType);
-
- targetList = new Gtk.TargetList (targets);
- targets = (Gtk.TargetEntry[]) targetList;
- }
-
- public static Gtk.TargetEntry[] Targets {
- get { return targets; }
- }
-
- public static void SourceSet (Gtk.Widget source)
- {
- Gtk.Drag.SourceSet (source, Gdk.ModifierType.Button1Mask,
- targets, Gdk.DragAction.Move);
- }
-
- public static void SourceUnset (Gtk.Widget source)
- {
- Gtk.Drag.SourceUnset (source);
- }
-
- public static void DestSet (Gtk.Widget dest, bool automatic)
- {
- Gtk.Drag.DestSet (dest, automatic ? Gtk.DestDefaults.All : 0,
- targets, Gdk.DragAction.Move | Gdk.DragAction.Copy);
- }
-
- public static void DestUnset (Gtk.Widget dest)
- {
- Gtk.Drag.DestUnset (dest);
- }
-
- static Gtk.Widget dragWidget;
- static WidgetDropCallback dropCallback;
- static int dragHotX;
- static int dragHotY;
-
- // Drag function for non-automatic sources, called from MotionNotifyEvent
- public static void Drag (Gtk.Widget source, Gdk.Event evt, Gtk.Widget dragWidget)
- {
- Gdk.DragContext ctx;
-
- ctx = Gtk.Drag.Begin (source, targetList, Gdk.DragAction.Move,
- 1 /* button */, evt);
- Drag (source, ctx, dragWidget);
- }
-
- // Drag function for automatic sources, called from DragBegin
- public static void Drag (Gtk.Widget source, Gdk.DragContext ctx, WidgetDropCallback dropCallback, string label)
- {
- Gtk.Frame fr = new Gtk.Frame ();
- fr.ShadowType = Gtk.ShadowType.Out;
- Gtk.HBox box = new Gtk.HBox ();
- box.Spacing = 3;
- box.BorderWidth = 3;
- box.PackStart (new Gtk.Image (widgetIcon), false, false, 0);
- Gtk.Label lab = new Gtk.Label (label);
- lab.Xalign = 0;
- box.PackStart (lab, true, true, 0);
- fr.Add (box);
- fr.ShowAll ();
- Drag (source, ctx, dropCallback, fr);
- }
-
- // Drag function for automatic sources, called from DragBegin
- public static void Drag (Gtk.Widget source, Gdk.DragContext ctx, Gtk.Widget dragWidget)
- {
- Drag (source, ctx, null, dragWidget);
- }
-
- // Drag function for automatic sources, called from DragBegin
- static void Drag (Gtk.Widget source, Gdk.DragContext ctx, WidgetDropCallback dropCallback, Gtk.Widget dragWidget)
- {
- if (ctx == null)
- return;
-
- Gtk.Window dragWin;
- Gtk.Requisition req;
-
- ShowFaults ();
- DND.dragWidget = dragWidget;
- DND.dropCallback = dropCallback;
-
- dragWin = new Gtk.Window (Gtk.WindowType.Popup);
- dragWin.Add (dragWidget);
-
- req = dragWidget.SizeRequest ();
- if (req.Width < 20 && req.Height < 20)
- dragWin.SetSizeRequest (20, 20);
- else if (req.Width < 20)
- dragWin.SetSizeRequest (20, -1);
- else if (req.Height < 20)
- dragWin.SetSizeRequest (-1, 20);
-
- req = dragWin.SizeRequest ();
-
- int px, py, rx, ry;
- Gdk.ModifierType pmask;
- ctx.SourceWindow.GetPointer (out px, out py, out pmask);
- ctx.SourceWindow.GetRootOrigin (out rx, out ry);
-
- dragWin.Move (rx + px, ry + py);
- dragWin.Show ();
-
- dragHotX = req.Width / 2;
- dragHotY = -3;
-
- Gtk.Drag.SetIconWidget (ctx, dragWin, dragHotX, dragHotY);
-
- if (source != null) {
- source.DragDataGet += DragDataGet;
- source.DragEnd += DragEnded;
- }
- }
-
- public static Gtk.Widget DragWidget {
- get {
- return dragWidget;
- }
- }
-
- public static int DragHotX {
- get {
- return dragHotX;
- }
- }
-
- public static int DragHotY {
- get {
- return dragHotY;
- }
- }
-
- // Call this from a DragDrop event to receive the dragged widget
- public static void Drop (Gdk.DragContext ctx, uint time, ObjectWrapper targetWrapper, string dropData)
- {
- if (dropCallback == null) {
- Gtk.Widget w = Drop (ctx, (Gtk.Widget) targetWrapper.Wrapped, time);
- targetWrapper.DropObject (dropData, w);
- return;
- }
-
- Cancel ();
- Gtk.Drag.Finish (ctx, true, true, time);
-
- Gtk.Application.Invoke (delegate {
- IProject project = targetWrapper.Project;
- string uid = targetWrapper.UndoId;
- string tname = ((Wrapper.Widget)targetWrapper).GetTopLevel ().Wrapped.Name;
-
- // This call may cause the project to be reloaded
- dragWidget = dropCallback ();
- if (dragWidget == null)
- return;
-
- if (targetWrapper.IsDisposed) {
- // The project has been reloaded. Find the wrapper again.
- Gtk.Widget twidget = project.GetWidget (tname);
- ObjectWrapper ow = ObjectWrapper.Lookup (twidget);
- if (ow != null)
- targetWrapper = ow.FindObjectByUndoId (uid);
- else
- targetWrapper = null;
-
- if (targetWrapper == null) {
- // Target wrapper not found. Just ignore the drop.
- return;
- }
- }
-
- targetWrapper.DropObject (dropData, dragWidget);
- });
- }
-
- public static Gtk.Widget Drop (Gdk.DragContext ctx, Gtk.Widget target, uint time)
- {
- if (dropCallback != null) {
- dragWidget = dropCallback ();
- }
-
- if (dragWidget == null) {
- Gtk.Drag.GetData (target, ctx, GladeUtils.ApplicationXGladeAtom, time);
- return null;
- }
-
- Gtk.Widget w = Cancel ();
- Gtk.Drag.Finish (ctx, true, true, time);
- return w;
- }
-
- // Call this from a DragEnd event to check if the widget wasn't dropped
- public static Gtk.Widget Cancel ()
- {
- if (dragWidget == null)
- return null;
-
- Gtk.Widget w = dragWidget;
- dragWidget = null;
-
- // Remove the widget from its dragWindow
- Gtk.Container parent = w.Parent as Gtk.Container;
- if (parent != null) {
- parent.Remove (w);
- parent.Destroy ();
- }
- return w;
- }
-
- static void DragEnded (object obj, Gtk.DragEndArgs args)
- {
- dragWidget = null;
- HideFaults ();
-
- ((Gtk.Widget)obj).DragEnd -= DragEnded;
- ((Gtk.Widget)obj).DragDataGet -= DragDataGet;
- }
-
- static void DragDataGet (object obj, Gtk.DragDataGetArgs args)
- {
- if (args.Info == GladeType) {
- Gtk.Widget w = Cancel ();
- if (w != null)
- WidgetUtils.Copy (w, args.SelectionData, false);
- }
- }
-
- class Fault {
- public Stetic.Wrapper.Widget Owner;
- public object Id;
- public Gtk.Orientation Orientation;
- public Gdk.Window Window;
-
- public Fault (Stetic.Wrapper.Widget owner, object id,
- Gtk.Orientation orientation, Gdk.Window window)
- {
- Owner = owner;
- Id = id;
- Orientation = orientation;
- Window = window;
- }
- }
-
- static Hashtable faultGroups = new Hashtable ();
- const int FaultOverlap = 3;
-
- public static void AddFault (Stetic.Wrapper.Widget owner, object faultId,
- Gtk.Orientation orientation, Gdk.Rectangle fault)
- {
- AddFault (owner, faultId, orientation,
- fault.X, fault.Y, fault.Width, fault.Height);
- }
-
- public static void AddFault (Stetic.Wrapper.Widget owner, object faultId,
- Gtk.Orientation orientation,
- int x, int y, int width, int height)
- {
- Gtk.Widget widget = owner.Wrapped;
- if (!widget.IsRealized)
- return;
-
- Gdk.Window win = NewWindow (widget, Gdk.WindowClass.InputOnly);
- win.MoveResize (x, y, width, height);
-
- Hashtable widgetFaults = faultGroups[widget] as Hashtable;
- if (widgetFaults == null) {
- faultGroups[widget] = widgetFaults = new Hashtable ();
- widget.Destroyed += FaultWidgetDestroyed;
- widget.DragMotion += FaultDragMotion;
- widget.DragLeave += FaultDragLeave;
- widget.DragDrop += FaultDragDrop;
- widget.DragDataReceived += FaultDragDataReceived;
- DND.DestSet (widget, false);
- }
- widgetFaults[win] = new Fault (owner, faultId, orientation, win);
- }
-
- public static void AddFault (Stetic.Wrapper.Widget owner, object faultId,
- Gtk.Orientation orientation,
- Gtk.Widget before, Gtk.Widget after)
- {
- if (orientation == Gtk.Orientation.Horizontal)
- AddHFault (owner, faultId, before, after);
- else
- AddVFault (owner, faultId, before, after);
- }
-
- public static void AddHFault (Stetic.Wrapper.Widget owner, object faultId,
- Gtk.Widget above, Gtk.Widget below)
- {
- Gtk.Widget widget = owner.Wrapped;
- if (!widget.IsRealized)
- return;
-
- Gdk.Rectangle aboveAlloc, belowAlloc;
- int x1, y1, x2, y2;
-
- if (above != null && below != null) {
- aboveAlloc = above.Allocation;
- belowAlloc = below.Allocation;
-
- x1 = Math.Min (aboveAlloc.X, belowAlloc.X);
- x2 = Math.Max (aboveAlloc.X + aboveAlloc.Width, belowAlloc.X + belowAlloc.Width);
- y1 = aboveAlloc.Y + aboveAlloc.Height;
- y2 = belowAlloc.Y;
-
- while (y2 - y1 < FaultOverlap * 2) {
- y1--;
- y2++;
- }
- } else if (above == null) {
- belowAlloc = below.Allocation;
-
- x1 = belowAlloc.X;
- x2 = belowAlloc.X + belowAlloc.Width;
- y1 = 0;
- y2 = Math.Max (belowAlloc.Y, FaultOverlap);
- } else {
- aboveAlloc = above.Allocation;
-
- x1 = aboveAlloc.X;
- x2 = aboveAlloc.X + aboveAlloc.Width;
- y1 = Math.Min (aboveAlloc.Y + aboveAlloc.Height, widget.Allocation.Height - FaultOverlap);
- y2 = widget.Allocation.Height;
- }
-
- AddFault (owner, faultId, Gtk.Orientation.Horizontal,
- x1, y1, x2 - x1, y2 - y1);
- }
-
- public static void AddVFault (Stetic.Wrapper.Widget owner, object faultId,
- Gtk.Widget left, Gtk.Widget right)
- {
- Gtk.Widget widget = owner.Wrapped;
- if (!widget.IsRealized)
- return;
-
- Gdk.Rectangle leftAlloc, rightAlloc;
- int x1, y1, x2, y2;
-
- if (left != null && right != null) {
- leftAlloc = left.Allocation;
- rightAlloc = right.Allocation;
-
- x1 = leftAlloc.X + leftAlloc.Width;
- x2 = rightAlloc.X;
-
- y1 = Math.Min (leftAlloc.Y, rightAlloc.Y);
- y2 = Math.Max (leftAlloc.Y + leftAlloc.Height, rightAlloc.Y + rightAlloc.Height);
-
- while (x2 - x1 < FaultOverlap * 2) {
- x1--;
- x2++;
- }
- } else if (left == null) {
- rightAlloc = right.Allocation;
-
- x1 = 0;
- x2 = Math.Max (rightAlloc.X, FaultOverlap);
-
- y1 = rightAlloc.Y;
- y2 = rightAlloc.Y + rightAlloc.Height;
- } else {
- leftAlloc = left.Allocation;
-
- x1 = Math.Min (leftAlloc.X + leftAlloc.Width, widget.Allocation.Width - FaultOverlap);
- x2 = widget.Allocation.Width;
-
- y1 = leftAlloc.Y;
- y2 = leftAlloc.Y + leftAlloc.Height;
- }
-
- AddFault (owner, faultId, Gtk.Orientation.Vertical,
- x1, y1, x2 - x1, y2 - y1);
- }
-
- public static void AddFault (Stetic.Wrapper.Widget owner, object faultId,
- Gtk.SideType side, Gtk.Widget widget)
- {
- Gdk.Rectangle fault;
- Gtk.Orientation orientation;
-
- if (widget == null) {
- fault = owner.Wrapped.Allocation;
- int border = (int)((Gtk.Container)owner.Wrapped).BorderWidth;
- fault.Inflate (-border, -border);
- } else
- fault = widget.Allocation;
-
- switch (side) {
- case Gtk.SideType.Top:
- fault.Y -= FaultOverlap;
- fault.Height = 2 * FaultOverlap;
- orientation = Gtk.Orientation.Horizontal;
- break;
- case Gtk.SideType.Bottom:
- fault.Y += fault.Height - FaultOverlap;
- fault.Height = 2 * FaultOverlap;
- orientation = Gtk.Orientation.Horizontal;
- break;
- case Gtk.SideType.Left:
- fault.X -= FaultOverlap;
- fault.Width = 2 * FaultOverlap;
- orientation = Gtk.Orientation.Vertical;
- break;
- case Gtk.SideType.Right:
- fault.X += fault.Width - FaultOverlap;
- fault.Width = 2 *FaultOverlap;
- orientation = Gtk.Orientation.Vertical;
- break;
- default:
- throw new Exception ("not reached");
- }
-
- AddFault (owner, faultId, orientation, fault);
- }
-
- static void FaultWidgetDestroyed (object widget, EventArgs args)
- {
- ClearFaults ((Gtk.Widget)widget);
- }
-
- public static void ClearFaults (Stetic.Wrapper.Widget owner)
- {
- ClearFaults (owner.Wrapped);
- }
-
- static void ClearFaults (Gtk.Widget widget)
- {
- Hashtable widgetFaults = faultGroups[widget] as Hashtable;
- if (widgetFaults == null)
- return;
- faultGroups.Remove (widget);
-
- foreach (Gdk.Window win in widgetFaults.Keys)
- win.Destroy ();
- widgetFaults.Clear ();
- DND.DestUnset (widget);
- }
-
- static void ShowFaults ()
- {
- foreach (Hashtable widgetFaults in faultGroups.Values) {
- foreach (Gdk.Window win in widgetFaults.Keys)
- win.Show ();
- }
- }
-
- static void HideFaults ()
- {
- foreach (Hashtable widgetFaults in faultGroups.Values) {
- foreach (Gdk.Window win in widgetFaults.Keys)
- win.Hide ();
- }
- DestroySplitter ();
- dragFault = null;
- }
-
- static Fault dragFault;
- static Gdk.Window splitter;
-
- static void DestroySplitter ()
- {
- if (splitter != null) {
- splitter.Hide ();
- splitter.Destroy ();
- splitter = null;
- }
- }
-
- static Fault FindFault (int x, int y, Gtk.Widget w)
- {
- int wx, wy, width, height, depth;
-
- Hashtable widgetFaults = (Hashtable) faultGroups [w];
- if (widgetFaults == null)
- return null;
-
- foreach (Fault f in widgetFaults.Values) {
- f.Window.GetGeometry (out wx, out wy, out width, out height, out depth);
- if (x >= wx && y >= wy && x <= wx + width && y <= wy + height) {
- return f;
- }
- }
- return null;
- }
-
- static void FaultDragMotion (object obj, Gtk.DragMotionArgs args)
- {
- int wx, wy, width, height, depth;
-
- Gtk.Widget widget = (Gtk.Widget) obj;
- int px = args.X + widget.Allocation.X;
- int py = args.Y + widget.Allocation.Y;
-
- Fault fault = FindFault (px, py, widget);
-
- // If there's a splitter visible, and we're not currently dragging
- // in the fault that owns that splitter, hide it
- if (splitter != null && dragFault != fault)
- DestroySplitter ();
-
- if (dragFault != fault) {
- dragFault = fault;
- if (dragFault == null)
- return;
-
- splitter = NewWindow (fault.Owner.Wrapped, Gdk.WindowClass.InputOutput);
- fault.Window.GetGeometry (out wx, out wy, out width, out height, out depth);
- if (fault.Orientation == Gtk.Orientation.Horizontal) {
- splitter.MoveResize (wx, wy + height / 2 - FaultOverlap,
- width, 2 * FaultOverlap);
- } else {
- splitter.MoveResize (wx + width / 2 - FaultOverlap, wy,
- 2 * FaultOverlap, height);
- }
- splitter.ShowUnraised ();
- fault.Window.Lower ();
- } else if (dragFault == null)
- return;
-
- Gdk.Drag.Status (args.Context, Gdk.DragAction.Move, args.Time);
- args.RetVal = true;
- }
-
- static void FaultDragLeave (object obj, Gtk.DragLeaveArgs args)
- {
- DestroySplitter ();
- dragFault = null;
- }
-
- static void FaultDrop (Stetic.Wrapper.Widget wrapper, int x, int y, Gtk.Widget targetWidget)
- {
- Fault fault = FindFault (x, y, targetWidget);
- if (fault != null) {
- fault.Owner.Drop (wrapper.Wrapped, fault.Id);
- wrapper.Select ();
- }
- }
-
- static void FaultDragDrop (object obj, Gtk.DragDropArgs args)
- {
- Gtk.Widget w = DND.Drop (args.Context, (Gtk.Widget)obj, args.Time);
- Stetic.Wrapper.Widget dropped = Stetic.Wrapper.Widget.Lookup (w);
- if (dropped != null) {
- Gtk.Widget targetWidget = (Gtk.Widget) obj;
- int px = args.X + targetWidget.Allocation.X;
- int py = args.Y + targetWidget.Allocation.Y;
-
- FaultDrop (dropped, px, py, targetWidget);
- args.RetVal = true;
- }
- }
-
- static void FaultDragDataReceived (object obj, Gtk.DragDataReceivedArgs args)
- {
- Stetic.Wrapper.Widget dropped = null;
-
- Stetic.Wrapper.Widget faultOwner = Stetic.Wrapper.Widget.Lookup ((Gtk.Widget)obj);
- if (faultOwner != null)
- dropped = WidgetUtils.Paste (faultOwner.Project, args.SelectionData);
- Gtk.Drag.Finish (args.Context, dropped != null,
- dropped != null, args.Time);
- if (dropped != null) {
- Gtk.Widget targetWidget = (Gtk.Widget) obj;
- int px = args.X + targetWidget.Allocation.X;
- int py = args.Y + targetWidget.Allocation.Y;
- FaultDrop (dropped, px, py, targetWidget);
- }
- }
-
- static Gdk.Window NewWindow (Gtk.Widget parent, Gdk.WindowClass wclass)
- {
- Gdk.WindowAttr attributes;
- Gdk.WindowAttributesType attributesMask;
- Gdk.Window win;
-
- attributes = new Gdk.WindowAttr ();
- attributes.WindowType = Gdk.WindowType.Child;
- attributes.Wclass = wclass ;
- attributes.Visual = parent.Visual;
- attributes.Colormap = parent.Colormap;
- attributes.Mask = (Gdk.EventMask.ButtonPressMask |
- Gdk.EventMask.ButtonMotionMask |
- Gdk.EventMask.ButtonReleaseMask |
- Gdk.EventMask.ExposureMask |
- Gdk.EventMask.EnterNotifyMask |
- Gdk.EventMask.LeaveNotifyMask);
-
- attributesMask =
- Gdk.WindowAttributesType.Visual |
- Gdk.WindowAttributesType.Colormap;
-
- win = new Gdk.Window (parent.GdkWindow, attributes, attributesMask);
- win.UserData = parent.Handle;
-
- if (wclass == Gdk.WindowClass.InputOutput)
- parent.Style.Attach (win);
-
- return win;
- }
- }
-
- public delegate Gtk.Widget WidgetDropCallback ();
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/EnumDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/EnumDescriptor.cs
deleted file mode 100644
index 79ee48b3c9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/EnumDescriptor.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Xml;
-
-namespace Stetic {
- public class EnumValue {
- public Enum Value;
- public string Label;
- public string Description;
-
- internal EnumValue (Enum value, string label, string description)
- {
- Value = value;
- Label = label;
- Description = description;
- }
- }
-
- public class EnumDescriptor {
-
- Type enumType;
- Hashtable values;
- Enum[] values_array;
- string name;
-
- public EnumDescriptor (XmlElement elem)
- {
- string cls = elem.GetAttribute ("type");
- enumType = Registry.GetType (cls, true);
- this.name = enumType.FullName;
-
- values = new Hashtable ();
-
- // This gets the list of enum names and gets the value of each of them.
- // This is not done the other way (get the values, and then the names from them)
- // because it won't work if two different enum members have the same value
- ArrayList list = new ArrayList ();
- Hashtable evalues = new Hashtable ();
- foreach (string name in Enum.GetNames (enumType)) {
- object value = Enum.Parse (enumType, name);
- list.Add (value);
- evalues[name] = value;
- }
-
- foreach (XmlElement valueElem in elem.SelectNodes ("value")) {
- string name = valueElem.GetAttribute ("name");
- if (!evalues.Contains (name))
- throw new ArgumentException ("<enum> node for " + enumType.FullName + " contains extra element " + name);
- Enum value = (Enum)evalues[name];
- values[value] = new EnumValue (value,
- valueElem.GetAttribute ("label"),
- valueElem.GetAttribute ("description"));
- evalues.Remove (name);
- }
-
- // Remove from the array the values not declared in the xml file
- foreach (object val in evalues.Values)
- list.Remove (val);
-
- values_array = (Enum[]) list.ToArray (typeof(Enum));
- }
-
- public string Name {
- get { return name; }
- }
-
- public Type EnumType {
- get {
- return enumType;
- }
- }
-
- public Enum[] Values {
- get {
- return values_array;
- }
- }
-
- public EnumValue this[Enum value] {
- get {
- return (EnumValue)values[value];
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ErrorWidget.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ErrorWidget.cs
deleted file mode 100644
index 82ec4ecc50..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ErrorWidget.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-using System;
-using System.Xml;
-using System.CodeDom;
-using Mono.Unix;
-
-namespace Stetic
-{
- // This widget is shown in place of widgets with unknown classes.
-
- public class ErrorWidget: Gtk.Frame
- {
- readonly string className;
- readonly Exception exc;
-
- public ErrorWidget (Exception ex, string id)
- {
- exc = ex;
- Init (Catalog.GetString ("Load Error:") + " " + ex.Message, id);
- }
-
- public ErrorWidget (string className, string id)
- {
- this.className = className;
- Init (Catalog.GetString ("Unknown widget:") + " " + className, id);
- }
-
- public ErrorWidget (string className, string minGtkVersion, string foundGtkVersion, string id)
- {
- this.className = className;
- Init (string.Format (Catalog.GetString ("Widget '{0}' not available in GTK# {1}"), className, foundGtkVersion), id);
- }
-
- void Init (string message, string id)
- {
- Gtk.Label lab = new Gtk.Label ();
- lab.Markup = "<b><span foreground='red'>" + message + "</span></b>";
- this.CanFocus = false;
- Add (lab);
- this.ShadowType = Gtk.ShadowType.In;
- ShowAll ();
- if (id != null && id.Length > 0)
- Name = id;
- }
-
- public string ClassName {
- get { return className; }
- }
-
- public Exception Exception {
- get { return exc; }
- }
- }
-
- internal class ErrorWidgetWrapper: Wrapper.Widget
- {
- XmlElement elementData;
- FileFormat format;
-
- public override void Read (ObjectReader reader, XmlElement elem)
- {
- elementData = elem;
- this.format = reader.Format;
- }
-
- public override XmlElement Write (ObjectWriter writer)
- {
- if (writer.Format != this.format) {
- ErrorWidget ew = (ErrorWidget) Wrapped;
- XmlElement elem = writer.XmlDocument.CreateElement ("widget");
- elem.SetAttribute ("class", "Gtk.Label");
- elem.SetAttribute ("id", Wrapped.Name);
- XmlElement ce = writer.XmlDocument.CreateElement ("property");
- string msg;
- if (ew.Exception != null)
- msg = "Invalid widget";
- else
- msg = "Unknown widget: " + ew.ClassName;
- ce.SetAttribute ("name", "LabelProp");
- ce.InnerText = msg;
- elem.AppendChild (ce);
- return elem;
- }
- else
- return (XmlElement) writer.XmlDocument.ImportNode (elementData, true);
- }
-
- public override string WrappedTypeName {
- get {
- ErrorWidget ew = (ErrorWidget) Wrapped;
- return ew.ClassName;
- }
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- ErrorWidget ew = (ErrorWidget) Wrapped;
- string msg;
- if (ew.Exception != null)
- msg = Project.FolderName + ": Could not generate code for an invalid widget. The widget failed to load: " + ew.Exception.Message + ". The generated code may be invalid.";
- else
- msg = Project.FolderName + ": Could not generate code for widgets of type: " + ew.ClassName + ". The widget could not be found in any referenced library. The generated code may be invalid.";
-
- if (ctx.Options.FailForUnknownWidgets) {
- throw new InvalidOperationException (msg);
- } else {
- ctx.ReportWarning (msg);
- return new CodePrimitiveExpression (null);
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/GeneratorContext.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/GeneratorContext.cs
deleted file mode 100644
index 65b6daa416..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/GeneratorContext.cs
+++ /dev/null
@@ -1,546 +0,0 @@
-using System;
-using System.CodeDom;
-using System.Collections;
-
-namespace Stetic
-{
- public class GeneratorContext
- {
- CodeNamespace cns;
- int n;
- string idPrefix;
- Hashtable vars = new Hashtable ();
- ArrayList generatedWrappers = new ArrayList ();
- WidgetMap map;
- CodeStatementCollection statements;
- GenerationOptions options;
- ArrayList warnings = new ArrayList ();
- CodeExpression rootObject;
-
- public GeneratorContext (CodeNamespace cns, string idPrefix, CodeStatementCollection statements, GenerationOptions options)
- {
- this.cns = cns;
- this.idPrefix = idPrefix;
- this.statements = statements;
- this.options = options;
- map = new WidgetMap (vars);
- }
-
- public CodeNamespace GlobalCodeNamespace {
- get { return cns; }
- }
-
- public CodeStatementCollection Statements {
- get { return statements; }
- }
-
- public GenerationOptions Options {
- get { return options; }
- }
-
- public string[] Warnings {
- get { return (string[]) warnings.ToArray (typeof(string)); }
- }
-
- public void ReportWarning (string s)
- {
- warnings.Add (s);
- }
-
- public string NewId ()
- {
- return idPrefix + (++n);
- }
-
- public CodeExpression GenerateNewInstanceCode (Wrapper.Widget widget)
- {
- CodeExpression exp = widget.GenerateObjectCreation (this);
- CodeExpression var = GenerateInstanceExpression (widget, exp);
- GenerateBuildCode (widget, var);
- return var;
- }
-
- public virtual CodeExpression GenerateInstanceExpression (ObjectWrapper wrapper, CodeExpression newObject)
- {
- string varName = NewId ();
- CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement (wrapper.WrappedTypeName.ToGlobalTypeRef (), varName);
- varDec.InitExpression = newObject;
- statements.Add (varDec);
- return new CodeVariableReferenceExpression (varName);
- }
-
- public virtual void GenerateCreationCode (ObjectWrapper wrapper, CodeExpression varExp)
- {
- rootObject = varExp;
- wrapper.GenerateInitCode (this, varExp);
- GenerateBuildCode (wrapper, varExp);
- }
-
- public virtual void GenerateBuildCode (ObjectWrapper wrapper, CodeExpression var)
- {
- vars [wrapper] = var;
- wrapper.GenerateBuildCode (this, var);
- generatedWrappers.Add (wrapper);
- }
-
- public virtual void GenerateCreationCode (Wrapper.ActionGroup agroup, CodeExpression var)
- {
- rootObject = var;
- vars [agroup] = var;
- agroup.GenerateBuildCode (this, var);
- }
-
- public CodeExpression GenerateValue (object value, Type type)
- {
- return GenerateValue (value, type, false);
- }
-
- public CodeExpression GenerateValue (object value, Type type, bool translatable)
- {
- if (value == null)
- return new CodePrimitiveExpression (value);
-
- if (value.GetType ().IsEnum) {
- if (!type.IsEnum) {
- object ival = Convert.ChangeType (value, type);
- return new CodePrimitiveExpression (ival);
- } else {
- long ival = (long) Convert.ChangeType (value, typeof(long));
- return new CodeCastExpression (
- value.GetType ().ToGlobalTypeRef (),
- new CodePrimitiveExpression (ival)
- );
- }
- }
-
- if (value is Gtk.Adjustment) {
- Gtk.Adjustment adj = value as Gtk.Adjustment;
- return new CodeObjectCreateExpression (
- typeof(Gtk.Adjustment).ToGlobalTypeRef (),
- new CodePrimitiveExpression (adj.Value),
- new CodePrimitiveExpression (adj.Lower),
- new CodePrimitiveExpression (adj.Upper),
- new CodePrimitiveExpression (adj.StepIncrement),
- new CodePrimitiveExpression (adj.PageIncrement),
- new CodePrimitiveExpression (adj.PageSize));
- }
- if (value is ushort || value is uint) {
- return new CodeCastExpression (
- value.GetType ().ToGlobalTypeRef (),
- new CodePrimitiveExpression (Convert.ChangeType (value, typeof(long))));
- }
- if (value is ulong) {
- return new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (value.GetType ()),
- "Parse",
- new CodePrimitiveExpression (value.ToString ()));
- }
-
- if (value is ImageInfo && typeof(Gdk.Pixbuf).IsAssignableFrom (type))
- return ((ImageInfo)value).ToCodeExpression (this);
-
- if (value is Wrapper.ActionGroup) {
- return new CodeMethodInvokeExpression (
- new CodeMethodReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (GlobalCodeNamespace.Name + ".ActionGroups", CodeTypeReferenceOptions.GlobalReference)),
- "GetActionGroup"
- ),
- new CodePrimitiveExpression (((Wrapper.ActionGroup)value).Name)
- );
- }
-
- if (value is Array) {
- ArrayList list = new ArrayList ();
- foreach (object val in (Array)value)
- list.Add (GenerateValue (val, val != null ? val.GetType() : null, translatable));
- return new CodeArrayCreateExpression (value.GetType().GetElementType(), (CodeExpression[]) list.ToArray(typeof(CodeExpression)));
- }
-
- if (value is DateTime) {
- return new CodeObjectCreateExpression (
- typeof(DateTime).ToGlobalTypeRef (),
- new CodePrimitiveExpression (((DateTime)value).Ticks)
- );
- }
-
- if (value is TimeSpan) {
- return new CodeObjectCreateExpression (
- typeof(TimeSpan).ToGlobalTypeRef (),
- new CodePrimitiveExpression (((TimeSpan)value).Ticks)
- );
- }
-
- string str = value as string;
- if (translatable && str != null && str.Length > 0 && options.UseGettext) {
- return new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (options.GettextClass, CodeTypeReferenceOptions.GlobalReference)),
- "GetString",
- new CodePrimitiveExpression (str)
- );
- }
-
- return new CodePrimitiveExpression (value);
- }
-
- public WidgetMap WidgetMap {
- get { return map; }
- }
-
- public System.CodeDom.CodeExpression RootObject {
- get {
- return rootObject;
- }
- set {
- rootObject = value;
- }
- }
-
- public void EndGeneration ()
- {
- foreach (ObjectWrapper w in generatedWrappers) {
- CodeExpression var = (CodeExpression) vars [w];
- w.GeneratePostBuildCode (this, var);
- }
- }
-
- public void Reset ()
- {
- vars.Clear ();
- generatedWrappers.Clear ();
- map = new WidgetMap (vars);
- n = 0;
- }
-
- public CodeExpression GenerateLoadPixbuf (string name, Gtk.IconSize size)
- {
- bool found = false;
- foreach (CodeTypeDeclaration t in cns.Types) {
- if (t.Name == "IconLoader") {
- found = true;
- break;
- }
- }
-
- if (!found)
- {
- CodeTypeDeclaration cls = new CodeTypeDeclaration ("IconLoader");
- cls.Attributes = MemberAttributes.Private;
- cls.TypeAttributes = System.Reflection.TypeAttributes.NestedAssembly;
- cns.Types.Add (cls);
-
- CodeMemberMethod met = new CodeMemberMethod ();
- cls.Members.Add (met);
- met.Attributes = MemberAttributes.Public | MemberAttributes.Static;
- met.Name = "LoadIcon";
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(Gtk.Widget), "widget"));
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(string), "name"));
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(Gtk.IconSize), "size"));
- met.ReturnType = new CodeTypeReference (typeof(Gdk.Pixbuf));
-
- CodeExpression widgetExp = new CodeVariableReferenceExpression ("widget");
- CodeExpression nameExp = new CodeVariableReferenceExpression ("name");
- CodeExpression sizeExp = new CodeVariableReferenceExpression ("size");
- CodeExpression szExp = new CodeVariableReferenceExpression ("sz");
- CodeExpression mgExp = new CodeBinaryOperatorExpression (szExp, CodeBinaryOperatorType.Divide, new CodePrimitiveExpression (4));
- CodeExpression pmapExp = new CodeVariableReferenceExpression ("pmap");
- CodeExpression gcExp = new CodeVariableReferenceExpression ("gc");
- CodeExpression szM1Exp = new CodeBinaryOperatorExpression (szExp, CodeBinaryOperatorType.Subtract, new CodePrimitiveExpression (1));
- CodeExpression zeroExp = new CodePrimitiveExpression (0);
- CodeExpression resExp = new CodeVariableReferenceExpression ("res");
-
- met.Statements.Add (
- new CodeVariableDeclarationStatement (typeof(Gdk.Pixbuf), "res",
- new CodeMethodInvokeExpression (
- widgetExp,
- "RenderIcon",
- nameExp,
- sizeExp,
- new CodePrimitiveExpression (null)
- )
- )
- );
-
- CodeConditionStatement nullcheck = new CodeConditionStatement ();
- met.Statements.Add (nullcheck);
- nullcheck.Condition = new CodeBinaryOperatorExpression (
- resExp,
- CodeBinaryOperatorType.IdentityInequality,
- new CodePrimitiveExpression (null)
- );
- nullcheck.TrueStatements.Add (new CodeMethodReturnStatement (resExp));
-
- // int sz, h;
- // Gtk.Icon.SizeLookup (size, out sz, out h);
-
- nullcheck.FalseStatements.Add (new CodeVariableDeclarationStatement (typeof(int), "sz"));
- nullcheck.FalseStatements.Add (new CodeVariableDeclarationStatement (typeof(int), "sy"));
- nullcheck.FalseStatements.Add (new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (typeof(Gtk.Icon).ToGlobalTypeRef ()),
- "SizeLookup",
- sizeExp,
- new CodeDirectionExpression (FieldDirection.Out, szExp),
- new CodeDirectionExpression (FieldDirection.Out, new CodeVariableReferenceExpression ("sy"))
- ));
-
- CodeTryCatchFinallyStatement trycatch = new CodeTryCatchFinallyStatement ();
- nullcheck.FalseStatements.Add (trycatch);
- trycatch.TryStatements.Add (
- new CodeMethodReturnStatement (
- new CodeMethodInvokeExpression (
- new CodePropertyReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (typeof(Gtk.IconTheme))),
- "Default"
- ),
- "LoadIcon",
- nameExp,
- szExp,
- zeroExp
- )
- )
- );
-
- CodeCatchClause ccatch = new CodeCatchClause ();
- trycatch.CatchClauses.Add (ccatch);
-
- CodeConditionStatement cond = new CodeConditionStatement ();
- ccatch.Statements.Add (cond);
-
- cond.Condition = new CodeBinaryOperatorExpression (
- nameExp,
- CodeBinaryOperatorType.IdentityInequality,
- new CodePrimitiveExpression ("gtk-missing-image")
- );
-
- cond.TrueStatements.Add (
- new CodeMethodReturnStatement (
- new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (cns.Name + "." + cls.Name),
- "LoadIcon",
- widgetExp,
- new CodePrimitiveExpression ("gtk-missing-image"),
- sizeExp
- )
- )
- );
-
- CodeStatementCollection stms = cond.FalseStatements;
-
- stms.Add (
- new CodeVariableDeclarationStatement (typeof(Gdk.Pixmap), "pmap",
- new CodeObjectCreateExpression (
- typeof(Gdk.Pixmap),
- new CodePropertyReferenceExpression (
- new CodePropertyReferenceExpression (
- new CodeTypeReferenceExpression (typeof(Gdk.Screen)),
- "Default"
- ),
- "RootWindow"
- ),
- szExp,
- szExp
- )
- )
- );
- stms.Add (
- new CodeVariableDeclarationStatement (typeof(Gdk.GC), "gc",
- new CodeObjectCreateExpression (typeof(Gdk.GC), pmapExp)
- )
- );
- stms.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- gcExp,
- "RgbFgColor"
- ),
- new CodeObjectCreateExpression (
- typeof(Gdk.Color),
- new CodePrimitiveExpression (255),
- new CodePrimitiveExpression (255),
- new CodePrimitiveExpression (255)
- )
- )
- );
- stms.Add (
- new CodeMethodInvokeExpression (
- pmapExp,
- "DrawRectangle",
- gcExp,
- new CodePrimitiveExpression (true),
- zeroExp,
- zeroExp,
- szExp,
- szExp
- )
- );
- stms.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- gcExp,
- "RgbFgColor"
- ),
- new CodeObjectCreateExpression (
- typeof(Gdk.Color),
- zeroExp, zeroExp, zeroExp
- )
- )
- );
- stms.Add (
- new CodeMethodInvokeExpression (
- pmapExp,
- "DrawRectangle",
- gcExp,
- new CodePrimitiveExpression (false),
- zeroExp,
- zeroExp,
- szM1Exp,
- szM1Exp
- )
- );
- stms.Add (
- new CodeMethodInvokeExpression (
- gcExp,
- "SetLineAttributes",
- new CodePrimitiveExpression (3),
- new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (typeof(Gdk.LineStyle)), "Solid"),
- new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (typeof(Gdk.CapStyle)), "Round"),
- new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (typeof(Gdk.JoinStyle)), "Round")
- )
- );
- stms.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- gcExp,
- "RgbFgColor"
- ),
- new CodeObjectCreateExpression (
- typeof(Gdk.Color),
- new CodePrimitiveExpression (255),
- zeroExp,
- zeroExp
- )
- )
- );
- stms.Add (
- new CodeMethodInvokeExpression (
- pmapExp,
- "DrawLine",
- gcExp,
- mgExp,
- mgExp,
- new CodeBinaryOperatorExpression (szM1Exp, CodeBinaryOperatorType.Subtract, mgExp),
- new CodeBinaryOperatorExpression (szM1Exp, CodeBinaryOperatorType.Subtract, mgExp)
- )
- );
- stms.Add (
- new CodeMethodInvokeExpression (
- pmapExp,
- "DrawLine",
- gcExp,
- new CodeBinaryOperatorExpression (szM1Exp, CodeBinaryOperatorType.Subtract, mgExp),
- mgExp,
- mgExp,
- new CodeBinaryOperatorExpression (szM1Exp, CodeBinaryOperatorType.Subtract, mgExp)
- )
- );
- stms.Add (
- new CodeMethodReturnStatement (
- new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (typeof(Gdk.Pixbuf)),
- "FromDrawable",
- pmapExp,
- new CodePropertyReferenceExpression (pmapExp, "Colormap"),
- zeroExp, zeroExp, zeroExp, zeroExp, szExp, szExp
- )
- )
- );
- }
-
- int sz, h;
- Gtk.Icon.SizeLookup (size, out sz, out h);
-
- return new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (cns.Name + ".IconLoader", CodeTypeReferenceOptions.GlobalReference)),
- "LoadIcon",
- rootObject,
- new CodePrimitiveExpression (name),
- new CodeFieldReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (typeof(Gtk.IconSize), CodeTypeReferenceOptions.GlobalReference)),
- size.ToString ()
- )
- );
- }
- }
-
- public class WidgetMap
- {
- Hashtable vars;
-
- internal WidgetMap (Hashtable vars)
- {
- this.vars = vars;
- }
-
- public CodeExpression GetWidgetExp (ObjectWrapper wrapper)
- {
- return (CodeExpression) vars [wrapper];
- }
-
- public CodeExpression GetWidgetExp (object wrapped)
- {
- ObjectWrapper w = ObjectWrapper.Lookup (wrapped);
- if (w != null)
- return GetWidgetExp (w);
- else
- return null;
- }
- }
-
- [Serializable]
- public class GenerationOptions
- {
- bool useGettext;
- bool partialClasses;
- bool generateEmptyBuildMethod;
- bool generateSingleFile = true;
- bool failForUnknownWidgets = false;
- string path;
- string globalNamespace = "Stetic";
- string gettextClass;
-
- public bool UseGettext {
- get { return useGettext; }
- set { useGettext = value; }
- }
-
- public string GettextClass {
- get {
- if (gettextClass == null || gettextClass.Length == 0)
- return "Mono.Unix.Catalog";
- else
- return gettextClass;
- }
- set { gettextClass = value; }
- }
-
- public string Path {
- get { return path; }
- set { path = value; }
- }
-
- public bool GenerateEmptyBuildMethod {
- get { return generateEmptyBuildMethod; }
- set { generateEmptyBuildMethod = value; }
- }
-
- public string GlobalNamespace {
- get { return globalNamespace; }
- set { globalNamespace = value; }
- }
-
- public bool FailForUnknownWidgets {
- get { return failForUnknownWidgets; }
- set { failForUnknownWidgets = value; }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/GladeException.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/GladeException.cs
deleted file mode 100644
index 504dab9823..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/GladeException.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-
-namespace Stetic {
-
- public class GladeException : ApplicationException {
-
- public GladeException (string message) : base (message) { }
-
- public GladeException (string message, string className) :
- this (message + " (class " + className + ")")
- {
- this.className = className;
- }
-
- public GladeException (string message, string className,
- bool childprop, string propName) :
- this (message + " (class " + className + ", " + (childprop ? "child " : "") + "property " + propName + ")")
- {
- this.childprop = childprop;
- this.propName = propName;
- }
-
- public GladeException (string message, string className,
- bool childprop, string propName, string propVal) :
- this (message + " (class " + className + ", " + (childprop ? "child " : "") + "property " + propName + ", value " + propVal + ")")
- {
- this.childprop = childprop;
- this.propName = propName;
- this.propVal = propVal;
- }
-
- string className, propName, propVal;
- bool childprop;
-
- public string ClassName {
- get {
- return className;
- }
- }
-
- public bool ChildProp {
- get {
- return childprop;
- }
- }
-
- public string PropName {
- get {
- return propName;
- }
- }
-
- public string PropVal {
- get {
- return propVal;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/GladeUtils.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/GladeUtils.cs
deleted file mode 100644
index bb02c0e198..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/GladeUtils.cs
+++ /dev/null
@@ -1,773 +0,0 @@
-using System;
-using System.Reflection;
-using System.Collections;
-using System.Runtime.InteropServices;
-using System.Xml;
-using Stetic.Wrapper;
-
-namespace Stetic {
-
- public static class GladeUtils {
-
- public const string Glade20SystemId = "http://glade.gnome.org/glade-2.0.dtd";
-
- static Gdk.Atom gladeAtom;
- public static Gdk.Atom ApplicationXGladeAtom {
- get {
- if (gladeAtom == null)
- gladeAtom = Gdk.Atom.Intern ("application/x-glade", false);
- return gladeAtom;
- }
- }
-
- public static XmlDocument XslImportTransform (XmlDocument doc)
- {
-/* XmlDocumentType doctype = doc.DocumentType;
- if (doctype == null ||
- doctype.Name != "glade-interface" ||
- doctype.SystemId != Glade20SystemId)
- throw new GladeException ("Not a glade file according to doctype");
-*/
- XmlReader reader = Registry.GladeImportXsl.Transform (doc, null, (XmlResolver)null);
- doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
- doc.Load (reader);
-
- return doc;
- }
-
- public static XmlDocument XslExportTransform (XmlDocument doc)
- {
- XmlReader reader = Registry.GladeExportXsl.Transform (doc, null, (XmlResolver)null);
- doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
- doc.Load (reader);
-
- XmlDocumentType doctype = doc.CreateDocumentType ("glade-interface", null, Glade20SystemId, null);
- doc.PrependChild (doctype);
-
- return doc;
- }
-
- public static XmlDocument Export (Gtk.Widget widget)
- {
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (widget);
- if (wrapper == null)
- return null;
-
- XmlDocument doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
-
- XmlElement toplevel = doc.CreateElement ("glade-interface");
- doc.AppendChild (toplevel);
-
- // For toplevel widgets, glade just saves it as-is. For
- // non-toplevels, it puts the widget into a dummy GtkWindow,
- // but using the packing attributes of the widget's real
- // container (so as to preserve expand/fill settings and the
- // like).
-
- XmlElement elem;
- Stetic.Wrapper.Container parent = wrapper.ParentWrapper;
- ObjectWriter writer = new ObjectWriter (doc, FileFormat.Glade);
-
- if (parent == null) {
- elem = wrapper.Write (writer);
- if (elem == null)
- return null;
- if (!(widget is Gtk.Window)) {
- XmlElement window = doc.CreateElement ("widget");
- window.SetAttribute ("class", "GtkWindow");
- window.SetAttribute ("id", "glade-dummy-container");
- XmlElement child = doc.CreateElement ("child");
- window.AppendChild (child);
- child.AppendChild (elem);
- elem = window;
- }
- } else {
- elem = doc.CreateElement ("widget");
- // Set the class correctly (temporarily) so the XSL
- // transforms will work correctly.
- ClassDescriptor klass = parent.ClassDescriptor;
- elem.SetAttribute ("class", klass.CName);
- elem.AppendChild (parent.WriteContainerChild (writer, wrapper));
- }
- toplevel.AppendChild (elem);
-
- doc = XslExportTransform (doc);
-
- if (parent != null) {
- elem = (XmlElement)doc.SelectSingleNode ("glade-interface/widget");
- elem.SetAttribute ("class", "GtkWindow");
- elem.SetAttribute ("id", "glade-dummy-container");
- }
- return doc;
- }
-
-// public static Stetic.Wrapper.Widget Import (IProject project, XmlDocument doc)
-// {
-// try {
-// doc = XslImportTransform (doc);
-// } catch {
-// return null;
-// }
-//
-// ObjectReader reader = new ObjectReader (project, FileFormat.Glade);
-//
-// XmlElement elem = (XmlElement)doc.SelectSingleNode ("glade-interface/widget");
-// if (elem.GetAttribute ("class") != "GtkWindow" ||
-// elem.GetAttribute ("id") != "glade-dummy-container") {
-// // Creating a new toplevel
-// Stetic.Wrapper.Widget toplevel = (Stetic.Wrapper.Widget)
-// Stetic.ObjectWrapper.ReadObject (reader, elem);
-// if (toplevel != null) {
-// project.AddWindow ((Gtk.Window)toplevel.Wrapped);
-// }
-// return toplevel;
-// }
-//
-// return (Stetic.Wrapper.Widget)
-// Stetic.ObjectWrapper.ReadObject (reader, (XmlElement)elem.SelectSingleNode ("child/widget"));
-// }
-
- public static void Copy (Gtk.Widget widget, Gtk.SelectionData seldata, bool copyAsText)
- {
- XmlDocument doc = Export (widget);
- if (doc == null)
- return;
-
- if (copyAsText)
- seldata.Text = doc.OuterXml;
- else
- seldata.Set (ApplicationXGladeAtom, 8, System.Text.Encoding.UTF8.GetBytes (doc.OuterXml));
- }
-
-// public static Stetic.Wrapper.Widget Paste (IProject project, Gtk.SelectionData seldata)
-// {
-// if (seldata.Type != ApplicationXGladeAtom)
-// return null;
-// string data = System.Text.Encoding.UTF8.GetString (seldata.Data);
-//
-// XmlDocument doc = new XmlDocument ();
-// doc.PreserveWhitespace = true;
-// try {
-// doc.LoadXml (data);
-// } catch {
-// return null;
-// }
-//
-// return Import (project, doc);
-// }
-
- static object GetProperty (XmlElement elem, string selector, object defaultValue, bool extract)
- {
- XmlElement prop = (XmlElement)elem.SelectSingleNode (selector);
- if (prop == null)
- return defaultValue;
- if (extract)
- prop.ParentNode.RemoveChild (prop);
- return ParseProperty (null, defaultValue.GetType (), prop.InnerText).Val;
- }
-
- public static object GetProperty (XmlElement elem, string name, object defaultValue)
- {
- return GetProperty (elem, "./property[@name='" + name + "']", defaultValue, false);
- }
-
- public static object ExtractProperty (XmlElement elem, string name, object defaultValue)
- {
- return GetProperty (elem, "./property[@name='" + name + "']", defaultValue, true);
- }
-
- public static object GetChildProperty (XmlElement elem, string name, object defaultValue)
- {
- return GetProperty (elem, "./packing/property[@name='" + name + "']", defaultValue, false);
- }
-
- public static object ExtractChildProperty (XmlElement elem, string name, object defaultValue)
- {
- return GetProperty (elem, "./packing/property[@name='" + name + "']", defaultValue, true);
- }
-
- public static void SetProperty (XmlElement elem, string name, string value)
- {
- XmlElement prop_elem = elem.OwnerDocument.CreateElement ("property");
- prop_elem.SetAttribute ("name", name);
- prop_elem.InnerText = value;
- elem.AppendChild (prop_elem);
- }
-
- public static void SetChildProperty (XmlElement elem, string name, string value)
- {
- XmlElement packing_elem = elem["packing"];
- if (packing_elem == null) {
- packing_elem = elem.OwnerDocument.CreateElement ("packing");
- elem.AppendChild (packing_elem);
- }
- SetProperty (packing_elem, name, value);
- }
-
- static GLib.Value ParseBasicType (GLib.TypeFundamentals type, string strval)
- {
- switch (type) {
- case GLib.TypeFundamentals.TypeChar:
- return new GLib.Value (SByte.Parse (strval));
- case GLib.TypeFundamentals.TypeUChar:
- return new GLib.Value (Byte.Parse (strval));
- case GLib.TypeFundamentals.TypeBoolean:
- return new GLib.Value (strval == "True");
- case GLib.TypeFundamentals.TypeInt:
- return new GLib.Value (Int32.Parse (strval));
- case GLib.TypeFundamentals.TypeUInt:
- return new GLib.Value (UInt32.Parse (strval));
- case GLib.TypeFundamentals.TypeInt64:
- return new GLib.Value (Int64.Parse (strval));
- case GLib.TypeFundamentals.TypeUInt64:
- return new GLib.Value (UInt64.Parse (strval));
- case GLib.TypeFundamentals.TypeFloat:
- return new GLib.Value (Single.Parse (strval, System.Globalization.CultureInfo.InvariantCulture));
- case GLib.TypeFundamentals.TypeDouble:
- return new GLib.Value (Double.Parse (strval, System.Globalization.CultureInfo.InvariantCulture));
- case GLib.TypeFundamentals.TypeString:
- return new GLib.Value (strval);
- default:
- throw new GladeException ("Could not parse");
- }
- }
-
- static GLib.Value ParseEnum (IntPtr gtype, string strval)
- {
- IntPtr enum_class = g_type_class_ref (gtype);
- try {
- IntPtr enum_value = g_enum_get_value_by_name (enum_class, strval);
- if (enum_value == IntPtr.Zero)
- throw new GladeException ("Could not parse");
-
- int eval = Marshal.ReadInt32 (enum_value);
- return new GLib.Value (Enum.ToObject (GLib.GType.LookupType (gtype), eval));
- } finally {
- g_type_class_unref (enum_class);
- }
- }
-
- static GLib.Value ParseFlags (IntPtr gtype, string strval)
- {
- IntPtr flags_class = g_type_class_ref (gtype);
- uint fval = 0;
-
- try {
- foreach (string flag in strval.Split ('|')) {
- if (flag == "")
- continue;
- IntPtr flags_value = g_flags_get_value_by_name (flags_class, flag);
- if (flags_value == IntPtr.Zero)
- throw new GladeException ("Could not parse");
-
- int bits = Marshal.ReadInt32 (flags_value);
- fval |= (uint)bits;
- }
-
- return new GLib.Value (Enum.ToObject (GLib.GType.LookupType (gtype), fval));
- } finally {
- g_type_class_unref (flags_class);
- }
- }
-
- static GLib.Value ParseAdjustment (string strval)
- {
- string[] vals = strval.Split (' ');
- double deflt, min, max, step, page_inc, page_size;
-
- deflt = Double.Parse (vals[0], System.Globalization.CultureInfo.InvariantCulture);
- min = Double.Parse (vals[1], System.Globalization.CultureInfo.InvariantCulture);
- max = Double.Parse (vals[2], System.Globalization.CultureInfo.InvariantCulture);
- step = Double.Parse (vals[3], System.Globalization.CultureInfo.InvariantCulture);
- page_inc = Double.Parse (vals[4], System.Globalization.CultureInfo.InvariantCulture);
- page_size = Double.Parse (vals[5], System.Globalization.CultureInfo.InvariantCulture);
- return new GLib.Value (new Gtk.Adjustment (deflt, min, max, step, page_inc, page_size));
- }
-
- /* static GLib.Value ParseUnichar (string strval)
- {
- return new GLib.Value (strval.Length == 1 ? (uint)strval[0] : 0U);
- }*/
-
- static GLib.Value ParseProperty (ParamSpec pspec, Type propType, string strval)
- {
- IntPtr gtype;
- if (propType != null)
- gtype = ((GLib.GType)propType).Val;
-/*
- FIXME: ValueType is not supported right now
-
- else if (pspec != null)
- gtype = pspec.ValueType;
-*/
- else
- throw new GladeException ("Bad type");
-
- GLib.TypeFundamentals typef = (GLib.TypeFundamentals)(int)g_type_fundamental (gtype);
-
- if (gtype == Gtk.Adjustment.GType.Val)
- return ParseAdjustment (strval);
- else if (typef == GLib.TypeFundamentals.TypeEnum)
- return ParseEnum (gtype, strval);
- else if (typef == GLib.TypeFundamentals.TypeFlags)
- return ParseFlags (gtype, strval);
-// FIXME: Enable when ParamSpec.IsUnichar is implemented.
-// else if (pspec != null && pspec.IsUnichar)
-// return ParseUnichar (strval);
- else
- return ParseBasicType (typef, strval);
- }
-
- static PropertyInfo FindClrProperty (Type type, string name, bool childprop)
- {
- if (childprop) {
- Type[] types = type.GetNestedTypes ();
- foreach (Type t in types) {
- if (typeof(Gtk.Container.ContainerChild).IsAssignableFrom (t)) {
- type = t;
- break;
- }
- }
- foreach (PropertyInfo pi in type.GetProperties ()) {
- Gtk.ChildPropertyAttribute at = (Gtk.ChildPropertyAttribute) Attribute.GetCustomAttribute (pi, typeof(Gtk.ChildPropertyAttribute), false);
- if (at != null && at.Name == name)
- return pi;
- }
- if (typeof(GLib.Object).IsAssignableFrom (type.BaseType))
- return FindClrProperty (type.BaseType, name, true);
- }
-
- foreach (PropertyInfo pi in type.GetProperties ()) {
- GLib.PropertyAttribute at = (GLib.PropertyAttribute) Attribute.GetCustomAttribute (pi, typeof(GLib.PropertyAttribute), false);
- if (at != null && at.Name == name)
- return pi;
- }
- return null;
- }
-
- static GLib.Value ParseProperty (Type type, bool childprop, string name, string strval)
- {
- ParamSpec pspec;
-
- // FIXME: this can be removed when GParamSpec supports ValueType.
- PropertyInfo pi = FindClrProperty (type, name, childprop);
- if (pi == null)
- throw new GladeException ("Unknown property", type.ToString (), childprop, name, strval);
-
- if (childprop)
- pspec = ParamSpec.LookupChildProperty (type, name);
- else
- pspec = ParamSpec.LookupObjectProperty (type, name);
- if (pspec == null)
- throw new GladeException ("Unknown property", type.ToString (), childprop, name, strval);
-
- try {
- return ParseProperty (pspec, pi.PropertyType, strval);
- } catch {
- throw new GladeException ("Could not parse property", type.ToString (), childprop, name, strval);
- }
- }
-
- static void ParseProperties (Type type, bool childprops, IEnumerable props,
- out string[] propNames, out GLib.Value[] propVals)
- {
- ArrayList names = new ArrayList ();
- ArrayList values = new ArrayList ();
-
- foreach (XmlElement prop in props) {
- string name = prop.GetAttribute ("name").Replace ("_","-");
- string strval = prop.InnerText;
-
- // Skip translation context
- if (prop.GetAttribute ("context") == "yes" &&
- strval.IndexOf ('|') != -1)
- strval = strval.Substring (strval.IndexOf ('|') + 1);
-
- GLib.Value value;
- try {
- value = ParseProperty (type, childprops, name, strval);
- names.Add (name);
- values.Add (value);
- } catch (GladeException ge) {
- Console.Error.WriteLine (ge.Message);
- }
- }
-
- propNames = (string[])names.ToArray (typeof (string));
- propVals = (GLib.Value[])values.ToArray (typeof (GLib.Value));
- }
-
- static void ExtractProperties (TypedClassDescriptor klass, XmlElement elem,
- out Hashtable rawProps, out Hashtable overrideProps)
- {
- rawProps = new Hashtable ();
- overrideProps = new Hashtable ();
- foreach (ItemGroup group in klass.ItemGroups) {
- foreach (ItemDescriptor item in group) {
- TypedPropertyDescriptor prop = item as TypedPropertyDescriptor;
- if (prop == null)
- continue;
- prop = prop.GladeProperty;
- if (prop.GladeName == null)
- continue;
-
- XmlNode prop_node = elem.SelectSingleNode ("property[@name='" + prop.GladeName + "']");
- if (prop_node == null)
- continue;
-
- if (prop.GladeOverride)
- overrideProps[prop] = prop_node;
- else
- rawProps[prop] = prop_node;
- }
- }
- }
-
- static void ReadSignals (TypedClassDescriptor klass, ObjectWrapper wrapper, XmlElement elem)
- {
- Stetic.Wrapper.Widget ob = wrapper as Stetic.Wrapper.Widget;
- if (ob == null) return;
-
- foreach (ItemGroup group in klass.SignalGroups) {
- foreach (TypedSignalDescriptor signal in group) {
- if (signal.GladeName == null)
- continue;
-
- XmlElement signal_elem = elem.SelectSingleNode ("signal[@name='" + signal.GladeName + "']") as XmlElement;
- if (signal_elem == null)
- continue;
-
- string handler = signal_elem.GetAttribute ("handler");
- bool after = signal_elem.GetAttribute ("after") == "yes";
- ob.Signals.Add (new Signal (signal, handler, after));
- }
- }
- }
-
- static public void ImportWidget (ObjectWrapper wrapper, XmlElement elem)
- {
- string className = elem.GetAttribute ("class");
- if (className == null)
- throw new GladeException ("<widget> node with no class name");
-
- ClassDescriptor klassBase = Registry.LookupClassByCName (className);
- if (klassBase == null)
- throw new GladeException ("No stetic ClassDescriptor for " + className);
-
- TypedClassDescriptor klass = klassBase as TypedClassDescriptor;
- if (klass == null)
- throw new GladeException ("The widget class " + className + " is not supported by Glade");
-
- ReadSignals (klass, wrapper, elem);
-
- Hashtable rawProps, overrideProps;
- ExtractProperties (klass, elem, out rawProps, out overrideProps);
-
- string[] propNames;
- GLib.Value[] propVals;
- ParseProperties (klass.WrappedType, false, rawProps.Values,
- out propNames, out propVals);
-
- Gtk.Widget widget;
-
- if (wrapper.Wrapped == null) {
- if (className == "GtkWindow" || className == "GtkDialog") {
- widget = (Gtk.Widget) klass.CreateInstance (wrapper.Project);
- ObjectWrapper.Bind (wrapper.Project, klass, wrapper, widget, true);
- SetProperties (klass, widget, propNames, propVals);
- } else {
- IntPtr raw = gtksharp_object_newv (klass.GType.Val, propNames.Length, propNames, propVals);
- if (raw == IntPtr.Zero)
- throw new GladeException ("Could not create widget", className);
- widget = (Gtk.Widget)GLib.Object.GetObject (raw, true);
- if (widget == null) {
- gtk_object_sink (raw);
- throw new GladeException ("Could not create gtk# wrapper", className);
- }
- ObjectWrapper.Bind (wrapper.Project, klass, wrapper, widget, true);
- }
- } else {
- widget = (Gtk.Widget)wrapper.Wrapped;
- for (int i = 0; i < propNames.Length; i++)
- g_object_set_property (widget.Handle, propNames[i], ref propVals[i]);
- }
- MarkTranslatables (widget, rawProps);
-
- widget.Name = elem.GetAttribute ("id");
-
- SetOverrideProperties (wrapper, overrideProps);
- MarkTranslatables (widget, overrideProps);
- }
-
- static void SetProperties (TypedClassDescriptor klass, Gtk.Widget widget, string[] propNames, GLib.Value[] propVals)
- {
- for (int n=0; n<propNames.Length; n++) {
- foreach (ItemGroup grp in klass.ItemGroups) {
- foreach (ItemDescriptor it in grp) {
- if (it is TypedPropertyDescriptor) {
- TypedPropertyDescriptor prop = (TypedPropertyDescriptor)it;
- if (prop.GladeName == propNames[n]) {
- prop.SetValue (widget, propVals[n].Val);
- }
- }
- }
- }
- }
- }
-
-
- static void SetOverrideProperties (ObjectWrapper wrapper, Hashtable overrideProps)
- {
- foreach (TypedPropertyDescriptor prop in overrideProps.Keys) {
- XmlElement prop_elem = overrideProps[prop] as XmlElement;
-
- try {
- GLib.Value value = ParseProperty (prop.ParamSpec, prop.PropertyType, prop_elem.InnerText);
- prop.SetValue (wrapper.Wrapped, value.Val);
- } catch {
- throw new GladeException ("Could not parse property", wrapper.GetType ().ToString (), wrapper is Stetic.Wrapper.Container.ContainerChild, prop.GladeName, prop_elem.InnerText);
- }
- }
- }
-
- static void MarkTranslatables (object obj, Hashtable props)
- {
- foreach (PropertyDescriptor prop in props.Keys) {
- if (!prop.Translatable)
- continue;
-
- XmlElement prop_elem = props[prop] as XmlElement;
- if (prop_elem.GetAttribute ("translatable") != "yes") {
- prop.SetTranslated (obj, false);
- continue;
- }
-
- prop.SetTranslated (obj, true);
- if (prop_elem.GetAttribute ("context") == "yes") {
- string strval = prop_elem.InnerText;
- int bar = strval.IndexOf ('|');
- if (bar != -1)
- prop.SetTranslationContext (obj, strval.Substring (0, bar));
- }
-
- if (prop_elem.HasAttribute ("comments"))
- prop.SetTranslationComment (obj, prop_elem.GetAttribute ("comments"));
- }
- }
-
- static public void SetPacking (Stetic.Wrapper.Container.ContainerChild wrapper, XmlElement child_elem)
- {
- XmlElement packing = child_elem["packing"];
- if (packing == null)
- return;
-
- Gtk.Container.ContainerChild cc = wrapper.Wrapped as Gtk.Container.ContainerChild;
-
- TypedClassDescriptor klass = wrapper.ClassDescriptor as TypedClassDescriptor;
- if (klass == null)
- throw new GladeException ("The widget class " + cc.GetType () + " is not supported by Glade");
-
- Hashtable rawProps, overrideProps;
- ExtractProperties (klass, packing, out rawProps, out overrideProps);
-
- string[] propNames;
- GLib.Value[] propVals;
- ParseProperties (cc.Parent.GetType (), true, rawProps.Values,
- out propNames, out propVals);
-
- for (int i = 0; i < propNames.Length; i++)
- cc.Parent.ChildSetProperty (cc.Child, propNames[i], propVals[i]);
- MarkTranslatables (cc, rawProps);
-
- SetOverrideProperties (wrapper, overrideProps);
- MarkTranslatables (cc, overrideProps);
- }
-
- internal static XmlElement CreatePacking (XmlDocument doc, Stetic.Wrapper.Container.ContainerChild childwrapper)
- {
- XmlElement packing_elem = doc.CreateElement ("packing");
- GetProps (childwrapper, packing_elem);
- return packing_elem;
- }
-
- static string PropToString (ObjectWrapper wrapper, TypedPropertyDescriptor prop)
- {
- object value;
-
- if (!prop.GladeOverride) {
- Stetic.Wrapper.Container.ContainerChild ccwrap = wrapper as Stetic.Wrapper.Container.ContainerChild;
- GLib.Value gval;
-
- if (ccwrap != null) {
- Gtk.Container.ContainerChild cc = (Gtk.Container.ContainerChild)ccwrap.Wrapped;
- gval = new GLib.Value ((GLib.GType) prop.PropertyType);
- gtk_container_child_get_property (cc.Parent.Handle, cc.Child.Handle, prop.GladeName, ref gval);
- } else {
- Gtk.Widget widget = wrapper.Wrapped as Gtk.Widget;
- gval = new GLib.Value (widget, prop.GladeName);
- g_object_get_property (widget.Handle, prop.GladeName, ref gval);
- }
- value = gval.Val;
- } else
- value = prop.GetValue (wrapper.Wrapped);
- if (value == null)
- return null;
-
- // If the property has its default value, we don't need to write it
- if (prop.HasDefault && prop.ParamSpec.IsDefaultValue (value))
- return null;
-
- if (value is Gtk.Adjustment) {
- Gtk.Adjustment adj = value as Gtk.Adjustment;
- return String.Format ("{0:G} {1:G} {2:G} {3:G} {4:G} {5:G}",
- adj.Value, adj.Lower, adj.Upper,
- adj.StepIncrement, adj.PageIncrement,
- adj.PageSize);
- } else if (value is Enum && prop.ParamSpec != null) {
- IntPtr klass = g_type_class_ref (((GLib.GType)prop.PropertyType).Val);
-
- if (prop.PropertyType.IsDefined (typeof (FlagsAttribute), false)) {
- System.Text.StringBuilder sb = new System.Text.StringBuilder ();
- uint val = (uint)System.Convert.ChangeType (value, typeof (uint));
-
- while (val != 0) {
- IntPtr flags_value = g_flags_get_first_value (klass, val);
- if (flags_value == IntPtr.Zero)
- break;
- IntPtr fval = Marshal.ReadIntPtr (flags_value);
- val &= ~(uint)fval;
-
- IntPtr name = Marshal.ReadIntPtr (flags_value, Marshal.SizeOf (typeof (IntPtr)));
- if (name != IntPtr.Zero) {
- if (sb.Length != 0)
- sb.Append ('|');
- sb.Append (GLib.Marshaller.Utf8PtrToString (name));
- }
- }
-
- g_type_class_unref (klass);
- return sb.ToString ();
- } else {
- int val = (int)System.Convert.ChangeType (value, typeof (int));
- IntPtr enum_value = g_enum_get_value (klass, val);
- g_type_class_unref (klass);
-
- IntPtr name = Marshal.ReadIntPtr (enum_value, Marshal.SizeOf (typeof (IntPtr)));
- return GLib.Marshaller.Utf8PtrToString (name);
- }
- } else if (value is bool)
- return (bool)value ? "True" : "False";
- else
- return value.ToString ();
- }
-
- static public XmlElement ExportWidget (ObjectWrapper wrapper, XmlDocument doc)
- {
- XmlElement elem = doc.CreateElement ("widget");
- elem.SetAttribute ("class", wrapper.ClassDescriptor.CName);
- elem.SetAttribute ("id", ((Gtk.Widget)wrapper.Wrapped).Name);
-
- GetProps (wrapper, elem);
- GetSignals (wrapper, elem);
- return elem;
- }
-
- static public void GetProps (ObjectWrapper wrapper, XmlElement parent_elem)
- {
- ClassDescriptor klass = wrapper.ClassDescriptor;
-
- foreach (ItemGroup group in klass.ItemGroups) {
- foreach (ItemDescriptor item in group) {
- TypedPropertyDescriptor prop = item as TypedPropertyDescriptor;
- if (prop == null)
- continue;
- prop = prop.GladeProperty;
- if (prop.GladeName == null)
- continue;
- if (!prop.VisibleFor (wrapper.Wrapped))
- continue;
-
- string val = PropToString (wrapper, prop);
- if (val == null)
- continue;
-
- XmlElement prop_elem = parent_elem.OwnerDocument.CreateElement ("property");
- prop_elem.SetAttribute ("name", prop.GladeName);
- if (val.Length > 0)
- prop_elem.InnerText = val;
-
- if (prop.Translatable && prop.IsTranslated (wrapper.Wrapped)) {
- prop_elem.SetAttribute ("translatable", "yes");
- if (prop.TranslationContext (wrapper.Wrapped) != null) {
- prop_elem.SetAttribute ("context", "yes");
- prop_elem.InnerText = prop.TranslationContext (wrapper.Wrapped) + "|" + prop_elem.InnerText;
- }
- if (prop.TranslationComment (wrapper.Wrapped) != null)
- prop_elem.SetAttribute ("comments", prop.TranslationComment (wrapper.Wrapped));
- }
-
- parent_elem.AppendChild (prop_elem);
- }
- }
- }
-
- static public void GetSignals (ObjectWrapper wrapper, XmlElement parent_elem)
- {
- Stetic.Wrapper.Widget ob = wrapper as Stetic.Wrapper.Widget;
- if (ob == null) return;
-
- foreach (Signal signal in ob.Signals) {
- if (((TypedSignalDescriptor)signal.SignalDescriptor).GladeName == null)
- continue;
- if (!signal.SignalDescriptor.VisibleFor (wrapper.Wrapped))
- continue;
-
- XmlElement signal_elem = parent_elem.OwnerDocument.CreateElement ("signal");
- signal_elem.SetAttribute ("name", ((TypedSignalDescriptor)signal.SignalDescriptor).GladeName);
- signal_elem.SetAttribute ("handler", signal.Handler);
- if (signal.After)
- signal_elem.SetAttribute ("after", "yes");
- parent_elem.AppendChild (signal_elem);
- }
- }
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_type_fundamental (IntPtr gtype);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_type_class_ref (IntPtr gtype);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_type_class_unref (IntPtr klass);
-
- [DllImport("glibsharpglue-2")]
- static extern IntPtr gtksharp_object_newv (IntPtr gtype, int n_params, string[] names, GLib.Value[] vals);
-
- [DllImport("libgtk-win32-2.0-0.dll")]
- static extern void gtk_object_sink (IntPtr raw);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern void g_object_get_property (IntPtr obj, string name, ref GLib.Value val);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern void g_object_set_property (IntPtr obj, string name, ref GLib.Value val);
-
- [DllImport("libgtk-win32-2.0-0.dll")]
- static extern void gtk_container_child_get_property (IntPtr parent, IntPtr child, string name, ref GLib.Value val);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_enum_get_value_by_name (IntPtr enum_class, string name);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_enum_get_value (IntPtr enum_class, int val);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_flags_get_value_by_name (IntPtr flags_class, string nick);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_flags_get_first_value (IntPtr flags_class, uint val);
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IDesignArea.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/IDesignArea.cs
deleted file mode 100644
index 7fb86f1beb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IDesignArea.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public interface IDesignArea
- {
- IObjectSelection SetSelection (Gtk.Widget widget, object selectedInstance);
- IObjectSelection SetSelection (Gtk.Widget widget, object selectedInstance, bool allowDrag);
- void ResetSelection (Gtk.Widget widget);
- bool IsSelected (Gtk.Widget widget);
- IObjectSelection GetSelection ();
- IObjectSelection GetSelection (Gtk.Widget widget);
-
- void AddWidget (Gtk.Widget w, int x, int y);
- void RemoveWidget (Gtk.Widget w);
- void MoveWidget (Gtk.Widget w, int x, int y);
- Gdk.Rectangle GetCoordinates (Gtk.Widget w);
-
- event EventHandler SelectionChanged;
- }
-
- public delegate void DragDelegate (Gdk.EventMotion evt, int dx, int dy);
-
- public interface IObjectViewer
- {
- object TargetObject { get; set; }
- }
-
- public interface IObjectSelection: IDisposable
- {
- Gtk.Widget Widget { get; }
- object DataObject { get; }
- bool AllowDrag {get; set; }
-
- event DragDelegate Drag;
- event EventHandler Disposed;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IEditableObject.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/IEditableObject.cs
deleted file mode 100644
index dd2e54c5df..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IEditableObject.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public interface IEditableObject
- {
- bool CanCopy { get; }
- bool CanCut { get; }
- bool CanPaste { get; }
- bool CanDelete { get; }
-
- void Copy ();
- void Cut ();
- void Paste ();
- void Delete ();
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IProject.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/IProject.cs
deleted file mode 100644
index 03e1c4c477..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IProject.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-
-namespace Stetic
-{
- public interface IProject
- {
- //string FileName { get; }
- string FolderName { get; }
- Gtk.Widget[] Toplevels { get; }
- Gtk.Widget GetWidget (string name);
- Gtk.Widget Selection { get; set; }
- Wrapper.ActionGroupCollection ActionGroups { get; }
- ProjectIconFactory IconFactory { get; }
- string ImagesRootPath { get; }
- string TargetGtkVersion { get; }
-// bool Modified { get; set; }
- IResourceProvider ResourceProvider { get; set; }
-
- void PopupContextMenu (Stetic.Wrapper.Widget wrapper);
- void PopupContextMenu (Placeholder ph);
- void AddWindow (Gtk.Window window);
- string ImportFile (string filePath);
-
- event Wrapper.WidgetEventHandler SelectionChanged;
-
- void NotifyObjectChanged (ObjectWrapperEventArgs args);
- void NotifyNameChanged (Stetic.Wrapper.WidgetNameChangedArgs args);
- void NotifySignalAdded (SignalEventArgs args);
- void NotifySignalRemoved (SignalEventArgs args);
- void NotifySignalChanged (SignalChangedEventArgs args);
- void NotifyWidgetContentsChanged (Wrapper.Widget w);
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IPropertyEditor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/IPropertyEditor.cs
deleted file mode 100644
index f0cb14a48b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IPropertyEditor.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-
-namespace Stetic
-{
- // Property editors must be Gtk Widgets and implement this interface
-
- public interface IPropertyEditor: IDisposable
- {
- // Called once to initialize the editor.
- void Initialize (PropertyDescriptor descriptor);
-
- // Called when the object to be edited changes.
- void AttachObject (object obj);
-
- // Gets/Sets the value of the editor. If the editor supports
- // several value types, it is the responsibility of the editor
- // to return values with the expected type.
- object Value { get; set; }
-
- // To be fired when the edited value changes.
- event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IRadioGroupManager.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/IRadioGroupManager.cs
deleted file mode 100644
index fe0cdec704..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IRadioGroupManager.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-
-using System;
-using System.Collections;
-
-namespace Stetic
-{
- public delegate void GroupsChangedDelegate ();
-
- public interface IRadioGroupManagerProvider
- {
- IRadioGroupManager GetGroupManager ();
- }
-
- public interface IRadioGroupManager
- {
- event GroupsChangedDelegate GroupsChanged;
- IEnumerable GroupNames { get; }
- void Rename (string oldName, string newName);
- void Add (string group);
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IResourceProvider.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/IResourceProvider.cs
deleted file mode 100644
index 3394cf77a6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/IResourceProvider.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-
-using System;
-using System.IO;
-
-namespace Stetic
-{
- public interface IResourceProvider
- {
- ResourceInfo[] GetResources ();
- Stream GetResourceStream (string resourceName);
- ResourceInfo AddResource (string fileName);
- void RemoveResource (string resourceName);
- }
-
- public delegate string MimeResolverDelegate (string url);
-
- [Serializable]
- public class ResourceInfo
- {
- public static MimeResolverDelegate MimeResolver;
-
- string name;
- string fileName;
- string mimeType;
-
- public ResourceInfo (string name, string fileName): this (name, fileName, null)
- {
- }
-
- public ResourceInfo (string name, string fileName, string mimeType)
- {
- this.name = name;
- this.fileName = fileName;
- this.mimeType = mimeType;
- }
-
- public string Name {
- get { return name; }
- }
-
- public string FileName {
- get { return fileName; }
- }
-
- public string MimeType {
- get {
- if (mimeType == null) {
- if (MimeResolver == null)
- return null;
-
- if (File.Exists (fileName)) {
- mimeType = MimeResolver (fileName);
- } else {
- // Guess the mime type creating a temp file with the same extension
- string fn = Path.GetTempFileName ();
- string ext = Path.GetExtension (fileName);
- int n=0;
- while (File.Exists (fn + n + ext))
- n++;
- string tname = fn + n + ext;
- File.Move (fn, tname);
- mimeType = MimeResolver (tname);
- File.Delete (tname);
- }
- if (mimeType == null || mimeType == "")
- mimeType = "text";
- }
- return mimeType;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ImageInfo.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ImageInfo.cs
deleted file mode 100644
index d21e46c0f5..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ImageInfo.cs
+++ /dev/null
@@ -1,215 +0,0 @@
-
-using System;
-using System.IO;
-using System.CodeDom;
-
-namespace Stetic
-{
- public enum ImageSource
- {
- Theme,
- Resource,
- File
- }
-
- public class ImageInfo
- {
- ImageSource source;
- string name;
- Gtk.IconSize size;
- Gdk.Pixbuf image;
-
- private ImageInfo ()
- {
- }
-
- public string Label {
- get {
- if (source == ImageSource.File)
- return Path.GetFileName (name);
- else
- return name;
- }
- }
-
- public string Name {
- get { return name; }
- }
-
- public Gtk.IconSize ThemeIconSize {
- get { return size; }
- }
-
- public ImageSource Source {
- get { return source; }
- }
-
- public override string ToString ()
- {
- if (source == ImageSource.Theme)
- return "stock:" + name + " " + size;
- else if (source == ImageSource.Resource)
- return "resource:" + name;
- else
- return "file:" + name;
- }
-
- public static ImageInfo FromResource (string resourceName)
- {
- ImageInfo info = new ImageInfo ();
- info.name = resourceName;
- info.source = ImageSource.Resource;
- return info;
- }
-
- public static ImageInfo FromTheme (string iconId, Gtk.IconSize size)
- {
- ImageInfo info = new ImageInfo ();
- info.name = iconId;
- info.size = size;
- info.source = ImageSource.Theme;
- return info;
- }
-
- public static ImageInfo FromFile (string file)
- {
- ImageInfo info = new ImageInfo ();
- info.name = file;
- info.source = ImageSource.File;
- return info;
- }
-
- public static ImageInfo FromString (string str)
- {
- ImageInfo info = new ImageInfo ();
- if (str.StartsWith ("resource:")) {
- info.source = ImageSource.Resource;
- info.name = str.Substring (9);
- } else if (str.StartsWith ("stock:")) {
- info.source = ImageSource.Theme;
- string[] s = str.Substring (6).Split (' ');
- if (s.Length != 2)
- return null;
- info.name = s[0];
- info.size = (Gtk.IconSize) Enum.Parse (typeof(Gtk.IconSize), s[1]);
- } else if (str.StartsWith ("file:")) {
- info.source = ImageSource.File;
- info.name = str.Substring (5);
- } else
- return null;
- return info;
- }
-
- public Gdk.Pixbuf GetImage (IProject project)
- {
- if (image != null)
- return image;
-
- switch (source) {
- case ImageSource.Resource:
- if (project.ResourceProvider == null)
- return null;
- System.IO.Stream s = project.ResourceProvider.GetResourceStream (name);
- if (s == null)
- return null;
- try {
- return image = new Gdk.Pixbuf (s);
- } catch {
- // Not a valid image
- return WidgetUtils.MissingIcon;
- }
-
- case ImageSource.Theme:
- return image = WidgetUtils.LoadIcon (name, size);
-
- case ImageSource.File:
- try {
- string file = Path.Combine (project.ImagesRootPath, name);
- return image = new Gdk.Pixbuf (file);
- } catch {
- return WidgetUtils.MissingIcon;
- }
- }
- return null;
- }
-
- public Gdk.Pixbuf GetThumbnail (IProject project, int thumbnailSize)
- {
- Gdk.Pixbuf pix = GetImage (project);
- if (pix == null)
- return null;
-
- if (pix.Width >= pix.Height && pix.Width > thumbnailSize) {
- return ScaleImage (pix, thumbnailSize, thumbnailSize);
- } else if (pix.Height > pix.Width && pix.Height > thumbnailSize) {
- return ScaleImage (pix, thumbnailSize, thumbnailSize);
- }
- return pix;
- }
-
- public Gdk.Pixbuf GetScaledImage (IProject project, Gtk.IconSize size)
- {
- int w, h;
- Gtk.Icon.SizeLookup (size, out w, out h);
- return GetScaledImage (project, w, h);
- }
-
- public Gdk.Pixbuf GetScaledImage (IProject project, int width, int height)
- {
- Gdk.Pixbuf pix = GetImage (project);
- if (pix == null)
- return null;
- else
- return ScaleImage (pix, width, height);
- }
-
- Gdk.Pixbuf ScaleImage (Gdk.Pixbuf pix, int width, int height)
- {
- if ((pix.Width - width) > (pix.Height - height)) {
- if (pix.Width != width) {
- float prop = (float) pix.Height / (float) pix.Width;
- return pix.ScaleSimple (width, (int)(width * prop), Gdk.InterpType.Bilinear);
- }
- } else {
- if (pix.Height != height) {
- float prop = (float) pix.Width / (float) pix.Height;
- return pix.ScaleSimple ((int)(height * prop), height, Gdk.InterpType.Bilinear);
- }
- }
- return pix;
- }
-
- public CodeExpression ToCodeExpression (GeneratorContext ctx)
- {
- switch (source) {
- case ImageSource.Resource:
- return new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (typeof(Gdk.Pixbuf), CodeTypeReferenceOptions.GlobalReference)),
- "LoadFromResource",
- new CodePrimitiveExpression (name)
- );
-
- case ImageSource.Theme:
- return ctx.GenerateLoadPixbuf (name, size);
-
- case ImageSource.File:
- return new CodeObjectCreateExpression (
- typeof(Gdk.Pixbuf).ToGlobalTypeRef (),
- new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (typeof(System.IO.Path), CodeTypeReferenceOptions.GlobalReference)),
- "Combine",
- new CodePropertyReferenceExpression (
- new CodePropertyReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (typeof(AppDomain), CodeTypeReferenceOptions.GlobalReference)),
- "CurrentDomain"
- ),
- "BaseDirectory"
- ),
- new CodePrimitiveExpression (name)
- )
- );
- }
- return new CodePrimitiveExpression (null);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemDescriptor.cs
deleted file mode 100644
index a64644eb06..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemDescriptor.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-using System.Reflection;
-
-namespace Stetic
-{
- [Serializable]
- public abstract class ItemDescriptor
- {
- [NonSerialized]
- ArrayList deps;
-
- [NonSerialized]
- ArrayList visdeps;
-
- [NonSerialized]
- bool isInternal;
-
- [NonSerialized]
- ClassDescriptor klass;
-
- protected string targetGtkVersion;
-
- protected ItemDescriptor () {}
-
- protected ItemDescriptor (XmlElement elem, ItemGroup group, ClassDescriptor klass)
- {
- this.klass = klass;
- isInternal = elem.HasAttribute ("internal");
- deps = AddSubprops (elem.SelectNodes ("./disabled-if"), group, klass);
- visdeps = AddSubprops (elem.SelectNodes ("./invisible-if"), group, klass);
- targetGtkVersion = elem.GetAttribute ("gtk-version");
- if (targetGtkVersion.Length == 0)
- targetGtkVersion = null;
- }
-
- ArrayList AddSubprops (XmlNodeList nodes, ItemGroup group, ClassDescriptor klass)
- {
- ArrayList list = null;
-
- // Sub-properties can have a name+value (which checks for the value of a
- // property) or a method name, which should return true if the item has
- // to be disabled/hidden.
-
- foreach (XmlElement elem in nodes) {
- string name = elem.GetAttribute ("name");
- if (name.Length > 0) {
- string value = elem.GetAttribute ("value");
-
- PropertyDescriptor prop = (PropertyDescriptor)group[name];
- if (prop == null)
- prop = (PropertyDescriptor)klass[name];
- if (prop == null)
- throw new ArgumentException ("Bad sub-prop " + name);
- if (list == null)
- list = new ArrayList ();
-
- DepInfo info = new DepInfo ();
- info.Property = prop;
- info.Value = prop.StringToValue (value);
- list.Add (info);
- } else if ((name = elem.GetAttribute ("check")).Length > 0) {
- DepInfo info = new DepInfo ();
- info.CheckName = name;
- if (list == null)
- list = new ArrayList ();
- list.Add (info);
- } else {
- throw new ArgumentException ("Bad sub-prop");
- }
- }
- return list;
- }
-
- // The property's display name
- public abstract string Name { get; }
-
- public virtual string TargetGtkVersion {
- get {
- if (targetGtkVersion == null)
- return klass.TargetGtkVersion;
- else
- return targetGtkVersion;
- }
- }
-
- public bool SupportsGtkVersion (string targetVersion)
- {
- return WidgetUtils.CompareVersions (TargetGtkVersion, targetVersion) >= 0;
- }
-
- public bool HasDependencies {
- get {
- return deps != null || visdeps != null;
- }
- }
-
- public bool EnabledFor (object obj)
- {
- if (deps == null)
- return true;
-
- foreach (DepInfo dep in deps) {
- if (dep.Check (obj))
- return false;
- }
- return true;
- }
-
- public bool HasVisibility {
- get {
- return visdeps != null;
- }
- }
-
- public bool VisibleFor (object obj)
- {
- if (visdeps == null)
- return true;
-
- foreach (DepInfo dep in visdeps) {
- if (dep.Check (obj))
- return false;
- }
- return true;
- }
-
- public bool IsInternal {
- get {
- return isInternal;
- }
- }
-
- public ClassDescriptor ClassDescriptor {
- get { return klass; }
- }
-
- class DepInfo
- {
- public string CheckName;
- public PropertyDescriptor Property;
- public object Value;
-
- public bool Check (object obj)
- {
- if (Property != null) {
- object depValue = Property.GetValue (obj);
- return Value.Equals (depValue);
- } else {
- object wrapper = ObjectWrapper.Lookup (obj);
- object res = wrapper.GetType ().InvokeMember (CheckName, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, wrapper, null);
- return !(bool) res;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemGroup.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemGroup.cs
deleted file mode 100644
index f66a9d5603..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemGroup.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Xml;
-
-namespace Stetic {
- public class ItemGroup : IEnumerable
- {
- public static ItemGroup Empty;
-
- string label, name;
- ListDictionary items = new ListDictionary ();
- ClassDescriptor declaringType;
-
- static ItemGroup ()
- {
- Empty = new ItemGroup ();
- }
-
- private ItemGroup ()
- {
- }
-
- public ItemGroup (XmlElement elem, ClassDescriptor klass)
- {
- declaringType = klass;
- label = elem.GetAttribute ("label");
- name = elem.GetAttribute ("name");
-
- XmlNodeList nodes = elem.SelectNodes ("property | command | signal");
- for (int i = 0; i < nodes.Count; i++) {
- XmlElement item = (XmlElement)nodes[i];
- string refname = item.GetAttribute ("ref");
- if (refname != "") {
- if (refname.IndexOf ('.') != -1) {
- ItemDescriptor desc = (ItemDescriptor) Registry.LookupItem (refname);
- items.Add (desc.Name, desc);
- } else {
- ItemDescriptor desc = (ItemDescriptor) klass[refname];
- items.Add (desc.Name, desc);
- }
- continue;
- }
-
- ItemDescriptor idesc = klass.CreateItemDescriptor ((XmlElement)item, this);
- if (idesc != null)
- items.Add (idesc.Name, idesc);
- }
- }
-
- public string Label {
- get {
- return label;
- }
- }
-
- public string Name {
- get {
- return name;
- }
- }
-
- public IEnumerator GetEnumerator ()
- {
- return items.Values.GetEnumerator ();
- }
-
- public ItemDescriptor this [string name] {
- get {
- return (ItemDescriptor) items [name];
- }
- }
-
- public ClassDescriptor DeclaringType {
- get { return declaringType; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemGroupCollection.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemGroupCollection.cs
deleted file mode 100644
index 9fb9296315..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ItemGroupCollection.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-
-using System;
-using System.Collections;
-
-namespace Stetic
-{
- public class ItemGroupCollection: CollectionBase
- {
- public void Add (ItemGroup group)
- {
- List.Add (group);
- }
-
- public ItemGroup this [int n]
- {
- get {
- return (ItemGroup) List [n];
- }
- }
-
- public ItemGroup this [string name]
- {
- get {
- for (int n=0; n<List.Count; n++) {
- if (((ItemGroup) List [n]).Name == name)
- return (ItemGroup) List [n];
- }
- return null;
- }
- }
-
- public ItemDescriptor GetItem (string name)
- {
- for (int n=0; n<List.Count; n++) {
- ItemDescriptor item = ((ItemGroup) List [n])[name];
- if (item != null)
- return item;
- }
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Makefile.am b/main/src/addins/MonoDevelop.GtkCore2/libstetic/Makefile.am
deleted file mode 100644
index c9cc87438f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-include $(top_srcdir)/xbuild.include
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/NoGuiDispatchAttribute.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/NoGuiDispatchAttribute.cs
deleted file mode 100644
index e1ad777512..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/NoGuiDispatchAttribute.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public class NoGuiDispatchAttribute: Attribute
- {
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectReader.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectReader.cs
deleted file mode 100644
index 2f463d1d52..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectReader.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-
-using System;
-using System.Collections;
-using System.Xml;
-
-namespace Stetic
-{
- public class ObjectReader
- {
- FileFormat format;
- IProject proj;
- internal ArrayList GladeChildStack = new ArrayList ();
-
- public ObjectReader (IProject proj, FileFormat format)
- {
- this.format = format;
- this.proj = proj;
- }
-
- public FileFormat Format {
- get { return format; }
- }
-
- public IProject Project {
- get { return proj; }
- }
-
- public virtual ObjectWrapper ReadObject (XmlElement elem, ObjectWrapper root)
- {
- return Stetic.ObjectWrapper.ReadObject (this, elem, root);
- }
-
- public virtual void ReadExistingObject (ObjectWrapper wrapper, XmlElement elem)
- {
- Stetic.ObjectWrapper.ReadExistingObject (this, elem, wrapper);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWrapper.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWrapper.cs
deleted file mode 100644
index 6225267e24..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWrapper.cs
+++ /dev/null
@@ -1,482 +0,0 @@
-using System;
-using System.Collections;
-using System.CodeDom;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Xml;
-
-namespace Stetic {
-
- public enum FileFormat {
- Native,
- Glade
- }
-
- public abstract class ObjectWrapper : MarshalByRefObject, IDisposable
- {
- static Hashtable wrappers = new Hashtable ();
-
- protected IProject proj;
- protected object wrapped;
- protected ClassDescriptor classDescriptor;
- SignalCollection signals;
- internal Hashtable translationInfo;
- Hashtable extendedData;
- bool loading;
- IObjectFrontend frontend;
- bool disposed;
-
- // This id is used by the undo methods to identify an object.
- // This id is not stored, since it's used only while the widget is being
- // edited in the designer
- string undoId = WidgetUtils.GetUndoId ();
-
- UndoManager undoManager;
- static UndoManager defaultUndoManager = new UndoManager (true);
-
- public ObjectWrapper ()
- {
- undoManager = defaultUndoManager;
- }
-
- public SignalCollection Signals {
- get {
- if (signals == null)
- signals = new SignalCollection (this);
- return signals;
- }
- }
-
- public UndoManager UndoManager {
- get { return GetUndoManagerInternal (); }
- internal set { undoManager = value; }
- }
-
- // Called the get a diff of changes since the last call to GetUndoDiff().
- // The returned object can be used to restore the object status by calling
- // ApplyUndoRedoDiff. The implementation can use the UndoManager object to
- // store status information.
- public virtual object GetUndoDiff ()
- {
- return null;
- }
-
- // Called to apply a set of changes to the object. It returns
- // a set of changes which can be used to reverse the operation.
- public virtual object ApplyUndoRedoDiff (object diff)
- {
- return null;
- }
-
- public string UndoId {
- get { return undoId; }
- internal set { undoId = value; }
- }
-
- public virtual ObjectWrapper FindObjectByUndoId (string id)
- {
- if (undoId == id)
- return this;
- else
- return null;
- }
-
- internal virtual UndoManager GetUndoManagerInternal ()
- {
- return undoManager;
- }
-
- internal protected bool Loading {
- get { return loading; }
- set { loading = value; }
- }
-
- public IObjectFrontend Frontend {
- [NoGuiDispatch]
- get { return frontend; }
- [NoGuiDispatch]
- set {
- if (disposed)
- throw new InvalidOperationException ("Can't bind component to disposed wrapper");
- if (frontend != null)
- frontend.Dispose ();
- frontend = value;
- }
- }
-
- public IDictionary ExtendedData {
- get {
- if (extendedData == null)
- extendedData = new Hashtable ();
- return extendedData;
- }
- }
-
- public void AttachDesigner (IDesignArea designer)
- {
- OnDesignerAttach (designer);
- }
-
- public void DetachDesigner (IDesignArea designer)
- {
- OnDesignerDetach (designer);
- }
-
- public virtual void Wrap (object obj, bool initialized)
- {
- this.wrapped = obj;
- wrappers [GetIndentityObject (obj)] = this;
- }
-
- public virtual void Dispose ()
- {
- if (IsDisposed)
- return;
-
- if (Disposed != null)
- Disposed (this, EventArgs.Empty);
- disposed = true;
- if (frontend != null)
- frontend.Dispose ();
- frontend = null;
- if (wrapped != null)
- wrappers.Remove (GetIndentityObject (wrapped));
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- }
-
- public bool IsDisposed {
- [NoGuiDispatch]
- get { return disposed; }
- }
-
- public static ObjectWrapper Create (IProject proj, object wrapped, ObjectWrapper root)
- {
- ClassDescriptor klass = Registry.LookupClassByName (wrapped.GetType ().FullName);
- ObjectWrapper wrapper = klass.CreateWrapper ();
- if (root != null) {
- wrapper.RootWrapperName = (root.RootWrapperName != null) ? root.RootWrapperName : root.Name;
- }
- wrapper.Loading = true;
- wrapper.proj = proj;
- wrapper.classDescriptor = klass;
- wrapper.Wrap (wrapped, true);
- wrapper.OnWrapped ();
- wrapper.Loading = false;
- return wrapper;
- }
-
- internal static void Bind (IProject proj, ClassDescriptor klass, ObjectWrapper wrapper, object wrapped, bool initialized)
- {
- wrapper.proj = proj;
- wrapper.classDescriptor = klass;
- wrapper.Wrap (wrapped, initialized);
- wrapper.OnWrapped ();
- }
-
- public virtual void Read (ObjectReader reader, XmlElement element)
- {
- throw new System.NotImplementedException ();
- }
-
- public virtual XmlElement Write (ObjectWriter writer)
- {
- throw new System.NotImplementedException ();
- }
-
- public static ObjectWrapper ReadObject (ObjectReader reader, XmlElement elem, ObjectWrapper root)
- {
- string className = elem.GetAttribute ("class");
- ClassDescriptor klass;
- if (reader.Format == FileFormat.Native)
- klass = Registry.LookupClassByName (className);
- else
- klass = Registry.LookupClassByCName (className);
-
- if (klass == null) {
- ErrorWidget we = new ErrorWidget (className, elem.GetAttribute ("id"));
- ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we, null);
- wrap.Read (reader, elem);
- return wrap;
- }
- if (!klass.SupportsGtkVersion (reader.Project.TargetGtkVersion)) {
- ErrorWidget we = new ErrorWidget (className, klass.TargetGtkVersion, reader.Project.TargetGtkVersion, elem.GetAttribute ("id"));
- ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we, null);
- wrap.Read (reader, elem);
- return wrap;
- }
-
- ObjectWrapper wrapper = klass.CreateWrapper ();
- if (root != null) {
- if (root.RootWrapperName != null) {
- wrapper.RootWrapperName = root.RootWrapperName;
- }
- }
- wrapper.classDescriptor = klass;
- wrapper.proj = reader.Project;
- return ReadExistingObject (reader, elem, wrapper);
- }
-
- public static ObjectWrapper ReadExistingObject (ObjectReader reader, XmlElement elem, ObjectWrapper wrapper)
- {
- try {
- wrapper.OnBeginRead (reader.Format);
- wrapper.Read (reader, elem);
- return wrapper;
- }
- catch (Exception ex) {
- Console.WriteLine (ex);
- ErrorWidget we = new ErrorWidget (ex, elem.GetAttribute ("id"));
- ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we, null);
- wrap.Read (reader, elem);
- return wrap;
- }
- finally {
- wrapper.OnEndRead (reader.Format);
- }
- }
-
- internal void GenerateInitCode (GeneratorContext ctx, CodeExpression var)
- {
- // Set the value for initialization properties. The value for those properties is
- // usually set in the constructor, but top levels are created by the user, so
- // those properties need to be explicitely set in the Gui.Build method.
- foreach (PropertyDescriptor prop in ClassDescriptor.InitializationProperties) {
- GeneratePropertySet (ctx, var, prop);
- }
- }
-
- internal protected virtual void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- // Write the widget properties
- foreach (ItemGroup group in ClassDescriptor.ItemGroups) {
- foreach (ItemDescriptor item in group) {
- if (!item.SupportsGtkVersion (Project.TargetGtkVersion))
- continue;
- PropertyDescriptor prop = item as PropertyDescriptor;
- if (prop == null || !prop.IsRuntimeProperty)
- continue;
- if (ClassDescriptor.InitializationProperties != null && Array.IndexOf (ClassDescriptor.InitializationProperties, prop) != -1)
- continue;
- GeneratePropertySet (ctx, var, prop);
- }
- }
- }
-
- internal protected virtual void GeneratePostBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- }
-
- internal protected virtual CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- if (ClassDescriptor.InitializationProperties != null) {
- CodeExpression[] paramters = new CodeExpression [ClassDescriptor.InitializationProperties.Length];
- for (int n=0; n < paramters.Length; n++) {
- PropertyDescriptor prop = ClassDescriptor.InitializationProperties [n];
- paramters [n] = ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType, prop.Translatable && prop.IsTranslated (Wrapped));
- }
- return new CodeObjectCreateExpression (WrappedTypeName.ToGlobalTypeRef (), paramters);
- } else
- return new CodeObjectCreateExpression (WrappedTypeName.ToGlobalTypeRef ());
- }
-
- protected virtual void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- object oval = prop.GetValue (Wrapped);
- if (oval == null || (prop.HasDefault && prop.IsDefaultValue (oval)))
- return;
-
- CodeExpression val = ctx.GenerateValue (oval, prop.RuntimePropertyType, prop.Translatable && prop.IsTranslated (Wrapped));
- CodeExpression cprop;
-
- TypedPropertyDescriptor tprop = prop as TypedPropertyDescriptor;
- if (tprop == null || tprop.GladeProperty == prop) {
- cprop = new CodePropertyReferenceExpression (var, prop.Name);
- } else {
- cprop = new CodePropertyReferenceExpression (var, tprop.GladeProperty.Name);
- cprop = new CodePropertyReferenceExpression (cprop, prop.Name);
- }
- ctx.Statements.Add (new CodeAssignStatement (cprop, val));
- }
-
- public static ObjectWrapper Lookup (object obj)
- {
- if (obj == null)
- return null;
- else
- return wrappers [GetIndentityObject (obj)] as Stetic.ObjectWrapper;
- }
-
- public object Wrapped {
- get {
- return wrapped;
- }
- }
-
- public IProject Project {
- get {
- return proj;
- }
- }
-
- public ClassDescriptor ClassDescriptor {
- get { return classDescriptor; }
- }
-
- public virtual string WrappedTypeName {
- get { return classDescriptor.WrappedTypeName; }
- }
-
- public void NotifyChanged ()
- {
- if (UndoManager.CanNotifyChanged (this))
- OnObjectChanged (new ObjectWrapperEventArgs (this));
- }
-
- internal void FireObjectChangedEvent ()
- {
- OnObjectChanged (new ObjectWrapperEventArgs (this));
- }
-
- public abstract string Name { get; set; }
-
- public string RootWrapperName { get; protected set; }
-
- static object GetIndentityObject (object ob)
- {
- if (ob is Gtk.Container.ContainerChild) {
- // We handle ContainerChild in a special way here since
- // the Gtk.Container indexer always returns a new ContainerChild
- // instance. We register its wrapper using ContainerChildHashItem
- // to make sure that two different instance of the same ContainerChild
- // can be found equal.
- ContainerChildHashItem p = new ContainerChildHashItem ();
- p.ContainerChild = (Gtk.Container.ContainerChild) ob;
- return p;
- }
- else
- return ob;
- }
-
- public delegate void WrapperNotificationDelegate (object obj, string propertyName);
-
- public event WrapperNotificationDelegate Notify;
- public event SignalEventHandler SignalAdded;
- public event SignalEventHandler SignalRemoved;
- public event SignalChangedEventHandler SignalChanged;
- public event EventHandler Disposed;
-
- // Fired when any information of the object changes.
- public event ObjectWrapperEventHandler ObjectChanged;
-
- protected virtual void OnBeginRead (FileFormat format)
- {
- loading = true;
- }
-
- protected virtual void OnEndRead (FileFormat format)
- {
- loading = false;
- }
-
- internal protected virtual void OnObjectChanged (ObjectWrapperEventArgs args)
- {
- if (frontend != null)
- frontend.NotifyChanged ();
- if (!Loading) {
- if (proj != null)
- proj.NotifyObjectChanged (args);
- if (ObjectChanged != null)
- ObjectChanged (this, args);
- }
- }
-
- protected virtual void EmitNotify (string propertyName)
- {
- if (!Loading) {
- NotifyChanged ();
- if (!Loading && Notify != null)
- Notify (this, propertyName);
- }
- }
-
- internal protected virtual void OnSignalAdded (SignalEventArgs args)
- {
- OnObjectChanged (args);
- if (!Loading) {
- if (proj != null)
- proj.NotifySignalAdded (args);
- if (SignalAdded != null)
- SignalAdded (this, args);
- }
- }
-
- internal protected virtual void OnSignalRemoved (SignalEventArgs args)
- {
- OnObjectChanged (args);
- if (!Loading) {
- if (proj != null)
- proj.NotifySignalRemoved (args);
- if (SignalRemoved != null)
- SignalRemoved (this, args);
- }
- }
-
- internal protected virtual void OnSignalChanged (SignalChangedEventArgs args)
- {
- OnObjectChanged (args);
- if (!Loading) {
- if (proj != null)
- proj.NotifySignalChanged (args);
- if (SignalChanged != null)
- SignalChanged (this, args);
- }
- }
-
- internal protected virtual void OnDesignerAttach (IDesignArea designer)
- {
- }
-
- internal protected virtual void OnDesignerDetach (IDesignArea designer)
- {
- }
-
- internal protected virtual void OnWrapped ()
- {
- }
-
- internal protected virtual void DropObject (string data, Gtk.Widget obj)
- {
- // Called by DND.Drop
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
- }
-
- // Wraps a ContainerChild, and properly implements GetHashCode() and Equals()
- struct ContainerChildHashItem
- {
- public Gtk.Container.ContainerChild ContainerChild;
-
- public override int GetHashCode ()
- {
- return ContainerChild.Parent.GetHashCode () + ContainerChild.Child.GetHashCode ();
- }
-
- public override bool Equals (object ob)
- {
- if (!(ob is ContainerChildHashItem))
- return false;
- ContainerChildHashItem ot = (ContainerChildHashItem) ob;
- return ot.ContainerChild.Child == ContainerChild.Child && ot.ContainerChild.Parent == ContainerChild.Parent;
- }
- }
-
- public interface IObjectFrontend: IDisposable
- {
- void NotifyChanged ();
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWrapperEventHandler.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWrapperEventHandler.cs
deleted file mode 100644
index a9645e3384..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWrapperEventHandler.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-
-namespace Stetic
-{
- public delegate void ObjectWrapperEventHandler (object sender, ObjectWrapperEventArgs args);
-
- public class ObjectWrapperEventArgs: EventArgs
- {
- ObjectWrapper objectWrapper;
-
- public ObjectWrapperEventArgs (ObjectWrapper objectWrapper)
- {
- this.objectWrapper = objectWrapper;
- }
-
- public ObjectWrapper Wrapper {
- get { return objectWrapper; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWriter.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWriter.cs
deleted file mode 100644
index cb2e7fd41f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ObjectWriter.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-
-using System;
-using System.Xml;
-using Stetic.Wrapper;
-
-namespace Stetic
-{
- public class ObjectWriter
- {
- XmlDocument doc;
- FileFormat format;
- bool createUndo;
-
- public ObjectWriter (XmlDocument doc, FileFormat format)
- {
- this.doc = doc;
- this.format = format;
- }
-
- public FileFormat Format {
- get { return format; }
- }
-
- public XmlDocument XmlDocument {
- get { return doc; }
- }
-
- public bool CreateUndoInfo {
- get { return createUndo; }
- set { createUndo = value; }
- }
-
- public virtual XmlElement WriteObject (ObjectWrapper wrapper)
- {
- return wrapper.Write (this);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ParamSpec.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ParamSpec.cs
deleted file mode 100644
index c244285f22..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ParamSpec.cs
+++ /dev/null
@@ -1,225 +0,0 @@
-using GLib;
-using Gtk;
-using System;
-using System.Collections;
-using System.Runtime.InteropServices;
-
-namespace Stetic {
-
- public class ParamSpec : IDisposable {
- IntPtr _obj;
-
- public ParamSpec (IntPtr raw)
- {
- Raw = raw;
- }
-
- ~ParamSpec ()
- {
- Dispose ();
- }
-
- public void Dispose ()
- {
- Raw = IntPtr.Zero;
- GC.SuppressFinalize (this);
- }
-
- IntPtr Raw {
- get {
- return _obj;
- }
- set {
- if (_obj != IntPtr.Zero)
- g_param_spec_unref (_obj);
- _obj = value;
- if (_obj != IntPtr.Zero) {
- g_param_spec_ref (_obj);
- g_param_spec_sink (_obj);
- }
- }
- }
-
- public string Name {
- get {
- return GLib.Marshaller.Utf8PtrToString (g_param_spec_get_name (_obj));
- }
- }
-
- public string Nick {
- get {
- return GLib.Marshaller.Utf8PtrToString (g_param_spec_get_nick (_obj));
- }
- }
-
- public string Blurb {
- get {
- return GLib.Marshaller.Utf8PtrToString (g_param_spec_get_blurb (_obj));
- }
- }
-
-/* [DllImport("libsteticglue")]
- static extern bool stetic_param_spec_get_minimum (IntPtr pspec, ref GLib.Value value);
-
- public object Minimum {
- get {
- GLib.Value value = new GLib.Value ();
-
- if (stetic_param_spec_get_minimum (Raw, ref value))
- return value.Val;
- else
- return null;
- }
- }
-*/
- public object Minimum {
- get {
- return null;
- }
- }
-
-/* [DllImport("libsteticglue")]
- static extern bool stetic_param_spec_get_maximum (IntPtr pspec, ref GLib.Value value);
-
- public object Maximum {
- get {
- GLib.Value value = new GLib.Value ();
-
- if (stetic_param_spec_get_maximum (Raw, ref value))
- return value.Val;
- else
- return null;
- }
- }
-*/
- public object Maximum {
- get {
- return null;
- }
- }
-
- public bool IsDefaultValue (object value)
- {
- GLib.Value gvalue = new GLib.Value (value);
- return g_param_value_defaults (Raw, ref gvalue);
- }
-
-/* [DllImport("libsteticglue")]
- static extern bool stetic_param_spec_get_default (IntPtr pspec, ref GLib.Value value);
- public object Default {
- get {
- GLib.Value value = new GLib.Value ();
-
- if (stetic_param_spec_get_default (Raw, ref value))
- return value.Val;
- else
- return null;
- }
- }
-
- [DllImport("libsteticglue")]
- static extern IntPtr stetic_param_spec_get_value_type (IntPtr obj);
-
- public IntPtr ValueType {
- get {
- return stetic_param_spec_get_value_type (_obj);
- }
- }
-*/
-
-/* [DllImport("libsteticglue")]
- static extern bool stetic_param_spec_is_unichar (IntPtr pspec);
-
- public bool IsUnichar {
- get {
- return stetic_param_spec_is_unichar (_obj);
- }
- }
-*/
- static Hashtable props = new Hashtable (), childProps = new Hashtable ();
-
- private class ParamSpecTypeHack : GLib.Object {
- private ParamSpecTypeHack () : base (IntPtr.Zero) {}
-
- static Hashtable classes = new Hashtable ();
-
- public static IntPtr LookupGTypeClass (System.Type t)
- {
- if (classes[t] == null) {
- GType gtype = GLib.Object.LookupGType (t);
- classes[t] = g_type_class_ref (gtype.Val);
- }
-
- return (IntPtr)classes[t];
- }
- }
-
- public static ParamSpec LookupObjectProperty (Type type, string name)
- {
- string key = type.FullName + ":" + name;
- if (props[key] != null)
- return (ParamSpec)props[key];
-
- IntPtr klass = ParamSpecTypeHack.LookupGTypeClass (type);
- if (klass == IntPtr.Zero)
- return null;
-
- IntPtr pspec_raw = g_object_class_find_property (klass, name);
- if (pspec_raw == IntPtr.Zero)
- return null;
-
- ParamSpec pspec = new ParamSpec (pspec_raw);
- props[key] = pspec;
- return pspec;
- }
-
- public static ParamSpec LookupChildProperty (Type type, string name)
- {
- string key = type.FullName + ":" + name;
- if (childProps[key] != null)
- return (ParamSpec)childProps[key];
-
- IntPtr klass = ParamSpecTypeHack.LookupGTypeClass (type);
- if (klass == IntPtr.Zero)
- return null;
-
- IntPtr pspec_raw = gtk_container_class_find_child_property (klass, name);
- if (pspec_raw == IntPtr.Zero)
- return null;
-
- ParamSpec pspec = new ParamSpec (pspec_raw);
- childProps[key] = pspec;
- return pspec;
- }
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern void g_param_spec_ref (IntPtr obj);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern void g_param_spec_unref (IntPtr obj);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern void g_param_spec_sink (IntPtr obj);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_param_spec_get_name (IntPtr obj);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_param_spec_get_nick (IntPtr obj);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_param_spec_get_blurb (IntPtr obj);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern bool g_param_value_defaults (IntPtr obj, ref GLib.Value value);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_type_class_ref (IntPtr gtype);
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_object_class_find_property (IntPtr klass, string name);
-
- [DllImport("libgtk-win32-2.0-0.dll")]
- static extern IntPtr gtk_container_class_find_child_property (IntPtr klass, string name);
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Placeholder.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/Placeholder.cs
deleted file mode 100644
index 1a55e0258e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Placeholder.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-using Gtk;
-using System;
-
-namespace Stetic {
-
- public class Placeholder : Gtk.DrawingArea, IEditableObject
- {
- // This id is used by the undo methods to identify a child of a container.
- string undoId;
-
- public Placeholder ()
- {
- undoId = WidgetUtils.GetUndoId ();
- DND.DestSet (this, true);
- Events |= Gdk.EventMask.ButtonPressMask;
- WidgetFlags |= WidgetFlags.AppPaintable;
- }
-
- internal string UndoId {
- get { return undoId; }
- set { undoId = value; }
- }
-
- const int minSize = 10;
-
- protected override void OnSizeRequested (ref Requisition req)
- {
- base.OnSizeRequested (ref req);
- if (req.Width <= 0)
- req.Width = minSize;
- if (req.Height <= 0)
- req.Height = minSize;
- }
-
- protected override void OnRealized ()
- {
- base.OnRealized ();
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose evt)
- {
- if (!IsDrawable)
- return false;
-
- int width, height;
- GdkWindow.GetSize (out width, out height);
-
- Gdk.Rectangle a = new Gdk.Rectangle (0,0,width,height);
-
- byte b2 = 210;
-
- int ssLT = 12;
- int ssRB = 7;
- double grey = 0.6;
- double greyb1 = 0.9;
- double greyb2 = 0.6;
-
- Gdk.Rectangle rect = a;
- Cairo.Color back1 = new Cairo.Color (greyb1, greyb1, greyb1);
- Cairo.Color back2 = new Cairo.Color (greyb2, greyb2, greyb2);
- Cairo.Color cdark = new Cairo.Color (grey, grey, grey, 1);
- Cairo.Color clight = new Cairo.Color (grey, grey, grey, 0);
- using (Cairo.Context cr = Gdk.CairoHelper.Create (evt.Window)) {
-
- DrawGradient (cr, rect, 0, 0, 1, 1, back1, back2);
-
- rect.X = a.X;
- rect.Y = a.Y;
- rect.Height = ssLT;
- rect.Width = a.Width;
- DrawGradient (cr, rect, 0, 0, 0, 1, cdark, clight);
-
- rect.Y = a.Bottom - ssRB;
- rect.Height = ssRB;
- DrawGradient (cr, rect, 0, 0, 0, 1, clight, cdark);
-
- rect.X = a.X;
- rect.Y = a.Y;
- rect.Width = ssLT;
- rect.Height = a.Height;
- DrawGradient (cr, rect, 0, 0, 1, 0, cdark, clight);
-
- rect.X = a.Right - ssRB;
- rect.Width = ssRB;
- DrawGradient (cr, rect, 0, 0, 1, 0, clight, cdark);
-
- Gdk.GC gc = new Gdk.GC (GdkWindow);
- gc.RgbBgColor = new Gdk.Color (b2,b2,b2);
- gc.RgbFgColor = new Gdk.Color (b2,b2,b2);
- GdkWindow.DrawRectangle (gc, false, a.X, a.Y, a.Width, a.Height);
- gc.Dispose ();
- }
-
- return base.OnExposeEvent (evt);
- }
-
- void DrawGradient (Cairo.Context cr, Gdk.Rectangle rect, int fx, int fy, int fw, int fh, Cairo.Color c1, Cairo.Color c2)
- {
- cr.NewPath ();
- cr.MoveTo (rect.X, rect.Y);
- cr.RelLineTo (rect.Width, 0);
- cr.RelLineTo (0, rect.Height);
- cr.RelLineTo (-rect.Width, 0);
- cr.RelLineTo (0, -rect.Height);
- cr.ClosePath ();
-
- // FIXME: VV: Remove gradient features
- Cairo.LinearGradient pat = new Cairo.LinearGradient (rect.X + rect.Width*fx, rect.Y + rect.Height*fy, rect.X + rect.Width*fw, rect.Y + rect.Height*fh);
- pat.AddColorStop (0, c1);
- pat.AddColorStop (1, c2);
- cr.Pattern = pat;
- cr.FillPreserve ();
- }
-
- bool IEditableObject.CanDelete {
- get { return true; }
- }
-
- bool IEditableObject.CanPaste {
- get { return true; }
- }
-
- bool IEditableObject.CanCut {
- get { return false; }
- }
-
- bool IEditableObject.CanCopy {
- get { return false; }
- }
-
- void IEditableObject.Delete ()
- {
- Stetic.Wrapper.Container wc = Stetic.Wrapper.Container.LookupParent (this);
- if (wc != null)
- wc.Delete (this);
- }
-
- void IEditableObject.Paste ()
- {
- Clipboard.Paste (this);
- }
-
- void IEditableObject.Cut ()
- {
- }
-
- void IEditableObject.Copy ()
- {
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ProjectIconFactory.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/ProjectIconFactory.cs
deleted file mode 100644
index 79d6918625..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/ProjectIconFactory.cs
+++ /dev/null
@@ -1,335 +0,0 @@
-
-using System;
-using System.CodeDom;
-using System.Xml;
-using System.Collections;
-
-namespace Stetic
-{
- public class ProjectIconFactory
- {
- ProjectIconSetCollection icons = new ProjectIconSetCollection ();
-
- public ProjectIconFactory()
- {
- }
-
- public ProjectIconSetCollection Icons {
- get { return icons; }
- }
-
- public ProjectIconSet GetIcon (string name)
- {
- foreach (ProjectIconSet icon in icons)
- if (icon.Name == name)
- return icon;
- return null;
- }
-
- public XmlElement Write (XmlDocument doc)
- {
- XmlElement elem = doc.CreateElement ("icon-factory");
- foreach (ProjectIconSet icon in icons)
- elem.AppendChild (icon.Write (doc));
- return elem;
- }
-
- public void Read (IProject project, XmlElement elem)
- {
- icons.Clear ();
- foreach (XmlElement child in elem.SelectNodes ("icon-set")) {
- ProjectIconSet icon = new ProjectIconSet ();
- icon.Read (project, child);
- icons.Add (icon);
- }
- }
-
- public void GenerateBuildCode (GeneratorContext ctx)
- {
- string varName = ctx.NewId ();
- CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement (typeof(Gtk.IconFactory).ToGlobalTypeRef (), varName);
- varDec.InitExpression = new CodeObjectCreateExpression (typeof(Gtk.IconFactory).ToGlobalTypeRef ());
- ctx.Statements.Add (varDec);
-
- CodeVariableReferenceExpression var = new CodeVariableReferenceExpression (varName);
- foreach (ProjectIconSet icon in icons) {
-
- CodeExpression exp = new CodeMethodInvokeExpression (
- var,
- "Add",
- new CodePrimitiveExpression (icon.Name),
- icon.GenerateObjectBuild (ctx)
- );
- ctx.Statements.Add (exp);
- }
-
- CodeExpression addd = new CodeMethodInvokeExpression (
- var,
- "AddDefault"
- );
- ctx.Statements.Add (addd);
- }
-
- public Gdk.Pixbuf RenderIcon (IProject project, string name, Gtk.IconSize size)
- {
- ProjectIconSet icon = GetIcon (name);
- if (icon == null)
- return null;
-
- foreach (ProjectIconSource src in icon.Sources) {
- if (src.SizeWildcarded || src.Size == size)
- return src.Image.GetScaledImage (project, size);
- }
-
- return icon.Sources [0].Image.GetScaledImage (project, size);
- }
-
- public Gdk.Pixbuf RenderIcon (IProject project, string name, int size)
- {
- ProjectIconSet icon = GetIcon (name);
- if (icon == null)
- return null;
-
- return icon.Sources [0].Image.GetScaledImage (project, size, size);
- }
- }
-
- public class ProjectIconSet
- {
- ProjectIconSourceCollection sources = new ProjectIconSourceCollection ();
- string name;
-
- public string Name {
- get { return name; }
- set { name = value; }
- }
-
- public ProjectIconSourceCollection Sources {
- get { return sources; }
- }
-
- public XmlElement Write (XmlDocument doc)
- {
- XmlElement elem = doc.CreateElement ("icon-set");
- elem.SetAttribute ("id", name);
- foreach (ProjectIconSource src in sources)
- elem.AppendChild (src.Write (doc));
- return elem;
- }
-
- public void Read (IProject project, XmlElement elem)
- {
- sources.Clear ();
- name = elem.GetAttribute ("id");
- if (name.Length == 0)
- throw new InvalidOperationException ("Name attribute not found");
-
- foreach (XmlElement child in elem.SelectNodes ("source")) {
- ProjectIconSource src = new ProjectIconSource ();
- src.Read (project, child);
- sources.Add (src);
- }
- }
-
- internal CodeExpression GenerateObjectBuild (GeneratorContext ctx)
- {
- string varName = ctx.NewId ();
- CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement (typeof(Gtk.IconSet).ToGlobalTypeRef (), varName);
- ctx.Statements.Add (varDec);
-
- CodeVariableReferenceExpression var = new CodeVariableReferenceExpression (varName);
-
- if (sources.Count == 1 && sources[0].AllWildcarded) {
- varDec.InitExpression = new CodeObjectCreateExpression (
- typeof(Gtk.IconSet).ToGlobalTypeRef (),
- sources[0].Image.ToCodeExpression (ctx)
- );
- } else {
- varDec.InitExpression = new CodeObjectCreateExpression (typeof(Gtk.IconSet).ToGlobalTypeRef ());
- foreach (ProjectIconSource src in sources) {
- CodeExpression exp = new CodeMethodInvokeExpression (
- var,
- "AddSource",
- src.GenerateObjectBuild (ctx)
- );
- ctx.Statements.Add (exp);
- }
- }
- return var;
- }
- }
-
- public class ProjectIconSource: Gtk.IconSource
- {
- ImageInfo imageInfo;
-
- public ImageInfo Image {
- get { return imageInfo; }
- set { imageInfo = value; }
- }
-
- public bool AllWildcarded {
- get {
- return DirectionWildcarded && SizeWildcarded && StateWildcarded;
- }
- set {
- DirectionWildcarded = SizeWildcarded = StateWildcarded = true;
- }
- }
-
- public XmlElement Write (XmlDocument doc)
- {
- XmlElement elem = doc.CreateElement ("source");
-
- XmlElement prop = doc.CreateElement ("property");
- prop.SetAttribute ("name", "Image");
- prop.InnerText = imageInfo.ToString ();
- elem.AppendChild (prop);
-
- if (!SizeWildcarded) {
- prop = doc.CreateElement ("property");
- prop.SetAttribute ("name", "Size");
- prop.InnerText = Size.ToString ();
- elem.AppendChild (prop);
- }
-
- if (!StateWildcarded) {
- prop = doc.CreateElement ("property");
- prop.SetAttribute ("name", "State");
- prop.InnerText = State.ToString ();
- elem.AppendChild (prop);
- }
-
- if (!DirectionWildcarded) {
- prop = doc.CreateElement ("property");
- prop.SetAttribute ("name", "Direction");
- prop.InnerText = Direction.ToString ();
- elem.AppendChild (prop);
- }
-
- return elem;
- }
-
- public void Read (IProject project, XmlElement elem)
- {
- XmlElement prop = elem.SelectSingleNode ("property[@name='Image']") as XmlElement;
- if (prop != null)
- imageInfo = ImageInfo.FromString (prop.InnerText);
-
- prop = elem.SelectSingleNode ("property[@name='Size']") as XmlElement;
- if (prop != null && prop.InnerText != "*") {
- SizeWildcarded = false;
- Size = (Gtk.IconSize) Enum.Parse (typeof(Gtk.IconSize), prop.InnerText);
- } else
- SizeWildcarded = true;
-
- prop = elem.SelectSingleNode ("property[@name='State']") as XmlElement;
- if (prop != null && prop.InnerText != "*") {
- StateWildcarded = false;
- State = (Gtk.StateType) Enum.Parse (typeof(Gtk.StateType), prop.InnerText);
- } else
- StateWildcarded = true;
-
- prop = elem.SelectSingleNode ("property[@name='Direction']") as XmlElement;
- if (prop != null && prop.InnerText != "*") {
- DirectionWildcarded = false;
- Direction = (Gtk.TextDirection) Enum.Parse (typeof(Gtk.TextDirection), prop.InnerText);
- } else
- DirectionWildcarded = true;
- }
-
- internal CodeExpression GenerateObjectBuild (GeneratorContext ctx)
- {
- string varName = ctx.NewId ();
- CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement (typeof(Gtk.IconSource).ToGlobalTypeRef (), varName);
- varDec.InitExpression = new CodeObjectCreateExpression (typeof(Gtk.IconSource).ToGlobalTypeRef ());
- ctx.Statements.Add (varDec);
-
- CodeVariableReferenceExpression var = new CodeVariableReferenceExpression (varName);
-
- ctx.Statements.Add (new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "Pixbuf"),
- imageInfo.ToCodeExpression (ctx)
- ));
-
- if (!SizeWildcarded) {
- ctx.Statements.Add (new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "SizeWildcarded"),
- new CodePrimitiveExpression (false)
- ));
- ctx.Statements.Add (new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "Size"),
- new CodeFieldReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference ("Gtk.IconSize", CodeTypeReferenceOptions.GlobalReference)),
- Size.ToString ()
- )
- ));
- }
-
- if (!StateWildcarded) {
- ctx.Statements.Add (new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "StateWildcarded"),
- new CodePrimitiveExpression (false)
- ));
- ctx.Statements.Add (new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "State"),
- new CodeFieldReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference ("Gtk.StateType", CodeTypeReferenceOptions.GlobalReference)),
- State.ToString ()
- )
- ));
- }
-
- if (!DirectionWildcarded) {
- ctx.Statements.Add (new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "DirectionWildcarded"),
- new CodePrimitiveExpression (false)
- ));
- ctx.Statements.Add (new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "Direction"),
- new CodeFieldReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference ("Gtk.TextDirection", CodeTypeReferenceOptions.GlobalReference)),
- Direction.ToString ()
- )
- ));
- }
-
- return var;
- }
- }
-
- public class ProjectIconSetCollection: CollectionBase
- {
- public ProjectIconSet this [int n] {
- get { return (ProjectIconSet) List [n]; }
- }
-
- public void Add (ProjectIconSet icon)
- {
- List.Add (icon);
- }
-
- public void Remove (ProjectIconSet icon)
- {
- List.Remove (icon);
- }
- }
-
- public class ProjectIconSourceCollection: CollectionBase
- {
- public void AddRange (ICollection c)
- {
- foreach (ProjectIconSource s in c)
- List.Add (s);
- }
-
- public ProjectIconSource this [int n] {
- get { return (ProjectIconSource) List [n]; }
- }
-
- public void Add (ProjectIconSource source)
- {
- List.Add (source);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyDescriptor.cs
deleted file mode 100644
index 3a4a5e9ffb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyDescriptor.cs
+++ /dev/null
@@ -1,310 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Collections;
-using System.Reflection;
-using System.Xml;
-
-namespace Stetic {
-
- class TranslationInfo {
- public bool Translated;
- public string Context, Comment;
- }
-
- public abstract class PropertyDescriptor : ItemDescriptor
- {
- protected string label, description, gladeName;
- protected bool gladeOverride;
-
- protected bool isRuntimeProperty, hasDefault, initWithName;
- protected Type editorType;
- protected object minimum, maximum;
- protected object defaultValue;
- protected TypeConverter typeConverter;
- protected bool translatable;
-
- protected PropertyDescriptor ()
- {
- }
-
- protected PropertyDescriptor (XmlElement elem, ItemGroup group, ClassDescriptor klass): base (elem, group, klass)
- {
- }
-
- protected void Load (XmlElement elem)
- {
- if (elem.HasAttribute ("label"))
- label = elem.GetAttribute ("label");
-
- if (label == null)
- label = elem.GetAttribute ("name");
-
- if (elem.HasAttribute ("description"))
- description = elem.GetAttribute ("description");
-
- if (elem.HasAttribute ("min"))
- minimum = StringToValue (elem.GetAttribute ("min"));
-
- if (elem.HasAttribute ("max"))
- maximum = StringToValue (elem.GetAttribute ("max"));
-
- if (elem.HasAttribute ("glade-override"))
- gladeOverride = true;
-
- if (elem.HasAttribute ("glade-name"))
- gladeName = elem.GetAttribute ("glade-name");
-
- if (elem.HasAttribute ("init-with-name"))
- initWithName = true;
-
- if (elem.HasAttribute ("translatable"))
- translatable = true;
-
- if (elem.HasAttribute ("default")) {
- defaultValue = StringToValue (elem.GetAttribute ("default"));
- hasDefault = true;
- }
-
- string convTypeName = elem.GetAttribute ("type-converter");
- if (convTypeName.Length > 0) {
- Type type = Registry.GetType (convTypeName, true);
- typeConverter = (TypeConverter) Activator.CreateInstance (type);
- }
- }
-
- // The property's user-visible name
- public virtual string Label {
- get {
- return label;
- }
- }
-
- // The property's type
- public abstract Type PropertyType {
- get ;
- }
-
- // The property's user-visible description
- public virtual string Description {
- get {
- return description;
- }
- }
-
- // The property's GUI editor type, if overridden
- public virtual Type EditorType {
- get {
- return editorType;
- }
- }
-
- // The property's minimum value, if declared
- public virtual object Minimum {
- get {
- return minimum;
- }
- }
-
- // The property's maximum value, if declared
- public virtual object Maximum {
- get {
- return maximum;
- }
- }
-
- public virtual string InternalChildId {
- get { return null; }
- }
-
- // Whether or not the property has a default value
- public virtual bool HasDefault {
- get {
- return hasDefault;
- }
- set {
- hasDefault = value;
- }
- }
-
- public virtual bool IsDefaultValue (object value)
- {
- if (value == null)
- return true;
- if (defaultValue != null)
- return value.Equals (defaultValue);
- return false;
- }
-
- public virtual void ResetValue (object instance)
- {
- if (HasDefault)
- SetValue (instance, defaultValue);
- }
-
- // The property's type at run time
- public virtual Type RuntimePropertyType {
- get { return PropertyType; }
- }
-
- // Gets the value of the property on @obj
- public abstract object GetValue (object obj);
-
- // Gets the value of the property on @obj, bypassing the wrapper.
- public virtual object GetRuntimeValue (object obj)
- {
- return GetValue (obj);
- }
-
- // Whether or not the property is writable
- public virtual bool CanWrite {
- get { return true; }
- }
-
- // Sets the value of the property on @obj
- public abstract void SetValue (object obj, object value);
-
- // Sets the value of the property on @obj, bypassing the wrapper.
- public virtual void SetRuntimeValue (object obj, object value)
- {
- SetValue (obj, value);
- }
-
- // Parses a string an returns a value valid for this property
- public virtual object StringToValue (string value)
- {
- if (typeConverter != null && typeConverter.CanConvertFrom (typeof(string)))
- return typeConverter.ConvertFromString (value);
- else if (PropertyType.IsEnum)
- return Enum.Parse (PropertyType, value);
- else if (PropertyType == typeof(ImageInfo))
- return ImageInfo.FromString (value);
- else if (PropertyType == typeof(string[]))
- return string.IsNullOrEmpty (value) ? null : value.Split ('\n');
- else if (PropertyType == typeof(DateTime))
- return new DateTime (long.Parse (value));
- else if (PropertyType == typeof(TimeSpan))
- return new TimeSpan (long.Parse (value));
- else if (PropertyType == typeof(double)) {
- try {
- return Convert.ChangeType (value, PropertyType);
- }
- catch (InvalidCastException) {
- return Convert.ChangeType (value, PropertyType, System.Globalization.CultureInfo.InvariantCulture);
- }
- } else
- return Convert.ChangeType (value, PropertyType, System.Globalization.CultureInfo.InvariantCulture);
- }
-
- // Returns a string representation of the provided property value
- public virtual string ValueToString (object value)
- {
- if (typeConverter != null && typeConverter.CanConvertTo (typeof(string)))
- return typeConverter.ConvertToString (value);
- else if (PropertyType == typeof(string[]))
- return value == null ? string.Empty : string.Join ("\n", (string[])value);
- else if (PropertyType == typeof(DateTime))
- return ((DateTime)value).Ticks.ToString ();
- else if (PropertyType == typeof(TimeSpan))
- return ((TimeSpan)value).Ticks.ToString ();
- else if (PropertyType == typeof(double))
- return ((double)value).ToString (System.Globalization.CultureInfo.InvariantCulture);
- else
- return value.ToString ();
- }
-
- public virtual bool InitWithName {
- get {
- return initWithName;
- }
- }
-
- public virtual bool IsRuntimeProperty {
- get { return isRuntimeProperty; }
- }
-
- public virtual bool Translatable {
- get {
- return translatable;
- }
- }
-
- public virtual bool IsTranslated (object obj)
- {
- if (!translatable)
- return false;
-
- ObjectWrapper wrapper = ObjectWrapper.Lookup (obj);
- if (wrapper == null)
- return false;
-
- // Since translatable properties are assumed to be translated
- // by default, we return true if there is no TranslationInfo
- // for the object
-
- if (wrapper.translationInfo == null)
- return true;
-
- TranslationInfo info = (TranslationInfo)wrapper.translationInfo[obj];
- return (info == null || info.Translated == true);
- }
-
- public virtual void SetTranslated (object obj, bool translated)
- {
- ObjectWrapper wrapper = ObjectWrapper.Lookup (obj);
- if (wrapper == null) return;
-
- if (wrapper.translationInfo == null)
- wrapper.translationInfo = new Hashtable ();
-
- TranslationInfo info = (TranslationInfo)wrapper.translationInfo[obj];
- if (info == null) {
- info = new TranslationInfo ();
- wrapper.translationInfo[obj] = info;
- }
-
- if (translated)
- info.Translated = true;
- else
- info.Translated = false;
- // We leave the old Context and Comment around, so that if
- // you toggle Translated off and then back on, the old info
- // is still there.
- }
-
- public virtual string TranslationContext (object obj)
- {
- ObjectWrapper wrapper = ObjectWrapper.Lookup (obj);
- if (wrapper == null || wrapper.translationInfo == null) return null;
-
- TranslationInfo info = (TranslationInfo)wrapper.translationInfo[obj];
- return info != null ? info.Context : null;
- }
-
- public virtual void SetTranslationContext (object obj, string context)
- {
- SetTranslated (obj, true);
-
- ObjectWrapper wrapper = ObjectWrapper.Lookup (obj);
- if (wrapper == null) return;
- ((TranslationInfo)wrapper.translationInfo[obj]).Context = context;
- }
-
- public virtual string TranslationComment (object obj)
- {
- ObjectWrapper wrapper = ObjectWrapper.Lookup (obj);
- if (wrapper == null || wrapper.translationInfo == null) return null;
-
- TranslationInfo info = (TranslationInfo)wrapper.translationInfo[obj];
- return info != null ? info.Comment : null;
- }
-
- public virtual void SetTranslationComment (object obj, string comment)
- {
- SetTranslated (obj, true);
-
- ObjectWrapper wrapper = ObjectWrapper.Lookup (obj);
- if (wrapper == null) return;
- ((TranslationInfo)wrapper.translationInfo[obj]).Comment = comment;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyEditorAttribute.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyEditorAttribute.cs
deleted file mode 100644
index 05c2bb720b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyEditorAttribute.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-
-namespace Stetic {
-
- [AttributeUsage (AttributeTargets.Class)]
- public sealed class PropertyEditorAttribute : Attribute {
-
- public PropertyEditorAttribute (string property, string evt)
- {
- this.property = property;
- this.evt = evt;
- }
-
- public PropertyEditorAttribute (string property) : this (property, property + "Changed") {}
-
- string property;
- public string Property {
- get {
- return property;
- }
- set {
- property = value;
- }
- }
-
- string evt;
- public string Event {
- get {
- return evt;
- }
- set {
- evt = value;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyEditorCell.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyEditorCell.cs
deleted file mode 100644
index 1079054eb1..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/PropertyEditorCell.cs
+++ /dev/null
@@ -1,303 +0,0 @@
-
-using System;
-using System.Collections;
-using Gtk;
-using Gdk;
-
-namespace Stetic
-{
- public class PropertyEditorCell
- {
- Pango.Layout layout;
- PropertyDescriptor property;
- object obj;
- Gtk.Widget container;
-
- static Hashtable editors;
- static PropertyEditorCell Default = new PropertyEditorCell ();
- static Hashtable cellCache = new Hashtable ();
-
- static PropertyEditorCell ()
- {
- editors = new Hashtable ();
-
- editors[typeof (bool)] = typeof (Stetic.Editor.Boolean);
- editors[typeof (byte)] = typeof (Stetic.Editor.IntRange);
- editors[typeof (sbyte)] = typeof (Stetic.Editor.IntRange);
- editors[typeof (short)] = typeof (Stetic.Editor.IntRange);
- editors[typeof (ushort)] = typeof (Stetic.Editor.IntRange);
- editors[typeof (int)] = typeof (Stetic.Editor.IntRange);
- editors[typeof (uint)] = typeof (Stetic.Editor.IntRange);
- editors[typeof (long)] = typeof (Stetic.Editor.IntRange);
- editors[typeof (ulong)] = typeof (Stetic.Editor.IntRange);
- editors[typeof (float)] = typeof (Stetic.Editor.FloatRange);
- editors[typeof (double)] = typeof (Stetic.Editor.FloatRange);
- editors[typeof (char)] = typeof (Stetic.Editor.Char);
- editors[typeof (string)] = typeof (Stetic.Editor.TextEditor);
- editors[typeof (DateTime)] = typeof (Stetic.Editor.DateTimeEditorCell);
- editors[typeof (TimeSpan)] = typeof (Stetic.Editor.TimeSpanEditorCell);
- editors[typeof (string[])] = typeof (Stetic.Editor.StringArray);
- editors[typeof (Gdk.Color)] = typeof (Stetic.Editor.Color);
- editors[typeof (Stetic.ImageInfo)] = typeof (Stetic.Editor.ImageSelector);
- }
-
- public object Instance {
- get { return obj; }
- }
-
- public PropertyDescriptor Property {
- get { return property; }
- }
-
- public Gtk.Widget Container {
- get { return container; }
- }
-
- public void Initialize (Widget container, PropertyDescriptor property, object obj)
- {
- this.container = container;
- layout = new Pango.Layout (container.PangoContext);
- layout.Width = -1;
-
- Pango.FontDescription des = container.Style.FontDescription.Copy();
- des.Size = 10 * (int) Pango.Scale.PangoScale;
- layout.FontDescription = des;
-
- this.property = property;
- this.obj = obj;
- Initialize ();
- }
-
- public EditSession StartEditing (Gdk.Rectangle cell_area, StateType state)
- {
- IPropertyEditor ed = CreateEditor (cell_area, state);
- if (ed == null)
- return null;
- ed.Initialize (property);
- if (obj != null) {
- ed.AttachObject (obj);
- ed.Value = property.GetValue (obj);
- }
- return new EditSession (container, obj, property, ed);
- }
-
- protected virtual string GetValueText ()
- {
- if (obj == null) return "";
- object val = property.GetValue (obj);
- if (val == null) return "";
- else return property.ValueToString (val);
- }
-
- string GetNormalizedText ()
- {
- string s = GetValueText ();
- if (s == null)
- return "";
-
- int i = s.IndexOf ('\n');
- if (i == -1)
- return s;
-
- s = s.TrimStart ('\n',' ','\t');
- i = s.IndexOf ('\n');
- if (i != -1)
- return s.Substring (0, i) + "...";
- else
- return s;
- }
-
- public object Value {
- get { return obj != null ? property.GetValue (obj) : null; }
- }
-
- protected virtual void Initialize ()
- {
- layout.SetText (GetNormalizedText ());
- }
-
- public virtual void GetSize (int availableWidth, out int width, out int height)
- {
- layout.GetPixelSize (out width, out height);
- }
-
- public virtual void Render (Drawable window, Gdk.Rectangle bounds, StateType state)
- {
- int w, h;
- layout.GetPixelSize (out w, out h);
- int dy = (bounds.Height - h) / 2;
- window.DrawLayout (container.Style.TextGC (state), bounds.X, dy + bounds.Y, layout);
- }
-
- protected virtual IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, StateType state)
- {
- Type editorType = property.EditorType;
-
- if (editorType == null) {
- editorType = GetEditorForType (property.PropertyType);
- if (editorType == null)
- return null;
- }
-
- IPropertyEditor editor = Activator.CreateInstance (editorType) as IPropertyEditor;
- if (editor == null)
- throw new Exception ("The property editor '" + editorType + "' must implement the interface IPropertyEditor");
- return editor;
- }
-
- public static Type GetEditorForType (Type propertyType)
- {
- if (propertyType.IsEnum) {
- if (propertyType.IsDefined (typeof (FlagsAttribute), true))
- return typeof (Stetic.Editor.Flags);
- else
- return typeof (Stetic.Editor.Enumeration);
- } else {
- return editors [propertyType] as Type;
- }
- }
-
- public static PropertyEditorCell GetPropertyCell (PropertyDescriptor property)
- {
- Type editorType = property.EditorType;
-
- if (editorType == null)
- editorType = GetEditorForType (property.PropertyType);
-
- if (editorType == null)
- return Default;
-
- if (typeof(IPropertyEditor).IsAssignableFrom (editorType)) {
- if (!typeof(Gtk.Widget).IsAssignableFrom (editorType))
- throw new Exception ("The property editor '" + editorType + "' must be a Gtk Widget");
- return Default;
- }
-
- PropertyEditorCell cell = (PropertyEditorCell) cellCache [editorType];
- if (cell != null)
- return cell;
-
- if (!typeof(PropertyEditorCell).IsAssignableFrom (editorType))
- throw new Exception ("The property editor '" + editorType + "' must be a subclass of Stetic.PropertyEditorCell or implement Stetic.IPropertyEditor");
-
- cell = (PropertyEditorCell) Activator.CreateInstance (editorType);
- cellCache [editorType] = cell;
- return cell;
- }
- }
-
-
- class DefaultPropertyEditor: Gtk.Entry, IPropertyEditor
- {
- PropertyDescriptor property;
-
- public void Initialize (PropertyDescriptor property)
- {
- this.property = property;
- }
-
- public void AttachObject (object obj)
- {
- }
-
- public object Value {
- get {
- return Convert.ChangeType (Text, property.PropertyType);
- }
- set {
- if (value == null)
- Text = "";
- else
- Text = Convert.ToString (value);
- }
- }
-
- protected override void OnChanged ()
- {
- base.OnChanged ();
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- public event EventHandler ValueChanged;
- }
-
- public class EditSession
- {
- PropertyDescriptor property;
- object obj;
- Gtk.Widget container;
- IPropertyEditor currentEditor;
- bool syncing;
- object initialVal;
-
- public EditSession (Gtk.Widget container, object instance, PropertyDescriptor property, IPropertyEditor currentEditor)
- {
- this.property = property;
- this.obj = instance;
- this.container = container;
- this.currentEditor = currentEditor;
- currentEditor.ValueChanged += OnValueChanged;
- initialVal = currentEditor.Value;
- }
-
- public object Instance {
- get { return obj; }
- }
-
- public PropertyDescriptor Property {
- get { return property; }
- }
-
- public Gtk.Widget Container {
- get { return container; }
- }
-
- public IPropertyEditor Editor {
- get { return currentEditor; }
- }
-
- void OnValueChanged (object s, EventArgs a)
- {
- if (!syncing) {
- syncing = true;
- property.SetValue (obj, currentEditor.Value);
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (obj) as Stetic.Wrapper.Widget;
- if (wrapper != null)
- wrapper.NotifyChanged ();
- syncing = false;
- }
- }
-
- public void AttachObject (object ob)
- {
- if (ob == null)
- throw new ArgumentNullException ("ob");
-
- syncing = true;
- this.obj = ob;
- currentEditor.AttachObject (obj);
-
- // It is the responsibility of the editor to convert value types
- object initial = property.GetValue (obj);
- currentEditor.Value = initial;
-
- syncing = false;
- }
-
- public void UpdateEditor ()
- {
- if (!syncing) {
- syncing = true;
- currentEditor.Value = property.GetValue (obj);
- syncing = false;
- }
- }
-
- public void Dispose ()
- {
- if (!object.Equals (initialVal, currentEditor.Value))
- OnValueChanged (null, null);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/RadioGroupManager.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/RadioGroupManager.cs
deleted file mode 100644
index 73c8fb8f69..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/RadioGroupManager.cs
+++ /dev/null
@@ -1,212 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using System.CodeDom;
-
-// The stetic representation of "radio widget" (Gtk.RadioButton,
-// Gtk.RadioToolButton, and Gtk.RadioMenuItem) groups is that the
-// groups have names, and each widget's "Group" property stores the
-// name of its group. The glade representation is similar, except that
-// the group names aren't arbitrary; they have to be the name of the
-// first widget in the group. (On disk, the "group leader" has no
-// "group" property, and the other widgets have the leader's name as
-// their group property.)
-//
-// The internal gtk representation of groups is that each radio widget
-// has a GLib.SList "Group" property. The content of the list is
-// essentially opaque. (For Gtk.RadioButton, the list contains all of
-// the RadioButtons in the group. But for Gtk.ToolRadioButton it
-// contains pointers to internal widgets, not the ToolRadioButtons
-// themselves.) The only thing we can do with them then is to read one
-// widget's group and then immediately assign it to another widget. We
-// can't look into the list, or assume that a widget's Group property
-// will keep the same value if any other widget's Group changes.
-//
-// Each radio widget type wrapper class keeps a static
-// RadioGroupManager to handle this string<->GLib.SList translation
-// for it.
-
-namespace Stetic {
-
- public class RadioGroup {
- public string Name;
- public ArrayList Widgets;
-
- public RadioGroup (string name)
- {
- Name = name;
- Widgets = new ArrayList ();
- }
- }
-
- public class RadioGroupManager: IRadioGroupManager
- {
- PropertyInfo groupProperty;
- ArrayList groups;
- Hashtable widgets;
-
- public RadioGroupManager (Type widgetType)
- {
- groupProperty = widgetType.GetProperty ("Group");
- if (groupProperty == null || groupProperty.PropertyType != typeof (GLib.SList))
- throw new ArgumentException ("No 'public GLib.SList Group' property on '" + widgetType.FullName + "'");
-
- groups = new ArrayList ();
- widgets = new Hashtable ();
- }
-
- public event GroupsChangedDelegate GroupsChanged;
-
- void EmitGroupsChanged ()
- {
- if (GroupsChanged != null)
- GroupsChanged ();
- }
-
- public IEnumerable GroupNames {
- get {
- string[] names = new string[groups.Count];
- for (int i = 0; i < groups.Count; i++)
- names[i] = ((RadioGroup)groups[i]).Name;
- return names;
- }
- }
-
- public string LastGroup {
- get {
- if (groups.Count == 0)
- Add ("group1");
- RadioGroup group = groups[groups.Count - 1] as RadioGroup;
- return group.Name;
- }
- }
-
- public RadioGroup FindGroup (string name)
- {
- for (int i = 0; i < groups.Count; i++) {
- RadioGroup group = groups[i] as RadioGroup;
- if (group.Name == name)
- return group;
- }
- return null;
- }
-
- void IRadioGroupManager.Add (string name)
- {
- Add (name);
- }
-
- public RadioGroup Add (string name)
- {
- RadioGroup group = new RadioGroup (name);
- groups.Add (group);
- EmitGroupsChanged ();
- return group;
- }
-
- public void Rename (string oldName, string newName)
- {
- RadioGroup group = FindGroup (oldName);
- if (group != null) {
- group.Name = newName;
- EmitGroupsChanged ();
- }
- }
-
- void RadioDestroyed (object obj, EventArgs args)
- {
- Gtk.Widget radio = obj as Gtk.Widget;
- this[radio] = null;
- }
-
- public string this[Gtk.Widget radio] {
- get {
- RadioGroup group = widgets[radio] as RadioGroup;
- if (group != null)
- return group.Name;
- else
- return null;
- }
- set {
- GLib.SList group_value;
-
- RadioGroup oldGroup = widgets[radio] as RadioGroup;
- if (oldGroup == null) {
- radio.Destroyed += RadioDestroyed;
- } else {
- if (oldGroup.Name == value)
- return;
- oldGroup.Widgets.Remove (radio);
- if (oldGroup.Widgets.Count == 0) {
- groups.Remove (oldGroup);
- EmitGroupsChanged ();
- }
- }
-
- if (value == null) {
- radio.Destroyed -= RadioDestroyed;
- groupProperty.SetValue (radio, new GLib.SList (IntPtr.Zero), null);
- widgets.Remove (radio);
- return;
- }
-
- RadioGroup newGroup = FindGroup (value);
- if (newGroup == null)
- newGroup = Add (value);
-
- if (newGroup.Widgets.Count == 0)
- group_value = new GLib.SList (IntPtr.Zero);
- else
- group_value = (GLib.SList)groupProperty.GetValue (newGroup.Widgets[0], null);
-
- groupProperty.SetValue (radio, group_value, null);
- newGroup.Widgets.Add (radio);
- widgets[radio] = newGroup;
- }
- }
-
- public string GladeGroupName (Gtk.Widget radio)
- {
- RadioGroup group = widgets[radio] as RadioGroup;
- if (group == null || group.Widgets.Count == 0)
- return null;
-
- Gtk.Widget leader = (Gtk.Widget)group.Widgets[0];
- return leader.Name;
- }
-
- public CodeExpression GenerateGroupExpression (GeneratorContext ctx, Gtk.Widget widget)
- {
- // Returns and expression that represents the group to which the radio belongs.
- // This expression can be an empty SList, if this is the first radio of the
- // group that has been generated, or an SList taken from previously generated
- // radios from the same group.
-
- RadioGroup group = widgets[widget] as RadioGroup;
- CodeExpression var = null;
-
- foreach (Gtk.Widget radio in group.Widgets) {
- if (radio == widget)
- continue;
- var = ctx.WidgetMap.GetWidgetExp (radio);
- if (var != null)
- break;
- }
-
- if (var == null) {
- return new CodeObjectCreateExpression (
- "GLib.SList".ToGlobalTypeRef (),
- new CodePropertyReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (typeof(IntPtr), CodeTypeReferenceOptions.GlobalReference)),
- "Zero"
- )
- );
- } else {
- return new CodePropertyReferenceExpression (
- var,
- "Group"
- );
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Registry.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/Registry.cs
deleted file mode 100644
index 3316a524eb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Registry.cs
+++ /dev/null
@@ -1,370 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Xml;
-using System.Xml.Xsl;
-
-namespace Stetic {
- public static class Registry {
-
- static ArrayList libraries = new ArrayList ();
- static ArrayList classes = new ArrayList ();
-
- static XslTransform gladeImport, gladeExport;
- static WidgetLibrary coreLib;
- static WidgetLibrary coreLib2;
-
- public static event EventHandler RegistryChanging;
- public static event EventHandler RegistryChanged;
-
- static int changing;
- static bool changed;
-
- public static void Initialize (WidgetLibrary coreLibrary)
- {
- RegisterWidgetLibrary (coreLibrary);
-
- coreLib = coreLibrary;
-
- }
-
- public static WidgetLibrary CoreWidgetLibrary {
- get { return coreLib; }
- }
-
- public static WidgetLibrary CoreWidgetLibrary2 {
- get { return coreLib2; }
- }
-
- public static void BeginChangeSet ()
- {
- if (changing == 0)
- changed = false;
- changing++;
- }
-
- public static void EndChangeSet ()
- {
- if (--changing == 0) {
- if (changed) {
- foreach (WidgetLibrary lib in libraries)
- lib.Flush ();
- NotifyChanged ();
- }
- changed = false;
- }
- }
-
- public static void RegisterWidgetLibrary (WidgetLibrary library)
- {
- NotifyChanging ();
-
- try {
- if (coreLib != null && library.Name == coreLib.Name) {
- libraries.Remove (coreLib);
- InternalUpdate ();
- coreLib = library;
- }
- libraries.Add (library);
- library.Load ();
- classes.AddRange (library.AllClasses);
- UpdateGladeTransform ();
- } catch (Exception ex) {
- Console.WriteLine (ex);
- throw;
- } finally {
- NotifyChanged ();
- }
- }
-
- public static void UnregisterWidgetLibrary (WidgetLibrary library)
- {
- if (library == coreLib)
- return;
-
- NotifyChanging ();
-
- libraries.Remove (library);
- library.Dispose ();
- InternalUpdate ();
-
- NotifyChanged ();
- }
-
-
- // Returns true if all libraries that need reloading
- // could be reloaded
-
- public static bool ReloadWidgetLibraries ()
- {
- bool needsReload = false;
-
- // If there is a lib which can't be reloaded,
- // there is no need to start the reloading process
-
- foreach (WidgetLibrary lib in libraries) {
- if (lib != coreLib && lib.NeedsReload) {
- if (!lib.CanReload)
- return false;
- needsReload = true;
- }
- }
-
- if (!needsReload)
- return true;
-
- try {
- NotifyChanging ();
-
- foreach (WidgetLibrary lib in libraries)
- if (lib != coreLib && lib.NeedsReload)
- lib.Reload ();
-
- InternalUpdate ();
- } finally {
- NotifyChanged ();
- }
-
- return true;
- }
-
- public static bool IsRegistered (WidgetLibrary library)
- {
- return libraries.Contains (library);
- }
-
- public static WidgetLibrary GetWidgetLibrary (string name)
- {
- foreach (WidgetLibrary lib in libraries)
- if (lib.Name == name)
- return lib;
- return null;
- }
-
- public static bool IsRegistered (string name)
- {
- foreach (WidgetLibrary lib in libraries)
- if (lib.Name == name)
- return true;
- return false;
- }
-
- public static WidgetLibrary[] RegisteredWidgetLibraries {
- get { return (WidgetLibrary[]) libraries.ToArray (typeof(WidgetLibrary)); }
- }
-
- static void NotifyChanging ()
- {
- if (changing > 0) {
- if (changed)
- return;
- else
- changed = true;
- }
- if (RegistryChanging != null)
- RegistryChanging (null, EventArgs.Empty);
- }
-
- static void NotifyChanged ()
- {
- if (changing == 0 && RegistryChanged != null)
- RegistryChanged (null, EventArgs.Empty);
- }
-
- static void InternalUpdate ()
- {
- classes.Clear ();
- foreach (WidgetLibrary lib in libraries)
- classes.AddRange (lib.AllClasses);
- UpdateGladeTransform ();
- }
-
- static void UpdateGladeTransform ()
- {
- XmlDocument doc = CreateGladeTransformBase ();
- XmlNamespaceManager nsm = new XmlNamespaceManager (doc.NameTable);
- nsm.AddNamespace ("xsl", "http://www.w3.org/1999/XSL/Transform");
-
- foreach (WidgetLibrary lib in libraries) {
- foreach (XmlElement elem in lib.GetGladeImportTransformElements ())
- doc.FirstChild.PrependChild (doc.ImportNode (elem, true));
- }
-
- gladeImport = new XslTransform ();
- gladeImport.Load (doc, null, null);
-
- doc = CreateGladeTransformBase ();
-
- foreach (WidgetLibrary lib in libraries) {
- foreach (XmlElement elem in lib.GetGladeExportTransformElements ())
- doc.FirstChild.PrependChild (doc.ImportNode (elem, true));
- }
-
- gladeExport = new XslTransform ();
- gladeExport.Load (doc, null, null);
- }
-
- static XmlDocument CreateGladeTransformBase ()
- {
- XmlDocument doc = new XmlDocument ();
- doc.LoadXml (
- "<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>" +
- " <xsl:template match='@*|node()'>" +
- " <xsl:copy>" +
- " <xsl:apply-templates select='@*|node()' />" +
- " </xsl:copy>" +
- " </xsl:template>" +
- "</xsl:stylesheet>"
- );
- return doc;
- }
-
- public static IEnumerable AllClasses {
- get {
- return classes;
- }
- }
-
- public static XslTransform GladeImportXsl {
- get {
- return gladeImport;
- }
- }
-
- public static XslTransform GladeExportXsl {
- get {
- return gladeExport;
- }
- }
-
- public static EnumDescriptor LookupEnum (string typeName)
- {
- foreach (WidgetLibrary lib in libraries) {
- EnumDescriptor desc = lib.LookupEnum (typeName);
- if (desc != null)
- return desc;
- }
- return null;
- }
-
- public static ClassDescriptor LookupClassByCName (string cname)
- {
- foreach (WidgetLibrary lib in libraries) {
- ClassDescriptor desc = lib.LookupClassByCName (cname);
- if (desc != null)
- return desc;
- }
- return null;
- }
-
- public static ClassDescriptor LookupClassByName (string cname)
- {
- foreach (WidgetLibrary lib in libraries) {
- ClassDescriptor desc = lib.LookupClassByName (cname);
- if (desc != null)
- return desc;
- }
- return null;
- }
-
- static ClassDescriptor FindGroupClass (string name, out string groupname)
- {
- int sep = name.LastIndexOf ('.');
- string classname = name.Substring (0, sep);
- groupname = name.Substring (sep + 1);
- ClassDescriptor klass = LookupClassByName (classname);
- if (klass == null) {
- klass = LookupClassByName (name);
- if (klass == null)
- throw new ArgumentException ("No class for itemgroup " + name);
- classname = name;
- groupname = "";
- }
- return klass;
- }
-
- public static ItemGroup LookupItemGroup (string name)
- {
- string groupname;
- ClassDescriptor klass = FindGroupClass (name, out groupname);
-
- foreach (ItemGroup grp in klass.ItemGroups)
- if (grp.Name == groupname && grp.DeclaringType == klass)
- return grp;
-
- throw new ArgumentException ("No itemgroup '" + groupname + "' in class " + klass.WrappedTypeName);
- }
-
- public static ItemGroup LookupSignalGroup (string name)
- {
- string groupname;
- ClassDescriptor klass = FindGroupClass (name, out groupname);
-
- foreach (ItemGroup grp in klass.SignalGroups)
- if (grp.Name == groupname && grp.DeclaringType == klass)
- return grp;
- throw new ArgumentException ("No itemgroup '" + groupname + "' in class " + klass.WrappedTypeName);
- }
-
- public static ItemDescriptor LookupItem (string name)
- {
- int sep = name.LastIndexOf ('.');
- string classname = name.Substring (0, sep);
- string propname = name.Substring (sep + 1);
- ClassDescriptor klass = LookupClassByName (classname);
- if (klass == null)
- throw new ArgumentException ("No class " + classname + " for property " + propname);
- ItemDescriptor idesc = klass[propname];
- if (idesc == null)
- throw new ArgumentException ("Property '" + propname + "' not found in class '" + classname + "'");
- return idesc;
- }
-
- public static ItemGroup LookupContextMenu (string classname)
- {
- ClassDescriptor klass = LookupClassByName (classname);
- if (klass == null)
- throw new ArgumentException ("No class for contextmenu " + classname);
- return klass.ContextMenu;
- }
-
- public static object NewInstance (string typeName, IProject proj)
- {
- return LookupClassByName (typeName).NewInstance (proj);
- }
-
- public static Type GetType (string typeName, bool throwOnError)
- {
- Type t = Type.GetType (typeName, false);
- if (t != null) return t;
-
- foreach (WidgetLibrary lib in libraries) {
- t = lib.GetType (typeName);
- if (t != null) return t;
- }
-
- string tname, aname;
- int i = typeName.IndexOf (',');
- if (i != -1) {
- tname = typeName.Substring (0, i).Trim ();
- aname = typeName.Substring (i + 1).Trim ();
- }
- else {
- tname = typeName;
- aname = null;
- }
- foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ()) {
- if (aname == null || asm.GetName ().Name == aname) {
- t = asm.GetType (tname);
- if (t != null)
- return t;
- }
- }
-
- if (throwOnError)
- throw new TypeLoadException ("Could not load type '" + typeName + "'");
-
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Set.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/Set.cs
deleted file mode 100644
index 58f0b26b0b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/Set.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Stetic {
-
- public class Set : IEnumerable, IEnumerator {
-
- Hashtable hash = new Hashtable ();
-
- public bool this [object obj] {
- get {
- return hash[obj] != null;
- }
- set {
- if (value)
- hash[obj] = obj;
- else
- hash.Remove (obj);
- }
- }
-
- public void Clear ()
- {
- hash.Clear ();
- }
-
- public IEnumerator GetEnumerator ()
- {
- return this;
- }
-
- IDictionaryEnumerator hashEnum;
-
- public void Reset ()
- {
- hashEnum = hash.GetEnumerator ();
- hashEnum.Reset ();
- }
-
- public bool MoveNext ()
- {
- return hashEnum.MoveNext ();
- }
-
- public object Current {
- get {
- return hashEnum.Key;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/SignalDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/SignalDescriptor.cs
deleted file mode 100644
index 871364d67b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/SignalDescriptor.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using System;
-using System.Reflection;
-using System.Xml;
-
-namespace Stetic
-{
- [Serializable]
- public abstract class SignalDescriptor: ItemDescriptor
- {
- protected string name, label, description;
- protected string handlerTypeName;
- protected string handlerReturnTypeName;
- protected ParameterDescriptor[] handlerParameters;
-
- public SignalDescriptor (XmlElement elem, ItemGroup group, ClassDescriptor klass) : base (elem, group, klass)
- {
- }
-
- protected virtual void Load (XmlElement elem)
- {
- name = elem.GetAttribute ("name");
- label = elem.GetAttribute ("label");
- description = elem.GetAttribute ("description");
- }
-
- public override string Name {
- get { return name; }
- }
-
- public string Label {
- get { return label; }
- }
-
- public string Description {
- get { return description; }
- }
-
- public string HandlerTypeName {
- get { return handlerTypeName; }
- }
-
- public string HandlerReturnTypeName {
- get { return handlerReturnTypeName; }
- }
-
- public ParameterDescriptor[] HandlerParameters {
- get { return handlerParameters; }
- }
- }
-
- [Serializable]
- public class ParameterDescriptor
- {
- string name, type;
-
- public ParameterDescriptor (string name, string type)
- {
- this.name = name;
- this.type = type;
- }
-
- public string Name {
- get { return name; }
- }
-
- public string TypeName {
- get { return type; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TopLevelDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/TopLevelDialog.cs
deleted file mode 100644
index 04f066e507..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TopLevelDialog.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Gtk;
-
-namespace Stetic
-{
- public class TopLevelDialog: TopLevelWindow
- {
- HButtonBox buttonBox;
- VBox vbox;
- HSeparator separator;
-
- public TopLevelDialog ( )
- {
- vbox = new VBox ();
- separator = new HSeparator ();
- buttonBox = new HButtonBox ();
- vbox.PackEnd (buttonBox, false, false, 0);
- vbox.PackEnd (separator, false, false, 0);
- vbox.ShowAll ();
- Add (vbox);
- }
-
- public HButtonBox ActionArea {
- get { return buttonBox; }
- }
-
- public VBox VBox {
- get { return vbox; }
- }
-
- public bool HasSeparator
- {
- get { return separator.Visible; }
- set { separator.Visible = value; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TopLevelWindow.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/TopLevelWindow.cs
deleted file mode 100644
index 3e3cdc694a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TopLevelWindow.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Stetic
-{
- public class TopLevelWindow: Gtk.EventBox
- {
- string title;
- Gdk.WindowTypeHint typeHint;
- bool modal;
- bool resizable = true;
-
- public event EventHandler PropertyChanged;
-
- public string Title {
- get { return title; }
- set {
- title = value;
- NotifyChange ();
- }
- }
-
- public Gdk.WindowTypeHint TypeHint {
- get { return typeHint; }
- set {
- typeHint = value;
- NotifyChange ();
- }
- }
-
- public bool Modal {
- get { return modal; }
- set
- {
- modal = value;
- NotifyChange ();
- }
- }
-
- public bool Resizable
- {
- get { return resizable; }
- set
- {
- resizable = value;
- NotifyChange ();
- }
- }
-
- void NotifyChange ( )
- {
- if (PropertyChanged != null)
- PropertyChanged (this, EventArgs.Empty);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TranslatableAttribute.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/TranslatableAttribute.cs
deleted file mode 100644
index 2b938420e6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TranslatableAttribute.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using System;
-
-namespace Stetic {
-
- [AttributeUsage (AttributeTargets.Property | AttributeTargets.Field)]
- public sealed class TranslatableAttribute : Attribute {
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedClassDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedClassDescriptor.cs
deleted file mode 100644
index dbf7c6d5af..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedClassDescriptor.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Xml;
-
-namespace Stetic
-{
- public class TypedClassDescriptor: ClassDescriptor
- {
- Type wrapped, wrapper;
- GLib.GType gtype;
-
- MethodInfo ctorMethodInfo;
- MethodInfo ctorMethodInfoWithClass;
- ConstructorInfo cinfo;
- ConstructorInfo cinfoNoParams;
- bool useGTypeCtor;
- Gdk.Pixbuf icon;
- bool defaultValuesLoaded;
-
- const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
-
- static Gdk.Pixbuf missingIcon;
-
- public TypedClassDescriptor (Assembly assembly, XmlElement elem)
- {
- bool inheritedWrapper = false;
-
- wrapped = Registry.GetType (elem.GetAttribute ("type"), true);
- if (wrapped != null) {
- ConstructorInfo[] cInfos = wrapped.GetConstructors();
- foreach (ConstructorInfo ci in cInfos) {
- if (ci.GetParameters().Length == 0) {
- cinfoNoParams = ci;
- break;
- }
- }
- }
-
- if (elem.HasAttribute ("wrapper"))
- wrapper = Registry.GetType (elem.GetAttribute ("wrapper"), true);
- else {
- inheritedWrapper = true;
- string baseClass = elem.GetAttribute ("base-type");
- if (baseClass.Length > 0) {
- // If a base type is specified, use the wrapper of that base type
- TypedClassDescriptor parent = Registry.LookupClassByName (baseClass) as TypedClassDescriptor;
- if (parent != null)
- wrapper = parent.WrapperType;
- }
- else {
- for (Type type = wrapped.BaseType; type != null; type = type.BaseType) {
- TypedClassDescriptor parent = Registry.LookupClassByName (type.FullName) as TypedClassDescriptor;
- if (parent != null) {
- wrapper = parent.WrapperType;
- break;
- }
- }
- }
- if (wrapper == null)
- throw new ArgumentException (string.Format ("No wrapper type for class {0}", wrapped.FullName));
- }
-
- gtype = (GLib.GType)wrapped;
- cname = gtype.ToString ();
-
- string iconname = elem.GetAttribute ("icon");
- if (iconname.Length > 0) {
- try {
- // Using the pixbuf resource constructor generates a gdk warning.
- Gdk.PixbufLoader loader = new Gdk.PixbufLoader (assembly, iconname);
- icon = loader.Pixbuf;
- } catch {
- Console.WriteLine ("Could not load icon: " + iconname);
- icon = GetDefaultIcon ();
- }
- } else
- icon = GetDefaultIcon ();
-
- BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
-
- // If the wrapper is inherited from a base class, ignore the CreateInstance method
- // since it is going to create an instance of the base class.
- if (!inheritedWrapper) {
- ctorMethodInfoWithClass = wrapper.GetMethod ("CreateInstance", flags, null, new Type[] { typeof(ClassDescriptor)}, null);
- if (ctorMethodInfoWithClass == null) {
- ctorMethodInfo = wrapper.GetMethod ("CreateInstance", flags, null, Type.EmptyTypes, null);
- }
- }
-
- // Look for a constructor even if a CreateInstance method was
- // found, since it may return null.
- cinfo = wrapped.GetConstructor (Type.EmptyTypes);
- if (cinfo == null) {
- useGTypeCtor = true;
- cinfo = wrapped.GetConstructor (new Type[] { typeof (IntPtr) });
- }
-
- Load (elem);
- }
-
- public override Gdk.Pixbuf Icon {
- get {
- return icon;
- }
- }
-
- public override string WrappedTypeName {
- get { return WrappedType.FullName; }
- }
-
- public Type WrapperType {
- get {
- return wrapper;
- }
- }
-
- public Type WrappedType {
- get {
- return wrapped;
- }
- }
-
- public GLib.GType GType {
- get {
- return gtype;
- }
- }
-
- public override ObjectWrapper CreateWrapper ()
- {
- return (ObjectWrapper) Activator.CreateInstance (WrapperType);
- }
-
- [DllImport("libgobject-2.0-0.dll")]
- static extern IntPtr g_object_new (IntPtr gtype, IntPtr dummy);
-
- public override object CreateInstance (IProject proj)
- {
- object inst;
-
-
- if (ctorMethodInfoWithClass != null) {
- inst = ctorMethodInfoWithClass.Invoke (null, new object[] { this });
- if (inst != null) return inst;
- }
- if (ctorMethodInfo != null) {
- inst = ctorMethodInfo.Invoke (null, new object[0]);
- if (inst != null) return inst;
- }
-
- if (cinfoNoParams != null) {
- inst = cinfoNoParams.Invoke (null, null);
- if (inst != null) return inst;
- }
-
-
- if (cinfo == null)
- throw new InvalidOperationException ("The class '" + wrapped + "' does not have a default constructor.");
-
- if (!useGTypeCtor)
- inst = cinfo.Invoke (new object[0]);
- else {
- IntPtr raw = g_object_new (gtype.Val, IntPtr.Zero);
- inst = cinfo.Invoke (new object[] { raw });
- }
-
- return inst;
- }
-
- internal protected override ItemDescriptor CreateItemDescriptor (XmlElement elem, ItemGroup group)
- {
- if (elem.Name == "property")
- return new TypedPropertyDescriptor (elem, group, this);
- else if (elem.Name == "signal")
- return new TypedSignalDescriptor (elem, group, this);
- else
- return base.CreateItemDescriptor (elem, group);
- }
-
- Gdk.Pixbuf GetDefaultIcon ()
- {
- if (missingIcon == null)
- missingIcon = WidgetUtils.MissingIcon;
- return missingIcon;
- }
-
- internal void LoadDefaultValues ()
- {
- // This is a hack because there is no managed way of getting
- // the default value of a GObject property.
- // This method creates an dummy instance of this class and
- // gets the values for their properties. Those values are
- // considered the default
-
- if (defaultValuesLoaded)
- return;
- defaultValuesLoaded = true;
-
- object ob = NewInstance (null, false);
-
- foreach (ItemGroup group in ItemGroups) {
- foreach (ItemDescriptor item in group) {
- TypedPropertyDescriptor prop = item as TypedPropertyDescriptor;
- if (prop == null)
- continue;
-
- if (!prop.HasDefault) {
- prop.SetDefault (null);
- } else {
- object val = prop.GetValue (ob);
- prop.SetDefault (val);
- }
- }
- }
- ObjectWrapper ww = ObjectWrapper.Lookup (ob);
- ww.Dispose ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedPropertyDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedPropertyDescriptor.cs
deleted file mode 100644
index 5be86a0ad6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedPropertyDescriptor.cs
+++ /dev/null
@@ -1,321 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Collections;
-using System.Reflection;
-using System.Xml;
-
-namespace Stetic
-{
- public class TypedPropertyDescriptor : PropertyDescriptor {
-
- PropertyInfo memberInfo, propertyInfo, runtimePropertyInfo, runtimeMemberInfo;
- ParamSpec pspec;
- TypedPropertyDescriptor gladeProperty;
- bool isWrapperProperty;
- TypedClassDescriptor klass;
- bool defaultSet;
-
- const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
-
- public TypedPropertyDescriptor (XmlElement elem, ItemGroup group, TypedClassDescriptor klass) : base (elem, group, klass)
- {
- this.klass = klass;
- string propertyName = elem.GetAttribute ("name");
- int dot = propertyName.IndexOf ('.');
-
- if (dot != -1) {
- // Sub-property (eg, "Alignment.Value")
- memberInfo = FindProperty (klass.WrapperType, klass.WrappedType, propertyName.Substring (0, dot));
- isWrapperProperty = memberInfo.DeclaringType.IsSubclassOf (typeof (ObjectWrapper));
- gladeProperty = new TypedPropertyDescriptor (isWrapperProperty ? klass.WrapperType : klass.WrappedType, memberInfo.Name);
- propertyInfo = FindProperty (memberInfo.PropertyType, propertyName.Substring (dot + 1));
- } else {
- // Basic simple property
- propertyInfo = FindProperty (klass.WrapperType, klass.WrappedType, propertyName);
- isWrapperProperty = propertyInfo.DeclaringType.IsSubclassOf (typeof (ObjectWrapper));
- }
-
- // Wrapper properties that override widgets properties (using the same name)
- // must be considered runtime properties (will be available at run-time).
- if (!isWrapperProperty || klass.WrappedType.GetProperty (propertyName) != null)
- isRuntimeProperty = true;
-
- if (!IsInternal && propertyInfo.PropertyType.IsEnum &&
- Registry.LookupEnum (propertyInfo.PropertyType.FullName) == null)
- throw new ArgumentException ("No EnumDescriptor for " + propertyInfo.PropertyType.FullName + "(" + klass.WrappedType.FullName + "." + propertyName + ")");
-
- pspec = FindPSpec (propertyInfo);
-
- if (isWrapperProperty && pspec == null) {
- PropertyInfo pinfo = klass.WrappedType.GetProperty (propertyInfo.Name, flags);
- if (pinfo != null)
- pspec = FindPSpec (pinfo);
- }
-
- if (pspec != null) {
- // This information will be overridden by what's specified in the xml file
- description = pspec.Blurb;
- minimum = pspec.Minimum;
- maximum = pspec.Maximum;
- label = propertyName;
- if (!elem.HasAttribute ("ignore-default"))
- hasDefault = Type.GetTypeCode (PropertyType) != TypeCode.Object || PropertyType.IsEnum;
- } else {
- label = propertyInfo.Name;
- gladeOverride = true;
- }
-
- string typeName = elem.GetAttribute ("editor");
- if (typeName.Length > 0)
- editorType = Registry.GetType (typeName, false);
-
- // Look for a default value attribute
-
- object[] ats = propertyInfo.GetCustomAttributes (typeof(DefaultValueAttribute), true);
- if (ats.Length > 0) {
- DefaultValueAttribute at = (DefaultValueAttribute) ats [0];
- defaultValue = at.Value;
- }
-
- // Load default data
- Load (elem);
- }
-
- TypedPropertyDescriptor (Type objectType, string propertyName)
- {
- propertyInfo = FindProperty (objectType, propertyName);
- isWrapperProperty = false;
-
- pspec = FindPSpec (propertyInfo);
- if (pspec != null) {
- label = propertyName;
- description = pspec.Blurb;
- minimum = pspec.Minimum;
- maximum = pspec.Maximum;
- hasDefault = Type.GetTypeCode (PropertyType) != TypeCode.Object || PropertyType.IsEnum;
- } else
- label = propertyInfo.Name;
- }
-
- static PropertyInfo FindProperty (Type type, string propertyName) {
- return FindProperty (null, type, propertyName);
- }
-
- static PropertyInfo FindProperty (Type wrapperType, Type objectType, string propertyName)
- {
- PropertyInfo info = null;
-
- if (wrapperType != null) {
- info = wrapperType.GetProperty (propertyName, flags);
- if (info != null)
- return info;
- }
-
- try {
- info = objectType.GetProperty (propertyName, flags);
- }
- catch (AmbiguousMatchException) {
- foreach (PropertyInfo pi in objectType.GetProperties ()) {
- if (pi.Name == propertyName) {
- info = pi;
- break;
- }
- }
- }
-
- if (info != null)
- return info;
-
- throw new ArgumentException ("Invalid property name " + objectType.Name + "." + propertyName);
- }
-
- ParamSpec FindPSpec (PropertyInfo pinfo)
- {
- foreach (object attr in pinfo.GetCustomAttributes (false)) {
- if (attr is GLib.PropertyAttribute) {
- GLib.PropertyAttribute pattr = (GLib.PropertyAttribute)attr;
- return ParamSpec.LookupObjectProperty (pinfo.DeclaringType, pattr.Name);
- }
-
- if (attr is Gtk.ChildPropertyAttribute) {
- Gtk.ChildPropertyAttribute cpattr = (Gtk.ChildPropertyAttribute)attr;
- return ParamSpec.LookupChildProperty (pinfo.DeclaringType.DeclaringType, cpattr.Name);
- }
- }
- return null;
- }
-
- // The property's internal name
- public override string Name {
- get {
- return propertyInfo.Name;
- }
- }
-
- // The property's type
- public override Type PropertyType {
- get {
- return propertyInfo.PropertyType;
- }
- }
-
- // The property's PropertyInfo
- public PropertyInfo PropertyInfo {
- get {
- return propertyInfo;
- }
- }
-
- // The property's ParamSpec
- public virtual ParamSpec ParamSpec {
- get {
- return pspec;
- }
- }
-
- public override bool IsDefaultValue (object value)
- {
- if (defaultValue != null)
- return base.IsDefaultValue (value);
- if (ParamSpec != null && value != null)
- return ParamSpec.IsDefaultValue (value);
- else
- return false;
- }
-
- public override void ResetValue (object instance)
- {
- // This is a hack because there is no managed way of getting
- // the default value of a GObject property. The call to LoadDefaultValues
- // will guess the default values from a dummy instance
- if (!defaultSet) {
- ObjectWrapper ww = ObjectWrapper.Lookup (instance);
- TypedClassDescriptor td = ww.ClassDescriptor as TypedClassDescriptor;
- if (td != null)
- td.LoadDefaultValues ();
- defaultSet = true;
- }
- base.ResetValue (instance);
- }
-
- internal void SetDefault (object val)
- {
- defaultValue = val;
- defaultSet = true;
- }
-
- // Gets the value of the property on @obj
- public override object GetValue (object obj)
- {
- try {
- if (isWrapperProperty)
- obj = ObjectWrapper.Lookup (obj);
- if (memberInfo != null)
- obj = memberInfo.GetValue (obj, null);
- return propertyInfo.GetValue (obj, null);
- } catch (Exception ex) {
- throw new InvalidOperationException ("Could not get value for property " + klass.Name + "." + Name + " from object '" + obj + "'", ex);
- }
- }
-
- // Whether or not the property is writable
- public override bool CanWrite {
- get {
- return propertyInfo.CanWrite;
- }
- }
-
- // Sets the value of the property on @obj
- public override void SetValue (object obj, object value)
- {
- ObjectWrapper ww = ObjectWrapper.Lookup (obj);
- IDisposable t = ww != null && !ww.Loading? ww.UndoManager.AtomicChange : null;
- try {
- if (isWrapperProperty)
- obj = ww;
- if (memberInfo != null)
- obj = memberInfo.GetValue (obj, null);
- propertyInfo.SetValue (obj, value, null);
- } catch (Exception ex) {
- throw new InvalidOperationException ("Could not set value for property " + klass.Name + "." + Name + " to object '" + obj + "'", ex);
- } finally {
- if (t != null)
- t.Dispose ();
- }
- }
-
- // The property's type at run time
- public override Type RuntimePropertyType {
- get {
- if (runtimePropertyInfo == null)
- SetupRuntimeProperties ();
- return runtimePropertyInfo.PropertyType;
- }
- }
-
- public override void SetRuntimeValue (object obj, object value)
- {
- if (runtimePropertyInfo == null)
- SetupRuntimeProperties ();
- if (runtimeMemberInfo != null)
- obj = runtimeMemberInfo.GetValue (obj, null);
-
- if (runtimePropertyInfo.PropertyType.IsInstanceOfType (value))
- runtimePropertyInfo.SetValue (obj, value, null);
- }
-
- public override object GetRuntimeValue (object obj)
- {
- if (runtimePropertyInfo == null)
- SetupRuntimeProperties ();
- if (runtimeMemberInfo != null)
- obj = runtimeMemberInfo.GetValue (obj, null);
- return runtimePropertyInfo.GetValue (obj, null);
- }
-
- void SetupRuntimeProperties ()
- {
- if (isWrapperProperty) {
- Type t = klass.WrappedType;
- if (memberInfo != null) {
- runtimeMemberInfo = t.GetProperty (memberInfo.Name, flags);
- t = runtimeMemberInfo.PropertyType;
- }
- runtimePropertyInfo = t.GetProperty (propertyInfo.Name, flags);
- } else {
- runtimeMemberInfo = memberInfo;
- runtimePropertyInfo = propertyInfo;
- }
- }
-
- public virtual bool GladeOverride {
- get {
- return gladeOverride;
- }
- }
-
- public TypedPropertyDescriptor GladeProperty {
- get {
- if (gladeProperty != null)
- return gladeProperty;
- else
- return this;
- }
- }
-
- public virtual string GladeName {
- get {
- if (gladeName != null)
- return gladeName;
- else if (pspec != null && pspec.Name != null)
- return pspec.Name.Replace ('-', '_');
- else
- return null;
- }
- }
-
- public override string InternalChildId {
- get { return GladeName; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedSignalDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedSignalDescriptor.cs
deleted file mode 100644
index 5c87947dee..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/TypedSignalDescriptor.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-using System.Reflection;
-using System.Xml;
-
-namespace Stetic
-{
- [Serializable]
- public class TypedSignalDescriptor: SignalDescriptor
- {
- string gladeName;
-
- const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
-
- public TypedSignalDescriptor (XmlElement elem, ItemGroup group, TypedClassDescriptor klass) : base (elem, group, klass)
- {
- Load (elem);
-
- EventInfo eventInfo = FindEvent (klass.WrapperType, klass.WrappedType, name);
- MethodInfo handler = eventInfo.EventHandlerType.GetMethod ("Invoke");
-
- if (elem.HasAttribute ("glade-name"))
- gladeName = elem.GetAttribute ("glade-name");
- else {
- object[] att = eventInfo.GetCustomAttributes (typeof(GLib.SignalAttribute), true);
- if (att.Length > 0)
- gladeName = ((GLib.SignalAttribute)att[0]).CName;
- }
-
- handlerTypeName = eventInfo.EventHandlerType.FullName;
- handlerReturnTypeName = handler.ReturnType.FullName;
-
- ParameterInfo[] pars = handler.GetParameters ();
- handlerParameters = new ParameterDescriptor [pars.Length];
- for (int n=0; n<pars.Length; n++)
- handlerParameters [n] = new ParameterDescriptor (pars[n].Name, pars [n].ParameterType.FullName);
- }
-
- public string GladeName {
- get { return gladeName; }
- }
-
- static EventInfo FindEvent (Type wrapperType, Type objectType, string name)
- {
- EventInfo info;
-
- if (wrapperType != null) {
- info = wrapperType.GetEvent (name, flags);
- if (info != null)
- return info;
- }
-
- info = objectType.GetEvent (name, flags);
- if (info != null)
- return info;
-
- throw new ArgumentException ("Invalid event name " + objectType.Name + "." + name);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/WidgetLibrary.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/WidgetLibrary.cs
deleted file mode 100644
index b35c376382..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/WidgetLibrary.cs
+++ /dev/null
@@ -1,163 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-
-namespace Stetic
-{
- public abstract class WidgetLibrary: IDisposable
- {
- Hashtable classes_by_cname = new Hashtable ();
- Hashtable classes_by_csname = new Hashtable ();
- Hashtable enums = new Hashtable ();
- string targetGtkVersion;
-
- XmlElement[] importElems = new XmlElement [0];
- XmlElement[] exportElems = new XmlElement [0];
-
- public event EventHandler Changed;
-
- public abstract string Name { get; }
-
- public virtual bool NeedsReload {
- get { return false; }
- }
-
- public virtual bool CanReload {
- get { return false; }
- }
-
- // Returns true if it is possible to generate code using this widget library.
- // Not all widget libraries can generate code. For example, when a widget
- // depends on a wrapper class, and the wrapper class can't be loaded in memory,
- // then it is not possible to generate code.
- public virtual bool CanGenerateCode {
- get { return true; }
- }
-
- public virtual string[] GetLibraryDependencies ()
- {
- return new string [0];
- }
-
- public string TargetGtkVersion {
- get { return targetGtkVersion != null && targetGtkVersion.Length > 0 ? targetGtkVersion : "2.4"; }
- }
-
- public bool SupportsGtkVersion (string targetVersion)
- {
- return WidgetUtils.CompareVersions (TargetGtkVersion, targetVersion) >= 0;
- }
-
- public virtual void Reload ()
- {
- Load ();
- }
-
- public virtual void Load ()
- {
- }
-
- protected virtual void Load (XmlDocument objects)
- {
- classes_by_cname.Clear ();
- classes_by_csname.Clear ();
- enums.Clear ();
-
- if (objects == null || objects.DocumentElement == null)
- return;
-
- targetGtkVersion = objects.DocumentElement.GetAttribute ("gtk-version");
- if (targetGtkVersion.Length == 0)
- targetGtkVersion = "2.4";
-
- foreach (XmlElement element in objects.SelectNodes ("/objects/enum")) {
- EnumDescriptor enm = new EnumDescriptor (element);
- enums[enm.Name] = enm;
- }
-
- foreach (XmlElement element in objects.SelectNodes ("/objects/object"))
- AddClass (LoadClassDescriptor (element));
-
- XmlNamespaceManager nsm = new XmlNamespaceManager (objects.NameTable);
- nsm.AddNamespace ("xsl", "http://www.w3.org/1999/XSL/Transform");
-
- XmlNodeList nodes = objects.SelectNodes ("/objects/object/glade-transform/import/xsl:*", nsm);
- importElems = new XmlElement [nodes.Count];
- for (int n=0; n<nodes.Count; n++)
- importElems [n] = (XmlElement) nodes[n];
-
- nodes = objects.SelectNodes ("/objects/object/glade-transform/export/xsl:*", nsm);
- exportElems = new XmlElement [nodes.Count];
- for (int n=0; n<nodes.Count; n++)
- exportElems [n] = (XmlElement) nodes[n];
- }
-
- protected void AddClass (ClassDescriptor klass)
- {
- if (klass == null)
- return;
- klass.SetLibrary (this);
- classes_by_cname[klass.CName] = klass;
- classes_by_csname[klass.WrappedTypeName] = klass;
- }
-
- public virtual void Dispose ()
- {
- }
-
- // Flush is called by the registry to free cached data stored in the widget library.
- public virtual void Flush ()
- {
- }
-
- protected abstract ClassDescriptor LoadClassDescriptor (XmlElement element);
-
-
- public virtual XmlElement[] GetGladeImportTransformElements ()
- {
- return importElems;
- }
-
- public virtual XmlElement[] GetGladeExportTransformElements ()
- {
- return exportElems;
- }
-
- public virtual ICollection AllClasses {
- get {
- return classes_by_csname.Values;
- }
- }
-
- public virtual EnumDescriptor LookupEnum (string typeName)
- {
- return (EnumDescriptor)enums[typeName];
- }
-
- public virtual ClassDescriptor LookupClassByCName (string cname)
- {
- return (ClassDescriptor)classes_by_cname[cname];
- }
-
- public virtual ClassDescriptor LookupClassByName (string csname)
- {
- return (ClassDescriptor)classes_by_csname[csname];
- }
-
- public virtual Type GetType (string typeName)
- {
- return null;
- }
-
- public virtual System.IO.Stream GetResource (string name)
- {
- return null;
- }
-
- protected virtual void OnChanged ()
- {
- if (Changed != null)
- Changed (this, EventArgs.Empty);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/WidgetUtils.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/WidgetUtils.cs
deleted file mode 100644
index e97b352f49..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/WidgetUtils.cs
+++ /dev/null
@@ -1,393 +0,0 @@
-using System;
-using System.IO;
-using System.Reflection;
-using System.Collections;
-using System.Xml;
-using Stetic.Wrapper;
-
-namespace Stetic
-{
- public static class WidgetUtils
- {
- static Gdk.Atom steticAtom;
- static int undoIdCount;
- static Gdk.Pixbuf missingIcon;
- static Gtk.Widget renderer;
-
- public static Gdk.Atom ApplicationXSteticAtom {
- get {
- if (steticAtom == null)
- steticAtom = Gdk.Atom.Intern ("application/x-stetic", false);
- return steticAtom;
- }
- }
-
- public static XmlElement ExportWidget (Gtk.Widget widget)
- {
- XmlDocument doc = new XmlDocument ();
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (widget);
- if (wrapper == null)
- throw new InvalidOperationException ();
-
- XmlElement elem = wrapper.Write (new ObjectWriter (doc, FileFormat.Native));
- doc.AppendChild (elem);
- return doc.DocumentElement;
- }
-
- public static Gtk.Widget ImportWidget (IProject project, XmlElement element)
- {
- ObjectReader reader = new ObjectReader (project, FileFormat.Native);
- ObjectWrapper wrapper = Stetic.ObjectWrapper.ReadObject (reader, element, null);
- return wrapper.Wrapped as Gtk.Widget;
- }
-
- public static XmlElement Write (ObjectWrapper wrapper, XmlDocument doc)
- {
- ClassDescriptor klass = wrapper.ClassDescriptor;
-
- XmlElement elem = doc.CreateElement ("widget");
- elem.SetAttribute ("class", klass.Name);
- elem.SetAttribute ("id", ((Gtk.Widget)wrapper.Wrapped).Name);
-
- GetProps (wrapper, elem);
- GetSignals (wrapper, elem);
- return elem;
- }
-
- public static void GetProps (ObjectWrapper wrapper, XmlElement parent_elem)
- {
- ClassDescriptor klass = wrapper.ClassDescriptor;
-
- foreach (ItemGroup group in klass.ItemGroups) {
- foreach (ItemDescriptor item in group) {
- PropertyDescriptor prop = item as PropertyDescriptor;
- if (prop == null)
- continue;
- if (!prop.VisibleFor (wrapper.Wrapped) || !prop.CanWrite || prop.Name == "Name") // Name is written in the id attribute
- continue;
-
- object value = prop.GetValue (wrapper.Wrapped);
-
- // If the property has its default value, we don't need to write it
- if (value == null || (prop.HasDefault && prop.IsDefaultValue (value)))
- continue;
-
- string val = prop.ValueToString (value);
- if (val == null)
- continue;
-
- XmlElement prop_elem = parent_elem.OwnerDocument.CreateElement ("property");
- prop_elem.SetAttribute ("name", prop.Name);
- if (val.Length > 0)
- prop_elem.InnerText = val;
-
- if (prop.Translatable && prop.IsTranslated (wrapper.Wrapped)) {
- prop_elem.SetAttribute ("translatable", "yes");
- string tcx = prop.TranslationContext (wrapper.Wrapped);
- if (tcx != null && tcx.Length > 0) {
- prop_elem.SetAttribute ("context", "yes");
- prop_elem.InnerText = tcx + "|" + prop_elem.InnerText;
- }
- string tcm = prop.TranslationComment (wrapper.Wrapped);
- if (tcm != null && tcm.Length > 0)
- prop_elem.SetAttribute ("comments", prop.TranslationComment (wrapper.Wrapped));
- }
-
- parent_elem.AppendChild (prop_elem);
- }
- }
- }
-
- public static void GetSignals (ObjectWrapper ob, XmlElement parent_elem)
- {
- foreach (Signal signal in ob.Signals) {
- if (!signal.SignalDescriptor.VisibleFor (ob.Wrapped))
- continue;
-
- XmlElement signal_elem = parent_elem.OwnerDocument.CreateElement ("signal");
- signal_elem.SetAttribute ("name", signal.SignalDescriptor.Name);
- signal_elem.SetAttribute ("handler", signal.Handler);
- if (signal.After)
- signal_elem.SetAttribute ("after", "yes");
- parent_elem.AppendChild (signal_elem);
- }
- }
-
- static public void Read (ObjectWrapper wrapper, XmlElement elem)
- {
- string className = elem.GetAttribute ("class");
- if (className == null)
- throw new GladeException ("<widget> node with no class name");
-
- ClassDescriptor klass = Registry.LookupClassByName (className);
- if (klass == null)
- throw new GladeException ("No stetic ClassDescriptor for " + className);
-
- Gtk.Widget widget = (Gtk.Widget) wrapper.Wrapped;
- if (widget == null) {
- widget = (Gtk.Widget) klass.CreateInstance (wrapper.Project);
- //set name before binding to ensure
- //that ObjectWrapper.RootWrapperName will be valid
- widget.Name = elem.GetAttribute ("id");
- ObjectWrapper.Bind (wrapper.Project, klass, wrapper, widget, true);
- } else {
- widget.Name = elem.GetAttribute ("id");
- }
-
- ReadMembers (klass, wrapper, widget, elem);
-
- if (!(widget is Gtk.Window))
- widget.ShowAll ();
- }
-
- public static void ReadMembers (ClassDescriptor klass, ObjectWrapper wrapper, object wrapped, XmlElement elem)
- {
- foreach (XmlNode node in elem.ChildNodes) {
- XmlElement child = node as XmlElement;
- if (child == null)
- continue;
-
- if (child.LocalName == "signal")
- ReadSignal (klass, wrapper, child);
- else if (child.LocalName == "property")
- ReadProperty (klass, wrapper, wrapped, child);
- }
- }
-
- public static void ReadSignal (ClassDescriptor klass, ObjectWrapper ob, XmlElement elem)
- {
- string name = elem.GetAttribute ("name");
- SignalDescriptor signal = klass.SignalGroups.GetItem (name) as SignalDescriptor;
- if (signal != null) {
- string handler = elem.GetAttribute ("handler");
- bool after = elem.GetAttribute ("after") == "yes";
- ob.Signals.Add (new Signal (signal, handler, after));
- }
- }
-
- public static void ReadProperty (ClassDescriptor klass, ObjectWrapper wrapper, object wrapped, XmlElement prop_node)
- {
- string name = prop_node.GetAttribute ("name");
- PropertyDescriptor prop = klass [name] as PropertyDescriptor;
- if (prop == null || !prop.CanWrite)
- return;
-
- string strval = prop_node.InnerText;
-
- // Skip translation context
- if (prop_node.GetAttribute ("context") == "yes" && strval.IndexOf ('|') != -1)
- strval = strval.Substring (strval.IndexOf ('|') + 1);
-
- object value = prop.StringToValue (strval);
- prop.SetValue (wrapped, value);
-
- if (prop.Translatable) {
- if (prop_node.GetAttribute ("translatable") != "yes") {
- prop.SetTranslated (wrapped, false);
- }
- else {
- prop.SetTranslated (wrapped, true);
- if (prop_node.GetAttribute ("context") == "yes") {
- strval = prop_node.InnerText;
- int bar = strval.IndexOf ('|');
- if (bar != -1)
- prop.SetTranslationContext (wrapped, strval.Substring (0, bar));
- }
-
- if (prop_node.HasAttribute ("comments"))
- prop.SetTranslationComment (wrapped, prop_node.GetAttribute ("comments"));
- }
- }
- }
-
- static public void SetPacking (Stetic.Wrapper.Container.ContainerChild wrapper, XmlElement child_elem)
- {
- XmlElement packing = child_elem["packing"];
- if (packing == null)
- return;
-
- Gtk.Container.ContainerChild cc = wrapper.Wrapped as Gtk.Container.ContainerChild;
- ClassDescriptor klass = wrapper.ClassDescriptor;
- ReadMembers (klass, wrapper, cc, packing);
- }
-
- internal static XmlElement CreatePacking (XmlDocument doc, Stetic.Wrapper.Container.ContainerChild childwrapper)
- {
- XmlElement packing_elem = doc.CreateElement ("packing");
- WidgetUtils.GetProps (childwrapper, packing_elem);
- return packing_elem;
- }
-
- public static void Copy (Gtk.Widget widget, Gtk.SelectionData seldata, bool copyAsText)
- {
- XmlElement elem = ExportWidget (widget);
- if (elem == null)
- return;
-
- if (copyAsText)
- seldata.Text = elem.OuterXml;
- else
- seldata.Set (ApplicationXSteticAtom, 8, System.Text.Encoding.UTF8.GetBytes (elem.OuterXml));
- }
-
- public static Stetic.Wrapper.Widget Paste (IProject project, Gtk.SelectionData seldata)
- {
- if (seldata == null || seldata.Type == null || seldata.Type.Name != ApplicationXSteticAtom.Name)
- return null;
-
- string data = System.Text.Encoding.UTF8.GetString (seldata.Data);
- XmlDocument doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
- try {
- doc.LoadXml (data);
- } catch {
- return null;
- }
-
- Gtk.Widget w = ImportWidget (project, doc.DocumentElement);
- return Wrapper.Widget.Lookup (w);
- }
-
- public static IDesignArea GetDesignArea (Gtk.Widget w)
- {
- while (w != null && !(w is IDesignArea))
- w = w.Parent;
- return w as IDesignArea;
- }
-
- internal static void ParseWidgetName (string name, out string baseName, out int idx)
- {
- // Extract a numerical suffix from the name
- // If suffix has more than 4 digits, only the last 4 digits are considered
- // a numerical suffix.
-
- int n;
- for (n = name.Length - 1; n >= name.Length-4 && n >= 0 && char.IsDigit (name [n]); n--)
- ;
-
- if (n < name.Length - 1) {
- baseName = name.Substring (0, n + 1);
- idx = int.Parse (name.Substring (n + 1));
- } else {
- baseName = name;
- idx = 0;
- }
- }
-
- internal static string GetUndoId ()
- {
- return (undoIdCount++).ToString ();
- }
-
- public static Gdk.Pixbuf MissingIcon {
- get {
- if (missingIcon == null) {
- try {
- missingIcon = Gtk.IconTheme.Default.LoadIcon ("gtk-missing-image", 16, 0);
- } catch {}
- if (missingIcon == null) {
- try {
- missingIcon = Gdk.Pixbuf.LoadFromResource ("missing.png");
- } catch (Exception e) {
- Console.WriteLine ("Error while loading pixbuf 'missing.png': " + e);
- }
- }
- }
- return missingIcon;
- }
- }
-
- public static string AbsoluteToRelativePath (string baseDirectoryPath, string absPath)
- {
- if (! Path.IsPathRooted (absPath))
- return absPath;
-
- absPath = Path.GetFullPath (absPath);
- baseDirectoryPath = Path.GetFullPath (baseDirectoryPath);
-
- char[] separators = { Path.DirectorySeparatorChar, Path.VolumeSeparatorChar, Path.AltDirectorySeparatorChar };
- baseDirectoryPath = baseDirectoryPath.TrimEnd (separators);
- string[] bPath = baseDirectoryPath.Split (separators);
- string[] aPath = absPath.Split (separators);
- int indx = 0;
- for(; indx < Math.Min(bPath.Length, aPath.Length); ++indx){
- if(!bPath[indx].Equals(aPath[indx]))
- break;
- }
-
- if (indx == 0) {
- return absPath;
- }
-
- string erg = "";
-
- if(indx == bPath.Length) {
- erg += "." + Path.DirectorySeparatorChar;
- } else {
- for (int i = indx; i < bPath.Length; ++i) {
- erg += ".." + Path.DirectorySeparatorChar;
- }
- }
- erg += String.Join(Path.DirectorySeparatorChar.ToString(), aPath, indx, aPath.Length-indx);
-
- return erg;
- }
-
- public static int CompareVersions (string v1, string v2)
- {
- string[] a1 = v1.Split ('.');
- string[] a2 = v2.Split ('.');
-
- for (int n=0; n<a1.Length; n++) {
- if (n >= a2.Length)
- return -1;
- if (a1[n].Length == 0) {
- if (a2[n].Length != 0)
- return 1;
- continue;
- }
- try {
- int n1 = int.Parse (a1[n]);
- int n2 = int.Parse (a2[n]);
- if (n1 < n2)
- return 1;
- else if (n1 > n2)
- return -1;
- } catch {
- return 1;
- }
- }
- if (a2.Length > a1.Length)
- return 1;
- return 0;
- }
-
- public static Gdk.Pixbuf LoadIcon (string name, Gtk.IconSize size)
- {
- if (renderer == null)
- renderer = new Gtk.HBox ();
- Gdk.Pixbuf image = renderer.RenderIcon (name, size, null);
- if (image != null)
- return image;
-
- int w, h;
- Gtk.Icon.SizeLookup (size, out w, out h);
- try {
- return Gtk.IconTheme.Default.LoadIcon (name, w, 0);
- } catch {
- // Icon not in theme
- return MissingIcon;
- }
- }
-
- public static System.CodeDom.CodeTypeReference ToGlobalTypeRef (this Type type)
- {
- return new System.CodeDom.CodeTypeReference (type, System.CodeDom.CodeTypeReferenceOptions.GlobalReference);
- }
-
- public static System.CodeDom.CodeTypeReference ToGlobalTypeRef (this string type)
- {
- return new System.CodeDom.CodeTypeReference (type, System.CodeDom.CodeTypeReferenceOptions.GlobalReference);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/bin/Release/libstetic2.dll.config b/main/src/addins/MonoDevelop.GtkCore2/libstetic/bin/Release/libstetic2.dll.config
deleted file mode 100644
index 8c4c6ab9a9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/bin/Release/libstetic2.dll.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<configuration>
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.dylib" os="osx" />
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.dylib" os="osx"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.dylib" os="osx"/>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Accelerator.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Accelerator.cs
deleted file mode 100644
index f6f884848d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Accelerator.cs
+++ /dev/null
@@ -1,196 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using Mono.Unix;
-
-namespace Stetic.Editor {
-
- [PropertyEditor ("Accel", "AccelChanged")]
- public class Accelerator : Gtk.HBox, IPropertyEditor {
-
- uint keyval;
- Gdk.ModifierType mask;
- bool editing;
-
- Gtk.Button clearButton;
- Gtk.Entry entry;
-
- public const Gdk.ModifierType AcceleratorModifierMask = ~(
- Gdk.ModifierType.Button1Mask |
- Gdk.ModifierType.Button2Mask |
- Gdk.ModifierType.Button3Mask |
- Gdk.ModifierType.Button4Mask |
- Gdk.ModifierType.Button5Mask);
-
- public Accelerator ()
- {
- entry = new Gtk.Entry ();
- clearButton = new Gtk.Button (new Gtk.Image (Gtk.Stock.Clear, Gtk.IconSize.Menu));
- PackStart (entry, true, true, 0);
- PackStart (clearButton, false, false, 3);
- clearButton.Clicked += delegate (object s, EventArgs args) {
- Value = null;
- };
- entry.IsEditable = false;
- entry.ButtonPressEvent += OnButtonPressEvent;
- entry.KeyPressEvent += OnKeyPressEvent;
- ShowAll ();
- }
-
- public void Initialize (PropertyDescriptor descriptor)
- {
- if (descriptor.PropertyType != typeof(string))
- throw new ApplicationException ("Accelerator editor does not support editing values of type " + descriptor.PropertyType);
- }
-
- public void AttachObject (object obj)
- {
- Value = null;
- }
-
- [GLib.ConnectBefore]
- void OnButtonPressEvent (object s, Gtk.ButtonPressEventArgs args)
- {
- if (editing)
- Ungrab (args.Event.Time);
- else
- Grab (args.Event.Window, args.Event.Time);
- args.RetVal = true;
- }
-
- GrabDialog grabWindow;
-
- void Ungrab (uint time)
- {
- if (!editing)
- return;
- editing = false;
-
- if (Value != null)
- entry.Text = (string) Value;
- else
- entry.Text = "";
-
- grabWindow.Destroy ();
- }
-
- void Grab (Gdk.Window window, uint time)
- {
- if (editing)
- return;
-
- grabWindow = new GrabDialog ();
- editing = true;
- entry.Text = Catalog.GetString ("Press a key...");
- grabWindow.TransientFor = this.Toplevel as Gtk.Window;
- grabWindow.Run ();
- this.keyval = grabWindow.Keyval;
- this.mask = grabWindow.Mask;
- Ungrab (time);
- EmitAccelChanged ();
- }
-
- [GLib.ConnectBefore]
- void OnKeyPressEvent (object s, Gtk.KeyPressEventArgs args)
- {
- Gdk.EventKey evt = args.Event;
-
- if (!editing || !Gtk.Accelerator.Valid (evt.KeyValue, evt.State))
- return;
-
- uint keyval;
- int effectiveGroup, level;
- Gdk.ModifierType consumedMods, mask;
-
- // We know this will succeed, since we're already here...
- Gdk.Keymap.Default.TranslateKeyboardState (evt.HardwareKeycode, evt.State, evt.Group, out keyval, out effectiveGroup, out level, out consumedMods);
- mask = evt.State & AcceleratorModifierMask & ~consumedMods;
-
- if (evt.Key != Gdk.Key.Escape || mask != 0) {
- this.keyval = keyval;
- this.mask = mask;
- }
-
- clearButton.Sensitive = true;
-
- Ungrab (evt.Time);
- EmitAccelChanged ();
- args.RetVal = true;
- }
-
- public object Value {
- get {
- if (keyval != 0)
- return Gtk.Accelerator.Name (keyval, mask);
- else
- return null;
- }
- set {
- string s = value as string;
- if (s == null) {
- keyval = 0;
- mask = 0;
- clearButton.Sensitive = false;
- } else {
- Gtk.Accelerator.Parse (s, out keyval, out mask);
- clearButton.Sensitive = true;
- }
- if (Value != null)
- entry.Text = (string) Value;
- else
- entry.Text = "";
- EmitAccelChanged ();
- }
- }
-
- public event EventHandler ValueChanged;
-
- void EmitAccelChanged ()
- {
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
- }
-
- class GrabDialog: Gtk.Dialog
- {
- public uint Keyval;
- public Gdk.ModifierType Mask;
-
- public GrabDialog ()
- {
- Decorated = false;
- this.SkipPagerHint = true;
- this.SkipTaskbarHint = true;
- this.WindowPosition = Gtk.WindowPosition.CenterOnParent;
- Gtk.Frame f = new Gtk.Frame ();
- f.Shadow = Gtk.ShadowType.Out;
- this.VBox.PackStart (f, true, true, 0);
- Gtk.Label lab = new Gtk.Label (Catalog.GetString ("Press the key combination you want to assign to the accelerator..."));
- lab.Xpad = 12;
- lab.Ypad = 12;
- f.Add (lab);
- ShowAll ();
- }
-
- protected override bool OnKeyPressEvent (Gdk.EventKey evt)
- {
- uint keyval;
- int effectiveGroup, level;
- Gdk.ModifierType consumedMods, mask;
-
- if (!Gtk.Accelerator.Valid (evt.KeyValue, evt.State))
- return base.OnKeyPressEvent (evt);
-
- // We know this will succeed, since we're already here...
- Gdk.Keymap.Default.TranslateKeyboardState (evt.HardwareKeycode, evt.State, evt.Group, out keyval, out effectiveGroup, out level, out consumedMods);
- mask = evt.State & Accelerator.AcceleratorModifierMask & ~consumedMods;
-
- if (evt.Key != Gdk.Key.Escape || mask != 0) {
- Keyval = keyval;
- Mask = mask;
- this.Respond (0);
- }
- return false;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionGroupEditor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionGroupEditor.cs
deleted file mode 100644
index d5de903948..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionGroupEditor.cs
+++ /dev/null
@@ -1,577 +0,0 @@
-
-using System;
-using System.Collections;
-using Stetic.Wrapper;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- public class ActionGroupEditor: Gtk.EventBox, IMenuItemContainer
- {
- ActionGroup actionGroup;
- Gtk.Table table;
- IProject project;
- ArrayList items = new ArrayList ();
- Gtk.EventBox emptyLabel;
- EditableLabel headerLabel;
- uint columns = 2;
- bool modified;
- bool disposed;
- ObjectWrapperEventHandler changedEvent;
- IDesignArea darea;
-
- public EventHandler GroupModified;
- public EventHandler SelectionChanged;
-
- public ActionGroupEditor ()
- {
- changedEvent = new ObjectWrapperEventHandler (OnActionChanged);
-
- Gtk.Fixed fx = new Gtk.Fixed ();
- table = new Gtk.Table (0, 0, false);
- table.RowSpacing = 8;
- table.ColumnSpacing = 8;
- table.BorderWidth = 12;
-
- Gtk.EventBox ebox = new Gtk.EventBox ();
- ebox.ModifyBg (Gtk.StateType.Normal, this.Style.Backgrounds [0]);
- headerLabel = new EditableLabel ();
- headerLabel.MarkupTemplate = "<b>$TEXT</b>";
- headerLabel.Changed += OnGroupNameChanged;
- Gtk.VBox vbox = new Gtk.VBox ();
- Gtk.Label grpLabel = new Gtk.Label ();
- grpLabel.Xalign = 0;
- grpLabel.Markup = "<small><i>Action Group</i></small>";
-// vbox.PackStart (grpLabel, false, false, 0);
- vbox.PackStart (headerLabel, false, false, 3);
- vbox.BorderWidth = 12;
- ebox.Add (vbox);
-
- Gtk.VBox box = new Gtk.VBox ();
- box.Spacing = 6;
- box.PackStart (ebox, false, false, 0);
- box.PackStart (table, false, false, 0);
-
- fx.Put (box, 0, 0);
- Add (fx);
- ShowAll ();
- }
-
- public override void Dispose ()
- {
- if (disposed)
- return;
- disposed = true;
- headerLabel.Changed -= OnGroupNameChanged;
- if (emptyLabel != null)
- emptyLabel.ButtonPressEvent -= OnAddClicked;
-
- foreach (ActionMenuItem aitem in items) {
- aitem.KeyPressEvent -= OnItemKeyPress;
- aitem.Node.Dispose ();
- aitem.Detach ();
- aitem.Destroy ();
- }
- items.Clear ();
- ActionGroup = null;
- project = null;
- headerLabel = null;
-
- if (darea != null) {
- darea.SelectionChanged -= OnSelectionChanged;
- darea = null;
- }
-
- base.Dispose ();
- }
-
- public ActionGroup ActionGroup {
- get { return actionGroup; }
- set {
- if (actionGroup != null) {
- actionGroup.ObjectChanged -= OnGroupChanged;
- actionGroup.ActionAdded -= OnActionAdded;
- actionGroup.ActionRemoved -= OnActionRemoved;
- foreach (Wrapper.Action a in actionGroup.Actions)
- a.ObjectChanged -= changedEvent;
- }
- actionGroup = value;
- if (actionGroup != null) {
- headerLabel.Text = actionGroup.Name;
- actionGroup.ObjectChanged += OnGroupChanged;
- actionGroup.ActionAdded += OnActionAdded;
- actionGroup.ActionRemoved += OnActionRemoved;
- foreach (Wrapper.Action a in actionGroup.Actions)
- a.ObjectChanged += changedEvent;
- }
- if (!disposed)
- Fill ();
- }
- }
-
- public IProject Project {
- get { return project; }
- set { project = value; }
- }
-
- public bool Modified {
- get { return modified; }
- set { modified = value; }
- }
-
- public Wrapper.Action SelectedAction {
- get {
- IDesignArea designArea = GetDesignArea ();
- IObjectSelection sel = designArea.GetSelection ();
- if (sel != null)
- return ObjectWrapper.Lookup (sel.DataObject) as Wrapper.Action;
- else
- return null;
- }
- set {
- foreach (ActionMenuItem item in items) {
- if (item.Node.Action == value)
- item.Select ();
- }
- }
- }
-
- ActionMenuItem SelectedActionMenuItem {
- get {
- IDesignArea designArea = GetDesignArea ();
- IObjectSelection sel = designArea.GetSelection ();
- if (sel != null)
- return sel.Widget as ActionMenuItem;
- else
- return null;
- }
- }
-
- public void StartEditing ()
- {
- IDesignArea designArea = GetDesignArea ();
- designArea.SetSelection (headerLabel, null);
- headerLabel.StartEditing ();
- }
-
- void Fill ()
- {
- IDesignArea designArea = GetDesignArea ();
- if (designArea == null)
- return;
-
- Wrapper.Action selAction = null;
-
- foreach (ActionMenuItem item in items) {
- if (designArea.IsSelected (item))
- selAction = item.Node.Action;
- item.Node.Dispose ();
- item.Detach ();
- item.Destroy ();
- }
- items.Clear ();
-
- if (actionGroup != null) {
- Wrapper.Action[] sortedActions = new Wrapper.Action [actionGroup.Actions.Count];
- actionGroup.Actions.CopyTo (sortedActions, 0);
- Array.Sort (sortedActions, new ActionComparer ());
- for (int n = 0; n < sortedActions.Length; n++) {
- Wrapper.Action action = (Wrapper.Action) sortedActions [n];
- ActionMenuItem item = InsertAction (action, n);
- if (selAction == action)
- item.Select ();
- }
-
- if (selAction == null)
- designArea.SetSelection (null, null);
-
- headerLabel.Sensitive = true;
- PlaceAddLabel (actionGroup.Actions.Count);
- } else {
- HideAddLabel ();
- headerLabel.Text = Catalog.GetString ("No selection");
- headerLabel.Sensitive = false;
- }
- ShowAll ();
- }
-
- ActionMenuItem InsertAction (Wrapper.Action action, int n)
- {
- uint row = (uint) n / columns;
- uint col = (uint) (n % columns) * 3;
-
- IDesignArea designArea = GetDesignArea ();
- ActionTreeNode node = new ActionTreeNode (Gtk.UIManagerItemType.Menuitem, "", action);
- ActionMenuItem aitem = new ActionMenuItem (designArea, project, this, node);
- aitem.KeyPressEvent += OnItemKeyPress;
- aitem.MinWidth = 150;
- aitem.Attach (table, row, col);
-
- Gtk.Frame fr = new Gtk.Frame ();
- fr.Shadow = Gtk.ShadowType.Out;
- aitem.Add (fr);
-
- items.Add (aitem);
- return aitem;
- }
-
- void PlaceAddLabel (int n)
- {
- HideAddLabel ();
-
- uint r = (uint) n / columns;
- uint c = (uint) (n % columns) * 3;
-
- emptyLabel = new Gtk.EventBox ();
- emptyLabel.VisibleWindow = false;
- Gtk.Label label = new Gtk.Label ();
- label.Xalign = 0;
- label.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("Click to create action") + "</span></i>";
- emptyLabel.Add (label);
- emptyLabel.ButtonPressEvent += OnAddClicked;
- table.Attach (emptyLabel, c, c+3, r, r+1);
- }
-
- void HideAddLabel ()
- {
- if (emptyLabel != null) {
- table.Remove (emptyLabel);
- emptyLabel.ButtonPressEvent -= OnAddClicked;
- }
- emptyLabel = null;
- }
-
- void OnGroupChanged (object s, ObjectWrapperEventArgs args)
- {
- headerLabel.Text = actionGroup.Name;
- NotifyModified ();
- }
-
- void OnActionAdded (object s, ActionEventArgs args)
- {
- args.Action.ObjectChanged += changedEvent;
- Fill ();
- NotifyModified ();
- }
-
- void OnActionRemoved (object s, ActionEventArgs args)
- {
- args.Action.ObjectChanged -= changedEvent;
- Fill ();
- NotifyModified ();
- }
-
- void OnActionChanged (object s, ObjectWrapperEventArgs args)
- {
- NotifyModified ();
- }
-
- void NotifyModified ()
- {
- modified = true;
- if (GroupModified != null)
- GroupModified (this, EventArgs.Empty);
- }
-
- void OnAddClicked (object s, Gtk.ButtonPressEventArgs args)
- {
- Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (project,
- new Gtk.Action ("", "", null, null),
- ActionGroup);
- ActionMenuItem item = InsertAction (ac, actionGroup.Actions.Count);
- item.EditingDone += OnEditDone;
- item.Select ();
- item.StartEditing ();
- HideAddLabel ();
- ShowAll ();
- }
-
- void OnEditDone (object sender, EventArgs args)
- {
- ActionMenuItem item = (ActionMenuItem) sender;
- item.EditingDone -= OnEditDone;
- if (item.Node.Action.GtkAction.Label.Length > 0 || item.Node.Action.GtkAction.StockId != null) {
- actionGroup.Actions.Add (item.Node.Action);
- } else {
- IDesignArea designArea = GetDesignArea ();
- designArea.ResetSelection (item);
- item.Detach ();
- item.Node.Dispose ();
- items.Remove (item);
- item.Destroy ();
- PlaceAddLabel (actionGroup.Actions.Count);
- ShowAll ();
- }
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton ev)
- {
- IDesignArea designArea = GetDesignArea ();
- designArea.SetSelection (null, null);
- return true;
- }
-
- void OnItemKeyPress (object s, Gtk.KeyPressEventArgs args)
- {
- int pos = items.IndexOf (s);
-
- switch (args.Event.Key) {
- case Gdk.Key.Up:
- pos -= (int) columns;
- break;
- case Gdk.Key.Down:
- pos += (int) columns;
- break;
- case Gdk.Key.Right:
- pos ++;
- break;
- case Gdk.Key.Left:
- pos --;
- break;
- }
- if (pos >= 0 && pos < items.Count) {
- ((ActionMenuItem)items[pos]).Select ();
- args.RetVal = true;
- }
- else if (pos == items.Count) {
- OnAddClicked (null, null);
- args.RetVal = true;
- }
- }
-
- void OnGroupNameChanged (object s, EventArgs args)
- {
- if (actionGroup != null)
- actionGroup.Name = headerLabel.Text;
- }
-
- void OnSelectionChanged (object s, EventArgs args)
- {
- if (SelectionChanged != null)
- SelectionChanged (this, args);
- }
-
- public void Cut ()
- {
- ActionMenuItem menuItem = SelectedActionMenuItem;
- if (menuItem != null)
- Cut (SelectedActionMenuItem);
- }
-
- public void Copy ()
- {
- ActionMenuItem menuItem = SelectedActionMenuItem;
- if (menuItem != null)
- Copy (SelectedActionMenuItem);
- }
-
- public void Paste ()
- {
- }
-
- public void Delete ()
- {
- ActionMenuItem menuItem = SelectedActionMenuItem;
- if (menuItem != null)
- Delete (SelectedActionMenuItem);
- }
-
- void Cut (ActionMenuItem menuItem)
- {
- }
-
- void Copy (ActionMenuItem menuItem)
- {
- }
-
- void Paste (ActionMenuItem menuItem)
- {
- }
-
- void Delete (ActionMenuItem menuItem)
- {
- string msg = string.Format (Catalog.GetString ("Are you sure you want to delete the action '{0}'? It will be removed from all menus and toolbars."), menuItem.Node.Action.Name);
- Gtk.MessageDialog md = new Gtk.MessageDialog (null, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, msg);
- md.TransientFor = this.Toplevel as Gtk.Window;
- if (md.Run () == (int) Gtk.ResponseType.Yes) {
- menuItem.Node.Action.Delete ();
- darea.SetSelection (null, null);
- }
- md.Destroy ();
- }
-
- void IMenuItemContainer.ShowContextMenu (ActionItem aitem)
- {
- ActionMenuItem menuItem = aitem as ActionMenuItem;
-
- Gtk.Menu m = new Gtk.Menu ();
- Gtk.MenuItem item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- Cut (menuItem);
- };
- item.Visible = false; // No copy & paste for now
- item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- Copy (menuItem);
- };
- item.Visible = false; // No copy & paste for now
- item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- Paste (menuItem);
- };
- item.Visible = false; // No copy & paste for now
- item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- Delete (menuItem);
- };
- m.ShowAll ();
- m.Popup ();
- }
-
- IDesignArea GetDesignArea ()
- {
- if (darea != null)
- return darea;
-
- darea = WidgetUtils.GetDesignArea (this);
- darea.SelectionChanged += OnSelectionChanged;
- return darea;
- }
-
- ActionMenu IMenuItemContainer.OpenSubmenu {
- get { return null; }
- set { }
- }
-
- bool IMenuItemContainer.IsTopMenu {
- get { return false; }
- }
-
- Gtk.Widget IMenuItemContainer.Widget {
- get { return this; }
- }
-
- class ActionComparer: IComparer
- {
- public int Compare (object x, object y)
- {
- return string.Compare (((Wrapper.Action)x).GtkAction.Label, ((Wrapper.Action)y).GtkAction.Label);
- }
- }
- }
-
- public class EditableLabel: Gtk.EventBox
- {
- string text;
- string markup;
-
- public EditableLabel (): this ("")
- {
- }
-
- public EditableLabel (string txt)
- {
- VisibleWindow = false;
- text = txt;
- Add (CreateLabel ());
- }
-
- public string Text {
- get { return text; }
- set {
- text = value;
- if (Child is Gtk.Entry)
- ((Gtk.Entry)Child).Text = text;
- else
- ((Gtk.Label)Child).Markup = Markup;
- }
- }
-
- public string MarkupTemplate {
- get { return markup; }
- set {
- markup = value;
- if (Child is Gtk.Label)
- ((Gtk.Label)Child).Markup = Markup;
- }
- }
-
- public string Markup {
- get { return markup != null ? markup.Replace ("$TEXT",text) : text; }
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton ev)
- {
- IDesignArea d = WidgetUtils.GetDesignArea (this);
- if (d.IsSelected (this)) {
- if (Child is Gtk.Label) {
- StartEditing ();
- return true;
- }
- } else {
- d.SetSelection (this, null);
- return true;
- }
- return false;
- }
-
- void SelectionDisposed (object s, EventArgs args)
- {
- EndEditing ();
- }
-
- public void StartEditing ()
- {
- if (Child is Gtk.Label) {
- IDesignArea d = WidgetUtils.GetDesignArea (this);
- IObjectSelection sel = d.GetSelection (this);
- if (sel == null)
- sel = d.SetSelection (this, null);
-
- sel.Disposed += SelectionDisposed;
-
- Remove (Child);
- Add (CreateEntry ());
- ShowAll ();
- Child.GrabFocus ();
- }
- }
-
- public void EndEditing ()
- {
- if (Child is Gtk.Entry) {
- Remove (Child);
- Add (CreateLabel ());
- ShowAll ();
- }
- }
-
- Gtk.Label CreateLabel ()
- {
- Gtk.Label label = new Gtk.Label ();
- label.Markup = Markup;
- label.Xalign = 0;
- return label;
- }
-
- Gtk.Entry CreateEntry ()
- {
- Gtk.Entry e = new Gtk.Entry (text);
- e.Changed += delegate (object s, EventArgs a) {
- text = e.Text;
- if (Changed != null)
- Changed (this, a);
- };
- e.Activated += delegate (object s, EventArgs a) {
- EndEditing ();
- };
- return e;
- }
-
- public event EventHandler Changed;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionItem.cs
deleted file mode 100644
index 5d2d09cdd8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionItem.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-
-using System;
-using Stetic.Wrapper;
-
-namespace Stetic.Editor
-{
- abstract class ActionItem: Gtk.EventBox, IEditableObject
- {
- protected IMenuItemContainer parentMenu;
- protected ActionTreeNode node;
- protected Widget wrapper;
- protected bool localUpdate;
- protected bool editOnRelease;
- protected bool editing;
- protected uint itemSpacing;
- protected int minWidth;
-
- // To use in the action editor
- protected IDesignArea designArea;
- protected IProject project;
- bool disposed;
-
- public ActionItem (ActionTreeNode node, IMenuItemContainer parent, uint itemSpacing)
- {
- DND.SourceSet (this);
- this.parentMenu = parent;
- this.node = node;
- this.VisibleWindow = false;
- this.CanFocus = true;
- this.Events |= Gdk.EventMask.KeyPressMask;
- this.itemSpacing = itemSpacing;
- if (node.Action != null)
- node.Action.ObjectChanged += OnActionChanged;
- }
-
- public ActionTreeNode Node {
- get { return node; }
- }
-
- public uint ItemSpacing {
- get { return itemSpacing; }
- set { itemSpacing = value; }
- }
-
- public int MinWidth {
- get { return minWidth; }
- set { minWidth = value; }
- }
-
- public bool IsSelected {
- get {
- IDesignArea area = GetDesignArea ();
- return area.IsSelected (this);
- }
- }
-
- protected void UpdateSelectionStatus ()
- {
- IDesignArea area = GetDesignArea ();
- IObjectSelection sel = area.GetSelection ();
- sel.Disposed -= OnSelectionDisposed;
- sel.Drag -= HandleItemDrag;
-
- area.ResetSelection (this);
-
- sel = area.SetSelection (this, this);
- sel.Drag += HandleItemDrag;
- sel.Disposed += OnSelectionDisposed;
- }
-
- public virtual void Select ()
- {
- IDesignArea area = GetDesignArea ();
- if (area.IsSelected (this))
- return;
- IObjectSelection sel = area.SetSelection (this, node.Action != null ? node.Action.GtkAction : null);
- sel.Drag += HandleItemDrag;
- sel.Disposed += OnSelectionDisposed;
- GrabFocus ();
- }
-
- void OnSelectionDisposed (object ob, EventArgs a)
- {
- if (!disposed)
- EndEditing (Gdk.Key.Return);
- }
-
- protected virtual void EndEditing (Gdk.Key exitKey)
- {
- }
-
- public override void Dispose ()
- {
- disposed = true;
- base.Dispose ();
- }
-
-
- void HandleItemDrag (Gdk.EventMotion evt, int dx, int dy)
- {
- ProcessDragBegin (null, evt);
- }
-
- protected IDesignArea GetDesignArea ()
- {
- if (wrapper != null)
- return wrapper.GetDesignArea ();
- else
- return designArea;
- }
-
- protected IProject GetProject ()
- {
- if (wrapper != null)
- return wrapper.Project;
- else
- return project;
- }
-
- void OnActionChanged (object ob, ObjectWrapperEventArgs a)
- {
- if (!localUpdate)
- Refresh ();
- }
-
- public abstract void Refresh ();
-
- protected override bool OnButtonPressEvent (Gdk.EventButton ev)
- {
- return ProcessButtonPress (ev);
- }
-
- public bool ProcessButtonPress (Gdk.EventButton ev)
- {
- if (ev.Button == 1) {
- IDesignArea area = GetDesignArea ();
- if (area == null)
- return true;
-
- // Clicking a selected item starts the edit mode
- if (area.IsSelected (this)) {
- editOnRelease = true;
- return true;
- }
- } else if (ev.Button == 3) {
- parentMenu.ShowContextMenu (this);
- }
-
- Select ();
- return true;
- }
-
- protected override void OnDragBegin (Gdk.DragContext ctx)
- {
- ProcessDragBegin (ctx, null);
- }
-
- public virtual void ProcessDragBegin (Gdk.DragContext ctx, Gdk.EventMotion evt)
- {
- editOnRelease = false;
- ActionPaletteItem item = new ActionPaletteItem (node);
- if (ctx != null)
- DND.Drag (parentMenu.Widget, ctx, item);
- else
- DND.Drag (parentMenu.Widget, evt, item);
- }
-
- public bool CanCopy {
- get { return !editing; }
- }
-
- public bool CanCut {
- get { return false; }
- }
-
- public bool CanPaste {
- get { return false; }
- }
-
- public bool CanDelete {
- get { return !editing; }
- }
-
- public void Copy ()
- {
- }
-
- public void Cut ()
- {
- }
-
- public void Paste ()
- {
- }
-
- public void Delete ()
- {
- if (node.ParentNode != null)
- node.ParentNode.Children.Remove (node);
- Destroy ();
- }
-
- void IEditableObject.Delete ()
- {
- if (!editing)
- Delete ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenu.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenu.cs
deleted file mode 100644
index a34519a194..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenu.cs
+++ /dev/null
@@ -1,650 +0,0 @@
-
-using System;
-using System.Collections;
-using Stetic.Wrapper;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- public class ActionMenu: Gtk.EventBox, IMenuItemContainer
- {
- ActionTreeNode parentNode;
- ActionTreeNodeCollection nodes;
- ArrayList menuItems = new ArrayList ();
- Gtk.Table table;
- ActionMenu openSubmenu;
- Widget wrapper;
- int dropPosition = -1;
- int dropIndex;
- Gtk.EventBox emptyLabel;
- IMenuItemContainer parentMenu;
-
- public ActionMenu (IntPtr p): base (p)
- {}
-
- internal ActionMenu (Widget wrapper, IMenuItemContainer parentMenu, ActionTreeNode node)
- {
- DND.DestSet (this, true);
- parentNode = node;
- this.parentMenu = parentMenu;
- this.wrapper = wrapper;
- this.nodes = node.Children;
- table = new Gtk.Table (0, 0, false);
- table.ColumnSpacing = 5;
- table.RowSpacing = 5;
- table.BorderWidth = 5;
- this.AppPaintable = true;
-
- Add (table);
-
- Fill ();
-
- parentNode.ChildNodeAdded += OnChildAdded;
- parentNode.ChildNodeRemoved += OnChildRemoved;
- }
-
- protected override void OnDestroyed ()
- {
- parentNode.ChildNodeAdded -= OnChildAdded;
- parentNode.ChildNodeRemoved -= OnChildRemoved;
- parentNode = null;
-
- base.OnDestroyed ();
- }
-
- public void Select (ActionTreeNode node)
- {
- if (node != null) {
- ActionMenuItem item = FindMenuItem (node);
- if (item != null)
- item.Select ();
- } else {
- if (menuItems.Count > 0)
- ((ActionMenuItem)menuItems [0]).Select ();
- else
- InsertAction (0);
- }
- }
-
- public ActionTreeNode ParentNode {
- get { return parentNode; }
- }
-
- bool IMenuItemContainer.IsTopMenu {
- get { return false; }
- }
-
- Gtk.Widget IMenuItemContainer.Widget {
- get { return this; }
- }
-
- public void TrackWidgetPosition (Gtk.Widget refWidget, bool topMenu)
- {
- IDesignArea area = wrapper.GetDesignArea ();
- Gdk.Rectangle rect = area.GetCoordinates (refWidget);
- if (topMenu)
- area.MoveWidget (this, rect.X, rect.Bottom);
- else
- area.MoveWidget (this, rect.Right, rect.Top);
-
- GLib.Timeout.Add (50, new GLib.TimeoutHandler (RepositionSubmenu));
- }
-
- public bool RepositionSubmenu ()
- {
- if (openSubmenu == null)
- return false;
-
- ActionMenuItem item = FindMenuItem (openSubmenu.parentNode);
- if (item != null)
- openSubmenu.TrackWidgetPosition (item, false);
- return false;
- }
-
- void Fill ()
- {
- menuItems.Clear ();
-
- uint n = 0;
- ActionMenuItem editItem = null;
-
- if (nodes.Count > 0) {
- foreach (ActionTreeNode node in nodes) {
- ActionMenuItem item = new ActionMenuItem (wrapper, this, node);
- item.KeyPressEvent += OnItemKeyPress;
- item.Attach (table, n++, 0);
- menuItems.Add (item);
- // If adding an action with an empty name, select and start editing it
-// if (node.Action != null && node.Action.Name.Length == 0)
-// editItem = item;
- }
- }
-
- emptyLabel = new Gtk.EventBox ();
- emptyLabel.VisibleWindow = false;
- Gtk.Label label = new Gtk.Label ();
- label.Xalign = 0;
- label.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("Click to create action") + "</span></i>";
- emptyLabel.Add (label);
- emptyLabel.ButtonPressEvent += OnAddClicked;
- table.Attach (emptyLabel, 1, 2, n, n + 1);
-
- ShowAll ();
-
- if (editItem != null) {
- // If there is an item with an empty action, it means that it was an item that was
- // being edited. Restart the editing now.
- GLib.Timeout.Add (200, delegate {
- editItem.Select ();
- editItem.EditingDone += OnEditingDone;
- editItem.StartEditing ();
- return false;
- });
- }
- }
-
- void Refresh ()
- {
- IDesignArea area = wrapper.GetDesignArea ();
- ActionTreeNode selNode = null;
-
- foreach (Gtk.Widget w in table.Children) {
- ActionMenuItem ami = w as ActionMenuItem;
- if (area.IsSelected (w) && ami != null) {
- selNode = ami.Node;
- area.ResetSelection (w);
- }
- table.Remove (w);
- }
-
- Fill ();
-
- ActionMenuItem mi = FindMenuItem (selNode);
- if (mi != null)
- mi.Select ();
-
- GLib.Timeout.Add (50, new GLib.TimeoutHandler (RepositionSubmenu));
- }
-
- public ActionMenu OpenSubmenu {
- get { return openSubmenu; }
- set {
- if (openSubmenu != null) {
- openSubmenu.OpenSubmenu = null;
- IDesignArea area = wrapper.GetDesignArea ();
- area.RemoveWidget (openSubmenu);
- openSubmenu.Destroy ();
- }
- openSubmenu = value;
- }
- }
-
- internal void ResetSelection ()
- {
- if (OpenSubmenu != null)
- OpenSubmenu.ResetSelection ();
- IDesignArea area = wrapper.GetDesignArea ();
- if (area != null) {
- foreach (Gtk.Widget w in table.Children) {
- ActionMenuItem ami = w as ActionMenuItem;
- if (ami != null)
- area.ResetSelection (w);
- }
- }
- }
-
- ActionTreeNode InsertAction (int pos)
- {
- using (wrapper.UndoManager.AtomicChange) {
- Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project,
- new Gtk.Action ("", "", null, null),
- wrapper);
- ActionTreeNode newNode = new ActionTreeNode (Gtk.UIManagerItemType.Menuitem, null, ac);
- nodes.Insert (pos, newNode);
- ActionMenuItem item = FindMenuItem (newNode);
- item.EditingDone += OnEditingDone;
- item.Select ();
- item.StartEditing ();
- emptyLabel.Hide ();
-
- if (wrapper.LocalActionGroups.Count == 0)
- wrapper.LocalActionGroups.Add (new ActionGroup ("Default"));
- wrapper.LocalActionGroups [0].Actions.Add (ac);
- return newNode;
- }
- }
-
- void DeleteAction (ActionMenuItem item)
- {
- int pos = menuItems.IndexOf (item);
- item.Delete ();
- if (pos >= menuItems.Count)
- SelectLastItem ();
- else
- ((ActionMenuItem)menuItems [pos]).Select ();
- }
-
- void OnEditingDone (object ob, MenuItemEditEventArgs args)
- {
- ActionMenuItem item = (ActionMenuItem) ob;
- item.EditingDone -= OnEditingDone;
- if (item.Node.Action.GtkAction.Label.Length == 0 && item.Node.Action.GtkAction.StockId == null) {
- IDesignArea area = wrapper.GetDesignArea ();
- area.ResetSelection (item);
- using (wrapper.UndoManager.AtomicChange) {
- nodes.Remove (item.Node);
- wrapper.LocalActionGroups [0].Actions.Remove (item.Node.Action);
- }
- SelectLastItem ();
- }
- else {
- if (args.ExitKey == Gdk.Key.Up || args.ExitKey == Gdk.Key.Down)
- ProcessKey (item, args.ExitKey, Gdk.ModifierType.None);
- }
- }
-
- void SelectLastItem ()
- {
- if (menuItems.Count > 0)
- ((ActionMenuItem)menuItems [menuItems.Count - 1]).Select ();
- else if (parentMenu.Widget is ActionMenuBar) {
- ActionMenuBar bar = (ActionMenuBar) parentMenu.Widget;
- bar.Select (parentNode);
- }
- else if (parentMenu.Widget is ActionMenu) {
- ActionMenu parentAM = (ActionMenu) parentMenu.Widget;
- parentAM.Select (parentNode);
- }
- }
-
- void OnChildAdded (object ob, ActionTreeNodeArgs args)
- {
- Refresh ();
- }
-
- void OnChildRemoved (object ob, ActionTreeNodeArgs args)
- {
- IDesignArea area = wrapper.GetDesignArea ();
- IObjectSelection asel = area.GetSelection ();
- ActionMenuItem curSel = asel != null ? asel.DataObject as ActionMenuItem : null;
- int pos = menuItems.IndexOf (curSel);
-
- ActionMenuItem mi = FindMenuItem (args.Node);
- if (mi != null) {
- // Remove the table row that contains the menu item
- Gtk.Table.TableChild tc = (Gtk.Table.TableChild) table [mi];
- uint row = tc.TopAttach;
- mi.Detach ();
- menuItems.Remove (mi);
- foreach (Gtk.Widget w in table.Children) {
- tc = (Gtk.Table.TableChild) table [w];
- if (tc.TopAttach >= row)
- tc.TopAttach--;
- if (tc.BottomAttach > row)
- tc.BottomAttach--;
- }
- if (pos != -1 && pos < menuItems.Count)
- ((ActionMenuItem)menuItems[pos]).Select ();
- else
- SelectLastItem ();
- GLib.Timeout.Add (50, new GLib.TimeoutHandler (RepositionSubmenu));
- }
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose ev)
- {
- int w, h;
- this.GdkWindow.GetSize (out w, out h);
- Gdk.Rectangle clip = new Gdk.Rectangle (0,0,w,h);
- Gtk.Style.PaintBox (this.Style, this.GdkWindow, Gtk.StateType.Normal, Gtk.ShadowType.Out, clip, this, "menu", 0, 0, w, h);
-
- bool r = base.OnExposeEvent (ev);
-
- if (dropPosition != -1) {
- GdkWindow.DrawRectangle (this.Style.BlackGC, true, 0, dropPosition - 1, w - 2, 3);
- }
-
- return r;
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton ev)
- {
- return true;
- }
-
- void OnAddClicked (object s, Gtk.ButtonPressEventArgs args)
- {
- InsertAction (menuItems.Count);
- args.RetVal = true;
- }
-
- protected override bool OnDragMotion (Gdk.DragContext context, int x, int y, uint time)
- {
- ActionPaletteItem dragItem = DND.DragWidget as ActionPaletteItem;
- if (dragItem == null)
- return false;
-
- if (nodes.Count > 0) {
- ActionMenuItem item = LocateWidget (x, y);
- if (item != null) {
-
- // Show the submenu to allow droping to it, but avoid
- // droping a submenu inside itself
- if (item.HasSubmenu && item.Node != dragItem.Node)
- item.ShowSubmenu (wrapper.GetDesignArea(), item);
-
- // Look for the index where to insert the new item
- dropIndex = nodes.IndexOf (item.Node);
- int mpos = item.Allocation.Y + item.Allocation.Height / 2;
- if (y > mpos)
- dropIndex++;
-
- // Calculate the drop position, used to show the drop bar
- if (dropIndex == 0)
- dropPosition = item.Allocation.Y;
- else if (dropIndex == menuItems.Count)
- dropPosition = item.Allocation.Bottom;
- else {
- item = (ActionMenuItem) menuItems [dropIndex];
- ActionMenuItem prevItem = (ActionMenuItem) menuItems [dropIndex - 1];
- dropPosition = prevItem.Allocation.Bottom + (item.Allocation.Y - prevItem.Allocation.Bottom)/2;
- }
- }
- } else
- dropIndex = 0;
-
- QueueDraw ();
- return base.OnDragMotion (context, x, y, time);
- }
-
- protected override void OnDragLeave (Gdk.DragContext context, uint time)
- {
- dropPosition = -1;
- QueueDraw ();
- base.OnDragLeave (context, time);
- }
-
- protected override void OnDragDataReceived (Gdk.DragContext context, int x, int y, Gtk.SelectionData data, uint info, uint time)
- {
- }
-
- protected override bool OnDragDrop (Gdk.DragContext context, int x, int y, uint time)
- {
- ActionPaletteItem dropped = DND.Drop (context, null, time) as ActionPaletteItem;
- if (dropped == null)
- return false;
-
- if (dropped.Node.Type != Gtk.UIManagerItemType.Menuitem &&
- dropped.Node.Type != Gtk.UIManagerItemType.Menu &&
- dropped.Node.Type != Gtk.UIManagerItemType.Toolitem &&
- dropped.Node.Type != Gtk.UIManagerItemType.Separator)
- return false;
-
- ActionTreeNode newNode = null;
-
- // Toolitems are copied, not moved
-
- using (wrapper.UndoManager.AtomicChange) {
- if (dropped.Node.ParentNode != null && dropped.Node.Type != Gtk.UIManagerItemType.Toolitem) {
- if (dropIndex < nodes.Count) {
- // Do nothing if trying to drop the node over the same node
- ActionTreeNode dropNode = nodes [dropIndex];
- if (dropNode == dropped.Node)
- return false;
-
- dropped.Node.ParentNode.Children.Remove (dropped.Node);
-
- // The drop position may have changed after removing the dropped node,
- // so get it again.
- dropIndex = nodes.IndexOf (dropNode);
- nodes.Insert (dropIndex, dropped.Node);
- } else {
- dropped.Node.ParentNode.Children.Remove (dropped.Node);
- nodes.Add (dropped.Node);
- dropIndex = nodes.Count - 1;
- }
- } else {
- newNode = new ActionTreeNode (Gtk.UIManagerItemType.Menuitem, null, dropped.Node.Action);
- nodes.Insert (dropIndex, newNode);
- }
- // Select the dropped node
- ActionMenuItem mi = (ActionMenuItem) menuItems [dropIndex];
- mi.Select ();
- }
-
- return base.OnDragDrop (context, x, y, time);
- }
-
- [GLib.ConnectBefore]
- void OnItemKeyPress (object s, Gtk.KeyPressEventArgs args)
- {
- ActionMenuItem item = (ActionMenuItem) s;
- ProcessKey (item, args.Event.Key, args.Event.State);
- args.RetVal = true;
- }
-
- void ProcessKey (ActionMenuItem item, Gdk.Key key, Gdk.ModifierType modifier)
- {
- int pos = menuItems.IndexOf (item);
-
- switch (key) {
- case Gdk.Key.Up:
- if (pos > 0)
- ((ActionMenuItem)menuItems[pos - 1]).Select ();
- else if (parentMenu.Widget is ActionMenuBar) {
- ActionMenuBar bar = (ActionMenuBar) parentMenu.Widget;
- bar.Select (parentNode);
- }
- break;
- case Gdk.Key.Down:
- if (pos < menuItems.Count - 1)
- ((ActionMenuItem)menuItems[pos + 1]).Select ();
- else if (pos == menuItems.Count - 1) {
- InsertAction (menuItems.Count);
- }
- break;
- case Gdk.Key.Right:
- if ((modifier & Gdk.ModifierType.ControlMask) != 0 && item.Node.Type == Gtk.UIManagerItemType.Menuitem) {
- // Create a submenu
- using (item.Node.Action.UndoManager.AtomicChange) {
- item.Node.Type = Gtk.UIManagerItemType.Menu;
- }
- item.Node.Action.NotifyChanged ();
- }
- if (item.HasSubmenu) {
- item.ShowSubmenu ();
- if (openSubmenu != null)
- openSubmenu.Select (null);
- } else if (parentNode != null) {
- ActionMenuBar parentMB = parentMenu.Widget as ActionMenuBar;
- if (parentMB != null) {
- int i = parentNode.ParentNode.Children.IndexOf (parentNode);
- if (i < parentNode.ParentNode.Children.Count - 1)
- parentMB.DropMenu (parentNode.ParentNode.Children [i + 1]);
- }
- }
- break;
- case Gdk.Key.Left:
- if ((modifier & Gdk.ModifierType.ControlMask) != 0 && item.Node.Type == Gtk.UIManagerItemType.Menu) {
- // Remove the submenu
- OpenSubmenu = null;
- using (item.Node.Action.UndoManager.AtomicChange) {
- item.Node.Type = Gtk.UIManagerItemType.Menuitem;
- item.Node.Children.Clear ();
- }
- item.Node.Action.NotifyChanged ();
- break;
- }
- if (parentNode != null) {
- ActionMenu parentAM = parentMenu.Widget as ActionMenu;
- if (parentAM != null) {
- parentAM.Select (parentNode);
- }
- ActionMenuBar parentMB = parentMenu.Widget as ActionMenuBar;
- if (parentMB != null) {
- int i = parentNode.ParentNode.Children.IndexOf (parentNode);
- if (i > 0)
- parentMB.DropMenu (parentNode.ParentNode.Children [i - 1]);
- }
- }
- break;
- case Gdk.Key.Return:
- item.EditingDone += OnEditingDone;
- item.StartEditing ();
- break;
- case Gdk.Key.Insert:
- if ((modifier & Gdk.ModifierType.ControlMask) != 0)
- InsertActionAt (item, true, true);
- else
- InsertActionAt (item, false, false);
- break;
- case Gdk.Key.Delete:
- DeleteAction (item);
- break;
- }
- }
-
- void InsertActionAt (ActionMenuItem item, bool after, bool separator)
- {
- int pos = menuItems.IndexOf (item);
- if (pos == -1)
- return;
-
- if (after)
- pos++;
-
- if (separator) {
- ActionTreeNode newNode = new ActionTreeNode (Gtk.UIManagerItemType.Separator, null, null);
- nodes.Insert (pos, newNode);
- Select (newNode);
- } else
- InsertAction (pos);
- }
-
- void Paste (ActionMenuItem item)
- {
- }
-
- void IMenuItemContainer.ShowContextMenu (ActionItem aitem)
- {
- ActionMenuItem menuItem = aitem as ActionMenuItem;
- Gtk.Menu m = new Gtk.Menu ();
- Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("Insert Before"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, false, false);
- };
- item = new Gtk.MenuItem (Catalog.GetString ("Insert After"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, true, false);
- };
- item = new Gtk.MenuItem (Catalog.GetString ("Insert Separator Before"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, false, true);
- };
- item = new Gtk.MenuItem (Catalog.GetString ("Insert Separator After"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, true, true);
- };
-
- m.Add (new Gtk.SeparatorMenuItem ());
-
- item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- menuItem.Cut ();
- };
- item.Visible = false; // No copy & paste for now
- item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- menuItem.Copy ();
- };
- item.Visible = false;
- item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- Paste (menuItem);
- };
- item.Visible = false;
-
- item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- DeleteAction (menuItem);
- };
- m.ShowAll ();
- m.Popup ();
- }
-
- internal void SaveStatus (ArrayList status)
- {
- for (int n=0; n<menuItems.Count; n++) {
- ActionMenuItem item = (ActionMenuItem) menuItems [n];
- if (item.IsSelected) {
- status.Add (n);
- return;
- }
- if (item.IsSubmenuVisible) {
- status.Add (n);
- OpenSubmenu.SaveStatus (status);
- return;
- }
- }
- }
-
- internal void RestoreStatus (ArrayList status, int index)
- {
- int pos = (int) status [index];
- if (pos >= menuItems.Count)
- return;
-
- ActionMenuItem item = (ActionMenuItem)menuItems [pos];
- if (index == status.Count - 1) {
- // The last position in the status is the selected item
- item.Select ();
- if (item.Node.Action != null && item.Node.Action.Name.Length == 0) {
- // Then only case when there can have an action when an empty name
- // is when the user clicked on the "add action" link. In this case,
- // start editing the item again
- item.EditingDone += OnEditingDone;
- item.StartEditing ();
- }
- }
- else {
- item.ShowSubmenu ();
- if (OpenSubmenu != null)
- OpenSubmenu.RestoreStatus (status, index + 1);
- }
- }
-
- ActionMenuItem LocateWidget (int x, int y)
- {
- foreach (ActionMenuItem mi in menuItems) {
- if (mi.Allocation.Contains (x, y))
- return mi;
- }
- return null;
- }
-
- ActionMenuItem FindMenuItem (ActionTreeNode node)
- {
- foreach (ActionMenuItem mi in menuItems) {
- if (mi.Node == node)
- return mi;
- }
- return null;
- }
- }
-
- interface IMenuItemContainer
- {
- ActionMenu OpenSubmenu { get; set; }
- bool IsTopMenu { get; }
- Gtk.Widget Widget { get; }
- void ShowContextMenu (ActionItem item);
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenuBar.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenuBar.cs
deleted file mode 100644
index 8d834b5583..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenuBar.cs
+++ /dev/null
@@ -1,555 +0,0 @@
-
-using System;
-using System.Xml;
-using System.Collections;
-using Stetic.Wrapper;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- class ActionMenuBar: Gtk.MenuBar, IMenuItemContainer
- {
- ActionMenu openSubmenu;
- ActionTree actionTree;
- int dropPosition = -1;
- int dropIndex;
- ArrayList menuItems = new ArrayList ();
- bool showPlaceholder;
- Gtk.Widget addLabel;
- Gtk.Widget spacerItem;
-
- public ActionMenuBar ()
- {
- DND.DestSet (this, true);
- }
-
- public void FillMenu (ActionTree actionTree)
- {
- addLabel = null;
-
- if (this.actionTree != null) {
- this.actionTree.ChildNodeAdded -= OnChildAdded;
- this.actionTree.ChildNodeRemoved -= OnChildRemoved;
- }
-
- this.actionTree = actionTree;
- if (actionTree == null) {
- AddSpacerItem ();
- return;
- }
-
- actionTree.ChildNodeAdded += OnChildAdded;
- actionTree.ChildNodeRemoved += OnChildRemoved;
-
- HideSpacerItem ();
- menuItems.Clear ();
- Widget wrapper = Widget.Lookup (this);
-
- foreach (Gtk.Widget w in Children) {
- Remove (w);
- w.Destroy ();
- }
-
- foreach (ActionTreeNode node in actionTree.Children) {
- ActionMenuItem aitem = new ActionMenuItem (wrapper, this, node);
- AddItem (aitem, -1);
- menuItems.Add (aitem);
- }
-
- if (showPlaceholder) {
- AddCreateItemLabel ();
- } else if (actionTree.Children.Count == 0) {
- // Give some height to the toolbar
- AddSpacerItem ();
- }
- }
-
- public object SaveStatus ()
- {
- ArrayList status = new ArrayList ();
-
- for (int n=0; n<menuItems.Count; n++) {
- ActionMenuItem item = (ActionMenuItem) menuItems [n];
- if (item.IsSubmenuVisible) {
- status.Add (n);
- OpenSubmenu.SaveStatus (status);
- break;
- }
- }
- return status;
- }
-
- public void RestoreStatus (object data)
- {
- ArrayList status = (ArrayList) data;
- if (status.Count == 0)
- return;
-
- int pos = (int) status [0];
- if (pos >= menuItems.Count)
- return;
-
- ActionMenuItem item = (ActionMenuItem) menuItems [pos];
- if (status.Count == 1) {
- // The last position in the status is the selected item
- item.Select ();
- if (item.Node.Action != null && item.Node.Action.Name.Length == 0) {
- // Then only case when there can have an action when an empty name
- // is when the user clicked on the "add action" link. In this case,
- // start editing the item again
- item.EditingDone += OnEditingDone;
- item.StartEditing ();
- }
- } else {
- item.ShowSubmenu ();
- if (OpenSubmenu != null)
- OpenSubmenu.RestoreStatus (status, 1);
- }
- }
-
- void AddCreateItemLabel ()
- {
- HideSpacerItem ();
- Gtk.Label emptyLabel = new Gtk.Label ();
- emptyLabel.Xalign = 0;
- emptyLabel.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("Click to create menu") + "</span></i>";
- Gtk.MenuItem mit = new Gtk.MenuItem ();
- mit.Child = emptyLabel;
- mit.ButtonPressEvent += OnNewItemPress;
- Insert (mit, -1);
- mit.ShowAll ();
- addLabel = mit;
- }
-
- void AddSpacerItem ()
- {
- if (spacerItem == null) {
- Gtk.Label emptyLabel = new Gtk.Label ();
- emptyLabel.Xalign = 0;
- emptyLabel.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("Empty menu bar") + "</span></i>";
- Gtk.MenuItem mit = new Gtk.MenuItem ();
- mit.Child = emptyLabel;
- Insert (mit, -1);
- spacerItem = mit;
- ShowAll ();
- }
- }
-
- void HideSpacerItem ()
- {
- if (spacerItem != null) {
- Remove (spacerItem);
- spacerItem = null;
- }
- }
-
- void AddItem (ActionMenuItem aitem, int pos)
- {
- Gtk.Table t = new Gtk.Table (1, 3, false);
- aitem.Attach (t, 0, 0);
- aitem.KeyPressEvent += OnItemKeyPress;
- t.ShowAll ();
-
- CustomMenuBarItem it = new CustomMenuBarItem ();
- it.ActionMenuItem = aitem;
- aitem.Bind (it);
- it.Child = t;
- it.ShowAll ();
- Insert (it, pos);
- }
-
- public bool ShowInsertPlaceholder {
- get { return showPlaceholder; }
- set {
- showPlaceholder = value;
- if (value && addLabel == null) {
- AddCreateItemLabel ();
- } else if (!value && addLabel != null) {
- Remove (addLabel);
- addLabel = null;
- if (menuItems.Count == 0)
- AddSpacerItem ();
- }
- }
- }
-
- public void Unselect ()
- {
- // Unselects any selected item and hides any open submenu menu
- Widget wrapper = Widget.Lookup (this);
- if (OpenSubmenu != null)
- OpenSubmenu.ResetSelection ();
- IDesignArea area = wrapper.GetDesignArea ();
- if (area != null) {
- foreach (Gtk.Widget w in Children) {
- CustomMenuBarItem it = w as CustomMenuBarItem;
- if (it != null)
- area.ResetSelection (it.ActionMenuItem);
- }
- }
- OpenSubmenu = null;
- }
-
- void OnChildAdded (object ob, ActionTreeNodeArgs args)
- {
- Refresh ();
- }
-
- void OnChildRemoved (object ob, ActionTreeNodeArgs args)
- {
- OpenSubmenu = null;
-
- Widget wrapper = Widget.Lookup (this);
- IDesignArea area = wrapper.GetDesignArea ();
- IObjectSelection asel = area.GetSelection ();
- ActionMenuItem curSel = asel != null ? asel.DataObject as ActionMenuItem : null;
- int pos = menuItems.IndexOf (curSel);
-
- foreach (Gtk.Widget w in Children) {
- if (w is CustomMenuBarItem && ((CustomMenuBarItem)w).ActionMenuItem.Node == args.Node) {
- Remove (w);
- menuItems.Remove (((CustomMenuBarItem)w).ActionMenuItem);
- if (menuItems.Count == 0 && !showPlaceholder)
- AddSpacerItem ();
- break;
- }
- }
- if (pos != -1 && pos < menuItems.Count)
- ((ActionMenuItem)menuItems[pos]).Select ();
- else if (menuItems.Count > 0)
- ((ActionMenuItem)menuItems[menuItems.Count-1]).Select ();
- }
-
- void Refresh ()
- {
- Widget wrapper = Widget.Lookup (this);
- IDesignArea area = wrapper.GetDesignArea ();
- if (area == null)
- return;
-
- ActionTreeNode selNode = null;
-
- foreach (Gtk.Widget w in Children) {
- CustomMenuBarItem it = w as CustomMenuBarItem;
- if (it != null && area.IsSelected (it.ActionMenuItem)) {
- selNode = it.ActionMenuItem.Node;
- area.ResetSelection (it.ActionMenuItem);
- }
- Remove (w);
- }
-
- FillMenu (actionTree);
-
- if (selNode != null) {
- ActionMenuItem mi = FindMenuItem (selNode);
- if (mi != null)
- mi.Select ();
- }
- }
-
- [GLib.ConnectBeforeAttribute]
- void OnNewItemPress (object ob, Gtk.ButtonPressEventArgs args)
- {
- InsertAction (menuItems.Count);
- args.RetVal = true;
- }
-
- void InsertAction (int pos)
- {
- Widget wrapper = Widget.Lookup (this);
- using (wrapper.UndoManager.AtomicChange) {
- Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project,
- new Gtk.Action ("", "", null, null),
- wrapper);
- ActionTreeNode node = new ActionTreeNode (Gtk.UIManagerItemType.Menu, "", ac);
- actionTree.Children.Insert (pos, node);
-
- ActionMenuItem aitem = FindMenuItem (node);
- aitem.EditingDone += OnEditingDone;
- aitem.Select ();
- aitem.StartEditing ();
-
- if (wrapper.LocalActionGroups.Count == 0)
- wrapper.LocalActionGroups.Add (new ActionGroup ("Default"));
- wrapper.LocalActionGroups[0].Actions.Add (ac);
- }
- }
-
- void OnEditingDone (object ob, EventArgs args)
- {
- ActionMenuItem item = (ActionMenuItem) ob;
- item.EditingDone -= OnEditingDone;
- Widget wrapper = Widget.Lookup (this);
-
- if (item.Node.Action.GtkAction.Label.Length == 0 && item.Node.Action.GtkAction.StockId == null) {
- IDesignArea area = wrapper.GetDesignArea ();
- area.ResetSelection (item);
- using (wrapper.UndoManager.AtomicChange) {
- actionTree.Children.Remove (item.Node);
- wrapper.LocalActionGroups [0].Actions.Remove (item.Node.Action);
- }
- }
- }
-
- public void Select (ActionTreeNode node)
- {
- ActionMenuItem item = FindMenuItem (node);
- if (item != null)
- item.Select ();
- }
-
- public void DropMenu (ActionTreeNode node)
- {
- ActionMenuItem item = FindMenuItem (node);
- if (item != null) {
- if (item.HasSubmenu) {
- item.ShowSubmenu ();
- if (openSubmenu != null)
- openSubmenu.Select (null);
- }
- else
- item.Select ();
- }
- }
-
- public ActionMenu OpenSubmenu {
- get { return openSubmenu; }
- set {
- if (openSubmenu != null) {
- openSubmenu.OpenSubmenu = null;
- Widget wrapper = Widget.Lookup (this);
- IDesignArea area = wrapper.GetDesignArea ();
- if (area != null)
- area.RemoveWidget (openSubmenu);
- openSubmenu.Destroy ();
- }
- openSubmenu = value;
- }
- }
-
- bool IMenuItemContainer.IsTopMenu {
- get { return true; }
- }
-
- Gtk.Widget IMenuItemContainer.Widget {
- get { return this; }
- }
-
- protected override bool OnDragMotion (Gdk.DragContext context, int x, int y, uint time)
- {
- ActionPaletteItem dragItem = DND.DragWidget as ActionPaletteItem;
- if (dragItem == null)
- return false;
-
- if (actionTree.Children.Count > 0) {
- ActionMenuItem item = LocateWidget (x, y);
- if (item != null) {
- Widget wrapper = Widget.Lookup (this);
-
- // Show the submenu to allow droping to it, but avoid
- // droping a submenu inside itself
- if (item.HasSubmenu && item.Node != dragItem.Node)
- item.ShowSubmenu (wrapper.GetDesignArea(), item);
-
- // Look for the index where to insert the new item
- dropIndex = actionTree.Children.IndexOf (item.Node);
- int mpos = item.Allocation.X + item.Allocation.Width / 2;
- if (x > mpos)
- dropIndex++;
-
- // Calculate the drop position, used to show the drop bar
- if (dropIndex == 0)
- dropPosition = item.Allocation.X;
- else if (dropIndex == menuItems.Count)
- dropPosition = item.Allocation.Right;
- else {
- item = (ActionMenuItem) menuItems [dropIndex];
- ActionMenuItem prevItem = (ActionMenuItem) menuItems [dropIndex - 1];
- dropPosition = prevItem.Allocation.Right + (item.Allocation.X - prevItem.Allocation.Right)/2;
- }
- }
- } else
- dropIndex = 0;
-
- QueueDraw ();
- return base.OnDragMotion (context, x, y, time);
- }
-
- protected override void OnDragLeave (Gdk.DragContext context, uint time)
- {
- dropPosition = -1;
- QueueDraw ();
- base.OnDragLeave (context, time);
- }
-
- protected override bool OnDragDrop (Gdk.DragContext context, int x, int y, uint time)
- {
- ActionPaletteItem dropped = DND.Drop (context, null, time) as ActionPaletteItem;
- if (dropped == null)
- return false;
-
- if (dropped.Node.Type != Gtk.UIManagerItemType.Menuitem &&
- dropped.Node.Type != Gtk.UIManagerItemType.Menu &&
- dropped.Node.Type != Gtk.UIManagerItemType.Toolitem &&
- dropped.Node.Type != Gtk.UIManagerItemType.Separator)
- return false;
-
- ActionTreeNode newNode = dropped.Node;
- if (dropped.Node.Type == Gtk.UIManagerItemType.Toolitem) {
- newNode = newNode.Clone ();
- newNode.Type = Gtk.UIManagerItemType.Menuitem;
- }
-
- Widget wrapper = Widget.Lookup (this);
- using (wrapper.UndoManager.AtomicChange) {
- if (dropIndex < actionTree.Children.Count) {
- // Do nothing if trying to drop the node over the same node
- ActionTreeNode dropNode = actionTree.Children [dropIndex];
- if (dropNode == dropped.Node)
- return false;
-
- if (newNode.ParentNode != null)
- newNode.ParentNode.Children.Remove (newNode);
-
- // The drop position may have changed after removing the dropped node,
- // so get it again.
- dropIndex = actionTree.Children.IndexOf (dropNode);
- actionTree.Children.Insert (dropIndex, newNode);
- } else {
- if (newNode.ParentNode != null)
- newNode.ParentNode.Children.Remove (newNode);
- actionTree.Children.Add (newNode);
- dropIndex = actionTree.Children.Count - 1;
- }
-
- // Select the dropped node
- ActionMenuItem mi = (ActionMenuItem) menuItems [dropIndex];
- mi.Select ();
- }
-
- return base.OnDragDrop (context, x, y, time);
- }
- protected override bool OnExposeEvent (Gdk.EventExpose ev)
- {
- bool r = base.OnExposeEvent (ev);
- int w, h;
- this.GdkWindow.GetSize (out w, out h);
- if (dropPosition != -1)
- GdkWindow.DrawRectangle (this.Style.BlackGC, true, dropPosition, 0, 3, h);
- return r;
- }
-
- void OnItemKeyPress (object s, Gtk.KeyPressEventArgs args)
- {
- int pos = menuItems.IndexOf (s);
- ActionMenuItem item = (ActionMenuItem) s;
-
- switch (args.Event.Key) {
- case Gdk.Key.Left:
- if (pos > 0)
- ((ActionMenuItem)menuItems[pos - 1]).Select ();
- break;
- case Gdk.Key.Right:
- if (pos < menuItems.Count - 1)
- ((ActionMenuItem)menuItems[pos + 1]).Select ();
- else if (pos == menuItems.Count - 1)
- InsertAction (menuItems.Count);
- break;
- case Gdk.Key.Down:
- if (item.HasSubmenu) {
- item.ShowSubmenu ();
- if (openSubmenu != null)
- openSubmenu.Select (null);
- }
- break;
- case Gdk.Key.Up:
- OpenSubmenu = null;
- break;
- }
- args.RetVal = true;
- }
-
- void InsertActionAt (ActionMenuItem item, bool after, bool separator)
- {
- int pos = menuItems.IndexOf (item);
- if (pos == -1)
- return;
-
- if (after)
- pos++;
-
- if (separator) {
- ActionTreeNode newNode = new ActionTreeNode (Gtk.UIManagerItemType.Separator, null, null);
- actionTree.Children.Insert (pos, newNode);
- } else
- InsertAction (pos);
- }
-
- void Paste (ActionMenuItem item)
- {
- }
-
- public void ShowContextMenu (ActionItem aitem)
- {
- ActionMenuItem menuItem = (ActionMenuItem) aitem;
-
- Gtk.Menu m = new Gtk.Menu ();
- Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("Insert Before"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, false, false);
- };
- item = new Gtk.MenuItem (Catalog.GetString ("Insert After"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, true, false);
- };
-
- m.Add (new Gtk.SeparatorMenuItem ());
-
- item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- menuItem.Cut ();
- };
- item.Visible = false; // No copy & paste for now
- item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- menuItem.Copy ();
- };
- item.Visible = false; // No copy & paste for now
- item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- Paste (menuItem);
- };
- item.Visible = false; // No copy & paste for now
- item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- menuItem.Delete ();
- };
- m.ShowAll ();
- m.Popup ();
- }
-
- ActionMenuItem LocateWidget (int x, int y)
- {
- foreach (ActionMenuItem mi in menuItems) {
- if (mi.Allocation.Contains (x, y))
- return mi;
- }
- return null;
- }
-
- ActionMenuItem FindMenuItem (ActionTreeNode node)
- {
- foreach (ActionMenuItem mi in menuItems) {
- if (mi.Node == node)
- return mi;
- }
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenuItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenuItem.cs
deleted file mode 100644
index 9ac08166b0..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionMenuItem.cs
+++ /dev/null
@@ -1,588 +0,0 @@
-
-using System;
-using Stetic.Wrapper;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- class ActionMenuItem: ActionItem
- {
- Gtk.Widget icon;
- Gtk.Widget label;
- Gtk.Widget accel;
- bool motionDrag;
- CustomMenuBarItem menuBarItem;
-
- static Gdk.Pixbuf addMenuImage;
- static Gdk.Pixbuf removeMenuImage;
-
- public event MenuItemEditEventHandler EditingDone;
-
- static ActionMenuItem ()
- {
- try {
- addMenuImage = Gdk.Pixbuf.LoadFromResource ("add-menu.png");
- removeMenuImage = Gdk.Pixbuf.LoadFromResource ("remove-menu.png");
- } catch (Exception e) {
- Console.WriteLine ("Error while loading pixbuf: " + e);
- }
- }
-
- internal ActionMenuItem (Widget wrapper, IMenuItemContainer parent, ActionTreeNode node)
- : this (wrapper, parent, node, 0)
- {
- }
-
- internal ActionMenuItem (IDesignArea designArea, IProject project, IMenuItemContainer parent, ActionTreeNode node)
- : this (null, parent, node, 6)
- {
- this.project = project;
- this.designArea = designArea;
- }
-
- internal ActionMenuItem (Widget wrapper, IMenuItemContainer parent, ActionTreeNode node, uint itemSpacing): base (node, parent, itemSpacing)
- {
- this.wrapper = wrapper;
- CreateControls ();
- }
-
- bool disposed;
-
- public override void Dispose ()
- {
- if (disposed)
- return;
- disposed = true;
- if (menuBarItem != null) {
- menuBarItem.ButtonPressEvent -= OnMenuItemPress;
- menuBarItem.ButtonReleaseEvent -= OnMemuItemRelease;
- menuBarItem.MotionNotifyEvent -= OnMotionNotify;
- }
- if (node.Action != null)
- node.Action.ObjectChanged -= OnActionChanged;
- base.Dispose ();
- }
-
- public bool HasSubmenu {
- get { return node.Type == Gtk.UIManagerItemType.Menu; }
- }
-
- public void StartEditing ()
- {
- if (!editing) {
- editing = true;
-
- Refresh ();
- if (node.Type == Gtk.UIManagerItemType.Menu)
- HideSubmenu ();
-
- UpdateSelectionStatus ();
- }
- }
-
-
- protected override void EndEditing (Gdk.Key exitKey)
- {
- if (editing) {
- Gtk.Entry entry = label as Gtk.Entry;
- if (entry != null && exitKey != Gdk.Key.Escape) {
- localUpdate = true;
- if (entry.Text.Trim().Length > 0 || node.Action.GtkAction.StockId != null) {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.Label = entry.Text;
- node.Action.NotifyChanged ();
- }
- }
- localUpdate = false;
- }
-
- editing = false;
- Refresh ();
- while (Gtk.Application.EventsPending ())
- Gtk.Application.RunIteration ();
- if (node.Type == Gtk.UIManagerItemType.Menu) {
- if (wrapper != null) {
- IDesignArea area = wrapper.GetDesignArea ();
- if (area != null)
- ShowSubmenu (area, this);
- }
- }
- GrabFocus ();
- UpdateSelectionStatus ();
-
- if (EditingDone != null) {
- MenuItemEditEventArgs args = new MenuItemEditEventArgs ();
- args.ExitKey = exitKey;
- EditingDone (this, args);
- }
- }
- }
-
- public override void Select ()
- {
- base.Select ();
-
- if (!IsSubmenuVisible) {
- parentMenu.OpenSubmenu = null;
- if (HasSubmenu)
- ShowSubmenu (GetDesignArea (), this);
- }
- GrabFocus ();
- }
-
- public void Attach (Gtk.Table table, uint row, uint col)
- {
- table.Attach (this, col, col + 3, row, row + 1);
- Show ();
- AttachChildren (table, row, col);
- }
-
- void AttachChildren (Gtk.Table table, uint row, uint col)
- {
- if (icon != null) {
- table.Attach (icon, col, col + 1, row, row + 1);
- Gtk.Table.TableChild tc = (Gtk.Table.TableChild) table [icon];
- if (!editing)
- tc.YPadding = itemSpacing;
- }
- if (label != null) {
- table.Attach (label, col + 1, col + 2, row, row + 1);
- Gtk.Table.TableChild tc = (Gtk.Table.TableChild) table [label];
- if (!editing)
- tc.YPadding = itemSpacing;
- label.GrabFocus ();
- }
- if (accel != null)
- table.Attach (accel, col + 2, col + 3, row, row + 1);
-
- if (minWidth > 0 && label != null) {
- if (label.SizeRequest().Width < minWidth)
- label.WidthRequest = minWidth;
- }
-
- bool sens = editing || node.Action == null || node.Action.GtkAction.Sensitive;
- if (icon != null)
- icon.Sensitive = sens;
- if (label != null)
- label.Sensitive = sens;
- if (accel != null)
- accel.Sensitive = sens;
- }
-
- void CreateControls ()
- {
- if (node.Type == Gtk.UIManagerItemType.Separator) {
- Gtk.Widget sep;
- if (parentMenu.IsTopMenu) {
- sep = new Gtk.VSeparator ();
- sep.WidthRequest = 6;
- } else {
- sep = new Gtk.HSeparator ();
- sep.HeightRequest = 6;
- }
- Add (sep);
- ShowAll ();
- return;
- } else {
- if (Child != null && Child is Gtk.Separator)
- Remove (Child);
- }
-
- if (node.Action == null)
- return;
-
- bool isGlobal = wrapper != null && wrapper.Project.ActionGroups.IndexOf (node.Action.ActionGroup) != -1;
-
- Gtk.Action gaction = node.Action.GtkAction;
- bool barItem = parentMenu.IsTopMenu;
-
- string text = gaction.Label;
- string stock = gaction.StockId;
-
- if (barItem) {
- icon = null;
- } else if (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio) {
- icon = new CheckActionIcon (true, node.Action.Active);
- } else if (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle) {
- icon = new CheckActionIcon (node.Action.DrawAsRadio, node.Action.Active);
- }
-
- if (stock != null) {
- Gtk.StockItem item = Gtk.Stock.Lookup (stock);
- if (text == null || text.Length == 0)
- text = item.Label;
-
- if (item.Keyval != 0 && !editing && !barItem) {
- Gtk.Label lac = new Gtk.Label ();
- string accelName = Gtk.Accelerator.Name (item.Keyval, item.Modifier).ToUpper ();
- accelName = accelName.Replace ("<CONTROL>", "Ctrl+");
- accelName = accelName.Replace ("<SHIFT>", "Shift+");
- accelName = accelName.Replace ("<ALT>", "Alt+");
- lac.Text = accelName;
- accel = lac;
- }
-
- if (icon == null && !barItem)
- icon = node.Action.CreateIcon (Gtk.IconSize.Menu);
- }
-
- if (editing && !isGlobal) {
- if (!barItem) {
- Gtk.HBox bbox = new Gtk.HBox ();
- if (icon != null) {
- bbox.PackStart (icon, false, false, 0);
- }
- bbox.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.In), false, false, 0);
- Gtk.Button b = new Gtk.Button (bbox);
- b.TooltipText = Catalog.GetString ("Select action type");
- b.Relief = Gtk.ReliefStyle.None;
- b.ButtonPressEvent += OnSelectIcon;
- icon = b;
- } else
- icon = null;
-
- Gtk.Entry entry = new Gtk.Entry ();
- entry.Text = text;
- entry.Activated += OnLabelActivated;
- entry.KeyPressEvent += OnEntryKeyPress;
- entry.HasFrame = false;
- this.label = entry;
- entry.TooltipText = Catalog.GetString ("Action label");
- } else {
- Gtk.Label label = new Gtk.Label (text);
- label.Xalign = 0;
- this.label = label;
- }
-
- if (editing && wrapper != null) {
- // Add a button for creating / deleting a submenu
- Gdk.Pixbuf img;
- string tip;
- if (node.Type != Gtk.UIManagerItemType.Menu) {
- img = addMenuImage;
- tip = Catalog.GetString ("Add submenu (Ctrl+Right)");
- } else {
- img = removeMenuImage;
- tip = Catalog.GetString ("Remove submenu (Ctrl+Left)");
- }
-
- Gtk.Button sb = new Gtk.Button (new Gtk.Image (img));
- sb.TooltipText = tip;
- sb.Relief = Gtk.ReliefStyle.None;
- sb.Clicked += OnCreateDeleteSubmenu;
-
- // Make sure the button is alligned to the right of the column
- Gtk.HBox bbox = new Gtk.HBox ();
- bbox.PackEnd (sb, false, false, 0);
- accel = bbox;
- }
-
-
- if (node.Type == Gtk.UIManagerItemType.Menu && !editing && !barItem) {
- Gtk.Arrow arrow = new Gtk.Arrow (Gtk.ArrowType.Right, Gtk.ShadowType.None);
- arrow.Xalign = 1;
- this.accel = arrow;
- }
-
- if (itemSpacing > 0 && icon != null) {
- // Add some padding to the left of the icon
- Gtk.Alignment a = new Gtk.Alignment (0, 0.5f, 0, 0);
- a.LeftPadding = itemSpacing;
- a.Add (icon);
- icon = a;
- }
- }
-
- public void Detach ()
- {
- if (disposed)
- return;
-
- Gtk.Table table = (Gtk.Table)Parent;
- if (table == null)
- return;
- if (icon != null)
- table.Remove (icon);
- if (label != null)
- table.Remove (label);
- if (accel != null)
- table.Remove (accel);
- table.Remove (this);
- }
-
- void OnCreateDeleteSubmenu (object ob, EventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- if (node.Type == Gtk.UIManagerItemType.Menu) {
- node.Type = Gtk.UIManagerItemType.Menuitem;
- node.Children.Clear ();
- } else {
- node.Type = Gtk.UIManagerItemType.Menu;
- }
-
- EndEditing (Gdk.Key.Return);
- node.Action.NotifyChanged ();
- }
- }
-
- void OnLabelActivated (object ob, EventArgs args)
- {
- EndEditing (Gdk.Key.Return);
- }
-
- [GLib.ConnectBefore]
- void OnEntryKeyPress (object ob, Gtk.KeyPressEventArgs args)
- {
- switch (args.Event.Key) {
- case Gdk.Key.Down:
- case Gdk.Key.Escape:
- case Gdk.Key.Up:
- EndEditing (args.Event.Key);
- args.RetVal = true;
- break;
- }
- args.RetVal = false;
- }
-
- [GLib.ConnectBeforeAttribute]
- void OnSelectIcon (object sender, Gtk.ButtonPressEventArgs e)
- {
- Gtk.Menu menu = new Gtk.Menu ();
-
- Gtk.CheckMenuItem item = new Gtk.CheckMenuItem (Catalog.GetString ("Action"));
- item.DrawAsRadio = true;
- item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action);
- item.Activated += OnSetActionType;
- menu.Insert (item, -1);
-
- item = new Gtk.CheckMenuItem (Catalog.GetString ("Radio Action"));
- item.DrawAsRadio = true;
- item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio);
- item.Activated += OnSetRadioType;
- menu.Insert (item, -1);
-
- item = new Gtk.CheckMenuItem (Catalog.GetString ("Toggle Action"));
- item.DrawAsRadio = true;
- item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle);
- item.Activated += OnSetToggleType;
- menu.Insert (item, -1);
-
- menu.Insert (new Gtk.SeparatorMenuItem (), -1);
-
- Gtk.MenuItem itIcons = new Gtk.MenuItem (Catalog.GetString ("Select Icon"));
- menu.Insert (itIcons, -1);
- IconSelectorMenu menuIcons = new IconSelectorMenu (GetProject ());
- menuIcons.IconSelected += OnStockSelected;
- itIcons.Submenu = menuIcons;
-
- Gtk.MenuItem it = new Gtk.MenuItem (Catalog.GetString ("Clear Icon"));
- it.Sensitive = (node.Action.GtkAction.StockId != null);
- it.Activated += OnClearIcon;
- menu.Insert (it, -1);
-
- menu.ShowAll ();
- menu.Popup (null, null, new Gtk.MenuPositionFunc (OnDropMenuPosition), 3, Gtk.Global.CurrentEventTime);
- e.RetVal = false;
- }
-
- void OnDropMenuPosition (Gtk.Menu menu, out int x, out int y, out bool pushIn)
- {
- this.ParentWindow.GetOrigin (out x, out y);
- x += this.Allocation.X;
- y += this.Allocation.Y + this.Allocation.Height;
- pushIn = true;
- }
-
- void OnStockSelected (object s, IconEventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.StockId = args.IconId;
- node.Action.NotifyChanged ();
- }
- }
-
- void OnSetToggleType (object ob, EventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.Type = Stetic.Wrapper.Action.ActionType.Toggle;
- node.Action.NotifyChanged ();
- }
- }
-
- void OnSetRadioType (object ob, EventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.Type = Stetic.Wrapper.Action.ActionType.Radio;
- node.Action.NotifyChanged ();
- }
- }
-
- void OnSetActionType (object ob, EventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.Type = Stetic.Wrapper.Action.ActionType.Action;
- node.Action.NotifyChanged ();
- }
- }
-
- void OnClearIcon (object on, EventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.StockId = null;
- node.Action.NotifyChanged ();
- }
- }
-
- public override void Refresh ()
- {
- Gtk.Table table = (Gtk.Table)Parent;
- if (table == null)
- return;
-
- if (icon != null && icon.Parent != null)
- table.Remove (icon);
- if (label != null && label.Parent != null)
- table.Remove (label);
- if (accel != null && accel.Parent != null)
- table.Remove (accel);
-
- icon = label = accel = null;
- CreateControls ();
- Gtk.Table.TableChild tc = (Gtk.Table.TableChild)table[this];
- AttachChildren (table, tc.TopAttach, tc.LeftAttach);
-
- table.ShowAll ();
- }
-
- internal void Bind (CustomMenuBarItem item)
- {
- // When embedding the action menu in a MenuBar,
- // the parent menu item intercepts the mouse events,
- // so those events must be manually bound here
- menuBarItem = item;
- item.ButtonPressEvent += OnMenuItemPress;
- item.ButtonReleaseEvent += OnMemuItemRelease;
- item.MotionNotifyEvent += OnMotionNotify;
- }
-
- [GLib.ConnectBeforeAttribute]
- void OnMenuItemPress (object ob, Gtk.ButtonPressEventArgs args)
- {
- Gtk.Widget mit = (Gtk.Widget) ob;
- if (wrapper != null && wrapper.Project.Selection != mit.Parent) {
- wrapper.Select ();
- args.RetVal = true;
- return;
- }
- motionDrag = true;
- args.RetVal = ProcessButtonPress (args.Event);
- }
-
- [GLib.ConnectBeforeAttribute]
- void OnMemuItemRelease (object ob, Gtk.ButtonReleaseEventArgs args)
- {
- args.RetVal = ProcessButtonRelease (args.Event);
- motionDrag = false;
- }
-
- void OnMotionNotify (object ob, Gtk.MotionNotifyEventArgs args)
- {
- if (motionDrag) {
- // Looks like drag begin can be intercepted, so the motion notify
- // has to be used.
- ProcessDragBegin (null, args.Event);
- motionDrag = false;
- }
- }
-
- protected override bool OnButtonReleaseEvent (Gdk.EventButton ev)
- {
- return ProcessButtonRelease (ev);
- }
-
- public bool ProcessButtonRelease (Gdk.EventButton ev)
- {
- // Clicking a selected item starts the edit mode
- if (editOnRelease)
- StartEditing ();
-
- editOnRelease = false;
- return true;
- }
-
- public override void ProcessDragBegin (Gdk.DragContext ctx, Gdk.EventMotion evt)
- {
- if (HasSubmenu)
- HideSubmenu ();
- base.ProcessDragBegin (ctx, evt);
- }
-
- void OnActionChanged (object ob, ObjectWrapperEventArgs a)
- {
- if (!localUpdate)
- Refresh ();
- }
-
- public bool IsSubmenuVisible {
- get {
- ActionMenu menu = parentMenu.OpenSubmenu;
- return (menu != null && menu.ParentNode == node);
- }
- }
-
- public void ShowSubmenu ()
- {
- ShowSubmenu (wrapper.GetDesignArea (), this);
- }
-
- public void ShowSubmenu (IDesignArea area, Gtk.Widget refWidget)
- {
- HideSubmenu ();
- Gdk.Rectangle rect = area.GetCoordinates (refWidget);
- ActionMenu menu = new ActionMenu (wrapper, parentMenu, node);
- menu.ShowAll ();
- area.AddWidget (menu, rect.Right, rect.Top);
- menu.TrackWidgetPosition (refWidget, parentMenu.IsTopMenu);
-
- parentMenu.OpenSubmenu = menu;
- }
-
- void HideSubmenu ()
- {
- parentMenu.OpenSubmenu = null;
- }
- }
-
- class CheckActionIcon: Gtk.EventBox
- {
- readonly bool isRadio;
- readonly bool active;
-
- public CheckActionIcon (bool isRadio, bool active)
- {
- this.isRadio = isRadio;
- this.active = active;
- WidthRequest = HeightRequest = 16;
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose ev)
- {
- Gdk.Rectangle rect = Allocation;
- rect.X = rect.Y = 0;
-
- Gtk.ShadowType sh = active ? Gtk.ShadowType.In : Gtk.ShadowType.Out;
- if (isRadio)
- Gtk.Style.PaintOption (this.Style, this.GdkWindow, this.State, sh, rect, this, "", rect.X, rect.Y, rect.Width, rect.Height);
- else
- Gtk.Style.PaintCheck (this.Style, this.GdkWindow, this.State, sh, rect, this, "", rect.X, rect.Y, rect.Width, rect.Height);
- return true;
- }
- }
-
- delegate void MenuItemEditEventHandler (object s, MenuItemEditEventArgs args);
-
- class MenuItemEditEventArgs: EventArgs
- {
- public Gdk.Key ExitKey;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionToolItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionToolItem.cs
deleted file mode 100644
index 5b27ab4c1c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionToolItem.cs
+++ /dev/null
@@ -1,371 +0,0 @@
-
-using System;
-using Stetic.Wrapper;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- class ActionToolItem: ActionItem
- {
- ActionToolbar parentToolbar;
-
- bool motionDrag;
- bool showingText;
- Gtk.Widget dropButton;
-
- public event EventHandler EditingDone;
-
- internal ActionToolItem (Widget wrapper, ActionToolbar parent, ActionTreeNode node)
- : this (wrapper, parent, node, 0)
- {
- }
-
- internal ActionToolItem (Widget wrapper, ActionToolbar parent, ActionTreeNode node, uint itemSpacing): base (node, parent, itemSpacing)
- {
- this.parentToolbar = parent;
- this.wrapper = wrapper;
- CreateControls ();
- }
-
- public void StartEditing (bool doClick)
- {
- if (!editing && node.Action != null) {
- // Don't allow efiting global actions
- if (wrapper != null && wrapper.Project.ActionGroups.IndexOf (node.Action.ActionGroup) != -1)
- return;
- editing = true;
- Refresh ();
-
- if (doClick && dropButton != null) {
- // Make sure the dropButton is properly shown
- while (Gtk.Application.EventsPending ())
- Gtk.Application.RunIteration ();
- OnSelectIcon (null, null);
- }
- }
- }
-
- protected override void EndEditing (Gdk.Key exitKey)
- {
- if (editing) {
- editing = false;
- Refresh ();
- while (Gtk.Application.EventsPending ())
- Gtk.Application.RunIteration ();
- GrabFocus ();
- if (EditingDone != null)
- EditingDone (this, EventArgs.Empty);
- }
- }
-
- void CreateControls ()
- {
- Gtk.Widget icon = null;
- Gtk.Widget label = null;
- dropButton = null;
-
- if (Child != null) {
- Gtk.Widget w = Child;
- Remove (w);
- w.Destroy ();
- }
-
- if (node.Type == Gtk.UIManagerItemType.Separator) {
- Gtk.Widget sep;
- if (parentToolbar.Orientation == Gtk.Orientation.Horizontal) {
- sep = new Gtk.VSeparator ();
- } else {
- sep = new Gtk.HSeparator ();
- }
- Gtk.HBox box = new Gtk.HBox ();
- box.BorderWidth = 6;
- box.PackStart (sep, true, true, 0);
- Add (box);
- return;
- }
-
- if (node.Action == null)
- return;
-
- Gtk.Action gaction = node.Action.GtkAction;
-
- bool showText = parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.Text;
- bool showIcon = parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.Icons;
- if (parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.Both) {
- showText = showIcon = true;
- }
- else if (parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.BothHoriz) {
- showText = parentToolbar.Orientation == Gtk.Orientation.Vertical || gaction.IsImportant;
- showIcon = true;
- }
-
- string text = node.Action.ToolLabel;
- showingText = showText;
-
- if (showIcon)
- {
- if (gaction.StockId != null) {
- icon = node.Action.CreateIcon (parentToolbar.IconSize);
- } else if (!gaction.IsImportant) {
- icon = CreateFakeItem ();
- }
- }
-
- if (editing) {
- Gtk.HBox bbox = new Gtk.HBox ();
- bbox.Spacing = 3;
- if (icon != null) {
- bbox.PackStart (icon, false, false, 0);
- }
- bbox.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.In), false, false, 0);
- Gtk.Button b = new Gtk.Button (bbox);
- b.TooltipText = Catalog.GetString ("Select action type");
- b.Relief = Gtk.ReliefStyle.None;
- b.ButtonPressEvent += OnSelectIcon;
- dropButton = b;
- icon = b;
-
- if (showText) {
- Gtk.Entry entry = new Gtk.Entry ();
- entry.Text = text;
- entry.Changed += OnLabelChanged;
- entry.Activated += OnLabelActivated;
- entry.HasFrame = false;
- label = entry;
- entry.TooltipText = Catalog.GetString ("Action label");
- }
- } else if (showText && text != null && text.Length > 0) {
- label = new Gtk.Label (text);
- label.Sensitive = editing || node.Action == null || node.Action.GtkAction.Sensitive;
- }
-
- if (icon != null && label != null) {
- if (parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.BothHoriz) {
- Gtk.HBox box = new Gtk.HBox ();
- box.PackStart (icon, false, false, 0);
- box.PackStart (label, true, true, 0);
- icon = box;
- } else if (parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.Both) {
- Gtk.VBox box = new Gtk.VBox ();
- Gtk.Alignment al = new Gtk.Alignment (0.5f, 0f, 0f, 0f);
- al.Add (icon);
- box.PackStart (al, false, false, 0);
- box.PackStart (label, true, true, 0);
- icon = box;
- }
- } else if (label != null) {
- icon = label;
- }
-
- if (icon == null) {
- icon = CreateFakeItem ();
- }
-
- icon.Sensitive = editing || node.Action == null || node.Action.GtkAction.Sensitive;
-
- if (!editing) {
- Gtk.Button but = new Gtk.Button (icon);
- but.Relief = Gtk.ReliefStyle.None;
- but.ButtonPressEvent += OnToolItemPress;
- but.ButtonReleaseEvent += OnMemuItemRelease;
- but.MotionNotifyEvent += OnMotionNotify;
- but.Events |= Gdk.EventMask.PointerMotionMask;
- icon = but;
- }
-
- Add (icon);
-
- ShowAll ();
- }
-
- Gtk.Widget CreateFakeItem ()
- {
- Gtk.Frame frm = new Gtk.Frame ();
- frm.ShadowType = Gtk.ShadowType.Out;
- int w, h;
- Gtk.Icon.SizeLookup (parentToolbar.IconSize, out w, out h);
- frm.WidthRequest = w;
- frm.HeightRequest = h;
- return frm;
- }
-
- void OnLabelChanged (object ob, EventArgs args)
- {
- localUpdate = true;
-
- Gtk.Entry entry = ob as Gtk.Entry;
- if (entry.Text.Length > 0 || node.Action.GtkAction.StockId != null) {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.Label = entry.Text;
- node.Action.NotifyChanged ();
- }
- }
- localUpdate = false;
- }
-
- void OnLabelActivated (object ob, EventArgs args)
- {
- EndEditing (Gdk.Key.Return);
- }
-
- [GLib.ConnectBeforeAttribute]
- void OnSelectIcon (object s, Gtk.ButtonPressEventArgs args)
- {
- Gtk.Menu menu = new Gtk.Menu ();
-
- Gtk.CheckMenuItem item = new Gtk.CheckMenuItem (Catalog.GetString ("Action"));
- item.DrawAsRadio = true;
- item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action);
- item.Activated += OnSetActionType;
- menu.Insert (item, -1);
-
- item = new Gtk.CheckMenuItem (Catalog.GetString ("Radio Action"));
- item.DrawAsRadio = true;
- item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio);
- item.Activated += OnSetRadioType;
- menu.Insert (item, -1);
-
- item = new Gtk.CheckMenuItem (Catalog.GetString ("Toggle Action"));
- item.DrawAsRadio = true;
- item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle);
- item.Activated += OnSetToggleType;
- menu.Insert (item, -1);
-
- menu.Insert (new Gtk.SeparatorMenuItem (), -1);
-
- Gtk.MenuItem itIcons = new Gtk.MenuItem (Catalog.GetString ("Select Icon"));
- menu.Insert (itIcons, -1);
- IconSelectorMenu menuIcons = new IconSelectorMenu (GetProject ());
- menuIcons.IconSelected += OnStockSelected;
- itIcons.Submenu = menuIcons;
-
- Gtk.MenuItem it = new Gtk.MenuItem (Catalog.GetString ("Clear Icon"));
- it.Sensitive = (node.Action.GtkAction.StockId != null);
- it.Activated += OnClearIcon;
- menu.Insert (it, -1);
-
- menu.ShowAll ();
-
- uint but = args != null ? args.Event.Button : 1;
- menu.Popup (null, null, new Gtk.MenuPositionFunc (OnDropMenuPosition), but, Gtk.Global.CurrentEventTime);
-
- // Make sure we get the focus after closing the menu, so we can keep browsing buttons
- // using the keyboard.
- menu.Hidden += delegate (object sender, EventArgs a) {
- GrabFocus ();
- };
-
- if (args != null)
- args.RetVal = false;
- }
-
- void OnDropMenuPosition (Gtk.Menu menu, out int x, out int y, out bool pushIn)
- {
- dropButton.ParentWindow.GetOrigin (out x, out y);
- x += dropButton.Allocation.X;
- y += dropButton.Allocation.Y + dropButton.Allocation.Height;
- pushIn = true;
- }
-
- void OnSetToggleType (object ob, EventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.Type = Stetic.Wrapper.Action.ActionType.Toggle;
- node.Action.NotifyChanged ();
- }
- }
-
- void OnSetRadioType (object ob, EventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.Type = Stetic.Wrapper.Action.ActionType.Radio;
- node.Action.NotifyChanged ();
- }
- }
-
- void OnSetActionType (object ob, EventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.Type = Stetic.Wrapper.Action.ActionType.Action;
- node.Action.NotifyChanged ();
- }
- }
-
- void OnStockSelected (object s, IconEventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.StockId = args.IconId;
- node.Action.NotifyChanged ();
- }
- }
-
- void OnClearIcon (object on, EventArgs args)
- {
- using (node.Action.UndoManager.AtomicChange) {
- node.Action.StockId = null;
- node.Action.NotifyChanged ();
- }
- }
-
- public override void Refresh ()
- {
- CreateControls ();
- }
-
- [GLib.ConnectBeforeAttribute]
- void OnToolItemPress (object ob, Gtk.ButtonPressEventArgs args)
- {
- if (wrapper != null && wrapper.Project.Selection != wrapper.Wrapped) {
- wrapper.Select ();
- args.RetVal = true;
- return;
- }
- if (args.Event.Button == 1)
- motionDrag = true;
- args.RetVal = ProcessButtonPress (args.Event);
- }
-
- [GLib.ConnectBeforeAttribute]
- void OnMemuItemRelease (object ob, Gtk.ButtonReleaseEventArgs args)
- {
- args.RetVal = ProcessButtonRelease (args.Event);
- motionDrag = false;
- }
-
- [GLib.ConnectBeforeAttribute]
- void OnMotionNotify (object ob, Gtk.MotionNotifyEventArgs args)
- {
- if (motionDrag) {
- // Looks like drag begin can be intercepted, so the motion notify
- // has to be used.
- ProcessDragBegin (null, args.Event);
- motionDrag = false;
- }
- }
-
- protected override bool OnButtonReleaseEvent (Gdk.EventButton ev)
- {
- return ProcessButtonRelease (ev);
- }
-
- public bool ProcessButtonRelease (Gdk.EventButton ev)
- {
- // Clicking a selected item starts the edit mode
- if (editOnRelease) {
- StartEditing (!showingText);
- }
-
- editOnRelease = false;
- return true;
- }
-
- protected override bool OnKeyPressEvent (Gdk.EventKey e)
- {
- if (e.Key == Gdk.Key.Return)
- EndEditing (Gdk.Key.Return);
- else if (e.Key == Gdk.Key.Escape)
- EndEditing (Gdk.Key.Escape);
- return base.OnKeyPressEvent (e);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionToolbar.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionToolbar.cs
deleted file mode 100644
index 3166f669a3..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ActionToolbar.cs
+++ /dev/null
@@ -1,542 +0,0 @@
-
-using System;
-using System.Xml;
-using System.Collections;
-using Stetic.Wrapper;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- class ActionToolbar: Gtk.Toolbar, IMenuItemContainer
- {
- ActionTree actionTree;
- int dropPosition = -1;
- int dropIndex;
- ArrayList toolItems = new ArrayList ();
- bool showPlaceholder = true;
- Gtk.Widget addLabel;
- Gtk.Widget spacerItem;
-
- public ActionToolbar ()
- {
- DND.DestSet (this, true);
- this.ShowArrow = false;
- }
-
- public void FillMenu (ActionTree actionTree)
- {
- addLabel = null;
-
- if (this.actionTree != null) {
- this.actionTree.ChildNodeAdded -= OnChildAdded;
- this.actionTree.ChildNodeRemoved -= OnChildRemoved;
- }
-
- this.actionTree = actionTree;
- if (actionTree == null) {
- AddSpacerItem ();
- return;
- }
-
- actionTree.ChildNodeAdded += OnChildAdded;
- actionTree.ChildNodeRemoved += OnChildRemoved;
-
- HideSpacerItem ();
- toolItems.Clear ();
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (this);
-
- foreach (Gtk.Widget w in Children) {
- Remove (w);
- w.Destroy ();
- }
-
- foreach (ActionTreeNode node in actionTree.Children) {
- ActionToolItem aitem = new ActionToolItem (wrapper, this, node);
- AddItem (aitem, -1);
- toolItems.Add (aitem);
- }
-
- if (actionTree.Children.Count == 0) {
- // If there are no buttons in the toolbar, give it some height so it is selectable.
- AddSpacerItem ();
- }
-
- if (showPlaceholder) {
- AddCreateItemLabel ();
- }
- }
-
- void AddCreateItemLabel ()
- {
- HideSpacerItem ();
- Gtk.EventBox ebox = new Gtk.EventBox ();
- ebox.VisibleWindow = false;
- Gtk.Label emptyLabel = new Gtk.Label ();
- emptyLabel.Xalign = 0;
- if (this.Orientation == Gtk.Orientation.Vertical)
- emptyLabel.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("New\nbutton") + "</span></i>";
- else
- emptyLabel.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("New button") + "</span></i>";
- ebox.BorderWidth = 3;
- ebox.Add (emptyLabel);
- Gtk.ToolItem mit = new Gtk.ToolItem ();
- mit.Child = ebox;
- ebox.ButtonPressEvent += OnNewItemPress;
- Insert (mit, -1);
- mit.ShowAll ();
- addLabel = mit;
- }
-
- void AddSpacerItem ()
- {
- if (spacerItem == null) {
- Gtk.ToolItem tb = new Gtk.ToolItem ();
- Gtk.Label emptyLabel = new Gtk.Label ();
- emptyLabel.Xalign = 0;
- emptyLabel.Xpad = 3;
- emptyLabel.Ypad = 3;
- if (this.Orientation == Gtk.Orientation.Vertical)
- emptyLabel.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("Empty\ntoolbar") + "</span></i>";
- else
- emptyLabel.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("Empty toolbar") + "</span></i>";
- tb.Child = emptyLabel;
- Insert (tb, -1);
- ShowAll ();
- spacerItem = tb;
- }
- }
-
- void HideSpacerItem ()
- {
- if (spacerItem != null) {
- Remove (spacerItem);
- spacerItem = null;
- }
- }
-
- void AddItem (ActionToolItem aitem, int pos)
- {
- aitem.KeyPressEvent += OnItemKeyPress;
-
- CustomToolbarItem it = new CustomToolbarItem ();
- it.ActionToolItem = aitem;
- it.Child = aitem;
- it.ShowAll ();
- Insert (it, pos);
- }
-
- public bool ShowInsertPlaceholder {
- get { return showPlaceholder; }
- set {
- showPlaceholder = value;
- if (value && addLabel == null) {
- AddCreateItemLabel ();
- } else if (!value && addLabel != null) {
- Remove (addLabel);
- addLabel.Destroy ();
- addLabel = null;
- if (actionTree.Children.Count == 0)
- AddSpacerItem ();
- }
- }
- }
-
- public Stetic.Editor.ActionMenu OpenSubmenu {
- get { return null; }
- set { }
- }
-
- public bool IsTopMenu {
- get { return true; }
- }
-
- public Gtk.Widget Widget {
- get { return this; }
- }
-
- public void Unselect ()
- {
- // Unselects any selected item
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (this);
- IDesignArea area = wrapper.GetDesignArea ();
- if (area != null) {
- foreach (Gtk.Widget w in Children) {
- CustomToolbarItem it = w as CustomToolbarItem;
- if (it != null)
- area.ResetSelection (it.ActionToolItem);
- }
- }
- }
-
- void OnChildAdded (object ob, ActionTreeNodeArgs args)
- {
- Refresh ();
- }
-
- void OnChildRemoved (object ob, ActionTreeNodeArgs args)
- {
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (this);
- IDesignArea area = wrapper.GetDesignArea ();
- IObjectSelection asel = area.GetSelection ();
- ActionToolItem curSel = asel != null ? asel.DataObject as ActionToolItem : null;
- int pos = toolItems.IndexOf (curSel);
-
- foreach (Gtk.Widget w in Children) {
- if (w is CustomToolbarItem && ((CustomToolbarItem)w).ActionToolItem.Node == args.Node) {
- Remove (w);
- toolItems.Remove (((CustomToolbarItem)w).ActionToolItem);
- w.Destroy ();
- if (!showPlaceholder && toolItems.Count == 0)
- AddSpacerItem ();
- break;
- }
- }
-
- if (pos != -1 && pos < toolItems.Count)
- ((ActionToolItem)toolItems[pos]).Select ();
- else if (toolItems.Count > 0)
- ((ActionToolItem)toolItems[toolItems.Count-1]).Select ();
- }
-
- void Refresh ()
- {
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (this);
- IDesignArea area = wrapper.GetDesignArea ();
- if (area == null)
- return;
-
- ActionTreeNode selNode = null;
-
- foreach (Gtk.Widget w in Children) {
- CustomToolbarItem it = w as CustomToolbarItem;
- if (it != null && area.IsSelected (it.ActionToolItem)) {
- selNode = it.ActionToolItem.Node;
- area.ResetSelection (it.ActionToolItem);
- }
- Remove (w);
- w.Destroy ();
- }
-
- FillMenu (actionTree);
-
- if (selNode != null) {
- ActionToolItem mi = FindMenuItem (selNode);
- if (mi != null)
- mi.Select ();
- }
- }
-
- [GLib.ConnectBeforeAttribute]
- void OnNewItemPress (object ob, Gtk.ButtonPressEventArgs args)
- {
- InsertAction (toolItems.Count);
- args.RetVal = true;
- }
-
- void InsertAction (int pos)
- {
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (this);
- using (wrapper.UndoManager.AtomicChange) {
- Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project,
- new Gtk.Action ("", "", null, null),
- wrapper);
- ActionTreeNode node = new ActionTreeNode (Gtk.UIManagerItemType.Toolitem, "", ac);
- actionTree.Children.Insert (pos, node);
-
- ActionToolItem aitem = FindMenuItem (node);
- aitem.EditingDone += OnEditingDone;
- aitem.Select ();
- aitem.StartEditing (false);
- //ShowInsertPlaceholder = false;
-
- if (wrapper.LocalActionGroups.Count == 0)
- wrapper.LocalActionGroups.Add (new ActionGroup ("Default"));
- wrapper.LocalActionGroups[0].Actions.Add (ac);
- }
- }
-
- void OnEditingDone (object ob, EventArgs args)
- {
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (this);
- if (wrapper == null)
- return;
-
- IDesignArea area = wrapper.GetDesignArea ();
- if (area == null) // The toolbar may be disposed before ending editing
- return;
-
- ActionToolItem item = (ActionToolItem) ob;
- item.EditingDone -= OnEditingDone;
-
- if (item.Node.Action.GtkAction.Label.Length == 0 && item.Node.Action.GtkAction.StockId == null) {
- area.ResetSelection (item);
- using (wrapper.UndoManager.AtomicChange) {
- actionTree.Children.Remove (item.Node);
- wrapper.LocalActionGroups [0].Actions.Remove (item.Node.Action);
- }
- }
- }
-
- public void Select (ActionTreeNode node)
- {
- ActionToolItem item = FindMenuItem (node);
- if (item != null)
- item.Select ();
- }
-
- protected override bool OnDragMotion (Gdk.DragContext context, int x, int y, uint time)
- {
- ActionPaletteItem dragItem = DND.DragWidget as ActionPaletteItem;
- if (dragItem == null)
- return false;
-
- x += Allocation.X;
- y += Allocation.Y;
-
- if (actionTree.Children.Count > 0) {
- ActionToolItem item = LocateWidget (x, y);
- if (item != null) {
- // Look for the index where to insert the new item
- dropIndex = actionTree.Children.IndexOf (item.Node);
- int spos = (Orientation == Gtk.Orientation.Horizontal) ? x : y;
- int mpos = GetButtonPos (item) + GetButtonSize (item) / 2;
- if (spos > mpos)
- dropIndex++;
-
- // Calculate the drop position, used to show the drop bar
- if (dropIndex == 0)
- dropPosition = GetButtonPos (item);
- else if (dropIndex == toolItems.Count)
- dropPosition = GetButtonEndPos (item);
- else {
- item = (ActionToolItem) toolItems [dropIndex];
- ActionToolItem prevItem = (ActionToolItem) toolItems [dropIndex - 1];
- dropPosition = GetButtonEndPos (prevItem) + (GetButtonPos (item) - GetButtonEndPos (prevItem))/2;
- }
- }
- } else
- dropIndex = 0;
-
- QueueDraw ();
- return base.OnDragMotion (context, x, y, time);
- }
-
- int GetButtonPos (Gtk.Widget w)
- {
- return (Orientation == Gtk.Orientation.Horizontal) ? w.Allocation.X : w.Allocation.Y;
- }
-
- int GetButtonEndPos (Gtk.Widget w)
- {
- return (Orientation == Gtk.Orientation.Horizontal) ? w.Allocation.Right : w.Allocation.Bottom;
- }
-
- int GetButtonSize (Gtk.Widget w)
- {
- return (Orientation == Gtk.Orientation.Horizontal) ? w.Allocation.Width : w.Allocation.Height;
- }
-
- protected override void OnDragLeave (Gdk.DragContext context, uint time)
- {
- dropPosition = -1;
- QueueDraw ();
- base.OnDragLeave (context, time);
- }
-
- protected override bool OnDragDrop (Gdk.DragContext context, int x, int y, uint time)
- {
- ActionPaletteItem dropped = DND.Drop (context, null, time) as ActionPaletteItem;
- if (dropped == null)
- return false;
-
- if (dropped.Node.Type != Gtk.UIManagerItemType.Menuitem &&
- dropped.Node.Type != Gtk.UIManagerItemType.Toolitem &&
- dropped.Node.Type != Gtk.UIManagerItemType.Separator)
- return false;
-
- ActionTreeNode newNode = dropped.Node;
- if (dropped.Node.Type == Gtk.UIManagerItemType.Menuitem) {
- newNode = newNode.Clone ();
- newNode.Type = Gtk.UIManagerItemType.Toolitem;
- }
-
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (this);
- using (wrapper.UndoManager.AtomicChange) {
- if (dropIndex < actionTree.Children.Count) {
- // Do nothing if trying to drop the node over the same node
- ActionTreeNode dropNode = actionTree.Children [dropIndex];
- if (dropNode == newNode)
- return false;
-
- if (newNode.ParentNode != null)
- newNode.ParentNode.Children.Remove (newNode);
-
- // The drop position may have changed after removing the dropped node,
- // so get it again.
- dropIndex = actionTree.Children.IndexOf (dropNode);
- actionTree.Children.Insert (dropIndex, newNode);
- } else {
- if (newNode.ParentNode != null)
- newNode.ParentNode.Children.Remove (newNode);
- actionTree.Children.Add (newNode);
- dropIndex = actionTree.Children.Count - 1;
- }
- }
- // Select the dropped node
- ActionToolItem mi = (ActionToolItem) toolItems [dropIndex];
- mi.Select ();
-
- return base.OnDragDrop (context, x, y, time);
- }
- protected override bool OnExposeEvent (Gdk.EventExpose ev)
- {
- bool r = base.OnExposeEvent (ev);
- if (dropPosition != -1) {
- if (this.Orientation == Gtk.Orientation.Horizontal)
- GdkWindow.DrawRectangle (this.Style.BlackGC, true, dropPosition, Allocation.Y, 3, Allocation.Height);
- else
- GdkWindow.DrawRectangle (this.Style.BlackGC, true, Allocation.X, dropPosition, Allocation.Width, 3);
- }
- return r;
- }
-
- void OnItemKeyPress (object s, Gtk.KeyPressEventArgs args)
- {
- int pos = toolItems.IndexOf (s);
- args.RetVal = false;
-
- switch (args.Event.Key) {
- case Gdk.Key.Left:
- args.RetVal = true;
- if (pos > 0)
- ((ActionToolItem)toolItems[pos - 1]).Select ();
- break;
- case Gdk.Key.Right:
- args.RetVal = true;
- if (pos < toolItems.Count - 1)
- ((ActionToolItem)toolItems[pos + 1]).Select ();
- else if (pos == toolItems.Count - 1)
- InsertAction (toolItems.Count);
- break;
- }
- }
-
- void InsertActionAt (ActionToolItem item, bool after, bool separator)
- {
- int pos = toolItems.IndexOf (item);
- if (pos == -1)
- return;
-
- if (after)
- pos++;
-
- if (separator) {
- ActionTreeNode newNode = new ActionTreeNode (Gtk.UIManagerItemType.Separator, null, null);
- actionTree.Children.Insert (pos, newNode);
- } else
- InsertAction (pos);
- }
-
- void Paste (ActionToolItem item)
- {
- }
-
- public void ShowContextMenu (ActionItem aitem)
- {
- ActionToolItem menuItem = aitem as ActionToolItem;
-
- Gtk.Menu m = new Gtk.Menu ();
- Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("Insert Before"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, false, false);
- };
- item = new Gtk.MenuItem (Catalog.GetString ("Insert After"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, true, false);
- };
- item = new Gtk.MenuItem (Catalog.GetString ("Insert Separator Before"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, false, true);
- };
- item = new Gtk.MenuItem (Catalog.GetString ("Insert Separator After"));
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- InsertActionAt (menuItem, true, true);
- };
-
- m.Add (new Gtk.SeparatorMenuItem ());
-
- item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- menuItem.Cut ();
- };
- item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- menuItem.Copy ();
- };
- item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- Paste (menuItem);
- };
- item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null);
- m.Add (item);
- item.Activated += delegate (object s, EventArgs a) {
- menuItem.Delete ();
- };
- m.ShowAll ();
- m.Popup ();
- }
-
- public object SaveStatus ()
- {
- for (int n=0; n<toolItems.Count; n++)
- if (((ActionToolItem)toolItems[n]).IsSelected)
- return n;
- return null;
- }
-
- public void RestoreStatus (object stat)
- {
- if (stat == null)
- return;
- int n = (int) stat;
- if (n < toolItems.Count)
- ((ActionToolItem)toolItems[n]).Select ();
- }
-
- ActionToolItem LocateWidget (int x, int y)
- {
- foreach (ActionToolItem mi in toolItems) {
- if (mi.Allocation.Contains (x, y))
- return mi;
- }
- return null;
- }
-
- ActionToolItem FindMenuItem (ActionTreeNode node)
- {
- foreach (ActionToolItem mi in toolItems) {
- if (mi.Node == node)
- return mi;
- }
- return null;
- }
- }
-
- class CustomToolbarItem: Gtk.ToolItem
- {
- public override void Dispose ()
- {
- ActionToolItem.Destroy ();
- base.Dispose ();
- }
-
- public ActionToolItem ActionToolItem;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Boolean.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Boolean.cs
deleted file mode 100644
index 26d4a12c55..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Boolean.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- public class Boolean : PropertyEditorCell
- {
- static int indicatorSize;
- static int indicatorSpacing;
-
- static Boolean ()
- {
- Gtk.CheckButton cb = new Gtk.CheckButton ();
- indicatorSize = (int) cb.StyleGetProperty ("indicator-size");
- indicatorSpacing = (int) cb.StyleGetProperty ("indicator-spacing");
- }
-
- public override void GetSize (int availableWidth, out int width, out int height)
- {
- width = 20;
- height = 20;
- }
-
- public override void Render (Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
- {
- Gtk.ShadowType sh = (bool) Value ? Gtk.ShadowType.In : Gtk.ShadowType.Out;
- int s = indicatorSize - 1;
- if (s > bounds.Height)
- s = bounds.Height;
- if (s > bounds.Width)
- s = bounds.Width;
- Gtk.Style.PaintCheck (Container.Style, window, state, sh, bounds, Container, "checkbutton", bounds.X + indicatorSpacing - 1, bounds.Y + (bounds.Height - s)/2, s, s);
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new BooleanEditor ();
- }
- }
-
- [PropertyEditor ("Active", "Toggled")]
- public class BooleanEditor : Gtk.CheckButton, IPropertyEditor
- {
- public void Initialize (PropertyDescriptor descriptor)
- {
- if (descriptor.PropertyType != typeof(bool))
- throw new ApplicationException ("Boolean editor does not support editing values of type " + descriptor.PropertyType);
- }
-
- public void AttachObject (object obj)
- {
- }
-
- public object Value {
- get { return Active; }
- set { Active = (bool) value; }
- }
-
- protected override void OnToggled ()
- {
- base.OnToggled ();
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/CellRendererComboBox.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/CellRendererComboBox.cs
deleted file mode 100644
index 186f446729..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/CellRendererComboBox.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-//
-// CellRendererComboBox.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using Gtk;
-using Gdk;
-
-namespace Stetic.Editor
-{
- public class CellRendererComboBox: CellRendererText
- {
- string[] values;
- string path;
- int rowHeight;
-
- public CellRendererComboBox ()
- {
- Mode |= Gtk.CellRendererMode.Editable;
- Entry dummyEntry = new Gtk.Entry ();
- rowHeight = dummyEntry.SizeRequest ().Height;
- }
-
- public string[] Values {
- get { return values; }
- set { values = value; }
- }
-
- public override void GetSize (Widget widget, ref Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
- {
- base.GetSize (widget, ref cell_area, out x_offset, out y_offset, out width, out height);
- if (height < rowHeight)
- height = rowHeight;
- }
-
- public override CellEditable StartEditing (Gdk.Event ev, Widget widget, string path, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags)
- {
- this.path = path;
-
- Gtk.ComboBox combo = Gtk.ComboBox.NewText ();
- foreach (string s in values)
- combo.AppendText (s);
-
- combo.Active = Array.IndexOf (values, Text);
- combo.Changed += new EventHandler (SelectionChanged);
- return new TreeViewCellContainer (combo);
- }
-
- void SelectionChanged (object s, EventArgs a)
- {
- Gtk.ComboBox combo = (Gtk.ComboBox) s;
- if (Changed != null)
- Changed (this, new ComboSelectionChangedArgs (path, combo.Active, (combo.Active != -1 ? values [combo.Active] : null)));
- }
-
- // Fired when the selection changes
- public event ComboSelectionChangedHandler Changed;
- }
-
- public delegate void ComboSelectionChangedHandler (object sender, ComboSelectionChangedArgs args);
-
- public class ComboSelectionChangedArgs: EventArgs
- {
- string path;
- int active;
- string activeText;
-
- internal ComboSelectionChangedArgs (string path, int active, string activeText)
- {
- this.path = path;
- this.active = active;
- this.activeText = activeText;
- }
-
- public string Path {
- get { return path; }
- }
-
- public int Active {
- get { return active; }
- }
-
- public string ActiveText {
- get { return activeText; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Char.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Char.cs
deleted file mode 100644
index e27b1b7662..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Char.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- public class Char : Gtk.Entry, IPropertyEditor {
-
- public Char ()
- {
- MaxLength = 1;
- }
-
- public void Initialize (PropertyDescriptor descriptor)
- {
- if (descriptor.PropertyType != typeof(char))
- throw new ApplicationException ("Char editor does not support editing values of type " + descriptor.PropertyType);
- }
-
- public void AttachObject (object obj)
- {
- }
-
- char last;
-
- public object Value {
- get {
- if (Text.Length == 0)
- return last;
- else
- return Text[0];
- }
- set {
- Text = value.ToString ();
- last = (char) value;
- }
- }
-
- protected override void OnChanged ()
- {
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Color.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Color.cs
deleted file mode 100644
index b771521aad..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Color.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- public class Color: PropertyEditorCell
- {
- public override void GetSize (int availableWidth, out int width, out int height)
- {
- width = 16;
- height = 16;
- }
-
- public override void Render (Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
- {
- Gdk.GC gc = new Gdk.GC (window);
- gc.RgbFgColor = (Gdk.Color) Value;
- window.DrawRectangle (gc, true, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
- window.DrawRectangle (Container.Style.BlackGC, false, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new ColorEditor ();
- }
- }
-
- [PropertyEditor ("Color", "ColorSet")]
- public class ColorEditor : Gtk.ColorButton, IPropertyEditor
- {
- public void Initialize (PropertyDescriptor descriptor)
- {
- if (descriptor.PropertyType != typeof(Gdk.Color))
- throw new ApplicationException ("Color editor does not support editing values of type " + descriptor.PropertyType);
- }
-
- public void AttachObject (object obj)
- {
- }
-
- public object Value {
- get { return Color; }
- set { Color = (Gdk.Color) value; }
- }
-
- protected override void OnColorSet ()
- {
- base.OnColorSet ();
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/DateTimeEditor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/DateTimeEditor.cs
deleted file mode 100644
index f338b8c54e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/DateTimeEditor.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-
-using System;
-using Gtk;
-using Gdk;
-using System.Text;
-
-namespace Stetic.Editor
-{
- public class DateTimeEditorCell: PropertyEditorCell
- {
- protected override string GetValueText ()
- {
- return ((DateTime)Value).ToLongDateString ();
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new DateTimeEditor ();
- }
- }
-
- public class DateTimeEditor: Gtk.HBox, IPropertyEditor
- {
- Gtk.Entry entry;
- DateTime time;
-
- public DateTimeEditor()
- {
- entry = new Gtk.Entry ();
- entry.Changed += OnChanged;
- PackStart (entry, true, true, 0);
- ShowAll ();
- }
-
- public void Initialize (PropertyDescriptor descriptor)
- {
- }
-
- public void AttachObject (object ob)
- {
- }
-
- public object Value {
- get { return time; }
- set {
- time = (DateTime) value;
- entry.Changed -= OnChanged;
- entry.Text = time.ToString ("G");
- entry.Changed += OnChanged;
- }
- }
-
- void OnChanged (object o, EventArgs a)
- {
- string s = entry.Text;
-
- foreach (string form in formats) {
- try {
- time = DateTime.ParseExact (s, form, null);
- if (ValueChanged != null)
- ValueChanged (this, a);
- break;
- } catch {
- }
- }
- }
-
- public event EventHandler ValueChanged;
-
- static string[] formats = {"u", "G", "g", "d", "T", "t"};
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/EditIconDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/EditIconDialog.cs
deleted file mode 100644
index d5ea4d8678..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/EditIconDialog.cs
+++ /dev/null
@@ -1,284 +0,0 @@
-
-using System;
-using System.Collections;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- public class EditIconDialog: IDisposable
- {
- [Glade.Widget] Gtk.Entry nameEntry;
- [Glade.Widget] Gtk.TreeView sourceList;
- [Glade.Widget] Gtk.RadioButton radioSingle;
- [Glade.Widget] Gtk.RadioButton radioMultiple;
- [Glade.Widget] Gtk.Label imageLabel;
- [Glade.Widget] Gtk.Image imageImage;
- [Glade.Widget] Gtk.Button okButton;
- [Glade.Widget] Gtk.HBox hboxSingle;
- [Glade.Widget] Gtk.HBox hboxMultiple;
- [Glade.Widget ("EditIconDialog")] Gtk.Dialog dialog;
-
- Gtk.ListStore sourceListStore;
-
- ProjectIconSet iconSet;
- IProject project;
-
- ImageInfo singleIcon;
-
- string[] sizes = { Catalog.GetString ("All Sizes"), "Menu", "SmallToolbar", "LargeToolbar", "Button", "Dnd", "Dialog" };
- string[] states = { Catalog.GetString ("All States"), "Normal", "Active", "Prelight", "Selected", "Insensitive" };
- string[] directions = { Catalog.GetString ("All Directions"), "Ltr", "Rtl" };
-
- public EditIconDialog (IProject project, ProjectIconSet iconSet)
- {
- Glade.XML xml = new Glade.XML (null, "stetic.glade", "EditIconDialog", null);
- xml.Autoconnect (this);
- dialog.Response += OnResponse;
-
- this.project = project;
- this.iconSet = iconSet;
-
- nameEntry.Text = iconSet.Name;
-
- if (iconSet.Sources.Count == 0) {
- radioSingle.Active = true;
- imageLabel.Text = "";
- }
- else if (iconSet.Sources.Count == 1 && iconSet.Sources[0].AllWildcarded) {
- radioSingle.Active = true;
- singleIcon = iconSet.Sources[0].Image;
- if (singleIcon != null) {
- imageLabel.Text = singleIcon.Label;
- imageImage.Pixbuf = singleIcon.GetThumbnail (project, 16);
- } else
- imageLabel.Text = "";
- } else {
- radioMultiple.Active = true;
- }
-
- hboxSingle.Sensitive = radioSingle.Active;
- hboxMultiple.Sensitive = !radioSingle.Active;
-
- // Build the tree
-
- sourceListStore = new Gtk.ListStore (typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string), typeof(string), typeof(object));
- sourceList.Model = sourceListStore;
-
- Gtk.TreeViewColumn col = new Gtk.TreeViewColumn ();
-
- Gtk.CellRendererPixbuf pr = new Gtk.CellRendererPixbuf ();
- col.Title = Catalog.GetString ("Image");
- col.PackStart (pr, false);
- col.AddAttribute (pr, "pixbuf", 0);
-
- Gtk.CellRendererText crt = new Gtk.CellRendererText ();
- col.PackStart (crt, true);
- col.AddAttribute (crt, "text", 1);
- sourceList.AppendColumn (col);
-
- col = new Gtk.TreeViewColumn ();
- col.Expand = true;
- col.Title = Catalog.GetString ("Size");
- CellRendererComboBox crtb = new CellRendererComboBox ();
- crtb.Changed += new ComboSelectionChangedHandler (OnSizeComboChanged);
- crtb.Values = sizes;
- col.PackStart (crtb, true);
- col.AddAttribute (crtb, "text", 2);
- sourceList.AppendColumn (col);
-
- col = new Gtk.TreeViewColumn ();
- col.Expand = true;
- col.Title = Catalog.GetString ("State");
- crtb = new CellRendererComboBox ();
- crtb.Changed += new ComboSelectionChangedHandler (OnStateComboChanged);
- crtb.Values = states;
- col.PackStart (crtb, true);
- col.AddAttribute (crtb, "text", 3);
- sourceList.AppendColumn (col);
-
- col = new Gtk.TreeViewColumn ();
- col.Expand = true;
- col.Title = Catalog.GetString ("Direction");
- crtb = new CellRendererComboBox ();
- crtb.Changed += new ComboSelectionChangedHandler (OnDirComboChanged);
- crtb.Values = directions;
- col.PackStart (crtb, true);
- col.AddAttribute (crtb, "text", 4);
- sourceList.AppendColumn (col);
-
- foreach (ProjectIconSource source in iconSet.Sources)
- AddSource (source);
-
- UpdateButtons ();
- }
-
- public Gtk.Window TransientFor {
- set { dialog.TransientFor = value; }
- }
-
- public int Run ()
- {
- return dialog.Run ();
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
-
- void AddSource (ProjectIconSource source)
- {
- string size = source.SizeWildcarded ? sizes[0] : source.Size.ToString ();
- string state = source.StateWildcarded ? states[0] : source.State.ToString ();
- string dir = source.DirectionWildcarded ? directions[0] : source.Direction.ToString ();
- sourceListStore.AppendValues (source.Image.GetThumbnail (project, 16), source.Image.Label, size, state, dir, source.Image);
- }
-
- ProjectIconSource GetSource (Gtk.TreeIter iter)
- {
- ProjectIconSource src = new ProjectIconSource ();
- src.Image = (ImageInfo) sourceListStore.GetValue (iter, 5);
- string s = (string) sourceListStore.GetValue (iter, 2);
- if (s == sizes[0])
- src.SizeWildcarded = true;
- else {
- src.SizeWildcarded = false;
- src.Size = (Gtk.IconSize) Enum.Parse (typeof(Gtk.IconSize), s);
- }
-
- s = (string) sourceListStore.GetValue (iter, 3);
- if (s == states[0])
- src.StateWildcarded = true;
- else {
- src.StateWildcarded = false;
- src.State = (Gtk.StateType) Enum.Parse (typeof(Gtk.StateType), s);
- }
-
- s = (string) sourceListStore.GetValue (iter, 4);
- if (s == directions[0])
- src.DirectionWildcarded = true;
- else {
- src.DirectionWildcarded = false;
- src.Direction = (Gtk.TextDirection) Enum.Parse (typeof(Gtk.TextDirection), s);
- }
-
- return src;
- }
-
- void Save ()
- {
- iconSet.Name = nameEntry.Text;
- iconSet.Sources.Clear ();
-
- if (radioSingle.Active) {
- ProjectIconSource src = new ProjectIconSource ();
- src.AllWildcarded = true;
- src.Image = singleIcon;
- iconSet.Sources.Add (src);
- } else {
- Gtk.TreeIter iter;
- if (sourceListStore.GetIterFirst (out iter)) {
- do {
- iconSet.Sources.Add (GetSource (iter));
- }
- while (sourceListStore.IterNext (ref iter));
- }
- }
- }
-
- void OnResponse (object o, Gtk.ResponseArgs args)
- {
- if (args.ResponseId == Gtk.ResponseType.Ok)
- Save ();
- }
-
- protected void OnSelectImage (object s, EventArgs args)
- {
- using (SelectImageDialog dlg = new SelectImageDialog (dialog, project)) {
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
- singleIcon = dlg.Icon;
- imageLabel.Text = singleIcon.Label;
- imageImage.Pixbuf = singleIcon.GetThumbnail (project, 16);
- UpdateButtons ();
- }
- }
- }
-
- protected void OnAddSource (object s, EventArgs args)
- {
- using (SelectImageDialog dlg = new SelectImageDialog (dialog, project)) {
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
- ProjectIconSource src = new ProjectIconSource ();
- src.Image = dlg.Icon;
- src.AllWildcarded = true;
- AddSource (src);
- UpdateButtons ();
- }
- }
- }
-
- protected void OnRemoveSource (object s, EventArgs args)
- {
- Gtk.TreeIter iter;
- Gtk.TreeModel model;
- if (sourceList.Selection.GetSelected (out model, out iter)) {
- sourceListStore.Remove (ref iter);
- UpdateButtons ();
- }
- }
-
- protected void OnSingleClicked (object s, EventArgs args)
- {
- hboxSingle.Sensitive = true;
- hboxMultiple.Sensitive = false;
- UpdateButtons ();
- }
-
- protected void OnMultipleClicked (object s, EventArgs args)
- {
- hboxSingle.Sensitive = false;
- hboxMultiple.Sensitive = true;
- UpdateButtons ();
- }
-
- protected void OnNameChanged (object s, EventArgs args)
- {
- UpdateButtons ();
- }
-
- void OnSizeComboChanged (object s, ComboSelectionChangedArgs args)
- {
- UpdateComboValue (args.Path, 2, args.ActiveText);
- }
-
- void OnStateComboChanged (object s, ComboSelectionChangedArgs args)
- {
- UpdateComboValue (args.Path, 3, args.ActiveText);
- }
-
- void OnDirComboChanged (object s, ComboSelectionChangedArgs args)
- {
- UpdateComboValue (args.Path, 4, args.ActiveText);
- }
-
- void UpdateComboValue (string path, int col, string activeText)
- {
- Gtk.TreeIter iter;
- if (sourceListStore.GetIter (out iter, new Gtk.TreePath (path))) {
- sourceListStore.SetValue (iter, col, activeText);
- }
- }
-
- void UpdateButtons ()
- {
- if (nameEntry.Text.Length == 0) {
- okButton.Sensitive = false;
- } else if (radioSingle.Active) {
- okButton.Sensitive = singleIcon != null;
- } else {
- Gtk.TreeIter iter;
- okButton.Sensitive = sourceListStore != null && sourceListStore.GetIterFirst (out iter);
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/EditIconFactoryDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/EditIconFactoryDialog.cs
deleted file mode 100644
index ee4f5c29ec..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/EditIconFactoryDialog.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-
-using System;
-using System.Collections;
-using System.IO;
-using Gtk;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- public class EditIconFactoryDialog: IDisposable
- {
- [Glade.Widget] Gtk.ScrolledWindow iconListScrolledwindow;
- [Glade.Widget ("EditIconFactoryDialog")] Gtk.Dialog dialog;
-
- ProjectIconList customIconList;
-
- Gtk.Window parent;
- Stetic.IProject project;
- ProjectIconFactory iconFactory;
-
- public EditIconFactoryDialog (Gtk.Window parent, Stetic.IProject project, ProjectIconFactory iconFactory)
- {
- this.iconFactory = iconFactory;
- this.parent = parent;
- this.project = project;
-
- Glade.XML xml = new Glade.XML (null, "stetic.glade", "EditIconFactoryDialog", null);
- xml.Autoconnect (this);
-
- customIconList = new ProjectIconList (project, iconFactory);
- iconListScrolledwindow.AddWithViewport (customIconList);
- }
-
- public int Run ()
- {
- dialog.ShowAll ();
- dialog.TransientFor = parent;
- return dialog.Run ();
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
-
- protected void OnAddIcon (object ob, EventArgs args)
- {
- ProjectIconSet icon = new ProjectIconSet ();
- using (EditIconDialog dlg = new EditIconDialog (project, icon)) {
- if (parent != null)
- dlg.TransientFor = parent.Toplevel as Gtk.Window;
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
- iconFactory.Icons.Add (icon);
- customIconList.Refresh ();
- customIconList.Selection = icon.Name;
-// project.Modified = true;
- }
- }
- }
-
- protected void OnRemoveIcon (object ob, EventArgs args)
- {
- string name = customIconList.Selection;
- ProjectIconSet icon = iconFactory.GetIcon (name);
- if (icon != null) {
- Gtk.MessageDialog md = new Gtk.MessageDialog (dialog, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, string.Format (Catalog.GetString ("Are you sure you want to delete the icon '{0}'"), icon.Name));
- if (parent != null)
- md.TransientFor = parent.Toplevel as Gtk.Window;
- if (md.Run () == (int) Gtk.ResponseType.Yes) {
- iconFactory.Icons.Remove (icon);
- customIconList.Refresh ();
-// project.Modified = true;
- }
- md.Destroy ();
- }
- }
-
- protected void OnEditIcon (object ob, EventArgs args)
- {
- string name = customIconList.Selection;
- ProjectIconSet icon = iconFactory.GetIcon (name);
- if (icon != null) {
- using (EditIconDialog dlg = new EditIconDialog (project, icon)) {
- if (parent != null)
- dlg.TransientFor = parent.Toplevel as Gtk.Window;
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
- customIconList.Refresh ();
- customIconList.Selection = icon.Name;
-// project.Modified = true;
- }
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Enumeration.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Enumeration.cs
deleted file mode 100644
index fd2237d02a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Enumeration.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Stetic.Editor {
-
- public class Enumeration: PropertyEditorCell
- {
- protected override string GetValueText ()
- {
- if (Value == null)
- return "";
-
- EnumDescriptor enm = Registry.LookupEnum (Property.PropertyType.FullName);
- EnumValue ev = enm [(Enum)Value];
- if (ev != null)
- return ev.Label;
- else
- return "";
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new EnumerationEditor ();
- }
- }
-
- public class EnumerationEditor : Gtk.HBox, IPropertyEditor {
-
- Gtk.EventBox ebox;
- Gtk.ComboBoxEntry combo;
- EnumDescriptor enm;
-
- public EnumerationEditor () : base (false, 0)
- {
- }
-
- public void Initialize (PropertyDescriptor prop)
- {
- if (!prop.PropertyType.IsEnum)
- throw new ApplicationException ("Enumeration editor does not support editing values of type " + prop.PropertyType);
-
- ebox = new Gtk.EventBox ();
- ebox.Show ();
- PackStart (ebox, true, true, 0);
-
- combo = Gtk.ComboBoxEntry.NewText ();
- combo.Changed += combo_Changed;
- combo.Entry.IsEditable = false;
- combo.Entry.HasFrame = false;
- combo.Entry.HeightRequest = combo.SizeRequest ().Height; // The combo does not set the entry to the correct size when it does not have a frame
- combo.Show ();
- ebox.Add (combo);
-
- enm = Registry.LookupEnum (prop.PropertyType.FullName);
- foreach (Enum value in enm.Values)
- combo.AppendText (enm[value].Label);
- }
-
- public void AttachObject (object obj)
- {
- }
-
- public object Value {
- get {
- return enm.Values[combo.Active];
- }
- set {
- int i = Array.IndexOf (enm.Values, (Enum)value);
- if (i != -1)
- combo.Active = i;
- }
- }
-
- public event EventHandler ValueChanged;
-
- void combo_Changed (object o, EventArgs args)
- {
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- EnumValue value = enm[(Enum)Value];
- if (value != null)
- ebox.TooltipText = value.Description;
- else
- ebox.TooltipText = string.Empty;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Flags.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Flags.cs
deleted file mode 100644
index 031d7a1319..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Flags.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-using Gtk;
-using System;
-using System.Collections;
-
-namespace Stetic.Editor {
-
- public class Flags: PropertyEditorCell
- {
- protected override string GetValueText ()
- {
- if (Value == null)
- return "";
-
- uint value = (uint)(int)Value;
- EnumDescriptor enm = Registry.LookupEnum (Property.PropertyType.FullName);
- string txt = "";
- foreach (Enum val in enm.Values) {
- EnumValue eval = enm[val];
- if (eval.Label == "")
- continue;
-
- if ((value & (uint) Convert.ToInt32 (eval.Value)) != 0) {
- if (txt.Length > 0) txt += ", ";
- txt += eval.Label;
- }
- }
- return txt;
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new FlagsEditor ();
- }
- }
-
- public class FlagsEditor : Gtk.HBox, IPropertyEditor {
-
- EnumDescriptor enm;
- Hashtable flags;
- Gtk.Entry flagsLabel;
- string property;
-
- public FlagsEditor ()
- {
- }
-
- public void Initialize (PropertyDescriptor prop)
- {
- if (!prop.PropertyType.IsEnum)
- throw new ApplicationException ("Flags editor does not support editing values of type " + prop.PropertyType);
-
- property = prop.Label;
- Spacing = 3;
-
- // For small enums, the editor is a list of checkboxes inside a frame
- // For large enums (>5), use a selector dialog.
-
- enm = Registry.LookupEnum (prop.PropertyType.FullName);
-
- if (enm.Values.Length < 6)
- {
- Gtk.VBox vbox = new Gtk.VBox (true, 3);
-
- flags = new Hashtable ();
-
- foreach (Enum value in enm.Values) {
- EnumValue eval = enm[value];
- if (eval.Label == "")
- continue;
-
- Gtk.CheckButton check = new Gtk.CheckButton (eval.Label);
- check.TooltipText = eval.Description;
- uint uintVal = (uint) Convert.ToInt32 (eval.Value);
- flags[check] = uintVal;
- flags[uintVal] = check;
-
- check.Toggled += FlagToggled;
- vbox.PackStart (check, false, false, 0);
- }
-
- Gtk.Frame frame = new Gtk.Frame ();
- frame.Add (vbox);
- frame.ShowAll ();
- PackStart (frame, true, true, 0);
- }
- else
- {
- flagsLabel = new Gtk.Entry ();
- flagsLabel.IsEditable = false;
- flagsLabel.HasFrame = false;
- flagsLabel.ShowAll ();
- PackStart (flagsLabel, true, true, 0);
-
- Gtk.Button but = new Gtk.Button ("...");
- but.Clicked += OnSelectFlags;
- but.ShowAll ();
- PackStart (but, false, false, 0);
- }
- }
-
- public void AttachObject (object ob)
- {
- }
-
- public object Value {
- get {
- return Enum.ToObject (enm.EnumType, UIntValue);
- }
- set {
- uint newVal = (uint)(int)value;
- if (flagsLabel != null) {
- string txt = "";
- foreach (Enum val in enm.Values) {
- EnumValue eval = enm[val];
- if (eval.Label == "")
- continue;
-
- if ((newVal & (uint) Convert.ToInt32 (eval.Value)) != 0) {
- if (txt.Length > 0) txt += ", ";
- txt += eval.Label;
- }
- }
- flagsLabel.Text = txt;
- UIntValue = newVal;
- }
- else {
- for (uint i = 1; i <= uintValue || i <= newVal; i = i << 1) {
- if ((uintValue & i) != (newVal & i)) {
- Gtk.CheckButton check = (Gtk.CheckButton)flags[i];
- if (check != null)
- check.Active = !check.Active;
- }
- }
- }
- }
- }
-
- public event EventHandler ValueChanged;
-
- uint uintValue;
- uint UIntValue {
- get {
- return uintValue;
- }
- set {
- if (uintValue != value) {
- uintValue = value;
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
- }
- }
-
- void FlagToggled (object o, EventArgs args)
- {
- Gtk.CheckButton check = (Gtk.CheckButton)o;
- uint val = (uint)flags[o];
-
- if (check.Active)
- UIntValue |= val;
- else
- UIntValue &= ~val;
- }
-
- void OnSelectFlags (object o, EventArgs args)
- {
- using (FlagsSelectorDialog dialog = new FlagsSelectorDialog (null, enm, UIntValue, property)) {
- if (dialog.Run () == (int) ResponseType.Ok) {
- Value = Enum.ToObject (enm.EnumType, dialog.Value);
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/FlagsSelectorDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/FlagsSelectorDialog.cs
deleted file mode 100644
index f2d8ca75e7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/FlagsSelectorDialog.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-
-using System;
-
-namespace Stetic.Editor
-{
- public class FlagsSelectorDialog: IDisposable
- {
- [Glade.Widget] Gtk.TreeView treeView;
- [Glade.Widget ("FlagsSelectorDialog")] Gtk.Dialog dialog;
- Gtk.ListStore store;
- Gtk.Window parent;
- uint flags;
-
- public FlagsSelectorDialog (Gtk.Window parent, EnumDescriptor enumDesc, uint flags, string title)
- {
- this.flags = flags;
- this.parent = parent;
-
- Glade.XML xml = new Glade.XML (null, "stetic.glade", "FlagsSelectorDialog", null);
- xml.Autoconnect (this);
-
- store = new Gtk.ListStore (typeof(bool), typeof(string), typeof(uint));
- treeView.Model = store;
-
- Gtk.TreeViewColumn col = new Gtk.TreeViewColumn ();
-
- Gtk.CellRendererToggle tog = new Gtk.CellRendererToggle ();
- tog.Toggled += new Gtk.ToggledHandler (OnToggled);
- col.PackStart (tog, false);
- col.AddAttribute (tog, "active", 0);
-
- Gtk.CellRendererText crt = new Gtk.CellRendererText ();
- col.PackStart (crt, true);
- col.AddAttribute (crt, "text", 1);
-
- treeView.AppendColumn (col);
-
- foreach (Enum value in enumDesc.Values) {
- EnumValue eval = enumDesc[value];
- if (eval.Label == "")
- continue;
- uint val = (uint) Convert.ToInt32 (eval.Value);
- store.AppendValues (((flags & val) != 0), eval.Label, val);
- }
- }
-
- public int Run ()
- {
- dialog.ShowAll ();
- dialog.TransientFor = parent;
- return dialog.Run ();
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
-
- void OnToggled (object s, Gtk.ToggledArgs args)
- {
- Gtk.TreeIter iter;
- if (!store.GetIterFromString (out iter, args.Path))
- return;
-
- bool oldValue = (bool) store.GetValue (iter, 0);
- uint flag = (uint) store.GetValue (iter, 2);
- store.SetValue (iter, 0, !oldValue);
-
- if (oldValue)
- flags &= ~flag;
- else
- flags |= flag;
- }
-
- public uint Value {
- get { return flags; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/FloatRange.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/FloatRange.cs
deleted file mode 100644
index 2b8894dbf3..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/FloatRange.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- public class FloatRange : Gtk.SpinButton, IPropertyEditor
- {
- Type propType;
-
- public FloatRange (): base (0, 0, 0.01)
- {
- }
-
- public void Initialize (PropertyDescriptor prop)
- {
- propType = prop.PropertyType;
-
- double min, max;
-
- if (propType == typeof(double)) {
- min = Double.MinValue;
- max = Double.MaxValue;
- } else if (propType == typeof(float)) {
- min = float.MinValue;
- max = float.MaxValue;
- } else
- throw new ApplicationException ("FloatRange editor does not support editing values of type " + propType);
-
- if (prop.Minimum != null)
- min = (double) Convert.ChangeType (prop.Minimum, typeof(double));
- if (prop.Maximum != null)
- max = (double) Convert.ChangeType (prop.Maximum, typeof(double));
-
- SetRange (min, max);
-
- Digits = 2;
- }
-
- public void AttachObject (object ob)
- {
- }
-
- object IPropertyEditor.Value {
- get { return Convert.ChangeType (base.Value, propType); }
- set { base.Value = (double) Convert.ChangeType (value, typeof(double)); }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/GroupPicker.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/GroupPicker.cs
deleted file mode 100644
index fd9d4b24cc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/GroupPicker.cs
+++ /dev/null
@@ -1,175 +0,0 @@
-using Gtk;
-using Gdk;
-using GLib;
-using System;
-using System.Collections;
-using System.Reflection;
-using Mono.Unix;
-
-namespace Stetic.Editor {
-
- [PropertyEditor ("Group", "Changed")]
- class GroupPicker : Gtk.HBox, IPropertyEditor {
-
- Gtk.ComboBox combo;
- IRadioGroupManager manager;
- ArrayList values;
- string group;
-
- const BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
-
- public GroupPicker () : base (false, 0)
- {
- }
-
- public void Initialize (PropertyDescriptor prop)
- {
- }
-
- public void AttachObject (object ob)
- {
- ob = ObjectWrapper.Lookup (ob);
-
- IRadioGroupManagerProvider provider = ob as IRadioGroupManagerProvider;
-
- if (provider == null)
- throw new ArgumentException ("The class " + ob.GetType() + " does not implement IRadioGroupManagerProvider");
-
- manager = provider.GetGroupManager ();
- manager.GroupsChanged += GroupsChanged;
- GroupsChanged ();
- }
-
- public override void Dispose ()
- {
- manager.GroupsChanged -= GroupsChanged;
- base.Dispose ();
- }
-
- void GroupsChanged ()
- {
- if (combo != null) {
- combo.Changed -= combo_Changed;
- Remove (combo);
- }
-
- combo = Gtk.ComboBox.NewText ();
- combo.Changed += combo_Changed;
-#if GTK_SHARP_2_6
- combo.RowSeparatorFunc = RowSeparatorFunc;
-#endif
- combo.Show ();
- PackStart (combo, true, true, 0);
-
- values = new ArrayList ();
- int i = 0;
- foreach (string name in manager.GroupNames) {
- values.Add (name);
- combo.AppendText (name);
- if (name == group)
- combo.Active = i;
- i++;
- }
-
-#if GTK_SHARP_2_6
- combo.AppendText ("");
-#endif
-
- combo.AppendText (Catalog.GetString ("Rename Group..."));
- combo.AppendText (Catalog.GetString ("New Group..."));
- }
-
-#if GTK_SHARP_2_6
- bool RowSeparatorFunc (Gtk.TreeModel model, Gtk.TreeIter iter)
- {
- GLib.Value val = new GLib.Value ();
- model.GetValue (iter, 0, ref val);
- bool sep = ((string)val) == "";
- val.Dispose ();
- return sep;
- }
-#endif
-
- public object Value {
- get {
- return group;
- }
- set {
- int index = values.IndexOf ((string) value);
- if (index != -1) {
- combo.Active = index;
- group = values[index] as string;
- }
- }
- }
-
- public event EventHandler ValueChanged;
-
- void combo_Changed (object o, EventArgs args)
- {
- if (combo.Active >= values.Count) {
- doDialog ();
- return;
- }
-
- group = values[combo.Active] as string;
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- void doDialog ()
- {
-#if GTK_SHARP_2_6
- bool rename = combo.Active == values.Count + 1;
-#else
- bool rename = combo.Active == values.Count;
-#endif
- Gtk.Dialog dialog = new Gtk.Dialog (
- rename ? Catalog.GetString ("Rename Group") : Catalog.GetString ("New Group"),
- combo.Toplevel as Gtk.Window,
- Gtk.DialogFlags.Modal | Gtk.DialogFlags.NoSeparator,
- Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
- Gtk.Stock.Ok, Gtk.ResponseType.Ok);
- dialog.DefaultResponse = Gtk.ResponseType.Ok;
- dialog.HasSeparator = false;
- dialog.BorderWidth = 12;
- dialog.VBox.Spacing = 18;
- dialog.VBox.BorderWidth = 0;
-
- Gtk.HBox hbox = new Gtk.HBox (false, 12);
- Gtk.Label label = new Gtk.Label (rename ? Catalog.GetString ("_New name:") : Catalog.GetString ("_Name:"));
- Gtk.Entry entry = new Gtk.Entry ();
- label.MnemonicWidget = entry;
- hbox.PackStart (label, false, false, 0);
- entry.ActivatesDefault = true;
- if (rename)
- entry.Text = group;
- hbox.PackStart (entry, true, true, 0);
- dialog.VBox.PackStart (hbox, false, false, 0);
-
- dialog.ShowAll ();
- // Have to set this *after* ShowAll
- dialog.ActionArea.BorderWidth = 0;
- dialog.TransientFor = this.Toplevel as Gtk.Window;
- Gtk.ResponseType response = (Gtk.ResponseType)dialog.Run ();
- if (response == Gtk.ResponseType.Cancel || entry.Text.Length == 0) {
- dialog.Destroy ();
- Value = group; // reset combo.Active
- return;
- }
-
- string oldname = group;
- group = entry.Text;
- dialog.Destroy ();
-
- // FIXME: check that the new name doesn't already exist
-
- // This will trigger a GroupsChanged, which will eventually
- // update combo.Active
- if (rename)
- manager.Rename (oldname, group);
- else
- manager.Add (group);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconList.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconList.cs
deleted file mode 100644
index 0803726b23..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconList.cs
+++ /dev/null
@@ -1,205 +0,0 @@
-
-using System;
-using System.Collections;
-using Gtk;
-
-namespace Stetic.Editor
-{
- // This is the internal class the represents the actual two-column
- // icon list. This can't just be handled as an HBox inside the main
- // window, because we need to override SetScrollAdjustments.
- class IconList : Gtk.HBox
- {
- ThemedIconColumn left, right;
- ArrayList IconNames = new ArrayList ();
-
- public event EventHandler Activated;
-
- protected IconList ()
- {
- left = new ThemedIconColumn ();
- PackStart (left);
- right = new ThemedIconColumn ();
- PackStart (right);
-
- left.Selection.Changed += LeftSelectionChanged;
- right.Selection.Changed += RightSelectionChanged;
- left.RowActivated += RowActivated;
- right.RowActivated += RowActivated;
- left.KeyPressEvent += ColumnKeyPressEvent;
- right.KeyPressEvent += ColumnKeyPressEvent;
- }
-
- protected void AddIcon (string name, Gdk.Pixbuf pixbuf, string label)
- {
- int i = IconNames.Count;
- IconNames.Add (name);
-
- if (i % 2 == 0)
- left.Append (pixbuf, name);
- else
- right.Append (pixbuf, name);
- }
-
- protected void Clear ()
- {
- IconNames.Clear ();
- left.Clear ();
- right.Clear ();
- }
-
- void RowActivated (object obj, RowActivatedArgs args)
- {
- if (Activated != null)
- Activated (this, EventArgs.Empty);
- }
-
- public int SelectionIndex {
- get {
- Gtk.TreePath[] selection;
- selection = left.Selection.GetSelectedRows ();
- if (selection.Length > 0)
- return selection[0].Indices[0] * 2;
- selection = right.Selection.GetSelectedRows ();
- if (selection.Length > 0)
- return selection[0].Indices[0] * 2 + 1;
- return -1;
- }
- set {
- if (value != -1) {
- if (value % 2 == 0)
- left.SelectRow (value / 2);
- else
- right.SelectRow (value / 2);
- } else {
- left.Selection.UnselectAll ();
- right.Selection.UnselectAll ();
- }
- }
- }
-
- public string Selection {
- get {
- int i = SelectionIndex;
- if (i != -1)
- return (string) IconNames [i];
- else
- return null;
- }
- set {
- if (value != null)
- SelectionIndex = IconNames.IndexOf (value);
- else
- SelectionIndex = -1;
- }
- }
-
- public event EventHandler SelectionChanged;
-
- public void Find (string text)
- {
- int selection = SelectionIndex;
- for (int i = (selection + 1) % IconNames.Count; i != selection; i = (i + 1) % IconNames.Count) {
- if (((string)IconNames[i]).IndexOf (text) != -1) {
- SelectionIndex = i;
- return;
- }
- }
- SelectionIndex = -1;
- }
-
- void LeftSelectionChanged (object obj, EventArgs args)
- {
- if (left.Selection.GetSelectedRows().Length != 0)
- right.Selection.UnselectAll ();
- if (SelectionChanged != null)
- SelectionChanged (this, EventArgs.Empty);
- }
-
- void RightSelectionChanged (object obj, EventArgs args)
- {
- if (right.Selection.GetSelectedRows().Length != 0)
- left.Selection.UnselectAll ();
- if (SelectionChanged != null)
- SelectionChanged (this, EventArgs.Empty);
- }
-
- [GLib.ConnectBefore]
- void ColumnKeyPressEvent (object obj, KeyPressEventArgs args)
- {
- if (args.Event.Key == Gdk.Key.Right) {
- if (obj == (object)left) {
- SelectionIndex++;
- right.GrabFocus ();
- }
- args.RetVal = true;
- } else if (args.Event.Key == Gdk.Key.Left) {
- if (obj == (object)right) {
- SelectionIndex--;
- left.GrabFocus ();
- }
- args.RetVal = true;
- }
- }
-
- protected override void OnSetScrollAdjustments (Gtk.Adjustment hadj, Gtk.Adjustment vadj)
- {
- left.SetScrollAdjustments (null, vadj);
- right.SetScrollAdjustments (null, vadj);
- }
- }
-
- // Another internal class. This is a single column of the ThemedIconList
- class ThemedIconColumn : Gtk.TreeView
- {
- public ThemedIconColumn ()
- {
- Model = store = new Gtk.ListStore (typeof (Gdk.Pixbuf),
- typeof (string));
- HeadersVisible = false;
- EnableSearch = false;
-
- TreeViewColumn col;
- CellRenderer renderer;
-
- col = new TreeViewColumn ();
- renderer = new CellRendererPixbuf ();
- col.PackStart (renderer, false);
- col.AddAttribute (renderer, "pixbuf", 0);
- renderer = new CellRendererText ();
- col.PackStart (renderer, false);
- col.AddAttribute (renderer, "text", 1);
- AppendColumn (col);
- }
-
- Gtk.ListStore store;
-
- public void Append (Gdk.Pixbuf pixbuf, string name)
- {
- if (name.Length > 30)
- name = name.Substring (0, 30) + "...";
- store.AppendValues (pixbuf, name);
- }
-
- public void SelectRow (int row)
- {
- Gtk.TreeIter iter;
- if (store.IterNthChild (out iter, row)) {
- Gtk.TreePath path = store.GetPath (iter);
-
- SetCursor (path, null, false);
-
- // We want the initial selection to be centered
- if (!IsRealized)
- ScrollToCell (path, null, true, 0.5f, 0.0f);
- }
- }
-
- public void Clear ()
- {
- store.Clear ();
- }
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorItem.cs
deleted file mode 100644
index 9c5980ce04..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorItem.cs
+++ /dev/null
@@ -1,285 +0,0 @@
-
-using System;
-using System.Reflection;
-using System.Collections;
-
-namespace Stetic.Editor
-{
- public class IconSelectorItem: Gtk.EventBox
- {
- ArrayList icons = new ArrayList ();
- ArrayList labels = new ArrayList ();
- ArrayList names = new ArrayList ();
- int columns = 12;
- int iconSize = 16;
- int spacing = 3;
- int selIndex = -1;
- int sectionGap = 10;
- int lastSel = -1;
- int xmax;
- int ymax;
- string title;
- Gtk.Window tipWindow;
- bool inited;
-
- public IconSelectorItem (IntPtr ptr): base (ptr)
- {
- }
-
- public IconSelectorItem (string title)
- {
- this.title = title;
-
- int w, h;
- Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out w, out h);
- iconSize = w;
-
- this.Events |= Gdk.EventMask.PointerMotionMask;
- }
-
- protected override void OnSizeRequested (ref Gtk.Requisition req)
- {
- if (!inited) {
- CreateIcons ();
- inited = true;
- }
-
- base.OnSizeRequested (ref req);
- CalcSize ();
-
- Gtk.Requisition nr = new Gtk.Requisition ();
- nr.Width = xmax;
- nr.Height = ymax;
- req = nr;
- }
-
- protected virtual void CreateIcons ()
- {
- }
-
- public int SelectedIndex {
- get { return selIndex; }
- }
-
- public string SelectedIcon {
- get {
- if (selIndex != -1)
- return (string) names [selIndex];
- else
- return null;
- }
- }
-
- protected void AddIcon (string name, Gdk.Pixbuf pix, string label)
- {
- icons.Add (pix);
- labels.Add (label);
- names.Add (name);
- }
-
- protected void AddSeparator (string separator)
- {
- icons.Add (null);
- labels.Add (null);
- names.Add (separator);
- }
-
- protected override bool OnMotionNotifyEvent (Gdk.EventMotion ev)
- {
- ProcessMotionEvent ((int) ev.X, (int) ev.Y);
- return true;
- }
-
- internal void ProcessMotionEvent (int x, int y)
- {
- int ix, iy;
- GetIconIndex (x, y, out selIndex, out ix, out iy);
- if (selIndex != -1) {
- string name = labels [selIndex] as string;
- if (name == null || name.Length == 0)
- name = names [selIndex] as string;
- if (selIndex != lastSel) {
- HideTip ();
- ShowTip (ix, iy + iconSize + spacing*2, name);
- }
- } else
- HideTip ();
-
- lastSel = selIndex;
-
- QueueDraw ();
- }
-
- void ShowTip (int x, int y, string text)
- {
- if (GdkWindow == null)
- return;
- if (tipWindow == null) {
- tipWindow = new TipWindow ();
- Gtk.Label lab = new Gtk.Label (text);
- lab.Xalign = 0;
- lab.Xpad = 3;
- lab.Ypad = 3;
- tipWindow.Add (lab);
- }
- ((Gtk.Label)tipWindow.Child).Text = text;
- int w = tipWindow.Child.SizeRequest().Width;
- int ox, oy;
- GdkWindow.GetOrigin (out ox, out oy);
- tipWindow.Move (ox + x - (w/2) + (iconSize/2), oy + y);
- tipWindow.ShowAll ();
- }
-
- void HideTip ()
- {
- if (tipWindow != null) {
- tipWindow.Destroy ();
- tipWindow = null;
- }
- }
-
- public override void Dispose ()
- {
- HideTip ();
- base.Dispose ();
- }
-
- protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing ev)
- {
- HideTip ();
- return base.OnLeaveNotifyEvent (ev);
- }
-
- internal void ProcessLeaveNotifyEvent (Gdk.EventCrossing ev)
- {
- HideTip ();
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose ev)
- {
- Draw ();
- return true;
- }
-
- void Draw ()
- {
- int a,b;
- Expose (true, -1, -1, out a, out b);
- }
-
- void CalcSize ()
- {
- int a,b;
- Expose (false, -1, -1, out a, out b);
- }
-
- void GetIconIndex (int x, int y, out int index, out int ix, out int iy)
- {
- index = Expose (false, x, y, out ix, out iy);
- }
-
- int Expose (bool draw, int testx, int testy, out int ix, out int iy)
- {
- int x = spacing;
- int y = spacing;
- int sx = spacing;
- int maxx = columns * (iconSize + spacing) + spacing;
- bool calcSize = (testx == -1);
-
- Pango.Layout layout = new Pango.Layout (this.PangoContext);
- Pango.FontDescription des = this.Style.FontDescription.Copy();
- des.Size = 10 * (int) Pango.Scale.PangoScale;
- layout.FontDescription = des;
- layout.SetMarkup (title);
- layout.Width = -1;
- int w, h;
- int tborder = 1;
- layout.GetPixelSize (out w, out h);
- if (draw) {
- GdkWindow.DrawRectangle (this.Style.DarkGC (Gtk.StateType.Normal), true, x, y, Allocation.Width + tborder*2, h + tborder*2);
- GdkWindow.DrawLayout (this.Style.ForegroundGC (Gtk.StateType.Normal), x + tborder + 2, y + tborder, layout);
- }
-
- if (calcSize)
- xmax = 0;
-
- y += h + spacing*2 + tborder*2;
-
- for (int n=0; n<icons.Count; n++) {
- string cmd = names [n] as string;
- Gdk.Pixbuf pix = icons [n] as Gdk.Pixbuf;
-
- if (cmd == "-") {
- if (x > sx) {
- y += iconSize + spacing;
- }
- x = sx;
- y -= spacing;
- if (draw) {
- Gdk.Rectangle rect = new Gdk.Rectangle (0, y+(sectionGap/2), Allocation.Width - x, 1);
- Gtk.Style.PaintHline (this.Style, this.GdkWindow, Gtk.StateType.Normal, rect, this, "", rect.X, rect.Right, rect.Y);
- }
- y += sectionGap;
- continue;
- }
-
- if (cmd == "|") {
- if (x == sx)
- continue;
- x += spacing;
- if (draw) {
- Gdk.Rectangle rect = new Gdk.Rectangle (x, y, 1, iconSize);
- Gtk.Style.PaintVline (this.Style, this.GdkWindow, Gtk.StateType.Normal, rect, this, "", rect.Y, rect.Bottom, rect.X);
- }
- x += spacing*2;
- continue;
- }
-
- if (testx != -1 && testx >= (x - spacing/2) && testx < (x + iconSize + spacing) && testy >= (y - spacing/2) && testy < (y + iconSize + spacing)) {
- ix = x;
- iy = y;
- return n;
- }
-
- if (draw) {
- Gtk.StateType state = (n == selIndex) ? Gtk.StateType.Selected : Gtk.StateType.Normal;
- if (n == selIndex)
- GdkWindow.DrawRectangle (this.Style.BackgroundGC (state), true, x-spacing, y-spacing, iconSize + spacing*2, iconSize + spacing*2);
- GdkWindow.DrawPixbuf (this.Style.ForegroundGC (state), pix, 0, 0, x, y, pix.Width, pix.Height, Gdk.RgbDither.None, 0, 0);
- }
-
- x += (iconSize + spacing);
- if (calcSize && x > xmax)
- xmax = x;
-
- if (x >= maxx) {
- x = sx;
- y += iconSize + spacing;
- }
- }
- if (calcSize) {
- if (x > sx)
- y += iconSize + spacing;
- ymax = y;
- }
-
- ix = iy = 0;
- return -1;
- }
- }
-
- class TipWindow: Gtk.Window
- {
- public TipWindow (): base (Gtk.WindowType.Popup)
- {
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose ev)
- {
- base.OnExposeEvent (ev);
- Gtk.Requisition req = SizeRequest ();
- Gtk.Style.PaintFlatBox (this.Style, this.GdkWindow, Gtk.StateType.Normal, Gtk.ShadowType.Out, Gdk.Rectangle.Zero, this, "tooltip", 0, 0, req.Width, req.Height);
- return true;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorMenu.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorMenu.cs
deleted file mode 100644
index ab6af38d28..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorMenu.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-
-using System;
-using System.Reflection;
-using System.Collections;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- public class IconSelectorMenu: Gtk.Menu
- {
- IProject project;
-
- public event IconEventHandler IconSelected;
-
- public IconSelectorMenu (IProject project)
- {
- this.project = project;
-
- // Stock icon selector
- IconSelectorMenuItem selStock = new IconSelectorMenuItem (new StockIconSelectorItem ());
- selStock.IconSelected += OnStockSelected;
- Insert (selStock, -1);
-
- // Project icon selector
- if (project != null && project.IconFactory.Icons.Count > 0) {
- IconSelectorMenuItem selProject = new IconSelectorMenuItem (new ProjectIconSelectorItem (project));
- selProject.IconSelected += OnStockSelected;
- Insert (selProject, -1);
- }
-
- Insert (new Gtk.SeparatorMenuItem (), -1);
-
- Gtk.MenuItem it = new Gtk.MenuItem (Catalog.GetString ("More..."));
- it.Activated += OnSetStockActionType;
- Insert (it, -1);
- }
-
- void OnStockSelected (object s, IconEventArgs args)
- {
- if (IconSelected != null)
- IconSelected (this, args);
- }
-
- void OnSetStockActionType (object ob, EventArgs args)
- {
- Stetic.Editor.SelectIconDialog dialog = new Stetic.Editor.SelectIconDialog (this.Toplevel as Gtk.Window, project);
- using (dialog)
- {
- if (dialog.Run () != (int) Gtk.ResponseType.Ok)
- return;
- if (IconSelected != null)
- IconSelected (this, new IconEventArgs (dialog.Icon));
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorMenuItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorMenuItem.cs
deleted file mode 100644
index 5ac94883eb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IconSelectorMenuItem.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-
-using System;
-
-namespace Stetic.Editor
-{
- public class IconSelectorMenuItem: Gtk.MenuItem
- {
- IconSelectorItem selector;
-
- public event IconEventHandler IconSelected;
-
- public IconSelectorMenuItem (IconSelectorItem item)
- {
- selector = item;
- Add (selector);
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton ev)
- {
- if (IconSelected != null)
- IconSelected (this, new IconEventArgs (selector.SelectedIcon));
- selector.Destroy ();
- return base.OnButtonPressEvent (ev);
- }
-
- protected override bool OnEnterNotifyEvent (Gdk.EventCrossing ev)
- {
- return true;
- }
-
- protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing ev)
- {
- selector.ProcessLeaveNotifyEvent (ev);
- return true;
- }
-
- protected override bool OnMotionNotifyEvent (Gdk.EventMotion ev)
- {
- selector.ProcessMotionEvent ((int)ev.X - selector.Allocation.X + Allocation.X, (int)ev.Y - selector.Allocation.Y + Allocation.Y);
- return true;
- }
- }
-
- public delegate void IconEventHandler (object s, IconEventArgs args);
-
- public class IconEventArgs: EventArgs
- {
- string iconId;
-
- public IconEventArgs (string iconId)
- {
- this.iconId = iconId;
- }
-
- public string IconId {
- get { return iconId; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Identifier.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Identifier.cs
deleted file mode 100644
index 6b7c42101e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Identifier.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-
-using System;
-using System.Text;
-using Gtk;
-using Gdk;
-
-namespace Stetic.Editor
-{
- public class Identifier: Gtk.Entry, IPropertyEditor
- {
- string id;
- int min = -1;
- int max = -1;
-
- public Identifier()
- {
- ShowAll ();
- HasFrame = false;
- }
-
- public void Initialize (PropertyDescriptor descriptor)
- {
- if (descriptor.PropertyType != typeof(string))
- throw new InvalidOperationException ("TextEditor only can edit string properties");
-
- try {
- if (descriptor.Minimum != null)
- min = Convert.ToInt32 (descriptor.Minimum);
- } catch {}
-
- try {
- if (descriptor.Maximum != null)
- max = Convert.ToInt32 (descriptor.Maximum);
- } catch {}
- }
-
- public void AttachObject (object obj)
- {
- }
-
- protected override bool OnFocusOutEvent (Gdk.EventFocus e)
- {
- DoChanged ();
- return base.OnFocusOutEvent (e);
- }
-
- void DoChanged ()
- {
- StringBuilder sb = new StringBuilder ();
- foreach (char c in Text) {
- if (char.IsLetterOrDigit (c) || c == '_')
- sb.Append (c);
- }
-
- string s = sb.ToString ();
- if (min != -1 && s.Length < min)
- return;
- if (max != -1 && s.Length > max)
- return;
-
- if (s == Text) {
- id = Text;
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- } else {
- Text = s;
- }
- }
-
- public object Value {
- get { return id; }
- set { id = Text = (value != null ? (string) value : ""); }
- }
-
- // To be fired when the edited value changes.
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Image.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Image.cs
deleted file mode 100644
index 0dbd5ed7e0..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Image.cs
+++ /dev/null
@@ -1,265 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using Mono.Unix;
-
-namespace Stetic.Editor {
-
- [PropertyEditor ("Value", "Changed")]
- public class Image : Gtk.HBox, IPropertyEditor {
- Gtk.Image image;
- Gtk.ComboBoxEntry combo;
- Gtk.Entry entry;
- Gtk.Button button;
- Gtk.ListStore store;
-
- const int IconColumn = 0;
- const int LabelColumn = 1;
-
- static string[] stockIds, stockLabels;
- static int imgWidth, imgHeight;
-
- static Image ()
- {
- ArrayList tmpIds = new ArrayList ();
-
- // We can't use Gtk.Stock.ListIds, because that returns different
- // values depending on what version of libgtk you have installed...
- foreach (PropertyInfo info in typeof (Gtk.Stock).GetProperties (BindingFlags.Public | BindingFlags.Static)) {
- if (info.CanRead && info.PropertyType == typeof (string))
- tmpIds.Add (info.GetValue (null, null));
- }
- foreach (PropertyInfo info in GnomeStock.Properties) {
- if (info.CanRead && info.PropertyType == typeof (string))
- tmpIds.Add (info.GetValue (null, null));
- }
-
- ArrayList items = new ArrayList (), nonItems = new ArrayList ();
- foreach (string id in tmpIds) {
- Gtk.StockItem item = Gtk.Stock.Lookup (id);
- if (item.StockId == null)
- nonItems.Add (id);
- else {
- item.Label = item.Label.Replace ("_", "");
- items.Add (item);
- }
- }
- items.Sort (new StockItemSorter ());
- nonItems.Sort ();
-
- stockIds = new string[items.Count + nonItems.Count];
- stockLabels = new string[items.Count + nonItems.Count];
- for (int i = 0; i < items.Count; i++) {
- stockIds[i] = ((Gtk.StockItem)items[i]).StockId;
- stockLabels[i] = ((Gtk.StockItem)items[i]).Label;
- }
- for (int i = 0; i < nonItems.Count; i++) {
- stockIds[i + items.Count] = nonItems[i] as string;
- stockLabels[i + items.Count] = nonItems[i] as string;
- }
-
- Gtk.Icon.SizeLookup (Gtk.IconSize.Button, out imgWidth, out imgHeight);
- }
-
- class StockItemSorter : IComparer {
- public int Compare (object itemx, object itemy)
- {
- Gtk.StockItem x = (Gtk.StockItem)itemx;
- Gtk.StockItem y = (Gtk.StockItem)itemy;
-
- return string.Compare (x.Label, y.Label);
- }
- }
-
- public Image () : this (true, true) {}
-
- public Image (bool allowStock, bool allowFile) : base (false, 6)
- {
- image = new Gtk.Image (GnomeStock.Blank, Gtk.IconSize.Button);
- PackStart (image, false, false, 0);
-
- if (allowStock) {
- store = new Gtk.ListStore (typeof (string), typeof (string));
- store.AppendValues (GnomeStock.Blank, Catalog.GetString ("(None)"));
- for (int i = 0; i < stockIds.Length; i++)
- store.AppendValues (stockIds[i], stockLabels[i]);
-
- combo = new Gtk.ComboBoxEntry (store, LabelColumn);
- Gtk.CellRendererPixbuf iconRenderer = new Gtk.CellRendererPixbuf ();
- iconRenderer.StockSize = (uint)Gtk.IconSize.Menu;
- combo.PackStart (iconRenderer, false);
- combo.Reorder (iconRenderer, 0);
- combo.AddAttribute (iconRenderer, "stock-id", IconColumn);
- combo.Changed += combo_Changed;
-
- // Pack the combo non-expandily into a VBox so it doesn't
- // get stretched to the file button's height
- Gtk.VBox vbox = new Gtk.VBox (false, 0);
- vbox.PackStart (combo, true, false, 0);
- PackStart (vbox, true, true, 0);
-
- entry = (Gtk.Entry)combo.Child;
- entry.Changed += entry_Changed;
-
- useStock = true;
- }
-
- if (allowFile) {
- if (!allowStock) {
- entry = new Gtk.Entry ();
- PackStart (entry, true, true, 0);
- entry.Changed += entry_Changed;
- }
-
- button = new Gtk.Button ();
- Gtk.Image icon = new Gtk.Image (Gtk.Stock.Open, Gtk.IconSize.Button);
- button.Add (icon);
- PackStart (button, false, false, 0);
- button.Clicked += button_Clicked;
- }
- ShowAll ();
- }
-
- public void Initialize (PropertyDescriptor prop)
- {
- if (prop.PropertyType != typeof(string))
- throw new ApplicationException ("Image editor does not support editing values of type " + prop.PropertyType);
- }
-
- public void AttachObject (object ob)
- {
- }
-
- public event EventHandler ValueChanged;
-
- bool syncing;
-
- void combo_Changed (object obj, EventArgs args)
- {
- if (syncing)
- return;
-
- useStock = true;
- syncing = true;
- if (combo.Active > 0)
- StockId = stockIds[combo.Active - 1];
- else
- StockId = null;
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- syncing = false;
- }
-
- void entry_Changed (object obj, EventArgs args)
- {
- if (syncing)
- return;
-
- useStock = true;
- syncing = true;
- StockId = entry.Text;
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- syncing = false;
- }
-
- void button_Clicked (object obj, EventArgs args)
- {
- Gtk.FileChooserDialog dialog =
- new Gtk.FileChooserDialog (Catalog.GetString ("Image"), null, Gtk.FileChooserAction.Open,
- Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
- Gtk.Stock.Open, Gtk.ResponseType.Ok);
- dialog.TransientFor = this.Toplevel as Gtk.Window;
- int response = dialog.Run ();
- string file = dialog.Filename;
- dialog.Destroy ();
-
- if (response == (int)Gtk.ResponseType.Ok) {
- syncing = true;
- useStock = false;
- entry.Text = file;
- File = file;
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- syncing = false;
- }
- }
-
- bool useStock;
-
- string stockId;
- public string StockId {
- get {
- return stockId;
- }
- set {
- useStock = true;
- stockId = value;
- file = null;
-
- image.SetFromStock (stockId, Gtk.IconSize.Button);
-
- if (!syncing) {
- int id = Array.IndexOf (stockIds, value);
- if (id != -1) {
- syncing = true;
- combo.Active = id + 1;
- syncing = false;
- }
- }
- }
- }
-
- string file;
- public string File {
- get {
- return file;
- }
- set {
- useStock = false;
- stockId = null;
- file = value;
-
- if (value == null)
- value = "";
-
- try {
- image.Pixbuf = new Gdk.Pixbuf (value, imgWidth, imgHeight);
- } catch {
- image.SetFromStock (GnomeStock.Blank, Gtk.IconSize.Button);
- }
-
- if (!syncing) {
- syncing = true;
- entry.Text = value;
- syncing = false;
- }
- }
- }
-
- public virtual object Value {
- get {
- if (useStock) {
- if (StockId != null)
- return "stock:" + StockId;
- else
- return null;
- } else {
- if (File != null)
- return "file:" + File;
- else
- return null;
- }
- }
- set {
- string val = value as string;
- if (val == null)
- File = null;
- else if (val.StartsWith ("stock:"))
- StockId = val.Substring (6);
- else if (val.StartsWith ("file:"))
- File = val.Substring (5);
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ImageFile.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ImageFile.cs
deleted file mode 100644
index 4d9ad3211a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ImageFile.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- [PropertyEditor ("File", "Changed")]
- public class ImageFile : Image {
-
- public ImageFile () : base (false, true) { }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ImageSelector.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ImageSelector.cs
deleted file mode 100644
index d983c521ec..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ImageSelector.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-
-using System;
-
-namespace Stetic.Editor
-{
- public class BaseImageCell: PropertyEditorCell
- {
- const int imgSize = 24;
- const int imgPad = 2;
- const int spacing = 5;
- Gdk.Pixbuf image;
-
- protected Gdk.Pixbuf Image {
- get { return image; }
- set { image = value; }
- }
-
- protected int ImageSize {
- get { return 16; }//imgSize - imgPad*2; }
- }
-
- public override void GetSize (int availableWidth, out int width, out int height)
- {
- base.GetSize (availableWidth, out width, out height);
- width += imgSize + spacing;
- height = Math.Max (imgSize, height);
- }
-
- public override void Render (Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
- {
- int iy = bounds.Y + (bounds.Height - imgSize) / 2;
-
- if (image != null) {
- int dy = (imgSize - image.Height) / 2;
- int dx = (imgSize - image.Width) / 2;
- window.DrawPixbuf (Container.Style.BackgroundGC (state), image, 0, 0, bounds.X + dx, iy + dy, -1, -1, Gdk.RgbDither.None, 0, 0);
- }
-
- window.DrawRectangle (Container.Style.DarkGC (state), false, bounds.X, iy, imgSize - 1, imgSize - 1);
-
- bounds.X += imgSize + spacing;
- base.Render (window, bounds, state);
- }
- }
-
- public class ImageSelector: BaseImageCell
- {
- IProject project;
- ImageInfo imageInfo;
-
- protected override void Initialize ()
- {
- base.Initialize ();
-
- if (Property.PropertyType != typeof(ImageInfo))
- throw new ApplicationException ("ImageSelector editor does not support editing values of type " + Property.PropertyType);
-
- if (Instance == null)
- return;
-
- Stetic.ObjectWrapper w = Stetic.ObjectWrapper.Lookup (Instance);
- project = w.Project;
- imageInfo = (ImageInfo)Value;
- if (imageInfo != null)
- Image = imageInfo.GetThumbnail (project, ImageSize);
- else
- Image = null;
- }
-
- protected override string GetValueText ()
- {
- if (imageInfo == null)
- return "";
- return imageInfo.Label;
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new ImageSelectorEditor ();
- }
- }
-
- public class ImageSelectorEditor: Gtk.HBox, IPropertyEditor
- {
- Gtk.Image image;
- Gtk.Label entry;
- Gtk.Button button;
- Gtk.Button clearButton;
- ImageInfo icon;
- IProject project;
- Gtk.Frame imageFrame;
-
- public ImageSelectorEditor()
- {
- Spacing = 3;
- imageFrame = new Gtk.Frame ();
- imageFrame.Shadow = Gtk.ShadowType.In;
- imageFrame.BorderWidth = 2;
- PackStart (imageFrame, false, false, 0);
-
- image = new Gtk.Image (GnomeStock.Blank, Gtk.IconSize.Button);
- imageFrame.Add (image);
-
- Gtk.Frame frame = new Gtk.Frame ();
- entry = new Gtk.Label ();
- entry.Xalign = 0;
- frame.Shadow = Gtk.ShadowType.In;
- frame.BorderWidth = 2;
- frame.Add (entry);
- PackStart (frame, true, true, 0);
-
- clearButton = new Gtk.Button (new Gtk.Image (Gtk.Stock.Clear, Gtk.IconSize.Menu));
- clearButton.Clicked += OnClearImage;
- PackStart (clearButton, false, false, 0);
-
- button = new Gtk.Button ("...");
- PackStart (button, false, false, 0);
- button.Clicked += button_Clicked;
- ShowAll ();
- }
-
- void button_Clicked (object obj, EventArgs args)
- {
- Gtk.Window parent = (Gtk.Window)GetAncestor (Gtk.Window.GType);
- using (SelectImageDialog dlg = new SelectImageDialog (parent, project)) {
- dlg.Icon = (ImageInfo) Value;
- if (dlg.Run () == (int) Gtk.ResponseType.Ok)
- Value = dlg.Icon;
- }
- }
-
- void OnClearImage (object obj, EventArgs args)
- {
- Value = null;
- }
-
- // Called once to initialize the editor.
- public void Initialize (PropertyDescriptor prop)
- {
- if (prop.PropertyType != typeof(ImageInfo))
- throw new ApplicationException ("ImageSelector editor does not support editing values of type " + prop.PropertyType);
- }
-
- // Called when the object to be edited changes.
- public void AttachObject (object obj)
- {
- Stetic.ObjectWrapper w = Stetic.ObjectWrapper.Lookup (obj);
- project = w.Project;
- }
-
- // Gets/Sets the value of the editor. If the editor supports
- // several value types, it is the responsibility of the editor
- // to return values with the expected type.
- public object Value {
- get { return icon; }
- set {
- icon = (ImageInfo) value;
- if (icon != null) {
- entry.Text = icon.Label;
- image.Pixbuf = icon.GetThumbnail (project, 16);
- imageFrame.Show ();
- clearButton.Show ();
- } else {
- imageFrame.Hide ();
- clearButton.Hide ();
- entry.Text = "";
- }
-
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
- }
-
- // To be fired when the edited value changes.
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IntRange.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IntRange.cs
deleted file mode 100644
index 415becc0dc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/IntRange.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- public class IntRange : PropertyEditorCell
- {
- bool optInteger;
-
- bool HasValue {
- get {
- if (!optInteger) return true;
- int val = (int) Convert.ChangeType (Value, typeof(int));
- return (val != -1);
- }
- }
-
- protected override void Initialize ()
- {
- base.Initialize ();
-
- if (Property.Minimum != null && Property.PropertyType == typeof(int)) {
- int min = (int) Convert.ChangeType (Property.Minimum, typeof(int));
- optInteger = (min == -1);
- } else
- optInteger = false;
- }
-
- public override void GetSize (int availableWidth, out int width, out int height)
- {
- if (HasValue)
- base.GetSize (availableWidth, out width, out height);
- else
- width = height = 0;
- }
-
- public override void Render (Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
- {
- if (HasValue)
- base.Render (window, bounds, state);
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- if (optInteger)
- return new OptIntRange (0, null);
- else
- return new IntRangeEditor ();
- }
- }
-
- public class IntRangeEditor : Gtk.SpinButton, IPropertyEditor {
-
- Type propType;
-
- public IntRangeEditor () : base (0, 0, 1.0)
- {
- this.HasFrame = false;
- }
-
- public void Initialize (PropertyDescriptor prop)
- {
- propType = prop.PropertyType;
-
- double min, max;
-
- switch (Type.GetTypeCode (propType)) {
- case TypeCode.Int16:
- min = (double) Int16.MinValue;
- max = (double) Int16.MaxValue;
- break;
- case TypeCode.UInt16:
- min = (double) UInt16.MinValue;
- max = (double) UInt16.MaxValue;
- break;
- case TypeCode.Int32:
- min = (double) Int32.MinValue;
- max = (double) Int32.MaxValue;
- break;
- case TypeCode.UInt32:
- min = (double) UInt32.MinValue;
- max = (double) UInt32.MaxValue;
- break;
- case TypeCode.Int64:
- min = (double) Int64.MinValue;
- max = (double) Int64.MaxValue;
- break;
- case TypeCode.UInt64:
- min = (double) UInt64.MinValue;
- max = (double) UInt64.MaxValue;
- break;
- case TypeCode.Byte:
- min = (double) Byte.MinValue;
- max = (double) Byte.MaxValue;
- break;
- case TypeCode.SByte:
- min = (double) SByte.MinValue;
- max = (double) SByte.MaxValue;
- break;
- default:
- throw new ApplicationException ("IntRange editor does not support editing values of type " + prop.PropertyType);
- }
-
- if (prop.Minimum != null)
- min = (double) Convert.ChangeType (prop.Minimum, typeof(double));
- if (prop.Maximum != null)
- max = (double) Convert.ChangeType (prop.Maximum, typeof(double));
-
- SetRange (min, max);
- }
-
- public void AttachObject (object ob)
- {
- }
-
- object IPropertyEditor.Value {
- get { return Convert.ChangeType (base.Value, propType); }
- set { base.Value = (double) Convert.ChangeType (value, typeof(double)); }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/NonContainerWarningDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/NonContainerWarningDialog.cs
deleted file mode 100644
index 3b212baa52..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/NonContainerWarningDialog.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-
-using System;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- public delegate void ShowUrlDelegate (string url);
-
- public class NonContainerWarningDialog: IDisposable
- {
- [Glade.Widget] Gtk.CheckButton showCheck;
- [Glade.Widget] Gtk.Button linkButton;
- [Glade.Widget] Gtk.Button okbutton;
- [Glade.Widget ("AddNonContainerDialog")] Gtk.Dialog dialog;
-
- public static ShowUrlDelegate ShowUrl;
-
- public NonContainerWarningDialog()
- {
- Glade.XML xml = new Glade.XML (null, "stetic.glade", "AddNonContainerDialog", null);
- xml.Autoconnect (this);
-
- ((Gtk.Label)linkButton.Child).Markup = "<u><span foreground='blue'>" + Catalog.GetString ("GTK# Widget Layout and Packing") + "</span></u>";
-
- linkButton.Clicked += delegate {
- if (ShowUrl != null)
- ShowUrl ("http://www.mono-project.com/GtkSharp:_Widget_Layout_and_Packing");
- };
- okbutton.HasFocus = true;
- }
-
- public bool ShowAgain {
- get { return !showCheck.Active; }
- set { showCheck.Active = !value; }
- }
-
- public Gtk.Window TransientFor {
- set { dialog.TransientFor = value; }
- }
-
- public int Run ()
- {
- return dialog.Run ();
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/OptIntRange.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/OptIntRange.cs
deleted file mode 100644
index 784c41f33b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/OptIntRange.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- public class OptIntRange : Gtk.HBox, IPropertyEditor {
-
- Gtk.CheckButton check;
- Gtk.SpinButton spin;
- object omin, omax;
-
- public OptIntRange () : base (false, 6)
- {
- }
-
- public OptIntRange (object omin, object omax) : base (false, 6)
- {
- this.omin = omin;
- this.omax = omax;
- }
-
- public void Initialize (PropertyDescriptor prop)
- {
- if (prop.PropertyType != typeof(int))
- throw new ApplicationException ("OptIntRange editor does not support editing values of type " + prop.PropertyType);
-
- double min = (double) Int32.MinValue;
- double max = (double) Int32.MaxValue;
-
- if (omin == null)
- omin = prop.Minimum;
- if (omax == null)
- omax = prop.Maximum;
-
- if (omin != null)
- min = (double) Convert.ChangeType (omin, typeof(double));
- if (omax != null)
- max = (double) Convert.ChangeType (omax, typeof(double));
-
- check = new Gtk.CheckButton ();
- check.Show ();
- check.Toggled += check_Toggled;
- PackStart (check, false, false, 0);
-
- spin = new Gtk.SpinButton (min, max, 1.0);
- spin.Show ();
- spin.HasFrame = false;
- spin.ValueChanged += spin_ValueChanged;
- PackStart (spin, true, true, 0);
- }
-
- public void AttachObject (object ob)
- {
- }
-
- void check_Toggled (object o, EventArgs args)
- {
- spin.Sensitive = check.Active;
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- void spin_ValueChanged (object o, EventArgs args)
- {
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- public object Value {
- get {
- if (check.Active)
- return (int)spin.Value;
- else
- return -1;
- }
- set {
- int val = (int) value;
- if (val == -1) {
- check.Active = false;
- spin.Sensitive = false;
- } else {
- check.Active = true;
- spin.Sensitive = true;
- spin.Value = (double)val;
- }
- }
- }
-
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ProjectIconList.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ProjectIconList.cs
deleted file mode 100644
index ff6a2fcce9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ProjectIconList.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-
-using System;
-using System.Collections;
-using Gtk;
-
-namespace Stetic.Editor
-{
- class ProjectIconList : IconList
- {
- IProject project;
- ProjectIconFactory icons;
-
- public ProjectIconList (IProject project, ProjectIconFactory icons)
- {
- this.project = project;
- this.icons = icons;
- Refresh ();
- }
-
- public void Refresh ()
- {
- Clear ();
- foreach (ProjectIconSet icon in icons.Icons)
- AddIcon (icon.Name, icon.Sources [0].Image.GetThumbnail (project, 16), icon.Name);
- }
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ProjectIconSelectorItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ProjectIconSelectorItem.cs
deleted file mode 100644
index fe5683918c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ProjectIconSelectorItem.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-
-using System;
-
-namespace Stetic.Editor
-{
- public class ProjectIconSelectorItem: IconSelectorItem
- {
- IProject project;
-
- public ProjectIconSelectorItem (IProject project): base ("Project Icons")
- {
- this.project = project;
- }
-
- protected override void CreateIcons ()
- {
- foreach (ProjectIconSet icon in project.IconFactory.Icons)
- AddIcon (icon.Name, icon.Sources [0].Image.GetScaledImage (project, Gtk.IconSize.Menu), icon.Name);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ResponseId.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ResponseId.cs
deleted file mode 100644
index bc7ef54bab..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ResponseId.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-
-namespace Stetic.Editor
-{
- public class ResponseId: PropertyEditorCell
- {
- protected override string GetValueText ()
- {
- if (Value == null)
- return "";
-
- int val = (int) Value;
- EnumDescriptor enm = Registry.LookupEnum ("Gtk.ResponseType");
- foreach (Enum value in enm.Values) {
- if (Convert.ToInt32 (enm[value].Value) == val) {
- return enm[value].Label;
- }
- }
- return val.ToString ();
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new ResponseIdEditor ();
- }
- }
-
- public class ResponseIdEditor : Gtk.HBox, IPropertyEditor {
-
- Gtk.ComboBoxEntry combo;
- Gtk.Entry entry;
- EnumDescriptor enm;
- ArrayList values;
-
- public ResponseIdEditor ()
- {
- combo = Gtk.ComboBoxEntry.NewText ();
- combo.Changed += combo_Changed;
- combo.Show ();
- PackStart (combo, true, true, 0);
-
- entry = combo.Child as Gtk.Entry;
- entry.Changed += entry_Changed;
-
- enm = Registry.LookupEnum ("Gtk.ResponseType");
- values = new ArrayList ();
- foreach (Enum value in enm.Values) {
- if (enm[value].Label != "") {
- combo.AppendText (enm[value].Label);
- values.Add (Convert.ToInt32 (enm[value].Value));
- }
- }
- }
-
- public void Initialize (PropertyDescriptor prop)
- {
- if (prop.PropertyType != typeof(int))
- throw new ApplicationException ("ResponseId editor does not support editing values of type " + prop.PropertyType);
- }
-
- public void AttachObject (object ob)
- {
- }
-
- public object Value {
- get {
- if (combo.Active != -1)
- return (int)values[combo.Active];
- else {
- try {
- return Int32.Parse (entry.Text);
- } catch {
- return 0;
- }
- }
- }
- set {
- combo.Active = values.IndexOf ((int)value);
- if (combo.Active == -1)
- entry.Text = value.ToString ();
- }
- }
-
- public event EventHandler ValueChanged;
-
- void combo_Changed (object o, EventArgs args)
- {
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- void entry_Changed (object o, EventArgs args)
- {
- if (combo.Active == -1 && ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/SelectIconDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/SelectIconDialog.cs
deleted file mode 100644
index 1d9c3b220d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/SelectIconDialog.cs
+++ /dev/null
@@ -1,179 +0,0 @@
-
-using System;
-using System.Collections;
-using System.IO;
-using Gtk;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- public class SelectIconDialog: IDisposable
- {
- [Glade.Widget] Gtk.Entry stockIconEntry;
- [Glade.Widget] Gtk.Notebook notebook;
- [Glade.Widget] Gtk.ScrolledWindow iconScrolledwindow;
- [Glade.Widget] Gtk.ScrolledWindow customIconScrolledwindow;
- [Glade.Widget] Gtk.Image previewIcon;
- [Glade.Widget] Gtk.Button okButton;
- [Glade.Widget] Gtk.Widget labelWarningIcon;
- [Glade.Widget ("SelectIconDialog")] Gtk.Dialog dialog;
-
- StockIconList iconList;
- ProjectIconList customIconList;
-
- Gtk.Window parent;
- Stetic.IProject project;
-
- public SelectIconDialog (Gtk.Window parent, Stetic.IProject project)
- {
- this.parent = parent;
- this.project = project;
-
- Glade.XML xml = new Glade.XML (null, "stetic.glade", "SelectIconDialog", null);
- xml.Autoconnect (this);
-
- // Stock icon list
-
- iconList = new StockIconList ();
- iconList.SelectionChanged += new EventHandler (OnIconSelectionChanged);
- iconScrolledwindow.AddWithViewport (iconList);
-
- // Custom icon list
-
- customIconList = new ProjectIconList (project, project.IconFactory);
- customIconList.SelectionChanged += new EventHandler (OnCustomIconSelectionChanged);
- customIconScrolledwindow.AddWithViewport (customIconList);
- dialog.ShowAll ();
-
- UpdateIconSelection ();
- UpdateButtons ();
- }
-
- public int Run ()
- {
- dialog.Show ();
- dialog.TransientFor = parent;
- return dialog.Run ();
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
-
- public string Icon {
- get {
- if (notebook.Page == 0) {
- if (stockIconEntry.Text.Length == 0)
- return null;
- return stockIconEntry.Text;
- } else {
- return customIconList.Selection;
- }
- }
- set {
- if (value == null)
- return;
-
- if (project.IconFactory.GetIcon (value) != null) {
- notebook.Page = 1;
- customIconList.Selection = value;
- } else {
- stockIconEntry.Text = value;
- iconList.Selection = value;
- notebook.Page = 0;
- }
- }
- }
-
- void UpdateButtons ()
- {
- okButton.Sensitive = Icon != null;
- }
-
- protected void OnCurrentPageChanged (object s, Gtk.SwitchPageArgs args)
- {
- UpdateButtons ();
- }
-
- void OnIconSelectionChanged (object s, EventArgs args)
- {
- if (iconList.Selection != null) {
- stockIconEntry.Text = iconList.Selection;
- }
- }
-
- void OnCustomIconSelectionChanged (object s, EventArgs args)
- {
- UpdateButtons ();
- }
-
- void UpdateIconSelection ()
- {
- labelWarningIcon.Visible = stockIconEntry.Text.Length > 0 && (!stockIconEntry.Text.StartsWith ("gtk-"));
-
- Gdk.Pixbuf icon = null;
- if (stockIconEntry.Text.Length > 0) {
- icon = WidgetUtils.LoadIcon (stockIconEntry.Text, Gtk.IconSize.Menu);
- }
- if (icon == null)
- icon = WidgetUtils.MissingIcon;
- previewIcon.Pixbuf = icon;
- }
-
- protected void OnIconNameChanged (object ob, EventArgs args)
- {
- UpdateIconSelection ();
- UpdateButtons ();
- }
-
- protected void OnAddIcon (object ob, EventArgs args)
- {
- ProjectIconSet icon = new ProjectIconSet ();
- using (EditIconDialog dlg = new EditIconDialog (project, icon)) {
- if (parent != null)
- dlg.TransientFor = parent.Toplevel as Gtk.Window;
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
- project.IconFactory.Icons.Add (icon);
- customIconList.Refresh ();
- customIconList.Selection = icon.Name;
-// project.Modified = true;
- }
- }
- }
-
- protected void OnRemoveIcon (object ob, EventArgs args)
- {
- string name = customIconList.Selection;
- ProjectIconSet icon = project.IconFactory.GetIcon (name);
- if (icon != null) {
- Gtk.MessageDialog md = new Gtk.MessageDialog (dialog, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, string.Format (Catalog.GetString ("Are you sure you want to delete the icon '{0}'"), icon.Name));
- if (parent != null)
- md.TransientFor = parent.Toplevel as Gtk.Window;
- if (md.Run () == (int) Gtk.ResponseType.Yes) {
- project.IconFactory.Icons.Remove (icon);
- customIconList.Refresh ();
-// project.Modified = true;
- }
- md.Destroy ();
- }
- }
-
- protected void OnEditIcon (object ob, EventArgs args)
- {
- string name = customIconList.Selection;
- ProjectIconSet icon = project.IconFactory.GetIcon (name);
- if (icon != null) {
- using (EditIconDialog dlg = new EditIconDialog (project, icon)) {
- if (parent != null)
- dlg.TransientFor = parent.Toplevel as Gtk.Window;
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
- customIconList.Refresh ();
- customIconList.Selection = icon.Name;
-// project.Modified = true;
- }
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/SelectImageDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/SelectImageDialog.cs
deleted file mode 100644
index 1ab23740aa..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/SelectImageDialog.cs
+++ /dev/null
@@ -1,314 +0,0 @@
-
-using System;
-using System.Collections;
-using System.IO;
-using Gtk;
-
-namespace Stetic.Editor
-{
- public class SelectImageDialog: IDisposable
- {
- [Glade.Widget] Gtk.TreeView resourceList;
- [Glade.Widget] Gtk.FileChooserWidget fileChooser;
- [Glade.Widget] Gtk.Entry iconNameEntry;
- [Glade.Widget] Gtk.Notebook notebook;
- [Glade.Widget] Gtk.ScrolledWindow iconScrolledwindow;
- [Glade.Widget] Gtk.Image previewIcon;
- [Glade.Widget] Gtk.Image previewResource;
- [Glade.Widget] Gtk.ComboBox iconSizeCombo;
- [Glade.Widget] Gtk.Entry resourceNameEntry;
- [Glade.Widget] Gtk.Button okButton;
- [Glade.Widget] Gtk.Button buttonAdd;
- [Glade.Widget] Gtk.Button buttonRemove;
- [Glade.Widget ("SelectImageDialog")] Gtk.Dialog dialog;
-
- ThemedIconList iconList;
-
- Gtk.ListStore resourceListStore;
- Gtk.Window parent;
-
- int thumbnailSize = 30;
- Hashtable resources = new Hashtable (); // Stores resourceName -> thumbnail pixbuf
- Gdk.Pixbuf missingThumbnail;
- IResourceProvider resourceProvider;
- string importedImageFile;
- Stetic.IProject project;
-
- public SelectImageDialog (Gtk.Window parent, Stetic.IProject project)
- {
- this.parent = parent;
- this.project = project;
- Glade.XML xml = new Glade.XML (null, "stetic.glade", "SelectImageDialog", null);
- xml.Autoconnect (this);
-
- // Stock icon list
-
- iconList = new ThemedIconList ();
- iconList.SelectionChanged += new EventHandler (OnIconSelectionChanged);
- iconScrolledwindow.AddWithViewport (iconList);
-
- // Icon Sizes
-
- foreach (IconSize s in Enum.GetValues (typeof(Gtk.IconSize))) {
- if (s != IconSize.Invalid)
- iconSizeCombo.AppendText (s.ToString ());
- }
- iconSizeCombo.Active = 0;
-
- // Resource list
-
- resourceListStore = new Gtk.ListStore (typeof(Gdk.Pixbuf), typeof(string), typeof(string));
- resourceList.Model = resourceListStore;
-
- Gtk.TreeViewColumn col = new Gtk.TreeViewColumn ();
-
- Gtk.CellRendererPixbuf pr = new Gtk.CellRendererPixbuf ();
- pr.Xpad = 3;
- col.PackStart (pr, false);
- col.AddAttribute (pr, "pixbuf", 0);
-
- Gtk.CellRendererText crt = new Gtk.CellRendererText ();
- col.PackStart (crt, true);
- col.AddAttribute (crt, "markup", 1);
-
- resourceList.AppendColumn (col);
- resourceProvider = project.ResourceProvider;
- if (resourceProvider == null) {
- buttonAdd.Sensitive = false;
- buttonRemove.Sensitive = false;
- }
- FillResources ();
- resourceList.Selection.Changed += OnResourceSelectionChanged;
-
- if (project.FolderName != null)
- fileChooser.SetCurrentFolder (project.ImagesRootPath);
-
- fileChooser.SelectionChanged += delegate (object s, EventArgs a) {
- UpdateButtons ();
- };
-
- fileChooser.FileActivated += delegate (object s, EventArgs a) {
- if (Icon != null) {
- if (Validate ())
- dialog.Respond (Gtk.ResponseType.Ok);
- }
- };
-
- okButton.Clicked += OnOkClicked;
-
- UpdateButtons ();
- }
-
- public int Run ()
- {
- dialog.ShowAll ();
- dialog.TransientFor = parent;
- return dialog.Run ();
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
-
- public ImageInfo Icon {
- get {
- if (notebook.Page == 0) {
- if (iconNameEntry.Text.Length == 0)
- return null;
- return ImageInfo.FromTheme (iconNameEntry.Text, SelectedIconSize);
- } else if (notebook.Page == 1) {
- if (resourceNameEntry.Text.Length == 0)
- return null;
- return ImageInfo.FromResource (resourceNameEntry.Text);
- } else {
- if (importedImageFile != null)
- return ImageInfo.FromFile (importedImageFile);
- if (fileChooser.Filename == null || fileChooser.Filename.Length == 0 || !File.Exists (fileChooser.Filename))
- return null;
- return ImageInfo.FromFile (fileChooser.Filename);
- }
- }
- set {
- if (value == null)
- return;
- if (value.Source == ImageSource.Theme) {
- iconNameEntry.Text = value.Name;
- SelectedIconSize = value.ThemeIconSize;
- notebook.Page = 0;
- } else if (value.Source == ImageSource.Resource) {
- notebook.Page = 1;
- resourceNameEntry.Text = value.Name;
- } else {
- fileChooser.SetFilename (value.Name);
- notebook.Page = 2;
- }
- }
- }
-
- Gtk.IconSize SelectedIconSize {
- get { return (IconSize) iconSizeCombo.Active + 1; }
- set { iconSizeCombo.Active = ((int) value) - 1; }
- }
-
- void UpdateButtons ()
- {
- okButton.Sensitive = Icon != null;
- }
-
- protected void OnCurrentPageChanged (object s, Gtk.SwitchPageArgs args)
- {
- UpdateButtons ();
- }
-
- void OnIconSelectionChanged (object s, EventArgs args)
- {
- if (iconList.Selection != null) {
- iconNameEntry.Text = iconList.Selection;
- }
- }
-
- void UpdateIconSelection ()
- {
- Gdk.Pixbuf icon = null;
- if (iconNameEntry.Text.Length > 0) {
- icon = WidgetUtils.LoadIcon (iconNameEntry.Text, SelectedIconSize);
- }
- if (icon == null)
- icon = WidgetUtils.MissingIcon;
- previewIcon.Pixbuf = icon;
- }
-
- protected void OnIconSizeChanged (object ob, EventArgs args)
- {
- UpdateIconSelection ();
- }
-
- protected void OnIconNameChanged (object ob, EventArgs args)
- {
- UpdateIconSelection ();
- UpdateButtons ();
- }
-
- void FillResources ()
- {
- resourceListStore.Clear ();
- resources.Clear ();
- if (resourceProvider != null) {
- foreach (ResourceInfo res in resourceProvider.GetResources ()) {
- if (res.MimeType.StartsWith ("image/")) {
- AppendResource (resourceProvider.GetResourceStream (res.Name), res.Name);
- }
- }
- }
- }
-
- void AppendResource (Stream stream, string name)
- {
- try {
- Gdk.Pixbuf pix = new Gdk.Pixbuf (stream);
- stream.Close ();
- string txt = name + "\n<span foreground='darkgrey' size='x-small'>" + pix.Width + " x " + pix.Height + "</span>";
- pix = GetThumbnail (pix);
- resourceListStore.AppendValues (pix, txt, name);
- resources [name] = pix;
- } catch {
- // Doesn't look like a valid image. Just ignore it.
- }
- }
-
- Gdk.Pixbuf GetThumbnail (Gdk.Pixbuf pix)
- {
- if (pix.Width > pix.Height) {
- if (pix.Width > thumbnailSize) {
- float prop = (float) pix.Height / (float) pix.Width;
- return pix.ScaleSimple (thumbnailSize, (int)(thumbnailSize * prop), Gdk.InterpType.Bilinear);
- }
- } else {
- if (pix.Height > thumbnailSize) {
- float prop = (float) pix.Width / (float) pix.Height;
- return pix.ScaleSimple ((int)(thumbnailSize * prop), thumbnailSize, Gdk.InterpType.Bilinear);
- }
- }
- return pix;
- }
-
- void OnResourceSelectionChanged (object obj, EventArgs args)
- {
- Gtk.TreeIter iter;
- Gtk.TreeModel model;
- if (!resourceList.Selection.GetSelected (out model, out iter)) {
- resourceNameEntry.Text = "";
- } else {
- resourceNameEntry.Text = (string) resourceListStore.GetValue (iter, 2);
- }
- }
-
- protected void OnResourceNameChanged (object ob, EventArgs args)
- {
- Gdk.Pixbuf pix = (Gdk.Pixbuf) resources [resourceNameEntry.Text];
- if (pix != null)
- previewResource.Pixbuf = pix;
- else {
- if (missingThumbnail == null)
- missingThumbnail = WidgetUtils.MissingIcon;
- previewResource.Pixbuf = missingThumbnail;
- }
- UpdateButtons ();
- }
-
- protected void OnAddResource (object ob, EventArgs args)
- {
- FileChooserDialog dialog =
- new FileChooserDialog ("Open File", null, FileChooserAction.Open,
- Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
- Gtk.Stock.Open, Gtk.ResponseType.Ok);
- if (parent != null)
- dialog.TransientFor = parent.Toplevel as Gtk.Window;
- int response = dialog.Run ();
- if (response == (int)Gtk.ResponseType.Ok) {
- ResourceInfo rinfo = resourceProvider.AddResource (dialog.Filename);
- AppendResource (resourceProvider.GetResourceStream (rinfo.Name), rinfo.Name);
- resourceNameEntry.Text = rinfo.Name;
- }
- dialog.Destroy ();
- }
-
- protected void OnRemoveResource (object ob, EventArgs args)
- {
- Gtk.TreeIter iter;
- Gtk.TreeModel model;
- if (resourceList.Selection.GetSelected (out model, out iter)) {
- string res = (string) resourceListStore.GetValue (iter, 2);
- Gtk.MessageDialog msg = new Gtk.MessageDialog (dialog, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, "Are you sure you want to delete the resource '{0}'?", res);
- if (parent != null)
- msg.TransientFor = parent.Toplevel as Gtk.Window;
- if (msg.Run () == (int) ResponseType.Yes) {
- resourceProvider.RemoveResource (res);
- resourceListStore.Remove (ref iter);
- }
- msg.Destroy ();
- }
- }
-
- bool Validate ()
- {
- if (notebook.Page == 2) {
- if (fileChooser.Filename == null || fileChooser.Filename.Length == 0 || !File.Exists (fileChooser.Filename))
- return true;
-
- importedImageFile = project.ImportFile (fileChooser.Filename);
- if (importedImageFile != null)
- importedImageFile = WidgetUtils.AbsoluteToRelativePath (project.ImagesRootPath, importedImageFile);
- return importedImageFile != null;
- }
- return true;
- }
-
- void OnOkClicked (object s, EventArgs args)
- {
- if (Validate ())
- dialog.Respond (Gtk.ResponseType.Ok);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockIconList.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockIconList.cs
deleted file mode 100644
index b8c5676990..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockIconList.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-
-using System;
-using System.Reflection;
-using System.Collections;
-using Gtk;
-
-namespace Stetic.Editor
-{
- class StockIconList : IconList
- {
- public StockIconList ()
- {
- foreach (PropertyInfo info in typeof (Gtk.Stock).GetProperties (BindingFlags.Public | BindingFlags.Static)) {
- if (info.CanRead && info.PropertyType == typeof (string)) {
- string name = (string) info.GetValue (null, null);
- AddIcon (name, WidgetUtils.LoadIcon (name, Gtk.IconSize.Menu), name);
- }
- }
- foreach (PropertyInfo info in GnomeStock.Properties) {
- if (info.CanRead && info.PropertyType == typeof (string)) {
- string name = (string) info.GetValue (null, null);
- AddIcon (name, WidgetUtils.LoadIcon (name, Gtk.IconSize.Menu), name);
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockIconSelectorItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockIconSelectorItem.cs
deleted file mode 100644
index bf18e604f4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockIconSelectorItem.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-
-using System;
-using Mono.Unix;
-
-namespace Stetic.Editor
-{
- public class StockIconSelectorItem: IconSelectorItem
- {
- public StockIconSelectorItem (IntPtr ptr): base (ptr)
- {
- }
-
- public StockIconSelectorItem (): base (Catalog.GetString ("Stock Icons"))
- {
- }
-
- protected override void CreateIcons ()
- {
- foreach (string s in StockIconHelper.StockIcons) {
- if (s != "-" && s != "|") {
- Gdk.Pixbuf pix = WidgetUtils.LoadIcon (s, Gtk.IconSize.Menu);
- if (pix != null) AddIcon (s, pix, s);
- }
- else
- AddSeparator (s);
- }
- }
- }
-
- class StockIconHelper
- {
- public static string[] StockIcons = {
- // Commands
- "gtk-new",
- "gtk-open",
- "gtk-save",
- "gtk-save-as",
- "gtk-revert-to-saved",
- "gtk-quit",
- "gtk-print",
- "gtk-print-preview",
- "gtk-properties",
- "|",
- "gtk-cut",
- "gtk-copy",
- "gtk-paste",
- "gtk-delete",
- "gtk-undelete",
- "gtk-undo",
- "gtk-redo",
- "gtk-preferences",
- "|",
- "gtk-execute",
- "gtk-stop",
- "gtk-refresh",
- "gtk-find",
- "gtk-find-and-replace",
- "|",
- "gtk-spell-check",
- "gtk-convert",
- "gtk-help",
- "|",
- "gtk-add",
- "gtk-remove",
- "gtk-clear",
- "-",
-
- // Formatting
- "gtk-bold",
- "gtk-italic",
- "gtk-underline",
- "gtk-strikethrough",
- "gtk-select-color",
- "gtk-select-font",
- "|",
- "gtk-indent",
- "gtk-unindent",
- "gtk-justify-center",
- "gtk-justify-fill",
- "gtk-justify-left",
- "gtk-justify-right",
- "|",
- "gtk-sort-ascending",
- "gtk-sort-descending",
- "|",
- "gtk-zoom-100",
- "gtk-zoom-fit",
- "gtk-zoom-in",
- "gtk-zoom-out",
- "-",
-
-
- // Dialog
- "gtk-yes",
- "gtk-no",
- "gtk-cancel",
- "gtk-ok",
- "gtk-apply",
- "gtk-close",
- "|",
- "gtk-dialog-error",
- "gtk-dialog-info",
- "gtk-dialog-question",
- "gtk-dialog-warning",
- "-",
-
- // Navigation
- "gtk-goto-bottom",
- "gtk-goto-first",
- "gtk-goto-last",
- "gtk-goto-top",
- "|",
- "gtk-go-back",
- "gtk-go-down",
- "gtk-go-forward",
- "gtk-go-up",
- "|",
- "gtk-home",
- "gtk-jump-to",
- "-",
-
- // Misc
- "gtk-cdrom",
- "gtk-floppy",
- "gtk-harddisk",
- "gtk-network",
- "gtk-color-picker",
- "gtk-dnd",
- "gtk-dnd-multiple",
- "gtk-missing-image",
- "gtk-index"
- };
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockItem.cs
deleted file mode 100644
index 5d9ed308da..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StockItem.cs
+++ /dev/null
@@ -1,200 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-
-namespace Stetic.Editor {
-
- internal static class GnomeStock {
-
- static string blank;
- static List<PropertyInfo> props = new List<PropertyInfo> ();
-
- static GnomeStock ()
- {
- try {
- Assembly assm = Assembly.Load ("gnome-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f");
- if (assm == null)
- return;
-
- Type type = assm.GetType ("Gnome.Stock");
- if (type == null)
- return;
-
- foreach (PropertyInfo info in type.GetProperties (BindingFlags.Static | BindingFlags.Public)) {
- if (info.Name == "Blank")
- blank = (string) info.GetValue (null, null);
- props.Add (info);
- }
- } catch {
- }
- }
-
- public static string Blank {
- get { return blank == null ? Gtk.Stock.New : blank; }
- }
-
- public static List<PropertyInfo> Properties {
- get { return props; }
- }
- }
-
- public class StockItem: BaseImageCell
- {
- string label;
-
- protected override void Initialize ()
- {
- base.Initialize ();
- string name = (string)Value;
- if (name != null) {
- Stetic.ObjectWrapper w = Stetic.ObjectWrapper.Lookup (Instance);
- Stetic.IProject project = w.Project;
- Gdk.Pixbuf px = project.IconFactory.RenderIcon (project, name, ImageSize);
- if (px != null) {
- Image = px;
- label = name;
- return;
- }
-
- Gtk.StockItem item = Gtk.Stock.Lookup (name);
- label = item.Label != null && item.Label.Length > 0 ? item.Label : name;
- label = label.Replace ("_", "");
-
- Gtk.IconSet iset = Gtk.IconFactory.LookupDefault (name);
- if (iset == null)
- Image = WidgetUtils.MissingIcon;
- else
- Image = iset.RenderIcon (new Gtk.Style (), Gtk.TextDirection.Ltr, Gtk.StateType.Normal, Gtk.IconSize.Menu, null, "");
- } else {
- Image = null;
- label = "";
- }
- }
-
- protected override string GetValueText ()
- {
- return label;
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new StockItemEditor ();
- }
- }
-
-/* [PropertyEditor ("StockId", "Changed")]
- public class StockItemEditor : Image {
-
- public StockItemEditor () : base (true, false) { }
-
- public override object Value {
- get { return StockId; }
- set { StockId = (string) value; }
- }
- }
- */
-
- public class StockItemEditor: Gtk.HBox, IPropertyEditor
- {
- Gtk.Image image;
- Gtk.Entry entry;
- Gtk.Button button;
- string icon;
- IProject project;
- Gtk.Frame imageFrame;
-
- public StockItemEditor()
- {
- Spacing = 3;
- imageFrame = new Gtk.Frame ();
- imageFrame.Shadow = Gtk.ShadowType.In;
- imageFrame.BorderWidth = 2;
- PackStart (imageFrame, false, false, 0);
-
- image = new Gtk.Image (GnomeStock.Blank, Gtk.IconSize.Button);
- imageFrame.Add (image);
-
- entry = new Gtk.Entry ();
- entry.Changed += OnTextChanged;
- entry.HasFrame = false;
- PackStart (entry, true, true, 0);
-
- button = new Gtk.Button ();
- button.Add (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out));
- PackStart (button, false, false, 0);
- button.Clicked += button_Clicked;
- ShowAll ();
- }
-
- void button_Clicked (object obj, EventArgs args)
- {
- IconSelectorMenu menu = new IconSelectorMenu (project);
- menu.IconSelected += OnStockSelected;
- menu.ShowAll ();
- menu.Popup (null, null, new Gtk.MenuPositionFunc (OnDropMenuPosition), 3, Gtk.Global.CurrentEventTime);
- }
-
- void OnDropMenuPosition (Gtk.Menu menu, out int x, out int y, out bool pushIn)
- {
- button.ParentWindow.GetOrigin (out x, out y);
- x += button.Allocation.X;
- y += button.Allocation.Y + button.Allocation.Height;
- pushIn = true;
- }
-
- void OnStockSelected (object s, IconEventArgs args)
- {
- Value = args.IconId;
- }
-
- void OnTextChanged (object s, EventArgs a)
- {
- if (entry.Text.Length == 0)
- Value = null;
- else
- Value = entry.Text;
- }
-
- // Called once to initialize the editor.
- public void Initialize (PropertyDescriptor prop)
- {
- if (prop.PropertyType != typeof(string))
- throw new ApplicationException ("StockItem editor does not support editing values of type " + prop.PropertyType);
- }
-
- // Called when the object to be edited changes.
- public void AttachObject (object obj)
- {
- Stetic.ObjectWrapper w = Stetic.ObjectWrapper.Lookup (obj);
- project = w.Project;
- }
-
- // Gets/Sets the value of the editor. If the editor supports
- // several value types, it is the responsibility of the editor
- // to return values with the expected type.
- public object Value {
- get { return icon; }
- set {
- icon = (string) value;
- if (icon != null && icon.Length > 0) {
- entry.Text = icon;
- Gdk.Pixbuf px = project.IconFactory.RenderIcon (project, icon, Gtk.IconSize.Menu);
- if (px == null)
- px = WidgetUtils.LoadIcon (icon, Gtk.IconSize.Menu);
- image.Pixbuf = px;
- imageFrame.Show ();
- } else {
- imageFrame.Hide ();
- entry.Text = "";
- }
-
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
- }
-
- // To be fired when the edited value changes.
- public event EventHandler ValueChanged;
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/String.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/String.cs
deleted file mode 100644
index dafbb3922a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/String.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- [PropertyEditor ("Text", "Changed")]
- public class String : Translatable {
-
- Gtk.Entry entry;
-
- public override void Initialize (PropertyDescriptor prop)
- {
- base.Initialize (prop);
-
- entry = new Gtk.Entry ();
- entry.HasFrame = false;
- entry.Show ();
- entry.Changed += EntryChanged;
- Add (entry);
- }
-
- protected override void CheckType (PropertyDescriptor prop)
- {
- if (prop.PropertyType != typeof(string))
- throw new ApplicationException ("String editor does not support editing values of type " + prop.PropertyType);
- }
-
- public override object Value {
- get {
- return entry.Text;
- }
- set {
- if (value == null)
- entry.Text = "";
- else
- entry.Text = (string) value;
- }
- }
-
- void EntryChanged (object obj, EventArgs args)
- {
- OnValueChanged ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StringArray.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StringArray.cs
deleted file mode 100644
index ca8d5bd064..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/StringArray.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-
-using System;
-using Gtk;
-using Gdk;
-using System.Text;
-
-namespace Stetic.Editor
-{
- public class StringArray: PropertyEditorCell
- {
- protected override string GetValueText ()
- {
- string[] val = (string[]) Value;
- return val == null ? string.Empty : "(Collection)";
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new StringArrayEditor ();
- }
- }
-
- public class StringArrayEditor: Gtk.HBox, IPropertyEditor
- {
- Gtk.Entry label;
- Gtk.Button button;
- PropertyDescriptor prop;
- object obj;
- string[] strings;
-
- public StringArrayEditor()
- {
- label = new Gtk.Entry ();
- label.IsEditable = false;
- PackStart (label, true, true, 0);
- button = new Button ("...");
- PackStart (button, false, false, 3);
- button.Clicked += ButtonClicked;
- ShowAll ();
- }
-
- void ButtonClicked (object s, EventArgs a)
- {
- using (TextEditorDialog dlg = new TextEditorDialog ()) {
- dlg.Text = strings != null ? string.Join ("\n", strings) : "";
- dlg.SetTranslatable (prop.Translatable);
- dlg.TransientFor = this.Toplevel as Gtk.Window;
- if (prop.Translatable) {
- dlg.Translated = prop.IsTranslated (obj);
- dlg.ContextHint = prop.TranslationContext (obj);
- dlg.Comment = prop.TranslationComment (obj);
- }
- if (dlg.Run () == (int) ResponseType.Ok) {
- if (prop.Translatable) {
- prop.SetTranslated (obj, dlg.Translated);
- if (dlg.Translated) {
- prop.SetTranslationComment (obj, dlg.Comment);
- prop.SetTranslationContext (obj, dlg.ContextHint);
- }
- }
- if (dlg.Text.Length == 0)
- strings = null;
- else
- strings = dlg.Text.Split ('\n');
- UpdateLabel ();
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
- }
- }
-
- public void Initialize (PropertyDescriptor descriptor)
- {
- if (descriptor.PropertyType != typeof(string[]))
- throw new InvalidOperationException ("StringArrayEditor can only edit string[] properties");
- prop = descriptor;
- }
-
- public void AttachObject (object obj)
- {
- this.obj = obj;
- }
-
- public object Value {
- get { return strings; }
- set {
- strings = (string[]) value;
- UpdateLabel ();
- }
- }
-
- void UpdateLabel ()
- {
- label.Text = strings != null ? "(Collection)" : System.String.Empty;
- }
-
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Text.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Text.cs
deleted file mode 100644
index 667ccb2537..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Text.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-
-namespace Stetic.Editor
-{
- public class Text : TextEditor
- {
- public Text ()
- {
- // Don't allow editing the text in the editor
- // since there is no room for multiline edit in the grid.
- entry.Sensitive = false;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextBox.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextBox.cs
deleted file mode 100644
index 6dd84a878c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextBox.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- public class TextBox : Gtk.ScrolledWindow {
-
- Gtk.TextView textview;
-
- public TextBox (int nlines)
- {
- ShadowType = Gtk.ShadowType.In;
- SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Automatic);
-
- textview = new Gtk.TextView ();
- textview.WrapMode = Gtk.WrapMode.Word;
- textview.Show ();
- Add (textview);
-
- Pango.Context ctx = textview.PangoContext;
- Pango.FontMetrics metrics = ctx.GetMetrics (textview.Style.FontDescription,
- ctx.Language);
- int lineHeight = (metrics.Ascent + metrics.Descent) / (int)Pango.Scale.PangoScale;
- SetSizeRequest (-1, lineHeight * nlines);
-
- textview.Buffer.Changed += Buffer_Changed;
- }
-
- public Gtk.TextView TextView {
- get {
- return textview;
- }
- }
-
- public string Text {
- get {
- return textview.Buffer.Text;
- }
- set {
- textview.Buffer.Text = value;
- }
- }
-
- void Buffer_Changed (object obj, EventArgs args)
- {
- if (Changed != null)
- Changed (this, EventArgs.Empty);
- }
-
- public event EventHandler Changed;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextEditor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextEditor.cs
deleted file mode 100644
index d2c135a2a6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextEditor.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-
-using System;
-using Gtk;
-using Gdk;
-
-namespace Stetic.Editor
-{
- public class TextEditor: Gtk.HBox, IPropertyEditor
- {
- protected Gtk.Entry entry;
- protected Gtk.Button button;
- PropertyDescriptor prop;
- object obj;
-
- public TextEditor()
- {
- Spacing = 3;
- entry = new Entry ();
- entry.HasFrame = false;
- PackStart (entry, true, true, 0);
- button = new Button ("...");
- button.Relief = ReliefStyle.Half;
- PackStart (button, false, false, 0);
- button.Clicked += ButtonClicked;
- entry.Activated += TextChanged;
- ShowAll ();
- }
-
- void ButtonClicked (object s, EventArgs a)
- {
- using (TextEditorDialog dlg = new TextEditorDialog ()) {
- dlg.Text = entry.Text;
- dlg.SetTranslatable (prop.Translatable);
- dlg.TransientFor = this.Toplevel as Gtk.Window;
- if (prop.Translatable) {
- dlg.Translated = prop.IsTranslated (obj);
- dlg.ContextHint = prop.TranslationContext (obj);
- dlg.Comment = prop.TranslationComment (obj);
- }
- if (dlg.Run () == (int) ResponseType.Ok) {
- if (prop.Translatable) {
- prop.SetTranslated (obj, dlg.Translated);
- if (dlg.Translated) {
- prop.SetTranslationComment (obj, dlg.Comment);
- prop.SetTranslationContext (obj, dlg.ContextHint);
- }
- }
- entry.Text = dlg.Text;
- TextChanged (null, null);
- }
- }
- }
-
- void TextChanged (object s, EventArgs a)
- {
- if (ValueChanged != null)
- ValueChanged (this, a);
- }
-
- public void Initialize (PropertyDescriptor descriptor)
- {
- if (descriptor.PropertyType != typeof(string))
- throw new InvalidOperationException ("TextEditor only can edit string properties");
- prop = descriptor;
- }
-
- public void AttachObject (object obj)
- {
- this.obj = obj;
- }
-
- // Gets/Sets the value of the editor. If the editor supports
- // several value types, it is the responsibility of the editor
- // to return values with the expected type.
- public object Value {
- get { return entry.Text; }
- set { entry.Text = value != null ? (string) value : ""; }
- }
-
- // To be fired when the edited value changes.
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextEditorDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextEditorDialog.cs
deleted file mode 100644
index b7df291eab..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TextEditorDialog.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-
-using System;
-
-namespace Stetic.Editor
-{
- public class TextEditorDialog: IDisposable
- {
- [Glade.Widget] Gtk.TextView textview;
- [Glade.Widget] Gtk.CheckButton checkTranslatable;
- [Glade.Widget] Gtk.Entry entryContext;
- [Glade.Widget] Gtk.Entry entryComment;
- [Glade.Widget] Gtk.Table translationTable;
- [Glade.Widget ("TextEditorDialog")] Gtk.Dialog dialog;
-
- public TextEditorDialog ()
- {
- Glade.XML xml = new Glade.XML (null, "stetic.glade", "TextEditorDialog", null);
- xml.Autoconnect (this);
- entryContext.Sensitive = entryComment.Sensitive = false;
- }
-
- public string Text {
- get { return textview.Buffer.Text; }
- set { textview.Buffer.Text = value; }
- }
-
- public string ContextHint {
- get { return entryContext.Text; }
- set { entryContext.Text = value != null ? value : ""; }
- }
-
- public string Comment {
- get { return entryComment.Text; }
- set { entryComment.Text = value != null ? value : ""; }
- }
-
- public bool Translated {
- get { return checkTranslatable.Active; }
- set { checkTranslatable.Active = value; }
- }
-
- public Gtk.Window TransientFor {
- set { dialog.TransientFor = value; }
- }
-
- public void SetTranslatable (bool translatable)
- {
- if (!translatable) {
- translationTable.Visible = false;
- checkTranslatable.Visible = false;
- }
- }
-
- protected void OnTranslatableToggled (object s, EventArgs a)
- {
- entryContext.Sensitive = checkTranslatable.Active;
- entryComment.Sensitive = checkTranslatable.Active;
- }
-
- public int Run ()
- {
- return dialog.Run ();
- }
-
- public void Dispose ()
- {
- dialog.Destroy ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ThemedIcon.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ThemedIcon.cs
deleted file mode 100644
index 3da369f94c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ThemedIcon.cs
+++ /dev/null
@@ -1,162 +0,0 @@
-using Gtk;
-using System;
-
-namespace Stetic.Editor {
-
- [PropertyEditor ("Value", "Changed")]
- public class ThemedIcon : Gtk.HBox, IPropertyEditor {
- Gtk.Image image;
- Gtk.Entry entry;
- Gtk.Button button;
-
- public ThemedIcon () : base (false, 6)
- {
- image = new Gtk.Image (GnomeStock.Blank, Gtk.IconSize.Button);
- PackStart (image, false, false, 0);
-
- entry = new Gtk.Entry ();
- PackStart (entry, true, true, 0);
- entry.Changed += entry_Changed;
-
- button = new Gtk.Button ("...");
- PackStart (button, false, false, 0);
- button.Clicked += button_Clicked;
- }
-
- public void Initialize (PropertyDescriptor prop)
- {
- if (prop.PropertyType != typeof(string))
- throw new ApplicationException ("ThemedIcon editor does not support editing values of type " + prop.PropertyType);
- }
-
- public void AttachObject (object ob)
- {
- }
-
- public event EventHandler ValueChanged;
-
- bool syncing;
-
- void entry_Changed (object obj, EventArgs args)
- {
- if (!syncing)
- Value = entry.Text;
- }
-
- void button_Clicked (object obj, EventArgs args)
- {
- Gtk.Window parent = (Gtk.Window)GetAncestor (Gtk.Window.GType);
- Value = ThemedIconBrowser.Browse (parent, (string) Value);
- }
-
- string icon;
- public object Value {
- get {
- return icon;
- }
- set {
- string val = (string) value;
- if (icon == val)
- return;
-
- icon = val;
- Gdk.Pixbuf pix = WidgetUtils.LoadIcon (icon, Gtk.IconSize.Menu);
- if (pix != null) {
- image.Pixbuf = pix;
- } else {
- image.Stock = GnomeStock.Blank;
- }
-
- syncing = true;
- entry.Text = icon;
- syncing = false;
-
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
- }
- }
-
- public class ThemedIconBrowser : Gtk.Dialog {
-
- public ThemedIconBrowser (Gtk.Window parent) :
- base ("Select a Themed Icon", parent, Gtk.DialogFlags.Modal,
- Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
- Gtk.Stock.Ok, Gtk.ResponseType.Ok)
- {
- HasSeparator = false;
- BorderWidth = 12;
- VBox.Spacing = 18;
- VBox.BorderWidth = 0;
-
- DefaultResponse = Gtk.ResponseType.Ok;
-
- Gtk.HBox hbox = new Gtk.HBox (false, 12);
- VBox.PackStart (hbox, false, false, 0);
-
- entry = new Gtk.Entry ();
- entry.Activated += DoFind;
- hbox.PackStart (entry);
-
- Gtk.Button button = new Gtk.Button (Gtk.Stock.Find);
- button.Clicked += DoFind;
- hbox.PackStart (button, false, false, 0);
-
- ScrolledWindow scwin = new Gtk.ScrolledWindow ();
- scwin.SizeRequested += ScrolledWindowSizeRequested;
- VBox.PackStart (scwin, true, true, 0);
- scwin.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Automatic);
- scwin.ShadowType = Gtk.ShadowType.In;
-
- list = new ThemedIconList ();
- scwin.Add (list);
- list.SelectionChanged += ListSelectionChanged;
- list.Activated += ListActivated;
- SetResponseSensitive (Gtk.ResponseType.Ok, false);
-
- VBox.ShowAll ();
- }
-
- public static string Browse (Gtk.Window parent, string selection)
- {
- ThemedIconBrowser browser = new ThemedIconBrowser (parent);
- browser.list.Selection = selection;
- int response = browser.Run ();
- if (response == (int)Gtk.ResponseType.Ok)
- selection = browser.list.Selection;
- browser.Destroy ();
- return selection;
- }
-
- Gtk.Entry entry;
- ThemedIconList list;
-
- void ScrolledWindowSizeRequested (object obj, SizeRequestedArgs args)
- {
- Gtk.Requisition req = list.SizeRequest ();
- if (req.Width <= 0)
- return;
-
- Gtk.ScrolledWindow scwin = ((Gtk.ScrolledWindow)obj);
- scwin.SizeRequested -= ScrolledWindowSizeRequested;
- scwin.SetSizeRequest (req.Width, req.Width * 2 / 3);
- ActionArea.BorderWidth = 0; // has to happen post-realize
- }
-
- void ListSelectionChanged (object obj, EventArgs args)
- {
- SetResponseSensitive (Gtk.ResponseType.Ok, list.Selection != null);
- }
-
- void ListActivated (object obj, EventArgs args)
- {
- Respond (Gtk.ResponseType.Ok);
- }
-
- void DoFind (object obj, EventArgs args)
- {
- list.Find (entry.Text);
- }
-
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ThemedIconList.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ThemedIconList.cs
deleted file mode 100644
index dd1dc1a12b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/ThemedIconList.cs
+++ /dev/null
@@ -1,1018 +0,0 @@
-
-using System;
-using System.Collections;
-using Gtk;
-
-namespace Stetic.Editor
-{
- class ThemedIconList : IconList
- {
- public ThemedIconList ()
- {
- Gtk.IconTheme theme = Gtk.IconTheme.Default;
- foreach (string icon in ThemeIconNames)
- AddIcon (icon, GetPixbuf (theme, icon), icon);
- }
-
- Gdk.Pixbuf GetPixbuf (Gtk.IconTheme theme, string name)
- {
- try {
- return theme.LoadIcon (name, 16, 0);
- } catch {
- return RenderIcon (name, Gtk.IconSize.Menu, null);
- }
- }
-
- public static string[] ThemeIconNames = new string[] {
- // Gtk 2.6 stock icons
- "gtk-about",
- "gtk-add",
- "gtk-apply",
- "gtk-bold",
- "gtk-cancel",
- "gtk-cdrom",
- "gtk-clear",
- "gtk-close",
- "gtk-color-picker",
- "gtk-connect",
- "gtk-convert",
- "gtk-copy",
- "gtk-cut",
- "gtk-delete",
- "gtk-dialog-authentication",
- "gtk-dialog-error",
- "gtk-dialog-info",
- "gtk-dialog-question",
- "gtk-dialog-warning",
- "gtk-directory",
- "gtk-disconnect",
- "gtk-dnd",
- "gtk-dnd-multiple",
- "gtk-edit",
- "gtk-execute",
- "gtk-file",
- "gtk-find",
- "gtk-find-and-replace",
- "gtk-floppy",
- "gtk-go-back",
- "gtk-go-down",
- "gtk-go-forward",
- "gtk-go-up",
- "gtk-goto-bottom",
- "gtk-goto-first",
- "gtk-goto-last",
- "gtk-goto-top",
- "gtk-harddisk",
- "gtk-help",
- "gtk-home",
- "gtk-indent",
- "gtk-index",
- "gtk-italic",
- "gtk-jump-to",
- "gtk-justify-center",
- "gtk-justify-fill",
- "gtk-justify-left",
- "gtk-justify-right",
- "gtk-media-forward",
- "gtk-media-next",
- "gtk-media-pause",
- "gtk-media-play",
- "gtk-media-previous",
- "gtk-media-record",
- "gtk-media-rewind",
- "gtk-media-stop",
- "gtk-missing-image",
- "gtk-network",
- "gtk-new",
- "gtk-no",
- "gtk-ok",
- "gtk-open",
- "gtk-paste",
- "gtk-preferences",
- "gtk-print",
- "gtk-print-preview",
- "gtk-properties",
- "gtk-quit",
- "gtk-redo",
- "gtk-refresh",
- "gtk-remove",
- "gtk-revert-to-saved",
- "gtk-save",
- "gtk-save-as",
- "gtk-select-color",
- "gtk-select-font",
- "gtk-sort-ascending",
- "gtk-sort-descending",
- "gtk-spell-check",
- "gtk-stop",
- "gtk-strikethrough",
- "gtk-undelete",
- "gtk-underline",
- "gtk-undo",
- "gtk-unindent",
- "gtk-yes",
- "gtk-zoom-100",
- "gtk-zoom-fit",
- "gtk-zoom-in",
- "gtk-zoom-out",
-
- // Themable stock icons
- "stock_about",
- "stock_active",
- "stock_add-bookmark",
- "stock_add-decimal-place",
- "stock_addressbook",
- "stock_advanced-filter",
- "stock_alarm",
- "stock_alignment",
- "stock_alignment-bottom",
- "stock_alignment-centered",
- "stock_alignment-centered-vertically",
- "stock_alignment-left",
- "stock_alignment-right",
- "stock_alignment-top",
- "stock_allow-effects",
- "stock_anchor",
- "stock_animation",
- "stock_appointment-reminder",
- "stock_appointment-reminder-excl",
- "stock_arrowstyle",
- "stock_attach",
- "stock_auto-contour",
- "stock_autocompletion",
- "stock_autofilter",
- "stock_autoformat",
- "stock_autopilot",
- "stock_autopilot-24",
- "stock_autospellcheck",
- "stock_autotext",
- "stock_bell",
- "stock_bluetooth",
- "stock_book_blue",
- "stock_book_green",
- "stock_book_open",
- "stock_book_red",
- "stock_book_yellow",
- "stock_bookmark",
- "stock_bottom",
- "stock_briefcase",
- "stock_brightness",
- "stock_bring-backward",
- "stock_bring-forward",
- "stock_bucketfill",
- "stock_calc-accept",
- "stock_calc-cancel",
- "stock_calendar",
- "stock_calendar-and-tasks",
- "stock_calendar-view-day",
- "stock_calendar-view-list",
- "stock_calendar-view-month",
- "stock_calendar-view-week",
- "stock_calendar-view-work-week",
- "stock_calendar-view-year",
- "stock_cell-align-bottom",
- "stock_cell-align-center",
- "stock_cell-align-top",
- "stock_cell-phone",
- "stock_certificate",
- "stock_channel",
- "stock_channel-blue",
- "stock_channel-green",
- "stock_channel-red",
- "stock_chart",
- "stock_chart-autoformat",
- "stock_chart-data-in-columns",
- "stock_chart-data-in-rows",
- "stock_chart-edit-type",
- "stock_chart-reorganize",
- "stock_chart-scale-text",
- "stock_chart-toggle-axes",
- "stock_chart-toggle-axes-title",
- "stock_chart-toggle-hgrid",
- "stock_chart-toggle-legend",
- "stock_chart-toggle-title",
- "stock_chart-toggle-vgrid",
- "stock_check-filled",
- "stock_choose-themes",
- "stock_close",
- "stock_color",
- "stock_compile",
- "stock_connect",
- "stock_connect-to-url",
- "stock_contact",
- "stock_contact-list",
- "stock_contrast",
- "stock_copy",
- "stock_create-with-attributes",
- "stock_creditcard",
- "stock_crop",
- "stock_cut",
- "stock_data-delete-link",
- "stock_data-delete-query",
- "stock_data-delete-record",
- "stock_data-delete-sql-query",
- "stock_data-delete-table",
- "stock_data-edit-link",
- "stock_data-edit-query",
- "stock_data-edit-sql-query",
- "stock_data-edit-table",
- "stock_data-explorer",
- "stock_data-first",
- "stock_data-last",
- "stock_data-link",
- "stock_data-linked-table",
- "stock_data-links",
- "stock_data-new-link",
- "stock_data-new-query",
- "stock_data-new-record",
- "stock_data-new-sql-query",
- "stock_data-new-table",
- "stock_data-next",
- "stock_data-previous",
- "stock_data-queries",
- "stock_data-query",
- "stock_data-query-rename",
- "stock_data-save",
- "stock_data-sources",
- "stock_data-sources-delete",
- "stock_data-sources-hand",
- "stock_data-sources-modified",
- "stock_data-sources-new",
- "stock_data-table",
- "stock_data-tables",
- "stock_data-undo",
- "stock_datapilot",
- "stock_decrease-font",
- "stock_default-folder",
- "stock_delete",
- "stock_delete-autofilter",
- "stock_delete-bookmark",
- "stock_delete-column",
- "stock_delete-decimal-place",
- "stock_delete-row",
- "stock_dialog-error",
- "stock_dialog-info",
- "stock_dialog-question",
- "stock_dialog-warning",
- "stock_directcursor",
- "stock_directory-server",
- "stock_disconnect",
- "stock_display-grid",
- "stock_display-guides",
- "stock_distort",
- "stock_down",
- "stock_down-with-subpoints",
- "stock_drag-mode",
- "stock_draw-arc",
- "stock_draw-callouts",
- "stock_draw-circle",
- "stock_draw-circle-arc",
- "stock_draw-circle-pie",
- "stock_draw-circle-pie-unfilled",
- "stock_draw-circle-segment",
- "stock_draw-circle-segment-unfilled",
- "stock_draw-circle-unfilled",
- "stock_draw-cone",
- "stock_draw-connector",
- "stock_draw-connector-ends-with-arrow",
- "stock_draw-connector-ends-with-circle",
- "stock_draw-connector-starts-with-arrow",
- "stock_draw-connector-starts-with-circle",
- "stock_draw-connector-with-arrows",
- "stock_draw-connector-with-circles",
- "stock_draw-cube",
- "stock_draw-curve",
- "stock_draw-curve-filled",
- "stock_draw-curved-connector",
- "stock_draw-curved-connector-ends-with-arrow",
- "stock_draw-curved-connector-ends-with-circle",
- "stock_draw-curved-connector-starts-with-arrow",
- "stock_draw-curved-connector-starts-with-circle",
- "stock_draw-curved-connector-with-arrows",
- "stock_draw-curved-connector-with-circles",
- "stock_draw-cylinder",
- "stock_draw-dimension-line",
- "stock_draw-ellipse",
- "stock_draw-ellipse-pie",
- "stock_draw-ellipse-pie-unfilled",
- "stock_draw-ellipse-segment",
- "stock_draw-ellipse-segment-unfilled",
- "stock_draw-ellipse-unfilled",
- "stock_draw-freeform-line",
- "stock_draw-freeform-line-filled",
- "stock_draw-half-sphere",
- "stock_draw-line",
- "stock_draw-line-45",
- "stock_draw-line-connector",
- "stock_draw-line-connector-ends-with-arrow",
- "stock_draw-line-connector-ends-with-circle",
- "stock_draw-line-connector-starts-with-arrow",
- "stock_draw-line-connector-starts-with-circle",
- "stock_draw-line-connector-with-arrows",
- "stock_draw-line-connector-with-circles",
- "stock_draw-line-ends-with-arrow",
- "stock_draw-line-starts-with-arrow",
- "stock_draw-line-with-arrow-circle",
- "stock_draw-line-with-arrow-square",
- "stock_draw-line-with-arrows",
- "stock_draw-line-with-circle-arrow",
- "stock_draw-line-with-square-arrow",
- "stock_draw-polygon",
- "stock_draw-polygon-45",
- "stock_draw-polygon-45-filled",
- "stock_draw-polygon-filled",
- "stock_draw-pyramid",
- "stock_draw-rectangle",
- "stock_draw-rectangle-unfilled",
- "stock_draw-rounded-rectangle",
- "stock_draw-rounded-rectangle-unfilled",
- "stock_draw-rounded-square",
- "stock_draw-rounded-square-unfilled",
- "stock_draw-selection",
- "stock_draw-shell",
- "stock_draw-sphere",
- "stock_draw-square",
- "stock_draw-square-unfilled",
- "stock_draw-straight-connector",
- "stock_draw-straight-connector-ends-with-arrow",
- "stock_draw-straight-connector-ends-with-circle",
- "stock_draw-straight-connector-starts-with-arrow",
- "stock_draw-straight-connector-starts-with-circle",
- "stock_draw-straight-connector-with-arrows",
- "stock_draw-straight-connector-with-circles",
- "stock_draw-text",
- "stock_draw-text-animation",
- "stock_draw-text-frame",
- "stock_draw-torus",
- "stock_draw-vertical-callouts",
- "stock_draw-vertical-text",
- "stock_draw-vertical-text-frame",
- "stock_edit",
- "stock_edit-bookmark",
- "stock_edit-contour",
- "stock_edit-headers-and-footers",
- "stock_edit-points",
- "stock_effects",
- "stock_effects-more-options",
- "stock_effects-object",
- "stock_effects-object-colorize",
- "stock_effects-object-hide",
- "stock_effects-play-in-full",
- "stock_effects-preview",
- "stock_effects-sound",
- "stock_effects-text",
- "stock_enter-group",
- "stock_equals",
- "stock_error-next",
- "stock_error-next-16",
- "stock_error-previous",
- "stock_error-previous-16",
- "stock_euro",
- "stock_example",
- "stock_exchange-columns",
- "stock_exchange-connector",
- "stock_exchange-rows",
- "stock_exit",
- "stock_exit-group",
- "stock_export",
- "stock_extended-help",
- "stock_file-properties",
- "stock_file-with-objects",
- "stock_filter-data-by-criteria",
- "stock_filter-navigator",
- "stock_filters",
- "stock_filters-aging",
- "stock_filters-charcoal",
- "stock_filters-invert",
- "stock_filters-pixelize",
- "stock_filters-pop-art",
- "stock_filters-posterize",
- "stock_filters-relief",
- "stock_filters-remove-noise",
- "stock_filters-sharpen",
- "stock_filters-smooth",
- "stock_filters-solarize",
- "stock_first",
- "stock_first-page",
- "stock_flip",
- "stock_flip-horizontally",
- "stock_flip-vertically",
- "stock_folder",
- "stock_folder-copy",
- "stock_folder-move",
- "stock_folder-properties",
- "stock_font",
- "stock_font-formatting-toggle",
- "stock_font-size",
- "stock_fontwork",
- "stock_fontwork-2dshadow",
- "stock_fontwork-3dshadow",
- "stock_fontwork-adaptation-off",
- "stock_fontwork-adaptation-rotate",
- "stock_fontwork-adaptation-slant-h",
- "stock_fontwork-adaptation-slant-v",
- "stock_fontwork-adaptation-straight",
- "stock_fontwork-align-fill",
- "stock_fontwork-noshadow",
- "stock_fontwork-preview-spline",
- "stock_fontwork-reverse-text-flow",
- "stock_fontwork-shadow-angle",
- "stock_fontwork-shadow-length",
- "stock_fontwork-shadow-x-offset",
- "stock_fontwork-shadow-y-offset",
- "stock_fontwork-spline-distance",
- "stock_fontwork-spline-indent",
- "stock_fontwork-text-border",
- "stock_form-activation-order",
- "stock_form-add-field",
- "stock_form-automatic-control-focus",
- "stock_form-autopilots",
- "stock_form-button",
- "stock_form-checkbox",
- "stock_form-combobox",
- "stock_form-control-properties",
- "stock_form-currency-field",
- "stock_form-date-field",
- "stock_form-design-mode",
- "stock_form-file-selection",
- "stock_form-formatted-field",
- "stock_form-frame",
- "stock_form-image-button",
- "stock_form-image-control",
- "stock_form-label",
- "stock_form-letter-dialog",
- "stock_form-line-horizontal",
- "stock_form-line-vertical",
- "stock_form-listbox",
- "stock_form-navigator",
- "stock_form-numerical-field",
- "stock_form-open-in-design-mode",
- "stock_form-pattern-field",
- "stock_form-progressbar",
- "stock_form-properties",
- "stock_form-radio",
- "stock_form-table-control",
- "stock_form-text-box",
- "stock_form-time-field",
- "stock_format-character",
- "stock_format-default",
- "stock_format-numbering-bullets",
- "stock_format-object",
- "stock_format-page",
- "stock_format-paragraph",
- "stock_format-percent",
- "stock_format-scientific",
- "stock_formula-cursor",
- "stock_frame",
- "stock_fullscreen",
- "stock_function-autopilot",
- "stock_gamma",
- "stock_glue",
- "stock_gluepoint-down",
- "stock_gluepoint-horizontal-center",
- "stock_gluepoint-horizontal-left",
- "stock_gluepoint-horizontal-right",
- "stock_gluepoint-left",
- "stock_gluepoint-relative",
- "stock_gluepoint-right",
- "stock_gluepoint-up",
- "stock_gluepoint-vertical-bottom",
- "stock_gluepoint-vertical-center",
- "stock_gluepoint-vertical-top",
- "stock_goal-seek",
- "stock_gradient",
- "stock_graphic-styles",
- "stock_graphics-align-bottom",
- "stock_graphics-align-center",
- "stock_graphics-align-centered",
- "stock_graphics-align-left",
- "stock_graphics-align-right",
- "stock_graphics-align-top",
- "stock_group",
- "stock_group-cells",
- "stock_groupwise-connector",
- "stock_guides",
- "stock_hand-signed",
- "stock_handles-big",
- "stock_handles-simple",
- "stock_headphones",
- "stock_help",
- "stock_help-add-bookmark",
- "stock_help-agent",
- "stock_help-book",
- "stock_help-book-open",
- "stock_help-chat",
- "stock_help-document",
- "stock_help-pane-off",
- "stock_help-pane-on",
- "stock_home",
- "stock_hyperlink",
- "stock_hyperlink-internet-search",
- "stock_hyperlink-target",
- "stock_hyperlink-toolbar",
- "stock_id",
- "stock_imagemap-editor",
- "stock_inbox",
- "stock_increase-font",
- "stock_init",
- "stock_insert-applet",
- "stock_insert-caption",
- "stock_insert-cells",
- "stock_insert-cells-down",
- "stock_insert-cells-right",
- "stock_insert-chart",
- "stock_insert-columns",
- "stock_insert-cross-reference",
- "stock_insert-fields",
- "stock_insert-fields-author",
- "stock_insert-fields-subject",
- "stock_insert-fields-title",
- "stock_insert-file",
- "stock_insert-floating-frame",
- "stock_insert-footer",
- "stock_insert-form",
- "stock_insert-gluepoint",
- "stock_insert-header",
- "stock_insert-math-object",
- "stock_insert-names-define",
- "stock_insert-note",
- "stock_insert-ole-object",
- "stock_insert-plugin",
- "stock_insert-rows",
- "stock_insert-rule",
- "stock_insert-single-column-text-frame",
- "stock_insert-slide",
- "stock_insert-sound-plugin",
- "stock_insert-table",
- "stock_insert-text-frame",
- "stock_insert-url",
- "stock_insert-video-plugin",
- "stock_insert_endnote",
- "stock_insert_footnote",
- "stock_insert_graphic",
- "stock_insert_image",
- "stock_insert_index_marker",
- "stock_insert_section",
- "stock_insert_special_character",
- "stock_interaction",
- "stock_internet",
- "stock_keyring",
- "stock_landline-phone",
- "stock_last",
- "stock_last-page",
- "stock_left",
- "stock_left-with-subpoints",
- "stock_line-spacing-1",
- "stock_line-spacing-1.5",
- "stock_line-spacing-2",
- "stock_line_in",
- "stock_linepen",
- "stock_link",
- "stock_list-insert-unnumbered",
- "stock_list_bullet",
- "stock_list_enum",
- "stock_list_enum-off",
- "stock_list_enum-restart",
- "stock_live-mode",
- "stock_lock",
- "stock_lock-broken",
- "stock_lock-ok",
- "stock_lock-open",
- "stock_macro-check-brackets",
- "stock_macro-controls",
- "stock_macro-insert",
- "stock_macro-insert-breakpoint",
- "stock_macro-jump-back",
- "stock_macro-objects",
- "stock_macro-organizer",
- "stock_macro-stop-after-command",
- "stock_macro-stop-after-procedure",
- "stock_macro-stop-watching",
- "stock_macro-watch-variable",
- "stock_mail",
- "stock_mail-accounts",
- "stock_mail-compose",
- "stock_mail-copy",
- "stock_mail-druid",
- "stock_mail-druid-account",
- "stock_mail-filters-apply",
- "stock_mail-flag-for-followup",
- "stock_mail-flag-for-followup-done",
- "stock_mail-forward",
- "stock_mail-handling",
- "stock_mail-hide-deleted",
- "stock_mail-hide-read",
- "stock_mail-hide-selected",
- "stock_mail-import",
- "stock_mail-merge",
- "stock_mail-move",
- "stock_mail-open",
- "stock_mail-open-multiple",
- "stock_mail-priority-high",
- "stock_mail-receive",
- "stock_mail-replied",
- "stock_mail-reply",
- "stock_mail-reply-to-all",
- "stock_mail-send",
- "stock_mail-send-receive",
- "stock_mail-unread",
- "stock_mail-unread-multiple",
- "stock_mark",
- "stock_media-fwd",
- "stock_media-next",
- "stock_media-pause",
- "stock_media-play",
- "stock_media-prev",
- "stock_media-rec",
- "stock_media-rew",
- "stock_media-shuffle",
- "stock_media-stop",
- "stock_message-display",
- "stock_mic",
- "stock_midi",
- "stock_modify-layout",
- "stock_music-library",
- "stock_my-documents",
- "stock_navigate-next",
- "stock_navigate-prev",
- "stock_navigator",
- "stock_navigator-all-or-sel-toggle",
- "stock_navigator-database-ranges",
- "stock_navigator-drag-mode",
- "stock_navigator-edit-entry",
- "stock_navigator-foonote-body-toggle",
- "stock_navigator-footer-body-toggle",
- "stock_navigator-header-body-toggle",
- "stock_navigator-headings",
- "stock_navigator-indexes",
- "stock_navigator-insert-as-copy",
- "stock_navigator-insert-as-link",
- "stock_navigator-insert-index",
- "stock_navigator-insert-linked",
- "stock_navigator-levels",
- "stock_navigator-list-box-toggle",
- "stock_navigator-master-toggle",
- "stock_navigator-next-object",
- "stock_navigator-open-toolbar",
- "stock_navigator-previous-object",
- "stock_navigator-range-names",
- "stock_navigator-references",
- "stock_navigator-reminder",
- "stock_navigator-scenarios",
- "stock_navigator-sections",
- "stock_navigator-shift-down",
- "stock_navigator-shift-left",
- "stock_navigator-shift-right",
- "stock_navigator-shift-up",
- "stock_navigator-table-formula",
- "stock_navigator-text",
- "stock_navigator-update-entry",
- "stock_navigator-wrong-table-formula",
- "stock_network-printer",
- "stock_new",
- "stock_new",
- "stock_new-24h-appointment",
- "stock_new-appointment",
- "stock_new-bcard",
- "stock_new-dir",
- "stock_new-drawing",
- "stock_new-formula",
- "stock_new-html",
- "stock_new-labels",
- "stock_new-master-document",
- "stock_new-meeting",
- "stock_new-presentation",
- "stock_new-spreadsheet",
- "stock_new-tab",
- "stock_new-template",
- "stock_new-text",
- "stock_new-window",
- "stock_news",
- "stock_next",
- "stock_next-page",
- "stock_node-add",
- "stock_node-close-path",
- "stock_node-convert",
- "stock_node-corner",
- "stock_node-corner-to-smooth",
- "stock_node-curve-split",
- "stock_node-delete",
- "stock_node-mark-for-deletion",
- "stock_node-move",
- "stock_node-smooth-to-symmetrical",
- "stock_nonprinting-chars",
- "stock_not",
- "stock_not-spam",
- "stock_notebook",
- "stock_notes",
- "stock_object-behind",
- "stock_object-infront",
- "stock_online-layout",
- "stock_open",
- "stock_open-read-only",
- "stock_openoffice",
- "stock_opensave",
- "stock_outbox",
- "stock_page-number",
- "stock_page-total-number",
- "stock_paragraph-spacing-decrease",
- "stock_paragraph-spacing-increase",
- "stock_paste",
- "stock_people",
- "stock_person",
- "stock_pin",
- "stock_placeholder-graphic",
- "stock_placeholder-line-contour",
- "stock_placeholder-picture",
- "stock_placeholder-text",
- "stock_playlist",
- "stock_position-size",
- "stock_post-message",
- "stock_presentation-box",
- "stock_presentation-styles",
- "stock_preview-four-pages",
- "stock_preview-two-pages",
- "stock_previous",
- "stock_previous-page",
- "stock_print",
- "stock_print-driver",
- "stock_print-duplex",
- "stock_print-duplex-no-tumble",
- "stock_print-duplex-tumble",
- "stock_print-layout",
- "stock_print-non-duplex",
- "stock_print-options",
- "stock_print-preview",
- "stock_print-preview-print",
- "stock_print-resolution",
- "stock_print-setup",
- "stock_printers",
- "stock_properties",
- "stock_proxy",
- "stock_quickmask",
- "stock_record-macro",
- "stock_record-number",
- "stock_redo",
- "stock_refresh",
- "stock_reload",
- "stock_repeat",
- "stock_reverse-order",
- "stock_right",
- "stock_right-with-subpoints",
- "stock_rotate",
- "stock_rotate-3d",
- "stock_rotation-mode",
- "stock_run-macro",
- "stock_samples",
- "stock_save",
- "stock_save-as",
- "stock_save-pdf",
- "stock_save-template",
- "stock_save_as",
- "stock_score-high",
- "stock_score-higher",
- "stock_score-highest",
- "stock_score-low",
- "stock_score-lower",
- "stock_score-lowest",
- "stock_score-normal",
- "stock_scores",
- "stock_script",
- "stock_script",
- "stock_scripts",
- "stock_search",
- "stock_search-and-replace",
- "stock_select-all",
- "stock_select-cell",
- "stock_select-column",
- "stock_select-row",
- "stock_select-table",
- "stock_send-fax",
- "stock_sent-mail",
- "stock_shadow",
- "stock_show-all",
- "stock_show-draw-functions",
- "stock_show-form-dialog",
- "stock_show-hidden-controls",
- "stock_shuffle",
- "stock_signature",
- "stock_signature-bad",
- "stock_signature-ok",
- "stock_slide-design",
- "stock_slide-duplicate",
- "stock_slide-expand",
- "stock_slide-reherse-timings",
- "stock_slide-show",
- "stock_slide-showhide",
- "stock_smart-playlist",
- "stock_smiley-1",
- "stock_smiley-2",
- "stock_smiley-3",
- "stock_smiley-4",
- "stock_smiley-5",
- "stock_smiley-6",
- "stock_smiley-7",
- "stock_smiley-8",
- "stock_smiley-9",
- "stock_smiley-10",
- "stock_smiley-11",
- "stock_smiley-12",
- "stock_smiley-13",
- "stock_smiley-14",
- "stock_smiley-15",
- "stock_smiley-16",
- "stock_smiley-17",
- "stock_smiley-18",
- "stock_smiley-19",
- "stock_smiley-20",
- "stock_smiley-21",
- "stock_smiley-22",
- "stock_smiley-23",
- "stock_smiley-24",
- "stock_smiley-25",
- "stock_smiley-26",
- "stock_snap-grid",
- "stock_snap-guides",
- "stock_snap-margins",
- "stock_snap-object",
- "stock_snap-object-points",
- "stock_sort-ascending",
- "stock_sort-column-ascending",
- "stock_sort-criteria",
- "stock_sort-descending",
- "stock_sort-row-ascending",
- "stock_sort-table-column-ascending",
- "stock_sort-table-row-ascending",
- "stock_sound",
- "stock_spam",
- "stock_spellcheck",
- "stock_standard-filter",
- "stock_stop",
- "stock_styles",
- "stock_styles-character-styles",
- "stock_styles-fill-format-mode",
- "stock_styles-frame-styles",
- "stock_styles-new-style-from-selection",
- "stock_styles-numbering-styles",
- "stock_styles-page-styles",
- "stock_styles-paragraph-styles",
- "stock_styles-update-style",
- "stock_subscript",
- "stock_sum",
- "stock_summary",
- "stock_superscript",
- "stock_symbol-selection",
- "stock_table-align-bottom",
- "stock_table-align-center",
- "stock_table-align-top",
- "stock_table-borders",
- "stock_table-combine",
- "stock_table-fit-height",
- "stock_table-fit-width",
- "stock_table-fixed",
- "stock_table-fixed-proportional",
- "stock_table-line-color",
- "stock_table-line-style",
- "stock_table-optimize",
- "stock_table-same-height",
- "stock_table-same-width",
- "stock_table-split",
- "stock_table-variable",
- "stock_table_borders",
- "stock_table_fill",
- "stock_task",
- "stock_task-assigned",
- "stock_task-assigned-to",
- "stock_task-recurring",
- "stock_test-mode",
- "stock_text-direction-ltr",
- "stock_text-direction-ttb",
- "stock_text-double-click-to-edit",
- "stock_text-monospaced",
- "stock_text-outline",
- "stock_text-quickedit",
- "stock_text-select-text-only",
- "stock_text-shadow",
- "stock_text-spacing",
- "stock_text-strikethrough",
- "stock_text_bold",
- "stock_text_center",
- "stock_text_color_background",
- "stock_text_color_foreground",
- "stock_text_color_hilight",
- "stock_text_indent",
- "stock_text_italic",
- "stock_text_justify",
- "stock_text_left",
- "stock_text_right",
- "stock_text_underlined",
- "stock_text_underlined-double",
- "stock_text_unindent",
- "stock_thesaurus",
- "stock_3d-3d-attributes-only",
- "stock_3d-all-attributes",
- "stock_3d-color-picker",
- "stock_3d-colors",
- "stock_3d-custom-color",
- "stock_3d-effects",
- "stock_3d-favourites",
- "stock_3d-geometry",
- "stock_3d-light",
- "stock_3d-off",
- "stock_3d-on",
- "stock_3d-material",
- "stock_3d-normals-double-sided",
- "stock_3d-normals-double-sided-closed-body",
- "stock_3d-normals-flat",
- "stock_3d-normals-flip-illumination",
- "stock_3d-normals-object-specific",
- "stock_3d-normals-spherical",
- "stock_3d-perspective",
- "stock_3d-shading",
- "stock_3d-texture",
- "stock_3d-texture-and-shading",
- "stock_3d-texture-object-specific",
- "stock_3d-texture-only",
- "stock_3d-texture-parallel",
- "stock_3d-texture-spherical",
- "stock_3dsound",
- "stock_timer",
- "stock_timer_stopped",
- "stock_timezone",
- "stock_to-3d",
- "stock_to-3d-rotation-object",
- "stock_to-background",
- "stock_to-bottom",
- "stock_to-curve",
- "stock_to-foreground",
- "stock_to-polygon",
- "stock_to-top",
- "stock_todo",
- "stock_toggle-graphics",
- "stock_toggle-info",
- "stock_toggle-preview",
- "stock_toilet-paper",
- "stock_tools-hyphenation",
- "stock_tools-macro",
- "stock_top",
- "stock_transform-circle-perspective",
- "stock_transform-circle-slant",
- "stock_transparency",
- "stock_trash_full",
- "stock_undelete",
- "stock_undo",
- "stock_undo-history",
- "stock_ungroup",
- "stock_ungroup-cells",
- "stock_unknown",
- "stock_unlink",
- "stock_up",
- "stock_up-one-dir",
- "stock_up-with-subpoints",
- "stock_update-data",
- "stock_update-fields",
- "stock_video-conferencing",
- "stock_view-details",
- "stock_view-field-shadings",
- "stock_view-fields",
- "stock_view-function-selection",
- "stock_view-html-source",
- "stock_volume",
- "stock_wallpaper-center",
- "stock_wallpaper-fill",
- "stock_wallpaper-scale",
- "stock_wallpaper-tile",
- "stock_weather-cloudy",
- "stock_weather-few-clouds",
- "stock_weather-fog",
- "stock_weather-night-clear",
- "stock_weather-night-few-clouds",
- "stock_weather-showers",
- "stock_weather-snow",
- "stock_weather-storm",
- "stock_weather-sunny",
- "stock_web-calendar",
- "stock_web-support",
- "stock_wrap-around",
- "stock_wrap-behind",
- "stock_wrap-contour",
- "stock_wrap-interrupt",
- "stock_wrap-left",
- "stock_wrap-optimal",
- "stock_wrap-right",
- "stock_zoom",
- "stock_zoom-1",
- "stock_zoom-in",
- "stock_zoom-next",
- "stock_zoom-object",
- "stock_zoom-optimal",
- "stock_zoom-out",
- "stock_zoom-page",
- "stock_zoom-page-width",
- "stock_zoom-previous",
- "stock_zoom-shift",
- };
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TimeSpanEditor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TimeSpanEditor.cs
deleted file mode 100644
index fb40194da3..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TimeSpanEditor.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-
-using System;
-using Gtk;
-using Gdk;
-using System.Text;
-
-namespace Stetic.Editor
-{
- public class TimeSpanEditorCell: PropertyEditorCell
- {
- protected override string GetValueText ()
- {
- return ((TimeSpan)Value).ToString ();
- }
-
- protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
- {
- return new TimeSpanEditor ();
- }
- }
-
- public class TimeSpanEditor: Gtk.HBox, IPropertyEditor
- {
- Gtk.Entry entry;
- TimeSpan time;
-
- public TimeSpanEditor()
- {
- entry = new Gtk.Entry ();
- entry.Changed += OnChanged;
- PackStart (entry, true, true, 0);
- ShowAll ();
- }
-
- public void Initialize (PropertyDescriptor descriptor)
- {
- }
-
- public void AttachObject (object ob)
- {
- }
-
- public object Value {
- get { return time; }
- set {
- time = (TimeSpan) value;
- entry.Changed -= OnChanged;
- entry.Text = time.ToString ();
- entry.Changed += OnChanged;
- }
- }
-
- void OnChanged (object o, EventArgs a)
- {
- string s = entry.Text;
-
- try {
- time = TimeSpan.Parse (s);
- if (ValueChanged != null)
- ValueChanged (this, a);
- } catch {
- }
- }
-
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Translatable.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Translatable.cs
deleted file mode 100644
index c04192620f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/Translatable.cs
+++ /dev/null
@@ -1,233 +0,0 @@
-using System;
-
-namespace Stetic.Editor {
-
- public abstract class Translatable : Gtk.VBox, IPropertyEditor {
-
- PropertyDescriptor prop;
- object obj;
-
- Gtk.Box mainHBox, contextBox, commentBox;
- Gtk.Button button;
- Gdk.Pixbuf globe, globe_not;
- Gtk.Image image;
- Gtk.Menu menu;
- Gtk.CheckMenuItem markItem;
- Gtk.MenuItem addContextItem, remContextItem, addCommentItem, remCommentItem;
- Gtk.Entry contextEntry;
- TextBox commentText;
- bool initializing;
-
- public virtual void Initialize (PropertyDescriptor prop)
- {
- CheckType (prop);
-
- this.prop = prop;
-
- mainHBox = new Gtk.HBox (false, 6);
- PackStart (mainHBox, false, false, 0);
-
- if (!prop.Translatable)
- return;
-
- button = new Gtk.Button ();
- try {
- globe = Gdk.Pixbuf.LoadFromResource ("globe.png");
- globe_not = Gdk.Pixbuf.LoadFromResource ("globe-not.png");
- } catch (Exception e) {
- Console.WriteLine ("Error while loading pixbuf: " + e);
- }
- image = new Gtk.Image (globe);
- button.Add (image);
- button.ButtonPressEvent += ButtonPressed;
- mainHBox.PackEnd (button, false, false, 0);
- mainHBox.ShowAll ();
-
- menu = new Gtk.Menu ();
-
- markItem = new Gtk.CheckMenuItem ("Mark for Translation");
- markItem.Toggled += ToggleMark;
- markItem.Show ();
- menu.Add (markItem);
-
- addContextItem = new Gtk.MenuItem ("Add Translation Context Hint");
- addContextItem.Activated += AddContext;
- menu.Add (addContextItem);
- remContextItem = new Gtk.MenuItem ("Remove Translation Context Hint");
- remContextItem.Activated += RemoveContext;
- menu.Add (remContextItem);
-
- addCommentItem = new Gtk.MenuItem ("Add Comment for Translators");
- addCommentItem.Activated += AddComment;
- menu.Add (addCommentItem);
- remCommentItem = new Gtk.MenuItem ("Remove Comment for Translators");
- remCommentItem.Activated += RemoveComment;
- menu.Add (remCommentItem);
-
- contextBox = new Gtk.HBox (false, 6);
- Gtk.Label contextLabel = new Gtk.Label ("Translation context");
- contextLabel.Xalign = 0.0f;
- contextBox.PackStart (contextLabel, false, false, 0);
- contextEntry = new Gtk.Entry ();
- contextEntry.WidthChars = 8;
- contextBox.PackStart (contextEntry, true, true, 0);
- contextBox.ShowAll ();
- contextEntry.Changed += ContextChanged;
-
- commentBox = new Gtk.VBox (false, 3);
- Gtk.Label commentLabel = new Gtk.Label ("Comment for Translators:");
- commentLabel.Xalign = 0.0f;
- commentBox.PackStart (commentLabel, false, false, 0);
- commentText = new TextBox (3);
- commentBox.PackStart (commentText, false, false, 0);
- commentBox.ShowAll ();
- commentText.Changed += CommentChanged;
- }
-
- protected virtual void CheckType (PropertyDescriptor prop)
- {
- }
-
- public virtual void AttachObject (object ob)
- {
- this.obj = ob;
-
- if (!prop.Translatable)
- return;
-
- initializing = true;
-
- if (contextBox.Parent != null)
- Remove (contextBox);
- if (commentBox.Parent != null)
- Remove (commentBox);
-
- markItem.Active = prop.IsTranslated (obj);
- image.Pixbuf = markItem.Active ? globe : globe_not;
-
- if (prop.IsTranslated (obj)) {
- if (prop.TranslationContext (obj) != null) {
- remContextItem.Show ();
- PackStart (contextBox, false, false, 0);
- contextEntry.Text = prop.TranslationContext (obj);
- } else
- addContextItem.Show ();
- } else {
- addContextItem.Show ();
- addContextItem.Sensitive = false;
- }
-
- if (prop.IsTranslated (obj)) {
- if (prop.TranslationComment (obj) != null) {
- remCommentItem.Show ();
- PackEnd (commentBox, false, false, 0);
- commentText.Text = prop.TranslationComment (obj);
- } else
- addCommentItem.Show ();
- } else {
- addCommentItem.Show ();
- addCommentItem.Sensitive = false;
- }
-
- initializing = false;
- }
-
-
- public abstract object Value { get; set; }
-
- public event EventHandler ValueChanged;
-
- protected virtual void OnValueChanged ()
- {
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- protected override void OnAdded (Gtk.Widget child)
- {
- mainHBox.PackStart (child, true, true, 0);
- }
-
- void MenuPosition (Gtk.Menu menu, out int x, out int y, out bool push_in)
- {
- button.GdkWindow.GetOrigin (out x, out y);
- Gdk.Rectangle alloc = button.Allocation;
- x += alloc.X;
- y += alloc.Y + alloc.Height;
- push_in = true;
- }
-
- [GLib.ConnectBefore]
- void ButtonPressed (object o, Gtk.ButtonPressEventArgs args)
- {
- menu.Popup (null, null, MenuPosition, 1, args.Event.Time);
- args.RetVal = true;
- }
-
- void ToggleMark (object o, EventArgs args)
- {
- if (initializing) return;
- if (!markItem.Active) {
- // Make sure we're showing the "Add" menu items
- // rather than the "Remove" ones
- if (prop.TranslationContext (obj) != null)
- RemoveContext (remContextItem, EventArgs.Empty);
- if (prop.TranslationComment (obj) != null)
- RemoveComment (remCommentItem, EventArgs.Empty);
- }
-
- prop.SetTranslated (obj, markItem.Active);
- image.Pixbuf = markItem.Active ? globe : globe_not;
- addContextItem.Sensitive = markItem.Active;
- addCommentItem.Sensitive = markItem.Active;
- }
-
- void AddContext (object o, EventArgs args)
- {
- prop.SetTranslationContext (obj, contextEntry.Text);
- PackStart (contextBox, false, false, 0);
-
- addContextItem.Hide ();
- remContextItem.Show ();
- }
-
- void RemoveContext (object o, EventArgs args)
- {
- prop.SetTranslationContext (obj, null);
- Remove (contextBox);
-
- remContextItem.Hide ();
- addContextItem.Show ();
- }
-
- void ContextChanged (object o, EventArgs args)
- {
- if (initializing) return;
- prop.SetTranslationContext (obj, contextEntry.Text);
- }
-
- void AddComment (object o, EventArgs args)
- {
- prop.SetTranslationComment (obj, commentText.Text);
- PackEnd (commentBox, false, false, 0);
-
- addCommentItem.Hide ();
- remCommentItem.Show ();
- }
-
- void RemoveComment (object o, EventArgs args)
- {
- prop.SetTranslationComment (obj, null);
- Remove (commentBox);
-
- remCommentItem.Hide ();
- addCommentItem.Show ();
- }
-
- void CommentChanged (object o, EventArgs args)
- {
- if (initializing) return;
- prop.SetTranslationComment (obj, commentText.Text);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TreeViewCellContainer.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TreeViewCellContainer.cs
deleted file mode 100644
index c027a02986..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/TreeViewCellContainer.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// TreeViewCellContainer.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-using System;
-using Gtk;
-using Gdk;
-
-namespace Stetic.Editor
-{
- class TreeViewCellContainer: Entry
- {
- EventBox box;
-
- public TreeViewCellContainer (Gtk.Widget child)
- {
- box = new EventBox ();
- box.ButtonPressEvent += new ButtonPressEventHandler (OnClickBox);
- box.ModifyBg (StateType.Normal, Style.White);
- box.Add (child);
- child.Show ();
- Show ();
- }
-
- [GLib.ConnectBefore]
- void OnClickBox (object s, ButtonPressEventArgs args)
- {
- // Avoid forwarding the button press event to the
- // tree, since it would hide the cell editor.
- args.RetVal = true;
- }
-
- protected override void OnParentSet (Gtk.Widget parent)
- {
- base.OnParentSet (parent);
-
- if (Parent != null) {
- if (ParentWindow != null)
- box.ParentWindow = ParentWindow;
- box.Parent = Parent;
- box.Show ();
- }
- else
- box.Unparent ();
- }
-
- protected override void OnShown ()
- {
- // Do nothing.
- }
-
- protected override void OnSizeAllocated (Gdk.Rectangle allocation)
- {
- base.OnSizeAllocated (allocation);
- box.SizeRequest ();
- box.Allocation = allocation;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/WidgetSelector.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/WidgetSelector.cs
deleted file mode 100644
index 68991a32e6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/editor/WidgetSelector.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-
-using System;
-using System.Collections;
-using Gtk;
-using Gdk;
-
-namespace Stetic.Editor
-{
- public class WidgetSelector: ComboBox, IPropertyEditor
- {
- Gtk.Widget obj;
- ListStore store;
- Hashtable widgets = new Hashtable ();
-
- public void Initialize (PropertyDescriptor descriptor)
- {
- store = new ListStore (typeof(Pixbuf), typeof(string));
- Model = store;
- store.SetSortColumnId (1, SortType.Ascending);
- CellRendererPixbuf crp = new CellRendererPixbuf ();
- CellRendererText crt = new CellRendererText ();
- PackStart (crp, false);
- PackStart (crt, true);
- SetAttributes (crp, "pixbuf", 0);
- SetAttributes (crt, "text", 1);
- }
-
- public void AttachObject (object obj)
- {
- this.obj = obj as Gtk.Widget;
- FillWidgets ();
- }
-
- void FillWidgets ()
- {
- store.Clear ();
- widgets.Clear ();
-
- Stetic.Wrapper.Widget widget = Stetic.Wrapper.Widget.Lookup (obj);
- if (widget == null)
- return;
-
- while (!widget.IsTopLevel)
- widget = widget.ParentWrapper;
-
- store.AppendValues (null, "(None)");
- FillWidgets (widget, 0);
- }
-
- void FillWidgets (Stetic.Wrapper.Widget widget, int level)
- {
- if (!widget.Unselectable) {
- TreeIter iter = store.AppendValues (widget.ClassDescriptor.Icon, widget.Wrapped.Name);
- widgets [widget.Wrapped.Name] = iter;
- }
- Gtk.Container cont = widget.Wrapped as Gtk.Container;
- if (cont != null && widget.ClassDescriptor.AllowChildren) {
- foreach (Gtk.Widget child in cont.AllChildren) {
- Stetic.Wrapper.Widget cwidget = Stetic.Wrapper.Widget.Lookup (child);
- if (cwidget != null)
- FillWidgets (cwidget, level+1);
- }
- }
- }
-
-
- public object Value {
- get {
- if (Active <= 0)
- return null;
- else {
- TreeIter iter;
- if (!GetActiveIter (out iter))
- return null;
- return (string) store.GetValue (iter, 1);
- }
- }
- set {
- if (value == null)
- Active = 0;
- else if (widgets.Contains ((string) value)) {
- TreeIter iter = (TreeIter) widgets [value];
- SetActiveIter (iter);
- }
- }
- }
-
- protected override void OnChanged ()
- {
- base.OnChanged ();
- if (ValueChanged != null)
- ValueChanged (this, EventArgs.Empty);
- }
-
- // To be fired when the edited value changes.
- public event EventHandler ValueChanged;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic.csproj b/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic.csproj
deleted file mode 100644
index 104e2cf3b0..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic.csproj
+++ /dev/null
@@ -1,455 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{90CBA7FD-CB46-4711-97BB-2420DC01F016}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AssemblyName>libstetic2</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <RootNamespace>Stetic</RootNamespace>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.GtkCore2</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Mono.Posix" />
- <Reference Include="System" />
- <Reference Include="System.Xml" />
- <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="Mono.Cairo" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ClassDescriptor.cs" />
- <Compile Include="Clipboard.cs" />
- <Compile Include="CommandDescriptor.cs" />
- <Compile Include="CustomWidget.cs" />
- <Compile Include="DND.cs" />
- <Compile Include="editor\Accelerator.cs" />
- <Compile Include="editor\ActionGroupEditor.cs" />
- <Compile Include="editor\ActionItem.cs" />
- <Compile Include="editor\ActionMenu.cs" />
- <Compile Include="editor\ActionMenuBar.cs" />
- <Compile Include="editor\ActionMenuItem.cs" />
- <Compile Include="editor\ActionToolbar.cs" />
- <Compile Include="editor\ActionToolItem.cs" />
- <Compile Include="editor\Boolean.cs" />
- <Compile Include="editor\CellRendererComboBox.cs" />
- <Compile Include="editor\Char.cs" />
- <Compile Include="editor\Color.cs" />
- <Compile Include="editor\DateTimeEditor.cs" />
- <Compile Include="editor\EditIconDialog.cs" />
- <Compile Include="editor\EditIconFactoryDialog.cs" />
- <Compile Include="editor\Enumeration.cs" />
- <Compile Include="editor\Flags.cs" />
- <Compile Include="editor\FlagsSelectorDialog.cs" />
- <Compile Include="editor\FloatRange.cs" />
- <Compile Include="editor\GroupPicker.cs" />
- <Compile Include="editor\IconList.cs" />
- <Compile Include="editor\IconSelectorItem.cs" />
- <Compile Include="editor\IconSelectorMenu.cs" />
- <Compile Include="editor\IconSelectorMenuItem.cs" />
- <Compile Include="editor\Identifier.cs" />
- <Compile Include="editor\Image.cs" />
- <Compile Include="editor\ImageFile.cs" />
- <Compile Include="editor\ImageSelector.cs" />
- <Compile Include="editor\IntRange.cs" />
- <Compile Include="editor\NonContainerWarningDialog.cs" />
- <Compile Include="editor\OptIntRange.cs" />
- <Compile Include="editor\ProjectIconList.cs" />
- <Compile Include="editor\ProjectIconSelectorItem.cs" />
- <Compile Include="editor\ResponseId.cs" />
- <Compile Include="editor\SelectIconDialog.cs" />
- <Compile Include="editor\SelectImageDialog.cs" />
- <Compile Include="editor\StockIconList.cs" />
- <Compile Include="editor\StockIconSelectorItem.cs" />
- <Compile Include="editor\StockItem.cs" />
- <Compile Include="editor\String.cs" />
- <Compile Include="editor\StringArray.cs" />
- <Compile Include="editor\Text.cs" />
- <Compile Include="editor\TextBox.cs" />
- <Compile Include="editor\TextEditor.cs" />
- <Compile Include="editor\TextEditorDialog.cs" />
- <Compile Include="editor\ThemedIcon.cs" />
- <Compile Include="editor\ThemedIconList.cs" />
- <Compile Include="editor\TimeSpanEditor.cs" />
- <Compile Include="editor\Translatable.cs" />
- <Compile Include="editor\TreeViewCellContainer.cs" />
- <Compile Include="editor\WidgetSelector.cs" />
- <Compile Include="EnumDescriptor.cs" />
- <Compile Include="ErrorWidget.cs" />
- <Compile Include="GeneratorContext.cs" />
- <Compile Include="GladeException.cs" />
- <Compile Include="GladeUtils.cs" />
- <Compile Include="IDesignArea.cs" />
- <Compile Include="IEditableObject.cs" />
- <Compile Include="ImageInfo.cs" />
- <Compile Include="IProject.cs" />
- <Compile Include="IPropertyEditor.cs" />
- <Compile Include="IRadioGroupManager.cs" />
- <Compile Include="IResourceProvider.cs" />
- <Compile Include="ItemDescriptor.cs" />
- <Compile Include="ItemGroup.cs" />
- <Compile Include="ItemGroupCollection.cs" />
- <Compile Include="NoGuiDispatchAttribute.cs" />
- <Compile Include="ObjectReader.cs" />
- <Compile Include="ObjectWrapper.cs" />
- <Compile Include="ObjectWrapperEventHandler.cs" />
- <Compile Include="ObjectWriter.cs" />
- <Compile Include="ParamSpec.cs" />
- <Compile Include="Placeholder.cs" />
- <Compile Include="ProjectIconFactory.cs" />
- <Compile Include="PropertyDescriptor.cs" />
- <Compile Include="PropertyEditorAttribute.cs" />
- <Compile Include="PropertyEditorCell.cs" />
- <Compile Include="RadioGroupManager.cs" />
- <Compile Include="Registry.cs" />
- <Compile Include="Set.cs" />
- <Compile Include="SignalDescriptor.cs" />
- <Compile Include="TranslatableAttribute.cs" />
- <Compile Include="TypedClassDescriptor.cs" />
- <Compile Include="TypedPropertyDescriptor.cs" />
- <Compile Include="TypedSignalDescriptor.cs" />
- <Compile Include="undo\ActionDiffAdaptor.cs" />
- <Compile Include="undo\DiffGenerator.cs" />
- <Compile Include="undo\IDiffAdaptor.cs" />
- <Compile Include="undo\UndoManager.cs" />
- <Compile Include="undo\XmlDiffAdaptor.cs" />
- <Compile Include="WidgetLibrary.cs" />
- <Compile Include="WidgetUtils.cs" />
- <Compile Include="wrapper\Action.cs" />
- <Compile Include="wrapper\ActionGroup.cs" />
- <Compile Include="wrapper\ActionToolbarWrapper.cs" />
- <Compile Include="wrapper\ActionTree.cs" />
- <Compile Include="wrapper\Bin.cs" />
- <Compile Include="wrapper\Box.cs" />
- <Compile Include="wrapper\Button.cs" />
- <Compile Include="wrapper\ButtonBox.cs" />
- <Compile Include="wrapper\CheckButton.cs" />
- <Compile Include="wrapper\ColorButton.cs" />
- <Compile Include="wrapper\ComboBox.cs" />
- <Compile Include="wrapper\ComboBoxEntry.cs" />
- <Compile Include="wrapper\Container.cs" />
- <Compile Include="wrapper\Custom.cs" />
- <Compile Include="wrapper\Dialog.cs" />
- <Compile Include="wrapper\Entry.cs" />
- <Compile Include="wrapper\Expander.cs" />
- <Compile Include="wrapper\Fixed.cs" />
- <Compile Include="wrapper\FontButton.cs" />
- <Compile Include="wrapper\FontSelectionDialog.cs" />
- <Compile Include="wrapper\Frame.cs" />
- <Compile Include="wrapper\HScale.cs" />
- <Compile Include="wrapper\HScrollbar.cs" />
- <Compile Include="wrapper\IconView.cs" />
- <Compile Include="wrapper\Image.cs" />
- <Compile Include="wrapper\ImageMenuItem.cs" />
- <Compile Include="wrapper\Label.cs" />
- <Compile Include="wrapper\MenuBar.cs" />
- <Compile Include="wrapper\MenuItem.cs" />
- <Compile Include="wrapper\MessageDialog.cs" />
- <Compile Include="wrapper\Misc.cs" />
- <Compile Include="wrapper\Notebook.cs" />
- <Compile Include="wrapper\Object.cs" />
- <Compile Include="wrapper\OptionMenu.cs" />
- <Compile Include="wrapper\Paned.cs" />
- <Compile Include="wrapper\RadioActionGroupManager.cs" />
- <Compile Include="wrapper\RadioButton.cs" />
- <Compile Include="wrapper\RadioMenuItem.cs" />
- <Compile Include="wrapper\RadioToolButton.cs" />
- <Compile Include="wrapper\Range.cs" />
- <Compile Include="wrapper\Scale.cs" />
- <Compile Include="wrapper\ScrolledWindow.cs" />
- <Compile Include="wrapper\Signal.cs" />
- <Compile Include="wrapper\SignalChangedEventHandler.cs" />
- <Compile Include="wrapper\SignalCollection.cs" />
- <Compile Include="wrapper\SignalEventHandler.cs" />
- <Compile Include="wrapper\SpinButton.cs" />
- <Compile Include="wrapper\Table.cs" />
- <Compile Include="wrapper\TextView.cs" />
- <Compile Include="wrapper\ToggleToolButton.cs" />
- <Compile Include="wrapper\Toolbar.cs" />
- <Compile Include="wrapper\ToolButton.cs" />
- <Compile Include="wrapper\TreeView.cs" />
- <Compile Include="wrapper\Viewport.cs" />
- <Compile Include="wrapper\VScale.cs" />
- <Compile Include="wrapper\VScrollbar.cs" />
- <Compile Include="wrapper\Widget.cs" />
- <Compile Include="wrapper\WidgetEventHandler.cs" />
- <Compile Include="wrapper\WidgetNameChangedHandler.cs" />
- <Compile Include="wrapper\Window.cs" />
- <Compile Include="TopLevelDialog.cs" />
- <Compile Include="TopLevelWindow.cs" />
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="stetic.glade">
- <LogicalName>stetic.glade</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\objects.xml">
- <LogicalName>objects.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\accellabel.png">
- <LogicalName>accellabel.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\actiongroup.png">
- <LogicalName>actiongroup.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\add-check-label.png">
- <LogicalName>add-check-label.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\add-menu.png">
- <LogicalName>add-menu.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\alignment.png">
- <LogicalName>alignment.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\arrow.png">
- <LogicalName>arrow.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\box-expand.png">
- <LogicalName>box-expand.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\box-fill.png">
- <LogicalName>box-fill.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\button.png">
- <LogicalName>button.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\calendar.png">
- <LogicalName>calendar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\cell-expand-h.png">
- <LogicalName>cell-expand-h.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\cell-expand-v.png">
- <LogicalName>cell-expand-v.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\cell-fill-h.png">
- <LogicalName>cell-fill-h.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\cell-fill-v.png">
- <LogicalName>cell-fill-v.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\checkbutton.png">
- <LogicalName>checkbutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\colorbutton.png">
- <LogicalName>colorbutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\colorselection.png">
- <LogicalName>colorselection.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\colorselectiondialog.png">
- <LogicalName>colorselectiondialog.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\combo.png">
- <LogicalName>combo.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\comboentry.png">
- <LogicalName>comboentry.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\custom.png">
- <LogicalName>custom.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\dec-border.png">
- <LogicalName>dec-border.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\dialog.png">
- <LogicalName>dialog.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\drawingarea.png">
- <LogicalName>drawingarea.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\entry.png">
- <LogicalName>entry.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\eventbox.png">
- <LogicalName>eventbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\expander.png">
- <LogicalName>expander.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fileselection.png">
- <LogicalName>fileselection.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fixed.png">
- <LogicalName>fixed.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fontbutton.png">
- <LogicalName>fontbutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fontselection.png">
- <LogicalName>fontselection.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fontselectiondialog.png">
- <LogicalName>fontselectiondialog.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\frame.png">
- <LogicalName>frame.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\globe.png">
- <LogicalName>globe.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\globe-not.png">
- <LogicalName>globe-not.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\handlebox.png">
- <LogicalName>handlebox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hbox.png">
- <LogicalName>hbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hbuttonbox.png">
- <LogicalName>hbuttonbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hpaned.png">
- <LogicalName>hpaned.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hscale.png">
- <LogicalName>hscale.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hscrollbar.png">
- <LogicalName>hscrollbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hseparator.png">
- <LogicalName>hseparator.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\iconview.png">
- <LogicalName>iconview.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\image.png">
- <LogicalName>image.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\inc-border.png">
- <LogicalName>inc-border.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\label.png">
- <LogicalName>label.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\menu.png">
- <LogicalName>menu.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\menubar.png">
- <LogicalName>menubar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\messagedialog.png">
- <LogicalName>messagedialog.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\missing.png">
- <LogicalName>missing.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\notebook.png">
- <LogicalName>notebook.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\optionmenu.png">
- <LogicalName>optionmenu.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\progressbar.png">
- <LogicalName>progressbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\radiobutton.png">
- <LogicalName>radiobutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\remove-check-label.png">
- <LogicalName>remove-check-label.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\remove-menu.png">
- <LogicalName>remove-menu.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\scrolledwindow.png">
- <LogicalName>scrolledwindow.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\spinbutton.png">
- <LogicalName>spinbutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\statusbar.png">
- <LogicalName>statusbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\table.png">
- <LogicalName>table.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\textview.png">
- <LogicalName>textview.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\togglebutton.png">
- <LogicalName>togglebutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\toolbar.png">
- <LogicalName>toolbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\treeview.png">
- <LogicalName>treeview.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vbox.png">
- <LogicalName>vbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vbuttonbox.png">
- <LogicalName>vbuttonbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\viewport.png">
- <LogicalName>viewport.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vpaned.png">
- <LogicalName>vpaned.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vscale.png">
- <LogicalName>vscale.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vscrollbar.png">
- <LogicalName>vscrollbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vseparator.png">
- <LogicalName>vseparator.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\widget.png">
- <LogicalName>widget.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\window.png">
- <LogicalName>window.png</LogicalName>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <None Include="libstetic.dll.config">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic.dll.config b/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic.dll.config
deleted file mode 100644
index 8c4c6ab9a9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic.dll.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<configuration>
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.dylib" os="osx" />
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.dylib" os="osx"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.dylib" os="osx"/>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic2.csproj b/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic2.csproj
deleted file mode 100644
index 2542aef5d7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic2.csproj
+++ /dev/null
@@ -1,455 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{90CBA7FD-CB46-4711-97BB-2420DC01F016}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AssemblyName>libstetic2</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <RootNamespace>Stetic</RootNamespace>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.GtkCore2</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Mono.Posix" />
- <Reference Include="System" />
- <Reference Include="System.Xml" />
- <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="Mono.Cairo" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ClassDescriptor.cs" />
- <Compile Include="Clipboard.cs" />
- <Compile Include="CommandDescriptor.cs" />
- <Compile Include="CustomWidget.cs" />
- <Compile Include="DND.cs" />
- <Compile Include="editor\Accelerator.cs" />
- <Compile Include="editor\ActionGroupEditor.cs" />
- <Compile Include="editor\ActionItem.cs" />
- <Compile Include="editor\ActionMenu.cs" />
- <Compile Include="editor\ActionMenuBar.cs" />
- <Compile Include="editor\ActionMenuItem.cs" />
- <Compile Include="editor\ActionToolbar.cs" />
- <Compile Include="editor\ActionToolItem.cs" />
- <Compile Include="editor\Boolean.cs" />
- <Compile Include="editor\CellRendererComboBox.cs" />
- <Compile Include="editor\Char.cs" />
- <Compile Include="editor\Color.cs" />
- <Compile Include="editor\DateTimeEditor.cs" />
- <Compile Include="editor\EditIconDialog.cs" />
- <Compile Include="editor\EditIconFactoryDialog.cs" />
- <Compile Include="editor\Enumeration.cs" />
- <Compile Include="editor\Flags.cs" />
- <Compile Include="editor\FlagsSelectorDialog.cs" />
- <Compile Include="editor\FloatRange.cs" />
- <Compile Include="editor\GroupPicker.cs" />
- <Compile Include="editor\IconList.cs" />
- <Compile Include="editor\IconSelectorItem.cs" />
- <Compile Include="editor\IconSelectorMenu.cs" />
- <Compile Include="editor\IconSelectorMenuItem.cs" />
- <Compile Include="editor\Identifier.cs" />
- <Compile Include="editor\Image.cs" />
- <Compile Include="editor\ImageFile.cs" />
- <Compile Include="editor\ImageSelector.cs" />
- <Compile Include="editor\IntRange.cs" />
- <Compile Include="editor\NonContainerWarningDialog.cs" />
- <Compile Include="editor\OptIntRange.cs" />
- <Compile Include="editor\ProjectIconList.cs" />
- <Compile Include="editor\ProjectIconSelectorItem.cs" />
- <Compile Include="editor\ResponseId.cs" />
- <Compile Include="editor\SelectIconDialog.cs" />
- <Compile Include="editor\SelectImageDialog.cs" />
- <Compile Include="editor\StockIconList.cs" />
- <Compile Include="editor\StockIconSelectorItem.cs" />
- <Compile Include="editor\StockItem.cs" />
- <Compile Include="editor\String.cs" />
- <Compile Include="editor\StringArray.cs" />
- <Compile Include="editor\Text.cs" />
- <Compile Include="editor\TextBox.cs" />
- <Compile Include="editor\TextEditor.cs" />
- <Compile Include="editor\TextEditorDialog.cs" />
- <Compile Include="editor\ThemedIcon.cs" />
- <Compile Include="editor\ThemedIconList.cs" />
- <Compile Include="editor\TimeSpanEditor.cs" />
- <Compile Include="editor\Translatable.cs" />
- <Compile Include="editor\TreeViewCellContainer.cs" />
- <Compile Include="editor\WidgetSelector.cs" />
- <Compile Include="EnumDescriptor.cs" />
- <Compile Include="ErrorWidget.cs" />
- <Compile Include="GeneratorContext.cs" />
- <Compile Include="GladeException.cs" />
- <Compile Include="GladeUtils.cs" />
- <Compile Include="IDesignArea.cs" />
- <Compile Include="IEditableObject.cs" />
- <Compile Include="ImageInfo.cs" />
- <Compile Include="IProject.cs" />
- <Compile Include="IPropertyEditor.cs" />
- <Compile Include="IRadioGroupManager.cs" />
- <Compile Include="IResourceProvider.cs" />
- <Compile Include="ItemDescriptor.cs" />
- <Compile Include="ItemGroup.cs" />
- <Compile Include="ItemGroupCollection.cs" />
- <Compile Include="NoGuiDispatchAttribute.cs" />
- <Compile Include="ObjectReader.cs" />
- <Compile Include="ObjectWrapper.cs" />
- <Compile Include="ObjectWrapperEventHandler.cs" />
- <Compile Include="ObjectWriter.cs" />
- <Compile Include="ParamSpec.cs" />
- <Compile Include="Placeholder.cs" />
- <Compile Include="ProjectIconFactory.cs" />
- <Compile Include="PropertyDescriptor.cs" />
- <Compile Include="PropertyEditorAttribute.cs" />
- <Compile Include="PropertyEditorCell.cs" />
- <Compile Include="RadioGroupManager.cs" />
- <Compile Include="Registry.cs" />
- <Compile Include="Set.cs" />
- <Compile Include="SignalDescriptor.cs" />
- <Compile Include="TranslatableAttribute.cs" />
- <Compile Include="TypedClassDescriptor.cs" />
- <Compile Include="TypedPropertyDescriptor.cs" />
- <Compile Include="TypedSignalDescriptor.cs" />
- <Compile Include="undo\ActionDiffAdaptor.cs" />
- <Compile Include="undo\DiffGenerator.cs" />
- <Compile Include="undo\IDiffAdaptor.cs" />
- <Compile Include="undo\UndoManager.cs" />
- <Compile Include="undo\XmlDiffAdaptor.cs" />
- <Compile Include="WidgetLibrary.cs" />
- <Compile Include="WidgetUtils.cs" />
- <Compile Include="wrapper\Action.cs" />
- <Compile Include="wrapper\ActionGroup.cs" />
- <Compile Include="wrapper\ActionToolbarWrapper.cs" />
- <Compile Include="wrapper\ActionTree.cs" />
- <Compile Include="wrapper\Bin.cs" />
- <Compile Include="wrapper\Box.cs" />
- <Compile Include="wrapper\Button.cs" />
- <Compile Include="wrapper\ButtonBox.cs" />
- <Compile Include="wrapper\CheckButton.cs" />
- <Compile Include="wrapper\ColorButton.cs" />
- <Compile Include="wrapper\ComboBox.cs" />
- <Compile Include="wrapper\ComboBoxEntry.cs" />
- <Compile Include="wrapper\Container.cs" />
- <Compile Include="wrapper\Custom.cs" />
- <Compile Include="wrapper\Dialog.cs" />
- <Compile Include="wrapper\Entry.cs" />
- <Compile Include="wrapper\Expander.cs" />
- <Compile Include="wrapper\Fixed.cs" />
- <Compile Include="wrapper\FontButton.cs" />
- <Compile Include="wrapper\FontSelectionDialog.cs" />
- <Compile Include="wrapper\Frame.cs" />
- <Compile Include="wrapper\HScale.cs" />
- <Compile Include="wrapper\HScrollbar.cs" />
- <Compile Include="wrapper\IconView.cs" />
- <Compile Include="wrapper\Image.cs" />
- <Compile Include="wrapper\ImageMenuItem.cs" />
- <Compile Include="wrapper\Label.cs" />
- <Compile Include="wrapper\MenuBar.cs" />
- <Compile Include="wrapper\MenuItem.cs" />
- <Compile Include="wrapper\MessageDialog.cs" />
- <Compile Include="wrapper\Misc.cs" />
- <Compile Include="wrapper\Notebook.cs" />
- <Compile Include="wrapper\Object.cs" />
- <Compile Include="wrapper\OptionMenu.cs" />
- <Compile Include="wrapper\Paned.cs" />
- <Compile Include="wrapper\RadioActionGroupManager.cs" />
- <Compile Include="wrapper\RadioButton.cs" />
- <Compile Include="wrapper\RadioMenuItem.cs" />
- <Compile Include="wrapper\RadioToolButton.cs" />
- <Compile Include="wrapper\Range.cs" />
- <Compile Include="wrapper\Scale.cs" />
- <Compile Include="wrapper\ScrolledWindow.cs" />
- <Compile Include="wrapper\Signal.cs" />
- <Compile Include="wrapper\SignalChangedEventHandler.cs" />
- <Compile Include="wrapper\SignalCollection.cs" />
- <Compile Include="wrapper\SignalEventHandler.cs" />
- <Compile Include="wrapper\SpinButton.cs" />
- <Compile Include="wrapper\Table.cs" />
- <Compile Include="wrapper\TextView.cs" />
- <Compile Include="wrapper\ToggleToolButton.cs" />
- <Compile Include="wrapper\Toolbar.cs" />
- <Compile Include="wrapper\ToolButton.cs" />
- <Compile Include="wrapper\TreeView.cs" />
- <Compile Include="wrapper\Viewport.cs" />
- <Compile Include="wrapper\VScale.cs" />
- <Compile Include="wrapper\VScrollbar.cs" />
- <Compile Include="wrapper\Widget.cs" />
- <Compile Include="wrapper\WidgetEventHandler.cs" />
- <Compile Include="wrapper\WidgetNameChangedHandler.cs" />
- <Compile Include="wrapper\Window.cs" />
- <Compile Include="TopLevelDialog.cs" />
- <Compile Include="TopLevelWindow.cs" />
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="stetic.glade">
- <LogicalName>stetic.glade</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\objects.xml">
- <LogicalName>objects.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\accellabel.png">
- <LogicalName>accellabel.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\actiongroup.png">
- <LogicalName>actiongroup.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\add-check-label.png">
- <LogicalName>add-check-label.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\add-menu.png">
- <LogicalName>add-menu.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\alignment.png">
- <LogicalName>alignment.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\arrow.png">
- <LogicalName>arrow.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\box-expand.png">
- <LogicalName>box-expand.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\box-fill.png">
- <LogicalName>box-fill.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\button.png">
- <LogicalName>button.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\calendar.png">
- <LogicalName>calendar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\cell-expand-h.png">
- <LogicalName>cell-expand-h.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\cell-expand-v.png">
- <LogicalName>cell-expand-v.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\cell-fill-h.png">
- <LogicalName>cell-fill-h.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\cell-fill-v.png">
- <LogicalName>cell-fill-v.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\checkbutton.png">
- <LogicalName>checkbutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\colorbutton.png">
- <LogicalName>colorbutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\colorselection.png">
- <LogicalName>colorselection.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\colorselectiondialog.png">
- <LogicalName>colorselectiondialog.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\combo.png">
- <LogicalName>combo.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\comboentry.png">
- <LogicalName>comboentry.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\custom.png">
- <LogicalName>custom.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\dec-border.png">
- <LogicalName>dec-border.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\dialog.png">
- <LogicalName>dialog.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\drawingarea.png">
- <LogicalName>drawingarea.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\entry.png">
- <LogicalName>entry.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\eventbox.png">
- <LogicalName>eventbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\expander.png">
- <LogicalName>expander.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fileselection.png">
- <LogicalName>fileselection.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fixed.png">
- <LogicalName>fixed.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fontbutton.png">
- <LogicalName>fontbutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fontselection.png">
- <LogicalName>fontselection.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\fontselectiondialog.png">
- <LogicalName>fontselectiondialog.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\frame.png">
- <LogicalName>frame.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\globe.png">
- <LogicalName>globe.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\globe-not.png">
- <LogicalName>globe-not.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\handlebox.png">
- <LogicalName>handlebox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hbox.png">
- <LogicalName>hbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hbuttonbox.png">
- <LogicalName>hbuttonbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hpaned.png">
- <LogicalName>hpaned.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hscale.png">
- <LogicalName>hscale.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hscrollbar.png">
- <LogicalName>hscrollbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\hseparator.png">
- <LogicalName>hseparator.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\iconview.png">
- <LogicalName>iconview.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\image.png">
- <LogicalName>image.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\inc-border.png">
- <LogicalName>inc-border.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\label.png">
- <LogicalName>label.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\menu.png">
- <LogicalName>menu.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\menubar.png">
- <LogicalName>menubar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\messagedialog.png">
- <LogicalName>messagedialog.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\missing.png">
- <LogicalName>missing.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\notebook.png">
- <LogicalName>notebook.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\optionmenu.png">
- <LogicalName>optionmenu.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\progressbar.png">
- <LogicalName>progressbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\radiobutton.png">
- <LogicalName>radiobutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\remove-check-label.png">
- <LogicalName>remove-check-label.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\remove-menu.png">
- <LogicalName>remove-menu.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\scrolledwindow.png">
- <LogicalName>scrolledwindow.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\spinbutton.png">
- <LogicalName>spinbutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\statusbar.png">
- <LogicalName>statusbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\table.png">
- <LogicalName>table.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\textview.png">
- <LogicalName>textview.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\togglebutton.png">
- <LogicalName>togglebutton.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\toolbar.png">
- <LogicalName>toolbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\treeview.png">
- <LogicalName>treeview.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vbox.png">
- <LogicalName>vbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vbuttonbox.png">
- <LogicalName>vbuttonbox.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\viewport.png">
- <LogicalName>viewport.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vpaned.png">
- <LogicalName>vpaned.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vscale.png">
- <LogicalName>vscale.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vscrollbar.png">
- <LogicalName>vscrollbar.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\vseparator.png">
- <LogicalName>vseparator.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\widget.png">
- <LogicalName>widget.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="wrapper\pixmaps\window.png">
- <LogicalName>window.png</LogicalName>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <None Include="libstetic2.dll.config">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic2.dll.config b/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic2.dll.config
deleted file mode 100644
index 8c4c6ab9a9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/libstetic2.dll.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<configuration>
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.dylib" os="osx" />
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.dylib" os="osx"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.dylib" os="osx"/>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/stetic.glade b/main/src/addins/MonoDevelop.GtkCore2/libstetic/stetic.glade
deleted file mode 100644
index 9f58816ce1..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/stetic.glade
+++ /dev/null
@@ -1,2107 +0,0 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
-<glade-interface>
-
-<widget class="GtkDialog" id="SelectImageDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Select Image</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="default_width">650</property>
- <property name="default_height">450</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okButton">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">0</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkNotebook" id="notebook">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="show_tabs">True</property>
- <property name="show_border">True</property>
- <property name="tab_pos">GTK_POS_TOP</property>
- <property name="scrollable">False</property>
- <property name="enable_popup">False</property>
- <signal name="switch_page" handler="OnCurrentPageChanged" last_modification_time="Thu, 18 May 2006 12:07:20 GMT"/>
-
- <child>
- <widget class="GtkVBox" id="vbox1">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="iconScrolledwindow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkImage" id="previewIcon">
- <property name="visible">True</property>
- <property name="icon_size">4</property>
- <property name="icon_name">gtk-missing-image</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">3</property>
- <property name="ypad">3</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox3">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <widget class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Icon Name:</property>
- <property name="use_underline">True</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="mnemonic_widget">iconNameEntry</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEntry" id="iconNameEntry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- <signal name="changed" handler="OnIconNameChanged" last_modification_time="Fri, 10 Mar 2006 13:48:39 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkComboBox" id="iconSizeCombo">
- <property name="visible">True</property>
- <property name="items" translatable="yes"></property>
- <property name="add_tearoffs">False</property>
- <property name="focus_on_click">True</property>
- <signal name="changed" handler="OnIconSizeChanged" last_modification_time="Fri, 10 Mar 2006 13:50:33 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="tab_expand">False</property>
- <property name="tab_fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Themed Icons</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="type">tab</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox2">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow7">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="resourceList">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">False</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">True</property>
- <property name="fixed_height_mode">False</property>
- <property name="hover_selection">False</property>
- <property name="hover_expand">False</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVButtonBox" id="vbuttonbox1">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_START</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkButton" id="buttonAdd">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-add</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnAddResource" last_modification_time="Fri, 10 Mar 2006 11:17:29 GMT"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="buttonRemove">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-delete</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnRemoveResource" last_modification_time="Fri, 10 Mar 2006 11:17:42 GMT"/>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox4">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkImage" id="previewResource">
- <property name="width_request">30</property>
- <property name="height_request">30</property>
- <property name="visible">True</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label6">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Resource Name:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEntry" id="resourceNameEntry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- <signal name="changed" handler="OnResourceNameChanged" last_modification_time="Fri, 10 Mar 2006 16:31:30 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="tab_expand">False</property>
- <property name="tab_fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Resources</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="type">tab</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkFileChooserWidget" id="fileChooser">
- <property name="border_width">12</property>
- <property name="visible">True</property>
- <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
- <property name="local_only">True</property>
- <property name="select_multiple">False</property>
- <property name="show_hidden">False</property>
- </widget>
- <packing>
- <property name="tab_expand">False</property>
- <property name="tab_fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Files</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="type">tab</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-<widget class="GtkDialog" id="FlagsSelectorDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Flags</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="default_width">500</property>
- <property name="default_height">450</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox2">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area2">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton2">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okbutton1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow8">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
- <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="treeView">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">False</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">True</property>
- <property name="fixed_height_mode">False</property>
- <property name="hover_selection">False</property>
- <property name="hover_expand">False</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-<widget class="GtkDialog" id="TextEditorDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Text</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="default_width">600</property>
- <property name="default_height">350</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox3">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area3">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton3">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okbutton2">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox4">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow9">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTextView" id="textview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="overwrite">False</property>
- <property name="accepts_tab">True</property>
- <property name="justification">GTK_JUSTIFY_LEFT</property>
- <property name="wrap_mode">GTK_WRAP_CHAR</property>
- <property name="cursor_visible">True</property>
- <property name="pixels_above_lines">0</property>
- <property name="pixels_below_lines">0</property>
- <property name="pixels_inside_wrap">0</property>
- <property name="left_margin">0</property>
- <property name="right_margin">0</property>
- <property name="indent">0</property>
- <property name="text" translatable="yes"></property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkCheckButton" id="checkTranslatable">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Translatable</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="OnTranslatableToggled" last_modification_time="Fri, 17 Mar 2006 16:37:34 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkTable" id="translationTable">
- <property name="visible">True</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="homogeneous">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label7">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Translation Context Hint:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label8">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Comment for Translators</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEntry" id="entryContext">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEntry" id="entryComment">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"></property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-<widget class="GtkDialog" id="SelectIconDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Select Image</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="default_width">650</property>
- <property name="default_height">450</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="vbox5">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="hbuttonbox1">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="button1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okButton">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkNotebook" id="notebook">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="show_tabs">True</property>
- <property name="show_border">True</property>
- <property name="tab_pos">GTK_POS_TOP</property>
- <property name="scrollable">False</property>
- <property name="enable_popup">False</property>
- <signal name="switch_page" handler="OnCurrentPageChanged" last_modification_time="Thu, 18 May 2006 12:05:33 GMT"/>
-
- <child>
- <widget class="GtkVBox" id="vbox6">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="iconScrolledwindow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox5">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkImage" id="previewIcon">
- <property name="visible">True</property>
- <property name="icon_size">4</property>
- <property name="icon_name">gtk-missing-image</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0</property>
- <property name="xpad">3</property>
- <property name="ypad">3</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox7">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <widget class="GtkHBox" id="hbox6">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Icon Name:</property>
- <property name="use_underline">True</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="mnemonic_widget">stockIconEntry</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEntry" id="stockIconEntry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- <signal name="changed" handler="OnIconNameChanged" last_modification_time="Fri, 10 Mar 2006 13:48:39 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="labelWarningIcon">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <widget class="GtkHSeparator" id="hseparator2">
- <property name="visible">True</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox11">
- <property name="border_width">3</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">3</property>
-
- <child>
- <widget class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="stock">gtk-dialog-warning</property>
- <property name="icon_size">1</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="labelWarning">
- <property name="width_request">513</property>
- <property name="visible">True</property>
- <property name="label" translatable="yes">The selected icon may not show at run time if the required icon factory is not properly initialized.</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">True</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="tab_expand">False</property>
- <property name="tab_fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label10">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Stock Icons</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="type">tab</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox8">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkHBox" id="hbox7">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="customIconScrolledwindow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVButtonBox" id="vbuttonbox2">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_START</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkButton" id="button3">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-add</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnAddIcon" last_modification_time="Wed, 17 May 2006 11:25:29 GMT"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="button4">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-edit</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnEditIcon" last_modification_time="Wed, 17 May 2006 11:24:58 GMT"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="button5">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-delete</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnRemoveIcon" last_modification_time="Wed, 17 May 2006 11:25:18 GMT"/>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="tab_expand">False</property>
- <property name="tab_fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label12">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Project Icons</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="type">tab</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-<widget class="GtkDialog" id="EditIconDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Edit Icon</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="default_width">650</property>
- <property name="default_height">400</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox4">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area4">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton4">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okButton">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox12">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkHBox" id="hbox15">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label21">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Icon name:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEntry" id="nameEntry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- <property name="width_chars">20</property>
- <signal name="changed" handler="OnNameChanged" last_modification_time="Wed, 17 May 2006 15:53:15 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHSeparator" id="hseparator1">
- <property name="visible">True</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkRadioButton" id="radioSingle">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Single source icon</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- <signal name="clicked" handler="OnSingleClicked" last_modification_time="Wed, 17 May 2006 12:17:45 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hboxSingle">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label20">
- <property name="width_request">12</property>
- <property name="visible">True</property>
- <property name="label" translatable="yes"></property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label17">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Image:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkFrame" id="frame1">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="label_yalign">0.5</property>
- <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
-
- <child>
- <widget class="GtkHBox" id="hbox14">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkImage" id="imageImage">
- <property name="visible">True</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">6</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="imageLabel">
- <property name="visible">True</property>
- <property name="label">image name</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkButton" id="button9">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Select Image...</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnSelectImage" last_modification_time="Wed, 17 May 2006 12:11:57 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkRadioButton" id="radioMultiple">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Multiple source icon</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- <property name="group">radioSingle</property>
- <signal name="clicked" handler="OnMultipleClicked" last_modification_time="Wed, 17 May 2006 12:18:00 GMT"/>
- </widget>
- <packing>
- <property name="padding">3</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox12">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <widget class="GtkLabel" id="label19">
- <property name="width_request">12</property>
- <property name="visible">True</property>
- <property name="label" translatable="yes"></property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hboxMultiple">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow13">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="sourceList">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">True</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">True</property>
- <property name="fixed_height_mode">False</property>
- <property name="hover_selection">False</property>
- <property name="hover_expand">False</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVButtonBox" id="vbuttonbox3">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_START</property>
- <property name="spacing">3</property>
-
- <child>
- <widget class="GtkButton" id="button10">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-add</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnAddSource" last_modification_time="Wed, 17 May 2006 12:12:11 GMT"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="button11">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-delete</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnRemoveSource" last_modification_time="Wed, 17 May 2006 12:12:21 GMT"/>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-<widget class="GtkDialog" id="EditIconFactoryDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Edit Icon Factory</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="default_width">450</property>
- <property name="default_height">460</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="vbox14">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="hbuttonbox2">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="button17">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-close</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-7</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox22">
- <property name="border_width">12</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="iconListScrolledwindow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVButtonBox" id="vbuttonbox4">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_START</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkButton" id="button18">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-add</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnAddIcon" last_modification_time="Wed, 17 May 2006 11:25:29 GMT"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="button19">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-edit</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnEditIcon" last_modification_time="Wed, 17 May 2006 11:24:58 GMT"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="button20">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-delete</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="OnRemoveIcon" last_modification_time="Wed, 17 May 2006 11:25:18 GMT"/>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-<widget class="GtkDialog" id="AddNonContainerDialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Widget Designer</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">True</property>
- <property name="resizable">False</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox5">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area5">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton5">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okbutton">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox23">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <widget class="GtkImage" id="image2">
- <property name="visible">True</property>
- <property name="stock">gtk-dialog-warning</property>
- <property name="icon_size">6</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="mainBox">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label22">
- <property name="width_request">449</property>
- <property name="visible">True</property>
- <property name="label" translatable="yes">You are trying to add a non-container widget into the main window. In &lt;b&gt;GTK#&lt;/b&gt;, widget positioning is controlled by a special type of widgets called &lt;b&gt;Container&lt;/b&gt; widgets. If you don't place the widget into a container, it will fill the all the available space in the window. Are you sure you want to continue?</property>
- <property name="use_underline">False</property>
- <property name="use_markup">True</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">True</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox24">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label23">
- <property name="visible">True</property>
- <property name="label" translatable="yes">To know more about this topic see the article:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkButton" id="linkButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">GTK# Widget Layout and Packing</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="focus_on_click">True</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkCheckButton" id="showCheck">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Don't show this message again</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-</glade-interface>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/ActionDiffAdaptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/ActionDiffAdaptor.cs
deleted file mode 100644
index 880aaea21a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/ActionDiffAdaptor.cs
+++ /dev/null
@@ -1,273 +0,0 @@
-
-using System;
-using System.Xml;
-using System.Collections;
-using Stetic.Wrapper;
-
-namespace Stetic.Undo
-{
- class ActionDiffAdaptor: IDiffAdaptor
- {
- IProject project;
-
- public ActionDiffAdaptor (IProject project)
- {
- this.project = project;
- }
-
- public IEnumerable GetChildren (object parent)
- {
- if (parent is Wrapper.Action)
- yield break;
- else if (parent is ActionGroup) {
- foreach (Wrapper.Action ac in ((ActionGroup)parent).Actions)
- if (ac.Name.Length > 0)
- yield return ac;
- }
- else if (parent is ActionGroupCollection) {
- foreach (ActionGroup ag in (ActionGroupCollection) parent)
- yield return ag;
- }
- else
- throw new NotImplementedException ();
- }
-
- public string GetUndoId (object childObject)
- {
- if (childObject is ActionGroup)
- return ((ActionGroup)childObject).UndoId;
- if (childObject is Wrapper.Action)
- return ((Wrapper.Action)childObject).UndoId;
-
- throw new NotImplementedException ();
- }
-
- public object FindChild (object parent, string undoId)
- {
- foreach (object ob in GetChildren (parent))
- if (GetUndoId (ob) == undoId) {
- if ((ob is Wrapper.Action) && ((Wrapper.Action)ob).Name.Length == 0)
- continue;
- return ob;
- }
- return null;
- }
-
- public void RemoveChild (object parent, string undoId)
- {
- object child = FindChild (parent, undoId);
- if (child == null)
- return;
- if (parent is ActionGroup) {
- ((ActionGroup)parent).Actions.Remove ((Wrapper.Action)child);
- } else if (parent is ActionGroupCollection) {
- ((ActionGroupCollection)parent).Remove ((ActionGroup)child);
- } else
- throw new NotImplementedException ();
- }
-
- public void AddChild (object parent, XmlElement node, string insertAfter)
- {
- object data = DeserializeChild (node);
- if (parent is ActionGroup) {
- ActionGroup group = (ActionGroup) parent;
- if (insertAfter == null)
- group.Actions.Insert (0, (Wrapper.Action) data);
- else {
- for (int n=0; n<group.Actions.Count; n++) {
- if (group.Actions [n].UndoId == insertAfter) {
- group.Actions.Insert (n+1, (Wrapper.Action) data);
- return;
- }
- }
- group.Actions.Add ((Wrapper.Action) data);
- }
- }
- if (parent is ActionGroupCollection) {
- ActionGroupCollection col = (ActionGroupCollection) parent;
- if (insertAfter == null)
- col.Insert (0, (ActionGroup) data);
- else {
- for (int n=0; n<col.Count; n++) {
- if (col [n].UndoId == insertAfter) {
- col.Insert (n+1, (ActionGroup) data);
- return;
- }
- }
- col.Add ((ActionGroup) data);
- }
- }
- }
-
- public IEnumerable GetProperties (object obj)
- {
- Wrapper.Action action = obj as Wrapper.Action;
- if (action != null) {
- foreach (ItemGroup iset in action.ClassDescriptor.ItemGroups) {
- foreach (ItemDescriptor it in iset) {
- PropertyDescriptor prop = it as PropertyDescriptor;
-
- if (!prop.VisibleFor (action.Wrapped) || !prop.CanWrite)
- continue;
-
- object value = prop.GetValue (action.Wrapped);
-
- // If the property has its default value, we don't need to check it
- if (value == null || (prop.HasDefault && prop.IsDefaultValue (value)))
- continue;
-
- yield return it;
- }
- }
- }
- else if (obj is ActionGroup)
- yield return "name"; // ActionGroup only has one property, the name
- else
- yield break;
- }
-
- public XmlElement SerializeChild (object child)
- {
- XmlDocument doc = new XmlDocument ();
- ObjectWriter ow = new ObjectWriter (doc, FileFormat.Native);
-
- if (child is Wrapper.Action) {
- return ((Wrapper.Action)child).Write (ow);
- } else if (child is ActionGroup) {
- return ((ActionGroup)child).Write (ow);
- }
- throw new NotImplementedException ();
- }
-
- public object DeserializeChild (XmlElement data)
- {
- ObjectReader or = new ObjectReader (project, FileFormat.Native);
- if (data.LocalName == "action") {
- Wrapper.Action ac = new Wrapper.Action ();
- ac.Read (or, data);
- return ac;
- } else if (data.LocalName == "action-group") {
- ActionGroup ac = new ActionGroup ();
- ac.Read (or, data);
- return ac;
- }
- throw new NotImplementedException ();
- }
-
- public IDiffAdaptor GetChildAdaptor (object child)
- {
- return this;
- }
-
- public object GetPropertyByName (object obj, string name)
- {
- if (obj is Wrapper.Action) {
- if (name == "id") name = "Name";
- return ((Wrapper.Action)obj).ClassDescriptor [name];
- }
- else if (obj is ActionGroup) {
- if (name == "name") return name;
- }
- throw new NotImplementedException ();
- }
-
- public string GetPropertyName (object property)
- {
- if (property is PropertyDescriptor) {
- PropertyDescriptor prop = (PropertyDescriptor) property;
- if (prop.Name == "Name") return "id";
- return prop.Name;
- }
- else if (property is string)
- return (string) property;
-
- throw new NotImplementedException ();
- }
-
- public string GetPropertyValue (object obj, object property)
- {
- if (obj is Wrapper.Action) {
- PropertyDescriptor prop = (PropertyDescriptor) property;
- object val = prop.GetValue (((Wrapper.Action)obj).Wrapped);
- return prop.ValueToString (val);
- }
- else if (obj is ActionGroup) {
- if (((string)property) == "name")
- return ((ActionGroup)obj).Name;
- }
- throw new NotImplementedException ();
- }
-
- public void SetPropertyValue (object obj, string name, string value)
- {
- if (obj is Wrapper.Action) {
- if (name == "id") name = "Name";
- PropertyDescriptor prop = (PropertyDescriptor) GetPropertyByName (obj, name);
- if (prop == null)
- throw new InvalidOperationException ("Property '" + name + "' not found in object of type: " + obj.GetType ());
- prop.SetValue (((Wrapper.Action)obj).Wrapped, prop.StringToValue (value));
- return;
- }
- else if (obj is ActionGroup) {
- if (name == "name") {
- ((ActionGroup)obj).Name = value;
- return;
- }
- }
- throw new NotImplementedException ();
- }
-
- public void ResetPropertyValue (object obj, string name)
- {
- if (obj is Wrapper.Action) {
- if (name == "id") name = "Name";
- PropertyDescriptor prop = (PropertyDescriptor) GetPropertyByName (obj, name);
- prop.ResetValue (((Wrapper.Action)obj).Wrapped);
- }
- }
-
- public IEnumerable GetSignals (object obj)
- {
- if (obj is Wrapper.Action) {
- foreach (Signal s in ((Wrapper.Action)obj).Signals)
- yield return s;
- }
- else
- yield break;
- }
-
- public object GetSignal (object obj, string name, string handler)
- {
- foreach (Signal s in ((Wrapper.Action)obj).Signals) {
- if (s.SignalDescriptor.Name == name && s.Handler == handler)
- return s;
- }
- return null;
- }
-
- public void GetSignalInfo (object signal, out string name, out string handler)
- {
- Signal s = (Signal) signal;
- name = s.SignalDescriptor.Name;
- handler = s.Handler;
- }
-
- public void AddSignal (object obj, string name, string handler)
- {
- SignalDescriptor sd = (SignalDescriptor) ((Wrapper.Action)obj).ClassDescriptor.SignalGroups.GetItem (name);
- Signal sig = new Signal (sd);
- sig.Handler = handler;
- ((Wrapper.Action)obj).Signals.Add (sig);
- }
-
- public void RemoveSignal (object obj, string name, string handler)
- {
- foreach (Signal sig in ((Wrapper.Action)obj).Signals) {
- if (sig.SignalDescriptor.Name == name && sig.Handler == handler) {
- ((Wrapper.Action)obj).Signals.Remove (sig);
- return;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/DiffGenerator.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/DiffGenerator.cs
deleted file mode 100644
index 3db856c08b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/DiffGenerator.cs
+++ /dev/null
@@ -1,319 +0,0 @@
-
-using System;
-using System.Collections;
-using System.Xml;
-using Stetic.Wrapper;
-
-namespace Stetic.Undo
-{
- class DiffGenerator
- {
- IDiffAdaptor currentStatusAdaptor;
- IDiffAdaptor newStatusAdaptor;
-
- public DiffGenerator ()
- {
- }
-
- public DiffGenerator (IDiffAdaptor currentStatusAdaptor, IDiffAdaptor newStatusAdaptor)
- {
- this.currentStatusAdaptor = currentStatusAdaptor;
- this.newStatusAdaptor = newStatusAdaptor;
- }
-
- public IDiffAdaptor CurrentStatusAdaptor {
- get { return currentStatusAdaptor; }
- set { currentStatusAdaptor = value; }
- }
-
- public IDiffAdaptor NewStatusAdaptor {
- get { return newStatusAdaptor; }
- set { newStatusAdaptor = value; }
- }
-
- internal ObjectDiff GetDiff (object oldStatus, object newStatus)
- {
- PropertyDiff[] propChanges = GetPropertyDiff (currentStatusAdaptor, oldStatus, newStatusAdaptor, newStatus);
- PropertyDiff[] signalChanges = GetSignalDiff (currentStatusAdaptor, oldStatus, newStatusAdaptor, newStatus);
-
- ArrayList changes = new ArrayList ();
- Hashtable foundChildren = new Hashtable ();
-
- // Register changed and deleted child elements
- foreach (object oldChild in currentStatusAdaptor.GetChildren (oldStatus)) {
- string cid = currentStatusAdaptor.GetUndoId (oldChild);
- if (cid != null && cid.Length > 0) {
- object newChild = newStatusAdaptor.FindChild (newStatus, cid);
- if (newChild != null) {
- // ChildCreate will work even if the packing element is null
- ObjectDiff odiff = GetChildDiff (oldChild, newChild);
- if (odiff != null) {
- ChildDiff cdiff = new ChildDiff ();
- cdiff.Id = cid;
- cdiff.Operation = DiffOperation.Update;
- cdiff.Diff = odiff;
- changes.Add (cdiff);
- }
- foundChildren [cid] = cid;
- } else {
- ChildDiff cdiff = new ChildDiff ();
- cdiff.Id = cid;
- cdiff.Operation = DiffOperation.Remove;
- changes.Add (cdiff);
- }
- } else {
- throw new InvalidOperationException ("Found an element of type '" + oldChild.GetType () + "' without ID");
- }
- }
-
- // Register new elements
-
- string lastWidgetId = null;
- foreach (object newChildElem in newStatusAdaptor.GetChildren (newStatus)) {
- string cid = newStatusAdaptor.GetUndoId (newChildElem);
- if (cid.Length > 0) {
- if (!foundChildren.ContainsKey (cid)) {
- ChildDiff cdiff = new ChildDiff ();
- cdiff.Id = cid;
- cdiff.Operation = DiffOperation.Add;
- cdiff.AddContent = newStatusAdaptor.SerializeChild (newChildElem);
- cdiff.InsertAfter = lastWidgetId;
- changes.Add (cdiff);
- }
- } else
- throw new InvalidOperationException ("Found an element of type '" + newChildElem.GetType () + "' without ID");
-
- lastWidgetId = cid;
- }
-
- ChildDiff[] childChanges = null;
- if (changes.Count > 0)
- childChanges = (ChildDiff[]) changes.ToArray (typeof(ChildDiff));
-
- if (childChanges != null || propChanges != null || signalChanges != null) {
- ObjectDiff dif = new ObjectDiff ();
- dif.PropertyChanges = propChanges;
- dif.SignalChanges = signalChanges;
- dif.ChildChanges = childChanges;
- return dif;
- }
- else
- return null;
- }
-
- public void ApplyDiff (object status, ObjectDiff diff)
- {
- if (diff.PropertyChanges != null)
- ApplyPropertyChanges (diff.PropertyChanges, currentStatusAdaptor, status);
-
- if (diff.SignalChanges != null)
- ApplySignalChanges (diff.SignalChanges, currentStatusAdaptor, status);
-
- if (diff.ChildChanges != null) {
- foreach (ChildDiff cdiff in diff.ChildChanges) {
- if (cdiff.Operation == DiffOperation.Update) {
- object statusChild = currentStatusAdaptor.FindChild (status, cdiff.Id);
- ApplyChildDiff (statusChild, cdiff.Diff);
- } else if (cdiff.Operation == DiffOperation.Remove) {
- // Remove the child
- currentStatusAdaptor.RemoveChild (status, cdiff.Id);
- } else {
- // Add the child at the correct position
- currentStatusAdaptor.AddChild (status, cdiff.AddContent, cdiff.InsertAfter);
- }
- }
- }
- }
-
- protected virtual ObjectDiff GetChildDiff (object oldChild, object newChild)
- {
- DiffGenerator childGenerator = new DiffGenerator ();
- childGenerator.CurrentStatusAdaptor = currentStatusAdaptor.GetChildAdaptor (oldChild);
- childGenerator.NewStatusAdaptor = newStatusAdaptor.GetChildAdaptor (newChild);
-
- return childGenerator.GetDiff (oldChild, newChild);
- }
-
- protected virtual void ApplyChildDiff (object child, ObjectDiff cdiff)
- {
- DiffGenerator childGenerator = new DiffGenerator ();
- childGenerator.CurrentStatusAdaptor = currentStatusAdaptor.GetChildAdaptor (child);
- childGenerator.ApplyDiff (child, cdiff);
- }
-
- protected virtual PropertyDiff[] GetPropertyDiff (IDiffAdaptor currentAdaptor, object currentObject, IDiffAdaptor newAdaptor, object newObject)
- {
- ArrayList changes = new ArrayList ();
- Hashtable found = new Hashtable ();
-
- // Look for modified and deleted elements
- if (currentObject != null) {
- foreach (object oldProp in currentAdaptor.GetProperties (currentObject)) {
- string name = currentAdaptor.GetPropertyName (oldProp);
- object newProp = newObject != null ? newAdaptor.GetPropertyByName (newObject, name) : null;
- if (newProp == null)
- changes.Add (new PropertyDiff (DiffOperation.Remove, name, null));
- else {
- found [name] = found;
- string newValue = newAdaptor.GetPropertyValue (newObject, newProp);
- if (newValue != currentAdaptor.GetPropertyValue (currentObject, oldProp))
- changes.Add (new PropertyDiff (DiffOperation.Update, name, newValue));
- }
- }
- }
-
- // Look for new elements
- if (newObject != null) {
- foreach (object newProp in newAdaptor.GetProperties (newObject)) {
- string name = newAdaptor.GetPropertyName (newProp);
- if (!found.ContainsKey (name))
- changes.Add (new PropertyDiff (DiffOperation.Add, name, newAdaptor.GetPropertyValue (newObject, newProp)));
- }
- }
-
- if (changes.Count == 0)
- return null;
- return (PropertyDiff[]) changes.ToArray (typeof(PropertyDiff));
- }
-
- protected virtual PropertyDiff[] GetSignalDiff (IDiffAdaptor currentAdaptor, object currentObject, IDiffAdaptor newAdaptor, object newObject)
- {
- ArrayList changes = new ArrayList ();
- Hashtable found = new Hashtable ();
-
- // Look for modified and deleted elements
- if (currentObject != null) {
- foreach (object oldProp in currentAdaptor.GetSignals (currentObject)) {
- string name;
- string handler;
- currentAdaptor.GetSignalInfo (oldProp, out name, out handler);
- object newProp = newObject != null ? newAdaptor.GetSignal (newObject, name, handler) : null;
- if (newProp == null)
- changes.Add (new PropertyDiff (DiffOperation.Remove, name, handler));
- found [name + " " + handler] = found;
- }
- }
-
- // Look for new elements
- if (newObject != null) {
- foreach (object newProp in newAdaptor.GetSignals (newObject)) {
- string name;
- string handler;
- newAdaptor.GetSignalInfo (newProp, out name, out handler);
- if (!found.ContainsKey (name + " " + handler))
- changes.Add (new PropertyDiff (DiffOperation.Add, name, handler));
- }
- }
-
- if (changes.Count == 0)
- return null;
- return (PropertyDiff[]) changes.ToArray (typeof(PropertyDiff));
- }
-
- public virtual void ApplyPropertyChanges (PropertyDiff[] changes, IDiffAdaptor adaptor, object obj)
- {
- foreach (PropertyDiff pdif in changes) {
- if (pdif.Operation == DiffOperation.Add || pdif.Operation == DiffOperation.Update)
- adaptor.SetPropertyValue (obj, pdif.Name, pdif.Text);
- else
- adaptor.ResetPropertyValue (obj, pdif.Name);
- }
- }
-
- public virtual void ApplySignalChanges (PropertyDiff[] changes, IDiffAdaptor adaptor, object obj)
- {
- foreach (PropertyDiff pdif in changes) {
- if (pdif.Operation == DiffOperation.Add)
- adaptor.AddSignal (obj, pdif.Name, pdif.Text);
- else
- adaptor.RemoveSignal (obj, pdif.Name, pdif.Text);
- }
- }
- }
-
-
- class PropertyDiff
- {
- public PropertyDiff (DiffOperation Operation, string Name, string Text)
- {
- this.Operation = Operation;
- this.Name = Name;
- this.Text = Text;
- }
-
- public DiffOperation Operation;
- public string Name;
- public string Text;
- }
-
- enum DiffOperation
- {
- Add,
- Remove,
- Update
- }
-
- class ChildDiff
- {
- public string Id;
- public DiffOperation Operation;
- public XmlElement AddContent;
- public string InsertAfter;
- public ObjectDiff Diff;
-
- public string ToString (int indent)
- {
- string ind = new string (' ', indent);
- string s = ind + Operation + " id:" + Id + "\n";
- if (Operation == DiffOperation.Update)
- s += Diff.ToString (indent + 2) + "\n";
- if (Operation == DiffOperation.Add) {
- s += ind + " InsertAfter: " + InsertAfter + "\n";
- s += ind + " Content: " + AddContent.OuterXml + "\n";
- }
- return s;
- }
- }
-
- class ObjectDiff
- {
- public PropertyDiff[] PropertyChanges;
- public PropertyDiff[] SignalChanges;
- public ChildDiff[] ChildChanges;
-
- public override string ToString ()
- {
- return ToString (0);
- }
-
- internal string ToString (int indent)
- {
- string ind = new string (' ', indent);
- string s = ind + "ObjectDiff:\n";
-
- if (PropertyChanges != null) {
- s += ind + " Properties:\n";
- foreach (PropertyDiff d in PropertyChanges) {
- s += ind + " " + d.Operation + ": " + d.Name;
- if (d.Operation != DiffOperation.Remove)
- s += " = " + d.Text;
- s += "\n";
- }
- }
-
- if (SignalChanges != null) {
- s += ind + " Signals:\n";
- foreach (PropertyDiff d in SignalChanges)
- s += ind + " " + d.Operation + ": " + d.Name + " - " + d.Text + "\n";
- }
-
- if (ChildChanges != null) {
- s += ind + " Children:\n";
- foreach (ChildDiff cd in ChildChanges)
- s += cd.ToString (indent + 4);
- }
-
- return s;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/IDiffAdaptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/IDiffAdaptor.cs
deleted file mode 100644
index aab6567c81..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/IDiffAdaptor.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-
-using System;
-using System.Collections;
-using System.Xml;
-
-namespace Stetic.Undo
-{
- interface IDiffAdaptor
- {
- IEnumerable GetChildren (object parent);
- string GetUndoId (object childObject);
- object FindChild (object parent, string undoId);
- void RemoveChild (object parent, string undoId);
- void AddChild (object parent, XmlElement data, string insertAfter);
- XmlElement SerializeChild (object child);
- IDiffAdaptor GetChildAdaptor (object child);
-
- IEnumerable GetProperties (object obj);
- object GetPropertyByName (object obj, string name);
- string GetPropertyName (object property);
- string GetPropertyValue (object obj, object property);
- void SetPropertyValue (object obj, string name, string value);
- void ResetPropertyValue (object obj, string name);
-
- IEnumerable GetSignals (object obj);
- object GetSignal (object obj, string name, string handler);
- void GetSignalInfo (object signal, out string name, out string handler);
- void AddSignal (object obj, string name, string handler);
- void RemoveSignal (object obj, string name, string handler);
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/UndoManager.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/UndoManager.cs
deleted file mode 100644
index 12e5f14d84..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/UndoManager.cs
+++ /dev/null
@@ -1,315 +0,0 @@
-
-using System;
-using System.Xml;
-using System.Collections;
-using Stetic.Wrapper;
-
-namespace Stetic
-{
- // This class holds an xml tree which describes the whole widget structure being designed.
- // It is used by the Undo/Redo infrastructure to keep track of changes in widgets.
- public class UndoManager
- {
- Hashtable elements = new Hashtable ();
- XmlDocument doc;
- ObjectWrapper root;
- AtomicChangeTracker atomicChangeTracker;
- bool isDefaultManager;
-
- public event UndoCheckpointHandler UndoCheckpoint;
-
- public UndoManager ()
- {
- atomicChangeTracker = new AtomicChangeTracker ();
- atomicChangeTracker.undoManager = this;
- }
-
- internal UndoManager (bool isDefaultManager): this ()
- {
- this.isDefaultManager = isDefaultManager;
- }
-
- public void SetRoot (ObjectWrapper wrapper)
- {
- root = wrapper;
- wrapper.UndoManager = this;
- elements.Clear ();
-
- doc = new XmlDocument ();
- UndoWriter writer = new UndoWriter (doc, this);
- writer.WriteObject (wrapper);
- }
-
- internal bool CanNotifyChanged (ObjectWrapper wrapper)
- {
- if (!InAtomicChange) {
- if (IsRegistered (wrapper) && UndoCheckpoint != null)
- UndoCheckpoint (this, new UndoCheckpointEventArgs (new ObjectWrapper[] { wrapper }));
- return true;
- } else
- return atomicChangeTracker.ProcessChange (wrapper);
- }
-
- public IAtomicChange AtomicChange {
- get {
- atomicChangeTracker.Count++;
- return atomicChangeTracker;
- }
- }
-
- public bool InAtomicChange {
- get { return atomicChangeTracker.InAtomicChange; }
- }
-
- // This method can be called by containers to register new objects in the tree.
- // Unless an object is registered in this way, no status will be tracked for it.
- // The provided status element must be a direct or indirect child of the parent status.
- internal void RegisterObject (ObjectWrapper w, XmlElement status)
- {
- VerifyManager ();
-
- if (IsRegistered (w))
- throw new InvalidOperationException ("Object already registered: " + w.GetType ());
-
- elements [w] = GetLocalElement (status);
-
- w.Disposed += OnObjectDisposed;
- }
-
- void OnObjectDisposed (object s, EventArgs a)
- {
- ObjectWrapper w = (ObjectWrapper) s;
- UnregisterObject (w);
- w.Disposed -= OnObjectDisposed;
- }
-
- // This method can be called to update the xml tree, for example when a change in the
- // object is detected.
- internal void UpdateObjectStatus (ObjectWrapper w, XmlElement status)
- {
- VerifyManager ();
-
- XmlElement oldElem = (XmlElement) elements [w];
- if (oldElem == null)
- throw new InvalidOperationException ("Could not update unregistered object of type " + w.GetType ());
-
- if (oldElem != status) {
- XmlElement newElem = GetLocalElement (status);
- if (oldElem.ParentNode != null) {
- oldElem.ParentNode.ReplaceChild (newElem, oldElem);
- elements [w] = newElem;
- } else {
- if (w != root)
- throw new InvalidOperationException ("Root element does not match the root widget: " + w.GetType ());
- elements [w] = newElem;
- }
- }
- }
-
- // Returns the xml that describes the specified widget (including information for all
- // children of the widget).
- internal XmlElement GetObjectStatus (ObjectWrapper w)
- {
- VerifyManager ();
-
- XmlElement elem = (XmlElement) elements [w];
- if (elem == null)
- throw new InvalidOperationException ("No status found for object of type " + w.GetType ());
- return elem;
- }
-
- internal bool IsRegistered (ObjectWrapper w)
- {
- return elements.ContainsKey (w);
- }
-
- internal void UnregisterObject (ObjectWrapper w)
- {
- VerifyManager ();
- elements.Remove (w);
- }
-
- void VerifyManager ()
- {
- if (isDefaultManager)
- throw new InvalidOperationException ("The default UndoManager can't track changes in objects.");
- }
-
- XmlElement GetLocalElement (XmlElement elem)
- {
- if (elem.OwnerDocument != doc)
- throw new InvalidOperationException ("Invalid document owner.");
- return elem;
- }
-
- internal void NotifyUndoCheckpoint (ObjectWrapper[] obs)
- {
- if (UndoCheckpoint != null)
- UndoCheckpoint (this, new UndoCheckpointEventArgs (obs));
- }
-
- internal void Dump ()
- {
- Console.WriteLine ("--------------------------------------");
- Console.WriteLine ("UNDO STATUS:");
- Console.WriteLine (GetObjectStatus (root).OuterXml);
- Console.WriteLine ("--------------------------------------");
- }
- }
-
- public delegate void UndoCheckpointHandler (object sender, UndoCheckpointEventArgs args);
-
- public class UndoCheckpointEventArgs: EventArgs
- {
- ObjectWrapper[] objects;
-
- internal UndoCheckpointEventArgs (ObjectWrapper[] objects)
- {
- this.objects = objects;
- }
-
- public ObjectWrapper[] ModifiedObjects {
- get { return objects; }
- }
- }
-
- // This is a special writer use to generate status info from widgets.
- // This writer won't recurse through objects which are already registered
- // in the provided UndoManager.
- class UndoWriter: ObjectWriter
- {
- UndoManager undoManager;
- bool allowMarkers = true;
-
- public UndoWriter (XmlDocument doc, UndoManager undoManager): base (doc, FileFormat.Native)
- {
- this.undoManager = undoManager;
- CreateUndoInfo = true;
- }
-
- public override XmlElement WriteObject (ObjectWrapper wrapper)
- {
- Wrapper.Widget ww = wrapper as Wrapper.Widget;
-
- // If the object is already registered, skip it (just create a dummy object)
- if (allowMarkers && ww != null && undoManager.IsRegistered (ww) && !ww.RequiresUndoStatusUpdate) {
- XmlElement marker = XmlDocument.CreateElement ("widget");
- marker.SetAttribute ("unchanged_marker","yes");
- return marker;
- }
-
- // Don't allow markers in indirect children, since those are not checked
- // when creating the diff
- bool oldAllow = allowMarkers;
- allowMarkers = false;
- XmlElement elem = base.WriteObject (wrapper);
- allowMarkers = oldAllow;
-
- if (ww != null) {
- ww.RequiresUndoStatusUpdate = false;
- }
-
- // Register the object, so it is correctly bound to this xml element
- if (undoManager.IsRegistered (wrapper))
- undoManager.UnregisterObject (wrapper);
- undoManager.RegisterObject (wrapper, elem);
-
- return elem;
- }
- }
-
- class UndoReader: ObjectReader
- {
- UndoManager undoManager;
-
- public UndoReader (IProject proj, FileFormat format, UndoManager undoManager): base (proj, format)
- {
- this.undoManager = undoManager;
- }
-
- public override ObjectWrapper ReadObject (XmlElement elem, ObjectWrapper root)
- {
- ObjectWrapper ww = base.ReadObject (elem, root);
- if (ww is Widget)
- undoManager.RegisterObject ((Widget)ww, elem);
- return ww;
- }
-
- public override void ReadExistingObject (ObjectWrapper wrapper, XmlElement elem)
- {
- base.ReadExistingObject (wrapper, elem);
- if (wrapper is Widget)
- undoManager.RegisterObject ((Widget)wrapper, elem);
- }
- }
-
- public interface IAtomicChange: IDisposable
- {
- void Delay ();
- }
-
- class AtomicChangeTracker: IAtomicChange
- {
- public int Count;
- public ArrayList ChangeEventPending = new ArrayList ();
- public UndoManager undoManager;
- bool delayed;
-
- public bool InAtomicChange {
- get { return Count > 0; }
- }
-
- public bool ProcessChange (ObjectWrapper wrapper)
- {
- if (!ChangeEventPending.Contains (wrapper)) {
- ChangeEventPending.Add (wrapper);
- delayed = false;
- }
- return false;
- }
-
- public void Delay ()
- {
- delayed = true;
- }
-
- public void Dispose ()
- {
- if (Count == 0)
- return;
-
- if (Count == 1) {
- // The change events fired here may generate changes in other
- // objects. Those changes will also be included in the transaction.
- // So, the ChangeEventPending array may grow while calling NotifyChanged,
- // and that's ok.
-
- for (int n=0; n < ChangeEventPending.Count; n++) {
- ((ObjectWrapper)ChangeEventPending[n]).FireObjectChangedEvent ();
- }
-
- // Remove from the list the widgets that have been disposed. It means that
- // they have been deleted. That change will be recorded by their parents.
- // Remove as well wrappers that are not registered, since there won't be
- // status information for them.
- for (int n=0; n<ChangeEventPending.Count; n++) {
- ObjectWrapper w = (ObjectWrapper)ChangeEventPending[n];
- if (w.IsDisposed || !undoManager.IsRegistered (w)) {
- ChangeEventPending.RemoveAt (n);
- n--;
- }
- }
-
- ObjectWrapper[] obs = (ObjectWrapper[]) ChangeEventPending.ToArray (typeof(ObjectWrapper));
- ChangeEventPending.Clear ();
- Count = 0;
-
- if (!delayed)
- undoManager.NotifyUndoCheckpoint (obs);
- delayed = false;
- }
- else
- Count--;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/XmlDiffAdaptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/XmlDiffAdaptor.cs
deleted file mode 100644
index 5d30c15078..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/undo/XmlDiffAdaptor.cs
+++ /dev/null
@@ -1,230 +0,0 @@
-
-using System;
-using System.Collections;
-using System.Xml;
-
-namespace Stetic.Undo
-{
- class XmlDiffAdaptor: IDiffAdaptor
- {
- string childElementName;
- string propsElementName;
- bool processProperties = true;
- XmlDiffAdaptor childAdaptor;
-
- public XmlDiffAdaptor ChildAdaptor {
- get { return childAdaptor; }
- set { childAdaptor = value; }
- }
-
- public string ChildElementName {
- get { return childElementName; }
- set { childElementName = value; }
- }
-
- public string PropsElementName {
- get { return propsElementName; }
- set { propsElementName = value; }
- }
-
- public bool ProcessProperties {
- get { return processProperties; }
- set { processProperties = value; }
- }
-
- public IEnumerable GetChildren (object parent)
- {
- if (childElementName != null)
- return ((XmlElement)parent).SelectNodes (childElementName);
- else
- return new object[0];
- }
-
- public string GetUndoId (object childObject)
- {
- return ((XmlElement)childObject).GetAttribute ("undoId");
- }
-
- public object FindChild (object parent, string undoId)
- {
- return ((XmlElement) parent).SelectSingleNode (childElementName + "[@undoId='" + undoId + "']");
- }
-
- public void RemoveChild (object parent, string undoId)
- {
- XmlElement elem = (XmlElement) parent;
- XmlElement child = (XmlElement) elem.SelectSingleNode (childElementName + "[@undoId='" + undoId + "']");
- if (child != null)
- elem.RemoveChild (child);
- }
-
- public void AddChild (object parent, XmlElement newNode, string insertAfter)
- {
- XmlElement status = (XmlElement) parent;
- if (newNode.OwnerDocument != status.OwnerDocument)
- newNode = (XmlElement) status.OwnerDocument.ImportNode (newNode, true);
-
- if (insertAfter != null) {
- XmlElement statusChild = (XmlElement) status.SelectSingleNode (childElementName + "[@undoId='" + insertAfter + "']");
- if (statusChild != null)
- status.InsertAfter (newNode, statusChild);
- else
- status.AppendChild (newNode);
- } else {
- if (status.FirstChild != null)
- status.InsertBefore (newNode, status.FirstChild);
- else
- status.AppendChild (newNode);
- }
- }
-
- public XmlElement SerializeChild (object child)
- {
- return (XmlElement) child;
- }
-
- public object DeserializeChild (XmlElement data)
- {
- return data;
- }
-
- public IDiffAdaptor GetChildAdaptor (object child)
- {
- if (childAdaptor != null)
- return childAdaptor;
- else
- return this;
- }
-
- XmlElement GetPropsElem (object obj, bool create)
- {
- if (propsElementName != null) {
- XmlElement elem = ((XmlElement)obj) [propsElementName];
- if (elem == null && create) {
- elem = ((XmlElement)obj).OwnerDocument.CreateElement (propsElementName);
- ((XmlElement)obj).AppendChild (elem);
- }
- return elem;
- }
- else
- return (XmlElement) obj;
- }
-
- public IEnumerable GetProperties (object obj)
- {
- XmlElement elem = GetPropsElem (obj, false);
- if (elem != null && processProperties) {
- XmlAttribute at = elem.Attributes ["name"];
- if (at != null)
- yield return at;
- at = elem.Attributes ["id"];
- if (at != null)
- yield return at;
- foreach (XmlElement e in elem.SelectNodes ("property"))
- yield return e;
- } else
- yield break;
- }
-
- public object GetPropertyByName (object obj, string name)
- {
- XmlElement elem = GetPropsElem (obj, false);
- if (elem == null)
- return null;
- XmlElement prop = (XmlElement) elem.SelectSingleNode ("property[@name='" + name + "']");
- if (prop != null)
- return prop;
- return elem.Attributes [name];
- }
-
- public string GetPropertyName (object property)
- {
- if (property is XmlElement)
- return ((XmlElement)property).GetAttribute ("name");
- else
- return ((XmlAttribute)property).LocalName;
- }
-
- public string GetPropertyValue (object obj, object property)
- {
- if (property is XmlElement)
- return ((XmlElement)property).InnerText;
- else
- return ((XmlAttribute)property).Value;
- }
-
- public void SetPropertyValue (object obj, string name, string value)
- {
- XmlElement elem = GetPropsElem (obj, true);
- if (name == "id" || name == "name") {
- elem.SetAttribute (name, value);
- } else {
- XmlElement prop = (XmlElement) elem.SelectSingleNode ("property[@name='" + name + "']");
- if (prop == null) {
- prop = elem.OwnerDocument.CreateElement ("property");
- prop.SetAttribute ("name", name);
- elem.AppendChild (prop);
- }
- prop.InnerText = value;
- }
- }
-
- public void ResetPropertyValue (object obj, string name)
- {
- XmlElement elem = GetPropsElem (obj, false);
- if (elem == null)
- return;
- XmlElement prop = (XmlElement) elem.SelectSingleNode ("property[@name='" + name + "']");
- if (prop != null)
- elem.RemoveChild (prop);
- else {
- XmlAttribute at = elem.Attributes [name];
- if (at != null)
- elem.Attributes.Remove (at);
- }
- }
-
- public IEnumerable GetSignals (object obj)
- {
- XmlElement elem = GetPropsElem (obj, false);
- if (elem != null && processProperties)
- return elem.SelectNodes ("signal");
- else
- return Type.EmptyTypes;
- }
-
- public object GetSignal (object obj, string name, string handler)
- {
- XmlElement elem = GetPropsElem (obj, false);
- if (elem == null)
- return null;
- return elem.SelectSingleNode ("signal[@name='" + name + "' and @handler='" + handler + "']");
- }
-
- public void GetSignalInfo (object signal, out string name, out string handler)
- {
- XmlElement elem = (XmlElement) signal;
- name = elem.GetAttribute ("name");
- handler = elem.GetAttribute ("handler");
- }
-
- public void AddSignal (object obj, string name, string handler)
- {
- XmlElement elem = GetPropsElem (obj, true);
- XmlElement signal = elem.OwnerDocument.CreateElement ("signal");
- signal.SetAttribute ("name", name);
- signal.SetAttribute ("handler", handler);
- elem.AppendChild (signal);
- }
-
- public void RemoveSignal (object obj, string name, string handler)
- {
- XmlElement elem = GetPropsElem (obj, false);
- if (elem == null)
- return;
- XmlElement prop = (XmlElement) elem.SelectSingleNode ("signal[@name='" + name + "' && @handler='" + handler + "']");
- if (prop != null)
- elem.RemoveChild (prop);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/AboutDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/AboutDialog.cs
deleted file mode 100644
index 52da310dbf..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/AboutDialog.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-
-namespace Stetic.Wrapper {
-
- public class AboutDialog : Window {
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
-
- if (!initialized) {
- // FIXME; set from Project eventually
- about.Name = "My Application";
- }
- }
-
- Gtk.AboutDialog about {
- get {
- return (Gtk.AboutDialog)Wrapped;
- }
- }
-
- string logo;
- public string Logo {
- get {
- return logo;
- }
- set {
- logo = value;
- about.Logo = new Gdk.Pixbuf (logo);
- }
- }
-
- // In the underlying representation, WebsiteLabel is always set
- // if Website is; if you set Website to something, and WebsiteLabel
- // is null, then WebsiteLabel gets set to match Website. There are
- // two problems with this for us:
- //
- // 1. If you type "http..." into Website while WebsiteLabel is
- // blank, WebsiteLabel ends up being forcibly set to just "h".
- //
- // 2. If the user decides s/he wants to get rid of WebsiteLabel,
- // they have to actually copy the URL from Website over it.
- //
- // In Stetic's representation, WebsiteLabel is always "what to show
- // *instead of* Website", and if it's empty, then you see the raw URL.
-
- public string Website {
- get {
- return about.Website;
- }
- set {
- if (website_label == null)
- about.WebsiteLabel = value;
- about.Website = value;
- }
- }
-
- string website_label;
- public string WebsiteLabel {
- get {
- return website_label;
- }
- set {
- if (value == "" || value == null) {
- about.WebsiteLabel = about.Website;
- website_label = null;
- } else {
- about.WebsiteLabel = value;
- website_label = value;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Action.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Action.cs
deleted file mode 100644
index bc6dd51c91..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Action.cs
+++ /dev/null
@@ -1,504 +0,0 @@
-
-using System;
-using System.Text;
-using System.Xml;
-using System.CodeDom;
-using System.Collections;
-using Stetic.Undo;
-
-namespace Stetic.Wrapper
-{
- public sealed class Action: Stetic.Wrapper.Object, IRadioGroupManagerProvider
- {
- ActionType type;
- bool drawAsRadio;
- int radioValue;
- bool active;
- string name;
- string accelerator;
- ActionGroup group;
-
- string oldDefaultName;
- string nameRoot;
-
- static RadioActionGroupManager GroupManager = new RadioActionGroupManager ();
-
- public enum ActionType {
- Action,
- Toggle,
- Radio
- }
-
- public event EventHandler Activated;
- public event EventHandler Toggled;
- public event Gtk.ChangedHandler Changed;
- public event EventHandler Deleted;
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- }
-
- public Gtk.Action GtkAction {
- get { return (Gtk.Action) Wrapped; }
- }
-
- public override string Name {
- get {
- if (name == null || name.Length == 0) {
- name = nameRoot = oldDefaultName = GetDefaultName ();
- if (group != null)
- name = group.GetValidName (this, name);
- }
- return name;
- }
- set {
- name = nameRoot = value;
- if (group != null)
- name = group.GetValidName (this, name);
- EmitNotify ("Name");
- }
- }
-
- public string Label {
- get { return GtkAction.Label; }
- set { GtkAction.Label = value; EmitNotify ("Label"); }
- }
-
- public string StockId {
- get { return GtkAction.StockId; }
- set { GtkAction.StockId = value; EmitNotify ("StockId"); }
- }
-
- public override string WrappedTypeName {
- get {
- if (type == ActionType.Action)
- return "Gtk.Action";
- else if (type == ActionType.Toggle)
- return "Gtk.ToggleAction";
- else
- return "Gtk.RadioAction";
- }
- }
-
- IRadioGroupManager IRadioGroupManagerProvider.GetGroupManager ()
- {
- return GroupManager;
- }
-
- internal void UpdateNameIndex ()
- {
- // Adds a number to the action name if the current name already
- // exists in the action group.
-
- string vname = group.GetValidName (this, Name);
- if (vname != Name) {
- name = vname;
- EmitNotify ("Name");
- }
- }
-
- string GetDefaultName ()
- {
- // Don't use the label for stock actions, since it depends on the current locale
- if (!string.IsNullOrEmpty (GtkAction.StockId)) {
- if (GtkAction.StockId.StartsWith ("gtk-"))
- return GetIdentifier (GtkAction.StockId.Substring (4));
- if (GtkAction.StockId.StartsWith ("gnome-stock-"))
- return GetIdentifier (GtkAction.StockId.Substring (12));
- }
-
- if (!string.IsNullOrEmpty (GtkAction.Label))
- return GetIdentifier (GtkAction.Label);
-
- if (!string.IsNullOrEmpty (GtkAction.StockId))
- return GetIdentifier (GtkAction.StockId);
-
- return "Action";
- }
-
- public ActionType Type {
- get { return type; }
- set {
- if (type == value)
- return;
- type = value;
- if (type == ActionType.Radio)
- Group = GroupManager.LastGroup;
- else
- Group = null;
-
- EmitNotify ("Type");
- }
- }
-
- public bool DrawAsRadio {
- get { return drawAsRadio; }
- set { drawAsRadio = value; EmitNotify ("DrawAsRadio"); }
- }
-
- public int Value {
- get { return radioValue; }
- set { radioValue = value; EmitNotify ("Value"); }
- }
-
- public string Accelerator {
- get { return accelerator; }
- set { accelerator = value; EmitNotify ("Accelerator"); }
- }
-
- public bool Active {
- get { return active; }
- set {
- active = value;
- if (Activated != null)
- Activated (this, EventArgs.Empty);
- if (Toggled != null)
- Toggled (this, EventArgs.Empty);
- if (Changed != null)
- Changed (this, new Gtk.ChangedArgs ());
- }
- }
-
- public string MenuLabel {
- get {
- if (GtkAction.Label != null && GtkAction.Label.Length > 0)
- return GtkAction.Label;
-
- if (GtkAction.StockId == null)
- return "";
-
- Gtk.StockItem item = Gtk.Stock.Lookup (GtkAction.StockId);
- if (item.Label != null)
- return item.Label;
-
- return "";
- }
- }
-
- public string ToolLabel {
- get {
- if (GtkAction.ShortLabel != null && GtkAction.ShortLabel.Length > 0)
- return GtkAction.ShortLabel;
- else
- return MenuLabel;
- }
- }
-
- public ActionGroup ActionGroup {
- get { return group; }
- }
-
- public string Group {
- get {
- return GroupManager.GetGroup (this);
- }
- set {
- if (value != null && value.Length > 0)
- Type = ActionType.Radio;
- GroupManager.SetGroup (this, value);
- EmitNotify ("Group");
- }
- }
-
- public void Delete ()
- {
- if (group != null)
- group.Actions.Remove (this);
- if (Deleted != null)
- Deleted (this, EventArgs.Empty);
- Dispose ();
- }
-
- protected override void EmitNotify (string propertyName)
- {
- if (propertyName == "Label" || propertyName == "StockId") {
- // If the current name is a name generated from label or stockid,
- // we update here the name again
- if (nameRoot == oldDefaultName)
- Name = GetDefaultName ();
- oldDefaultName = GetDefaultName ();
- }
- base.EmitNotify (propertyName);
- }
-
- public override XmlElement Write (ObjectWriter writer)
- {
- XmlElement elem = writer.XmlDocument.CreateElement ("action");
- elem.SetAttribute ("id", Name);
- WidgetUtils.GetProps (this, elem);
- WidgetUtils.GetSignals (this, elem);
- if (writer.CreateUndoInfo)
- elem.SetAttribute ("undoId", UndoId);
- return elem;
- }
-
- public override void Read (ObjectReader reader, XmlElement elem)
- {
- Gtk.Action ac = new Gtk.Action ("", "");
-
- ClassDescriptor klass = Registry.LookupClassByName ("Gtk.Action");
- ObjectWrapper.Bind (reader.Project, klass, this, ac, true);
-
- WidgetUtils.ReadMembers (klass, this, ac, elem);
- name = nameRoot = oldDefaultName = elem.GetAttribute ("id");
-
- string uid = elem.GetAttribute ("undoId");
- if (uid.Length > 0)
- UndoId = uid;
- }
-
- public Action Clone ()
- {
- Action a = (Action) ObjectWrapper.Create (Project, new Gtk.Action ("", ""), this);
- a.CopyFrom (this);
- return a;
- }
-
- public void CopyFrom (Action action)
- {
- type = action.type;
- drawAsRadio = action.drawAsRadio;
- radioValue = action.radioValue;
- active = action.active;
- name = action.name;
- GtkAction.HideIfEmpty = action.GtkAction.HideIfEmpty;
- GtkAction.IsImportant = action.GtkAction.IsImportant;
- GtkAction.Label = action.GtkAction.Label;
- GtkAction.Sensitive = action.GtkAction.Sensitive;
- GtkAction.ShortLabel = action.GtkAction.ShortLabel;
- GtkAction.StockId = action.GtkAction.StockId;
- GtkAction.Tooltip = action.GtkAction.Tooltip;
- GtkAction.Visible = action.GtkAction.Visible;
- GtkAction.VisibleHorizontal = action.GtkAction.VisibleHorizontal;
- GtkAction.VisibleVertical = action.GtkAction.VisibleVertical;
-
- Signals.Clear ();
- foreach (Signal s in action.Signals)
- Signals.Add (new Signal (s.SignalDescriptor, s.Handler, s.After));
-
- NotifyChanged ();
- }
-
- public Gtk.Widget CreateIcon (Gtk.IconSize size)
- {
- if (GtkAction.StockId == null)
- return null;
-
- Gdk.Pixbuf px = Project.IconFactory.RenderIcon (Project, GtkAction.StockId, size);
- if (px != null)
- return new Gtk.Image (px);
- else
- return GtkAction.CreateIcon (size);
- }
-
- public Gdk.Pixbuf RenderIcon (Gtk.IconSize size)
- {
- if (GtkAction.StockId == null)
- return null;
-
- Gdk.Pixbuf px = Project.IconFactory.RenderIcon (Project, GtkAction.StockId, size);
- if (px != null)
- return px;
-
- Gtk.IconSet iset = Gtk.IconFactory.LookupDefault (GtkAction.StockId);
- if (iset == null)
- return WidgetUtils.MissingIcon;
- else
- return iset.RenderIcon (new Gtk.Style (), Gtk.TextDirection.Ltr, Gtk.StateType.Normal, size, null, "");
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- CodeObjectCreateExpression exp = new CodeObjectCreateExpression ();
-
- PropertyDescriptor prop = (PropertyDescriptor) ClassDescriptor ["Name"];
- exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType));
-
- prop = (PropertyDescriptor) ClassDescriptor ["Label"];
- string lab = (string) prop.GetValue (Wrapped);
- if (lab == "") lab = null;
- exp.Parameters.Add (ctx.GenerateValue (lab, prop.RuntimePropertyType, prop.Translatable));
-
- prop = (PropertyDescriptor) ClassDescriptor ["Tooltip"];
- exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType, prop.Translatable));
-
- prop = (PropertyDescriptor) ClassDescriptor ["StockId"];
- exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType, prop.Translatable));
-
- if (type == ActionType.Action)
- exp.CreateType = new CodeTypeReference ("Gtk.Action", CodeTypeReferenceOptions.GlobalReference);
- else if (type == ActionType.Toggle)
- exp.CreateType = new CodeTypeReference ("Gtk.ToggleAction", CodeTypeReferenceOptions.GlobalReference);
- else {
- exp.CreateType = new CodeTypeReference ("Gtk.RadioAction", CodeTypeReferenceOptions.GlobalReference);
- prop = (PropertyDescriptor) ClassDescriptor ["Value"];
- exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), typeof(int)));
- }
- return exp;
- }
-
- internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- if (Type == ActionType.Radio) {
- CodeExpression groupExp = GroupManager.GenerateGroupExpression (ctx, this);
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "Group"),
- groupExp)
- );
- }
- else if (type == ActionType.Toggle) {
- if (Active) {
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "Active"),
- new CodePrimitiveExpression (true))
- );
- }
- if (DrawAsRadio) {
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "DrawAsRadio"),
- new CodePrimitiveExpression (true))
- );
- }
- }
- base.GenerateBuildCode (ctx, var);
- }
-
- internal void SetActionGroup (ActionGroup g)
- {
- group = g;
- }
-
- string GetIdentifier (string name)
- {
- StringBuilder sb = new StringBuilder ();
-
- bool wstart = false;
- foreach (char c in name) {
- if (c == '_' || (int)c > 127) // No underline, no unicode
- continue;
- if (c == '-' || c == ' ' || !char.IsLetterOrDigit (c)) {
- wstart = true;
- continue;
- }
- if (wstart) {
- sb.Append (char.ToUpper (c));
- wstart = false;
- } else
- sb.Append (c);
- }
- return sb.ToString () + "Action";
- }
-
- internal override UndoManager GetUndoManagerInternal ()
- {
- if (group != null)
- return group.GetUndoManagerInternal ();
- else
- return base.GetUndoManagerInternal ();
- }
-
- DiffGenerator GetDiffGenerator ()
- {
- DiffGenerator gen = new DiffGenerator ();
- gen.CurrentStatusAdaptor = new ActionDiffAdaptor (Project);
- gen.NewStatusAdaptor = new XmlDiffAdaptor ();
- return gen;
- }
-
- public override object GetUndoDiff ()
- {
- XmlElement oldElem = UndoManager.GetObjectStatus (this);
- UndoWriter writer = new UndoWriter (oldElem.OwnerDocument, UndoManager);
- XmlElement newElem = Write (writer);
- ObjectDiff actionsDiff = GetDiffGenerator().GetDiff (this, oldElem);
- UndoManager.UpdateObjectStatus (this, newElem);
- return actionsDiff;
- }
-
- public override object ApplyUndoRedoDiff (object diff)
- {
- ObjectDiff actionsDiff = (ObjectDiff) diff;
-
- XmlElement status = UndoManager.GetObjectStatus (this);
-
- DiffGenerator differ = GetDiffGenerator();
- differ.ApplyDiff (this, actionsDiff);
- actionsDiff = differ.GetDiff (this, status);
-
- UndoWriter writer = new UndoWriter (status.OwnerDocument, UndoManager);
- XmlElement newElem = Write (writer);
- UndoManager.UpdateObjectStatus (this, newElem);
-
- return actionsDiff;
- }
- }
-
- [Serializable]
- public class ActionCollection: CollectionBase
- {
- [NonSerialized]
- ActionGroup group;
-
- public ActionCollection ()
- {
- }
-
- internal ActionCollection (ActionGroup group)
- {
- this.group = group;
- }
-
- public void Add (Action action)
- {
- List.Add (action);
- }
-
- public void Insert (int i, Action action)
- {
- List.Insert (i, action);
- }
-
- public Action this [int n] {
- get { return (Action) List [n]; }
- }
-
- public void Remove (Action action)
- {
- List.Remove (action);
- }
-
- public bool Contains (Action action)
- {
- return List.Contains (action);
- }
-
- public void CopyTo (Action[] array, int index)
- {
- List.CopyTo (array, index);
- }
-
- protected override void OnInsertComplete (int index, object val)
- {
- if (group != null)
- group.NotifyActionAdded ((Action) val);
- }
-
- protected override void OnRemoveComplete (int index, object val)
- {
- if (group != null)
- group.NotifyActionRemoved ((Action)val);
- }
-
- protected override void OnSetComplete (int index, object oldv, object newv)
- {
- if (group != null) {
- group.NotifyActionRemoved ((Action) oldv);
- group.NotifyActionAdded ((Action) newv);
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionGroup.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionGroup.cs
deleted file mode 100644
index 1e3c7dbf1b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionGroup.cs
+++ /dev/null
@@ -1,425 +0,0 @@
-
-using System;
-using System.CodeDom;
-using System.Xml;
-using System.Collections;
-using Stetic.Undo;
-
-namespace Stetic.Wrapper
-{
- public sealed class ActionGroup: ObjectWrapper
- {
- string name;
- ActionCollection actions;
- ObjectWrapper owner;
- bool generatePublic = true;
-
- public event ActionEventHandler ActionAdded;
- public event ActionEventHandler ActionRemoved;
- public event ActionEventHandler ActionChanged;
-
- public ActionGroup ()
- {
- actions = new ActionCollection (this);
- }
-
- public ActionGroup (string name): this ()
- {
- this.name = name;
- }
-
- public override void Dispose ()
- {
- foreach (Action a in actions)
- a.Dispose ();
- base.Dispose ();
- }
-
- public ActionCollection Actions {
- get { return actions; }
- }
-
- public override string Name {
- get { return name; }
- set {
- name = value;
- NotifyChanged ();
- }
- }
-
- public bool GeneratePublic {
- get { return generatePublic; }
- set { generatePublic = value; }
- }
-
- public Action GetAction (string name)
- {
- foreach (Action ac in actions)
- if (ac.Name == name)
- return ac;
- return null;
- }
-
- internal string GetValidName (Action reqAction, string name)
- {
- int max = 0;
- bool found = false;
- foreach (Action ac in Actions) {
- if (ac == reqAction)
- continue;
-
- string bname;
- int index;
- WidgetUtils.ParseWidgetName (ac.Name, out bname, out index);
-
- if (name == ac.Name)
- found = true;
- if (name == bname && index > max)
- max = index;
- }
- if (found)
- return name + (max+1);
- else
- return name;
- }
-
- public override XmlElement Write (ObjectWriter writer)
- {
- XmlElement group = writer.XmlDocument.CreateElement ("action-group");
- group.SetAttribute ("name", name);
- if (writer.CreateUndoInfo)
- group.SetAttribute ("undoId", UndoId);
- foreach (Action ac in actions) {
- if (ac.Name.Length > 0)
- group.AppendChild (writer.WriteObject (ac));
- }
- return group;
- }
-
- public override void Read (ObjectReader reader, XmlElement elem)
- {
- name = elem.GetAttribute ("name");
- string uid = elem.GetAttribute ("undoId");
- if (uid.Length > 0)
- UndoId = uid;
- foreach (XmlElement child in elem.SelectNodes ("action")) {
- Action ac = new Action ();
- ac.Read (reader, child);
- actions.Add (ac);
- }
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- return new CodeObjectCreateExpression (
- typeof(Gtk.ActionGroup).ToGlobalTypeRef (),
- new CodePrimitiveExpression (Name)
- );
- }
-
- internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- foreach (Action action in Actions) {
- // Create the action
- CodeExpression acVarExp = ctx.GenerateInstanceExpression (action, action.GenerateObjectCreation (ctx));
- ctx.GenerateBuildCode (action, acVarExp);
- ctx.Statements.Add (
- new CodeMethodInvokeExpression (
- var,
- "Add",
- acVarExp,
- new CodePrimitiveExpression (action.Accelerator)
- )
- );
- }
- }
-
- internal void SetOwner (ObjectWrapper owner)
- {
- this.owner = owner;
- }
-
- internal override UndoManager GetUndoManagerInternal ()
- {
- if (owner != null)
- return owner.UndoManager;
- else
- return base.GetUndoManagerInternal ();
- }
-
- public override ObjectWrapper FindObjectByUndoId (string id)
- {
- ObjectWrapper ow = base.FindObjectByUndoId (id);
- if (ow != null) return ow;
-
- foreach (Action ac in Actions) {
- ow = ac.FindObjectByUndoId (id);
- if (ow != null)
- return ow;
- }
- return null;
- }
-
- DiffGenerator GetDiffGenerator ()
- {
- DiffGenerator gen = new DiffGenerator ();
- gen.CurrentStatusAdaptor = new ActionDiffAdaptor (Project);
- XmlDiffAdaptor xad = new XmlDiffAdaptor ();
- xad.ChildElementName = "action";
- gen.NewStatusAdaptor = xad;
- return gen;
- }
-
- public override object GetUndoDiff ()
- {
- XmlElement oldElem = UndoManager.GetObjectStatus (this);
- UndoWriter writer = new UndoWriter (oldElem.OwnerDocument, UndoManager);
-
- XmlElement newElem = Write (writer);
- ObjectDiff actionsDiff = GetDiffGenerator().GetDiff (this, oldElem);
- UndoManager.UpdateObjectStatus (this, newElem);
- return actionsDiff;
- }
-
- public override object ApplyUndoRedoDiff (object diff)
- {
- ObjectDiff actionsDiff = (ObjectDiff) diff;
-
- XmlElement status = UndoManager.GetObjectStatus (this);
-
- DiffGenerator differ = GetDiffGenerator();
- differ.ApplyDiff (this, actionsDiff);
- actionsDiff = differ.GetDiff (this, status);
-
- UndoWriter writer = new UndoWriter (status.OwnerDocument, UndoManager);
- XmlElement newElem = Write (writer);
- UndoManager.UpdateObjectStatus (this, newElem);
-
- return actionsDiff;
- }
-
- internal void NotifyActionAdded (Action ac)
- {
- ac.SetActionGroup (this);
- ac.ObjectChanged += OnActionChanged;
- ac.SignalAdded += OnSignalAdded;
- ac.SignalRemoved += OnSignalRemoved;
- ac.SignalChanged += OnSignalChanged;
-
- ac.UpdateNameIndex ();
-
- NotifyChanged ();
-
- if (ActionAdded != null)
- ActionAdded (this, new ActionEventArgs (ac));
- }
-
- internal void NotifyActionRemoved (Action ac)
- {
- ac.SetActionGroup (null);
- ac.ObjectChanged -= OnActionChanged;
- ac.SignalAdded -= OnSignalAdded;
- ac.SignalRemoved -= OnSignalRemoved;
- ac.SignalChanged -= OnSignalChanged;
-
- NotifyChanged ();
-
- if (ActionRemoved != null)
- ActionRemoved (this, new ActionEventArgs (ac));
- }
-
- void OnActionChanged (object s, ObjectWrapperEventArgs args)
- {
- NotifyChanged ();
- if (ActionChanged != null)
- ActionChanged (this, new ActionEventArgs ((Action) args.Wrapper));
- }
-
- void OnSignalAdded (object s, SignalEventArgs args)
- {
- OnSignalAdded (args);
- }
-
- void OnSignalRemoved (object s, SignalEventArgs args)
- {
- OnSignalRemoved (args);
- }
-
- void OnSignalChanged (object s, SignalChangedEventArgs args)
- {
- OnSignalChanged (args);
- }
- }
-
- public class ActionGroupCollection: CollectionBase
- {
- ActionGroup[] toClear;
- ObjectWrapper owner;
-
- internal void SetOwner (ObjectWrapper owner)
- {
- this.owner = owner;
- }
-
- public void Add (ActionGroup group)
- {
- List.Add (group);
- }
-
- public void Insert (int n, ActionGroup group)
- {
- List.Insert (n, group);
- }
-
- public ActionGroup this [int n] {
- get { return (ActionGroup) List [n]; }
- }
-
- public ActionGroup this [string name] {
- get {
- foreach (ActionGroup grp in List)
- if (grp.Name == name)
- return grp;
- return null;
- }
- }
-
- internal ObjectWrapper FindObjectByUndoId (string id)
- {
- foreach (ActionGroup ag in List) {
- ObjectWrapper ow = ag.FindObjectByUndoId (id);
- if (ow != null)
- return ow;
- }
- return null;
- }
-
- DiffGenerator GetDiffGenerator (IProject prj)
- {
- DiffGenerator gen = new DiffGenerator ();
- gen.CurrentStatusAdaptor = new ActionDiffAdaptor (prj);
- XmlDiffAdaptor xad = new XmlDiffAdaptor ();
- xad.ChildElementName = "action-group";
- xad.ProcessProperties = false;
- xad.ChildAdaptor = new XmlDiffAdaptor ();
- xad.ChildAdaptor.ChildElementName = "action";
- gen.NewStatusAdaptor = xad;
- return gen;
- }
-
- internal ObjectDiff GetDiff (IProject prj, XmlElement elem)
- {
- return GetDiffGenerator (prj).GetDiff (this, elem);
- }
-
- internal void ApplyDiff (IProject prj, ObjectDiff diff)
- {
- GetDiffGenerator (prj).ApplyDiff (this, diff);
- }
-
- public int IndexOf (ActionGroup group)
- {
- return List.IndexOf (group);
- }
-
- public void Remove (ActionGroup group)
- {
- List.Remove (group);
- }
-
- protected override void OnInsertComplete (int index, object val)
- {
- NotifyGroupAdded ((ActionGroup) val);
- }
-
- protected override void OnRemoveComplete (int index, object val)
- {
- NotifyGroupRemoved ((ActionGroup)val);
- }
-
- protected override void OnSetComplete (int index, object oldv, object newv)
- {
- NotifyGroupRemoved ((ActionGroup) oldv);
- NotifyGroupAdded ((ActionGroup) newv);
- }
-
- protected override void OnClear ()
- {
- toClear = new ActionGroup [Count];
- List.CopyTo (toClear, 0);
- }
-
- protected override void OnClearComplete ()
- {
- foreach (ActionGroup a in toClear)
- NotifyGroupRemoved (a);
- toClear = null;
- }
-
- void NotifyGroupAdded (ActionGroup grp)
- {
- grp.SetOwner (owner);
- grp.ObjectChanged += OnGroupChanged;
- if (ActionGroupAdded != null)
- ActionGroupAdded (this, new ActionGroupEventArgs (grp));
- }
-
- void NotifyGroupRemoved (ActionGroup grp)
- {
- grp.SetOwner (null);
- grp.ObjectChanged -= OnGroupChanged;
- if (ActionGroupRemoved != null)
- ActionGroupRemoved (this, new ActionGroupEventArgs (grp));
- }
-
- void OnGroupChanged (object s, ObjectWrapperEventArgs a)
- {
- if (ActionGroupChanged != null)
- ActionGroupChanged (this, new ActionGroupEventArgs ((ActionGroup)s));
- }
-
- public ActionGroup[] ToArray ()
- {
- ActionGroup[] groups = new ActionGroup [Count];
- List.CopyTo (groups, 0);
- return groups;
- }
-
- public event ActionGroupEventHandler ActionGroupAdded;
- public event ActionGroupEventHandler ActionGroupRemoved;
- public event ActionGroupEventHandler ActionGroupChanged;
- }
-
-
- public delegate void ActionEventHandler (object sender, ActionEventArgs args);
-
- public class ActionEventArgs: EventArgs
- {
- readonly Action action;
-
- public ActionEventArgs (Action ac)
- {
- action = ac;
- }
-
- public Action Action {
- get { return action; }
- }
- }
-
- public delegate void ActionGroupEventHandler (object sender, ActionGroupEventArgs args);
-
- public class ActionGroupEventArgs: EventArgs
- {
- readonly ActionGroup action;
-
- public ActionGroupEventArgs (ActionGroup ac)
- {
- action = ac;
- }
-
- public ActionGroup ActionGroup {
- get { return action; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionToolbarWrapper.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionToolbarWrapper.cs
deleted file mode 100644
index 1b973b8660..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionToolbarWrapper.cs
+++ /dev/null
@@ -1,294 +0,0 @@
-
-using System;
-using System.CodeDom;
-using System.Xml;
-using System.Collections;
-using Stetic.Editor;
-
-namespace Stetic.Wrapper
-{
- public class ActionToolbarWrapper: Container
- {
- ActionTree actionTree;
- XmlElement toolbarInfo;
- ToolbarStyle toolbarStyle;
- bool treeChanged;
- static Gtk.ToolbarStyle defaultStyle;
- static bool gotDefault;
-
- public enum ToolbarStyle {
- Icons,
- Text,
- Both,
- BothHoriz,
- Default
- }
-
- public ActionToolbarWrapper()
- {
- }
-
- public override void Dispose ()
- {
- DisposeTree ();
- base.Dispose ();
- }
-
- public static Gtk.Toolbar CreateInstance ()
- {
- ActionToolbar t = new ActionToolbar ();
- return t;
- }
-
- ActionToolbar toolbar {
- get { return (ActionToolbar) Wrapped; }
- }
-
- protected override bool AllowPlaceholders {
- get { return false; }
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- CreateTree ();
- toolbar.FillMenu (actionTree);
- }
-
- public override bool HExpandable {
- get {
- return toolbar.Orientation == Gtk.Orientation.Horizontal;
- }
- }
-
- public override bool VExpandable {
- get {
- return toolbar.Orientation == Gtk.Orientation.Vertical;
- }
- }
-
- public Gtk.Orientation Orientation {
- get {
- return toolbar.Orientation;
- }
- set {
- toolbar.Orientation = value;
- EmitContentsChanged ();
- }
- }
-
- public Gtk.IconSize IconSize {
- get { return toolbar.IconSize; }
- set { toolbar.IconSize = value; EmitNotify ("IconSize"); }
- }
-
- public ToolbarStyle ButtonStyle {
- get { return toolbarStyle; }
- set {
- toolbarStyle = value;
- if (value == ToolbarStyle.Default) {
- if (!gotDefault) {
- // Is there a better way of getting the default?
- Gtk.Window d = new Gtk.Window ("");
- Gtk.Toolbar t = new Gtk.Toolbar ();
- d.Add (t);
- defaultStyle = t.ToolbarStyle;
- d.Destroy ();
- gotDefault = true;
- }
- toolbar.ToolbarStyle = defaultStyle;
- } else {
- toolbar.ToolbarStyle = (Gtk.ToolbarStyle) ((int)value);
- }
- EmitNotify ("ButtonStyle");
- }
- }
-
- internal protected override void OnSelected ()
- {
- Loading = true;
- toolbar.ShowInsertPlaceholder = true;
- Loading = false;
- }
-
- internal protected override void OnUnselected ()
- {
- base.OnUnselected ();
- Loading = true;
- toolbar.ShowInsertPlaceholder = false;
- toolbar.Unselect ();
- Loading = false;
- }
-
- protected override XmlElement WriteProperties (ObjectWriter writer)
- {
- XmlElement elem = base.WriteProperties (writer);
- if (writer.Format == FileFormat.Native) {
- // The style is already stored in ButtonStyle
- GladeUtils.ExtractProperty (elem, "ToolbarStyle", "");
- if (toolbarInfo != null)
- elem.AppendChild (writer.XmlDocument.ImportNode (toolbarInfo, true));
- else
- elem.AppendChild (actionTree.Write (writer.XmlDocument, writer.Format));
- }
- return elem;
- }
-
- protected override void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- base.ReadProperties (reader, elem);
- toolbarInfo = elem ["node"];
- }
-
- protected override void OnNameChanged (WidgetNameChangedArgs args)
- {
- base.OnNameChanged (args);
- if (actionTree != null)
- actionTree.Name = Name;
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- BuildTree ();
- actionTree.Type = Gtk.UIManagerItemType.Toolbar;
- actionTree.Name = Name;
-
- CodeExpression exp = GenerateUiManagerElement (ctx, actionTree);
- if (exp != null)
- return new CodeCastExpression (typeof(Gtk.Toolbar).ToGlobalTypeRef (), exp);
- else
- return base.GenerateObjectCreation (ctx);
- }
-
- protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- if (toolbarStyle == ToolbarStyle.Default && prop.Name == "ToolbarStyle")
- return;
- else
- base.GeneratePropertySet (ctx, var, prop);
- }
-
- internal protected override void OnDesignerAttach (IDesignArea designer)
- {
- base.OnDesignerAttach (designer);
- BuildTree ();
-
- Loading = true;
- toolbar.FillMenu (actionTree);
- Loading = false;
-
- if (LocalActionGroups.Count == 0)
- LocalActionGroups.Add (new ActionGroup ("Default"));
- }
-
- protected override void EmitNotify (string propertyName)
- {
- base.EmitNotify (propertyName);
- toolbar.FillMenu (actionTree);
- }
-
- public override object GetUndoDiff ()
- {
- XmlElement oldElem = treeChanged ? UndoManager.GetObjectStatus (this) ["node"] : null;
- if (oldElem != null)
- oldElem = (XmlElement) oldElem.CloneNode (true);
-
- treeChanged = false;
- object baseDiff = base.GetUndoDiff ();
-
- if (oldElem != null) {
- XmlElement newElem = UndoManager.GetObjectStatus (this) ["node"];
- if (newElem != null && oldElem.OuterXml == newElem.OuterXml)
- oldElem = null;
- }
-
- if (baseDiff == null && oldElem == null)
- return null;
- else {
- object stat = toolbar.SaveStatus ();
- return new object[] { baseDiff, oldElem, stat };
- }
- }
-
- public override object ApplyUndoRedoDiff (object diff)
- {
- object[] data = (object[]) diff;
- object retBaseDiff;
- XmlElement oldNode = null;
-
- if (actionTree != null) {
- XmlElement status = UndoManager.GetObjectStatus (this);
- oldNode = status ["node"];
- if (oldNode != null)
- oldNode = (XmlElement) oldNode.CloneNode (true);
- }
- object oldStat = toolbar.SaveStatus ();
-
- if (data [0] != null)
- retBaseDiff = base.ApplyUndoRedoDiff (data [0]);
- else
- retBaseDiff = null;
-
- XmlElement xdiff = (XmlElement) data [1];
-
- if (xdiff != null) {
- XmlElement status = UndoManager.GetObjectStatus (this);
- XmlElement prevNode = status ["node"];
- if (prevNode != null)
- status.RemoveChild (prevNode);
- status.AppendChild (xdiff);
-
- if (actionTree != null) {
- Loading = true;
- DisposeTree ();
- CreateTree ();
- actionTree.Read (this, xdiff);
- toolbar.FillMenu (actionTree);
- Loading = false;
- }
- }
-
- // Restore the status after all menu structure has been properly built
- GLib.Timeout.Add (50, delegate {
- toolbar.RestoreStatus (data[2]);
- return false;
- });
-
- return new object [] { retBaseDiff, oldNode, oldStat };
- }
-
-
- void BuildTree ()
- {
- if (toolbarInfo != null) {
- DisposeTree ();
- CreateTree ();
- actionTree.Read (this, toolbarInfo);
- toolbarInfo = null;
- }
- }
-
- void CreateTree ()
- {
- actionTree = new ActionTree ();
- actionTree.Name = Name;
- actionTree.Type = Gtk.UIManagerItemType.Toolbar;
- actionTree.Changed += OnTreeChanged;
- }
-
- void DisposeTree ()
- {
- if (actionTree != null) {
- actionTree.Dispose ();
- actionTree.Changed -= OnTreeChanged;
- actionTree = null;
- }
- }
-
- void OnTreeChanged (object s, EventArgs a)
- {
- treeChanged = true;
- NotifyChanged ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionTree.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionTree.cs
deleted file mode 100644
index 82eae3e23d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ActionTree.cs
+++ /dev/null
@@ -1,351 +0,0 @@
-
-using System;
-using System.Text;
-using System.Xml;
-using System.CodeDom;
-using System.Collections;
-
-namespace Stetic.Wrapper
-{
-
- public class ActionTree: ActionTreeNode
- {
- public event EventHandler Changed;
-
- public ActionTree()
- {
- }
-
- public void GenerateBuildCode (GeneratorContext ctx, CodeFieldReferenceExpression uiManager)
- {
- StringBuilder sb = new StringBuilder ();
- sb.Append ("<ui>");
- GenerateUiString (sb);
- sb.Append ("</ui>");
-
- CodeMethodInvokeExpression exp = new CodeMethodInvokeExpression (
- uiManager,
- "AddUiFromString",
- new CodePrimitiveExpression (sb.ToString ())
- );
- ctx.Statements.Add (exp);
- }
-
- public ActionGroup[] GetRequiredGroups ()
- {
- ArrayList list = new ArrayList ();
- GetRequiredGroups (list);
- return (ActionGroup[]) list.ToArray (typeof(ActionGroup));
- }
-
- internal override void NotifyChanged ()
- {
- if (Changed != null)
- Changed (this, EventArgs.Empty);
- }
- }
-
- public class ActionTreeNode: IDisposable
- {
- Gtk.UIManagerItemType type;
- string name;
- Action action;
- ActionTreeNodeCollection children;
- ActionTreeNode parentNode;
- bool loading;
- string lastActionName;
-
- public ActionTreeNode ()
- {
- }
-
- public ActionTreeNode Clone ()
- {
- return new ActionTreeNode (type, name, action);
- }
-
- public ActionTreeNode (Gtk.UIManagerItemType type, string name, Action action)
- {
- this.type = type;
- this.name = name;
- this.action = action;
- if (this.action != null) {
- lastActionName = this.action.Name;
- this.action.Deleted += OnActionDeleted;
- this.action.ObjectChanged += OnActionChanged;
- }
- }
-
- public virtual void Dispose ()
- {
- if (action != null) {
- action.Deleted -= OnActionDeleted;
- action.ObjectChanged -= OnActionChanged;
- }
- if (children != null)
- foreach (ActionTreeNode node in children)
- node.Dispose ();
- }
-
- void OnActionDeleted (object s, EventArgs args)
- {
- if (parentNode != null)
- parentNode.Children.Remove (this);
- }
-
- void OnActionChanged (object s, ObjectWrapperEventArgs args)
- {
- // If the name of the action changes, consider it a change in
- // the node, since the generated xml will be different
-
- Action ac = (Action) args.Wrapper;
- if (ac.Name != lastActionName) {
- lastActionName = ac.Name;
- NotifyChanged ();
- }
- }
-
- internal virtual void NotifyChanged ()
- {
- if (parentNode != null)
- parentNode.NotifyChanged ();
- }
-
- public XmlElement Write (XmlDocument doc, FileFormat format)
- {
- XmlElement elem = doc.CreateElement ("node");
- if (name != null && name.Length > 0)
- elem.SetAttribute ("name", name);
- elem.SetAttribute ("type", type.ToString ());
- if (action != null)
- elem.SetAttribute ("action", action.Name);
-
- if (children != null) {
- foreach (ActionTreeNode child in children) {
- if (child.Action != null && child.Action.Name.Length == 0)
- continue;
- elem.AppendChild (child.Write (doc, format));
- }
- }
- return elem;
- }
-
- public void Read (Wrapper.Widget baseWidget, XmlElement elem)
- {
- name = elem.GetAttribute ("name");
- if (elem.HasAttribute ("type"))
- type = (Gtk.UIManagerItemType) Enum.Parse (typeof(Gtk.UIManagerItemType), elem.GetAttribute ("type"));
-
- // The name of an action may be empty in some situations (e.g. when adding a new action but before entering the name)
- XmlAttribute actionAt = elem.Attributes ["action"];
- if (actionAt != null) {
- string aname = actionAt.Value;
- foreach (ActionGroup grp in baseWidget.LocalActionGroups) {
- action = grp.GetAction (aname);
- if (action != null)
- break;
- }
- if (action == null) {
- foreach (ActionGroup group in baseWidget.Project.ActionGroups) {
- action = group.GetAction (aname);
- if (action != null)
- break;
- }
- }
- if (action != null) {
- lastActionName = action.Name;
- action.Deleted += OnActionDeleted;
- action.ObjectChanged += OnActionChanged;
- }
- }
-
- try {
- loading = true;
- foreach (XmlElement child in elem.SelectNodes ("node")) {
- ActionTreeNode node = new ActionTreeNode ();
- node.Read (baseWidget, child);
- Children.Add (node);
- }
- } finally {
- loading = false;
- }
- }
-
- public virtual void GenerateBuildCode (GeneratorContext ctx, CodeVariableReferenceExpression uiManager, string path)
- {
- CodeMethodInvokeExpression exp = new CodeMethodInvokeExpression (
- uiManager,
- "AddUi",
- new CodePrimitiveExpression (0),
- new CodePrimitiveExpression (path),
- new CodePrimitiveExpression (name),
- new CodePrimitiveExpression (action != null ? action.Name : null),
- new CodeFieldReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (typeof(Gtk.UIManagerItemType), CodeTypeReferenceOptions.GlobalReference)),
- type.ToString()
- ),
- new CodePrimitiveExpression (false)
- );
- ctx.Statements.Add (exp);
-
- string localName = (name != null && name.Length > 0 ? name : (action != null ? action.Name : null));
- if (localName != null) {
- if (path != "/")
- path = path + "/" + localName;
- else
- path += localName;
- }
-
- foreach (ActionTreeNode node in Children)
- node.GenerateBuildCode (ctx, uiManager, path);
- }
-
- public void GenerateUiString (StringBuilder sb)
- {
- sb.Append ('<').Append (type.ToString().ToLower());
-
- string name = this.name;
- if (String.IsNullOrEmpty (name) && action != null)
- name = action.Name;
-
- if (!String.IsNullOrEmpty (name))
- sb.Append (' ').Append ("name='").Append (name).Append ("'");
- if (action != null)
- sb.Append (' ').Append ("action='").Append (action.Name).Append ("'");
-
- if (Children.Count > 0) {
- sb.Append ('>');
- foreach (ActionTreeNode node in Children)
- node.GenerateUiString (sb);
- sb.Append ("</").Append (type.ToString().ToLower()).Append ('>');
- } else
- sb.Append ("/>");
- }
-
- protected void GetRequiredGroups (ArrayList list)
- {
- if (action != null && action.ActionGroup != null && !list.Contains (action.ActionGroup))
- list.Add (action.ActionGroup);
- foreach (ActionTreeNode node in Children)
- node.GetRequiredGroups (list);
- }
-
- public Gtk.UIManagerItemType Type {
- get { return type; }
- set { type = value; NotifyChanged (); }
- }
-
- public string Name {
- get { return name; }
- set { name = value; NotifyChanged (); }
- }
-
- public Action Action {
- get { return action; }
- }
-
- public ActionTreeNode ParentNode {
- get { return parentNode; }
- }
-
- public ActionTreeNodeCollection Children {
- get {
- if (children == null)
- children = new ActionTreeNodeCollection (this);
- return children;
- }
- }
-
- internal void NotifyChildAdded (ActionTreeNode node)
- {
- node.parentNode = this;
- if (!loading) {
- NotifyChanged ();
- if (ChildNodeAdded != null)
- ChildNodeAdded (this, new ActionTreeNodeArgs (node));
- }
- }
-
- internal void NotifyChildRemoved (ActionTreeNode node)
- {
- node.parentNode = null;
- if (!loading) {
- NotifyChanged ();
- if (ChildNodeRemoved != null)
- ChildNodeRemoved (this, new ActionTreeNodeArgs (node));
- }
- }
-
- public event ActionTreeNodeHanlder ChildNodeAdded;
- public event ActionTreeNodeHanlder ChildNodeRemoved;
- }
-
- public class ActionTreeNodeCollection: CollectionBase
- {
- ActionTreeNode parent;
-
- public ActionTreeNodeCollection (ActionTreeNode parent)
- {
- this.parent = parent;
- }
-
- public void Add (ActionTreeNode node)
- {
- List.Add (node);
- }
-
- public void Insert (int index, ActionTreeNode node)
- {
- List.Insert (index, node);
- }
-
- public int IndexOf (ActionTreeNode node)
- {
- return List.IndexOf (node);
- }
-
- public void Remove (ActionTreeNode node)
- {
- if (List.Contains (node))
- List.Remove (node);
- }
-
- public ActionTreeNode this [int n] {
- get { return (ActionTreeNode) List [n]; }
- set { List [n] = value; }
- }
-
- protected override void OnInsertComplete (int index, object val)
- {
- parent.NotifyChildAdded ((ActionTreeNode) val);
- }
-
- protected override void OnRemoveComplete (int index, object val)
- {
- parent.NotifyChildRemoved ((ActionTreeNode)val);
- }
-
- protected override void OnSetComplete (int index, object oldv, object newv)
- {
- parent.NotifyChildRemoved ((ActionTreeNode) oldv);
- parent.NotifyChildAdded ((ActionTreeNode) newv);
- }
- }
-
- public delegate void ActionTreeNodeHanlder (object ob, ActionTreeNodeArgs args);
-
- public class ActionTreeNodeArgs: EventArgs
- {
- readonly ActionTreeNode node;
-
- public ActionTreeNodeArgs (ActionTreeNode node)
- {
- this.node = node;
- }
-
- public ActionTreeNode Node {
- get { return node; }
- }
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Bin.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Bin.cs
deleted file mode 100644
index 4fd3ab2bee..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Bin.cs
+++ /dev/null
@@ -1,388 +0,0 @@
-using System;
-using System.CodeDom;
-using System.Reflection;
-
-namespace Stetic.Wrapper
-{
- public class Bin: Container
- {
- public static Gtk.Bin CreateInstance (ClassDescriptor klass)
- {
- if (klass.Name == "Gtk.Bin")
- return new CustomWidget ();
- else
- return null;
- }
-
- internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- if (ClassDescriptor.WrappedTypeName == "Gtk.Bin") {
-
- // Gtk.Bin needs a helper class which handles child allocation.
- // This class needs to be generated since Stetic won't be linked with
- // the app.
-
- bool found = false;
- foreach (CodeTypeDeclaration dec in ctx.GlobalCodeNamespace.Types) {
- if (dec.Name == "BinContainer") {
- found = true;
- break;
- }
- }
-
- if (!found)
- GenerateHelperClass (ctx);
-
- CodeMethodInvokeExpression attachExp = new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (ctx.GlobalCodeNamespace.Name + ".BinContainer", CodeTypeReferenceOptions.GlobalReference)),
- "Attach",
- var
- );
-
- // If the Bin has its own action groups, we need to register
- // the resulting UIManager in the BinContainer, but it needs to be done
- // after generating it. Right now, we only keep a reference to
- // the BinContainer.
-
- string binContainerVar = null;
-
- if (IsTopLevel && LocalActionGroups.Count > 0) {
- binContainerVar = ctx.NewId ();
- ctx.Statements.Add (
- new CodeVariableDeclarationStatement (
- (ctx.GlobalCodeNamespace.Name + ".BinContainer"),
- binContainerVar,
- attachExp
- )
- );
- } else {
- ctx.Statements.Add (attachExp);
- }
-
- base.GenerateBuildCode (ctx, var);
-
- // Register the UIManager, if the Bin has one
-
- if (binContainerVar != null && UIManagerName != null) {
- ctx.Statements.Add (
- new CodeMethodInvokeExpression (
- new CodeVariableReferenceExpression (binContainerVar),
- "SetUiManager",
- new CodeVariableReferenceExpression (UIManagerName)
- )
- );
- }
-
- } else
- base.GenerateBuildCode (ctx, var);
- }
-
- void GenerateHelperClass (GeneratorContext ctx)
- {
- CodeTypeDeclaration type = new CodeTypeDeclaration ("BinContainer");
- type.Attributes = MemberAttributes.Private;
- type.TypeAttributes = TypeAttributes.NestedAssembly;
- ctx.GlobalCodeNamespace.Types.Add (type);
-
- CodeMemberField field = new CodeMemberField ("Gtk.Widget", "child");
- field.Attributes = MemberAttributes.Private;
- type.Members.Add (field);
-
- field = new CodeMemberField ("Gtk.UIManager", "uimanager");
- field.Attributes = MemberAttributes.Private;
- type.Members.Add (field);
-
- CodeExpression child = new CodeFieldReferenceExpression (
- new CodeThisReferenceExpression (),
- "child"
- );
-
- CodeExpression uimanager = new CodeFieldReferenceExpression (
- new CodeThisReferenceExpression (),
- "uimanager"
- );
-
- // Attach method
-
- CodeMemberMethod met = new CodeMemberMethod ();
- type.Members.Add (met);
- met.Name = "Attach";
- met.Attributes = MemberAttributes.Public | MemberAttributes.Static;
- met.ReturnType = new CodeTypeReference ("BinContainer");
- met.Parameters.Add (new CodeParameterDeclarationExpression ("Gtk.Bin", "bin"));
-
- CodeVariableDeclarationStatement bcDec = new CodeVariableDeclarationStatement ("BinContainer", "bc");
- bcDec.InitExpression = new CodeObjectCreateExpression ("BinContainer");
- met.Statements.Add (bcDec);
- CodeVariableReferenceExpression bc = new CodeVariableReferenceExpression ("bc");
- CodeArgumentReferenceExpression bin = new CodeArgumentReferenceExpression ("bin");
-
- met.Statements.Add (
- new CodeAttachEventStatement (
- bin,
- "SizeRequested",
- new CodeDelegateCreateExpression (
- new CodeTypeReference ("Gtk.SizeRequestedHandler"), bc, "OnSizeRequested"
- )
- )
- );
-
- met.Statements.Add (
- new CodeAttachEventStatement (
- bin,
- "SizeAllocated",
- new CodeDelegateCreateExpression (
- new CodeTypeReference ("Gtk.SizeAllocatedHandler"), bc, "OnSizeAllocated"
- )
- )
- );
-
- met.Statements.Add (
- new CodeAttachEventStatement (
- bin,
- "Added",
- new CodeDelegateCreateExpression (
- new CodeTypeReference ("Gtk.AddedHandler"), bc, "OnAdded"
- )
- )
- );
- met.Statements.Add (new CodeMethodReturnStatement (bc));
-
- // OnSizeRequested override
-
- met = new CodeMemberMethod ();
- type.Members.Add (met);
- met.Name = "OnSizeRequested";
- met.ReturnType = new CodeTypeReference (typeof(void));
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object), "sender"));
- met.Parameters.Add (new CodeParameterDeclarationExpression ("Gtk.SizeRequestedArgs", "args"));
-
- CodeConditionStatement cond = new CodeConditionStatement ();
- cond.Condition = new CodeBinaryOperatorExpression (
- child,
- CodeBinaryOperatorType.IdentityInequality,
- new CodePrimitiveExpression (null)
- );
- cond.TrueStatements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- new CodeArgumentReferenceExpression ("args"),
- "Requisition"
- ),
- new CodeMethodInvokeExpression (
- child,
- "SizeRequest"
- )
- )
- );
- met.Statements.Add (cond);
-
- // OnSizeAllocated method
-
- met = new CodeMemberMethod ();
- type.Members.Add (met);
- met.Name = "OnSizeAllocated";
- met.ReturnType = new CodeTypeReference (typeof(void));
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object), "sender"));
- met.Parameters.Add (new CodeParameterDeclarationExpression ("Gtk.SizeAllocatedArgs", "args"));
-
- cond = new CodeConditionStatement ();
- cond.Condition = new CodeBinaryOperatorExpression (
- child,
- CodeBinaryOperatorType.IdentityInequality,
- new CodePrimitiveExpression (null)
- );
- cond.TrueStatements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- child,
- "Allocation"
- ),
- new CodePropertyReferenceExpression (
- new CodeArgumentReferenceExpression ("args"),
- "Allocation"
- )
- )
- );
- met.Statements.Add (cond);
-
- // OnAdded method
-
- met = new CodeMemberMethod ();
- type.Members.Add (met);
- met.Name = "OnAdded";
- met.ReturnType = new CodeTypeReference (typeof(void));
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object), "sender"));
- met.Parameters.Add (new CodeParameterDeclarationExpression ("Gtk.AddedArgs", "args"));
-
- met.Statements.Add (
- new CodeAssignStatement (
- child,
- new CodePropertyReferenceExpression (
- new CodeArgumentReferenceExpression ("args"),
- "Widget"
- )
- )
- );
-
- // SetUiManager method
-
- met = new CodeMemberMethod ();
- type.Members.Add (met);
- met.Name = "SetUiManager";
- met.Attributes = MemberAttributes.Public | MemberAttributes.Final;
- met.ReturnType = new CodeTypeReference (typeof(void));
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(Gtk.UIManager), "uim"));
-
- met.Statements.Add (
- new CodeAssignStatement (
- uimanager,
- new CodeArgumentReferenceExpression ("uim")
- )
- );
- met.Statements.Add (
- new CodeAttachEventStatement (
- child,
- "Realized",
- new CodeDelegateCreateExpression (
- new CodeTypeReference ("System.EventHandler"), new CodeThisReferenceExpression(), "OnRealized"
- )
- )
- );
-
- // OnRealized method
-
- met = new CodeMemberMethod ();
- type.Members.Add (met);
- met.Name = "OnRealized";
- met.ReturnType = new CodeTypeReference (typeof(void));
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object), "sender"));
- met.Parameters.Add (new CodeParameterDeclarationExpression ("System.EventArgs", "args"));
-
- cond = new CodeConditionStatement ();
- cond.Condition = new CodeBinaryOperatorExpression (
- uimanager,
- CodeBinaryOperatorType.IdentityInequality,
- new CodePrimitiveExpression (null)
- );
-
- cond.TrueStatements.Add (
- new CodeVariableDeclarationStatement (
- typeof(Gtk.Widget),
- "w"
- )
- );
-
- CodeExpression wexp = new CodeVariableReferenceExpression ("w");
-
- cond.TrueStatements.Add (
- new CodeAssignStatement (
- wexp,
- new CodePropertyReferenceExpression (
- child,
- "Toplevel"
- )
- )
- );
-
- CodeConditionStatement cond2 = new CodeConditionStatement ();
- cond2.Condition = new CodeBinaryOperatorExpression (
- new CodeBinaryOperatorExpression (
- wexp,
- CodeBinaryOperatorType.IdentityInequality,
- new CodePrimitiveExpression (null)
- ),
- CodeBinaryOperatorType.BooleanAnd,
- new CodeMethodInvokeExpression (
- new CodeTypeOfExpression ("Gtk.Window"),
- "IsInstanceOfType",
- wexp
- )
- );
-
- cond2.TrueStatements.Add (
- new CodeMethodInvokeExpression (
- new CodeCastExpression ("Gtk.Window", wexp),
- "AddAccelGroup",
- new CodePropertyReferenceExpression (
- uimanager,
- "AccelGroup"
- )
- )
- );
- cond2.TrueStatements.Add (
- new CodeAssignStatement (
- uimanager,
- new CodePrimitiveExpression (null)
- )
- );
- cond.TrueStatements.Add (cond2);
-
- met.Statements.Add (cond);
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- CustomWidget custom = obj as CustomWidget;
- if (custom != null) {
- RootWrapperName = custom.Name;
- }
- //during Wrap RootWrapperName will be set in the children widgets
- base.Wrap (obj, initialized);
- }
- }
-
-/*
- This is a model of what GenerateHelperClass generates:
-
- class BinContainer
- {
- Gtk.Widget child;
- UIManager uimanager;
-
- public static BinContainer Attach (Gtk.Bin bin)
- {
- BinContainer bc = new BinContainer ();
- bin.SizeRequested += new Gtk.SizeRequestedHandler (bc.OnSizeRequested);
- bin.SizeAllocated += new Gtk.SizeAllocatedHandler (bc.OnSizeAllocated);
- bin.Added += new Gtk.AddedHandler (bc.OnAdded);
- return bin;
- }
-
- void OnSizeRequested (object s, Gtk.SizeRequestedArgs args)
- {
- if (child != null)
- args.Requisition = child.SizeRequest ();
- }
-
- void OnSizeAllocated (object s, Gtk.SizeAllocatedArgs args)
- {
- if (child != null)
- child.Allocation = args.Allocation;
- }
-
- void OnAdded (object s, Gtk.AddedArgs args)
- {
- child = args.Widget;
- }
-
- public void SetUiManager (UIManager manager)
- {
- uimanager = manager;
- child.Realized += new System.EventHandler (OnRealized);
- }
-
- void OnRealized ()
- {
- if (uimanager != null) {
- Gtk.Widget w = child.Toplevel;
- if (w != null && w is Gtk.Window) {
- ((Gtk.Window)w).AddAccelGroup (uimanager.AccelGroup);
- uimanager = null;
- }
- }
- }
- }
-*/
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Box.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Box.cs
deleted file mode 100644
index 8e57f4b80f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Box.cs
+++ /dev/null
@@ -1,276 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Stetic.Wrapper {
-
- public class Box : Container {
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized && AllowPlaceholders) {
- Placeholder ph = CreatePlaceholder ();
- box.PackStart (ph);
- NotifyChildAdded (ph);
- ph = CreatePlaceholder ();
- box.PackStart (ph);
- NotifyChildAdded (ph);
- box.Spacing = 6;
- }
- box.SizeAllocated += box_SizeAllocated;
- ContainerOrientation = obj is Gtk.HBox ? Gtk.Orientation.Horizontal : Gtk.Orientation.Vertical;
- DND.ClearFaults (this);
- }
-
- public override void Dispose ()
- {
- box.SizeAllocated -= box_SizeAllocated;
- base.Dispose ();
- }
-
- protected Gtk.Box box {
- get {
- return (Gtk.Box)Wrapped;
- }
- }
-
-/*
- FIXME: why was this needed?
- protected override bool AllowPlaceholders {
- get {
- return InternalChildProperty != null;
- }
- }
-*/
- // DoSync() does two things: first, it makes sure that all of the
- // PackStart widgets have Position numbers less than all of the
- // PackEnd widgets. Second, it creates faults anywhere two widgets
- // could be split apart. The fault IDs correspond to the Position
- // a widget would have to be assigned to end up in that slot
- // (negated for PackEnd slots).
- //
- // Position/PackType: 0S 1S 2S 4E 3E
- // +----------------------+
- // | AA BB CC DD EE |
- // +----------------------+
- // Fault Id: 0 1 2 3 -5 -4 -3
-
- protected override void DoSync ()
- {
- if (!box.IsRealized)
- return;
-
- DND.ClearFaults (this);
-
- Gtk.Widget[] children = box.Children;
- if (children.Length == 0)
- return;
-
- Gtk.Widget[] sorted = new Gtk.Widget[children.Length];
- int last_start = -1;
- bool hbox = ContainerOrientation == Gtk.Orientation.Horizontal;
-
- foreach (Gtk.Widget child in children) {
- Gtk.Box.BoxChild bc = box[child] as Gtk.Box.BoxChild;
- if (AutoSize[child]) {
- bool exp = hbox ? ChildHExpandable (child) : ChildVExpandable (child);
- if (bc.Expand != exp)
- bc.Expand = exp;
- if (bc.Fill != exp)
- bc.Fill = exp;
- }
-
- // Make sure all of the PackStart widgets are before
- // any PackEnd widgets in the list.
- if (bc.PackType == Gtk.PackType.Start) {
- if (bc.Position != ++last_start) {
- Array.Copy (sorted, last_start, sorted, last_start + 1, bc.Position - last_start);
- box.ReorderChild (child, last_start);
- }
- }
-
- if (!(child is Placeholder))
- sorted[bc.Position] = child;
- }
-
- // The orientation of the faults is the opposite of the
- // orientation of the box
- Gtk.Orientation orientation = hbox ? Gtk.Orientation.Vertical : Gtk.Orientation.Horizontal;
- Gtk.SideType before = hbox ? Gtk.SideType.Left : Gtk.SideType.Top;
- Gtk.SideType after = hbox ? Gtk.SideType.Right : Gtk.SideType.Bottom;
-
- if (!Unselectable) {
- // If there are no PackStart widgets, we need a fault at the leading
- // edge. Otherwise if there's a widget at the leading edge, we need a
- // fault before it.
- if (last_start == -1)
- DND.AddFault (this, 0, before, null);
- else if (sorted[0] != null)
- DND.AddFault (this, 0, before, sorted[0]);
-
- // Add a fault between each pair of (non-placeholder) start widgets
- for (int i = 1; i <= last_start; i++) {
- if (sorted[i - 1] != null && sorted[i] != null)
- DND.AddFault (this, i, orientation, sorted[i - 1], sorted[i]);
- }
-
- // If there's a non-placeholder at the end of the PackStart
- // range, add a fault after it
- if (last_start > -1 && sorted[last_start] != null)
- DND.AddFault (this, last_start + 1, after, sorted[last_start]);
-
- // Now the PackEnd widgets
- if (last_start == sorted.Length - 1)
- DND.AddFault (this, -(last_start + 1), after, null);
- else if (sorted[last_start + 1] != null)
- DND.AddFault (this, -(last_start + 1), after, sorted[last_start + 1]);
-
- for (int i = last_start + 2; i < sorted.Length; i++) {
- if (sorted[i - 1] != null && sorted[i] != null)
- DND.AddFault (this, -i, orientation, sorted[i - 1], sorted[i]);
- }
-
- if (sorted.Length > last_start + 1 && sorted[sorted.Length - 1] != null)
- DND.AddFault (this, -sorted.Length, before, sorted[sorted.Length - 1]);
- }
- }
-
- internal void InsertBefore (Gtk.Widget context)
- {
- int position;
- Gtk.PackType type;
-
- if (context == box) {
- position = 0;
- type = Gtk.PackType.Start;
- } else {
- Gtk.Box.BoxChild bc = (Gtk.Box.BoxChild)ContextChildProps (context);
- position = bc.Position;
- type = bc.PackType;
- }
-
- Placeholder ph = CreatePlaceholder ();
- if (type == Gtk.PackType.Start) {
- box.PackStart (ph);
- box.ReorderChild (ph, position);
- } else {
- box.PackEnd (ph);
- box.ReorderChild (ph, position + 1);
- }
- NotifyChildAdded (ph);
- }
-
- internal void InsertAfter (Gtk.Widget context)
- {
- int position;
- Gtk.PackType type;
-
- if (context == box) {
- position = 0;
- type = Gtk.PackType.End;
- } else {
- Gtk.Box.BoxChild bc = (Gtk.Box.BoxChild)ContextChildProps (context);
- position = bc.Position;
- type = bc.PackType;
- }
-
- Placeholder ph = CreatePlaceholder ();
- if (type == Gtk.PackType.Start) {
- box.PackStart (ph);
- box.ReorderChild (ph, position + 1);
- } else {
- box.PackEnd (ph);
- box.ReorderChild (ph, position);
- }
- NotifyChildAdded (ph);
- }
-
- protected override void ChildContentsChanged (Container child) {
- Gtk.Widget widget = child.Wrapped;
-
- if (widget != null && AutoSize[widget]) {
- Gtk.Box.BoxChild bc = box[widget] as Gtk.Box.BoxChild;
- bool newExp = (ContainerOrientation == Gtk.Orientation.Horizontal) ? ChildHExpandable (widget) : ChildVExpandable (widget);
- if (newExp != bc.Expand)
- bc.Expand = newExp;
- if (newExp != bc.Fill)
- bc.Fill = newExp;
- }
- base.ChildContentsChanged (child);
- }
-
- protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- base.ReplaceChild (oldChild, newChild);
-
- Container container = Stetic.Wrapper.Container.Lookup (newChild);
- if (container != null)
- ChildContentsChanged (container);
- }
-
- void box_SizeAllocated (object obj, Gtk.SizeAllocatedArgs args)
- {
- Sync ();
- }
-
- public override IEnumerable GladeChildren {
- get {
- // Return childs using the position order.
- // This is needed to make sure children are
- // added in the right order to the box while loading
- // or building the box.
- object[] obs = new object [box.Children.Length];
- foreach (Gtk.Widget child in box.Children) {
- Gtk.Box.BoxChild bc = (Gtk.Box.BoxChild) box [child];
- obs [bc.Position] = child;
- }
- return obs;
- }
- }
-
- public override void Drop (Gtk.Widget w, object faultId)
- {
- AutoSize[w] = true;
- int pos = (int)faultId;
-
- Freeze ();
- if (pos >= 0) {
- box.Add (w);
- box.ReorderChild (w, pos);
- } else {
- box.Add (w);
- box.ReorderChild (w, -pos);
- }
- EmitContentsChanged ();
- Thaw ();
- }
-
- public class BoxChild : Container.ContainerChild {
-
- public bool BoxExpand {
- get { return ((Gtk.Box.BoxChild)Wrapped).Expand; }
- set {
- AutoSize = false;
- ((Gtk.Box.BoxChild)Wrapped).Expand = value;
- }
- }
-
- public bool BoxFill {
- get { return ((Gtk.Box.BoxChild)Wrapped).Fill; }
- set {
- AutoSize = false;
- ((Gtk.Box.BoxChild)Wrapped).Fill = value;
- }
- }
-
- protected override void EmitNotify (string propertyName)
- {
- if (propertyName == "AutoSize") {
- base.EmitNotify ("Expand");
- base.EmitNotify ("Fill");
- }
- base.EmitNotify (propertyName);
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Button.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Button.cs
deleted file mode 100644
index fc78a59531..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Button.cs
+++ /dev/null
@@ -1,339 +0,0 @@
-using System;
-using System.CodeDom;
-using System.Collections;
-using System.Xml;
-
-namespace Stetic.Wrapper {
-
- public class Button : Container {
-
- ImageInfo imageInfo;
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
-
- if (!initialized)
- UseUnderline = true;
-
- if (button.UseStock) {
- type = ButtonType.StockItem;
- StockId = button.Label;
- } else if (!initialized) {
- type = ButtonType.TextOnly;
- Label = button.Name;
- } else if (button.Child is Gtk.Label) {
- type = ButtonType.TextOnly;
- label = button.Label;
- useUnderline = button.UseUnderline;
- } else {
- type = ButtonType.Custom;
- FixupGladeChildren ();
- }
- }
-
- public override void Read (ObjectReader reader, XmlElement elem)
- {
- base.Read (reader, elem);
- if (reader.Format == FileFormat.Glade)
- UseUnderline = true;
- }
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- ObjectWrapper ret = null;
- if (Type == ButtonType.Custom || reader.Format == FileFormat.Glade) {
- if (button.Child != null)
- button.Remove (button.Child);
- ret = base.ReadChild (reader, child_elem);
- FixupGladeChildren ();
- } else if (Type == ButtonType.TextAndIcon)
- ConstructContents ();
- return ret;
- }
-
- protected override XmlElement WriteChild (ObjectWriter writer, Widget wrapper)
- {
- if (writer.Format == FileFormat.Glade || Type == ButtonType.Custom)
- return base.WriteChild (writer, wrapper);
- else
- return null;
- }
-
- void FixupGladeChildren ()
- {
- Gtk.Alignment alignment = button.Child as Gtk.Alignment;
- if (alignment == null)
- return;
- Gtk.HBox box = alignment.Child as Gtk.HBox;
- if (box == null)
- return;
-
- Gtk.Widget[] children = box.Children;
- if (children == null || children.Length != 2)
- return;
-
- Gtk.Image image = children[0] as Gtk.Image;
- Gtk.Label label = children[1] as Gtk.Label;
- if (image == null || label == null)
- return;
- Stetic.Wrapper.Image iwrap = Stetic.ObjectWrapper.Lookup (image) as Stetic.Wrapper.Image;
- if (iwrap == null)
- return;
-
- this.label = label.LabelProp;
- button.UseUnderline = label.UseUnderline;
-
- imageInfo = iwrap.Pixbuf;
- Type = ButtonType.TextAndIcon;
- }
-
- protected override XmlElement WriteProperties (ObjectWriter writer)
- {
- XmlElement elem = base.WriteProperties (writer);
- if (Type == ButtonType.StockItem)
- GladeUtils.SetProperty (elem, "label", stockId);
- return elem;
- }
-
- public override IEnumerable RealChildren {
- get {
- if (type == ButtonType.Custom)
- return base.RealChildren;
- else
- return new Gtk.Widget[0];
- }
- }
-
- public override IEnumerable GladeChildren {
- get {
- if (type == ButtonType.StockItem || type == ButtonType.TextOnly)
- return new Gtk.Widget[0];
- else
- return base.GladeChildren;
- }
- }
-
- private Gtk.Button button {
- get {
- return (Gtk.Button)Wrapped;
- }
- }
-
- public enum ButtonType {
- StockItem,
- TextOnly,
- TextAndIcon,
- Custom
- };
-
- ButtonType type;
- public ButtonType Type {
- get {
- return type;
- }
- set {
- type = value;
- EmitNotify ("Type");
- switch (type) {
- case ButtonType.StockItem:
- button.UseStock = true;
- StockId = stockId;
- break;
- case ButtonType.TextOnly:
- labelWidget = null;
- button.UseStock = false;
- Label = label;
- UseUnderline = useUnderline;
- break;
- case ButtonType.TextAndIcon:
- button.UseStock = false;
- Label = label;
- UseUnderline = useUnderline;
- Icon = imageInfo;
- break;
- case ButtonType.Custom:
- button.UseStock = false;
- if (button.Child != null)
- ReplaceChild (button.Child, CreatePlaceholder (), true);
- break;
- }
- }
- }
-
- public ImageInfo Icon {
- get { return imageInfo; }
- set {
- imageInfo = value;
- if (!Loading) {
- ConstructContents ();
- EmitNotify ("Image");
- }
- }
- }
-
- Gtk.Label labelWidget;
-
- protected override void OnEndRead (FileFormat format)
- {
- base.OnEndRead (format);
- if (format == FileFormat.Native && Type == ButtonType.TextAndIcon) {
- Loading = true;
- ConstructContents ();
- Loading = false;
- }
- }
-
- void ConstructContents ()
- {
- if (button.Child != null)
- button.Remove (button.Child);
-
- if (useUnderline) {
- labelWidget = new Gtk.Label (label);
- labelWidget.MnemonicWidget = button;
- } else
- labelWidget = Gtk.Label.New (label);
-
- Gtk.Image imageWidget = (Gtk.Image)Registry.NewInstance ("Gtk.Image", proj);
- Image imageWrapper = (Image)Widget.Lookup (imageWidget);
- imageWrapper.Unselectable = true;
- if (type != ButtonType.StockItem) {
- imageWrapper.Pixbuf = imageInfo;
- }
-
- Gtk.HBox box = new Gtk.HBox (false, 2);
- box.PackStart (imageWidget, false, false, 0);
- box.PackEnd (labelWidget, false, false, 0);
-
- Gtk.Alignment alignment = new Gtk.Alignment (button.Xalign, button.Yalign, 0.0f, 0.0f);
- alignment.Add (box);
-
- ObjectWrapper buttonWrapper = ObjectWrapper.Lookup (this);
- Widget wrapper = (Widget)ObjectWrapper.Create (proj, labelWidget, buttonWrapper);
- wrapper.Unselectable = true;
- wrapper = (Widget)ObjectWrapper.Create (proj, box, buttonWrapper);
- wrapper.Unselectable = true;
- wrapper = (Widget)ObjectWrapper.Create (proj, alignment, buttonWrapper);
- wrapper.Unselectable = true;
-
- alignment.ShowAll ();
- button.Add (alignment);
- }
-
- string stockId = Gtk.Stock.Ok;
- public string StockId {
- get {
- return stockId;
- }
- set {
- if (responseId == ResponseIdForStockId (stockId))
- responseId = 0;
-
- if (value != null) {
- string sid = value;
- if (sid.StartsWith ("stock:"))
- sid = sid.Substring (6);
- button.Label = stockId = sid;
- button.UseStock = true;
- Gtk.StockItem item = Gtk.Stock.Lookup (sid);
- if (item.StockId == sid) {
- label = item.Label;
- useUnderline = true;
- }
- } else {
- stockId = value;
- }
-
- EmitNotify ("StockId");
-
- if (responseId == 0)
- ResponseId = ResponseIdForStockId (stockId);
- }
- }
-
- string label;
- public string Label {
- get {
- return label;
- }
- set {
- label = value;
- if (labelWidget != null)
- labelWidget.LabelProp = value;
- else
- button.Label = value;
- }
- }
-
- bool useUnderline;
- public bool UseUnderline {
- get {
- return useUnderline;
- }
- set {
- useUnderline = value;
- if (labelWidget != null)
- labelWidget.UseUnderline = value;
- else
- button.UseUnderline = value;
- }
- }
-
- public bool IsDialogButton {
- get {
- ButtonBox box = this.ParentWrapper as ButtonBox;
- return (box != null && box.InternalChildProperty != null && box.InternalChildProperty.Name == "ActionArea");
- }
- }
-
- int responseId;
- public int ResponseId {
- get {
- return responseId;
- }
- set {
- responseId = value;
- EmitNotify ("ResponseId");
- }
- }
-
- int ResponseIdForStockId (string stockId)
- {
- if (stockId == Gtk.Stock.Ok)
- return (int)Gtk.ResponseType.Ok;
- else if (stockId == Gtk.Stock.Cancel)
- return (int)Gtk.ResponseType.Cancel;
- else if (stockId == Gtk.Stock.Close)
- return (int)Gtk.ResponseType.Close;
- else if (stockId == Gtk.Stock.Yes)
- return (int)Gtk.ResponseType.Yes;
- else if (stockId == Gtk.Stock.No)
- return (int)Gtk.ResponseType.No;
- else if (stockId == Gtk.Stock.Apply)
- return (int)Gtk.ResponseType.Apply;
- else if (stockId == Gtk.Stock.Help)
- return (int)Gtk.ResponseType.Help;
- else
- return 0;
- }
-
- internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- base.GenerateBuildCode (ctx, var);
-
- if (Type != ButtonType.TextAndIcon) {
- CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression (var, "Label");
- PropertyDescriptor prop = (PropertyDescriptor) this.ClassDescriptor ["Label"];
- bool trans = Type != ButtonType.StockItem && prop.IsTranslated (Wrapped);
- CodeExpression val = ctx.GenerateValue (button.Label, typeof(string), trans);
- ctx.Statements.Add (new CodeAssignStatement (cprop, val));
- }
- }
-
- protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- if (prop.Name != "Label")
- base.GeneratePropertySet (ctx, var, prop);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ButtonBox.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ButtonBox.cs
deleted file mode 100644
index 37b8b60e7f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ButtonBox.cs
+++ /dev/null
@@ -1,161 +0,0 @@
-using System;
-using System.Xml;
-using System.Collections;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class ButtonBox : Box {
-
- Dialog actionDialog;
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- foreach (Gtk.Widget child in buttonbox.Children) {
- if (child is Placeholder)
- ReplaceChild (child, NewButton (), true);
- }
- }
-
- public void SetActionDialog (Dialog dialog)
- {
- actionDialog = dialog;
- }
-
- Gtk.Button NewButton ()
- {
- Gtk.Button button = (Gtk.Button)Registry.NewInstance ("Gtk.Button", proj);
- button.CanDefault = true;
- return button;
- }
-
- protected Gtk.ButtonBox buttonbox {
- get {
- return (Gtk.ButtonBox)Wrapped;
- }
- }
-
- protected override bool AllowPlaceholders {
- get {
- return false;
- }
- }
- internal new void InsertBefore (Gtk.Widget context)
- {
- int position;
- bool secondary;
-
- if (context == buttonbox) {
- position = 0;
- secondary = false;
- } else {
- Gtk.ButtonBox.ButtonBoxChild bbc = (Gtk.ButtonBox.ButtonBoxChild)ContextChildProps (context);
- position = bbc.Position;
- secondary = bbc.Secondary;
- }
-
- Gtk.Button button = NewButton ();
- buttonbox.PackStart (button, false, false, 0);
- buttonbox.ReorderChild (button, position);
- buttonbox.SetChildSecondary (button, secondary);
- EmitContentsChanged ();
- }
-
- internal new void InsertAfter (Gtk.Widget context)
- {
- int position;
- bool secondary;
-
- if (context == buttonbox) {
- position = buttonbox.Children.Length - 1;
- secondary = false;
- } else {
- Gtk.ButtonBox.ButtonBoxChild bbc = (Gtk.ButtonBox.ButtonBoxChild)ContextChildProps (context);
- position = bbc.Position;
- secondary = bbc.Secondary;
- }
-
- Gtk.Button button = NewButton ();
- buttonbox.PackStart (button, false, false, 0);
- buttonbox.ReorderChild (button, position + 1);
- buttonbox.SetChildSecondary (button, secondary);
- EmitContentsChanged ();
- }
-
- public int Size {
- get {
- return buttonbox.Children.Length;
- }
- set {
- Gtk.Widget[] children = buttonbox.Children;
- int cursize = children.Length;
-
- while (cursize > value) {
- Gtk.Widget w = children[--cursize];
- buttonbox.Remove (w);
- w.Destroy ();
- }
- while (cursize < value) {
- buttonbox.PackStart (NewButton (), false, false, 0);
- cursize++;
- }
- }
- }
-
- protected override void ReadChildren (ObjectReader reader, XmlElement elem)
- {
- // Reset the button count
- Size = 0;
- base.ReadChildren (reader, elem);
- }
-
- protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
- {
- if (actionDialog != null && wrapper is Button) {
-
- // If this is the action area of a dialog, buttons must be added using AddActionWidget,
- // so they are properly registered.
-
- ObjectWrapper childwrapper = ChildWrapper (wrapper);
- Button button = wrapper as Button;
-
- if (childwrapper != null) {
- CodeExpression dialogVar = ctx.WidgetMap.GetWidgetExp (actionDialog);
- ctx.Statements.Add (new CodeCommentStatement ("Container child " + Wrapped.Name + "." + childwrapper.Wrapped.GetType ()));
- CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
- if (button.ResponseId != (int) Gtk.ResponseType.None) {
- CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
- dialogVar,
- "AddActionWidget",
- var,
- new CodePrimitiveExpression (button.ResponseId)
- );
- ctx.Statements.Add (invoke);
- }
- else {
- CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
- parentVar,
- "Add",
- var
- );
- ctx.Statements.Add (invoke);
- }
- GenerateSetPacking (ctx, parentVar, var, childwrapper);
- }
- } else
- base.GenerateChildBuildCode (ctx, parentVar, wrapper);
- }
-
- public class ButtonBoxChild : Box.BoxChild {
-
- public bool InDialog {
- get {
- if (ParentWrapper == null)
- return false;
- return ParentWrapper.InternalChildProperty != null && ParentWrapper.InternalChildProperty.Name == "ActionArea";
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/CheckButton.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/CheckButton.cs
deleted file mode 100644
index cd2fd6e88b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/CheckButton.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-using System.Xml;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class CheckButton : Container {
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized)
- checkbutton.UseUnderline = true;
- }
-
- public override void Read (ObjectReader reader, XmlElement elem)
- {
- base.Read (reader, elem);
- if (reader.Format == FileFormat.Glade)
- checkbutton.UseUnderline = true;
- }
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- hasLabel = false;
- if (checkbutton.Child != null)
- checkbutton.Remove (checkbutton.Child);
- return base.ReadChild (reader, child_elem);
- }
-
- public Gtk.CheckButton checkbutton {
- get {
- return (Gtk.CheckButton)Wrapped;
- }
- }
-
- bool hasLabel = true;
- public bool HasLabel {
- get {
- return hasLabel;
- }
- set {
- hasLabel = value;
- EmitNotify ("HasLabel");
- }
- }
-
- internal void RemoveLabel ()
- {
- AddPlaceholder ();
- HasLabel = false;
- }
-
- public override Placeholder AddPlaceholder ()
- {
- if (checkbutton.Child != null)
- checkbutton.Remove (checkbutton.Child);
- return base.AddPlaceholder ();
- }
-
- internal void RestoreLabel ()
- {
- checkbutton.Label = checkbutton.Name;
- HasLabel = true;
- }
-
- protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- base.ReplaceChild (oldChild, newChild);
- EmitNotify ("HasContents");
- }
-
- protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
- {
- if (!HasLabel) {
- // CheckButton generates a label by default. Remove it if it is not required.
- ctx.Statements.Add (
- new CodeMethodInvokeExpression (
- parentVar,
- "Remove",
- new CodePropertyReferenceExpression (
- parentVar,
- "Child"
- )
- )
- );
- }
- base.GenerateChildBuildCode (ctx, parentVar, wrapper);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ColorButton.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ColorButton.cs
deleted file mode 100644
index 1cf71351aa..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ColorButton.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class ColorButton : Container {
-
- public int Alpha {
- get {
- Gtk.ColorButton cb = (Gtk.ColorButton)Wrapped;
-
- if (cb.UseAlpha)
- return cb.Alpha;
- else
- return -1;
- }
- set {
- Gtk.ColorButton cb = (Gtk.ColorButton)Wrapped;
-
- if (value == -1)
- cb.UseAlpha = false;
- else {
- cb.UseAlpha = true;
- cb.Alpha = (ushort)value;
- }
- }
- }
-
- protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- if (prop.Name == "Alpha" && Alpha == -1)
- return;
- else
- base.GeneratePropertySet (ctx, var, prop);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ComboBox.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ComboBox.cs
deleted file mode 100644
index 5d196c5bc4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ComboBox.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-using System;
-using System.Xml;
-using System.CodeDom;
-using System.Runtime.InteropServices;
-
-namespace Stetic.Wrapper {
-
- public class ComboBox : Container {
-
- public static Gtk.ComboBox CreateInstance ()
- {
- Gtk.ComboBox c = Gtk.ComboBox.NewText ();
- // Make sure all children are created, so the mouse events can be
- // bound and the widget can be selected.
- c.EnsureStyle ();
- try {
- FixSensitivity (c);
- } catch {
- }
- return c;
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized)
- textCombo = true;
- }
-
-
- string[] items = new string[0];
- bool textCombo;
-
- public string[] Items {
- get { return items; }
- set {
- Gtk.ComboBox combobox = (Gtk.ComboBox)Wrapped;
- int active = combobox.Active;
-
- int row = 0, oi = 0, ni = 0;
- while (value != null && oi < items.Length && ni < value.Length) {
- if (items [oi] == value [ni]) {
- oi++;
- ni++;
- row++;
- } else if (ni < value.Length - 1 &&
- items [oi] == value [ni + 1]) {
- combobox.InsertText (row++, value [ni++]);
- if (active > row)
- active++;
- } else {
- combobox.RemoveText (row);
- if (active > row)
- active--;
- oi++;
- }
- }
-
- while (oi < items.Length) {
- combobox.RemoveText (row);
- oi++;
- }
-
- while (value != null && ni < value.Length)
- combobox.InsertText (row++, value [ni++]);
-
- items = value == null ? new string [0] : value;
- combobox.Active = active;
-
- EmitNotify ("Items");
- }
- }
-
- public bool IsTextCombo {
- get { return textCombo; }
- set { textCombo = value; EmitNotify ("IsTextCombo"); }
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- if (textCombo) {
- return new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference ("Gtk.ComboBox", CodeTypeReferenceOptions.GlobalReference)),
- "NewText"
- );
- } else
- return base.GenerateObjectCreation (ctx);
- }
-
- internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- if (textCombo && Items != null && Items.Length > 0) {
- foreach (string str in Items) {
- ctx.Statements.Add (new CodeMethodInvokeExpression (
- var,
- "AppendText",
- ctx.GenerateValue (str, typeof(string), true)
- ));
- }
- }
-
- base.GenerateBuildCode (ctx, var);
- }
-
- public override void Read (ObjectReader reader, XmlElement element)
- {
- base.Read (reader, element);
- if (reader.Format == FileFormat.Glade && items.Length > 0)
- IsTextCombo = true;
- }
-
- internal static void FixSensitivity (Gtk.ComboBox c)
- {
- // Since gtk+ 2.14, empty combos are disabled by default
- // This method disables this behavior
- gtk_combo_box_set_button_sensitivity (c.Handle, 1);
- }
-
- [DllImport("libgtk-win32-2.0-0.dll")]
- extern static void gtk_combo_box_set_button_sensitivity (IntPtr combo, int mode);
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ComboBoxEntry.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ComboBoxEntry.cs
deleted file mode 100644
index 9461b7422f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ComboBoxEntry.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class ComboBoxEntry : ComboBox {
-
- public static new Gtk.ComboBoxEntry CreateInstance ()
- {
- Gtk.ComboBoxEntry c = Gtk.ComboBoxEntry.NewText ();
- // Make sure all children are created, so the mouse events can be
- // bound and the widget can be selected.
- c.EnsureStyle ();
- try {
- FixSensitivity (c);
- } catch {
- }
- return c;
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- if (IsTextCombo) {
- return new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference ("Gtk.ComboBoxEntry", CodeTypeReferenceOptions.GlobalReference)),
- "NewText"
- );
- } else
- return base.GenerateObjectCreation (ctx);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Container.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Container.cs
deleted file mode 100644
index 8fd16191ef..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Container.cs
+++ /dev/null
@@ -1,1456 +0,0 @@
-using System;
-using System.CodeDom;
-using System.Collections;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Xml;
-using Stetic.Undo;
-using Stetic.Editor;
-
-namespace Stetic.Wrapper
-{
- public class Container : Widget
- {
- int designWidth;
- int designHeight;
- IDesignArea designer;
- CodeExpression generatedTooltips;
- bool internalAdd;
-
- static DiffGenerator containerDiffGenerator;
- static bool showNonContainerWarning = true;
-
- static Container ()
- {
- XmlDiffAdaptor adaptor = new XmlDiffAdaptor ();
- adaptor.ChildElementName = "child";
- adaptor.ChildAdaptor = new XmlDiffAdaptor ();
- adaptor.ChildAdaptor.PropsElementName = "packing";
-
- containerDiffGenerator = new DiffGenerator ();
- containerDiffGenerator.CurrentStatusAdaptor = adaptor;
- containerDiffGenerator.NewStatusAdaptor = adaptor;
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
-
- ClassDescriptor klass = this.ClassDescriptor;
- foreach (PropertyDescriptor prop in klass.InternalChildren) {
- Gtk.Widget child = prop.GetValue (container) as Gtk.Widget;
- if (child == null)
- continue;
- Widget wrapper = ObjectWrapper.Create (proj, child, this) as Stetic.Wrapper.Widget;
- wrapper.InternalChildProperty = prop;
- if (child.Name == ((GLib.GType)child.GetType ()).ToString ())
- child.Name = container.Name + "_" + prop.Name;
- }
-
- container.Removed += ChildRemoved;
- container.Added += OnChildAdded;
-
- if (!initialized && container.Children.Length == 0 && AllowPlaceholders)
- AddPlaceholder ();
-
- if (Wrapped.GetType ().ToString ()[0] == 'H')
- ContainerOrientation = Gtk.Orientation.Horizontal;
- else
- ContainerOrientation = Gtk.Orientation.Vertical;
-
- if (!Loading)
- ValidateChildNames (Wrapped);
- }
-
- public override void Dispose ()
- {
- container.Removed -= ChildRemoved;
- container.Added -= OnChildAdded;
- AutoSize.Clear ();
- base.Dispose ();
- }
-
- void OnChildAdded (object o, Gtk.AddedArgs args)
- {
- if (!internalAdd)
- HandleNewChild (args.Widget);
- }
-
- protected void NotifyChildAdded (Gtk.Widget child)
- {
- HandleNewChild (child);
- EmitContentsChanged ();
- }
-
- void HandleNewChild (Gtk.Widget child)
- {
- // Make sure children's IDs don't conflict with other widgets
- // in the parent container.
- if (!Loading)
- ValidateChildNames (child);
-
- Widget w = Widget.Lookup (child);
- if (w != null) {
- w.RequiresUndoStatusUpdate = true;
- if (designer != null)
- w.OnDesignerAttach (designer);
-
- // If the ShowScrollbars flag is set, make sure the scrolled window is created.
- if (w.ShowScrollbars)
- w.UpdateScrolledWindow ();
- }
-
- Placeholder ph = child as Placeholder;
- if (ph != null) {
- ph.DragDrop += PlaceholderDragDrop;
- ph.DragDataReceived += PlaceholderDragDataReceived;
- ph.ButtonPressEvent += PlaceholderButtonPress;
- AutoSize[ph] = true;
- }
- }
-
- Gtk.Container container {
- get {
- return (Gtk.Container)Wrapped;
- }
- }
-
- protected virtual bool AllowPlaceholders {
- get {
- return true && this.ClassDescriptor.AllowChildren;
- }
- }
-
- public int DesignWidth {
- get { return designWidth; }
- set { designWidth = value; NotifyChanged (); }
- }
-
- public int DesignHeight {
- get { return designHeight; }
- set { designHeight = value; NotifyChanged (); }
- }
-
- public void IncreaseBorderWidth ()
- {
- container.BorderWidth += 3;
- }
-
- public void DecreaseBorderWidth ()
- {
- if (container.BorderWidth >= 3)
- container.BorderWidth -= 3;
- else
- container.BorderWidth = 0;
- }
-
- internal bool ChildrenAllowed ()
- {
- return this.ClassDescriptor.AllowChildren;
- }
-
- int freeze;
- protected void Freeze ()
- {
- freeze++;
- }
-
- protected void Thaw ()
- {
- if (--freeze == 0)
- Sync ();
- }
-
- protected virtual void DoSync ()
- {
- ;
- }
-
- protected void Sync ()
- {
- if (freeze > 0 || Loading)
- return;
- freeze = 1;
- DoSync ();
- freeze = 0;
- }
-
- public override object GetUndoDiff ()
- {
- XmlElement oldElem = UndoManager.GetObjectStatus (this);
-
-// Console.WriteLine ("UNDO status: ");
-// Console.WriteLine (oldElem.OuterXml);
-
- // Write the new status of the object. This is going to replace the old status in undoManager.
- // In the process, register new objects found.
-
- UndoWriter writer = new UndoWriter (oldElem.OwnerDocument, UndoManager);
- XmlElement newElem = Write (writer);
-
-// Console.WriteLine ("CURRENT status: ");
-// Console.WriteLine (newElem.OuterXml);
-
- // Get the changes since the last undo checkpoint
-
- ObjectDiff actionsDiff = null;
- ObjectDiff objectDiff = containerDiffGenerator.GetDiff (newElem, oldElem);
-
- // If there are child changes there is no need to look for changes in the
- // actions, since the whole widget will be read again
-
- if (IsTopLevel && (objectDiff == null || objectDiff.ChildChanges == null))
- actionsDiff = LocalActionGroups.GetDiff (Project, oldElem);
-
- // The undo writer skips children which are already registered in the undo manager
- // to avoid writing information we already have. Now it's the moment to fill the gaps
-
- foreach (XmlElement newChild in newElem.SelectNodes ("child[widget/@unchanged_marker='yes']")) {
- string cid = newChild.GetAttribute ("undoId");
- XmlElement oldChild = (XmlElement) oldElem.SelectSingleNode ("child[@undoId='" + cid + "']");
- if (oldChild == null)
- throw new InvalidOperationException ("Child not found when filling widget info gaps.");
-
- XmlElement oldWidgetChild = oldChild ["widget"];
- XmlElement newWidgetChild = newChild ["widget"];
-
- oldChild.RemoveChild (oldWidgetChild);
- if (newWidgetChild != null)
- newChild.ReplaceChild (oldWidgetChild, newWidgetChild);
- }
-
- // Update the status tree
-
- UndoManager.UpdateObjectStatus (this, newElem);
-
-// UndoManager.Dump ();
-
- if (objectDiff != null || actionsDiff != null)
- return new ObjectDiff[] { objectDiff, actionsDiff };
- else
- return null;
- }
-
- public override object ApplyUndoRedoDiff (object data)
- {
- ObjectDiff diff = ((ObjectDiff[]) data)[0];
- ObjectDiff actionsDiff = ((ObjectDiff[]) data)[1];
-
- ObjectDiff reverseDiff = null;
- ObjectDiff reverseActionsDiff = null;
-
- XmlElement status = UndoManager.GetObjectStatus (this);
- XmlElement oldStatus = (XmlElement) status.CloneNode (true);
- UndoReader reader = new UndoReader (Project, FileFormat.Native, UndoManager);
-
- // Only apply the actions diff if the widget has not been completely reloaded
- if (actionsDiff != null && !(diff != null && diff.ChildChanges != null)) {
- // Apply the patch
- LocalActionGroups.ApplyDiff (Project, actionsDiff);
-
- // Get the redo patch
- reverseActionsDiff = LocalActionGroups.GetDiff (Project, oldStatus);
-
- // Update the status of the action group list in the undo status tree.
- // It has to remove all action groups and then write them again
- foreach (XmlElement group in status.SelectNodes ("action-group"))
- status.RemoveChild (group);
-
- UndoWriter writer = new UndoWriter (status.OwnerDocument, UndoManager);
- foreach (ActionGroup actionGroup in LocalActionGroups)
- status.InsertBefore (actionGroup.Write (writer), status.FirstChild);
- }
-
- if (diff != null) {
- containerDiffGenerator.ApplyDiff (status, diff);
- reverseDiff = containerDiffGenerator.GetDiff (status, oldStatus);
-
- // Avoid reading the whole widget tree if only the properties have changed.
- if (diff.ChildChanges == null) {
- ReadProperties (reader, status);
- } else {
-// Console.WriteLine ("BEFORE PATCH: " + status.OuterXml);
- Read (reader, status);
-// Console.WriteLine ("\nAFTER PATCH:");
-// UndoManager.Dump ();
- EmitContentsChanged ();
- }
- }
-
- if (reverseDiff != null || reverseActionsDiff != null)
- return new ObjectDiff[] { reverseDiff, reverseActionsDiff };
- else
- return null;
- }
-
- public override void Read (ObjectReader reader, XmlElement elem)
- {
- // Remove all existing children
- if (ClassDescriptor.AllowChildren && Wrapped != null) {
- foreach (Gtk.Widget child in GladeChildren) {
- Widget wrapper = Widget.Lookup (child);
-
- if (wrapper != null) {
- if (wrapper.InternalChildProperty != null)
- continue;
- container.Remove (child);
- child.Destroy ();
- } else if (child is Stetic.Placeholder) {
- container.Remove (child);
- child.Destroy ();
- }
- }
- }
-
- try {
- Loading = true;
- ReadActionGroups (reader, elem);
- ReadProperties (reader, elem);
- ReadChildren (reader, elem);
- DoSync ();
- } finally {
- Loading = false;
- }
- }
-
- protected virtual void ReadChildren (ObjectReader reader, XmlElement elem)
- {
- int gladeChildStackPos = reader.GladeChildStack.Count;
-
- foreach (XmlElement child_elem in elem.SelectNodes ("./child")) {
- try {
- if (child_elem.HasAttribute ("internal-child"))
- ReadInternalChild (reader, child_elem);
- else if (child_elem["widget"] == null)
- ReadPlaceholder (reader, child_elem);
- else {
- ObjectWrapper cw = ReadChild (reader, child_elem);
-
- // Set a temporary id used for the undo/redo operations
- ObjectWrapper ccw = ChildWrapper ((Widget)cw);
- if (ccw != null) {
- string cid = child_elem.GetAttribute ("undoId");
- if (cid.Length > 0)
- ChildWrapper ((Widget)cw).UndoId = cid;
- else
- child_elem.SetAttribute ("undoId", ChildWrapper ((Widget)cw).UndoId);
- }
- }
- } catch (GladeException ge) {
- Console.Error.WriteLine (ge.Message);
- }
- }
-
- if (reader.Format == FileFormat.Glade) {
- for (int n = reader.GladeChildStack.Count - 1; n >= gladeChildStackPos; n--) {
- ObjectWrapper ob = ReadInternalChild (reader, (XmlElement) reader.GladeChildStack [n]);
- if (ob != null)
- reader.GladeChildStack.RemoveAt (n);
- }
- }
-
- string ds = elem.GetAttribute ("design-size");
- if (ds.Length > 0) {
- int i = ds.IndexOf (' ');
- DesignWidth = int.Parse (ds.Substring (0, i));
- DesignHeight = int.Parse (ds.Substring (i+1));
- }
-
- Sync ();
- }
-
- protected virtual ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- Container.ContainerChild childwrapper = null;
-
- try {
- wrapper.Loading = true;
-
- Gtk.Widget child = (Gtk.Widget)wrapper.Wrapped;
-
- AutoSize[child] = false;
- container.Add (child);
-
- childwrapper = ChildWrapper ((Widget)wrapper);
- if (childwrapper != null)
- childwrapper.Loading = true;
-
- if (reader.Format == FileFormat.Glade)
- GladeUtils.SetPacking (childwrapper, child_elem);
- else
- WidgetUtils.SetPacking (childwrapper, child_elem);
- return wrapper;
- } finally {
- wrapper.Loading = false;
- if (childwrapper != null)
- childwrapper.Loading = false;
- }
- }
-
- void ReadPlaceholder (ObjectReader reader, XmlElement child_elem)
- {
- Placeholder ph = AddPlaceholder ();
- if (ph != null) {
- string cid = child_elem.GetAttribute ("undoId");
- if (cid.Length > 0)
- ph.UndoId = cid;
- else
- child_elem.SetAttribute ("undoId", ph.UndoId);
- }
- }
-
- protected virtual ObjectWrapper ReadInternalChild (ObjectReader reader, XmlElement child_elem)
- {
- ClassDescriptor klass = base.ClassDescriptor;
- string childId = child_elem.GetAttribute ("internal-child");
-
- foreach (PropertyDescriptor prop in klass.InternalChildren) {
- if (reader.Format == FileFormat.Glade && ((TypedPropertyDescriptor)prop).GladeName != childId)
- continue;
- else if (reader.Format == FileFormat.Native && prop.Name != childId)
- continue;
-
- Gtk.Widget child = prop.GetValue (container) as Gtk.Widget;
- Widget wrapper = Widget.Lookup (child);
- if (wrapper != null) {
- reader.ReadExistingObject (wrapper, child_elem["widget"]);
- if (reader.Format == FileFormat.Glade)
- GladeUtils.SetPacking (ChildWrapper (wrapper), child_elem);
- else
- WidgetUtils.SetPacking (ChildWrapper (wrapper), child_elem);
- return wrapper;
- }
- }
-
- // In Glade, internal children may not be direct children of the root container. This is handled in a special way.
- if (reader.Format == FileFormat.Glade) {
- if (!reader.GladeChildStack.Contains (child_elem))
- reader.GladeChildStack.Add (child_elem);
- return null;
- }
- else
- throw new GladeException ("Unrecognized internal child name", Wrapped.GetType ().FullName, false, "internal-child", childId);
- }
-
- public override XmlElement Write (ObjectWriter writer)
- {
- XmlElement elem = WriteProperties (writer);
- WriteActionGroups (writer, elem);
- XmlElement child_elem;
-
- if (ClassDescriptor.AllowChildren) {
- foreach (Gtk.Widget child in GladeChildren) {
- Widget wrapper = Widget.Lookup (child);
-
- if (wrapper != null) {
- // Iternal children are written later
- if (wrapper.InternalChildProperty != null)
- continue;
- child_elem = WriteChild (writer, wrapper);
- if (child_elem != null)
- elem.AppendChild (child_elem);
- } else if (child is Stetic.Placeholder) {
- child_elem = writer.XmlDocument.CreateElement ("child");
- if (writer.CreateUndoInfo)
- child_elem.SetAttribute ("undoId", ((Stetic.Placeholder)child).UndoId);
- child_elem.AppendChild (writer.XmlDocument.CreateElement ("placeholder"));
- elem.AppendChild (child_elem);
- }
- }
- }
-
- foreach (PropertyDescriptor prop in this.ClassDescriptor.InternalChildren) {
- Gtk.Widget child = prop.GetValue (Wrapped) as Gtk.Widget;
- if (child == null)
- continue;
-
- child_elem = writer.XmlDocument.CreateElement ("child");
- Widget wrapper = Widget.Lookup (child);
- if (wrapper == null) {
- child_elem.AppendChild (writer.XmlDocument.CreateElement ("placeholder"));
- elem.AppendChild (child_elem);
- continue;
- }
-
- string cid = writer.Format == FileFormat.Glade ? prop.InternalChildId : prop.Name;
-
- XmlElement widget_elem = writer.WriteObject (wrapper);
- child_elem.SetAttribute ("internal-child", cid);
- // Sets the child Id to be used in undo/redo operations
- if (writer.CreateUndoInfo)
- child_elem.SetAttribute ("undoId", cid);
-
- child_elem.AppendChild (widget_elem);
- elem.AppendChild (child_elem);
- }
-
- if (DesignWidth != 0 || DesignHeight != 0)
- elem.SetAttribute ("design-size", DesignWidth + " " + DesignHeight);
-
- return elem;
- }
-
- protected virtual XmlElement WriteChild (ObjectWriter writer, Widget wrapper)
- {
- XmlElement child_elem = writer.XmlDocument.CreateElement ("child");
- XmlElement widget_elem = writer.WriteObject (wrapper);
- child_elem.AppendChild (widget_elem);
-
- Container.ContainerChild childwrapper = ChildWrapper (wrapper);
- if (childwrapper != null) {
- XmlElement packing_elem;
-
- if (writer.Format == FileFormat.Glade)
- packing_elem = GladeUtils.CreatePacking (writer.XmlDocument, childwrapper);
- else
- packing_elem = WidgetUtils.CreatePacking (writer.XmlDocument, childwrapper);
-
- // Sets the child Id to be used in undo/redo operations
- if (writer.CreateUndoInfo)
- child_elem.SetAttribute ("undoId", childwrapper.UndoId);
-
- if (packing_elem.HasChildNodes)
- child_elem.AppendChild (packing_elem);
- } else {
- // There is no container child, so make up an id.
- if (writer.CreateUndoInfo)
- child_elem.SetAttribute ("undoId", "0");
- }
-
- return child_elem;
- }
-
- public XmlElement WriteContainerChild (ObjectWriter writer, Widget wrapper)
- {
- return WriteChild (writer, wrapper);
- }
-
- internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- generatedTooltips = null;
-
- base.GenerateBuildCode (ctx, var);
-
- if (ClassDescriptor.AllowChildren) {
- foreach (Gtk.Widget child in GladeChildren) {
- Widget wrapper = Widget.Lookup (child);
-
- if (wrapper != null && wrapper.InternalChildProperty == null)
- // Iternal children are written later
- GenerateChildBuildCode (ctx, var, wrapper);
- }
- }
-
- foreach (TypedPropertyDescriptor prop in this.ClassDescriptor.InternalChildren) {
- GenerateSetInternalChild (ctx, var, prop);
- }
-
-
- if (IsTopLevel && Wrapped is Gtk.Bin) {
- CodeExpression childExp = new CodePropertyReferenceExpression (var, "Child");
- CodeConditionStatement cond = new CodeConditionStatement ();
- cond.Condition =
- new CodeBinaryOperatorExpression (
- childExp,
- CodeBinaryOperatorType.IdentityInequality,
- new CodePrimitiveExpression (null)
- );
- cond.TrueStatements.Add (
- new CodeMethodInvokeExpression (
- childExp,
- "ShowAll"
- )
- );
- ctx.Statements.Add (cond);
- }
- }
-
- protected virtual void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
- {
- ObjectWrapper childwrapper = ChildWrapper (wrapper);
- if (childwrapper != null) {
- ctx.Statements.Add (new CodeCommentStatement ("Container child " + Wrapped.Name + "." + childwrapper.Wrapped.GetType ()));
- CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
- CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
- parentVar,
- "Add",
- var
- );
- ctx.Statements.Add (invoke);
-
- GenerateSetPacking (ctx, parentVar, var, childwrapper);
- }
- }
-
- void GenerateSetInternalChild (GeneratorContext ctx, CodeExpression parentVar, TypedPropertyDescriptor prop)
- {
- Gtk.Widget child = prop.GetValue (container) as Gtk.Widget;
- Widget cwrapper = Widget.Lookup (child);
- if (cwrapper != null) {
- ctx.Statements.Add (new CodeCommentStatement ("Internal child " + Wrapped.Name + "." + prop.Name));
- string childVar = ctx.NewId ();
- CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement (child.GetType().ToGlobalTypeRef (), childVar);
- ctx.Statements.Add (varDec);
- varDec.InitExpression = new CodePropertyReferenceExpression (parentVar, prop.Name);
-
- ctx.GenerateBuildCode (cwrapper, new CodeVariableReferenceExpression (childVar));
- return;
- }
- }
-
- protected void GenerateSetPacking (GeneratorContext ctx, CodeExpression parentVar, CodeExpression childVar, ObjectWrapper containerChildWrapper)
- {
- Gtk.Container.ContainerChild cc = containerChildWrapper.Wrapped as Gtk.Container.ContainerChild;
- ClassDescriptor klass = containerChildWrapper.ClassDescriptor;
-
- // Generate a variable that holds the container child
-
- string contChildVar = ctx.NewId ();
- CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement (cc.GetType().ToGlobalTypeRef (), contChildVar);
- varDec.InitExpression = new CodeCastExpression (
- cc.GetType ().ToGlobalTypeRef (),
- new CodeIndexerExpression (parentVar, childVar)
- );
-
- CodeVariableReferenceExpression var = new CodeVariableReferenceExpression (contChildVar);
-
- // Set the container child properties
-
- ctx.Statements.Add (varDec);
- int count = ctx.Statements.Count;
-
- foreach (ItemGroup group in klass.ItemGroups) {
- foreach (ItemDescriptor item in group) {
- PropertyDescriptor prop = item as PropertyDescriptor;
- if (prop == null || !prop.IsRuntimeProperty)
- continue;
- GenerateChildPropertySet (ctx, var, klass, prop, cc);
- }
- }
-
- if (ctx.Statements.Count == count) {
- ctx.Statements.Remove (varDec);
- }
- }
-
- protected virtual void GenerateChildPropertySet (GeneratorContext ctx, CodeVariableReferenceExpression var, ClassDescriptor containerChildClass, PropertyDescriptor prop, object child)
- {
- if (containerChildClass.InitializationProperties != null && Array.IndexOf (containerChildClass.InitializationProperties, prop) != -1)
- return;
-
- // Design time
- if (prop.Name == "AutoSize")
- return;
-
- object oval = prop.GetValue (child);
- if (oval == null || (prop.HasDefault && prop.IsDefaultValue (oval)))
- return;
-
- CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression (var, prop.Name);
- CodeExpression val = ctx.GenerateValue (oval, prop.RuntimePropertyType, prop.Translatable);
- ctx.Statements.Add (new CodeAssignStatement (cprop, val));
- }
-
- internal protected override void GeneratePostBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- base.GeneratePostBuildCode (ctx, var);
-
- if (IsTopLevel && (Wrapped is Gtk.Bin) && Visible) {
- ctx.Statements.Add (
- new CodeMethodInvokeExpression (
- var,
- "Show"
- )
- );
- }
- }
-
- internal void GenerateTooltip (GeneratorContext ctx, Widget widget)
- {
- if (WidgetUtils.CompareVersions (Project.TargetGtkVersion, "2.12") <= 0) {
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (ctx.WidgetMap.GetWidgetExp (widget), "TooltipMarkup"),
- new CodePrimitiveExpression (widget.Tooltip)
- )
- );
- return;
- }
-
- if (generatedTooltips == null) {
- string tid = ctx.NewId ();
- Type t = typeof(Gtk.Widget).Assembly.GetType ("Gtk.Tooltips");
- CodeVariableDeclarationStatement vardec = new CodeVariableDeclarationStatement (
- t.ToGlobalTypeRef (), tid, new CodeObjectCreateExpression (t)
- );
- ctx.Statements.Add (vardec);
- generatedTooltips = new CodeVariableReferenceExpression (tid);
- }
- ctx.Statements.Add (
- new CodeMethodInvokeExpression (
- generatedTooltips,
- "SetTip",
- ctx.WidgetMap.GetWidgetExp (widget),
- new CodePrimitiveExpression (widget.Tooltip),
- new CodePrimitiveExpression (widget.Tooltip)
- )
- );
- }
-
- internal protected override void OnDesignerAttach (IDesignArea designer)
- {
- base.OnDesignerAttach (designer);
- this.designer = designer;
- foreach (Gtk.Widget w in RealChildren) {
- ObjectWrapper wr = ObjectWrapper.Lookup (w);
- if (wr != null)
- wr.OnDesignerAttach (designer);
- }
- }
-
- internal protected override void OnDesignerDetach (IDesignArea designer)
- {
- base.OnDesignerDetach (designer);
- foreach (Gtk.Widget w in RealChildren) {
- ObjectWrapper wr = ObjectWrapper.Lookup (w);
- if (wr != null)
- wr.OnDesignerDetach (designer);
- }
- this.designer = null;
- }
-
- public virtual Placeholder AddPlaceholder ()
- {
- Placeholder ph = CreatePlaceholder ();
- container.Add (ph);
- return ph;
- }
-
- public virtual void Add (Gtk.Widget child)
- {
- container.Add (child);
- }
-
- public static new Container Lookup (GLib.Object obj)
- {
- return Stetic.ObjectWrapper.Lookup (obj) as Stetic.Wrapper.Container;
- }
-
- public static Container LookupParent (Gtk.Widget widget)
- {
- if (widget == null)
- return null;
- Gtk.Widget parent = widget.Parent;
- Container wrapper = null;
- while ((wrapper == null || wrapper.Unselectable) && parent != null) {
- wrapper = Lookup (parent);
- parent = parent.Parent;
- }
- return wrapper;
- }
-
- public static Stetic.Wrapper.Container.ContainerChild ChildWrapper (Stetic.Wrapper.Widget wrapper) {
- Stetic.Wrapper.Container parentWrapper = wrapper.ParentWrapper;
- if (parentWrapper == null)
- return null;
-
- Gtk.Container parent = parentWrapper.Wrapped as Gtk.Container;
- if (parent == null)
- return null;
-
- Gtk.Widget child = (Gtk.Widget)wrapper.Wrapped;
- while (child != null && child.Parent != parent)
- child = child.Parent;
- if (child == null)
- return null;
-
- Gtk.Container.ContainerChild cc = parent[child];
- Container.ContainerChild cwrap = ObjectWrapper.Lookup (cc) as Container.ContainerChild;
- if (cwrap != null)
- return cwrap;
- else
- return Stetic.ObjectWrapper.Create (parentWrapper.proj, cc, parentWrapper) as ContainerChild;
- }
-
- protected Gtk.Container.ContainerChild ContextChildProps (Gtk.Widget context)
- {
- if (context == container)
- return null;
-
- do {
- if (context.Parent == container)
- return container[context];
- context = context.Parent;
- } while (context != null);
-
- return null;
- }
-
- public delegate void ContentsChangedHandler (Container container);
- public event ContentsChangedHandler ContentsChanged;
-
- protected void EmitContentsChanged ()
- {
- if (Loading)
- return;
- if (ContentsChanged != null)
- ContentsChanged (this);
- if (ParentWrapper != null)
- ParentWrapper.ChildContentsChanged (this);
- if (Project != null)
- Project.NotifyWidgetContentsChanged (this);
- NotifyChanged ();
- }
-
- protected Set AutoSize = new Set ();
-
- protected virtual Placeholder CreatePlaceholder ()
- {
- Placeholder ph = new Placeholder ();
- ph.Show ();
- return ph;
- }
-
- void PlaceholderButtonPress (object obj, Gtk.ButtonPressEventArgs args)
- {
- if (args.Event.Type != Gdk.EventType.ButtonPress)
- return;
-
- Placeholder ph = obj as Placeholder;
-
- if (args.Event.Button == 1) {
- proj.Selection = ph;
- args.RetVal = true;
- } else if (args.Event.Button == 3) {
- proj.PopupContextMenu (ph);
- args.RetVal = true;
- }
- }
-
- public static bool ShowNonContainerWarning {
- get { return showNonContainerWarning; }
- set { showNonContainerWarning = value; }
- }
-
- static IList nonContainers = new string[] {
- "Gtk.Button", "Gtk.Entry", "Gtk.Label", "Gtk.Arrow", "Gtk.Calendar", "Gtk.CheckButton",
- "Gtk.ColorButton", "Gtk.ComboBox", "Gtk.ComboBoxEntry", "Gtk.Entry", "Gtk.FontButton",
- "Gtk.HScale", "Gtk.VScale", "Gtk.Image", "Gtk.MenuBar", "Gtk.Toolbar", "Gtk.RadioButton",
- "Gtk.ProgressBar", "Stetic.Editor.ActionToolbar", "Stetic.Editor.ActionMenuBar",
- "Gtk.ToggleButton", "Gtk.TextView", "Gtk.VScrollbar", "Gtk.HScrollbar", "Gtk.SpinButton",
- "Gtk.Statusbar", "Gtk.HSeparator", "Gtk.VSeparator"
- };
-
- void PlaceholderDrop (Placeholder ph, Stetic.Wrapper.Widget wrapper)
- {
- Gtk.Dialog parentDialog = Wrapped.Parent as Gtk.Dialog;
- if (showNonContainerWarning && (IsTopLevel || (parentDialog != null && parentDialog.VBox == Wrapped))) {
- if (nonContainers.Contains (wrapper.Wrapped.GetType ().ToString ())) {
- using (NonContainerWarningDialog dlg = new NonContainerWarningDialog ()) {
- int res = dlg.Run ();
- showNonContainerWarning = dlg.ShowAgain;
- if (res != (int) Gtk.ResponseType.Ok)
- return;
- }
- }
- }
- using (UndoManager.AtomicChange) {
- ReplaceChild (ph, wrapper.Wrapped, true);
- wrapper.Select ();
- }
- }
-
- void PlaceholderDragDrop (object obj, Gtk.DragDropArgs args)
- {
- Placeholder ph = (Placeholder)obj;
- // This Drop call will end calling DropObject()
- DND.Drop (args.Context, args.Time, this, ph.UndoId);
- args.RetVal = true;
- }
-
- internal protected override void DropObject (string data, Gtk.Widget w)
- {
- Placeholder ph = FindPlaceholder (container, data);
- if (ph != null) {
- Widget dropped = Stetic.Wrapper.Widget.Lookup (w);
- if (dropped != null)
- PlaceholderDrop (ph, dropped);
- }
- }
-
- Placeholder FindPlaceholder (Gtk.Container c, string pid)
- {
- foreach (Gtk.Widget cw in c.AllChildren) {
- Placeholder ph = cw as Placeholder;
- if (ph != null && ph.UndoId == pid)
- return ph;
- Gtk.Container cc = cw as Gtk.Container;
- if (cc != null) {
- ph = FindPlaceholder (cc, pid);
- if (ph != null)
- return ph;
- }
- }
- return null;
- }
-
- void PlaceholderDragDataReceived (object obj, Gtk.DragDataReceivedArgs args)
- {
- Widget dropped = WidgetUtils.Paste (proj, args.SelectionData);
- Gtk.Drag.Finish (args.Context, dropped != null,
- dropped != null, args.Time);
- if (dropped != null) {
- dropped.RequiresUndoStatusUpdate = true;
- PlaceholderDrop ((Placeholder)obj, dropped);
- }
- }
-
- protected virtual void ChildContentsChanged (Container child)
- {
- }
-
- void ChildRemoved (object obj, Gtk.RemovedArgs args)
- {
- NotifyChildRemoved (args.Widget);
- }
-
- protected void NotifyChildRemoved (Gtk.Widget child)
- {
- if (Loading)
- return;
-
- ObjectWrapper w = ObjectWrapper.Lookup (child);
- if (w != null) {
- if (w.Loading)
- return;
- if (designer != null)
- w.OnDesignerDetach (designer);
- }
- ChildRemoved (child);
- }
-
- protected virtual void ChildRemoved (Gtk.Widget w)
- {
- AutoSize[w] = false;
- EmitContentsChanged ();
- }
-
- public virtual IEnumerable RealChildren {
- get {
- ArrayList children = new ArrayList ();
- foreach (Gtk.Widget widget in container.AllChildren) {
- if (!(widget is Placeholder))
- children.Add (widget);
- }
- return children;
- }
- }
-
- public virtual IEnumerable GladeChildren {
- get {
- return container.AllChildren;
- }
- }
-
- public void PasteChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- using (UndoManager.AtomicChange) {
- Widget w = Widget.Lookup (newChild);
- w.RequiresUndoStatusUpdate = true;
- ReplaceChild (oldChild, newChild, true);
- }
- }
-
- internal protected void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild, bool destroyOld)
- {
- ReplaceChild (oldChild, newChild);
- if (destroyOld)
- oldChild.Destroy ();
- }
-
- protected virtual void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- using (UndoManager.AtomicChange)
- {
- Gtk.Container.ContainerChild cc;
- Hashtable props = new Hashtable ();
-
- cc = container[oldChild];
- foreach (PropertyInfo pinfo in cc.GetType ().GetProperties ()) {
- if (!pinfo.IsDefined (typeof (Gtk.ChildPropertyAttribute), true))
- continue;
- props[pinfo] = pinfo.GetValue (cc, null);
- }
-
- container.Remove (oldChild);
- AutoSize[oldChild] = false;
- AutoSize[newChild] = true;
-
- try {
- // Don't fire the child added event until the packing info is set
- internalAdd = true;
- container.Add (newChild);
- } finally {
- internalAdd = false;
- }
-
- cc = container[newChild];
- foreach (PropertyInfo pinfo in props.Keys)
- pinfo.SetValue (cc, props[pinfo], null);
-
- Sync ();
- NotifyChildAdded (newChild);
- if (Project != null)
- Project.Selection = newChild;
- }
- }
-
- Gtk.Widget selection;
-
- public virtual void Select (Gtk.Widget widget)
- {
- if (widget == null) {
- Select (null, false);
- } else {
- Widget wrapper = Widget.Lookup (widget);
- bool allowDrag = wrapper != null && wrapper.InternalChildProperty == null && !wrapper.IsTopLevel;
- Select (widget, allowDrag);
- }
- }
-
- public virtual void UnSelect (Gtk.Widget widget)
- {
- if (selection == widget)
- Select (null, false);
- }
-
- void Select (Gtk.Widget widget, bool dragHandles)
- {
- if (widget == selection)
- return;
-
- Gtk.Window win = GetParentWindow ();
-
- if (selection != null) {
- selection.Destroyed -= SelectionDestroyed;
- HideSelectionBox (selection);
- Widget wr = Widget.Lookup (selection);
- if (wr != null)
- wr.OnUnselected ();
- }
-
- selection = widget;
- if (win != null) {
- if (widget != null) {
- if (widget.CanFocus)
- win.Focus = widget;
- else {
- // Look for a focusable parent container
- Widget wr = GetTopLevel ();
- Gtk.Widget w = wr.Wrapped;
- while (w != null && !w.CanFocus)
- w = w.Parent;
-
- // If the widget is not focusable,
- // remove the focus from the window. In this way we ensure
- // that the current selected widget will lose the focus,
- // even if the new selection is not focusable.
- win.Focus = w;
- }
- } else {
- if (designer != null)
- designer.ResetSelection (null);
- }
- }
-
- if (selection != null) {
- selection.Destroyed += SelectionDestroyed;
-
- // FIXME: if the selection isn't mapped, we should try to force it
- // to be. (Eg, if you select a widget in a hidden window, the window
- // should map. If you select a widget on a non-current notebook
- // page, the notebook should switch pages, etc.)
- if (selection.IsDrawable && selection.Visible) {
- ShowSelectionBox (selection, dragHandles);
- }
-
- Widget wr = Widget.Lookup (selection);
- if (wr != null)
- wr.OnSelected ();
- }
- }
-
- void ShowSelectionBox (Gtk.Widget widget, bool dragHandles)
- {
- HideSelectionBox (selection);
-
- IDesignArea designArea = GetDesignArea (widget);
- if (designArea != null) {
- IObjectSelection sel = designArea.SetSelection (widget, widget, dragHandles);
- sel.Drag += HandleWindowDrag;
- return;
- }
- }
-
- void HideSelectionBox (Gtk.Widget widget)
- {
- if (widget != null) {
- IDesignArea designArea = GetDesignArea (widget);
- if (designArea != null)
- designArea.ResetSelection (widget);
- }
- }
-
- Gtk.Window GetParentWindow ()
- {
- Gtk.Container cc = Wrapped as Gtk.Container;
- while (cc.Parent != null)
- cc = cc.Parent as Gtk.Container;
- return cc as Gtk.Window;
- }
-
- void SelectionDestroyed (object obj, EventArgs args)
- {
- if (!IsDisposed)
- UnSelect (selection);
- }
-
- Gtk.Widget dragSource;
-
- void HandleWindowDrag (Gdk.EventMotion evt, int dx, int dy)
- {
- Gtk.Widget dragWidget = selection;
-
- Project.Selection = null;
-
- using (UndoManager.AtomicChange) {
- dragSource = CreateDragSource (dragWidget);
- }
-
- DND.Drag (dragSource, evt, dragWidget);
- }
-
- protected virtual Gtk.Widget CreateDragSource (Gtk.Widget dragWidget)
- {
- Placeholder ph = CreatePlaceholder ();
- Gdk.Rectangle alloc = dragWidget.Allocation;
- ph.SetSizeRequest (alloc.Width, alloc.Height);
- ph.DragEnd += DragEnd;
- ReplaceChild (dragWidget, ph, false);
- return ph;
- }
-
- void DragEnd (object obj, Gtk.DragEndArgs args)
- {
- using (UndoManager.AtomicChange) {
- Placeholder ph = obj as Placeholder;
- ph.DragEnd -= DragEnd;
-
- dragSource = null;
- if (DND.DragWidget == null) {
- if (AllowPlaceholders)
- ph.SetSizeRequest (-1, -1);
- else
- container.Remove (ph);
- Sync ();
- } else
- ReplaceChild (ph, DND.Cancel (), true);
- }
- }
-
- public virtual void Delete (Stetic.Wrapper.Widget wrapper)
- {
- using (UndoManager.AtomicChange) {
- if (AllowPlaceholders)
- ReplaceChild (wrapper.Wrapped, CreatePlaceholder (), true);
- else {
- container.Remove (wrapper.Wrapped);
- wrapper.Wrapped.Destroy ();
- }
- }
- }
-
- public virtual void Delete (Stetic.Placeholder ph)
- {
- if (AllowPlaceholders) {
- // Don't allow deleting the only placeholder of a top level container
- if (IsTopLevel && container.Children.Length == 1)
- return;
- using (UndoManager.AtomicChange) {
- container.Remove (ph);
- ph.Destroy ();
- // If there aren't more placeholders in this container, just delete the container
- if (container.Children.Length == 0)
- Delete ();
- }
- }
- }
-
- protected bool ChildHExpandable (Gtk.Widget child)
- {
- if (child == dragSource)
- child = DND.DragWidget;
- else if (child is Placeholder)
- return true;
-
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (child);
- if (wrapper != null)
- return wrapper.HExpandable;
- else
- return false;
- }
-
- protected bool ChildVExpandable (Gtk.Widget child)
- {
- if (child == dragSource)
- child = DND.DragWidget;
- else if (child is Placeholder)
- return true;
-
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (child);
- if (wrapper != null)
- return wrapper.VExpandable;
- else
- return false;
- }
-
- // Note that this will be invalid/random for non-H/V-paired classes
- protected Gtk.Orientation ContainerOrientation;
-
- public override bool HExpandable {
- get {
- if (base.HExpandable)
- return true;
-
- // A horizontally-oriented container is HExpandable if any
- // child is. A vertically-oriented container is HExpandable
- // if *every* child is.
-
- foreach (Gtk.Widget w in container) {
- if (ChildHExpandable (w)) {
- if (ContainerOrientation == Gtk.Orientation.Horizontal)
- return true;
- } else if (ContainerOrientation == Gtk.Orientation.Vertical)
- return false;
- }
- return (ContainerOrientation == Gtk.Orientation.Vertical);
- }
- }
-
- public override bool VExpandable {
- get {
- if (base.VExpandable)
- return true;
-
- // Opposite of above
-
- foreach (Gtk.Widget w in container) {
- if (ChildVExpandable (w)) {
- if (ContainerOrientation == Gtk.Orientation.Vertical)
- return true;
- } else if (ContainerOrientation == Gtk.Orientation.Horizontal)
- return false;
- }
- return (ContainerOrientation == Gtk.Orientation.Horizontal);
- }
- }
-
- void ValidateChildNames (Gtk.Widget newWidget)
- {
- // newWidget is the widget which triggered the name check.
- // It will be the last widget to check, so if there are
- // name conflicts, the name to change to avoid the conflict
- // will be the name of that widget.
-
- if (!IsTopLevel) {
- ParentWrapper.ValidateChildNames (newWidget);
- return;
- }
-
- Hashtable names = new Hashtable ();
-
- // Validate all names excluding the new widget
- ValidateChildName (names, container, newWidget);
-
- if (newWidget != null) {
- // Now validate names in the new widget.
- ValidateChildName (names, newWidget, null);
- }
- }
-
- void ValidateChildName (Hashtable names, Gtk.Widget w, Gtk.Widget newWidget)
- {
- if (w == newWidget)
- return;
-
- if (names.Contains (w.Name)) {
- // There is a widget with the same name. If the widget
- // has a numeric suffix, just increase it.
- string name; int idx;
- WidgetUtils.ParseWidgetName (w.Name, out name, out idx);
-
- string compName = idx != 0 ? name + idx : name;
- while (names.Contains (compName)) {
- idx++;
- compName = name + idx;
- }
- w.Name = compName;
- Widget ww = Widget.Lookup (w);
- if (ww != null)
- ww.InitializeName (compName);
- else
- w.Name = compName;
-
- }
-
- names [w.Name] = w;
-
- if (w is Gtk.Container) {
- foreach (Gtk.Widget cw in ((Gtk.Container)w).AllChildren)
- ValidateChildName (names, cw, newWidget);
- }
- }
-
- internal string GetValidWidgetName (Gtk.Widget widget)
- {
- // Get a valid name for a widget (a name that doesn't
- // exist in the parent container.
-
- if (!IsTopLevel)
- return ParentWrapper.GetValidWidgetName (widget);
-
- string name;
- int idx;
-
- WidgetUtils.ParseWidgetName (widget.Name, out name, out idx);
-
- string compName = idx != 0 ? name + idx : name;
-
- Gtk.Widget fw = FindWidget (compName, widget);
- while (fw != null) {
- idx++;
- compName = name + idx;
- fw = FindWidget (compName, widget);
- }
-
- return compName;
- }
-
- public Widget FindChild (string name)
- {
- Gtk.Widget w = FindWidget (name, null);
- return Widget.Lookup (w);
- }
-
- Gtk.Widget FindWidget (string name, Gtk.Widget skipwidget)
- {
- if (Wrapped != skipwidget && Wrapped.Name == name)
- return Wrapped;
- else
- return FindWidget ((Gtk.Container)Wrapped, name, skipwidget);
- }
-
- Gtk.Widget FindWidget (Gtk.Container parent, string name, Gtk.Widget skipwidget)
- {
- foreach (Gtk.Widget w in parent.AllChildren) {
- if (w.Name == name && w != skipwidget)
- return w;
- if (w is Gtk.Container) {
- Gtk.Widget res = FindWidget ((Gtk.Container)w, name, skipwidget);
- if (res != null)
- return res;
- }
- }
- return null;
- }
-
- public override ObjectWrapper FindObjectByUndoId (string id)
- {
- ObjectWrapper c = base.FindObjectByUndoId (id);
- if (c != null)
- return c;
-
- foreach (Gtk.Widget w in container.AllChildren) {
- Widget ww = Widget.Lookup (w);
- if (ww == null)
- continue;
- ObjectWrapper ow = ww.FindObjectByUndoId (id);
- if (ow != null)
- return ow;
- }
- return null;
- }
-
-
-
- public class ContainerChild : Stetic.ObjectWrapper
- {
- internal static void Register ()
- {
- // FIXME?
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- cc.Child.ChildNotified += ChildNotifyHandler;
- cc.Child.ParentSet += OnParentSet;
- }
-
- [GLib.ConnectBefore]
- void OnParentSet (object ob, Gtk.ParentSetArgs args)
- {
- // Dispose the wrapper if the child is removed from the parent
- Gtk.Widget w = (Gtk.Widget)ob;
- if (w.Parent == null) {
- Dispose ();
- w.ParentSet -= OnParentSet;
- }
- }
-
- public override void Dispose ()
- {
- cc.Child.ChildNotified -= ChildNotifyHandler;
- base.Dispose ();
- }
-
- protected virtual void ChildNotifyHandler (object obj, Gtk.ChildNotifiedArgs args)
- {
- ParamSpec pspec = new ParamSpec (args.Pspec);
- EmitNotify (pspec.Name);
- }
-
- protected override void EmitNotify (string propertyName)
- {
- base.EmitNotify (propertyName);
- ParentWrapper.Sync ();
- ParentWrapper.NotifyChanged ();
- }
-
- Gtk.Container.ContainerChild cc {
- get {
- return (Gtk.Container.ContainerChild)Wrapped;
- }
- }
-
- protected Stetic.Wrapper.Container ParentWrapper {
- get {
- return Stetic.Wrapper.Container.Lookup (cc.Parent);
- }
- }
-
- public bool AutoSize {
- get {
- return ParentWrapper.AutoSize[cc.Child];
- }
- set {
- ParentWrapper.AutoSize[cc.Child] = value;
- EmitNotify ("AutoSize");
- }
- }
-
- public override string Name { get; set; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Custom.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Custom.cs
deleted file mode 100644
index 5f73164b8e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Custom.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-using System;
-using Gtk;
-
-namespace Stetic
-{
- public class Custom : Gtk.DrawingArea
- {
- public Custom () {}
-
- public Custom (IntPtr raw) : base (raw) {}
-
- // from glade
- static private string[] custom_bg_xpm = {
- "8 8 4 1",
- " c None",
- ". c #BBBBBB",
- "+ c #D6D6D6",
- "@ c #6B5EFF",
- ".+..+...",
- "+..@@@..",
- "..@...++",
- "..@...++",
- "+.@..+..",
- ".++@@@..",
- "..++....",
- "..++...."
- };
-
- Gdk.Pixmap pixmap;
-
- protected override void OnRealized ()
- {
- base.OnRealized ();
-
- Gdk.Pixmap mask;
- pixmap = Gdk.Pixmap.CreateFromXpmD (GdkWindow, out mask, new Gdk.Color (99, 99, 99), custom_bg_xpm);
- }
-
- string creationFunction, string1, string2;
- int int1, int2;
-
- public string CreationFunction {
- get {
- return creationFunction;
- }
- set {
- creationFunction = value;
- }
- }
-
- public string LastModificationTime {
- get {
- return null;
- }
- set {
- ;
- }
- }
-
- public string String1 {
- get {
- return string1;
- }
- set {
- string1 = value;
- }
- }
-
- public string String2 {
- get {
- return string2;
- }
- set {
- string2 = value;
- }
- }
-
- public int Int1 {
- get {
- return int1;
- }
- set {
- int1 = value;
- }
- }
-
- public int Int2 {
- get {
- return int2;
- }
- set {
- int2 = value;
- }
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose evt)
- {
- if (!IsDrawable)
- return false;
-
- int width, height;
- GdkWindow.GetSize (out width, out height);
-
- Gdk.GC light, dark;
- light = Style.LightGC (StateType.Normal);
- dark = Style.DarkGC (StateType.Normal);
-
- // Looks like GdkWindow.SetBackPixmap doesn't work very well,
- // so draw the pixmap manually.
- light.Fill = Gdk.Fill.Tiled;
- light.Tile = pixmap;
- GdkWindow.DrawRectangle (light, true, 0, 0, width, height);
- light.Fill = Gdk.Fill.Solid;
-
- GdkWindow.DrawLine (light, 0, 0, width - 1, 0);
- GdkWindow.DrawLine (light, 0, 0, 0, height - 1);
- GdkWindow.DrawLine (dark, 0, height - 1, width - 1, height - 1);
- GdkWindow.DrawLine (dark, width - 1, 0, width - 1, height - 1);
-
- return base.OnExposeEvent (evt);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Dialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Dialog.cs
deleted file mode 100644
index 82312cfd4d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Dialog.cs
+++ /dev/null
@@ -1,183 +0,0 @@
-using System;
-using System.Xml;
-using System.Collections;
-
-namespace Stetic.Wrapper {
-
- public class Dialog : Window {
-
- Stetic.Wrapper.ButtonBox actionArea;
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
-
- actionArea = (ButtonBox)Container.Lookup (dialog.ActionArea);
- actionArea.SetActionDialog (this);
-
- if (!initialized) {
- dialog.HasSeparator = false;
- if (!initialized && dialog.VBox.Children.Length == 1) {
- Container vbox = Container.Lookup (dialog.VBox);
- Placeholder ph = vbox.AddPlaceholder ();
- ph.SetSizeRequest (200, 200);
- Buttons = 1;
- }
- } else
- ButtonsChanged (actionArea);
-
- actionArea.ContentsChanged += ButtonsChanged;
- }
-
- internal static new TopLevelDialog CreateInstance ( )
- {
- return new TopLevelDialog ();
- }
-
- public override void Dispose ( )
- {
- actionArea.ContentsChanged -= ButtonsChanged;
- actionArea.SetActionDialog (null);
- base.Dispose ();
- }
-
- protected override void ReadChildren (ObjectReader reader, XmlElement elem)
- {
- // Ignore changes in the buttons while loading
- actionArea.ContentsChanged -= ButtonsChanged;
- base.ReadChildren (reader, elem);
- actionArea.ContentsChanged += ButtonsChanged;
- actionArea.SetActionDialog (this);
- }
-
- TopLevelDialog dialog {
- get {
- return (TopLevelDialog) Wrapped;
- }
- }
-
- public Gtk.HButtonBox ActionArea {
- get { return dialog.ActionArea; }
- }
-
- public Gtk.VBox VBox
- {
- get { return dialog.VBox; }
- }
-
- public bool HasSeparator {
- get { return dialog.HasSeparator; }
- set { dialog.HasSeparator = value; EmitNotify ("HasSeparator"); }
- }
-
- public int Buttons
- {
- get {
- return actionArea.Size - ExtraButtons;
- }
- set {
- actionArea.Size = value + ExtraButtons;
- EmitNotify ("Buttons");
- }
- }
-
- int ExtraButtons {
- get {
- return helpButton == null ? 0 : 1;
- }
- }
-
- Gtk.Button helpButton;
-
- public bool HelpButton {
- get {
- return helpButton != null;
- }
- set {
- if (HelpButton == value)
- return;
-
- if (value) {
- helpButton = AddButton (Gtk.Stock.Help, Gtk.ResponseType.Help, false);
- // Make it the first child, so that decreasing
- // Buttons won't delete it
- dialog.ActionArea.ReorderChild (helpButton, 0);
- } else {
- helpButton.Destroy ();
- helpButton = null;
- }
-
- EmitNotify ("HelpButton");
- }
- }
-
- // Check that a button is the Help button
- bool ButtonIsHelp (Gtk.Button button)
- {
- return (button.UseStock &&
- button.Label == Gtk.Stock.Help &&
- dialog.ActionArea.GetChildSecondary (button));
- }
-
- Gtk.Button AddButton (string stockId, Gtk.ResponseType response, bool hasDefault)
- {
- Stetic.Wrapper.Button wrapper;
- Gtk.Button button;
-
- button = (Gtk.Button)Registry.NewInstance ("Gtk.Button", proj);
- wrapper = (Stetic.Wrapper.Button) ObjectWrapper.Lookup (button);
- if (stockId != null) {
- wrapper.Type = Button.ButtonType.StockItem;
- wrapper.StockId = stockId;
- } else {
- wrapper.Type = Button.ButtonType.TextOnly;
- wrapper.Label = button.Name;
- }
- wrapper.ResponseId = (int)response;
-
- Stetic.Wrapper.Container actionArea = Stetic.Wrapper.Container.Lookup (dialog.ActionArea);
- actionArea.Add (button);
-
- button.CanDefault = true;
- wrapper.HasDefault = hasDefault;
-
- if (stockId == Gtk.Stock.Help)
- ((Gtk.ButtonBox)actionArea.Wrapped).SetChildSecondary (button, true);
-
- return button;
- }
-
- void ButtonsChanged (Container container)
- {
- Gtk.Widget[] children = dialog.ActionArea.Children;
-
- // If the user manually removes (or breaks) the Help button,
- // uncheck the corresponding property
- if (helpButton != null) {
- if (Array.IndexOf (children, helpButton) == -1 ||
- !ButtonIsHelp (helpButton)) {
- helpButton = null;
- EmitNotify ("HelpButton");
- }
- }
-
- // If the user manually creates a Help button, set the property
- if (helpButton == null) {
- foreach (Gtk.Widget w in children) {
- Gtk.Button button = w as Gtk.Button;
- if (button != null && ButtonIsHelp (button)) {
- helpButton = button;
- dialog.ActionArea.ReorderChild (helpButton, 0);
- EmitNotify ("HelpButton");
- break;
- }
- }
- }
-
- // If the user removed all (non-Secondary) buttons, add back a
- // single custom button
- if (Buttons == 0)
- Buttons = 1;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Entry.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Entry.cs
deleted file mode 100644
index 64a9b068b2..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Entry.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.ComponentModel;
-
-namespace Stetic.Wrapper
-{
- public class Entry: Widget
- {
- [DefaultValue ('*')]
- public char InvisibleChar {
- get { return ((Gtk.Entry)Wrapped).InvisibleChar; }
- set { ((Gtk.Entry)Wrapped).InvisibleChar = value; }
- }
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Expander.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Expander.cs
deleted file mode 100644
index 7ea5d73acf..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Expander.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class Expander : Container {
-
- public static Gtk.Expander CreateInstance ()
- {
- return new Gtk.Expander ("");
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized) {
- expander.Label = expander.Name;
- if (AllowPlaceholders)
- AddPlaceholder ();
- }
- if (expander.LabelWidget != null)
- ObjectWrapper.Create (proj, expander.LabelWidget, this);
- }
-
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- if ((string)GladeUtils.GetChildProperty (child_elem, "type", "") == "label_item") {
- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- expander.LabelWidget = (Gtk.Widget)wrapper.Wrapped;
- return wrapper;
- } else
- return base.ReadChild (reader, child_elem);
- }
-
- protected override XmlElement WriteChild (ObjectWriter writer, Widget wrapper)
- {
- XmlElement child_elem = base.WriteChild (writer, wrapper);
- if (wrapper.Wrapped == expander.LabelWidget)
- GladeUtils.SetChildProperty (child_elem, "type", "label_item");
- return child_elem;
- }
-
- Gtk.Expander expander {
- get {
- return (Gtk.Expander)Wrapped;
- }
- }
-
- protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- if (oldChild == expander.LabelWidget)
- expander.LabelWidget = newChild;
- else
- base.ReplaceChild (oldChild, newChild);
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- return new CodeObjectCreateExpression (ClassDescriptor.WrappedTypeName.ToGlobalTypeRef (), new CodePrimitiveExpression (null));
- }
-
- protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
- {
- if (wrapper.Wrapped == expander.LabelWidget) {
- CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
- CodeAssignStatement assign = new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- parentVar,
- "LabelWidget"
- ),
- var
- );
- ctx.Statements.Add (assign);
- } else
- base.GenerateChildBuildCode (ctx, parentVar, wrapper);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Fixed.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Fixed.cs
deleted file mode 100644
index 840c050dcc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Fixed.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-
-using System;
-
-namespace Stetic.Wrapper
-{
- public class Fixed: Container
- {
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
-
- DND.DestSet (gtkfixed, true);
- gtkfixed.DragDrop += FixedDragDrop;
- gtkfixed.DragDataReceived += FixedDragDataReceived;
- }
-
- public override void Dispose ()
- {
- gtkfixed.DragDrop -= FixedDragDrop;
- gtkfixed.DragDataReceived -= FixedDragDataReceived;
- }
-
- Gtk.Fixed gtkfixed {
- get {
- return (Gtk.Fixed)Wrapped;
- }
- }
-
- protected override bool AllowPlaceholders {
- get {
- return false;
- }
- }
-
- void FixedDragDrop (object obj, Gtk.DragDropArgs args)
- {
- Gtk.Widget w = DND.Drop (args.Context, gtkfixed, args.Time);
- Widget ww = Widget.Lookup (w);
- if (ww != null) {
- gtkfixed.Put (w, args.X - DND.DragHotX, args.Y - DND.DragHotY);
- NotifyChildAdded (w);
- args.RetVal = true;
- ww.Select ();
- }
- }
-
- void FixedDragDataReceived (object obj, Gtk.DragDataReceivedArgs args)
- {
- Widget dropped = WidgetUtils.Paste (proj, args.SelectionData);
- Gtk.Drag.Finish (args.Context, dropped != null, dropped != null, args.Time);
- if (dropped != null) {
- gtkfixed.Put (dropped.Wrapped, 0, 0);
- NotifyChildAdded (dropped.Wrapped);
- dropped.Select ();
- }
- }
-
- int dragX, dragY;
-
- protected override Gtk.Widget CreateDragSource (Gtk.Widget dragWidget)
- {
- Gtk.Fixed.FixedChild fc = (Gtk.Fixed.FixedChild) gtkfixed [dragWidget];
- if (fc == null)
- return null;
-
- dragX = fc.X;
- dragY = fc.Y;
-
- gtkfixed.Remove (dragWidget);
- gtkfixed.DragEnd += DragEnd;
- return gtkfixed;
- }
-
- void DragEnd (object obj, Gtk.DragEndArgs args)
- {
- using (UndoManager.AtomicChange) {
- gtkfixed.DragEnd -= DragEnd;
- if (DND.DragWidget != null) {
- DND.DragWidget.Unparent ();
- gtkfixed.Put (DND.DragWidget, dragX, dragY);
- NotifyChildAdded (DND.DragWidget);
- Widget ww = Widget.Lookup (DND.DragWidget);
- ww.Select ();
- }
- }
- }
-
- public class FixedChild : Container.ContainerChild {
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/FontButton.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/FontButton.cs
deleted file mode 100644
index c005e23e4e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/FontButton.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-
-namespace Stetic.Wrapper {
-
- public class FontButton : Widget {
-
- public bool UseFont {
- get {
- return ((Gtk.FontButton)Wrapped).UseFont;
- }
- set {
- Gtk.FontButton fb = (Gtk.FontButton)Wrapped;
-
- fb.UseFont = value;
-
- // Force it to update
- fb.ShowSize = !fb.ShowSize;
- fb.ShowSize = !fb.ShowSize;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/FontSelectionDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/FontSelectionDialog.cs
deleted file mode 100644
index f0b1cf000e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/FontSelectionDialog.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-
-namespace Stetic.Wrapper {
-
- public class FontSelectionDialog : Dialog {
-
- public Gtk.FontSelection FontSelection {
- get {
- Gtk.Dialog dialog = (Gtk.Dialog)Wrapped;
-
- foreach (Gtk.Widget w in dialog.VBox) {
- if (w is Gtk.FontSelection)
- return (Gtk.FontSelection)w;
- }
- return null;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Frame.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Frame.cs
deleted file mode 100644
index 4478c0ff36..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Frame.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class Frame : Container {
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized) {
- frame.Label = "<b>" + frame.Name + "</b>";
- ((Gtk.Label)frame.LabelWidget).UseMarkup = true;
- frame.Shadow = Gtk.ShadowType.None;
- if (AllowPlaceholders) {
- Gtk.Alignment align = new Gtk.Alignment (0, 0, 1, 1);
- align.LeftPadding = 12;
- Container align_wrapper = (Container)ObjectWrapper.Create (proj, align, this);
- align_wrapper.AddPlaceholder ();
- ReplaceChild (frame.Child, (Gtk.Widget)align_wrapper.Wrapped, true);
- }
- }
-
- if (frame.LabelWidget != null)
- ObjectWrapper.Create (proj, frame.LabelWidget, this);
- frame.AddNotification ("label-widget", LabelWidgetChanged);
- }
-
- void LabelWidgetChanged (object obj, GLib.NotifyArgs args)
- {
- if (!IsDisposed && frame.LabelWidget != null && !(frame.LabelWidget is Stetic.Placeholder))
- ObjectWrapper.Create (proj, frame.LabelWidget, this);
- }
-
- Gtk.Frame frame {
- get {
- return (Gtk.Frame)Wrapped;
- }
- }
-
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- if ((string)GladeUtils.GetChildProperty (child_elem, "type", "") == "label_item") {
- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- frame.LabelWidget = (Gtk.Widget)wrapper.Wrapped;
- return wrapper;
- } else
- return base.ReadChild (reader, child_elem);
- }
-
- protected override XmlElement WriteChild (ObjectWriter writer, Widget wrapper)
- {
- XmlElement child_elem = base.WriteChild (writer, wrapper);
- if (wrapper.Wrapped == frame.LabelWidget)
- GladeUtils.SetChildProperty (child_elem, "type", "label_item");
- return child_elem;
- }
-
- protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
- {
- if (wrapper.Wrapped == frame.LabelWidget) {
- CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
- CodeAssignStatement assign = new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- parentVar,
- "LabelWidget"
- ),
- var
- );
- ctx.Statements.Add (assign);
- } else
- base.GenerateChildBuildCode (ctx, parentVar, wrapper);
- }
-
- protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- if (oldChild == frame.LabelWidget)
- frame.LabelWidget = newChild;
- else
- base.ReplaceChild (oldChild, newChild);
- }
-
- public override void Delete (Stetic.Placeholder ph)
- {
- using (UndoManager.AtomicChange) {
- Delete ();
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/HScale.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/HScale.cs
deleted file mode 100644
index 0af92c7a5f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/HScale.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class HScale : Scale {
-
- public static Gtk.HScale CreateInstance ()
- {
- return new Gtk.HScale (0.0, 100.0, 1.0);
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- return new CodeObjectCreateExpression (ClassDescriptor.WrappedTypeName.ToGlobalTypeRef (), new CodePrimitiveExpression (null));
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/HScrollbar.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/HScrollbar.cs
deleted file mode 100644
index 696ccee6b8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/HScrollbar.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class HScrollbar : Range {
-
- public static Gtk.HScrollbar CreateInstance ()
- {
- return new Gtk.HScrollbar (new Gtk.Adjustment (0.0, 0.0, 100.0, 1.0, 10.0, 10.0));
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- return new CodeObjectCreateExpression (ClassDescriptor.WrappedTypeName.ToGlobalTypeRef (), new CodePrimitiveExpression (null));
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/IconView.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/IconView.cs
deleted file mode 100644
index 592b005e54..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/IconView.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// IconView.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-//
-
-namespace Stetic.Wrapper
-{
- public class IconView: Container
- {
- protected override bool AllowPlaceholders {
- get {
- return false;
- }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Image.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Image.cs
deleted file mode 100644
index befbc1c642..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Image.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using System.Xml;
-using System.Collections;
-
-namespace Stetic.Wrapper {
-
- public class Image : Misc {
-
- ImageInfo imageInfo;
-
- public static Gtk.Image CreateInstance ()
- {
- return new Gtk.Image (Gtk.Stock.Execute, Gtk.IconSize.Dialog);
- }
-
- protected override void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- if (reader.Format == FileFormat.Glade) {
- string file = (string)GladeUtils.ExtractProperty (elem, "pixbuf", "");
- string stock = (string)GladeUtils.ExtractProperty (elem, "stock", "");
- string iconSize = (string)GladeUtils.ExtractProperty (elem, "icon_size", "");
- base.ReadProperties (reader, elem);
-
- if (stock != null && stock.Length > 0) {
- Pixbuf = ImageInfo.FromTheme (stock, (Gtk.IconSize) int.Parse (iconSize));
- } else if (file != null && file != "") {
- Pixbuf = ImageInfo.FromFile (file);
- }
- } else
- base.ReadProperties (reader, elem);
- }
-
- protected override XmlElement WriteProperties (ObjectWriter writer)
- {
- XmlElement elem = base.WriteProperties (writer);
- if (imageInfo != null) {
- if (writer.Format == FileFormat.Glade) {
- // The generated pixbuf property doesn't have a valid value, it needs to be replaced.
- GladeUtils.ExtractProperty (elem, "pixbuf", "");
- switch (imageInfo.Source) {
- case ImageSource.File:
- GladeUtils.SetProperty (elem, "pixbuf", imageInfo.Name);
- break;
- case ImageSource.Theme:
- GladeUtils.SetProperty (elem, "stock", imageInfo.Name);
- GladeUtils.SetProperty (elem, "icon_size", ((int)imageInfo.ThemeIconSize).ToString ());
- break;
- default:
- throw new System.NotSupportedException ("Image source not supported by Glade.");
- }
- }
- }
- return elem;
- }
-
- Gtk.Image image {
- get {
- return (Gtk.Image)Wrapped;
- }
- }
-
- void BreakImage ()
- {
- image.IconSize = (int)Gtk.IconSize.Button;
- image.Stock = Gtk.Stock.MissingImage;
- }
-
- public ImageInfo Pixbuf {
- get { return imageInfo; }
- set {
- imageInfo = value;
- if (imageInfo == null)
- BreakImage ();
- else
- image.Pixbuf = imageInfo.GetImage (Project);
- EmitNotify ("Pixbuf");
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ImageMenuItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ImageMenuItem.cs
deleted file mode 100644
index 24cfd01465..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ImageMenuItem.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Xml;
-
-namespace Stetic.Wrapper {
-
- public class ImageMenuItem : MenuItem {
-
- public static new Gtk.ImageMenuItem CreateInstance ()
- {
- // Use the ctor that will create an AccelLabel
- return new Gtk.ImageMenuItem ("");
- }
-
- protected override void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- Gtk.StockItem stockItem = Gtk.StockItem.Zero;
- bool use_stock = (bool)GladeUtils.ExtractProperty (elem, "use_stock", false);
- if (use_stock) {
- string label = (string)GladeUtils.GetProperty (elem, "label", "");
- stockItem = Gtk.Stock.Lookup (label);
- if (stockItem.Label != null)
- GladeUtils.ExtractProperty (elem, "label", "");
- }
- base.ReadProperties (reader, elem);
-
- if (stockItem.StockId != null)
- Image = "stock:" + stockItem.StockId;
- if (stockItem.Keyval != 0)
- Accelerator = Gtk.Accelerator.Name (stockItem.Keyval, stockItem.Modifier);
- }
-
- string image;
-
- public string Image {
- get {
- return image;
- }
- set {
- image = value;
-
- Gtk.Widget icon;
- Gtk.StockItem stockItem = Gtk.StockItem.Zero;
-
- if (image.StartsWith ("stock:"))
- stockItem = Gtk.Stock.Lookup (image.Substring (6));
-
- if (stockItem.StockId != null) {
- icon = new Gtk.Image (stockItem.StockId, Gtk.IconSize.Menu);
- Label = stockItem.Label;
- UseUnderline = true;
- } else if (image.StartsWith ("file:"))
- icon = new Gtk.Image (image.Substring (5));
- else
- icon = new Gtk.Image (WidgetUtils.MissingIcon);
-
- ((Gtk.ImageMenuItem)Wrapped).Image = icon;
-
- EmitNotify ("Image");
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Label.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Label.cs
deleted file mode 100644
index e12944c6f1..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Label.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.CodeDom;
-using System.Collections;
-
-namespace Stetic.Wrapper {
-
- public class Label : Misc {
-
- public Label () {}
-
- string mnem;
- public string MnemonicWidget {
- get {
- return mnem;
- }
- set {
- mnem = value;
- }
- }
-
- protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- if (prop.Name != "MnemonicWidget")
- base.GeneratePropertySet (ctx, var, prop);
- }
-
- internal protected override void GeneratePostBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- if (mnem != null) {
- Widget targetWidget = GetTopLevel ().FindChild (mnem);
- if (targetWidget != null) {
- CodeExpression memVar = ctx.WidgetMap.GetWidgetExp (targetWidget);
- if (memVar != null) {
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- var,
- "MnemonicWidget"
- ),
- memVar
- )
- );
- }
- }
- }
- base.GeneratePostBuildCode (ctx, var);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MenuBar.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MenuBar.cs
deleted file mode 100644
index fec2f29509..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MenuBar.cs
+++ /dev/null
@@ -1,261 +0,0 @@
-
-using System;
-using System.CodeDom;
-using System.Xml;
-using System.Collections;
-using Stetic.Editor;
-
-namespace Stetic.Wrapper
-{
- public class MenuBar: Container
- {
- ActionTree actionTree;
- XmlElement menuInfo;
- bool treeChanged;
-
- public MenuBar()
- {
- }
-
- public override void Dispose ()
- {
- DisposeTree ();
- base.Dispose ();
- }
-
- public static Gtk.MenuBar CreateInstance ()
- {
- return new ActionMenuBar ();
- }
-
- protected override bool AllowPlaceholders {
- get { return false; }
- }
-
- ActionMenuBar menu {
- get { return (ActionMenuBar) Wrapped; }
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- CreateTree ();
- }
-
- internal protected override void OnSelected ()
- {
- Loading = true;
- menu.ShowInsertPlaceholder = true;
- Loading = false;
- }
-
- internal protected override void OnUnselected ()
- {
- base.OnUnselected ();
- Loading = true;
- menu.ShowInsertPlaceholder = false;
- menu.Unselect ();
- Loading = false;
- }
-
- protected override XmlElement WriteProperties (ObjectWriter writer)
- {
- XmlElement elem = base.WriteProperties (writer);
- if (menuInfo != null)
- elem.AppendChild (writer.XmlDocument.ImportNode (menuInfo, true));
- else
- elem.AppendChild (actionTree.Write (writer.XmlDocument, writer.Format));
- return elem;
- }
-
- protected override void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- base.ReadProperties (reader, elem);
- menuInfo = elem ["node"];
- treeChanged = false;
- }
-
- public override object GetUndoDiff ()
- {
- XmlElement oldElem = treeChanged ? UndoManager.GetObjectStatus (this) ["node"] : null;
- if (oldElem != null)
- oldElem = (XmlElement) oldElem.CloneNode (true);
-
- treeChanged = false;
- object baseDiff = base.GetUndoDiff ();
-
- if (oldElem != null) {
- XmlElement newElem = UndoManager.GetObjectStatus (this) ["node"];
- if (newElem != null && oldElem.OuterXml == newElem.OuterXml)
- oldElem = null;
- }
-
- if (baseDiff == null && oldElem == null)
- return null;
- else {
- object stat = menu.SaveStatus ();
- return new object[] { baseDiff, oldElem, stat };
- }
- }
-
- public override object ApplyUndoRedoDiff (object diff)
- {
- object[] data = (object[]) diff;
- object retBaseDiff;
- XmlElement oldNode = null;
-
- if (actionTree != null) {
- XmlElement status = UndoManager.GetObjectStatus (this);
- oldNode = status ["node"];
- if (oldNode != null)
- oldNode = (XmlElement) oldNode.CloneNode (true);
- }
- object oldStat = menu.SaveStatus ();
-
- if (data [0] != null)
- retBaseDiff = base.ApplyUndoRedoDiff (data [0]);
- else
- retBaseDiff = null;
-
- XmlElement xdiff = (XmlElement) data [1];
-
- if (xdiff != null) {
- XmlElement status = UndoManager.GetObjectStatus (this);
- XmlElement prevNode = status ["node"];
- if (prevNode != null)
- status.RemoveChild (prevNode);
- status.AppendChild (xdiff);
-
- if (actionTree != null) {
- Loading = true;
- menu.OpenSubmenu = null;
- DisposeTree ();
- CreateTree ();
- actionTree.Read (this, xdiff);
- menu.FillMenu (actionTree);
- Loading = false;
- } else
- menuInfo = xdiff;
- }
-
- // Restore the status after all menu structure has been properly built
- GLib.Timeout.Add (50, delegate {
- menu.RestoreStatus (data[2]);
- return false;
- });
-
- return new object [] { retBaseDiff, oldNode, oldStat };
- }
-
- protected override void OnNameChanged (WidgetNameChangedArgs args)
- {
- base.OnNameChanged (args);
- if (actionTree != null)
- actionTree.Name = Name;
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- BuildTree ();
- actionTree.Name = Name;
- CodeExpression exp = GenerateUiManagerElement (ctx, actionTree);
- if (exp != null)
- return new CodeCastExpression (typeof(Gtk.MenuBar).ToGlobalTypeRef (), exp);
- else
- return base.GenerateObjectCreation (ctx);
- }
-
- internal protected override void OnDesignerAttach (IDesignArea designer)
- {
- base.OnDesignerAttach (designer);
- BuildTree ();
- Loading = true;
- menu.FillMenu (actionTree);
- Loading = false;
-
- if (LocalActionGroups.Count == 0)
- LocalActionGroups.Add (new ActionGroup ("Default"));
- }
-
- void BuildTree ()
- {
- if (menuInfo != null) {
- DisposeTree ();
- CreateTree ();
- actionTree.Read (this, menuInfo);
- menuInfo = null;
- }
- }
-
- void CreateTree ()
- {
- actionTree = new ActionTree ();
- actionTree.Name = Name;
- actionTree.Type = Gtk.UIManagerItemType.Menubar;
- actionTree.Changed += OnTreeChanged;
- }
-
- void DisposeTree ()
- {
- if (actionTree != null) {
- actionTree.Dispose ();
- actionTree.Changed -= OnTreeChanged;
- actionTree = null;
- }
- }
-
- void OnTreeChanged (object s, EventArgs a)
- {
- treeChanged = true;
- NotifyChanged ();
- }
- }
-
- class CustomMenuBarItem: Gtk.MenuItem
- {
- public ActionMenuItem ActionMenuItem;
-// public ActionTreeNode Node;
- }
-
- public class ActionPaletteItem: Gtk.HBox
- {
- ActionTreeNode node;
- bool disposeNode;
-
- public ActionPaletteItem (Gtk.UIManagerItemType type, string name, Action action)
- : this (new ActionTreeNode (type, name, action))
- {
- disposeNode = true;
- }
-
- public ActionPaletteItem (ActionTreeNode node)
- {
- this.node = node;
- Spacing = 3;
- if (node.Type == Gtk.UIManagerItemType.Menu) {
- PackStart (new Gtk.Label ("Menu"), true, true, 0);
- } else if (node.Action != null && node.Action.GtkAction != null) {
- if (node.Action.GtkAction.StockId != null)
- PackStart (node.Action.CreateIcon (Gtk.IconSize.Menu), true, true, 0);
- PackStart (new Gtk.Label (node.Action.GtkAction.Label), true, true, 0);
- } else if (node.Type == Gtk.UIManagerItemType.Separator) {
- PackStart (new Gtk.Label ("Separator"), true, true, 0);
- } else {
- PackStart (new Gtk.Label ("Empty Action"), true, true, 0);
- }
- ShowAll ();
- }
-
- public ActionTreeNode Node {
- get { return node; }
- }
-
- public override void Dispose ()
- {
- if (disposeNode)
- node.Dispose ();
- base.Dispose ();
- }
-
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MenuItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MenuItem.cs
deleted file mode 100644
index 4321ce602e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MenuItem.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using System;
-using System.Xml;
-
-namespace Stetic.Wrapper {
-
- public class MenuItem : Container {
-
- public static Gtk.MenuItem CreateInstance ()
- {
- // Use the ctor that will create an AccelLabel
- return new Gtk.MenuItem ("");
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- }
-
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- menuitem.Submenu = (Gtk.Menu)wrapper.Wrapped;
- return wrapper;
- }
-
- Gtk.MenuItem menuitem {
- get {
- return (Gtk.MenuItem)Wrapped;
- }
- }
-
- Gtk.Label label {
- get {
- Gtk.AccelLabel label = menuitem.Child as Gtk.AccelLabel;
- if (label != null)
- return label;
-
- if (menuitem.Child != null)
- menuitem.Child.Destroy ();
-
- label = new Gtk.AccelLabel ("");
- label.MnemonicWidget = menuitem;
- label.AccelWidget = menuitem;
- label.Xalign = 0.0f;
- label.Show ();
- menuitem.Add (label);
-
- return label;
- }
- }
-
- public bool HasSubmenu {
- get {
- return menuitem.Submenu != null;
- }
- }
-
- string labelText;
-
- public string Label {
- get {
- return labelText;
- }
- set {
- label.LabelProp = labelText = value;
- EmitNotify ("Label");
- }
- }
-
- public bool UseUnderline {
- get {
- return label.UseUnderline;
- }
- set {
- label.UseUnderline = value;
- EmitNotify ("UseUnderline");
- }
- }
-
- Gtk.AccelGroup accelGroup;
- string accelerator;
- public string Accelerator {
- get {
- return accelerator;
- }
- set {
- uint key;
- Gdk.ModifierType mods;
-
- if (accelGroup != null && accelerator != null) {
- Gtk.Accelerator.Parse (accelerator, out key, out mods);
- menuitem.RemoveAccelerator (accelGroup, key, mods);
- }
-
- accelerator = value;
-
- if (accelerator != null) {
- if (accelGroup == null)
- accelGroup = new Gtk.AccelGroup ();
-
- Gtk.Accelerator.Parse (accelerator, out key, out mods);
- menuitem.AddAccelerator ("activate", accelGroup, key, mods,
- Gtk.AccelFlags.Visible);
- }
-
- EmitNotify ("Accelerator");
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MessageDialog.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MessageDialog.cs
deleted file mode 100644
index 805b02932c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/MessageDialog.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System;
-
-namespace Stetic {
-
- public class MessageDialog : Gtk.Dialog {
-
- public MessageDialog ()
- {
- Resizable = false;
- HasSeparator = false;
- BorderWidth = 12;
-
- label = new Gtk.Label ();
- label.LineWrap = true;
- label.Selectable = true;
- label.UseMarkup = true;
- label.SetAlignment (0.0f, 0.0f);
-
- secondaryLabel = new Gtk.Label ();
- secondaryLabel.LineWrap = true;
- secondaryLabel.Selectable = true;
- secondaryLabel.UseMarkup = true;
- secondaryLabel.SetAlignment (0.0f, 0.0f);
-
- icon = new Gtk.Image (Gtk.Stock.DialogInfo, Gtk.IconSize.Dialog);
- icon.SetAlignment (0.5f, 0.0f);
-
- Gtk.StockItem item = Gtk.Stock.Lookup (icon.Stock);
- Title = item.Label;
-
- Gtk.HBox hbox = new Gtk.HBox (false, 12);
- Gtk.VBox vbox = new Gtk.VBox (false, 12);
-
- vbox.PackStart (label, false, false, 0);
- vbox.PackStart (secondaryLabel, true, true, 0);
-
- hbox.PackStart (icon, false, false, 0);
- hbox.PackStart (vbox, true, true, 0);
-
- VBox.PackStart (hbox, false, false, 0);
- hbox.ShowAll ();
-
- Buttons = Gtk.ButtonsType.OkCancel;
- }
-
- Gtk.Label label, secondaryLabel;
- Gtk.Image icon;
-
- public Gtk.MessageType MessageType {
- get {
- if (icon.Stock == Gtk.Stock.DialogInfo)
- return Gtk.MessageType.Info;
- else if (icon.Stock == Gtk.Stock.DialogQuestion)
- return Gtk.MessageType.Question;
- else if (icon.Stock == Gtk.Stock.DialogWarning)
- return Gtk.MessageType.Warning;
- else
- return Gtk.MessageType.Error;
- }
- set {
- Gtk.StockItem item = Gtk.Stock.Lookup (icon.Stock);
- bool setTitle = (Title == "") || (Title == item.Label);
-
- if (value == Gtk.MessageType.Info)
- icon.Stock = Gtk.Stock.DialogInfo;
- else if (value == Gtk.MessageType.Question)
- icon.Stock = Gtk.Stock.DialogQuestion;
- else if (value == Gtk.MessageType.Warning)
- icon.Stock = Gtk.Stock.DialogWarning;
- else
- icon.Stock = Gtk.Stock.DialogError;
-
- if (setTitle) {
- item = Gtk.Stock.Lookup (icon.Stock);
- Title = item.Label;
- }
- }
- }
-
- public string primaryText;
- public string PrimaryText {
- get {
- return primaryText;
- }
- set {
- primaryText = value;
- label.Markup = "<b>" + value + "</b>";
- }
- }
-
- public string SecondaryText {
- get {
- return secondaryLabel.Text;
- }
- set {
- secondaryLabel.Markup = value;
- }
- }
-
- Gtk.ButtonsType buttons;
- public Gtk.ButtonsType Buttons {
- get {
- return buttons;
- }
- set {
- Gtk.Widget[] oldButtons = ActionArea.Children;
- foreach (Gtk.Widget w in oldButtons)
- ActionArea.Remove (w);
-
- buttons = value;
- switch (buttons) {
- case Gtk.ButtonsType.None:
- // nothing
- break;
-
- case Gtk.ButtonsType.Ok:
- AddButton (Gtk.Stock.Ok, Gtk.ResponseType.Ok);
- break;
-
- case Gtk.ButtonsType.Close:
- AddButton (Gtk.Stock.Close, Gtk.ResponseType.Close);
- break;
-
- case Gtk.ButtonsType.Cancel:
- AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
- break;
-
- case Gtk.ButtonsType.YesNo:
- AddButton (Gtk.Stock.No, Gtk.ResponseType.No);
- AddButton (Gtk.Stock.Yes, Gtk.ResponseType.Yes);
- break;
-
- case Gtk.ButtonsType.OkCancel:
- AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
- AddButton (Gtk.Stock.Ok, Gtk.ResponseType.Ok);
- break;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Misc.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Misc.cs
deleted file mode 100644
index 44624a73d6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Misc.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-
-using System;
-
-namespace Stetic.Wrapper
-{
- public class Misc: Widget
- {
- public bool AlignLeft {
- get {
- return ((Gtk.Misc)Wrapped).Xalign == 0;
- }
- set {
- ((Gtk.Misc)Wrapped).Xalign = 0;
- }
- }
-
- public bool AlignRight {
- get {
- return ((Gtk.Misc)Wrapped).Xalign == 1;
- }
- set {
- ((Gtk.Misc)Wrapped).Xalign = 1;
- }
- }
-
- public bool AlignCenter {
- get {
- return ((Gtk.Misc)Wrapped).Xalign == 0.5f;
- }
- set {
- ((Gtk.Misc)Wrapped).Xalign = 0.5f;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Notebook.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Notebook.cs
deleted file mode 100644
index 978aae7502..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Notebook.cs
+++ /dev/null
@@ -1,269 +0,0 @@
-using System;
-using System.CodeDom;
-using System.Collections;
-using System.Xml;
-
-namespace Stetic.Wrapper {
-
- public class Notebook : Container {
-
- ArrayList tabs = new ArrayList ();
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized && AllowPlaceholders) {
- if (notebook.Children.Length != 0) {
- // Remove the dummy page Container.Wrap added
- notebook.Remove (notebook.Children[0]);
- }
- InsertPage (0);
- }
- notebook.SwitchPage += OnPageChanged;
- }
-
- public override void Dispose ()
- {
- notebook.SwitchPage -= OnPageChanged;
- base.Dispose ();
- }
-
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- if ((string)GladeUtils.GetChildProperty (child_elem, "type", "") == "tab") {
- ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this);
- Gtk.Widget widget = (Gtk.Widget)wrapper.Wrapped;
- notebook.SetTabLabel (notebook.GetNthPage (notebook.NPages - 1), widget);
- tabs.Add (widget);
- return wrapper;
- } else
- return base.ReadChild (reader, child_elem);
- }
-
- protected override XmlElement WriteChild (ObjectWriter writer, Widget wrapper)
- {
- XmlElement child_elem = base.WriteChild (writer, wrapper);
- if (tabs.Contains (wrapper.Wrapped))
- GladeUtils.SetChildProperty (child_elem, "type", "tab");
- return child_elem;
- }
- public override void Read (ObjectReader reader, XmlElement element)
- {
- object cp = GladeUtils.ExtractProperty (element, "CurrentPage", 0);
- base.Read (reader, element);
- notebook.CurrentPage = (int) cp;
- }
-
- protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentExp, Widget wrapper)
- {
- Gtk.Widget child = (Gtk.Widget) wrapper.Wrapped;
-
- if (notebook.PageNum (child) == -1) {
- // It's a tab
-
- ctx.Statements.Add (new CodeCommentStatement ("Notebook tab"));
- Gtk.Widget page = null;
- CodeExpression pageVar;
-
- // Look for the page widget contained in this tab
- for (int n=0; n < notebook.NPages; n++) {
- if (notebook.GetTabLabel (notebook.GetNthPage (n)) == child) {
- page = notebook.GetNthPage (n);
- break;
- }
- }
-
- // If the page contains a placeholder, generate a dummy page
- if (page is Stetic.Placeholder) {
- CodeVariableDeclarationStatement dvar = new CodeVariableDeclarationStatement (
- "Gtk.Label".ToGlobalTypeRef (),
- ctx.NewId (),
- new CodeObjectCreateExpression ("Gtk.Label".ToGlobalTypeRef ())
- );
- ctx.Statements.Add (dvar);
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- new CodeVariableReferenceExpression (dvar.Name),
- "Visible"
- ),
- new CodePrimitiveExpression (true)
- )
- );
- ctx.Statements.Add (
- new CodeMethodInvokeExpression (
- parentExp,
- "Add",
- new CodeVariableReferenceExpression (dvar.Name)
- )
- );
- pageVar = new CodeVariableReferenceExpression (dvar.Name);
- } else
- pageVar = ctx.WidgetMap.GetWidgetExp (page);
-
- // Generate code for the tab
- CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
-
- // Assign the tab to the page
- CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
- parentExp,
- "SetTabLabel",
- pageVar,
- var
- );
- ctx.Statements.Add (invoke);
-
- // Workaround for GTK bug. ShowAll is not propagated to tab labels.
- invoke = new CodeMethodInvokeExpression (
- var,
- "ShowAll"
- );
- ctx.Statements.Add (invoke);
- } else
- base.GenerateChildBuildCode (ctx, parentExp, wrapper);
- }
-
-
- private Gtk.Notebook notebook {
- get {
- return (Gtk.Notebook)Wrapped;
- }
- }
-
- public override void Select (Gtk.Widget widget)
- {
- if (widget != null) {
- int index = tabs.IndexOf (widget);
- if (index != -1 && index != notebook.CurrentPage)
- notebook.CurrentPage = index;
- }
- base.Select (widget);
- }
-
- protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- int index = tabs.IndexOf (oldChild);
- if (index != -1) {
- tabs[index] = newChild;
- Gtk.Widget page = notebook.GetNthPage (index);
- notebook.SetTabLabel (page, newChild);
- } else {
- Gtk.Widget tab = notebook.GetTabLabel (oldChild);
- int current = notebook.CurrentPage;
- int oldPageNum = ((Gtk.Notebook.NotebookChild)notebook [oldChild]).Position;
- base.ReplaceChild (oldChild, newChild);
- // Get the widget again because it may have changed (for example, if it is a text view
- // and has the ShowScrollbars option set.
- newChild = notebook.GetNthPage (oldPageNum);
- notebook.CurrentPage = current;
- notebook.SetTabLabel (newChild, tab);
- Widget ww = Widget.Lookup (tab);
- if (ww != null)
- ww.RequiresUndoStatusUpdate = true;
- }
- }
-
- int InsertPage (int position)
- {
- Gtk.Label label = (Gtk.Label)Registry.NewInstance ("Gtk.Label", proj);
- label.LabelProp = "page" + (notebook.NPages + 1).ToString ();
- tabs.Insert (position, label);
-
- Placeholder ph = CreatePlaceholder ();
- int i = notebook.InsertPage (ph, label, position);
- NotifyChildAdded (ph);
- return i;
- }
-
- internal void PreviousPage ()
- {
- notebook.PrevPage ();
- }
-
- internal bool CheckPreviousPage ()
- {
- return notebook.CurrentPage > 0;
- }
-
- internal void NextPage ()
- {
- notebook.NextPage ();
- }
-
- internal bool CheckNextPage ()
- {
- return notebook.CurrentPage < notebook.NPages - 1;
- }
-
- internal void DeletePage ()
- {
- tabs.RemoveAt (notebook.CurrentPage);
- notebook.RemovePage (notebook.CurrentPage);
- }
-
- internal bool CheckDeletePage ()
- {
- return notebook.NPages > 0;
- }
-
- internal void SwapPrevious ()
- {
- object ob = tabs [notebook.CurrentPage];
- tabs [notebook.CurrentPage] = tabs [notebook.CurrentPage - 1];
- tabs [notebook.CurrentPage - 1] = ob;
-
- Gtk.Widget cp = notebook.GetNthPage (notebook.CurrentPage);
- notebook.ReorderChild (cp, notebook.CurrentPage - 1);
- }
-
- internal void SwapNext ()
- {
- object ob = tabs [notebook.CurrentPage];
- tabs [notebook.CurrentPage] = tabs [notebook.CurrentPage + 1];
- tabs [notebook.CurrentPage + 1] = ob;
-
- Gtk.Widget cp = notebook.GetNthPage (notebook.CurrentPage);
- notebook.ReorderChild (cp, notebook.CurrentPage + 1);
- }
-
- internal void InsertBefore ()
- {
- notebook.CurrentPage = InsertPage (notebook.CurrentPage);
- }
-
- internal bool CheckInsertBefore ()
- {
- return notebook.NPages > 0;
- }
-
- internal void InsertAfter ()
- {
- notebook.CurrentPage = InsertPage (notebook.CurrentPage + 1);
- }
-
- public override bool HExpandable {
- get {
- foreach (Gtk.Widget w in notebook) {
- if (ChildHExpandable (w))
- return true;
- }
- return false;
- }
- }
-
- public override bool VExpandable {
- get {
- foreach (Gtk.Widget w in notebook) {
- if (ChildVExpandable (w))
- return true;
- }
- return false;
- }
- }
-
- void OnPageChanged (object s, Gtk.SwitchPageArgs args)
- {
- EmitNotify ("CurrentPage");
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Object.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Object.cs
deleted file mode 100644
index 4d8954c426..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Object.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Stetic.Wrapper {
- public abstract class Object : Stetic.ObjectWrapper {
-
- public override void Dispose ()
- {
- if (Wrapped == null)
- return;
- ((GLib.Object)Wrapped).RemoveNotification (NotifyHandler);
- base.Dispose ();
- }
-
- internal protected override void OnDesignerAttach (IDesignArea designer)
- {
- base.OnDesignerAttach (designer);
- ((GLib.Object)Wrapped).AddNotification (NotifyHandler);
- }
-
- internal protected override void OnDesignerDetach (IDesignArea designer)
- {
- base.OnDesignerDetach (designer);
- ((GLib.Object)Wrapped).RemoveNotification (NotifyHandler);
- }
-
- public static Object Lookup (GLib.Object obj)
- {
- return Stetic.ObjectWrapper.Lookup (obj) as Stetic.Wrapper.Object;
- }
-
- void NotifyHandler (object obj, GLib.NotifyArgs args)
- {
- if (Loading)
- return;
-
- // Translate gtk names into descriptor names.
- foreach (ItemGroup group in ClassDescriptor.ItemGroups) {
- foreach (ItemDescriptor item in group) {
- TypedPropertyDescriptor prop = item as TypedPropertyDescriptor;
- if (prop != null && prop.GladeName == args.Property) {
- EmitNotify (prop.Name);
- return;
- }
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/OptionMenu.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/OptionMenu.cs
deleted file mode 100644
index 8234c595a1..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/OptionMenu.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-
-// Don't warn that OptionMenu is deprecated. We know that.
-#pragma warning disable 612
-
-namespace Stetic.Wrapper {
-
- public class OptionMenu : Container {
-
- public override void Wrap (object obj, bool initialized)
- {
- Gtk.OptionMenu omenu = (Gtk.OptionMenu)obj;
- if (omenu.Menu == null) {
- Gtk.Menu menu = new Gtk.Menu ();
- menu.Show ();
- omenu.Menu = menu;
- }
-
- base.Wrap (obj, initialized);
- }
-
- protected override void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- int history = (int)GladeUtils.ExtractProperty (elem, "history", -1);
- base.ReadProperties (reader, elem);
-
- // Fiddle with things to make the optionmenu resize itself correctly
- Gtk.Widget menu = optionmenu.Menu;
- optionmenu.Menu = new Gtk.Menu ();
- optionmenu.Menu = menu;
-
- if (history != -1)
- Active = history;
- else
- Active = 0;
- }
-
- // Some versions of glade call the menu an internal child, some don't
-
- protected override ObjectWrapper ReadInternalChild (ObjectReader reader, XmlElement child_elem)
- {
- if (child_elem.GetAttribute ("internal-child") == "menu")
- return ReadChild (reader, child_elem);
- else
- return base.ReadInternalChild (reader, child_elem);
- }
-
- protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem)
- {
- Widget wrapper = Stetic.Wrapper.Widget.Lookup (optionmenu.Menu);
- reader.ReadExistingObject (wrapper, child_elem["widget"]);
- return wrapper;
- }
-
- public override IEnumerable GladeChildren {
- get {
- return new Gtk.Widget[] { optionmenu.Menu };
- }
- }
-
- Gtk.OptionMenu optionmenu {
- get {
- return (Gtk.OptionMenu)Wrapped;
- }
- }
-
- public int Active {
- get {
- return optionmenu.History;
- }
- set {
- optionmenu.SetHistory ((uint)value);
- EmitNotify ("Active");
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Paned.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Paned.cs
deleted file mode 100644
index 477923a27c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Paned.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using System;
-
-namespace Stetic.Wrapper {
-
- public class Paned : Container {
-
- int position;
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized && AllowPlaceholders) {
- Placeholder ph = CreatePlaceholder ();
- paned.Pack1 (ph, true, false);
- NotifyChildAdded (ph);
- ph = CreatePlaceholder ();
- paned.Pack2 (ph, true, false);
- NotifyChildAdded (ph);
- }
- position = paned.Position;
- paned.Realized += PanedRealized;
- }
-
- void PanedRealized (object sender, EventArgs e)
- {
- // The position may be reset while realizing the object, so
- // we set it now here. See bug #542227. This seems to be Windows only.
- bool old = Loading;
- Loading = true;
- paned.Position = position;
- Loading = old;
- }
-
- public override void Dispose ()
- {
- base.Dispose ();
- paned.Realized -= PanedRealized;
- }
-
- protected Gtk.Paned paned {
- get {
- return (Gtk.Paned)Wrapped;
- }
- }
-
- public int Position {
- get {
- return paned.Position;
- }
- set {
- position = value;
- paned.Position = value;
- }
- }
-
- protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- if (oldChild == paned.Child1) {
- paned.Remove (oldChild);
- paned.Add1 (newChild);
- } else if (oldChild == paned.Child2) {
- paned.Remove (oldChild);
- paned.Add2 (newChild);
- }
- NotifyChildAdded (newChild);
- }
-
- public override void Delete (Stetic.Placeholder ph)
- {
- // Don't allow deleting placeholders
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioActionGroupManager.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioActionGroupManager.cs
deleted file mode 100644
index 0f67944ce4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioActionGroupManager.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-
-using System;
-using System.Collections;
-using System.CodeDom;
-
-namespace Stetic.Wrapper
-{
- public class RadioActionGroupManager: IRadioGroupManager
- {
- public event GroupsChangedDelegate GroupsChanged;
- Hashtable actions = new Hashtable ();
- ArrayList groups = new ArrayList ();
-
- public IEnumerable GroupNames {
- get {
- foreach (string grp in groups)
- yield return grp;
- }
- }
-
- public void Rename (string oldName, string newName)
- {
- int i = groups.IndexOf (oldName);
- if (i == -1)
- return;
-
- groups [i] = newName;
-
- ArrayList list = new ArrayList ();
- foreach (Action a in FindActionsInGroup (oldName))
- list.Add (a);
-
- foreach (Action a in list)
- actions [a] = newName;
-
- EmitGroupsChanged ();
- }
-
- public void Add (string name)
- {
- groups.Add (name);
- EmitGroupsChanged ();
- }
-
- public RadioGroup FindGroup (string name)
- {
- for (int i = 0; i < groups.Count; i++) {
- RadioGroup group = groups[i] as RadioGroup;
- if (group.Name == name)
- return group;
- }
- return null;
- }
-
- public string GetGroup (Action action)
- {
- return actions [action] as string;
- }
-
- public void SetGroup (Action action, string group)
- {
- if (group == null) {
- if (actions.Contains (action)) {
- actions.Remove (action);
- action.Disposed -= OnActionDisposed;
- }
- return;
- }
-
- if (!actions.Contains (action))
- action.Disposed += OnActionDisposed;
- actions [action] = group;
- if (!groups.Contains (group))
- groups.Add (group);
- }
-
- void OnActionDisposed (object s, EventArgs a)
- {
- Action ac = (Action) s;
- if (ac != null) {
- ac.Disposed -= OnActionDisposed;
- actions.Remove (ac);
- }
- }
-
- public string LastGroup {
- get {
- if (groups.Count == 0)
- Add ("group1");
- return groups [groups.Count - 1] as string;
- }
- }
-
- void EmitGroupsChanged ()
- {
- if (GroupsChanged != null)
- GroupsChanged ();
- }
-
- IEnumerable FindActionsInGroup (string grp)
- {
- foreach (DictionaryEntry e in actions)
- if (((string)e.Value) == grp)
- yield return e.Key;
- }
-
- public CodeExpression GenerateGroupExpression (GeneratorContext ctx, Action action)
- {
- // Returns and expression that represents the group to which the radio belongs.
- // This expression can be an empty SList, if this is the first radio of the
- // group that has been generated, or an SList taken from previously generated
- // radios from the same group.
-
- string group = actions [action] as string;
- if (group == null)
- return new CodePrimitiveExpression (null);
-
- CodeExpression var = null;
-
- foreach (Action a in FindActionsInGroup (group)) {
- if (a == action)
- continue;
- var = ctx.WidgetMap.GetWidgetExp (a);
- if (var != null)
- break;
- }
-
- if (var == null) {
- return new CodeObjectCreateExpression (
- "GLib.SList".ToGlobalTypeRef (),
- new CodePropertyReferenceExpression (
- new CodeTypeReferenceExpression (typeof(IntPtr).ToGlobalTypeRef ()),
- "Zero"
- )
- );
- } else {
- return new CodePropertyReferenceExpression (
- var,
- "Group"
- );
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioButton.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioButton.cs
deleted file mode 100644
index a58d70f31c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioButton.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class RadioButton : CheckButton, IRadioGroupManagerProvider {
-
- static RadioGroupManager GroupManager = new RadioGroupManager (typeof (Gtk.RadioButton));
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
-
- Gtk.RadioButton radiobutton = (Gtk.RadioButton)Wrapped;
- if (!initialized)
- Group = GroupManager.LastGroup;
- else if (radiobutton.Group == null)
- Group = radiobutton.Name;
- }
-
- IRadioGroupManager IRadioGroupManagerProvider.GetGroupManager ()
- {
- return GroupManager;
- }
-
- protected override void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- bool active = (bool)GladeUtils.ExtractProperty (elem, "active", false);
- string group = (string)GladeUtils.ExtractProperty (elem, "group", "");
- base.ReadProperties (reader, elem);
-
- if (reader.Format == FileFormat.Glade) {
- if (group != "")
- Group = group;
- else
- Group = Wrapped.Name;
- }
-
- if (active)
- ((Gtk.RadioButton)Wrapped).Active = true;
- }
-
- protected override XmlElement WriteProperties (ObjectWriter writer)
- {
- XmlElement elem = base.WriteProperties (writer);
- if (writer.Format == FileFormat.Glade) {
- string group = GroupManager.GladeGroupName (Wrapped);
- if (group != Wrapped.Name)
- GladeUtils.SetProperty (elem, "group", group);
- }
- return elem;
- }
-
- protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- if (prop.Name == "Group") {
- CodeExpression groupExp = GroupManager.GenerateGroupExpression (ctx, (Gtk.Widget) Wrapped);
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "Group"),
- groupExp)
- );
- }
- else
- base.GeneratePropertySet (ctx, var, prop);
- }
-
- public string Group {
- get {
- return GroupManager[Wrapped];
- }
- set {
- GroupManager[Wrapped] = value;
- EmitNotify ("Group");
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioMenuItem.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioMenuItem.cs
deleted file mode 100644
index d8a232584b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioMenuItem.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class RadioMenuItem : MenuItem, IRadioGroupManagerProvider {
-
- static RadioGroupManager GroupManager = new RadioGroupManager (typeof (Gtk.RadioMenuItem));
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
-
- Gtk.RadioMenuItem radio = (Gtk.RadioMenuItem)Wrapped;
- if (!initialized)
- Group = GroupManager.LastGroup;
- else if (radio.Group == null)
- Group = radio.Name;
- }
-
- IRadioGroupManager IRadioGroupManagerProvider.GetGroupManager ()
- {
- return GroupManager;
- }
-
- protected override void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- string group = (string)GladeUtils.ExtractProperty (elem, "group", "");
- bool active = (bool)GladeUtils.ExtractProperty (elem, "active", false);
- base.ReadProperties (reader, elem);
-
- if (group != "")
- Group = group;
- else
- Group = Wrapped.Name;
- if (active)
- ((Gtk.RadioMenuItem)Wrapped).Active = true;
- }
-
- protected override XmlElement WriteProperties (ObjectWriter writer)
- {
- XmlElement elem = base.WriteProperties (writer);
- string group = GroupManager.GladeGroupName (Wrapped);
- if (group != Wrapped.Name)
- GladeUtils.SetProperty (elem, "group", group);
- return elem;
- }
-
- protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- if (prop.Name == "Group") {
- CodeExpression groupExp = GroupManager.GenerateGroupExpression (ctx, (Gtk.Widget) Wrapped);
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "Group"),
- groupExp)
- );
- }
- else
- base.GeneratePropertySet (ctx, var, prop);
- }
-
- public string Group {
- get {
- return GroupManager[Wrapped];
- }
- set {
- GroupManager[Wrapped] = value;
- EmitNotify ("Group");
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioToolButton.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioToolButton.cs
deleted file mode 100644
index 986d2476cc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/RadioToolButton.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class RadioToolButton : ToggleToolButton, IRadioGroupManagerProvider {
-
- public static new Gtk.ToolButton CreateInstance ()
- {
- return new Gtk.RadioToolButton (new GLib.SList (IntPtr.Zero), Gtk.Stock.SortAscending);
- }
-
- static RadioGroupManager GroupManager = new RadioGroupManager (typeof (Gtk.RadioToolButton));
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
-
- Gtk.RadioToolButton radio = (Gtk.RadioToolButton)Wrapped;
- if (!initialized)
- Group = GroupManager.LastGroup;
- else if (radio.Group == null)
- Group = radio.Name;
- }
-
- IRadioGroupManager IRadioGroupManagerProvider.GetGroupManager ()
- {
- return GroupManager;
- }
-
- protected override void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- string group = (string)GladeUtils.ExtractProperty (elem, "group", "");
- bool active = (bool)GladeUtils.ExtractProperty (elem, "active", false);
- base.ReadProperties (reader, elem);
-
- if (group != "")
- Group = group;
- else
- Group = Wrapped.Name;
- if (active)
- ((Gtk.RadioToolButton)Wrapped).Active = true;
- }
-
- protected override XmlElement WriteProperties (ObjectWriter writer)
- {
- XmlElement elem = base.WriteProperties (writer);
- string group = GroupManager.GladeGroupName (Wrapped);
- if (group != Wrapped.Name)
- GladeUtils.SetProperty (elem, "group", group);
- return elem;
- }
-
- protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- if (prop.Name == "Group") {
- CodeExpression groupExp = GroupManager.GenerateGroupExpression (ctx, (Gtk.Widget) Wrapped);
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (var, "Group"),
- groupExp)
- );
- }
- else
- base.GeneratePropertySet (ctx, var, prop);
- }
-
- public string Group {
- get {
- return GroupManager[Wrapped];
- }
- set {
- GroupManager[Wrapped] = value;
- EmitNotify ("Group");
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Range.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Range.cs
deleted file mode 100644
index 453e846004..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Range.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-
-namespace Stetic.Wrapper {
-
- public abstract class Range : Widget {
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- ((Gtk.Range)Wrapped).Adjustment.AddNotification (AdjustmentNotifyHandler);
- }
-
- public override void Dispose ()
- {
- ((Gtk.Range)Wrapped).Adjustment.RemoveNotification (AdjustmentNotifyHandler);
- base.Dispose ();
- }
-
- void AdjustmentNotifyHandler (object obj, GLib.NotifyArgs args)
- {
- EmitNotify (args.Property);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Scale.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Scale.cs
deleted file mode 100644
index c43f6609bd..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Scale.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-
-namespace Stetic.Wrapper {
-
- public abstract class Scale : Widget {
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- ((Gtk.Scale)Wrapped).Adjustment.AddNotification (AdjustmentNotifyHandler);
- }
-
- public override void Dispose ()
- {
- ((Gtk.Scale)Wrapped).Adjustment.RemoveNotification (AdjustmentNotifyHandler);
- base.Dispose ();
- }
-
- void AdjustmentNotifyHandler (object obj, GLib.NotifyArgs args)
- {
- EmitNotify (args.Property);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ScrolledWindow.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ScrolledWindow.cs
deleted file mode 100644
index e574d6a726..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ScrolledWindow.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using System;
-using System.Collections;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class ScrolledWindow : Container {
-
- Gtk.PolicyType hpolicy = Gtk.PolicyType.Automatic;
- Gtk.PolicyType vpolicy = Gtk.PolicyType.Automatic;
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized) {
- if (scrolled.Child == null && AllowPlaceholders)
- AddPlaceholder ();
- HscrollbarPolicy = VscrollbarPolicy = Gtk.PolicyType.Automatic;
- scrolled.ShadowType = Gtk.ShadowType.In;
- }
- scrolled.SetPolicy (Gtk.PolicyType.Always, Gtk.PolicyType.Always);
- }
-
- public Gtk.ScrolledWindow scrolled {
- get {
- return (Gtk.ScrolledWindow)Wrapped;
- }
- }
-
- public Gtk.PolicyType HscrollbarPolicy {
- get { return hpolicy; }
- set {
- hpolicy = value;
- EmitNotify ("HscrollbarPolicy");
- }
- }
-
- public Gtk.PolicyType VscrollbarPolicy {
- get { return vpolicy; }
- set {
- vpolicy = value;
- EmitNotify ("VscrollbarPolicy");
- }
- }
-
- public override IEnumerable RealChildren {
- get {
- if (scrolled.Child is Gtk.Viewport)
- return ((Gtk.Viewport)scrolled.Child).Children;
- else
- return base.RealChildren;
- }
- }
-
- internal void AddWithViewport (Gtk.Widget child)
- {
- Gtk.Viewport viewport = new Gtk.Viewport (scrolled.Hadjustment, scrolled.Vadjustment);
- ObjectWrapper.Create (proj, viewport, this);
- viewport.ShadowType = Gtk.ShadowType.None;
- viewport.Add (child);
- viewport.Show ();
- scrolled.Add (viewport);
- }
-
- protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- Widget ww = Widget.Lookup (oldChild);
- if (ww != null && ww.ShowScrollbars && ParentWrapper != null) {
- // The viewport is bound to the child widget. Remove it together with the child
- ParentWrapper.ReplaceChild (Wrapped, newChild, false);
- return;
- }
-
- if (scrolled.Child is Gtk.Viewport && oldChild != scrolled.Child) {
- Gtk.Viewport vp = (Gtk.Viewport)scrolled.Child;
- vp.Remove (oldChild);
- scrolled.Remove (vp);
- vp.Destroy ();
- }
- else
- scrolled.Remove (scrolled.Child);
-
- if (newChild.SetScrollAdjustments (null, null))
- scrolled.Add (newChild);
- else
- AddWithViewport (newChild);
-
- NotifyChildAdded (scrolled.Child);
- }
-
- public override Placeholder AddPlaceholder ()
- {
- Placeholder ph = CreatePlaceholder ();
- AddWithViewport (ph);
- return ph;
- }
-
- protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
- {
- Gtk.Viewport vp = wrapper.Wrapped as Gtk.Viewport;
- if (vp == null || (vp.Child != null && !(vp.Child is Placeholder)))
- base.GenerateChildBuildCode (ctx, parentVar, wrapper);
- }
-
- public override void Delete (Stetic.Placeholder ph)
- {
- using (UndoManager.AtomicChange) {
- Delete ();
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Signal.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Signal.cs
deleted file mode 100644
index 3c1700e805..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Signal.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- [Serializable]
- public class Signal
- {
- SignalDescriptor descriptor;
- string handlerName;
- bool after;
-
- [NonSerialized]
- internal ObjectWrapper Owner;
-
- public Signal (SignalDescriptor descriptor): this (descriptor, null, false)
- {
- }
-
- public Signal (SignalDescriptor descriptor, string handlerName, bool after)
- {
- this.descriptor = descriptor;
- this.handlerName = handlerName;
- this.after = after;
- }
-
- void NotifyChanged (Signal oldData)
- {
- if (Owner != null)
- Owner.OnSignalChanged (new SignalChangedEventArgs (Owner, oldData, this));
- }
-
- Signal Clone ()
- {
- return new Signal (descriptor, handlerName, after);
- }
-
- public SignalDescriptor SignalDescriptor {
- get { return descriptor; }
- }
-
- public string Handler {
- get { return handlerName; }
- set {
- Signal data = Clone ();
- handlerName = value;
- NotifyChanged (data);
- }
- }
-
- public bool After {
- get { return after; }
- set {
- Signal data = Clone ();
- after = value;
- NotifyChanged (data);
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalChangedEventHandler.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalChangedEventHandler.cs
deleted file mode 100644
index 1c2d138260..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalChangedEventHandler.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-
-namespace Stetic
-{
- public delegate void SignalChangedEventHandler (object sender, SignalChangedEventArgs args);
-
- public class SignalChangedEventArgs: SignalEventArgs
- {
- Signal oldSignal;
-
- public SignalChangedEventArgs (ObjectWrapper wrapper, Signal oldSignal, Signal signal): base (wrapper, signal)
- {
- this.oldSignal = oldSignal;
- }
-
- public Signal OldSignal {
- get { return oldSignal; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalCollection.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalCollection.cs
deleted file mode 100644
index c8b04ab33c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalCollection.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Stetic
-{
- [Serializable]
- public class SignalCollection: CollectionBase
- {
- [NonSerialized]
- ObjectWrapper owner;
-
- [NonSerialized]
- Signal[] clearedData;
-
- public SignalCollection ()
- {
- }
-
- internal SignalCollection (ObjectWrapper owner)
- {
- this.owner = owner;
- }
-
- public int Add (Signal signal)
- {
- return List.Add (signal);
- }
-
- public Signal this [int n] {
- get { return (Signal) List [n]; }
- }
-
- public void Remove (Signal signal)
- {
- List.Remove (signal);
- }
-
- public void CopyTo (Signal[] signals, int index)
- {
- List.CopyTo (signals, index);
- }
-
- protected override void OnClear ()
- {
- if (owner != null) {
- clearedData = new Signal [Count];
- List.CopyTo (clearedData, 0);
- }
- }
-
- protected override void OnClearComplete ()
- {
- if (owner != null) {
- Signal[] data = clearedData;
- clearedData = null;
- foreach (Signal s in data) {
- s.Owner = null;
- owner.OnSignalRemoved (new SignalEventArgs (owner, s));
- }
- }
- }
-
- protected override void OnInsertComplete (int index, object value)
- {
- if (owner != null) {
- ((Signal)value).Owner = owner;
- owner.OnSignalAdded (new SignalEventArgs (owner, (Signal) value));
- }
- }
-
- protected override void OnRemoveComplete (int index, object value)
- {
- if (owner != null) {
- ((Signal)value).Owner = null;
- owner.OnSignalRemoved (new SignalEventArgs (owner, (Signal) value));
- }
- }
-
- protected override void OnSetComplete (int index, object oldValue, object newValue)
- {
- if (owner != null) {
- ((Signal)oldValue).Owner = null;
- owner.OnSignalRemoved (new SignalEventArgs (owner, (Signal) oldValue));
- ((Signal)newValue).Owner = owner;
- owner.OnSignalAdded (new SignalEventArgs (owner, (Signal) newValue));
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalEventHandler.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalEventHandler.cs
deleted file mode 100644
index da56c35156..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SignalEventHandler.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-
-namespace Stetic
-{
- public delegate void SignalEventHandler (object sender, SignalEventArgs args);
-
- public class SignalEventArgs: ObjectWrapperEventArgs
- {
- Signal signal;
-
- public SignalEventArgs (ObjectWrapper wrapper, Signal signal): base (wrapper)
- {
- this.signal = signal;
- }
-
- public Signal Signal {
- get { return signal; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SpinButton.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SpinButton.cs
deleted file mode 100644
index fa9e200f7b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/SpinButton.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-
-namespace Stetic.Wrapper {
-
- public class SpinButton : Widget {
-
- public static Gtk.SpinButton CreateInstance ()
- {
- return new Gtk.SpinButton (0.0, 100.0, 1.0);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Table.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Table.cs
deleted file mode 100644
index f765aa847d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Table.cs
+++ /dev/null
@@ -1,520 +0,0 @@
-using System;
-using System.Collections;
-using System.Text.RegularExpressions;
-using System.Xml;
-
-namespace Stetic.Wrapper {
-
- public class Table : Container {
-
- const Gtk.AttachOptions expandOpts = Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill;
- const Gtk.AttachOptions fillOpts = Gtk.AttachOptions.Fill;
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized) {
- table.NRows = 3;
- table.NColumns = 3;
- table.RowSpacing = 6;
- table.ColumnSpacing = 6;
- }
- DoSync ();
- }
-
- private Gtk.Table table {
- get {
- return (Gtk.Table)Wrapped;
- }
- }
-
- public override void Delete (Stetic.Placeholder ph)
- {
- // Placeholders are deleted using commands.
- }
-
- protected override void DoSync ()
- {
- if (!AllowPlaceholders)
- return;
- using (UndoManager.AtomicChange) {
- uint left, right, top, bottom;
- uint row, col;
- Gtk.Widget w;
- Gtk.Widget[,] grid;
- Gtk.Table.TableChild tc;
- Gtk.Widget[] children;
- bool addedPlaceholders = false;
-
- children = table.Children;
- grid = new Gtk.Widget[NRows,NColumns];
-
- // First fill in the placeholders in the grid. If we find any
- // placeholders covering more than one grid square, remove them.
- // (New ones will be created below.)
- foreach (Gtk.Widget child in children) {
- if (!(child is Placeholder))
- continue;
-
- tc = table[child] as Gtk.Table.TableChild;
- left = tc.LeftAttach;
- right = tc.RightAttach;
- top = tc.TopAttach;
- bottom = tc.BottomAttach;
-
- if (right == left + 1 && bottom == top + 1)
- grid[top,left] = child;
- else {
- table.Remove (child);
- child.Destroy ();
- }
- }
-
- // Now fill in the real widgets, knocking out any placeholders
- // they overlap. (If there are real widgets that overlap
- // placeholders, neither will be knocked out, and the layout
- // will probably end up wrong as well. But this situation
- // happens at least temporarily during glade import.)
- foreach (Gtk.Widget child in children) {
- if (child is Placeholder)
- continue;
-
- tc = table[child] as Gtk.Table.TableChild;
- left = tc.LeftAttach;
- right = tc.RightAttach;
- top = tc.TopAttach;
- bottom = tc.BottomAttach;
-
- for (row = top; row < bottom; row++) {
- for (col = left; col < right; col++) {
- w = grid[row,col];
- if (w is Placeholder) {
- table.Remove (w);
- w.Destroy ();
- }
- grid[row,col] = child;
- }
- }
- }
-
- // Scan each row; if there are any empty cells, fill them in
- // with placeholders. If a row contains only placeholders, then
- // set them all to expand vertically so the row won't collapse.
- // OTOH, if the row contains any real widget, set any placeholders
- // in that row to not expand vertically, so they don't force the
- // real widgets to expand further than they should. If any row
- // is vertically expandable, then the table as a whole is.
- vexpandable = false;
- for (row = 0; row < NRows; row++) {
- bool allPlaceholders = true;
-
- for (col = 0; col < NColumns; col++) {
- w = grid[row,col];
- if (w == null) {
- w = CreatePlaceholder ();
- table.Attach (w, col, col + 1, row, row + 1);
- NotifyChildAdded (w);
- grid[row,col] = w;
- addedPlaceholders = true;
- } else if (!ChildVExpandable (w) || !AutoSize[w])
- allPlaceholders = false;
- }
-
- for (col = 0; col < NColumns; col++) {
- w = grid[row,col];
- if (!AutoSize[w])
- continue;
- tc = table[w] as Gtk.Table.TableChild;
- // We can't play with the vertical expansion property of
- // widgets which span more than one row
- if (tc.BottomAttach != tc.TopAttach + 1)
- continue;
- Gtk.AttachOptions opts = allPlaceholders ? expandOpts : fillOpts;
- if (tc.YOptions != opts)
- tc.YOptions = opts;
- }
-
- if (allPlaceholders)
- vexpandable = true;
- }
-
- // Now do the same for columns and horizontal expansion (but we
- // don't have to worry about empty cells this time).
- hexpandable = false;
- for (col = 0; col < NColumns; col++) {
- bool allPlaceholders = true;
-
- for (row = 0; row < NRows; row++) {
- w = grid[row,col];
- if (!ChildHExpandable (w) || !AutoSize[w]) {
- allPlaceholders = false;
- break;
- }
- }
-
- for (row = 0; row < NRows; row++) {
- w = grid[row,col];
- if (!AutoSize[w])
- continue;
- tc = table[w] as Gtk.Table.TableChild;
- // We can't play with the horizontal expansion property of
- // widgets which span more than one column
- if (tc.RightAttach != tc.LeftAttach + 1)
- continue;
- Gtk.AttachOptions opts = allPlaceholders ? expandOpts : fillOpts;
- if (tc.XOptions != opts)
- tc.XOptions = opts;
- }
-
- if (allPlaceholders)
- hexpandable = true;
- }
-
- if (addedPlaceholders)
- EmitContentsChanged ();
- }
- }
-
- public override Placeholder AddPlaceholder ()
- {
- // Placeholders are added by Sync ()
- return null;
- }
-
- public uint NRows {
- get {
- return table.NRows;
- }
- set {
- using (UndoManager.AtomicChange) {
- Freeze ();
- while (value < table.NRows)
- DeleteRow (table.NRows - 1);
- table.NRows = value;
- Thaw ();
- }
- }
- }
-
- public uint NColumns {
- get {
- return table.NColumns;
- }
- set {
- using (UndoManager.AtomicChange) {
- Freeze ();
- while (value < table.NColumns)
- DeleteColumn (table.NColumns - 1);
- table.NColumns = value;
- Thaw ();
- }
- }
- }
-
- void AddRow (uint row)
- {
- using (UndoManager.AtomicChange) {
- Freeze ();
- table.NRows++;
- foreach (Gtk.Widget w in table.Children) {
- Gtk.Table.TableChild tc = table[w] as Gtk.Table.TableChild;
-
- if (tc.BottomAttach > row)
- tc.BottomAttach++;
- if (tc.TopAttach >= row)
- tc.TopAttach++;
- }
- Thaw ();
- }
- }
-
- void DeleteRow (uint row)
- {
- Gtk.Widget[] children = table.Children;
- Gtk.Table.TableChild tc;
-
- using (UndoManager.AtomicChange) {
- Freeze ();
- foreach (Gtk.Widget child in children) {
- tc = table[child] as Gtk.Table.TableChild;
-
- if (tc.TopAttach == row) {
- if (tc.BottomAttach == tc.TopAttach + 1) {
- table.Remove (child);
- child.Destroy ();
- }
- else
- tc.BottomAttach--;
- } else {
- if (tc.TopAttach > row)
- tc.TopAttach--;
- if (tc.BottomAttach > row)
- tc.BottomAttach--;
- }
- }
- table.NRows--;
- Thaw ();
- }
- }
-
- void AddColumn (uint col)
- {
- using (UndoManager.AtomicChange) {
- Freeze ();
- table.NColumns++;
- foreach (Gtk.Widget w in table.Children) {
- Gtk.Table.TableChild tc = table[w] as Gtk.Table.TableChild;
-
- if (tc.RightAttach > col)
- tc.RightAttach++;
- if (tc.LeftAttach >= col)
- tc.LeftAttach++;
- }
- Thaw ();
- }
- }
-
- void DeleteColumn (uint col)
- {
- using (UndoManager.AtomicChange) {
- Gtk.Widget[] children = table.Children;
- Gtk.Table.TableChild tc;
-
- Freeze ();
- foreach (Gtk.Widget child in children) {
- tc = table[child] as Gtk.Table.TableChild;
-
- if (tc.LeftAttach == col) {
- if (tc.RightAttach == tc.LeftAttach + 1) {
- table.Remove (child);
- child.Destroy ();
- }
- else
- tc.RightAttach--;
- } else {
- if (tc.LeftAttach > col)
- tc.LeftAttach--;
- if (tc.RightAttach > col)
- tc.RightAttach--;
- }
- }
- table.NColumns--;
- Thaw ();
- }
- }
-
- public override IEnumerable GladeChildren {
- get {
- ArrayList list = new ArrayList ();
- foreach (object ob in base.GladeChildren)
- list.Add (ob);
- list.Sort (new NameComparer ());
- return list;
- }
- }
-
- class NameComparer: IComparer
- {
- public int Compare (object x, object y)
- {
- return string.Compare (((Gtk.Widget)x).Name, ((Gtk.Widget)y).Name);
- }
- }
-
- internal void InsertRowBefore (Gtk.Widget context)
- {
- Gtk.Table.TableChild tc = table[context] as Gtk.Table.TableChild;
- AddRow (tc.TopAttach);
- }
-
- internal void InsertRowAfter (Gtk.Widget context)
- {
- Gtk.Table.TableChild tc = table[context] as Gtk.Table.TableChild;
- AddRow (tc.BottomAttach);
- }
-
- internal void InsertColumnBefore (Gtk.Widget context)
- {
- Gtk.Table.TableChild tc = table[context] as Gtk.Table.TableChild;
- AddColumn (tc.LeftAttach);
- }
-
- internal void InsertColumnAfter (Gtk.Widget context)
- {
- Gtk.Table.TableChild tc = table[context] as Gtk.Table.TableChild;
- AddColumn (tc.RightAttach);
- }
-
- internal void DeleteRow (Gtk.Widget context)
- {
- Gtk.Table.TableChild tc = table[context] as Gtk.Table.TableChild;
- DeleteRow (tc.TopAttach);
- }
-
- internal void DeleteColumn (Gtk.Widget context)
- {
- Gtk.Table.TableChild tc = table[context] as Gtk.Table.TableChild;
- DeleteColumn (tc.LeftAttach);
- }
-
- private bool hexpandable, vexpandable;
- public override bool HExpandable { get { return hexpandable; } }
- public override bool VExpandable { get { return vexpandable; } }
-
- protected override void ChildContentsChanged (Container child)
- {
- using (UndoManager.AtomicChange) {
- Gtk.Widget widget = child.Wrapped;
- Freeze ();
- if (AutoSize[widget]) {
- Gtk.Table.TableChild tc = table[widget] as Gtk.Table.TableChild;
- tc.XOptions = 0;
- tc.YOptions = 0;
- }
- Thaw ();
- }
-
- base.ChildContentsChanged (child);
- }
-
- public class TableChild : Container.ContainerChild {
-
- bool freeze;
-
- Gtk.Table.TableChild tc {
- get {
- return (Gtk.Table.TableChild)Wrapped;
- }
- }
-
- public bool XExpand {
- get {
- return (tc.XOptions & Gtk.AttachOptions.Expand) != 0;
- }
- set {
- freeze = true;
- if (value)
- tc.XOptions |= Gtk.AttachOptions.Expand;
- else
- tc.XOptions &= ~Gtk.AttachOptions.Expand;
- freeze = false;
- EmitNotify ("XExpand");
- }
- }
-
- public bool XFill {
- get {
- return (tc.XOptions & Gtk.AttachOptions.Fill) != 0;
- }
- set {
- freeze = true;
- if (value)
- tc.XOptions |= Gtk.AttachOptions.Fill;
- else
- tc.XOptions &= ~Gtk.AttachOptions.Fill;
- freeze = false;
- EmitNotify ("XFill");
- }
- }
-
- public bool XShrink {
- get {
- return (tc.XOptions & Gtk.AttachOptions.Shrink) != 0;
- }
- set {
- freeze = true;
- if (value)
- tc.XOptions |= Gtk.AttachOptions.Shrink;
- else
- tc.XOptions &= ~Gtk.AttachOptions.Shrink;
- freeze = false;
- EmitNotify ("XShrink");
- }
- }
-
- public bool YExpand {
- get {
- return (tc.YOptions & Gtk.AttachOptions.Expand) != 0;
- }
- set {
- freeze = true;
- if (value)
- tc.YOptions |= Gtk.AttachOptions.Expand;
- else
- tc.YOptions &= ~Gtk.AttachOptions.Expand;
- freeze = false;
- EmitNotify ("YExpand");
- }
- }
-
- public bool YFill {
- get {
- return (tc.YOptions & Gtk.AttachOptions.Fill) != 0;
- }
- set {
- freeze = true;
- if (value)
- tc.YOptions |= Gtk.AttachOptions.Fill;
- else
- tc.YOptions &= ~Gtk.AttachOptions.Fill;
- freeze = false;
- EmitNotify ("YFill");
- }
- }
-
- public bool YShrink {
- get {
- return (tc.YOptions & Gtk.AttachOptions.Shrink) != 0;
- }
- set {
- freeze = true;
- if (value)
- tc.YOptions |= Gtk.AttachOptions.Shrink;
- else
- tc.YOptions &= ~Gtk.AttachOptions.Shrink;
- freeze = false;
- EmitNotify ("YShrink");
- }
- }
-
- protected override void EmitNotify (string propertyName)
- {
- if (freeze || Loading) return;
-
- if (propertyName == "x-options" || propertyName == "AutoSize") {
- base.EmitNotify ("XExpand");
- base.EmitNotify ("XFill");
- base.EmitNotify ("XShrink");
- }
- if (propertyName == "y-options" || propertyName == "AutoSize") {
- base.EmitNotify ("YExpand");
- base.EmitNotify ("YFill");
- base.EmitNotify ("YShrink");
- }
- base.EmitNotify (propertyName);
- }
-
- // Properties to be used by the wrapper commands
-
- public bool CellXExpand {
- get { return XExpand; }
- set { AutoSize = false; XExpand = value; }
- }
-
- public bool CellXFill{
- get { return XFill; }
- set { AutoSize = false; XFill = value; }
- }
-
- public bool CellYExpand {
- get { return YExpand; }
- set { AutoSize = false; YExpand = value; }
- }
-
- public bool CellYFill{
- get { return YFill; }
- set { AutoSize = false; YFill = value; }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/TextView.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/TextView.cs
deleted file mode 100644
index 1fbc09e0b6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/TextView.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.CodeDom;
-using System.Collections;
-
-namespace Stetic.Wrapper {
-
- public class TextView : Container {
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- ((Gtk.TextView)Wrapped).Buffer.Changed += Buffer_Changed;
- if (!initialized)
- ShowScrollbars = true;
- }
-
- public override void Dispose ()
- {
- ((Gtk.TextView)Wrapped).Buffer.Changed -= Buffer_Changed;
- base.Dispose ();
- }
-
- public string Text {
- get {
- return ((Gtk.TextView)Wrapped).Buffer.Text;
- }
- set {
- ((Gtk.TextView)Wrapped).Buffer.Text = value;
- }
- }
-
- public void Buffer_Changed (object obj, EventArgs args)
- {
- EmitNotify ("Text");
- }
-
- protected override bool AllowPlaceholders {
- get {
- return false;
- }
- }
-
- internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- if (Text.Length > 0) {
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- new CodePropertyReferenceExpression (
- var,
- "Buffer"
- ),
- "Text"
- ),
- new CodePrimitiveExpression (Text)
- )
- );
- }
- base.GenerateBuildCode (ctx, var);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ToggleToolButton.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ToggleToolButton.cs
deleted file mode 100644
index a8a0654f1f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ToggleToolButton.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-
-namespace Stetic.Wrapper {
-
- public class ToggleToolButton : ToolButton {
-
- public static new Gtk.ToolButton CreateInstance ()
- {
- return new Gtk.ToggleToolButton (Gtk.Stock.Bold);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ToolButton.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ToolButton.cs
deleted file mode 100644
index 76bb51faf7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/ToolButton.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-using System;
-using System.CodeDom;
-using System.Xml;
-
-namespace Stetic.Wrapper {
-
- public class ToolButton : Widget {
-
- ButtonType type;
- string stockId;
- string label;
- ImageInfo imageInfo;
-
- public enum ButtonType {
- StockItem,
- TextAndIcon
- };
-
- public static Gtk.ToolButton CreateInstance ()
- {
- return new Gtk.ToolButton (Gtk.Stock.New);
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- Gtk.ToolButton toolbutton = (Gtk.ToolButton)Wrapped;
-
- if (toolbutton.StockId != null) {
- stockId = toolbutton.StockId;
- type = ButtonType.StockItem;
- } else {
- type = ButtonType.TextAndIcon;
- }
- }
-
- protected override void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- if (reader.Format == FileFormat.Glade) {
- string icon = (string)GladeUtils.ExtractProperty (elem, "icon", "");
- stockId = (string)GladeUtils.ExtractProperty (elem, "stock_id", "");
- label = (string)GladeUtils.ExtractProperty (elem, "label", "");
- base.ReadProperties (reader, elem);
-
- if (stockId != null && stockId.Length > 0) {
- Type = ButtonType.StockItem;
- } else if (icon != null && icon != "") {
- imageInfo = ImageInfo.FromFile (icon);
- Type = ButtonType.TextAndIcon;
- }
- } else
- base.ReadProperties (reader, elem);
- }
-
- protected override XmlElement WriteProperties (ObjectWriter writer)
- {
- XmlElement elem = base.WriteProperties (writer);
- if (type != ButtonType.StockItem && imageInfo != null) {
- if (writer.Format == FileFormat.Glade) {
- switch (imageInfo.Source) {
- case ImageSource.File:
- GladeUtils.SetProperty (elem, "icon", imageInfo.Name);
- break;
- case ImageSource.Theme:
- GladeUtils.SetProperty (elem, "stock_id", imageInfo.Name);
- break;
- default:
- throw new System.NotSupportedException ("Image source not supported by Glade.");
- }
- }
- }
- return elem;
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- return new CodeObjectCreateExpression (
- ClassDescriptor.WrappedTypeName.ToGlobalTypeRef (),
- new CodePrimitiveExpression (null),
- new CodePrimitiveExpression (null)
- );
- }
-
- Gtk.ToolButton button {
- get { return (Gtk.ToolButton) Wrapped; }
- }
-
- public ButtonType Type {
- get {
- return type;
- }
- set {
- type = value;
- switch (type) {
- case ButtonType.StockItem:
- button.IconWidget = null;
- StockId = stockId;
- Label = label;
- break;
- case ButtonType.TextAndIcon:
- button.StockId = null;
- Icon = imageInfo;
- Label = label;
- break;
- }
- EmitNotify ("Type");
- }
- }
-
- public string Label {
- get { return label; }
- set {
- if (type == ButtonType.StockItem && value != null) {
- label = value.Length == 0 ? null : value;
- } else
- label = value;
-
- button.Label = label;
- }
- }
-
- public string StockId {
- get { return stockId; }
- set {
- stockId = value;
- if (stockId != null && stockId.StartsWith ("stock:"))
- stockId = stockId.Substring (6);
- button.StockId = stockId;
- button.ShowAll ();
- }
- }
-
- public ImageInfo Icon {
- get { return imageInfo; }
- set {
- imageInfo = value;
- if (imageInfo != null) {
- button.IconWidget = new Gtk.Image (imageInfo.GetImage (Project));
- button.ShowAll ();
- }
- else
- button.IconWidget = null;
- EmitNotify ("Icon");
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Toolbar.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Toolbar.cs
deleted file mode 100644
index cc15543888..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Toolbar.cs
+++ /dev/null
@@ -1,178 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Stetic.Wrapper {
-
- public class Toolbar : Container {
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- toolbar.SizeAllocated += toolbar_SizeAllocated;
- }
-
- public override void Dispose ()
- {
- toolbar.SizeAllocated -= toolbar_SizeAllocated;
- base.Dispose ();
- }
-
- public override IEnumerable RealChildren {
- get {
- // Don't return Gtk.ToolItems that are only being used
- // to hold other non-ToolItem widgets. Just return the
- // contained widgets themselves.
-
- Gtk.Widget[] children = toolbar.Children;
- for (int i = 0; i < children.Length; i++) {
- if (children[i].GetType () == typeof (Gtk.ToolItem))
- children[i] = ((Gtk.ToolItem)children[i]).Child;
- }
- return children;
- }
- }
-
- Gtk.Toolbar toolbar {
- get {
- return (Gtk.Toolbar)Wrapped;
- }
- }
-
- public override bool HExpandable {
- get {
- return toolbar.Orientation == Gtk.Orientation.Horizontal;
- }
- }
-
- public override bool VExpandable {
- get {
- return toolbar.Orientation == Gtk.Orientation.Vertical;
- }
- }
-
- public Gtk.Orientation Orientation {
- get {
- return toolbar.Orientation;
- }
- set {
- toolbar.Orientation = value;
- EmitContentsChanged ();
- }
- }
-
- protected override void DoSync ()
- {
- DND.ClearFaults (this);
- Gtk.Orientation faultOrientation =
- Orientation == Gtk.Orientation.Horizontal ? Gtk.Orientation.Vertical : Gtk.Orientation.Horizontal;
- Gdk.Rectangle tbAlloc = toolbar.Allocation;
-
- Gtk.Widget[] children = toolbar.Children;
- if (children.Length == 0) {
- DND.AddFault (this, 0, faultOrientation, tbAlloc);
- return;
- }
-
- if (faultOrientation == Gtk.Orientation.Horizontal) {
- DND.AddHFault (this, 0, null, children[0]);
- DND.AddHFault (this, children.Length, children[children.Length - 1], null);
- } else {
- DND.AddVFault (this, 0, null, children[0]);
- DND.AddVFault (this, children.Length, children[children.Length - 1], null);
- }
-
- for (int i = 1; i < children.Length; i++) {
- if (faultOrientation == Gtk.Orientation.Horizontal)
- DND.AddHFault (this, i, children[i - 1], children[i]);
- else
- DND.AddVFault (this, i, children[i - 1], children[i]);
- }
- }
-
- void toolbar_SizeAllocated (object obj, Gtk.SizeAllocatedArgs args)
- {
- Sync ();
- }
-
- // Insert widget at index, wrapping a ToolItem around it if needed
- void ToolItemize (Gtk.Widget widget, int index)
- {
- Gtk.ToolItem toolItem = widget as Gtk.ToolItem;
- if (toolItem == null) {
- toolItem = new Gtk.ToolItem ();
- toolItem.Show ();
- toolItem.Add (widget);
- }
- toolbar.Insert (toolItem, index);
- }
-
- // Remove widget (or its ToolItem parent), returning its position
- int ToolDeItemize (Gtk.Widget widget)
- {
- Gtk.ToolItem toolItem = widget as Gtk.ToolItem;
- if (toolItem == null) {
- toolItem = (Gtk.ToolItem)widget.Parent;
- toolItem.Remove (widget);
- }
-
- int index = toolbar.GetItemIndex (toolItem);
-
- toolbar.Remove (toolItem);
- if (toolItem != (widget as Gtk.ToolItem))
- toolItem.Destroy ();
-
- return index;
- }
-
- protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- ToolItemize (newChild, ToolDeItemize (oldChild));
- }
-
- public override Placeholder AddPlaceholder ()
- {
- Placeholder ph = CreatePlaceholder ();
- ToolItemize (ph, 0);
- return ph;
- }
-
- int dragIndex;
-
- protected override Gtk.Widget CreateDragSource (Gtk.Widget dragWidget)
- {
- Gtk.Invisible invis = new Gtk.Invisible ();
- invis.Show ();
- invis.DragEnd += DragEnd;
-
- dragIndex = ToolDeItemize (dragWidget);
- return invis;
- }
-
- void DragEnd (object obj, Gtk.DragEndArgs args)
- {
- Gtk.Invisible invis = obj as Gtk.Invisible;
- invis.DragEnd -= DragEnd;
- invis.Destroy ();
-
- if (DND.DragWidget != null)
- ToolItemize (DND.Cancel (), dragIndex);
- dragIndex = -1;
- }
-
- public override void Drop (Gtk.Widget w, object faultId)
- {
- ToolItemize (w, (int)faultId);
- EmitContentsChanged ();
- Sync ();
- }
-
- public class ToolbarChild : Container.ContainerChild {
- public Gtk.ToolItem ToolItem {
- get {
- Gtk.Container.ContainerChild cc = (Gtk.Container.ContainerChild)Wrapped;
- return (Gtk.ToolItem)cc.Child;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/TreeView.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/TreeView.cs
deleted file mode 100644
index 0444f4f4b1..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/TreeView.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-
-using System;
-
-namespace Stetic.Wrapper
-{
- public class TreeView: Container
- {
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- if (!initialized)
- ShowScrollbars = true;
- }
-
- protected override bool AllowPlaceholders {
- get {
- return false;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/VScale.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/VScale.cs
deleted file mode 100644
index e0fb10677c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/VScale.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class VScale : Scale {
-
- public static Gtk.VScale CreateInstance ()
- {
- return new Gtk.VScale (0.0, 100.0, 1.0);
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- return new CodeObjectCreateExpression (ClassDescriptor.WrappedTypeName.ToGlobalTypeRef (), new CodePrimitiveExpression (null));
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/VScrollbar.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/VScrollbar.cs
deleted file mode 100644
index 8270c97a4e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/VScrollbar.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.CodeDom;
-
-namespace Stetic.Wrapper {
-
- public class VScrollbar : Range {
-
- public static Gtk.VScrollbar CreateInstance ()
- {
- return new Gtk.VScrollbar (new Gtk.Adjustment (0.0, 0.0, 100.0, 1.0, 10.0, 10.0));
- }
-
- internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
- {
- return new CodeObjectCreateExpression (ClassDescriptor.WrappedTypeName.ToGlobalTypeRef (), new CodePrimitiveExpression (null));
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Viewport.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Viewport.cs
deleted file mode 100644
index 41dbacc161..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Viewport.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Stetic.Wrapper {
-
- public class Viewport : Container {
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- Unselectable = true;
- }
-
- protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
- {
- Widget ww = Widget.Lookup (oldChild);
- if ((oldChild is Placeholder) && (ParentWrapper is ScrolledWindow) && newChild.SetScrollAdjustments (null, null)) {
- Widget wrapper = Widget.Lookup (newChild);
- wrapper.ShowScrollbars = false;
- ParentWrapper.ReplaceChild (Wrapped, newChild, false);
- } else if (ww != null && ww.ShowScrollbars && (ParentWrapper is ScrolledWindow) && ParentWrapper.ParentWrapper != null) {
- // The viewport is bound to the child widget. Remove it together with the child
- ParentWrapper.ParentWrapper.ReplaceChild (ParentWrapper.Wrapped, newChild, false);
- } else
- base.ReplaceChild (oldChild, newChild);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Widget.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Widget.cs
deleted file mode 100644
index 80f5ab8e33..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Widget.cs
+++ /dev/null
@@ -1,1094 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-using System.CodeDom;
-using Stetic.Undo;
-
-namespace Stetic.Wrapper {
-
- public class Widget : Object, IEditableObject
- {
- static DiffGenerator propDiffGenerator;
-
- string oldName;
- string oldMemberName;
- bool hexpandable, vexpandable;
- bool generatePublic = true;
-
- bool window_visible = true;
- bool hasDefault;
- bool canDefault;
- Gdk.EventMask events;
- bool canFocus;
-
- ActionGroupCollection actionGroups;
- string member;
- string tooltip;
-
- bool requiresUndoStatusUpdate;
-
- // List of groups added to the UIManager
- ArrayList includedActionGroups;
-
- bool unselectable;
- bool boundToScrollWindow;
-
- public event EventHandler Destroyed;
-
- // Fired when the name of the widget changes.
- public event WidgetNameChangedHandler NameChanged;
- // Fired when the member name of the widget changes.
- public event WidgetNameChangedHandler MemberNameChanged;
-
- static Widget ()
- {
- propDiffGenerator = new DiffGenerator ();
- propDiffGenerator.CurrentStatusAdaptor = new XmlDiffAdaptor ();
- propDiffGenerator.NewStatusAdaptor = propDiffGenerator.CurrentStatusAdaptor;
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
-
- oldName = ((Gtk.Widget)obj).Name;
-
- if (!initialized) {
- events = Wrapped.Events;
- canFocus = Wrapped.CanFocus;
- }
-
- if (!(Wrapped is Gtk.Window))
- Wrapped.ShowAll ();
-
- Wrapped.PopupMenu += PopupMenu;
- Wrapped.FocusInEvent += OnFocusIn;
- InterceptClicks (Wrapped);
-
- hexpandable = this.ClassDescriptor.HExpandable;
- vexpandable = this.ClassDescriptor.VExpandable;
-
- if (ParentWrapper != null) {
- // Make sure the widget's name is not already being used.
- string nn = ParentWrapper.GetValidWidgetName (Wrapped);
- if (nn != Wrapped.Name)
- Wrapped.Name = nn;
- }
-
- Wrapped.Destroyed += OnDestroyed;
-
- if (Wrapped.Parent != null) {
- // The object was added to the parent before creating the wrapper.
- // Since it's now a wrapped object, the parent don't need to
- // intercept clicks for it anymore
- Widget w = GetInterceptorParent ();
- if (w != null)
- w.UninterceptClicks (Wrapped);
- }
- }
-
- void OnDestroyed (object on, EventArgs a)
- {
- if (Destroyed != null)
- Destroyed (this, a);
- Dispose ();
- }
-
- public override void Dispose ()
- {
- if (Wrapped == null)
- return;
-
- if (Project != null && Project.Selection == Wrapped)
- Project.Selection = null;
-
- Wrapped.Destroyed -= OnDestroyed;
- Wrapped.PopupMenu -= PopupMenu;
- Wrapped.FocusInEvent -= OnFocusIn;
- UninterceptClicks (Wrapped);
-
- if (actionGroups != null) {
- foreach (ActionGroup ag in actionGroups)
- ag.Dispose ();
- actionGroups = null;
- }
- base.Dispose ();
- }
-
- void OnFocusIn (object s, Gtk.FocusInEventArgs a)
- {
- if (!Unselectable)
- Select ();
- else if (ParentWrapper != null)
- ParentWrapper.Select ();
- }
-
- internal override UndoManager GetUndoManagerInternal ()
- {
- if (ParentWrapper != null)
- return ParentWrapper.UndoManager;
- else
- return base.GetUndoManagerInternal ();
- }
-
- public bool GeneratePublic {
- get { return generatePublic; }
- set { generatePublic = value; }
- }
-
- public bool Unselectable {
- get {
- return unselectable;
- }
- set {
- if (value == unselectable)
- return;
- unselectable = value;
- Widget w = GetInterceptorParent ();
- if (w != null) {
- // If a widget becomes unselectable, then the parent must intercept
- // their clicks.
- if (unselectable)
- w.InterceptClicks (Wrapped);
- else
- w.UninterceptClicks (Wrapped);
- }
- }
- }
-
- Widget GetInterceptorParent ()
- {
- Gtk.Widget wp = Wrapped.Parent;
- while (wp != null && Lookup (wp) == null)
- wp = wp.Parent;
- return Lookup (wp);
- }
-
- void InterceptClicks (Gtk.Widget widget)
- {
- if (widget is Stetic.Placeholder)
- return;
-
- if (!widget.IsRealized)
- widget.Events |= Gdk.EventMask.ButtonPressMask;
- widget.WidgetEvent += WidgetEvent;
-
- Gtk.Container container = widget as Gtk.Container;
- if (container != null) {
- container.Added += OnInterceptedChildAdded;
- container.Removed += OnInterceptedChildRemoved;
- foreach (Gtk.Widget child in container.AllChildren) {
- Widget w = Lookup (child);
- if (w == null || w.Unselectable)
- InterceptClicks (child);
- }
- }
- }
-
- [GLib.ConnectBefore]
- void OnInterceptedChildAdded (object o, Gtk.AddedArgs args)
- {
- Widget w = Lookup (args.Widget);
- if (w == null || w.Unselectable)
- InterceptClicks (args.Widget);
- }
-
- void OnInterceptedChildRemoved (object o, Gtk.RemovedArgs args)
- {
- UninterceptClicks (args.Widget);
- }
-
- void UninterceptClicks (Gtk.Widget widget)
- {
- widget.WidgetEvent -= WidgetEvent;
-
- Gtk.Container container = widget as Gtk.Container;
- if (container != null) {
- container.Added -= OnInterceptedChildAdded;
- container.Removed -= OnInterceptedChildRemoved;
- foreach (Gtk.Widget child in container.AllChildren) {
- if (Lookup (child) == null)
- UninterceptClicks (child);
- }
- }
- }
-
- public new Gtk.Widget Wrapped {
- get {
- return base.Wrapped as Gtk.Widget;
- }
- }
-
- public Stetic.Wrapper.Container ParentWrapper {
- get {
- return Container.LookupParent (Wrapped);
- }
- }
-
- public bool IsTopLevel {
- get { return Wrapped.Parent == null || Widget.Lookup (Wrapped.Parent) == null; }
- }
-
- public string UIManagerName {
- get {
- return actionGroups != null && actionGroups.Count > 0 ? "UIManager" : String.Empty;
- }
- }
-
- internal void InitializeName (string name)
- {
- oldName = name;
- Wrapped.Name = name;
- }
-
- public override string Name {
- get { return Wrapped.Name; }
- set { Wrapped.Name = value; EmitNotify ("Name"); }
- }
-
- public string MemberName {
- get { return member != null ? member : ""; }
- set { member = value; EmitNotify ("MemberName"); }
- }
-
- public Container GetTopLevel ()
- {
- Widget c = this;
- while (!c.IsTopLevel)
- c = c.ParentWrapper;
- return c as Container;
- }
-
- public ActionGroupCollection LocalActionGroups {
- get {
- if (IsTopLevel) {
- if (actionGroups == null) {
- actionGroups = new ActionGroupCollection ();
- actionGroups.SetOwner (this);
- actionGroups.ActionGroupAdded += OnGroupAdded;
- actionGroups.ActionGroupRemoved += OnGroupRemoved;
- actionGroups.ActionGroupChanged += OnGroupChanged;
- }
- return actionGroups;
- } else {
- return ParentWrapper.LocalActionGroups;
- }
- }
- }
-
- void OnGroupAdded (object s, Stetic.Wrapper.ActionGroupEventArgs args)
- {
- args.ActionGroup.SignalAdded += OnSignalAdded;
- args.ActionGroup.SignalRemoved += OnSignalRemoved;
- args.ActionGroup.SignalChanged += OnSignalChanged;
- NotifyChanged ();
- }
-
- void OnGroupRemoved (object s, Stetic.Wrapper.ActionGroupEventArgs args)
- {
- args.ActionGroup.SignalAdded -= OnSignalAdded;
- args.ActionGroup.SignalRemoved -= OnSignalRemoved;
- args.ActionGroup.SignalChanged -= OnSignalChanged;
- NotifyChanged ();
- }
-
- void OnGroupChanged (object s, Stetic.Wrapper.ActionGroupEventArgs args)
- {
- NotifyChanged ();
- }
-
- void OnSignalAdded (object sender, SignalEventArgs args)
- {
- OnSignalAdded (args);
- }
-
- void OnSignalRemoved (object sender, SignalEventArgs args)
- {
- OnSignalRemoved (args);
- }
-
- void OnSignalChanged (object sender, SignalChangedEventArgs args)
- {
- OnSignalChanged (args);
- }
-
- [GLib.ConnectBefore]
- void WidgetEvent (object obj, Gtk.WidgetEventArgs args)
- {
- if (args.Event.Type == Gdk.EventType.ButtonPress)
- args.RetVal = HandleClick ((Gdk.EventButton)args.Event);
- }
-
- internal bool HandleClick (Gdk.EventButton evb)
- {
- int x = (int)evb.X, y = (int)evb.Y;
- int erx, ery, wrx, wry;
-
- // Translate from event window to widget window coords
- evb.Window.GetOrigin (out erx, out ery);
- Wrapped.GdkWindow.GetOrigin (out wrx, out wry);
- x += erx - wrx;
- y += ery - wry;
-
- Widget wrapper = FindWrapper (Wrapped, x, y);
- if (wrapper == null)
- return false;
-
- if (wrapper.Wrapped != proj.Selection) {
- wrapper.Select ();
- return true;
- } else if (evb.Button == 3) {
- proj.PopupContextMenu (wrapper);
- return true;
- } else
- return false;
- }
-
- Widget FindWrapper (Gtk.Widget top, int x, int y)
- {
- Widget wrapper;
-
- Gtk.Container container = top as Gtk.Container;
- if (container != null) {
- foreach (Gtk.Widget child in container.AllChildren) {
- if (!child.IsDrawable)
- continue;
-
- Gdk.Rectangle alloc = child.Allocation;
- if (alloc.Contains (x, y)) {
- if (child.GdkWindow == top.GdkWindow)
- wrapper = FindWrapper (child, x, y);
- else
- wrapper = FindWrapper (child, x - alloc.X, y - alloc.Y);
- if (wrapper != null)
- return wrapper;
- }
- }
- }
-
- wrapper = Lookup (top);
- if (wrapper == null || wrapper.Unselectable)
- return null;
- return wrapper;
- }
-
- void PopupMenu (object obj, EventArgs args)
- {
- proj.PopupContextMenu (this);
- }
-
- public void Select ()
- {
- proj.Selection = Wrapped;
- }
-
- public void Unselect ()
- {
- if (proj.Selection == Wrapped)
- proj.Selection = null;
- }
-
- internal protected virtual void OnSelected ()
- {
- }
-
- internal protected virtual void OnUnselected ()
- {
- }
-
- public void Delete ()
- {
- if (Project.Selection == Wrapped)
- Project.Selection = null;
-
- if (ParentWrapper != null)
- ParentWrapper.Delete (this);
- else
- Wrapped.Destroy ();
- }
-
- internal bool RequiresUndoStatusUpdate {
- get { return requiresUndoStatusUpdate; }
- set { requiresUndoStatusUpdate = value; }
- }
-
- public override ObjectWrapper FindObjectByUndoId (string id)
- {
- ObjectWrapper c = base.FindObjectByUndoId (id);
- if (c != null)
- return c;
-
- if (actionGroups != null)
- return actionGroups.FindObjectByUndoId (id);
- else
- return null;
- }
-
- public override object GetUndoDiff ()
- {
- XmlElement oldElem = UndoManager.GetObjectStatus (this);
- XmlElement newElem = WriteProperties (new ObjectWriter (oldElem.OwnerDocument, FileFormat.Native));
-
- ObjectDiff propsDiff = propDiffGenerator.GetDiff (newElem, oldElem);
- ObjectDiff actionsDiff = LocalActionGroups.GetDiff (Project, oldElem);
-
- UndoManager.UpdateObjectStatus (this, newElem);
-
- if (propsDiff == null && actionsDiff == null)
- return null;
- else
- return new ObjectDiff[] { propsDiff, actionsDiff };
- }
-
- public override object ApplyUndoRedoDiff (object diff)
- {
- ObjectDiff[] data = (ObjectDiff[]) diff;
-
- XmlElement status = UndoManager.GetObjectStatus (this);
- XmlElement oldElem = (XmlElement) status.CloneNode (true);
-
- ObjectDiff propsDiff = data [0];
-
- if (propsDiff != null) {
- propDiffGenerator.ApplyDiff (status, propsDiff);
- ReadProperties (new ObjectReader (Project, FileFormat.Native), status);
- data [0] = propDiffGenerator.GetDiff (status, oldElem);
- }
-
- ObjectDiff actionsDiff = data [1];
- if (actionsDiff != null) {
- LocalActionGroups.ApplyDiff (Project, actionsDiff);
- data [1] = LocalActionGroups.GetDiff (Project, oldElem);
- }
-
- return data;
- }
-
- public override void Read (ObjectReader reader, XmlElement elem)
- {
- ReadActionGroups (reader, elem);
- ReadProperties (reader, elem);
- }
-
- protected void ReadActionGroups (ObjectReader reader, XmlElement elem)
- {
- if (reader.Format == FileFormat.Native) {
- if (actionGroups == null) {
- actionGroups = new ActionGroupCollection ();
- actionGroups.SetOwner (this);
- actionGroups.ActionGroupAdded += OnGroupAdded;
- actionGroups.ActionGroupRemoved += OnGroupRemoved;
- actionGroups.ActionGroupChanged += OnGroupChanged;
- } else
- actionGroups.Clear ();
- foreach (XmlElement groupElem in elem.SelectNodes ("action-group")) {
- ActionGroup actionGroup = new ActionGroup ();
- actionGroup.Read (reader, groupElem);
- actionGroups.Add (actionGroup);
- }
- }
- }
-
- protected virtual void ReadProperties (ObjectReader reader, XmlElement elem)
- {
- if (Wrapped != null) {
- // There is already an instance. Load the default values.
- this.ClassDescriptor.ResetInstance (Wrapped);
- Signals.Clear ();
- }
-
- if (reader.Format == FileFormat.Native)
- WidgetUtils.Read (this, elem);
- else
- GladeUtils.ImportWidget (this, elem);
-
- string uid = elem.GetAttribute ("undoId");
- if (uid.Length > 0)
- UndoId = uid;
- oldName = Wrapped.Name;
- }
-
- public override XmlElement Write (ObjectWriter writer)
- {
- XmlElement elem = WriteProperties (writer);
- WriteActionGroups (writer, elem);
- return elem;
- }
-
- protected virtual XmlElement WriteProperties (ObjectWriter writer)
- {
- if (writer.Format == FileFormat.Native) {
- XmlElement elem = WidgetUtils.Write (this, writer.XmlDocument);
- if (writer.CreateUndoInfo)
- elem.SetAttribute ("undoId", UndoId);
- return elem;
- }
- else {
- XmlElement elem = GladeUtils.ExportWidget (this, writer.XmlDocument);
- GladeUtils.ExtractProperty (elem, "name", "");
- return elem;
- }
- }
-
- protected void WriteActionGroups (ObjectWriter writer, XmlElement elem)
- {
- if (writer.Format == FileFormat.Native) {
- if (actionGroups != null) {
- foreach (ActionGroup actionGroup in actionGroups)
- elem.InsertBefore (actionGroup.Write (writer), elem.FirstChild);
- }
- }
- }
-
- internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- if (!String.IsNullOrEmpty (UIManagerName)) {
- // Create an UI manager
- CodeFieldReferenceExpression uixp = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), UIManagerName);
- CodeAssignStatement uim_init = new CodeAssignStatement (uixp, new CodeObjectCreateExpression (typeof (Gtk.UIManager).ToGlobalTypeRef ()));
- ctx.Statements.Add (uim_init);
-
- includedActionGroups = new ArrayList ();
-
- // Generate action group creation
- foreach (ActionGroup actionGroup in actionGroups) {
-
- // Create the action group
- string grpVar = ctx.NewId ();
- CodeVariableDeclarationStatement uidec = new CodeVariableDeclarationStatement (
- typeof (Gtk.ActionGroup).ToGlobalTypeRef (),
- grpVar,
- actionGroup.GenerateObjectCreation (ctx)
- );
- ctx.Statements.Add (uidec);
- actionGroup.GenerateBuildCode (ctx, new CodeVariableReferenceExpression (grpVar));
-
- // Insert the action group in the UIManager
- CodeMethodInvokeExpression mi = new CodeMethodInvokeExpression (
- uixp,
- "InsertActionGroup",
- new CodeVariableReferenceExpression (grpVar),
- new CodePrimitiveExpression (includedActionGroups.Count)
- );
- ctx.Statements.Add (mi);
-
- includedActionGroups.Add (actionGroup);
- }
-
- // Adds the accel group to the window
- Window w = GetTopLevel () as Window;
- if (w != null) {
- CodeMethodInvokeExpression ami = new CodeMethodInvokeExpression (
- ctx.WidgetMap.GetWidgetExp (w),
- "AddAccelGroup",
- new CodePropertyReferenceExpression (
- uixp,
- "AccelGroup"
- )
- );
- ctx.Statements.Add (ami);
- } else {
- // There is no top level window, this must be a custom widget.
- // The only option is to register the accel group when
- // the widget is realized. This is done by the Bin wrapper.
- }
- }
-
- if (tooltip != null && tooltip.Length > 0)
- GetTopLevel().GenerateTooltip (ctx, this);
-
- base.GenerateBuildCode (ctx, var);
- }
-
- internal protected override void GeneratePostBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- base.GeneratePostBuildCode (ctx, var);
-
- // The visible property is generated here to ensure that widgets are made visible
- // after they have been fully built
-
- PropertyDescriptor prop = ClassDescriptor ["Visible"] as PropertyDescriptor;
- if (prop != null && prop.PropertyType == typeof(bool) && !(bool) prop.GetValue (Wrapped)) {
- ctx.Statements.Add (
- new CodeMethodInvokeExpression (
- var,
- "Hide"
- )
- );
- }
-
- // The HasDefault property can only be assigned when the widget is added to the window
- prop = ClassDescriptor ["HasDefault"] as PropertyDescriptor;
- if (prop != null && (bool) prop.GetValue (Wrapped)) {
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- var,
- "HasDefault"
- ),
- new CodePrimitiveExpression (true)
- )
- );
- }
- }
-
- protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- // Those properties are handled in GeneratePostBuildCode
- if (prop.Name == "Visible" || prop.Name == "HasDefault")
- return;
-
- // Don't generate a name for unselectable widgets
- if (prop.Name == "Name" && Unselectable)
- return;
-
- base.GeneratePropertySet (ctx, var, prop);
- }
-
- protected CodeExpression GenerateUiManagerElement (GeneratorContext ctx, ActionTree tree)
- {
- Widget topLevel = GetTopLevel ();
- string uiName = topLevel.UIManagerName;
- if (uiName != null) {
- CodeFieldReferenceExpression uiManager = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), uiName);
- if (topLevel.includedActionGroups == null)
- topLevel.includedActionGroups = new ArrayList ();
-
- // Add to the uimanager all action groups required by the
- // actions of the tree
-
- foreach (ActionGroup grp in tree.GetRequiredGroups ()) {
- if (!topLevel.includedActionGroups.Contains (grp)) {
- // Insert the action group in the UIManager
- CodeMethodInvokeExpression mi = new CodeMethodInvokeExpression (
- uiManager,
- "InsertActionGroup",
- ctx.GenerateValue (grp, typeof(ActionGroup)),
- new CodePrimitiveExpression (topLevel.includedActionGroups.Count)
- );
- ctx.Statements.Add (mi);
- topLevel.includedActionGroups.Add (grp);
- }
- }
-
- tree.GenerateBuildCode (ctx, uiManager);
- return new CodeMethodInvokeExpression (
- uiManager,
- "GetWidget",
- new CodePrimitiveExpression ("/" + Wrapped.Name)
- );
- }
- return null;
- }
-
- public static new Widget Lookup (GLib.Object obj)
- {
- return Stetic.ObjectWrapper.Lookup (obj) as Stetic.Wrapper.Widget;
- }
-
- PropertyDescriptor internalChildProperty;
- public PropertyDescriptor InternalChildProperty {
- get {
- return internalChildProperty;
- }
- set {
- internalChildProperty = value;
- }
- }
-
- public virtual void Drop (Gtk.Widget widget, object faultId)
- {
- widget.Destroy ();
- }
-
- public virtual bool HExpandable { get { return hexpandable; } }
- public virtual bool VExpandable { get { return vexpandable; } }
-
- public bool Visible {
- get {
- return window_visible;
- }
- set {
- window_visible = value;
- EmitNotify ("Visible");
- }
- }
-
- public bool HasDefault {
- get {
- return hasDefault;
- }
- set {
- hasDefault = value;
- EmitNotify ("HasDefault");
- if (hasDefault && !CanDefault)
- CanDefault = true;
- }
- }
-
- public bool CanDefault {
- get {
- return canDefault;
- }
- set {
- canDefault = value;
- EmitNotify ("CanDefault");
- if (!canDefault && HasDefault)
- HasDefault = false;
- }
- }
-
- public bool Sensitive {
- get {
- return Wrapped.Sensitive;
- }
- set {
- if (Wrapped.Sensitive == value)
- return;
-
- Wrapped.Sensitive = value;
- if (Wrapped.Sensitive)
- InsensitiveManager.Remove (this);
- else
- InsensitiveManager.Add (this);
- EmitNotify ("Sensitive");
- }
- }
-
- public Gdk.EventMask Events {
- get {
- return events;
- }
- set {
- events = value;
- EmitNotify ("Events");
- }
- }
-
- public bool CanFocus {
- get {
- return canFocus;
- }
- set {
- canFocus = value;
- EmitNotify ("CanFocus");
- }
- }
-
- public string Tooltip {
- get {
- return tooltip;
- }
- set {
- tooltip = value;
- }
- }
-
- public bool ShowScrollbars {
- get {
- return boundToScrollWindow;
- }
- set {
- if (boundToScrollWindow != value) {
- boundToScrollWindow = value;
- UpdateScrolledWindow ();
- EmitNotify ("ShowScrollbars");
- }
- }
- }
-
- internal void UpdateScrolledWindow ()
- {
- if (ParentWrapper == null)
- return;
- if (boundToScrollWindow) {
- if (!(Wrapped.Parent is Gtk.Viewport) && !(Wrapped.Parent is Gtk.ScrolledWindow)) {
- Gtk.ScrolledWindow scw = new Gtk.ScrolledWindow ();
- scw.HscrollbarPolicy = scw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
- scw.ShadowType = Gtk.ShadowType.In;
- ScrolledWindow wrapper = (ScrolledWindow) ObjectWrapper.Create (Project, scw, ParentWrapper);
- ParentWrapper.ReplaceChild (Wrapped, scw, false);
- if (Wrapped.SetScrollAdjustments (null, null))
- scw.Add (Wrapped);
- else
- wrapper.AddWithViewport (Wrapped);
- Select ();
- }
- }
- else if (((Wrapped.Parent is Gtk.Viewport) || (Wrapped.Parent is Gtk.ScrolledWindow)) && ParentWrapper.ParentWrapper != null) {
- Gtk.Container parent = (Gtk.Container) Wrapped.Parent;
- parent.Remove (Wrapped);
- Container grandParent;
- if (parent is Gtk.Viewport) {
- parent = (Gtk.Container) parent.Parent;
- grandParent = Container.LookupParent (parent);
- }
- else
- grandParent = Container.LookupParent (parent);
- grandParent.ReplaceChild (parent, Wrapped, true);
- }
- }
-
- public bool InWindow {
- get {
- return this.GetTopLevel ().Wrapped is TopLevelWindow;
- }
- }
-
- public bool IsScrollable {
- get {
- return !IsTopLevel && !(Wrapped is Gtk.ScrolledWindow);
- }
- }
-
- public override string ToString ()
- {
- if (Wrapped == null)
- return base.ToString ();
- else if (Wrapped.Name != null)
- return "[" + Wrapped.GetType ().Name + " '" + Wrapped.Name + "' " + Wrapped.GetHashCode ().ToString () + "]";
- else
- return "[" + Wrapped.GetType ().Name + " " + Wrapped.GetHashCode ().ToString () + "]";
- }
-
- public IDesignArea GetDesignArea ()
- {
- return GetDesignArea (Wrapped);
- }
-
- protected IDesignArea GetDesignArea (Gtk.Widget w)
- {
- while (w != null && !(w is IDesignArea))
- w = w.Parent;
- return w as IDesignArea;
- }
-
- protected override void EmitNotify (string propertyName)
- {
- // Don't notify parent change for top level widgets.
- if (propertyName == "parent" || propertyName == "has-focus" ||
- propertyName == "has-toplevel-focus" || propertyName == "is-active" ||
- propertyName == "is-focus" || propertyName == "style" ||
- propertyName == "Visible" || propertyName == "scroll-offset")
- return;
-
- if (propertyName == "Name") {
- if (Wrapped.Name != oldName) {
- if (ParentWrapper != null) {
- string nn = ParentWrapper.GetValidWidgetName (Wrapped);
- if (nn != Wrapped.Name) {
- // The name was not valid, so it has to be changed again.
- // Don't fire the changed event now, will be fired after the following change
- Wrapped.Name = nn;
- return;
- }
- }
-
- // This fires the changed event
- base.EmitNotify (propertyName);
-
- string on = oldName;
- oldName = Wrapped.Name;
- if (!Loading)
- OnNameChanged (new WidgetNameChangedArgs (this, on, Wrapped.Name));
-
- // Keep the member name in sync with the widget name
- if (on == MemberName)
- MemberName = Wrapped.Name;
- }
- }
- else if (propertyName == "MemberName") {
- if (MemberName != oldMemberName) {
- base.EmitNotify (propertyName);
- string on = oldMemberName;
- oldMemberName = MemberName;
- if (!Loading)
- OnMemberNameChanged (new WidgetNameChangedArgs (this, on, MemberName));
- }
- }
- else {
-// Console.WriteLine ("PROP: " + propertyName);
- base.EmitNotify (propertyName);
- }
- }
-
- protected virtual void OnNameChanged (WidgetNameChangedArgs args)
- {
- if (Project != null)
- Project.NotifyNameChanged (args);
- if (NameChanged != null)
- NameChanged (this, args);
- }
-
- protected virtual void OnMemberNameChanged (WidgetNameChangedArgs args)
- {
- if (MemberNameChanged != null)
- MemberNameChanged (this, args);
- }
-
- bool IEditableObject.CanCopy {
- get { return ClipboardCanCopy; }
- }
-
- bool IEditableObject.CanCut {
- get { return ClipboardCanCut; }
- }
-
- bool IEditableObject.CanPaste {
- get { return ClipboardCanPaste; }
- }
-
- bool IEditableObject.CanDelete {
- get { return CanDelete; }
- }
-
- void IEditableObject.Copy ()
- {
- ClipboardCopy ();
- }
-
- void IEditableObject.Cut ()
- {
- ClipboardCut ();
- }
-
- void IEditableObject.Paste ()
- {
- ClipboardPaste ();
- }
-
- void IEditableObject.Delete ()
- {
- Delete ();
- }
-
- protected virtual bool ClipboardCanCopy {
- get { return !IsTopLevel; }
- }
-
- protected virtual bool ClipboardCanCut {
- get { return InternalChildProperty == null && !IsTopLevel; }
- }
-
- protected virtual bool ClipboardCanPaste {
- get { return false; }
- }
-
- protected virtual bool CanDelete {
- get { return ClipboardCanCut; }
- }
-
- protected virtual void ClipboardCopy ()
- {
- Clipboard.Copy (Wrapped);
- }
-
- protected virtual void ClipboardCut ()
- {
- Clipboard.Cut (Wrapped);
- }
-
- protected virtual void ClipboardPaste ()
- {
- }
- }
-
- internal static class InsensitiveManager {
-
- static Gtk.Invisible invis;
- static Hashtable map;
-
- static InsensitiveManager ()
- {
- map = new Hashtable ();
- invis = new Gtk.Invisible ();
- invis.ButtonPressEvent += ButtonPress;
- }
-
- static void ButtonPress (object obj, Gtk.ButtonPressEventArgs args)
- {
- Gtk.Widget widget = (Gtk.Widget)map[args.Event.Window];
- if (widget == null)
- return;
-
- Widget wrapper = Widget.Lookup (widget);
- args.RetVal = wrapper.HandleClick (args.Event);
- }
-
- public static void Add (Widget wrapper)
- {
- Gtk.Widget widget = wrapper.Wrapped;
-
- widget.SizeAllocated += Insensitive_SizeAllocate;
- widget.Realized += Insensitive_Realized;
- widget.Unrealized += Insensitive_Unrealized;
- widget.Mapped += Insensitive_Mapped;
- widget.Unmapped += Insensitive_Unmapped;
-
- if (widget.IsRealized)
- Insensitive_Realized (widget, EventArgs.Empty);
- if (widget.IsMapped)
- Insensitive_Mapped (widget, EventArgs.Empty);
- }
-
- public static void Remove (Widget wrapper)
- {
- Gtk.Widget widget = wrapper.Wrapped;
- Gdk.Window win = (Gdk.Window)map[widget];
- if (win != null) {
- map.Remove (widget);
- map.Remove (win);
- win.Destroy ();
- }
- widget.SizeAllocated -= Insensitive_SizeAllocate;
- widget.Realized -= Insensitive_Realized;
- widget.Unrealized -= Insensitive_Unrealized;
- widget.Mapped -= Insensitive_Mapped;
- widget.Unmapped -= Insensitive_Unmapped;
- }
-
- static void Insensitive_SizeAllocate (object obj, Gtk.SizeAllocatedArgs args)
- {
- Gdk.Window win = (Gdk.Window)map[obj];
- if (win != null)
- win.MoveResize (args.Allocation);
- }
-
- static void Insensitive_Realized (object obj, EventArgs args)
- {
- Gtk.Widget widget = (Gtk.Widget)obj;
-
- Gdk.WindowAttr attributes = new Gdk.WindowAttr ();
- attributes.WindowType = Gdk.WindowType.Child;
- attributes.Wclass = Gdk.WindowClass.InputOnly;
- attributes.Mask = Gdk.EventMask.ButtonPressMask;
-
- Gdk.Window win = new Gdk.Window (widget.GdkWindow, attributes, 0);
- win.UserData = invis.Handle;
- win.MoveResize (widget.Allocation);
-
- map[widget] = win;
- map[win] = widget;
- }
-
- static void Insensitive_Mapped (object obj, EventArgs args)
- {
- Gdk.Window win = (Gdk.Window)map[obj];
- win.Show ();
- }
-
- static void Insensitive_Unmapped (object obj, EventArgs args)
- {
- Gdk.Window win = (Gdk.Window)map[obj];
- win.Hide ();
- }
-
- static void Insensitive_Unrealized (object obj, EventArgs args)
- {
- Gdk.Window win = (Gdk.Window)map[obj];
- win.Destroy ();
- map.Remove (obj);
- map.Remove (win);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/WidgetEventHandler.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/WidgetEventHandler.cs
deleted file mode 100644
index e6af45e1f6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/WidgetEventHandler.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-
-namespace Stetic.Wrapper
-{
- public delegate void WidgetEventHandler (object sender, WidgetEventArgs args);
-
- public class WidgetEventArgs: EventArgs
- {
- Stetic.Wrapper.Widget wrapper;
- Gtk.Widget widget;
-
- public WidgetEventArgs (Gtk.Widget widget)
- {
- this.widget = widget;
- wrapper = Stetic.Wrapper.Widget.Lookup (widget);
- }
-
- public WidgetEventArgs (Stetic.Wrapper.Widget wrapper)
- {
- this.wrapper = wrapper;
- if (wrapper != null)
- this.widget = wrapper.Wrapped;
- }
-
- public Gtk.Widget Widget {
- get { return widget; }
- }
-
- public Widget WidgetWrapper {
- get { return wrapper; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/WidgetNameChangedHandler.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/WidgetNameChangedHandler.cs
deleted file mode 100644
index 0d2df19114..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/WidgetNameChangedHandler.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-
-namespace Stetic.Wrapper
-{
- public delegate void WidgetNameChangedHandler (object sender, WidgetNameChangedArgs args);
-
- public class WidgetNameChangedArgs: WidgetEventArgs
- {
- string oldName;
- string newName;
-
- public WidgetNameChangedArgs (Stetic.Wrapper.Widget widget, string oldName, string newName): base (widget)
- {
- this.oldName = oldName;
- this.newName = newName;
- }
-
- public string OldName {
- get { return oldName; }
- }
-
- public string NewName {
- get { return newName; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Window.cs b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Window.cs
deleted file mode 100644
index 5210e47a42..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/Window.cs
+++ /dev/null
@@ -1,223 +0,0 @@
-using GLib;
-using System;
-using System.CodeDom;
-using System.Collections;
-
-namespace Stetic.Wrapper {
-
- public class Window : Container {
-
- public override void Wrap (object obj, bool initialized)
- {
- TopLevelWindow window = (TopLevelWindow) obj;
- RootWrapperName = window.Name;
-
- //during Wrap RootWrapperName will be set in the children widgets
- base.Wrap (obj, initialized);
-
- if (!initialized) {
- if (window.Child is Placeholder)
- window.Child.SetSizeRequest (200, 200);
- }
-
- window.DeleteEvent += DeleteEvent;
- }
-
- public static TopLevelWindow CreateInstance ( )
- {
- TopLevelWindow t = new TopLevelWindow ();
- return t;
- }
-
- public override void Dispose ( )
- {
- Wrapped.DeleteEvent -= DeleteEvent;
- base.Dispose ();
- }
-
- [ConnectBefore]
- void DeleteEvent (object obj, Gtk.DeleteEventArgs args)
- {
- Wrapped.Hide ();
- args.RetVal = true;
- }
-
- public override bool HExpandable { get { return true; } }
- public override bool VExpandable { get { return true; } }
-
- public bool Modal {
- get {
- return window.Modal;
- }
- set {
- window.Modal = value;
- EmitNotify ("Modal");
- }
- }
-
- public Gdk.WindowTypeHint TypeHint {
- get {
- return window.TypeHint;
- }
- set {
- window.TypeHint = value;
- EmitNotify ("TypeHint");
- }
- }
-
- Gtk.WindowType type;
- public Gtk.WindowType Type {
- get {
- return type;
- }
- set {
- type = value;
- EmitNotify ("Type");
- }
- }
-
- Gtk.WindowPosition windowPosition;
- public Gtk.WindowPosition WindowPosition {
- get {
- return windowPosition;
- }
- set {
- windowPosition = value;
- EmitNotify ("WindowPosition");
- }
- }
-
- ImageInfo icon;
- public ImageInfo Icon {
- get {
- return icon;
- }
- set {
- icon = value;
- EmitNotify ("Icon");
- }
- }
-
- TopLevelWindow window {
- get { return (TopLevelWindow) Wrapped; }
- }
-
- public string Title {
- get { return window.Title; }
- set { window.Title = value; EmitNotify ("Title"); }
- }
-
- public bool Resizable
- {
- get { return window.Resizable; }
- set { window.Resizable = value; EmitNotify ("Resizable"); }
- }
-
- bool allowGrow = true;
- public bool AllowGrow {
- get { return allowGrow; }
- set { allowGrow = value; EmitNotify ("AllowGrow"); }
- }
-
- bool allowShrink = false;
- public bool AllowShrink {
- get { return allowShrink; }
- set { allowShrink = value; EmitNotify ("AllowShrink"); }
- }
-
- int defaultWidth = -1;
- public int DefaultWidth {
- get { return defaultWidth; }
- set { defaultWidth = value; EmitNotify ("DefaultWidth"); }
- }
-
- int defaultHeight = -1;
- public int DefaultHeight {
- get { return defaultHeight; }
- set { defaultHeight = value; EmitNotify ("DefaultHeight"); }
- }
-
- bool acceptFocus = true;
- public bool AcceptFocus {
- get { return acceptFocus; }
- set { acceptFocus = value; EmitNotify ("AcceptFocus"); }
- }
-
- bool decorated = true;
- public bool Decorated {
- get { return decorated; }
- set { decorated = value; EmitNotify ("Decorated"); }
- }
-
- bool destroyWithParent;
- public bool DestroyWithParent {
- get { return destroyWithParent; }
- set { destroyWithParent = value; EmitNotify ("DestroyWithParent"); }
- }
-
- Gdk.Gravity gravity = Gdk.Gravity.NorthWest;
- public Gdk.Gravity Gravity {
- get { return gravity; }
- set { gravity = value; EmitNotify ("Gravity"); }
- }
-
- string role;
- public string Role {
- get { return role; }
- set { role = value; EmitNotify ("Role"); }
- }
-
- bool skipPagerHint;
- public bool SkipPagerHint {
- get { return skipPagerHint; }
- set { skipPagerHint = value; EmitNotify ("SkipPagerHint"); }
- }
-
- bool skipTaskbarHint;
- public bool SkipTaskbarHint {
- get { return skipTaskbarHint; }
- set { skipTaskbarHint = value; EmitNotify ("SkipTaskbarHint"); }
- }
-
- bool focusOnMap = true;
- public bool FocusOnMap {
- get { return focusOnMap; }
- set { focusOnMap = value; EmitNotify ("FocusOnMap"); }
- }
-
- internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
- {
- base.GenerateBuildCode (ctx, var);
-
- if (DefaultWidth == -1) {
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- var,
- "DefaultWidth"
- ),
- new CodePrimitiveExpression (DesignWidth)
- )
- );
- }
-
- if (DefaultHeight == -1) {
- ctx.Statements.Add (
- new CodeAssignStatement (
- new CodePropertyReferenceExpression (
- var,
- "DefaultHeight"
- ),
- new CodePrimitiveExpression (DesignHeight)
- )
- );
- }
- }
-
- protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
- {
- if (prop.Name != "Type")
- base.GeneratePropertySet (ctx, var, prop);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/objects.xml b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/objects.xml
deleted file mode 100644
index 9fd1d2a919..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/objects.xml
+++ /dev/null
@@ -1,2274 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<objects xmlns:xsl="http://www.w3.org/1999/XSL/Transform" gtk-version="2.4">
-
- <object type="Gtk.Widget,gtk-sharp" wrapper="Stetic.Wrapper.Widget">
- <itemgroups>
- <itemgroup label="Common Widget Properties">
- <property name="MemberName"
- editor="Stetic.Editor.Identifier"
- description="Name of the member to which this widget is bound." />
- <property name="WidthRequest" min="-1" />
- <property name="HeightRequest" min="-1" />
- <property name="Visible" glade-override="true" default="true"/>
- <property name="Sensitive" glade-override="true" />
- <property name="Tooltip" label="Tooltip" glade-name="tooltip"
- description="Tooltip for this widget"
- translatable="true" />
- <property name="CanDefault" />
- <property name="InWindow" internal="true"/>
- <property name="HasDefault" glade-override="true">
- <invisible-if name="InWindow" value="false" />
- </property>
- <property name="CanFocus" />
- <property name="Events" default="0"/>
- <property name="ExtensionEvents" />
- <property name="IsScrollable" internal="true"/>
- <property name="ShowScrollbars" label="Show Scrollbars" default="false">
- <invisible-if name="IsScrollable" value="false" />
- </property>
- <property name="GeneratePublic" internal="true" default="true"/>
- <property name="Name" internal="true"
- min="1"
- init-with-name="true"
- editor="Stetic.Editor.Identifier"/>
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Common Widget Signals">
- <signal name="AccelCanActivate" />
- <signal name="AccelClosuresChanged" />
- <signal name="ButtonPressEvent" />
- <signal name="ButtonReleaseEvent" />
- <signal name="ChildNotified" />
- <signal name="ClientEvent" />
- <signal name="ConfigureEvent" />
- <signal name="DeleteEvent" />
- <signal name="DestroyEvent" />
- <signal name="DirectionChanged" />
- <signal name="DragBegin" />
- <signal name="DragDataDelete"/>
- <signal name="DragDataGet" />
- <signal name="DragDataReceived" />
- <signal name="DragDrop" />
- <signal name="DragEnd" />
- <signal name="DragLeave" />
- <signal name="DragMotion" />
- <signal name="EnterNotifyEvent" />
- <signal name="ExposeEvent" />
- <signal name="Focused" />
- <signal name="FocusGrabbed" />
- <signal name="FocusInEvent" />
- <signal name="FocusOutEvent" />
- <signal name="GrabBrokenEvent" gtk-version="2.8"/>
- <signal name="GrabNotify" />
- <signal name="HelpShown" />
- <signal name="Hidden" />
- <signal name="HierarchyChanged" />
- <signal name="KeyPressEvent" />
- <signal name="KeyReleaseEvent" />
- <signal name="LeaveNotifyEvent" />
- <signal name="MapEvent" />
- <signal name="Mapped" />
- <signal name="MnemonicActivated" />
- <signal name="MotionNotifyEvent" />
- <signal name="NoExposeEvent" />
- <signal name="ParentSet" />
- <signal name="PopupMenu" />
- <signal name="PropertyNotifyEvent" />
- <signal name="ProximityInEvent" />
- <signal name="ProximityOutEvent" />
- <signal name="Realized" />
- <signal name="ScreenChanged" />
- <signal name="ScrollEvent" />
- <signal name="SelectionClearEvent" />
- <signal name="SelectionGet" />
- <signal name="SelectionNotifyEvent" />
- <signal name="SelectionReceived" />
- <signal name="SelectionRequestEvent" />
- <signal name="Shown" />
- <signal name="SizeAllocated" />
- <signal name="SizeRequested" />
- <signal name="StateChanged" />
- <signal name="StyleSet" />
- <signal name="UnmapEvent" />
- <signal name="Unmapped" />
- <signal name="Unrealized" />
- <signal name="VisibilityNotifyEvent" />
- <signal name="WidgetEvent" />
- <signal name="WidgetEventAfter" />
- <signal name="WindowStateEvent" />
- </itemgroup>
- </signals>
-
- <glade-transform>
- <!-- "events" property has extra spaces around "|"s -->
- <import>
- <xsl:template match="widget/property[@name='events']/text()">
- <xsl:call-template name="GtkWidget_fixevents2">
- <xsl:with-param name="string" select="." />
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="GtkWidget_fixevents2">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' | ')">
- <xsl:value-of select="substring-before($string, ' | ')"/>
- <xsl:text>|</xsl:text>
- <xsl:call-template name="GtkWidget_fixevents2">
- <xsl:with-param name="string" select="substring-after($string, ' | ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$string" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </import>
- <export>
- <xsl:template match="widget/property[@name='events']/text()">
- <xsl:call-template name="GtkWidget_breakevents2">
- <xsl:with-param name="string" select="." />
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="GtkWidget_breakevents2">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, '|')">
- <xsl:value-of select="substring-before($string, '|')"/>
- <xsl:text> | </xsl:text>
- <xsl:call-template name="GtkWidget_breakevents2">
- <xsl:with-param name="string" select="substring-after($string, '|')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$string" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </export>
- </glade-transform>
- </object>
-
- <object type="Gtk.Container,gtk-sharp" wrapper="Stetic.Wrapper.Container" base-type="Gtk.Widget">
- <itemgroups>
- <itemgroup name="Commands">
- <command name="IncreaseBorderWidth" label="Increase Border Width" icon="res:inc-border.png" />
- <command name="DecreaseBorderWidth" label="Decrease Border Width" icon="res:dec-border.png" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Container Signals">
- <signal name="Added" />
- <signal name="FocusChildSet" />
- <signal name="Removed" />
- <signal name="ResizeChecked" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.Container+ContainerChild,gtk-sharp" wrapper="Stetic.Wrapper.Container+ContainerChild" />
-
- <object type="Gtk.Window,gtk-sharp" base-type="Gtk.Container" wrapper="Stetic.Wrapper.Window"
- label="Window" icon="window.png" palette-category="window" init-properties="Type">
- <itemgroups>
- <itemgroup label="Window Properties">
- <property name="Title" init-with-name="true" translatable="true" />
- <property name="Icon" />
- <property name="Type" glade-override="true" internal="true" />
- <property name="TypeHint" glade-override="true" />
- <property name="WindowPosition" />
- <property name="Modal" glade-override="true" default="false" />
- <property name="BorderWidth" default="0"/>
- </itemgroup>
- <itemgroup label="Window Size Properties" name="Size">
- <property name="Resizable" default="true"/>
- <property name="AllowGrow" default="true"/>
- <property name="AllowShrink" default="false"/>
- <property name="DefaultWidth" min="-1"/>
- <property name="DefaultHeight" min="-1"/>
- </itemgroup>
- <itemgroup label="Miscellaneous Window Properties" name="Misc">
- <property name="AcceptFocus" default="true"/>
- <property name="Decorated" default="true"/>
- <property name="DestroyWithParent" default="false"/>
- <property name="Gravity" default="NorthWest"/>
- <property name="Role" />
- <property name="SkipPagerHint" default="false"/>
- <property name="SkipTaskbarHint" default="false"/>
- <property name="FocusOnMap" gtk-version="2.6"/>
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Window Signals">
- <signal name="DefaultActivated" />
- <signal name="FrameEvent" />
- <signal name="FocusActivated" />
- <signal name="KeysChanged" />
- <signal name="MoveFocus" />
- <signal name="SetFocus" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.Misc,gtk-sharp" wrapper="Stetic.Wrapper.Misc" base-type="Gtk.Widget">
- <itemgroups>
- <itemgroup label="Miscellaneous Alignment Properties">
- <property name="Xpad" />
- <property name="Ypad" />
- <property name="Xalign" min="0.0" max="1.0" />
- <property name="Yalign" min="0.0" max="1.0" />
- <command name="AlignLeft" label="Align Left" icon="gtk-justify-left" />
- <command name="AlignCenter" label="Align Center" icon="gtk-justify-center" />
- <command name="AlignRight" label="Align Right" icon="gtk-justify-right" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.Paned,gtk-sharp" wrapper="Stetic.Wrapper.Paned" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Pane Properties">
- <property name="Position" />
- <property name="BorderWidth" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Paned Signals">
- <signal name="CycleChildFocus" />
- <signal name="ToggleHandleFocus" />
- <signal name="AcceptPosition" />
- <signal name="CancelPosition" />
- <signal name="MoveHandle" />
- </itemgroup>
- </signals>
- </object>
- <object type="Gtk.Paned+PanedChild,gtk-sharp">
- <itemgroups>
- <itemgroup label="Pane Child Layout">
- <property name="Resize" />
- <property name="Shrink" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.Range,gtk-sharp" wrapper="Stetic.Wrapper.Range" base-type="Gtk.Widget">
- <itemgroups>
- <itemgroup label="Range Properties">
- <property name="UpdatePolicy" />
- <property name="Inverted" />
- <property name="Adjustment.Lower" />
- <property name="Adjustment.Upper" />
- <property name="Adjustment.PageIncrement" />
- <property name="Adjustment.PageSize" />
- <property name="Adjustment.StepIncrement" />
- <property name="Adjustment.Value" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Range Signals">
- <signal name="AdjustBounds" />
- <signal name="ValueChanged" />
- <signal name="MoveSlider" />
- <signal name="ChangeValue" gtk-version="2.6"/>
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.Scale,gtk-sharp" wrapper="Stetic.Wrapper.Scale" base-type="Gtk.Range">
- <itemgroups>
- <itemgroup label="Scale Properties">
- <property name="DrawValue" ignore-default="true" />
- <property name="Digits">
- <disabled-if name="DrawValue" value="false" />
- </property>
- <property name="ValuePos" ignore-default="true" >
- <disabled-if name="DrawValue" value="false" />
- </property>
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Scale Signals">
- <signal name="FormatValue" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.Alignment,gtk-sharp" base-type="Gtk.Container" label="Alignment" icon="alignment.png"
- init-properties="Xalign Yalign Xscale Yscale" palette-category="container">
- <itemgroups>
- <itemgroup label="Alignment Properties">
- <property name="Xscale" />
- <property name="Yscale" />
- <property name="Xalign" />
- <property name="Yalign" />
- <property name="LeftPadding" />
- <property name="TopPadding" />
- <property name="RightPadding" />
- <property name="BottomPadding" />
- <property name="BorderWidth" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.Arrow,gtk-sharp" base-type="Gtk.Misc"
- label="Arrow" icon="arrow.png" palette-category="widget" init-properties="ArrowType ShadowType">
- <itemgroups>
- <itemgroup label="Arrow Properties">
- <property name="ArrowType" />
- <property name="ShadowType" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.Bin,gtk-sharp" base-type="Gtk.Container" wrapper="Stetic.Wrapper.Bin"
- label="Bin" icon="custom.png">
- </object>
-
- <object type="Gtk.Box,gtk-sharp" wrapper="Stetic.Wrapper.Box" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Box Properties">
- <property name="Homogeneous" />
- <property name="Spacing" />
- <property name="BorderWidth" />
- </itemgroup>
- </itemgroups>
- <contextmenu>
- <command name="InsertBefore" label="Insert Before"
- description="Insert an empty row/column before the selected one">
- <invisible-if check="ChildrenAllowed" />
- </command>
-
- <command name="InsertAfter" label="Insert After"
- description="Insert an empty row/column after the selected one">
- <invisible-if check="ChildrenAllowed" />
- </command>
- </contextmenu>
- </object>
-
- <object type="Gtk.Box+BoxChild,gtk-sharp" wrapper="Stetic.Wrapper.Box+BoxChild">
- <itemgroups>
- <itemgroup label="Box Child Layout">
- <property name="PackType" />
- <property name="Position" ignore-default="true"/>
- <property name="AutoSize" label="Auto Size"
- description="If set, the other packing properties for this cell will be automatically adjusted as other widgets are added to and removed from the container" />
- <property name="Expand">
- <disabled-if name="AutoSize" value="true" />
- </property>
- <property name="Fill">
- <disabled-if name="AutoSize" value="true" />
- <disabled-if name="Expand" value="false" />
- </property>
- <property name="Padding" />
- <command name="BoxExpand" label="Expand" icon="res:box-expand.png" />
- <command name="BoxFill" label="Fill" icon="res:box-fill.png" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.ButtonBox,gtk-sharp" base-type="Gtk.Box" wrapper="Stetic.Wrapper.ButtonBox">
- <itemgroups>
- <itemgroup label="Button Box Properties">
- <property name="Size" label="Size"
- description="The number of buttons"
- min="0" />
- <property name="LayoutStyle" />
- </itemgroup>
- </itemgroups>
- <contextmenu>
- <command name="InsertBefore" label="Insert Button Before"
- description="Insert a new button before the selected one" >
- <invisible-if check="ChildrenAllowed" />
- </command>
- <command name="InsertAfter" label="Insert Button After"
- description="Insert a new button after the selected one">
- <invisible-if check="ChildrenAllowed" />
- </command>
- </contextmenu>
- </object>
- <object type="Gtk.ButtonBox+ButtonBoxChild,gtk-sharp" wrapper="Stetic.Wrapper.ButtonBox+ButtonBoxChild">
- <itemgroups>
- <itemgroup label="Button Box Child Layout">
- <property name="InDialog" internal="true" />
- <property name="Secondary">
- <invisible-if name="InDialog" value="true" />
- </property>
- <property name="Position" />
- <property name="Expand" />
- <property name="Fill">
- <disabled-if name="Expand" value="false" />
- </property>
- <property name="Padding" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.Button,gtk-sharp" wrapper="Stetic.Wrapper.Button" base-type="Gtk.Container"
- label="Button" icon="button.png" palette-category="widget">
- <itemgroups>
- <itemgroup label="Button Properties">
- <property name="UseStock" internal="true" />
- <property name="Type" label="Button Type"
- description="The type of button" />
- <property name="StockId" label="Stock Item"
- description="The stock button ID"
- editor="Stetic.Editor.StockItem">
- <invisible-if name="Type" value="TextOnly" />
- <invisible-if name="Type" value="TextAndIcon" />
- <invisible-if name="Type" value="Custom" />
- </property>
- <property name="Icon" label="Icon"
- description="The icon to display in the button"
- editor="Stetic.Editor.ImageSelector">
- <invisible-if name="Type" value="StockItem" />
- <invisible-if name="Type" value="TextOnly" />
- <invisible-if name="Type" value="Custom" />
- </property>
- <property name="Label" translatable="true">
- <invisible-if name="Type" value="StockItem" />
- <invisible-if name="Type" value="Custom" />
- </property>
- <property name="UseUnderline">
- <invisible-if name="Type" value="StockItem" />
- <invisible-if name="Type" value="Custom" />
- </property>
- <property name="IsDialogButton" internal="true" />
- <property name="ResponseId" label="Response Id" glade-name="response_id"
- description="The response ID to emit when this button is clicked."
- editor="Stetic.Editor.ResponseId">
- <invisible-if name="IsDialogButton" value="false" />
- </property>
- </itemgroup>
- <itemgroup label="Extra Button Properties" name="Extra">
- <property name="FocusOnClick" />
- <property name="Relief" />
- <property name="Xalign" />
- <property name="Yalign" />
- <property name="BorderWidth" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Button Signals">
- <signal name="Activated" />
- <signal name="Clicked" />
- <signal name="Entered" />
- <signal name="Left" />
- <signal name="Pressed" />
- <signal name="Released" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.Calendar,gtk-sharp" base-type="Gtk.Widget"
- label="Calendar" icon="calendar.png" palette-category="widget">
- <itemgroups>
- <itemgroup label="Calendar Properties">
- <property name="DisplayOptions" glade-name="display_options" internal="true" />
- <property name="ShowHeading" />
- <property name="ShowDayNames" />
- <property name="ShowWeekNumbers" />
- <property name="NoMonthChange" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Calendar Signals">
- <signal name="PrevMonth" />
- <signal name="DaySelected" />
- <signal name="NextMonth" />
- <signal name="MonthChanged" />
- <signal name="PrevYear" />
- <signal name="DaySelectedDoubleClick" />
- <signal name="NextYear" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.ToggleButton,gtk-sharp" base-type="Gtk.Button"
- label="Toggle Button" icon="togglebutton.png" palette-category="widget">
- <itemgroups>
- <itemgroup label="Toggle Button Properties">
- <property name="Active" />
- <property name="Inconsistent" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Toggle Button Signals">
- <signal name="Toggled" />
- </itemgroup>
- <itemgroup ref="Gtk.Button" />
- </signals>
- </object>
-
- <object type="Gtk.CheckButton,gtk-sharp" wrapper="Stetic.Wrapper.CheckButton"
- label="Check Box" icon="checkbutton.png" palette-category="widget"
- hexpandable="true" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Check Box Properties">
- <property name="Label" init-with-name="true" translatable="true" />
- <property name="Active" />
- <property name="Inconsistent" />
- <property name="DrawIndicator" ignore-default="true"/>
- <property name="HasLabel" internal="true" />
- <property name="UseUnderline" />
- <command name="RestoreLabel" label="Restore Label" icon="res:add-check-label.png"
- description="Restore the button's label">
- <disabled-if name="HasLabel" value="true" />
- </command>
- <command name="RemoveLabel" label="Remove Label" icon="res:remove-check-label.png"
- description="Remove the button's label">
- <disabled-if name="HasLabel" value="false" />
- </command>
- </itemgroup>
- <itemgroup ref="Gtk.Button.Extra" />
- </itemgroups>
- <signals>
- <itemgroup ref="Gtk.Button" />
- <itemgroup ref="Gtk.ToggleButton" />
- </signals>
- <contextmenu>
- <command ref="RemoveLabel" />
- <command ref="RestoreLabel" />
- </contextmenu>
- </object>
-
- <object type="Gtk.MenuItem,gtk-sharp" wrapper="Stetic.Wrapper.MenuItem"
- label="Menu Item">
- <itemgroups>
- <itemgroup label="Menu Item Properties">
- <property name="Label" translatable="true" glade-name="label" label="Label"
- description="The text of the menu item" />
- <property name="UseUnderline" glade-name="use_underline" label="Use Underline"
- description="If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key" />
- <property name="HasSubmenu" internal="true" />
- <property name="Accelerator" editor="Stetic.Editor.Accelerator">
- <disabled-if name="HasSubmenu" value="true" />
- </property>
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- </itemgroups>
- <signals>
- <itemgroup label="Menu Item Signals">
- <signal name="Activated" />
- <signal name="ActivateItem" />
- <signal name="Deselected" />
- <signal name="Selected" />
- <signal name="Toggled" />
- <signal name="ToggleSizeAllocated" />
- <signal name="ToggleSizeRequested" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- </signals>
-
- <glade-transform>
- <!-- A regular MenuItem with no label is really a SeparatorMenuItem -->
- <import>
- <xsl:template match="widget[@class='GtkMenuItem']">
- <xsl:choose>
- <xsl:when test="not(property[@name='label']) and not(property[@name='stock_item'])">
- <widget class="GtkSeparatorMenuItem">
- <xsl:attribute name="id"><xsl:value-of select="@id" /></xsl:attribute>
- <xsl:apply-templates select="node()" />
- </widget>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy>
- <xsl:apply-templates select="@*|node()" />
- </xsl:copy>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </import>
- </glade-transform>
- </object>
-
- <object type="Gtk.CheckMenuItem,gtk-sharp" label="Check Menu Item">
- <itemgroups>
- <itemgroup label="Check Menu Item Properties">
- <property ref="Gtk.MenuItem.Label" />
- <property ref="Gtk.MenuItem.UseUnderline" />
- <property ref="Gtk.MenuItem.Accelerator" />
- <property name="Active" />
- <property name="Inconsistent" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- </itemgroups>
- <signals>
- <itemgroup label="Check Menu Item Signals">
- <signal name="Toggled" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- <itemgroup ref="Gtk.MenuItem" />
- </signals>
- </object>
-
- <object type="Gtk.ColorButton,gtk-sharp" wrapper="Stetic.Wrapper.ColorButton"
- label="Color Button" icon="colorbutton.png" palette-category="widget" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Color Button Properties">
- <property name="Title" translatable="true" />
- <property name="UseAlpha" internal="true" />
- <property name="Alpha" min="-1" max="65535" />
- </itemgroup>
- <itemgroup ref="Gtk.Button.Extra" />
- </itemgroups>
- <signals>
- <itemgroup label="Color Button Signals">
- <signal name="ColorSet" />
- </itemgroup>
- <itemgroup ref="Gtk.Button" />
- </signals>
- </object>
-
- <object type="Gtk.ComboBox,gtk-sharp" wrapper="Stetic.Wrapper.ComboBox"
- label="Combo Box" icon="combo.png" palette-category="widget" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Combo Box Properties">
- <property name="IsTextCombo" label="Text ComboBox"
- description="Checked if the combo box displays a list of strings" />
- <property name="Items" translatable="true" label="Items" glade-name="items"
- description="The items to display in the Combo Box, one per line"
- editor="Stetic.Editor.StringArray">
- <disabled-if name="IsTextCombo" value="false" />
- </property>
- <property name="Active" min="-1" default="-1"/>
- <property name="HasFrame" gtk-version="2.6"/>
- <property name="AddTearoffs" gtk-version="2.6"/>
- <property name="FocusOnClick" gtk-version="2.6"/>
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="ComboBox Signals">
- <signal name="Changed" />
- <signal name="EditingDone" gtk-version="2.6"/>
- <signal name="WidgetRemoved" gtk-version="2.6"/>
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.ComboBoxEntry,gtk-sharp" wrapper="Stetic.Wrapper.ComboBoxEntry" icon="comboentry.png"
- label="Combo Box Entry" palette-category="widget" base-type="Gtk.ComboBox">
- </object>
-
- <object type="Gtk.Dialog,gtk-sharp" wrapper="Stetic.Wrapper.Dialog"
- label="Dialog Box" icon="dialog.png" palette-category="window" base-type="Gtk.Window">
- <itemgroups>
- <itemgroup label="Dialog Properties">
- <property name="Buttons" label="Number of Buttons"
- description="The number of buttons"
- min="1" />
- <property name="HelpButton" label="Help Button"
- description="Whether or not to display a 'Help' button" />
- <property name="HasSeparator" default="true"/>
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Dialog Signals">
- <signal name="Close" />
- <signal name="Response" />
- </itemgroup>
- </signals>
- <internal-children>
- <property name="VBox" glade-name="vbox" />
- <property name="ActionArea" glade-name="action_area" />
- </internal-children>
- </object>
-
- <object type="Gtk.DrawingArea,gtk-sharp" base-type="Gtk.Widget"
- label="Drawing Area" icon="drawingarea.png" palette-category="widget"
- hexpandable="true" vexpandable="true">
- </object>
-
- <object type="Gtk.Entry,gtk-sharp" base-type="Gtk.Widget"
- label="Entry" icon="entry.png" palette-category="widget"
- hexpandable="true" wrapper="Stetic.Wrapper.Entry">
- <itemgroups>
- <itemgroup label="Entry Properties">
- <property name="Text" translatable="true" />
- <property name="IsEditable" />
- <property name="WidthChars" min="-1"/>
- <property name="MaxLength" />
- <property name="HasFrame" />
- <property name="ActivatesDefault" />
- <property name="Visibility" />
- </itemgroup>
- <itemgroup label="Extra Entry Properties" name="Extra">
- <property name="InvisibleChar" />
- <property name="Xalign" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Entry Signals">
- <signal name="InsertAtCursor" />
- <signal name="ToggleOverwrite" />
- <signal name="PopulatePopup" />
- <signal name="ClipboardCopied" />
- <signal name="ClipboardPasted" />
- <signal name="DeleteFromCursor" />
- <signal name="Activated" />
- <signal name="ClipboardCut" />
- <signal name="MoveCursor" />
- <signal name="Changed" />
- <signal name="TextDeleted" />
- <signal name="TextInserted" />
- <signal name="EditingDone" />
- <signal name="WidgetRemoved" />
- <signal name="Backspace" gtk-version="2.6"/>
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.EventBox,gtk-sharp" base-type="Gtk.Container"
- label="Event Box" icon="eventbox.png" palette-category="container">
- <itemgroups>
- <itemgroup label="Event Box Properties">
- <property name="AboveChild" />
- <property name="VisibleWindow" />
- <property name="BorderWidth" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.Expander,gtk-sharp" base-type="Gtk.Container" wrapper="Stetic.Wrapper.Expander"
- label="Expander" icon="expander.png" palette-category="container">
- <itemgroups>
- <itemgroup label="Expander Properties">
- <property name="Expanded" />
- <property name="Spacing" />
- <property name="BorderWidth" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Expander Signals">
- <signal name="Activated" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.Fixed,gtk-sharp" wrapper="Stetic.Wrapper.Fixed" base-type="Gtk.Container"
- label="Fixed" icon="fixed.png" palette-category="container">
- <itemgroups>
- <itemgroup label="Fixed Properties">
- <property name="HasWindow" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.Fixed+FixedChild,gtk-sharp" wrapper="Stetic.Wrapper.Fixed+FixedChild">
- <itemgroups>
- <itemgroup label="Fixed Child Layout">
- <property name="X" />
- <property name="Y" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.FontButton,gtk-sharp" wrapper="Stetic.Wrapper.FontButton"
- label="Font Button" icon="fontbutton.png" palette-category="widget" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Font Button Properties">
- <property name="Title" translatable="true" />
- <property name="FontName" />
- <property name="ShowSize" />
- <property name="ShowStyle" />
- <property name="UseFont" />
- <property name="UseSize">
- <disabled-if name="UseFont" value="false" />
- </property>
- </itemgroup>
- <itemgroup ref="Gtk.Button.Extra" />
- </itemgroups>
- <signals>
- <itemgroup label="Font Button Signals">
- <signal name="FontSet" />
- </itemgroup>
- <itemgroup ref="Gtk.Button" />
- </signals>
- </object>
-
- <object type="Gtk.Frame,gtk-sharp" wrapper="Stetic.Wrapper.Frame" base-type="Gtk.Container"
- label="Frame" icon="frame.png" palette-category="container">
- <itemgroups>
- <itemgroup label="Frame Properties">
- <property name="ShadowType" />
- <property name="LabelXalign" />
- <property name="LabelYalign" />
- <property name="BorderWidth" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.HBox,gtk-sharp" base-type="Gtk.Box"
- label="HBox" icon="hbox.png" palette-category="container">
- </object>
-
- <object type="Gtk.HButtonBox,gtk-sharp" base-type="Gtk.ButtonBox"
- label="HButtonBox" icon="hbuttonbox.png" palette-category="container"
- hexpandable="true">
- <glade-transform>
- <!-- If a child has a "response_id" of -11 (GTK_RESPONSE_HELP), it should be packed with the "secondary" property -->
- <import>
- <xsl:template match="widget[@class='GtkHButtonBox']/child/widget[@class='GtkButton']">
- <xsl:copy>
- <xsl:apply-templates select="@*|node()"/>
- </xsl:copy>
- <xsl:if test="number (property[@name='response_id']) = -11">
- <packing>
- <property name="secondary">True</property>
- </packing>
- </xsl:if>
- </xsl:template>
- </import>
- </glade-transform>
- </object>
-
- <object type="Gtk.HPaned,gtk-sharp" base-type="Gtk.Paned"
- label="HPaned" icon="hpaned.png" palette-category="container"
- hexpandable="true">
- </object>
-
- <object type="Gtk.HScale,gtk-sharp" wrapper="Stetic.Wrapper.HScale"
- label="Horizontal Scale" icon="hscale.png" palette-category="widget"
- hexpandable="true" base-type="Gtk.Scale">
- </object>
-
- <object type="Gtk.HScrollbar,gtk-sharp" wrapper="Stetic.Wrapper.HScrollbar"
- label="Horizontal Scrollbar" icon="hscrollbar.png" palette-category="widget"
- hexpandable="true" base-type="Gtk.Range">
- </object>
-
- <object type="Gtk.HSeparator,gtk-sharp" base-type="Gtk.Widget"
- label="Horizontal Separator" icon="hseparator.png" palette-category="widget"
- hexpandable="true">
- </object>
-
- <object type="Gtk.Image,gtk-sharp" wrapper="Stetic.Wrapper.Image"
- label="Image" icon="image.png" palette-category="widget" base-type="Gtk.Misc">
- <itemgroups>
- <itemgroup label="Image Properties">
- <property name="Pixbuf" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.ImageMenuItem,gtk-sharp" wrapper="Stetic.Wrapper.ImageMenuItem"
- label="Image Menu Item">
- <itemgroups>
- <itemgroup label="Image Menu Item Properties">
- <property name="Image" editor="Stetic.Editor.Image" />
- <property ref="Gtk.MenuItem.Label" />
- <property ref="Gtk.MenuItem.UseUnderline" />
- <property ref="Gtk.MenuItem.Accelerator" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- </itemgroups>
- <signals>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- <itemgroup ref="Gtk.MenuItem" />
- </signals>
- </object>
-
- <object type="Gtk.Label,gtk-sharp" wrapper="Stetic.Wrapper.Label"
- label="Label" icon="label.png" palette-category="widget" base-type="Gtk.Misc">
- <itemgroups>
- <itemgroup label="Label Properties">
- <property name="LabelProp" init-with-name="true" translatable="true" default=""/>
- <property name="UseMarkup" />
- <property name="UseUnderline" />
- <property name="Wrap" />
- <property name="MnemonicWidget" glade-override="true" editor="Stetic.Editor.WidgetSelector" default=""/>
- <property name="Justify" />
- <property name="Selectable" />
- <property name="Ellipsize" gtk-version="2.6"/>
- <property name="WidthChars" min="-1" gtk-version="2.6" />
- <property name="MaxWidthChars" min="-1" gtk-version="2.6" />
- <property name="SingleLineMode" gtk-version="2.6" />
- <property name="Angle" gtk-version="2.6" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Label Signals">
- <signal name="CopyClipboard" />
- <signal name="MoveCursor" />
- <signal name="PopulatePopup" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.MenuBar,gtk-sharp" wrapper="Stetic.Wrapper.MenuBar"
- label="Menu Bar" icon="menubar.png" palette-category="widget" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="MenuBar Properties">
- <property name="PackDirection" gtk-version="2.8" />
- <property name="ChildPackDirection" gtk-version="2.8" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Menu Bar Signals">
- <signal name="Deactivated" />
- <signal name="SelectionDone" />
- <signal name="MoveCurrent" />
- <signal name="ActivateCurrent" />
- <signal name="Canceled" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.Menu,gtk-sharp" label="Menu" icon="menu.png" base-type="Gtk.Container">
- <signals>
- <itemgroup label="Menu Signals">
- <signal name="Deactivated" />
- <signal name="SelectionDone" />
- <signal name="MoveCurrent" />
- <signal name="ActivateCurrent" />
- <signal name="Canceled" />
- </itemgroup>
- </signals>
- </object>
- <object type="Gtk.Menu+MenuChild,gtk-sharp" />
-
-<!-- Code generation not implemented for MessageDialog
-
- <object type="Stetic.MessageDialog" cname="GtkMessageDialog" wrapper="Stetic.Wrapper.Window"
- label="Message Dialog" icon="messagedialog.png" palette-category="window">
- <itemgroups>
- <itemgroup label="Message Dialog Properties">
- <property ref="Gtk.Window.Title" />
- <property name="MessageType" label="Message Type"
- description="The type of message dialog this is" />
- <property name="PrimaryText" translatable="true" label="Primary Text"
- description="The primary message text" />
- <property name="SecondaryText" translatable="true" label="Secondary Text"
- description="The secondary message text" />
- <property name="Buttons" label="Buttons"
- description="The buttons to offer" />
- <property ref="Gtk.Window.Icon" />
- <property ref="Gtk.Window.WindowPosition" />
- <property ref="Gtk.Window.Modal" />
- <property name="BorderWidth" />
- </itemgroup>
- <itemgroup ref="Gtk.Dialog.Misc" />
- <itemgroup ref="Gtk.Window.Size" />
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container.Commands" />
- </itemgroups>
- <signals>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- <itemgroup ref="Gtk.Window" />
- <itemgroup ref="Gtk.Dialog" />
- </signals>
- </object>
--->
-
- <object type="Gtk.Notebook,gtk-sharp" wrapper="Stetic.Wrapper.Notebook" base-type="Gtk.Container"
- label="Notebook" icon="notebook.png" palette-category="container">
- <itemgroups>
- <itemgroup label="Notebook Properties">
- <property name="CurrentPage" />
- <property name="EnablePopup" />
- <property name="TabPos" />
- <property name="ShowBorder" />
- <property name="ShowTabs" />
- <property name="Scrollable" />
- <property name="BorderWidth" />
- <command name="InsertBefore" label="Insert Page Before"
- description="Insert a blank page before this one">
- <invisible-if check="ChildrenAllowed" />
- <disabled-if check="CheckInsertBefore" />
- </command>
- <command name="InsertAfter" label="Insert Page After"
- description="Insert a blank page after this one" >
- <invisible-if check="ChildrenAllowed" />
- </command>
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Notebook Signals">
- <signal name="FocusTab" />
- <signal name="ChangeCurrentPage" />
- <signal name="MoveFocusOut" />
- <signal name="SwitchPage" />
- <signal name="SelectPage" />
- </itemgroup>
- </signals>
- <contextmenu>
- <command name="PreviousPage" label="Go to Previous Page"
- description="Show the previous page">
- <disabled-if check="CheckPreviousPage" />
- </command>
- <command name="NextPage" label="Go to Next Page"
- description="Show the next page">
- <disabled-if check="CheckNextPage" />
- </command>
- <command name="DeletePage" label="Delete Page"
- description="Delete the current page">
- <invisible-if check="ChildrenAllowed" />
- <disabled-if check="CheckDeletePage" />
- </command>
- <command name="SwapPrevious" label="Swap with Previous Page"
- description="Swap the contents of this page with the contents of the previous page">
- <invisible-if check="ChildrenAllowed" />
- <disabled-if check="CheckPreviousPage" />
- </command>
- <command name="SwapNext" label="Swap with Next Page"
- description="Swap the contents of this page with the contents of the next page">
- <invisible-if check="ChildrenAllowed" />
- <disabled-if check="CheckNextPage" />
- </command>
- <command ref="InsertBefore" />
- <command ref="InsertAfter" />
- </contextmenu>
- </object>
- <object type="Gtk.Notebook+NotebookChild,gtk-sharp">
- <itemgroups>
- <itemgroup label="Notebook Child Layout">
- <property name="Position" />
- <property name="TabPack" />
- <property name="TabExpand" />
- <property name="TabFill" />
- <property name="MenuLabel" translatable="true" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.OptionMenu,gtk-sharp" wrapper="Stetic.Wrapper.OptionMenu"
- label="Option Menu" icon="optionmenu.png" deprecated="true" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Option Menu Properties">
- <property name="Active" glade-name="history" label="Active"
- description="The active menu item" min="0" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Option Menu Signals">
- <signal name="Changed" />
- </itemgroup>
- <itemgroup ref="Gtk.Button" />
- </signals>
- <internal-children>
- <property name="Menu" glade-name="menu" />
- </internal-children>
- </object>
-
- <object type="Gtk.ProgressBar,gtk-sharp" base-type="Gtk.Widget"
- label="Progress Bar" icon="progressbar.png" palette-category="widget"
- hexpandable="true">
- <itemgroups>
- <itemgroup label="Progress Bar Properties">
- <property name="Orientation" />
- <property name="Text" translatable="true" />
- <property name="Fraction" />
- <property name="PulseStep" />
- <property name="Ellipsize" gtk-version="2.6"/>
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.RadioButton,gtk-sharp" wrapper="Stetic.Wrapper.RadioButton"
- label="Radio Button" icon="radiobutton.png" palette-category="widget"
- hexpandable="true" init-properties="Label" base-type="Gtk.CheckButton">
- <itemgroups>
- <itemgroup label="Radio Button Properties">
- <property name="Group" label="Group"
- description="The name of the radio button group that this button belongs to"
- editor="Stetic.Editor.GroupPicker" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Radio Button Signals">
- <signal name="GroupChanged" />
- </itemgroup>
- </signals>
- </object>
-<!--
- <object type="Gtk.RadioMenuItem,gtk-sharp" wrapper="Stetic.Wrapper.RadioMenuItem"
- label="Radio Menu Item">
- <itemgroups>
- <itemgroup label="Radio Menu Item Properties">
- <property ref="Gtk.MenuItem.Label" />
- <property ref="Gtk.MenuItem.UseUnderline" />
- <property ref="Gtk.MenuItem.Accelerator" />
- <property name="Group" label="Group"
- description="The name of the radio menu item group that this menu item belongs to"
- editor="Stetic.Editor.GroupPicker" />
- <property name="Active" />
- <property name="Inconsistent" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- </itemgroups>
- <signals>
- <itemgroup label="Radio Menu Item Signals">
- <signal name="Toggled" />
- <signal name="GroupChanged" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- <itemgroup ref="Gtk.MenuItem" />
- </signals>
- </object>
-
- <object type="Gtk.ToolItem,gtk-sharp" wrapper="Stetic.Wrapper.Widget">
- <signals>
- <itemgroup label="Tool Item Signals">
- <signal name="ToolbarReconfigured" />
- <signal name="CreateMenuProxy" />
- <signal name="TooltipSet" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.ToolButton,gtk-sharp" wrapper="Stetic.Wrapper.ToolButton"
- label="Toolbar Button" icon="button.png" palette-category="toolbaritem">
- <itemgroups>
- <itemgroup label="Toolbar Button Properties">
- <property name="Type" label="Button Type"
- description="The type of button" />
- <property name="StockId" label="Stock Item"
- description="The stock button ID"
- editor="Stetic.Editor.StockItem">
- <invisible-if name="Type" value="TextAndIcon" />
- </property>
- <property name="Icon" label="Icon"
- description="The icon to display in the button"
- editor="Stetic.Editor.ImageSelector">
- <invisible-if name="Type" value="StockItem" />
- </property>
- <property name="Label" translatable="true" />
- <property name="UseUnderline">
- <invisible-if name="Type" value="StockItem" />
- </property>
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- </itemgroups>
- <signals>
- <itemgroup label="Tool Button Signals">
- <signal name="Clicked" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- <itemgroup ref="Gtk.ToolItem" />
- </signals>
- </object>
-
- <object type="Gtk.RadioToolButton,gtk-sharp" wrapper="Stetic.Wrapper.RadioToolButton"
- label="Toolbar Radio Button" icon="radiobutton.png" palette-category="toolbaritem">
- <itemgroups>
- <itemgroup label="Toolbar Radio Button Properties">
- <property ref="Gtk.ToolButton.Icon" />
- <property ref="Gtk.ToolButton.Label" />
- <property ref="Gtk.ToolButton.UseUnderline" />
- <property name="Group" label="Group"
- description="The name of the radio toolbar item group that this toolbar item belongs to"
- editor="Stetic.Editor.GroupPicker" />
- <property name="Active" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- </itemgroups>
- <signals>
- <itemgroup label="Radio Tool Button Signals">
- <signal name="Toggled" />
- <signal name="Clicked" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- <itemgroup ref="Gtk.ToolItem" />
- </signals>
- </object>
--->
-
- <object type="Gtk.ScrolledWindow,gtk-sharp" wrapper="Stetic.Wrapper.ScrolledWindow"
- label="Scrolled Window" icon="scrolledwindow.png" palette-category="container"
- hexpandable="true" vexpandable="true" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Scrolled Window Properties">
- <property name="VscrollbarPolicy" default="Automatic" />
- <property name="HscrollbarPolicy" default="Automatic" />
- <property name="ShadowType" />
- <property name="WindowPlacement" />
- <property name="BorderWidth" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Scrolled Window Signals">
- <signal name="MoveFocusOut" />
- <signal name="ScrollChild" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.SeparatorMenuItem,gtk-sharp"
- label="Separator Menu Item" icon="hseparator.png">
- <itemgroups>
- <itemgroup ref="Gtk.Widget" important="false" />
- </itemgroups>
- <signals>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- <itemgroup ref="Gtk.MenuItem" />
- </signals>
- </object>
-
-<!-- <object type="Gtk.SeparatorToolItem,gtk-sharp"
- label="Toolbar Separator" icon="vseparator.png" palette-category="toolbaritem">
- <itemgroups>
- <itemgroup label="Toolbar Separator Properties">
- <property name="Draw" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- </itemgroups>
- <signals>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- <itemgroup ref="Gtk.ToolItem" />
- </signals>
- </object>
--->
-
- <object type="Gtk.SpinButton,gtk-sharp" wrapper="Stetic.Wrapper.SpinButton" base-type="Gtk.Widget"
- label="Spin Button" icon="spinbutton.png" palette-category="widget" init-properties="Lower Upper StepIncrement">
- <itemgroups>
- <itemgroup label="Range Properties">
- <property name="Adjustment.Lower" />
- <property name="Adjustment.Upper" />
- <property name="Adjustment.PageIncrement" />
- <property name="Adjustment.PageSize" />
- <property name="Adjustment.StepIncrement" />
- </itemgroup>
- <itemgroup label="Spin Button Properties" important="true">
- <property name="ClimbRate" />
- <property name="Digits" />
- <property name="Numeric" />
- <property name="SnapToTicks" />
- <property name="UpdatePolicy" />
- <property name="Value" />
- <property name="Wrap" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Spin Button Signals">
- <signal name="ChangeValue" />
- <signal name="Input" />
- <signal name="ValueChanged" />
- <signal name="Output" />
- </itemgroup>
- <itemgroup ref="Gtk.Entry" />
- </signals>
- </object>
-
- <object type="Gtk.Statusbar,gtk-sharp" base-type="Gtk.HBox"
- label="Statusbar" icon="statusbar.png" palette-category="widget"
- hexpandable="true">
- <itemgroups>
- <itemgroup label="Status Bar Properties">
- <property name="HasResizeGrip" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Statusbar Signals">
- <signal name="TextPopped" />
- <signal name="TextPushed" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.Table,gtk-sharp" wrapper="Stetic.Wrapper.Table" base-type="Gtk.Container"
- label="Table" icon="table.png" palette-category="container" init-properties="NRows NColumns Homogeneous">
- <itemgroups>
- <itemgroup label="Table Properties">
- <property name="NRows" min="1"/>
- <property name="NColumns" min="1"/>
- <property name="Homogeneous" />
- <property name="RowSpacing" />
- <property name="ColumnSpacing" />
- <property name="BorderWidth" />
- </itemgroup>
- </itemgroups>
- <contextmenu>
- <command name="InsertRowBefore" label="Insert Row Before"
- description="Insert an empty row above the selected row">
- <invisible-if check="ChildrenAllowed" />
- </command>
- <command name="InsertRowAfter" label="Insert Row After"
- description="Insert an empty row below the selected row">
- <invisible-if check="ChildrenAllowed" />
- </command>
- <command name="InsertColumnBefore" label="Insert Column Before"
- description="Insert an empty column before the selected column">
- <invisible-if check="ChildrenAllowed" />
- </command>
- <command name="InsertColumnAfter" label="Insert Column After"
- description="Insert an empty column after the selected column">
- <invisible-if check="ChildrenAllowed" />
- </command>
- <command name="DeleteRow" label="Delete Row"
- description="Delete the selected row">
- <invisible-if check="ChildrenAllowed" />
- </command>
- <command name="DeleteColumn" label="Delete Column"
- description="Delete the selected column">
- <invisible-if check="ChildrenAllowed" />
- </command>
- </contextmenu>
-
- <glade-transform>
- <!-- Child packing options are non-standard ("expand" instead of "GTK_EXPAND") -->
- <import>
- <xsl:template match="widget[@class='GtkTable']/child/packing/property[@name='x_options' or @name='y_options']/text()">
- <xsl:call-template name="GtkTable_fixoptions2">
- <xsl:with-param name="string" select="." />
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="GtkTable_fixoptions2">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, '|')">
- <xsl:call-template name="GtkTable_fixoptions2">
- <xsl:with-param name="string" select="substring-before($string, '|')"/>
- </xsl:call-template>
- <xsl:text>|</xsl:text>
- <xsl:call-template name="GtkTable_fixoptions2">
- <xsl:with-param name="string" select="substring-after($string, '|')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>GTK_</xsl:text>
- <xsl:value-of select="translate($string,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </import>
- <export>
- <xsl:template match="widget[@class='GtkTable']/child/packing/property[@name='x_options' or @name='y_options']/text()">
- <xsl:call-template name="GtkTable_breakoptions2">
- <xsl:with-param name="options" select="." />
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="GtkTable_breakoptions2">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, '|')">
- <xsl:call-template name="GtkTable_breakoptions2">
- <xsl:with-param name="string" select="substring-before($string, '|')"/>
- </xsl:call-template>
- <xsl:text>|</xsl:text>
- <xsl:call-template name="GtkTable_breakoptions2">
- <xsl:with-param name="string" select="substring-after($string, '|')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="translate(substring-after($string, 'GTK_'),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </export>
- </glade-transform>
- </object>
- <object type="Gtk.Table+TableChild,gtk-sharp" wrapper="Stetic.Wrapper.Table+TableChild">
- <itemgroups>
- <itemgroup label="Table Child Layout">
- <property name="TopAttach" />
- <property name="BottomAttach" />
- <property name="LeftAttach" />
- <property name="RightAttach" />
- <property name="XPadding" />
- <property name="YPadding" />
- <property name="AutoSize" label="Auto Size"
- description="If set, the other packing properties for this cell will be automatically adjusted as other widgets are added to and removed from the container" />
- <property name="XOptions" internal="true" />
- <property name="YOptions" internal="true" />
- <property name="XExpand" label="Expand Horizontally"
- description="Whether or not the table cell should expand horizontally">
- <disabled-if name="AutoSize" value="true" />
- </property>
- <property name="XFill" label="Fill Horizontally"
- description="Whether or not the widget should expand to fill its cell horizontally">
- <disabled-if name="AutoSize" value="true" />
- <disabled-if name="XExpand" value="true" />
- </property>
- <property name="XShrink" label="Shrink Horizontally"
- description="Whether or not the table cell should shrink horizontally">
- <disabled-if name="AutoSize" value="true" />
- </property>
- <property name="YExpand" label="Expand Vertically"
- description="Whether or not the table cell should expand vertically">
- <disabled-if name="AutoSize" value="true" />
- </property>
- <property name="YFill" label="Fill Vertically"
- description="Whether or not the widget should expand to fill its cell vertically">
- <disabled-if name="AutoSize" value="true" />
- <disabled-if name="YExpand" value="true" />
- </property>
- <property name="YShrink" label="Shrink Vertically"
- description="Whether or not the table cell should shrink vertically">
- <disabled-if name="AutoSize" value="true" />
- </property>
- <command name="CellXExpand" label="Expand Horizontally" icon="res:cell-expand-h.png" />
- <command name="CellXFill" label="Fill Horizontally" icon="res:cell-fill-h.png" />
- <command name="CellYExpand" label="Expand Vertically" icon="res:cell-expand-v.png" />
- <command name="CellYFill" label="Fill Vertically" icon="res:cell-fill-v.png" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.TextView,gtk-sharp" wrapper="Stetic.Wrapper.TextView"
- label="Text View" icon="textview.png" palette-category="widget"
- hexpandable="true" vexpandable="true" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Text View Properties">
- <property name="Editable" />
- <property name="CursorVisible" />
- <property name="Overwrite" />
- <property name="AcceptsTab" />
- <property name="Tabs" />
- <property name="Text" translatable="true" label="Text" glade-name="text"
- description="The initial text to display in the Text View"
- editor="Stetic.Editor.Text" />
- <property name="Justification" />
- <property name="WrapMode" />
- <property name="PixelsAboveLines" />
- <property name="PixelsBelowLines" />
- <property name="PixelsInsideWrap" />
- <property name="LeftMargin" />
- <property name="RightMargin" />
- <property name="Indent" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Text View Signals">
- <signal name="PasteClipboard" />
- <signal name="InsertAtCursor" />
- <signal name="CutClipboard" />
- <signal name="ToggleOverwrite" />
- <signal name="PageHorizontally" />
- <signal name="MoveFocus" />
- <signal name="CopyClipboard" />
- <signal name="DeleteFromCursor" />
- <signal name="PopulatePopup" />
- <signal name="MoveCursor" />
- <signal name="SetAnchor" />
- <signal name="ScrollAdjustmentsSet" />
- <signal name="Backspace" gtk-version="2.6"/>
- </itemgroup>
- </signals>
- </object>
-
-<!-- <object type="Gtk.ToggleToolButton,gtk-sharp" wrapper="Stetic.Wrapper.ToggleToolButton"
- label="Toolbar Toggle Button" icon="checkbutton.png" palette-category="toolbaritem">
- <itemgroups>
- <itemgroup label="Toolbar Toggle Button Properties">
- <property ref="Gtk.ToolButton.Icon" />
- <property ref="Gtk.ToolButton.Label" />
- <property ref="Gtk.ToolButton.UseUnderline" />
- <property name="Active" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- </itemgroups>
- <signals>
- <itemgroup label="Toggle Tool Button Signals">
- <signal name="Toggled" />
- <signal name="Clicked" />
- </itemgroup>
- <itemgroup ref="Gtk.Widget" />
- <itemgroup ref="Gtk.Container" />
- <itemgroup ref="Gtk.ToolItem" />
- </signals>
- </object>
--->
- <object type="Gtk.Toolbar,gtk-sharp" wrapper="Stetic.Wrapper.ActionToolbarWrapper"
- label="Toolbar" icon="toolbar.png" palette-category="widget" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Tool Bar Properties">
- <property name="Orientation" />
- <property name="ShowArrow" />
- <property name="Tooltips" />
- <property name="ButtonStyle" label="Toolbar style"/>
- <property name="ToolbarStyle" ignore-default="true" internal="true"/>
- <property name="IconSize" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Toolbar Signals">
- <signal name="OrientationChanged" />
- <signal name="PopupContextMenu" />
- <signal name="StyleChanged" />
- </itemgroup>
- </signals>
- </object>
-<!--
- <object type="Gtk.Toolbar+ToolbarChild,gtk-sharp" wrapper="Stetic.Wrapper.Toolbar+ToolbarChild">
- <itemgroups>
- <itemgroup label="Tool Bar Child Properties">
- <property name="Homogeneous" />
- <property name="Expand" />
- <property name="ToolItem" internal="true" />
- <property name="ToolItem.IsImportant" />
- <property name="ToolItem.VisibleHorizontal" />
- <property name="ToolItem.VisibleVertical" />
- </itemgroup>
- </itemgroups>
- </object>
--->
- <object type="Gtk.TreeView,gtk-sharp" wrapper="Stetic.Wrapper.TreeView"
- label="Tree View" icon="treeview.png" palette-category="widget"
- hexpandable="true" vexpandable="true" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Tree View Properties">
- <property name="EnableSearch" />
- <property name="FixedHeightMode" />
- <property name="HeadersVisible" />
- <property name="Reorderable" />
- <property name="RulesHint" />
- <property name="SearchColumn" min="-1"/>
- <property name="Model" />
- <property name="HeadersClickable" gtk-version="2.6" default="true"/>
- <property name="HoverSelection" gtk-version="2.6" />
- <property name="HoverExpand" gtk-version="2.6" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Tree View Signals">
- <signal name="CursorChanged" />
- <signal name="TestCollapseRow" />
- <signal name="RowActivated" />
- <signal name="ExpandCollapseCursorRow" />
- <signal name="ColumnsChanged" />
- <signal name="UnselectAll" />
- <signal name="SelectCursorParent" />
- <signal name="RowCollapsed" />
- <signal name="SelectAll" />
- <signal name="SelectCursorRow" />
- <signal name="TestExpandRow" />
- <signal name="StartInteractiveSearch" />
- <signal name="MoveCursor" />
- <signal name="RowExpanded" />
- <signal name="ToggleCursorRow" />
- <signal name="ScrollAdjustmentsSet" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.NodeView,gtk-sharp" wrapper="Stetic.Wrapper.TreeView"
- label="Node View" icon="treeview.png" palette-category="widget"
- hexpandable="true" vexpandable="true" base-type="Gtk.TreeView">
- </object>
-
- <object type="Gtk.IconView,gtk-sharp" wrapper="Stetic.Wrapper.IconView"
- label="Icon View" icon="iconview.png" palette-category="widget"
- hexpandable="true" vexpandable="true" base-type="Gtk.Container" gtk-version="2.6">
- <itemgroups>
- <itemgroup label="Icon View Properties">
- <property name="Columns" />
- <property name="ColumnSpacing" />
- <property name="ItemWidth" min="-1" />
- <property name="Margin" min="0" />
- <property name="Orientation" />
- <property name="Reorderable" gtk-version="2.8"/>
- <property name="RowSpacing" />
- <property name="SelectionMode" />
- <property name="Spacing" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Icon View Signals">
- <signal name="SelectionChanged" />
- <signal name="AllUnselected" />
- <signal name="ItemActivated" />
- <signal name="AllSelected" />
- <signal name="ToggleCursorItem" />
- <signal name="MoveCursor" />
- <signal name="ActivateCursorItem" />
- <signal name="SelectCursorItem" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.VBox,gtk-sharp" base-type="Gtk.Box"
- label="VBox" icon="vbox.png" palette-category="container">
- </object>
-
- <object type="Gtk.VButtonBox,gtk-sharp" base-type="Gtk.ButtonBox"
- label="VButtonBox" icon="vbuttonbox.png" palette-category="container"
- vexpandable="true">
- </object>
-
- <object type="Gtk.Viewport,gtk-sharp" wrapper="Stetic.Wrapper.Viewport"
- label="Viewport" icon="viewport.png" base-type="Gtk.Container">
- <itemgroups>
- <itemgroup label="Viewport Properties">
- <property name="ShadowType" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Viewport Signals">
- <signal name="ScrollAdjustmentsSet" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.VPaned,gtk-sharp" base-type="Gtk.Paned"
- label="VPaned" icon="vpaned.png" palette-category="container"
- vexpandable="true">
- </object>
-
- <object type="Gtk.VScale,gtk-sharp" wrapper="Stetic.Wrapper.VScale"
- label="Vertical Scale" icon="vscale.png" palette-category="widget"
- vexpandable="true" base-type="Gtk.Scale">
- </object>
-
- <object type="Gtk.VScrollbar,gtk-sharp" wrapper="Stetic.Wrapper.VScrollbar"
- label="Vertical Scrollbar" icon="vscrollbar.png" palette-category="widget"
- vexpandable="true" base-type="Gtk.Range">
- </object>
-
- <object type="Gtk.VSeparator,gtk-sharp" base-type="Gtk.Widget"
- label="Vertical Separator" icon="vseparator.png" palette-category="widget"
- vexpandable="true">
- </object>
-
- <object type="Stetic.Custom" cname="Custom" base-type="Gtk.Widget"
- label="Custom Widget" icon="custom.png" palette-category="widget">
- <itemgroups>
- <itemgroup label="Custom Widget Properties">
- <property name="CreationFunction" glade-name="creation_function" />
- <property name="LastModificationTime" glade-name="last_modification_time" internal="true" />
- <property name="String1" glade-name="string1" />
- <property name="String2" glade-name="string2" />
- <property name="Int1" glade-name="int1" />
- <property name="Int2" glade-name="int2" />
- </itemgroup>
- </itemgroups>
- </object>
-
-<!-- 2.6
- <object type="Gtk.AboutDialog,gtk-sharp" wrapper="Stetic.Wrapper.AboutDialog"
- label="About Dialog" icon="aboutdialog.png" palette-category="window">
- <itemgroups>
- <itemgroup label="About Dialog Properties">
- <property name="Name" translatable="true" />
- <property name="Version" translatable="true" />
- <property name="Logo" glade-override="true"
- editor="Stetic.Editor.ImageFile" />
- <property name="Comments" translatable="true" />
- <property name="Copyright" translatable="true" />
- <property name="Website" translatable="true" />
- <property name="WebsiteLabel" translatable="true" />
- <property name="Authors" translatable="true" />
- <property name="Documenters" translatable="true" />
- <property name="Artists" translatable="true" />
- <property name="TranslatorCredits" translatable="true" />
- <property name="License" translatable="true" editor="Stetic.Editor.Text" />
- <property ref="Gtk.Window.Icon" />
- <property ref="Gtk.Window.WindowPosition" />
- <property ref="Gtk.Window.Modal" />
- </itemgroup>
- <itemgroup ref="Gtk.Dialog.Misc" />
- <itemgroup ref="Gtk.Window.Size" />
- <itemgroup ref="Gtk.Widget" />
- </itemgroups>
- </object>
--->
-
- <object type="Gtk.ColorSelection,gtk-sharp" wrapper="Stetic.Wrapper.Widget"
- label="Color Selection" icon="colorselection.png" palette-category="widget"
- hexpandable="true" vexpandable="true" base-type="Gtk.Widget">
- <itemgroups>
- <itemgroup label="Color Selection Properties">
- <property name="HasPalette" />
- <property name="HasOpacityControl" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Color Selection Signals">
- <signal name="ColorChanged" />
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.ColorSelectionDialog,gtk-sharp" base-type="Gtk.Dialog" wrapper="Stetic.Wrapper.Dialog"
- label="Color Selection Dialog" icon="colorselectiondialog.png" palette-category="window">
- <internal-children>
- <property name="ColorSelection" glade-name="color_selection" />
- <property name="OkButton" glade-name="ok_button" />
- <property name="CancelButton" glade-name="cancel_button" />
- <property name="HelpButton" glade-name="help_button" />
- <property name="VBox" glade-name="vbox" />
- <property name="ActionArea" glade-name="action_area" />
- </internal-children>
- </object>
-
- <object type="Gtk.FileChooserWidget,gtk-sharp" wrapper="Stetic.Wrapper.Widget"
- label="File Chooser Widget" icon="fileselection.png" palette-category="widget"
- hexpandable="true" vexpandable="true" init-properties="Action" base-type="Gtk.Widget">
- <itemgroups>
- <itemgroup label="File Chooser Widget Properties">
- <property name="Action" />
- <property name="LocalOnly" />
- <property name="SelectMultiple">
- <disabled-if name="Action" value="Save" />
- <disabled-if name="Action" value="CreateFolder" />
- </property>
- <property name="ShowHidden" gtk-version="2.6"/>
- <property name="DoOverwriteConfirmation" gtk-version="2.8" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="File Chooser Widget Signals">
- <signal name="SelectionChanged" />
- <signal name="FileActivated" />
- <signal name="UpdatePreview" />
- <signal name="CurrentFolderChanged" />
- <signal name="ConfirmOverwrite" gtk-version="2.8"/>
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.FileChooserButton,gtk-sharp" wrapper="Stetic.Wrapper.Container" init-properties="Title Action"
- label="File Chooser Button" icon="fileselection.png" palette-category="widget"
- hexpandable="true" base-type="Gtk.Container" gtk-version="2.6">
- <itemgroups>
- <itemgroup label="File Chooser Button Properties">
- <property name="Title" translatable="true" />
- <property name="Action" />
- <property name="LocalOnly" />
- <property name="SelectMultiple">
- <disabled-if name="Action" value="Save" />
- <disabled-if name="Action" value="CreateFolder" />
- </property>
- <property name="WidthChars" min="-1"/>
- <property name="ShowHidden" gtk-version="2.6"/>
- <property name="DoOverwriteConfirmation" gtk-version="2.8" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="File Chooser Button Signals">
- <signal name="SelectionChanged" />
- <signal name="FileActivated" />
- <signal name="UpdatePreview" />
- <signal name="CurrentFolderChanged" />
- <signal name="ConfirmOverwrite" gtk-version="2.8"/>
- </itemgroup>
- </signals>
- </object>
-
- <object type="Gtk.FileChooserDialog,gtk-sharp" base-type="Gtk.Dialog"
- label="File Chooser Dialog" icon="fileselection.png" palette-category="window">
- <itemgroups>
- <itemgroup label="File Chooser Dialog Properties">
- <property name="Action" />
- <property name="LocalOnly" />
- <property name="SelectMultiple">
- <disabled-if name="Action" value="Save" />
- <disabled-if name="Action" value="CreateFolder" />
- </property>
- <property name="ShowHidden" gtk-version="2.6"/>
- <property name="DoOverwriteConfirmation" gtk-version="2.8" />
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="File Chooser Dialog Signals">
- <signal name="SelectionChanged" />
- <signal name="FileActivated" />
- <signal name="UpdatePreview" />
- <signal name="CurrentFolderChanged" />
- <signal name="ConfirmOverwrite" gtk-version="2.8"/>
- </itemgroup>
- </signals>
- <internal-children>
- <property name="VBox" glade-name="vbox" />
- <property name="ActionArea" glade-name="action_area" />
- </internal-children>
- </object>
-
- <object type="Gtk.FontSelection,gtk-sharp" wrapper="Stetic.Wrapper.Widget"
- label="Font Selection" icon="fontselection.png" palette-category="widget"
- hexpandable="true" vexpandable="true" base-type="Gtk.Widget">
- <itemgroups>
- <itemgroup label="Font Selection Properties">
- <property name="FontName" />
- <property name="PreviewText" translatable="true" />
- </itemgroup>
- </itemgroups>
- </object>
-
- <object type="Gtk.FontSelectionDialog,gtk-sharp" base-type="Gtk.Dialog" wrapper="Stetic.Wrapper.FontSelectionDialog"
- label="Font Selection Dialog" icon="fontselectiondialog.png" palette-category="window">
- <internal-children>
- <property name="VBox" glade-name="vbox" />
- <property name="ActionArea" glade-name="action_area" />
- <property name="FontSelection" glade-name="font_selection" />
- <property name="OkButton" glade-name="ok_button" />
- <property name="CancelButton" glade-name="cancel_button" />
- <property name="ApplyButton" glade-name="help_button" />
- </internal-children>
- </object>
-
- <object type="Stetic.ErrorWidget" wrapper="Stetic.ErrorWidgetWrapper">
- </object>
-
- <object type="Gtk.Action,gtk-sharp" label="Action" wrapper="Stetic.Wrapper.Action"
- init-properties="Name Label Tooltip StockId" >
- <itemgroups>
- <itemgroup label="Action Properties">
- <property name="Name" editor="Stetic.Editor.Identifier" min="1"/>
- <property name="Type" />
- <property name="Accelerator" editor="Stetic.Editor.Accelerator" />
- <property name="HideIfEmpty" />
- <property name="IsImportant" />
- <property name="Label" translatable="true"/>
- <property name="Sensitive" />
- <property name="ShortLabel" default="" translatable="true"/>
- <property name="StockId" editor="Stetic.Editor.StockItem"/>
- <property name="Tooltip" translatable="true"/>
- <property name="Visible" />
- <property name="VisibleHorizontal" />
- <property name="VisibleVertical" />
- <property name="VisibleOverflown" gtk-version="2.6"/>
- <property name="DrawAsRadio" label="Draw as radio">
- <invisible-if name="Type" value="Action" />
- </property>
- <property name="Active">
- <invisible-if name="Type" value="Action" />
- </property>
- <property name="Value">
- <invisible-if name="Type" value="Action" />
- <invisible-if name="Type" value="Toggle" />
- </property>
- <property name="Group" label="Group"
- description="The name of the radio action group that this action belongs to"
- editor="Stetic.Editor.GroupPicker">
- <invisible-if name="Type" value="Action" />
- <invisible-if name="Type" value="Toggle" />
- </property>
- </itemgroup>
- </itemgroups>
- <signals>
- <itemgroup label="Action Signals">
- <signal name="Activated" />
- <signal name="Changed" />
- <signal name="Toggled" />
- </itemgroup>
- </signals>
- </object>
-
-
-
- <enum type="Gdk.ExtensionMode,gdk-sharp">
- <value name="None" label="None"
- description="No extension events are desired" />
- <value name="All" label="All"
- description="All extension events are desired" />
- <value name="Cursor" label="Only if cursor displayed"
- description="Extension events are desired only if a cursor will be displayed for the device" />
- </enum>
-
- <enum type="Gdk.EventMask,gdk-sharp">
- <value name="ExposureMask" label="Expose"
- description="Receive expose events" />
- <value name="PointerMotionMask" label="All pointer motion"
- description="Receive all pointer motion events" />
- <value name="PointerMotionHintMask" label="Requested pointer motion"
- description="Receive pointer motion events when requested" />
- <value name="ButtonMotionMask" label="Pointer motion w/ any button"
- description="Receive pointer motion events while any button is pressed" />
- <value name="Button1MotionMask" label="Pointer motion w/ button 1"
- description="Receive pointer motion events while button 1 is pressed" />
- <value name="Button2MotionMask" label="Pointer motion w/ button 2"
- description="Receive pointer motion events while button 2 is pressed" />
- <value name="Button3MotionMask" label="Pointer motion w/ button 3"
- description="Receive pointer motion events while button 3 is pressed" />
- <value name="ButtonPressMask" label="Button press"
- description="Receive button press events" />
- <value name="ButtonReleaseMask" label="Button release"
- description="Receive button release events" />
- <value name="KeyPressMask" label="Key press"
- description="Receive key press events" />
- <value name="KeyReleaseMask" label="Key release"
- description="Receive key release events" />
- <value name="EnterNotifyMask" label="Window enter"
- description="Receive window enter events" />
- <value name="LeaveNotifyMask" label="Window leave"
- description="Receive window leave events" />
- <value name="FocusChangeMask" label="Focus change"
- description="Receive focus change events" />
- <value name="StructureMask" label="Window structure change"
- description="Receive events about window configuration change" />
- <value name="PropertyChangeMask" label="Property change"
- description="Receive property change events" />
- <value name="VisibilityNotifyMask" label="Visibility change"
- description="Receive visibility change events" />
- <value name="ProximityInMask" label="Proximity in"
- description="Receive proximity in events" />
- <value name="ProximityOutMask" label="Proximity out"
- description="Receive proximity out events" />
- <value name="SubstructureMask" label="Window substructure change"
- description="Receive events about window configuration changes of child windows" />
- <value name="ScrollMask" label="Scroll"
- description="Receive scroll events" />
- <value name="AllEventsMask" />
- </enum>
-
- <enum type="Gdk.Gravity,gdk-sharp">
- <value name="NorthWest" label="Northwest"
- description="The reference point is at the top left corner" />
- <value name="North" label="North"
- description="The reference point is at the middle of the top edge" />
- <value name="NorthEast" label="Northeast"
- description="The reference point is at the top right corner" />
- <value name="West" label="West"
- description="The reference point is at the middle of the left edge" />
- <value name="Center" label="Center"
- description="The reference point is at the center of the window" />
- <value name="East" label="East"
- description="The reference point is at the middle of the right edge" />
- <value name="SouthWest" label="Southwest"
- description="The reference point is at the lower left corner" />
- <value name="South" label="South"
- description="The reference point is at the middle of the lower edge" />
- <value name="SouthEast" label="Southeast"
- description="The reference point is at the lower right corner" />
- <value name="Static" label="Static"
- description="The reference point is at the top left corner of the window itself, ignoring window manager decorations" />
- </enum>
-
- <enum type="Gdk.WindowTypeHint,gdk-sharp">
- <value name="Normal" label="Normal"
- description="Normal toplevel window" />
- <value name="Dialog" label="Dialog"
- description="Dialog window" />
- <value name="Menu" label="Menu"
- description="Window used to implement a menu" />
- <value name="Toolbar" label="Toolbar"
- description="Window used to implement a toolbar" />
- <value name="Splashscreen" label="Splash screen"
- description="Window used to display a splash screen" />
- <value name="Utility" label="Utility"
- description="Utility windows which are not detached toolbars or dialogs" />
- <value name="Dock" label="Dock"
- description="Used for creating dock or panel windows" />
- <value name="Desktop" label="Desktop"
- description="Used for creating the desktop background window" />
- </enum>
-
- <enum type="Gtk.ArrowType,gtk-sharp">
- <value name="Up" label="Up"
- description="Up" />
- <value name="Down" label="Down"
- description="Down" />
- <value name="Left" label="Left"
- description="Left" />
- <value name="Right" label="Right"
- description="Right" />
- </enum>
-
- <enum type="Gtk.AttachOptions,gtk-sharp">
- <value name="Expand" label="Expand"
- description="The widget should expand to take up any extra space in its container that has been allocated" />
- <value name="Shrink" label="Shrink"
- description="The widget should shrink as and when possible" />
- <value name="Fill" label="Fill"
- description="The widget should fill the space allocated to it" />
- </enum>
-
- <enum type="Gtk.ButtonBoxStyle,gtk-sharp">
- <value name="DefaultStyle" label="Default"
- description="Default packing" />
- <value name="Spread" label="Spread"
- description="Buttons are evenly spread across the ButtonBox" />
- <value name="Edge" label="Edge"
- description="Buttons are placed at the edges of the ButtonBox" />
- <value name="Start" label="Start"
- description="Buttons are grouped towards the start (left or top) of the box" />
- <value name="End" label="End"
- description="Buttons are grouped toward the end (right or bottom) of the box" />
- </enum>
-
- <enum type="Gtk.ButtonsType,gtk-sharp">
- <value name="None" label="None"
- description="No buttons at all" />
- <value name="Ok" label="OK"
- description="an OK button" />
- <value name="Close" label="Close"
- description="a Close button" />
- <value name="Cancel" label="Cancel"
- description="a Cancel button" />
- <value name="YesNo" label="Yes / No"
- description="Yes and No buttons" />
- <value name="OkCancel" label="OK / Cancel"
- description="OK and Cancel buttons" />
- </enum>
-
- <enum type="Gtk.CornerType,gtk-sharp">
- <value name="TopLeft" label="Top Left"
- description="Place the scrollbars on the right and bottom of the contents" />
- <value name="BottomLeft" label="Bottom Left"
- description="Place the scrollbrs on the top and right of the contents" />
- <value name="TopRight" label="Top Right"
- description="Place the scrollbrs on the left and bottom of the contents" />
- <value name="BottomRight" label="Bottom Right"
- description="Place the scrollbrs on the top and left of the contents" />
- </enum>
-
- <enum type="Gtk.FileChooserAction,gtk-sharp">
- <value name="Open" label="Open"
- description="Open mode. The file chooser will only let the user pick an existing file." />
- <value name="Save" label="Save"
- description="Save mode. The file chooser will let the user pick an existing file, or type in a new filename." />
- <value name="SelectFolder" label="Select Folder"
- description="Open mode for selecting folders. The file chooser will let the user pick an existing folder." />
- <value name="CreateFolder" label="Create Folder"
- description="Mode for creating a new folder. The file chooser will let the user name an existing or new folder." />
- </enum>
-
- <enum type="Gtk.IconSize,gtk-sharp">
- <value name="Invalid" label="Invalid"
- description="Invalid" />
- <value name="Menu" label="Menu"
- description="The size of an icon an a menu item" />
- <value name="SmallToolbar" label="Small Toolbar"
- description="The size of an icon in a small toolbar" />
- <value name="LargeToolbar" label="Large Toolbar"
- description="The size of an icon in a large toolbar" />
- <value name="Button" label="Button"
- description="The size of an icon in a button" />
- <value name="Dnd" label="Drag and Drop"
- description="The size of an icon in a drag-and-drop operation" />
- <value name="Dialog" label="Dialog"
- description="The size of an icon in a dialog box" />
- </enum>
-
- <enum type="Gtk.Justification,gtk-sharp">
- <value name="Left" label="Left"
- description="The text is placed at the left edge of the label" />
- <value name="Right" label="Right"
- description="The text is placed at the right edge of the label" />
- <value name="Center" label="Center"
- description="The text is placed in the center of the label" />
- <value name="Fill" label="Fill"
- description="The text is distributed across the label" />
- </enum>
-
- <enum type="Gtk.MessageType,gtk-sharp">
- <value name="Info" label="Info"
- description="Informational message" />
- <value name="Warning" label="Warning"
- description="Non-fatal warning message" />
- <value name="Question" label="Question"
- description="Question requiring a choice" />
- <value name="Error" label="Error"
- description="Fatal error message" />
- </enum>
-
- <enum type="Gtk.Orientation,gtk-sharp">
- <value name="Horizontal" label="Horizontal"
- description="The widget is in horizontal orientation" />
- <value name="Vertical" label="Vertical"
- description="The widget is in vertical orientation" />
- </enum>
-
- <enum type="Gtk.PackType,gtk-sharp">
- <value name="Start" label="Start"
- description="The child is packed into the start (left or top) of the box" />
- <value name="End" label="End"
- description="The child is packed into the end (right or bottom) of the box" />
- </enum>
-
- <enum type="Gtk.PolicyType,gtk-sharp">
- <value name="Always" label="Always"
- description="The scrollbar is always visible" />
- <value name="Automatic" label="Automatic"
- description="The scrollbar will appear and disappear as necessary" />
- <value name="Never" label="Never"
- description="The scrollbar will never appear" />
- </enum>
-
- <enum type="Gtk.PositionType,gtk-sharp">
- <value name="Left" label="Left"
- description="The feature is at the left edge" />
- <value name="Right" label="Right"
- description="The feature is at the right edge" />
- <value name="Top" label="Top"
- description="The feature is at the top edge" />
- <value name="Bottom" label="Bottom"
- description="The feature is at the bottom edge" />
- </enum>
-
- <enum type="Gtk.ProgressBarOrientation,gtk-sharp">
- <value name="LeftToRight" label="Left to right"
- description="A horizontal progress bar growing from left to right" />
- <value name="RightToLeft" label="Right to left"
- description="A horizontal progress bar growing from right to left" />
- <value name="BottomToTop" label="Bottom to top"
- description="A vertical progress bar growing from bottom to top" />
- <value name="TopToBottom" label="Top to bottom"
- description="A vertical progress bar growing from top to bottom" />
- </enum>
-
- <enum type="Gtk.ReliefStyle,gtk-sharp">
- <value name="Normal" label="Normal"
- description="Draw a normal relief around the button" />
- <value name="Half" label="Half"
- description="Draw a half relief around the button" />
- <value name="None" label="None"
- description="Draw no relief around the button" />
- </enum>
-
- <enum type="Gtk.ResponseType,gtk-sharp">
- <value name="None" label="None"
- description="None" />
- <value name="Reject" label="Reject"
- description="Reject" />
- <value name="Accept" label="Accept"
- description="Accept" />
- <value name="DeleteEvent" />
- <value name="Ok" label="OK"
- description="OK" />
- <value name="Cancel" label="Cancel"
- description="Cancel" />
- <value name="Close" label="Close"
- description="Close" />
- <value name="Yes" label="Yes"
- description="Yes" />
- <value name="No" label="No"
- description="No" />
- <value name="Apply" label="Apply"
- description="Apply" />
- <value name="Help" label="Help"
- description="Help" />
- </enum>
-
- <enum type="Gtk.ShadowType,gtk-sharp">
- <value name="None" label="None"
- description="No outline" />
- <value name="In" label="In"
- description="The outline is bevelled inwards" />
- <value name="Out" label="Out"
- description="The outline is bevelled outwards, like a button" />
- <value name="EtchedIn" label="Etched in"
- description="" />
- <value name="EtchedOut" label="Etched out"
- description="" />
- </enum>
-
- <enum type="Gtk.SpinButtonUpdatePolicy,gtk-sharp">
- <value name="Always" label="Always"
- description="When refreshing the SpinButton, the value is always displayed" />
- <value name="IfValid" label="If valid"
- description="When refreshing the SpinButton, the value is only displayed if it is within the SpinButton's bounds" />
- </enum>
-
- <enum type="Stetic.Wrapper.ActionToolbarWrapper+ToolbarStyle">
- <value name="Default" label="System Default"
- description="Use the system default style" />
- <value name="Icons" label="Icons"
- description="Buttons display only icons in the toolbar" />
- <value name="Text" label="Text"
- description="Buttons display only text labels in the toolbar" />
- <value name="Both" label="Both"
- description="Buttons display text and icons in the toolbar" />
- <value name="BothHoriz" label="Both horizontally"
- description="Buttons display icons and text alongside each other, rather than vertically stacked" />
- </enum>
-
- <enum type="Gtk.UpdateType,gtk-sharp">
- <value name="Continuous" label="Continuous"
- description="The range value will change continuously as the slider is moved" />
- <value name="Discontinuous" label="Discontinuous"
- description="The range value will change only after the user releases the mouse button" />
- <value name="Delayed" label="Delayed"
- description="The range value will change if the user stops sliding the slider for a moment" />
- </enum>
-
- <enum type="Gtk.WindowPosition,gtk-sharp">
- <value name="None" label="Not specified"
- description="The window can be placed wherever the window manager chooses" />
- <value name="Center" label="Centered"
- description="The window should be placed in the center of the screen" />
- <value name="Mouse" label="At mouse position"
- description="The window should be placed at the current mouse position" />
- <value name="CenterAlways" label="Always centered"
- description="The window should be kept centered even if it changes size" />
- <value name="CenterOnParent" label="Centered on parent"
- description="Center the window on the parent window that it is transient for" />
- </enum>
-
- <enum type="Gtk.WindowType,gtk-sharp">
- <value name="Toplevel" label="Toplevel"
- description="A regular window or dialog" />
- <value name="Popup" label="Popup"
- description="A special window such as a tooltip" />
- </enum>
-
- <enum type="Gtk.WrapMode,gtk-sharp">
- <value name="None" label="None"
- description="Do not wrap lines; just make the text area wider" />
- <value name="Char" label="Character"
- description="Wrap text, breaking lines between any characters" />
- <value name="Word" label="Word"
- description="Wrap text, breaking lines between words" />
- <value name="WordChar" label="Word or Character"
- description="Wrap text, preferably breaking lines between words, but also breaking between characters if needed" />
- </enum>
-
- <enum type="Stetic.Wrapper.Button+ButtonType">
- <value name="StockItem" label="Stock button"
- description="Button displaying stock icon and text" />
- <value name="TextOnly" label="Text only"
- description="Button displaying text only" />
- <value name="TextAndIcon" label="Text and Icon"
- description="Button displaying an icon and application-provided text" />
- <value name="Custom" label="Custom"
- description="Button with entirely custom contents" />
- </enum>
-
- <enum type="Stetic.Wrapper.ToolButton+ButtonType">
- <value name="StockItem" label="Stock button"
- description="Button displaying stock icon and text" />
- <value name="TextAndIcon" label="Text and Icon"
- description="Button displaying an icon and application-provided text" />
- </enum>
-
- <enum type="Stetic.Wrapper.Action+ActionType">
- <value name="Action" label="Action"
- description="An normal action" />
- <value name="Toggle" label="Toggle Action"
- description="The action can be toggled between two states" />
- <value name="Radio" label="Radio Action"
- description="The action is controlled by a radio button" />
- </enum>
-
- <enum type="Pango.EllipsizeMode, pango-sharp">
- <value name="None" label="None"
- description="No ellipsization" />
- <value name="Start" label="Start"
- description="Omit characters at the start of the text" />
- <value name="Middle" label="Middle"
- description="Omit characters in the middle of the text" />
- <value name="End" label="End"
- description="Omit characters at the end of the text" />
- </enum>
-
- <enum type="Gtk.SelectionMode, gtk-sharp">
- <value name="None" label="None"
- description="Nothing can be selected" />
- <value name="Single" label="Single"
- description="Only one item can be selected at any given moment. Other items can have focus, but will not be marked as selected" />
- <value name="Browse" label="Browse"
- description="Only one item can be selected at any given moment. Any item currently having focus will be marked as selected" />
- <value name="Multiple" label="Multiple"
- description="Several items may be selected or unselected with a click or using the spacebar. The selection can be done using the Ctrl and Shift modifier keys in the usual way" />
- </enum>
-
- <enum type="Gtk.PackDirection, gtk-sharp">
- <value name="Ttb" label="Top to bottom"
- description="Top to bottom" />
- <value name="Btt" label="Bottom to top"
- description="Bottom to top" />
- <value name="Rtl" label="Right to left"
- description="Right to left" />
- <value name="Ltr" label="Left to right"
- description="Left to right" />
- </enum>
-
-</objects>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/COPIED b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/COPIED
deleted file mode 100644
index d693b81e9a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/COPIED
+++ /dev/null
@@ -1 +0,0 @@
-These were stolen from glade3 and are GPLed. \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/accellabel.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/accellabel.png
deleted file mode 100644
index 6ba42ba220..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/accellabel.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/actiongroup.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/actiongroup.png
deleted file mode 100644
index de43e0a5c4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/actiongroup.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/add-check-label.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/add-check-label.png
deleted file mode 100644
index cf3ad0c7d9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/add-check-label.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/add-menu.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/add-menu.png
deleted file mode 100644
index 19a98613c2..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/add-menu.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/alignment.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/alignment.png
deleted file mode 100644
index 5d7d311d96..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/alignment.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/arrow.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/arrow.png
deleted file mode 100644
index c9153b6f67..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/arrow.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/box-expand.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/box-expand.png
deleted file mode 100644
index 956903992b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/box-expand.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/box-fill.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/box-fill.png
deleted file mode 100644
index b0d67b54d7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/box-fill.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/button.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/button.png
deleted file mode 100644
index db816c21dc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/button.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/calendar.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/calendar.png
deleted file mode 100644
index c3cdf73ce8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/calendar.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-expand-h.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-expand-h.png
deleted file mode 100644
index 539a6f71b5..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-expand-h.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-expand-v.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-expand-v.png
deleted file mode 100644
index 658e63d82c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-expand-v.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-fill-h.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-fill-h.png
deleted file mode 100644
index 30162bf7ea..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-fill-h.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-fill-v.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-fill-v.png
deleted file mode 100644
index 95a9c1ab32..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/cell-fill-v.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/checkbutton.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/checkbutton.png
deleted file mode 100644
index 71565b0b1f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/checkbutton.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorbutton.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorbutton.png
deleted file mode 100644
index 281288d7cc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorbutton.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorselection.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorselection.png
deleted file mode 100644
index 281288d7cc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorselection.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorselectiondialog.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorselectiondialog.png
deleted file mode 100644
index 281288d7cc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/colorselectiondialog.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/combo.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/combo.png
deleted file mode 100644
index dab25d3c02..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/combo.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/comboentry.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/comboentry.png
deleted file mode 100644
index 13e02c820b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/comboentry.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/custom.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/custom.png
deleted file mode 100644
index df61924981..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/custom.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/dec-border.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/dec-border.png
deleted file mode 100644
index c5e5ae5b9e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/dec-border.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/dialog.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/dialog.png
deleted file mode 100644
index 6e81b2fd60..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/dialog.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/drawingarea.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/drawingarea.png
deleted file mode 100644
index ee65bba598..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/drawingarea.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/entry.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/entry.png
deleted file mode 100644
index d97bb9f378..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/entry.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/eventbox.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/eventbox.png
deleted file mode 100644
index c89d490375..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/eventbox.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/expander.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/expander.png
deleted file mode 100644
index 35d1c41d8b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/expander.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fileselection.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fileselection.png
deleted file mode 100644
index 03bda09484..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fileselection.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fixed.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fixed.png
deleted file mode 100644
index e6d5ece810..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fixed.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontbutton.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontbutton.png
deleted file mode 100644
index fe7a790ad4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontbutton.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontselection.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontselection.png
deleted file mode 100644
index fe7a790ad4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontselection.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontselectiondialog.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontselectiondialog.png
deleted file mode 100644
index 6936c47c05..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/fontselectiondialog.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/frame.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/frame.png
deleted file mode 100644
index 8a4c1f3a0e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/frame.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/globe-not.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/globe-not.png
deleted file mode 100644
index 3b1e292737..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/globe-not.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/globe.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/globe.png
deleted file mode 100644
index 2f25501e49..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/globe.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/handlebox.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/handlebox.png
deleted file mode 100644
index be064c6f51..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/handlebox.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hbox.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hbox.png
deleted file mode 100644
index 6971a3322b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hbox.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hbuttonbox.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hbuttonbox.png
deleted file mode 100644
index e38a4c5eed..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hbuttonbox.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hpaned.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hpaned.png
deleted file mode 100644
index e2847abd09..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hpaned.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hscale.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hscale.png
deleted file mode 100644
index 310e01cde2..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hscale.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hscrollbar.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hscrollbar.png
deleted file mode 100644
index 717b656220..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hscrollbar.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hseparator.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hseparator.png
deleted file mode 100644
index b32843abec..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/hseparator.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/iconview.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/iconview.png
deleted file mode 100644
index b875d3741b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/iconview.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/image.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/image.png
deleted file mode 100644
index 7f790e56b3..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/image.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/inc-border.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/inc-border.png
deleted file mode 100644
index 7f457c3f03..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/inc-border.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/label.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/label.png
deleted file mode 100644
index 9299f0fe24..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/label.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/menu.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/menu.png
deleted file mode 100644
index bcfdc9dd50..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/menu.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/menubar.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/menubar.png
deleted file mode 100644
index 14298a1b22..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/menubar.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/messagedialog.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/messagedialog.png
deleted file mode 100644
index a5330e2918..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/messagedialog.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/missing.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/missing.png
deleted file mode 100644
index 589da692bb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/missing.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/notebook.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/notebook.png
deleted file mode 100644
index 7d8f7067f4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/notebook.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/optionmenu.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/optionmenu.png
deleted file mode 100644
index d682108ad8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/optionmenu.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/progressbar.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/progressbar.png
deleted file mode 100644
index f48b47c485..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/progressbar.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/radiobutton.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/radiobutton.png
deleted file mode 100644
index c85d9492ad..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/radiobutton.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/remove-check-label.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/remove-check-label.png
deleted file mode 100644
index 25136e6df9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/remove-check-label.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/remove-menu.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/remove-menu.png
deleted file mode 100644
index 4777667d68..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/remove-menu.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/scrolledwindow.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/scrolledwindow.png
deleted file mode 100644
index 10323740f9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/scrolledwindow.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/spinbutton.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/spinbutton.png
deleted file mode 100644
index 9e98bb0ca3..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/spinbutton.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/statusbar.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/statusbar.png
deleted file mode 100644
index 26d8c2f7f8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/statusbar.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/table.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/table.png
deleted file mode 100644
index dc5886c9ea..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/table.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/textview.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/textview.png
deleted file mode 100644
index 642be08441..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/textview.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/togglebutton.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/togglebutton.png
deleted file mode 100644
index 62c13fad6e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/togglebutton.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/toolbar.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/toolbar.png
deleted file mode 100644
index 27b486a0fa..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/toolbar.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/treeview.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/treeview.png
deleted file mode 100644
index f6fd7d9d4e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/treeview.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vbox.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vbox.png
deleted file mode 100644
index fce6eb11e1..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vbox.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vbuttonbox.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vbuttonbox.png
deleted file mode 100644
index 68defd767e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vbuttonbox.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/viewport.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/viewport.png
deleted file mode 100644
index deccf531cb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/viewport.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vpaned.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vpaned.png
deleted file mode 100644
index 60628f46ef..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vpaned.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vscale.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vscale.png
deleted file mode 100644
index dbdc71e8ab..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vscale.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vscrollbar.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vscrollbar.png
deleted file mode 100644
index 09f8008ab1..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vscrollbar.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vseparator.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vseparator.png
deleted file mode 100644
index 6904fc2220..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/vseparator.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/widget.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/widget.png
deleted file mode 100644
index 7f5844bbfc..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/widget.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/window.png b/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/window.png
deleted file mode 100644
index 8f82250f04..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libstetic/wrapper/pixmaps/window.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionComponent.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionComponent.cs
deleted file mode 100644
index d5db89c4af..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionComponent.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public class ActionComponent: Component
- {
- Gdk.Pixbuf icon;
- string label;
-
- internal static Gdk.Pixbuf DefaultActionIcon;
-
- static ActionComponent ()
- {
- try {
- DefaultActionIcon = Gdk.Pixbuf.LoadFromResource ("action.png");
- } catch (Exception e) {
- Console.WriteLine ("Error while loading pixbuf 'action.png': " + e);
- }
- }
-
- public ActionComponent (Application owner, object backend, string name): base (owner, backend, name, owner.GetComponentType ("Gtk.Action"))
- {
- }
-
- public override string Name {
- get {
- if (name == null)
- name = ((Wrapper.Action)backend).Name;
- return name;
- }
- set {
- name = value;
- ((Wrapper.Action)backend).Name = value;
- }
- }
-
- public string Label {
- get {
- if (label == null)
- label = ((Wrapper.Action)backend).Label;
- return label;
- }
- set {
- label = value;
- ((Wrapper.Action)backend).Label = value;
- }
- }
-
- protected override void OnChanged ()
- {
- name = null;
- icon = null;
- label = null;
- base.OnChanged ();
- }
-
- public Gdk.Pixbuf Icon {
- get {
- if (icon == null) {
- byte[] data = app.Backend.GetActionIcon ((Wrapper.Action)backend);
- if (data == null)
- return DefaultActionIcon;
- else
- icon = new Gdk.Pixbuf (data);
- }
- return icon;
- }
- }
-
- public ActionGroupComponent ActionGroup {
- get { return (ActionGroupComponent) app.GetComponent (((Wrapper.Action)backend).ActionGroup, null, null); }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupComponent.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupComponent.cs
deleted file mode 100644
index 1b2a871d26..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupComponent.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-
-namespace Stetic
-{
- [Serializable]
- public class ActionGroupComponent: Component
- {
- public ActionGroupComponent (Application app, object backend, string name): base (app, backend, name, app.GetComponentType ("Gtk.ActionGroup"))
- {
- }
-
- public override string Name {
- get {
- if (name == null)
- name = ((Wrapper.ActionGroup)backend).Name;
- return name;
- }
- set {
- name = value;
- ((Wrapper.ActionGroup)backend).Name = value;
- }
- }
-
- public override bool GeneratePublic {
- get { return ((Wrapper.ActionGroup)backend).GeneratePublic; }
- set { ((Wrapper.ActionGroup)backend).GeneratePublic = value; }
- }
-
- protected override void OnChanged ()
- {
- name = null;
- base.OnChanged ();
- }
-
- public ActionComponent[] GetActions ()
- {
- Wrapper.ActionCollection acts = ((Wrapper.ActionGroup)backend).Actions;
-
- ArrayList comps = new ArrayList (acts.Count);
-
- for (int n=0; n<acts.Count; n++) {
- ActionComponent ac = (ActionComponent) app.GetComponent (acts[n], null, null);
- if (ac != null)
- comps.Add (ac);
- }
-
- return (ActionComponent[]) comps.ToArray (typeof(ActionComponent));
- }
-
- public override Component[] GetChildren ()
- {
- return GetActions ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupDesigner.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupDesigner.cs
deleted file mode 100644
index 473add6802..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupDesigner.cs
+++ /dev/null
@@ -1,278 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public class ActionGroupDesigner: Designer
- {
- ActionGroupEditSession editSession;
- ActionGroupDesignerFrontend frontend;
- Project project;
- string componentName;
- string actionGroupName;
- bool autoCommitChanges;
- WidgetDesigner relatedWidgetDesigner;
-
- public event EventHandler BindField;
- public event EventHandler ModifiedChanged;
- public event EventHandler RootComponentChanged;
- public event ComponentSignalEventHandler SignalAdded;
- public event ComponentSignalEventHandler SignalChanged;
-
- internal ActionGroupDesigner (Project project, string componentName, string actionGroupName, WidgetDesigner relatedWidgetDesigner, bool autoCommitChanges): base (project.App)
- {
- this.componentName = componentName;
- this.relatedWidgetDesigner = relatedWidgetDesigner;
-
- if (actionGroupName != null)
- this.actionGroupName = actionGroupName;
- this.autoCommitChanges = autoCommitChanges;
- this.project = project;
-
- frontend = new ActionGroupDesignerFrontend (this);
-
- CreateSession ();
- }
-
- internal override void SetActive ()
- {
- app.ActiveProject = project;
- }
-
- public override ProjectItemInfo ProjectItem {
- get { return project.GetWidget (RootComponent.Name); }
- }
-
- public Component RootComponent {
- get { return app.GetComponent (editSession.EditedActionGroup, null, null); }
- }
-
- public bool AllowActionBinding {
- get {
- return editSession != null && editSession.AllowActionBinding;
- }
- set {
- if (editSession != null)
- editSession.AllowActionBinding = value;
- }
- }
-
- public UndoQueue UndoQueue {
- get {
- if (relatedWidgetDesigner != null)
- return relatedWidgetDesigner.UndoQueue;
- else if (editSession != null)
- return editSession.UndoQueue;
- else
- return UndoQueue.Empty;
- }
- }
-
- public ActionComponent SelectedAction {
- get {
- if (editSession == null)
- return null;
- Wrapper.Action act;
- string an;
- editSession.GetSelectedAction (out act, out an);
- if (act != null)
- return (ActionComponent) app.GetComponent (act, an, null);
- else
- return null;
- }
- set {
- editSession.SetSelectedAction ((Wrapper.Action)value.Backend);
- }
- }
-
- public bool HasData {
- get { return editSession != null && editSession.HasData; }
- }
-
- public bool Modified {
- get { return editSession != null && editSession.Modified; }
- set {
- if (editSession != null)
- editSession.Modified = value;
- }
- }
-
- public string ActiveGroup {
- get {
- if (editSession == null)
- return null;
- return editSession.ActiveGroup;
- }
- set {
- if (editSession != null)
- editSession.ActiveGroup = value;
- }
- }
-
- public void Save ()
- {
- if (editSession != null) {
- editSession.Save ();
- if (!autoCommitChanges && componentName != null)
- componentName = editSession.ActiveGroup;
- }
- }
-
- public void CopySelection ()
- {
- if (editSession != null)
- editSession.CopySelection ();
- }
-
- public void CutSelection ()
- {
- if (editSession != null)
- editSession.CutSelection ();
- }
-
- public void PasteToSelection ()
- {
- if (editSession != null)
- editSession.PasteToSelection ();
- }
-
- public void DeleteSelection ()
- {
- if (editSession != null)
- editSession.DeleteSelection ();
- }
-
- protected override void OnCreatePlug (uint socketId)
- {
- editSession.CreateBackendWidgetPlug (socketId);
- }
-
- protected override void OnDestroyPlug (uint socketId)
- {
- editSession.DestroyBackendWidgetPlug ();
- }
-
- protected override Gtk.Widget OnCreateWidget ()
- {
- return editSession.Backend;
- }
-
- void CreateSession ()
- {
- try {
- if (actionGroupName != null)
- editSession = project.ProjectBackend.CreateGlobalActionGroupDesignerSession (frontend, actionGroupName, autoCommitChanges);
- else
- editSession = project.ProjectBackend.CreateLocalActionGroupDesignerSession (frontend, componentName, autoCommitChanges);
- ResetCustomWidget ();
- } catch (Exception ex) {
- editSession = null;
- Console.WriteLine (ex);
- AddCustomWidget (new Gtk.Label (ex.Message));
- }
- }
-
- protected override void OnDestroyed ()
- {
- frontend.disposed = true;
- System.Runtime.Remoting.RemotingServices.Disconnect (frontend);
- if (editSession != null)
- editSession.Dispose ();
- editSession = null;
- base.OnDestroyed ();
- }
-
- internal override void OnBackendChanged (ApplicationBackend oldBackend)
- {
- object[] sessionData = null;
-
- if (oldBackend != null) {
- if (!autoCommitChanges)
- sessionData = editSession.SaveState ();
- if (editSession != null)
- editSession.Dispose ();
- }
-
- CreateSession ();
-
- if (sessionData != null && editSession != null)
- editSession.RestoreState (sessionData);
-
- base.OnBackendChanged (oldBackend);
-
- if (RootComponentChanged != null)
- RootComponentChanged (this, EventArgs.Empty);
- }
-
- internal void NotifyBindField ()
- {
- if (BindField != null)
- BindField (this, EventArgs.Empty);
- }
-
- internal void NotifyModified ()
- {
- if (ModifiedChanged != null)
- ModifiedChanged (this, EventArgs.Empty);
- }
-
- internal void NotifySignalAdded (Wrapper.Action action, string name, Signal signal)
- {
- ActionComponent c = (ActionComponent) app.GetComponent (action, name, null);
- if (c != null && SignalAdded != null)
- SignalAdded (this, new ComponentSignalEventArgs (project, c, null, signal));
- }
-
- internal void NotifySignalChanged (Wrapper.Action action, string name, Signal oldSignal, Signal signal)
- {
- ActionComponent c = (ActionComponent) app.GetComponent (action, name, null);
- if (c != null && SignalChanged != null)
- SignalChanged (this, new ComponentSignalEventArgs (project, c, oldSignal, signal));
- }
- }
-
- internal class ActionGroupDesignerFrontend: MarshalByRefObject
- {
- ActionGroupDesigner designer;
- internal bool disposed;
-
- public ActionGroupDesignerFrontend (ActionGroupDesigner designer)
- {
- this.designer = designer;
- }
-
- public void NotifyBindField ()
- {
- Gtk.Application.Invoke (
- delegate { if (!disposed) designer.NotifyBindField (); }
- );
- }
-
- public void NotifyModified ()
- {
- Gtk.Application.Invoke (
- delegate { if (!disposed) designer.NotifyModified (); }
- );
- }
-
- public void NotifySignalAdded (Wrapper.Action action, string name, Signal signal)
- {
- Gtk.Application.Invoke (
- delegate { if (!disposed) designer.NotifySignalAdded (action, name, signal); }
- );
- }
-
- public void NotifySignalChanged (Wrapper.Action action, string name, Signal oldSignal, Signal signal)
- {
- Gtk.Application.Invoke (
- delegate { if (!disposed) designer.NotifySignalChanged (action, name, oldSignal, signal); }
- );
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupDesignerBackend.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupDesignerBackend.cs
deleted file mode 100644
index f5e562e12a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupDesignerBackend.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- internal class ActionGroupDesignerBackend: Gtk.VBox
- {
- Editor.ActionGroupEditor editor;
- ActionGroupToolbar toolbar;
- WidgetDesignerBackend groupDesign;
-
- internal ActionGroupDesignerBackend (WidgetDesignerBackend groupDesign, Editor.ActionGroupEditor editor, ActionGroupToolbar toolbar)
- {
- this.editor = editor;
- this.toolbar = toolbar;
- this.groupDesign = groupDesign;
-
- BorderWidth = 3;
- PackStart (toolbar, false, false, 0);
- PackStart (groupDesign, true, true, 3);
- }
-
- public Editor.ActionGroupEditor Editor {
- get { return editor; }
- }
-
- public ActionGroupToolbar Toolbar {
- get { return toolbar; }
- }
-
- public void UpdateObjectViewers ()
- {
- groupDesign.UpdateObjectViewers ();
- }
-
- public override void Dispose ()
- {
- this.editor = null;
- this.toolbar = null;
- this.groupDesign = null;
- base.Dispose ();
- }
-
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupEditSession.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupEditSession.cs
deleted file mode 100644
index c7900efe5d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupEditSession.cs
+++ /dev/null
@@ -1,355 +0,0 @@
-
-using System;
-using System.Xml;
-using System.Collections;
-
-namespace Stetic
-{
- internal class ActionGroupEditSession: MarshalByRefObject, IDisposable
- {
- ActionGroupDesignerBackend designer;
- Gtk.Plug plug;
- ActionGroupDesignerFrontend frontend;
- bool autoCommitChanges;
- string groupToEdit;
- string containerName;
- ProjectBackend project;
- bool modified;
- bool allowActionBinding;
- bool designerRequested;
- ActionGroupToolbar groupToolbar;
-
- Stetic.Wrapper.ActionGroup groupCopy;
- Stetic.Wrapper.ActionGroup group;
- Hashtable actionCopyMap = new Hashtable ();
-
- UndoRedoManager undoManager;
- UndoQueue undoQueue;
-
- public ActionGroupEditSession (ActionGroupDesignerFrontend frontend, ProjectBackend project, string containerName, string groupToEdit, bool autoCommitChanges)
- {
- this.groupToEdit = groupToEdit;
- this.containerName = containerName;
- this.frontend = frontend;
- this.project = project;
- this.autoCommitChanges = autoCommitChanges;
-
- if (groupToEdit != null) {
- group = project.ActionGroups [groupToEdit];
- if (group == null)
- throw new InvalidOperationException ("Unknown action group: " + groupToEdit);
- Load (group);
- undoManager = new UndoRedoManager ();
- undoQueue = new UndoQueue ();
- undoManager.UndoQueue = undoQueue;
- undoManager.RootObject = groupCopy;
-
- groupToolbar = new ActionGroupToolbar (frontend, groupCopy);
- }
- else {
- if (!autoCommitChanges)
- throw new System.NotSupportedException ();
-
- Stetic.Wrapper.Container container = project.GetTopLevelWrapper (containerName, true);
- groupToolbar = new ActionGroupToolbar (frontend, container.LocalActionGroups);
- }
-
- // Don't delay the creation of the designer because when used in combination with the
- // widget designer, change events are subscribed since the begining
-
- designer = UserInterface.CreateActionGroupDesigner (project, groupToolbar);
- designer.Editor.GroupModified += OnModified;
- designer.Toolbar.AllowActionBinding = allowActionBinding;
- designer.Destroyed += delegate { designer = null; Dispose (); };
- }
-
- public Wrapper.ActionGroup EditedActionGroup {
- get { return groupCopy; }
- }
-
- void Load (Stetic.Wrapper.ActionGroup group)
- {
- if (autoCommitChanges) {
- groupCopy = group;
- }
- else {
- actionCopyMap.Clear ();
-
- groupCopy = new Stetic.Wrapper.ActionGroup ();
- groupCopy.Name = group.Name;
-
- foreach (Stetic.Wrapper.Action action in group.Actions) {
- Stetic.Wrapper.Action dupaction = action.Clone ();
- groupCopy.Actions.Add (dupaction);
- actionCopyMap [dupaction] = action;
- }
- groupCopy.SignalAdded += new Stetic.SignalEventHandler (OnSignalAdded);
- groupCopy.SignalChanged += new Stetic.SignalChangedEventHandler (OnSignalChanged);
- }
- }
-
- public void Save ()
- {
- if (autoCommitChanges)
- return;
-
- if (group.Name != groupCopy.Name)
- group.Name = groupCopy.Name;
-
- foreach (Stetic.Wrapper.Action actionCopy in groupCopy.Actions) {
- Stetic.Wrapper.Action action = (Stetic.Wrapper.Action) actionCopyMap [actionCopy];
- if (action != null)
- action.CopyFrom (actionCopy);
- else {
- action = actionCopy.Clone ();
- actionCopyMap [actionCopy] = action;
- group.Actions.Add (action);
- }
- }
-
- ArrayList todelete = new ArrayList ();
- foreach (Stetic.Wrapper.Action actionCopy in actionCopyMap.Keys) {
- if (!groupCopy.Actions.Contains (actionCopy))
- todelete.Add (actionCopy);
- }
-
- foreach (Stetic.Wrapper.Action actionCopy in todelete) {
- Stetic.Wrapper.Action action = (Stetic.Wrapper.Action) actionCopyMap [actionCopy];
- group.Actions.Remove (action);
- actionCopyMap.Remove (actionCopy);
- }
- Modified = false;
- }
-
- public UndoQueue UndoQueue {
- get {
- if (undoQueue != null)
- return undoQueue;
- else
- return UndoQueue.Empty;
- }
- }
-
- public void CopySelection ()
- {
- if (designer != null)
- designer.Editor.Copy ();
- }
-
- public void CutSelection ()
- {
- if (designer != null)
- designer.Editor.Cut ();
- }
-
- public void PasteToSelection ()
- {
- if (designer != null)
- designer.Editor.Paste ();
- }
-
- public void DeleteSelection ()
- {
- if (designer != null)
- designer.Editor.Delete ();
- }
-
- void OnProjectReloaded (object s, EventArgs a)
- {
- // Called when the underlying project has changed. Object references need to be updated.
- if (autoCommitChanges) {
- if (designer != null) {
- if (groupToEdit != null) {
- groupToolbar.ActiveGroup = project.ActionGroups [groupToEdit];
- } else {
- Stetic.Wrapper.Container container = project.GetTopLevelWrapper (containerName, true);
- groupToolbar.ActionGroups = container.LocalActionGroups;
- }
- }
- } else {
- // We only need to remap the actions
- group = project.ActionGroups [groupToEdit];
- actionCopyMap.Clear ();
- foreach (Wrapper.Action dupac in groupCopy.Actions) {
- Wrapper.Action ac = group.GetAction (dupac.Name);
- if (ac != null)
- actionCopyMap [dupac] = ac;
- }
- }
- }
-
- void OnModified (object ob, EventArgs args)
- {
- modified = true;
- frontend.NotifyModified ();
- }
-
- public bool HasData {
- get {
- if (groupToEdit != null)
- return true;
- Stetic.Wrapper.Container container = project.GetTopLevelWrapper (containerName, true);
- return container.LocalActionGroups.Count > 0;
- }
- }
-
- public bool Modified {
- get { return modified; }
- set { modified = value; frontend.NotifyModified (); }
- }
-// public bool Modified {
-// get { return project.WasModified (); }
-// }
-
- public string ActiveGroup {
- get {
- if (designer != null) {
- Wrapper.ActionGroup grp = designer.Toolbar.ActiveGroup;
- if (grp != null)
- return grp.Name;
- }
- return null;
- }
- set {
- if (value != null || designer != null) {
- // No need to create the designer if the active group is being set to null.
- Wrapper.ActionGroup grp = Backend.Toolbar.ActionGroups [value];
- Backend.Toolbar.ActiveGroup = grp;
- }
- }
- }
-
- public void SetSelectedAction (Wrapper.Action action)
- {
- // No need to create the designer if the active action is being set to null.
- if (action != null || designer != null)
- Backend.Editor.SelectedAction = action;
- }
-
- public void GetSelectedAction (out Wrapper.Action action, out string name)
- {
- if (designer != null) {
- action = designer.Editor.SelectedAction;
- if (action != null)
- name = action.Name;
- else
- name = null;
- } else {
- action = null;
- name = null;
- }
- }
-
- public ActionGroupDesignerBackend Backend {
- get {
- designerRequested = true;
- return designer;
- }
- }
-
- [NoGuiDispatch]
- public void CreateBackendWidgetPlug (uint socketId)
- {
- Gdk.Threads.Enter ();
- plug = new Gtk.Plug (socketId);
- plug.Add (Backend);
- plug.Decorated = false;
- plug.ShowAll ();
- Gdk.Threads.Leave ();
- }
-
- public void DestroyBackendWidgetPlug ()
- {
- if (designer != null) {
- Gtk.Plug plug = (Gtk.Plug) designer.Parent;
- plug.Remove (designer);
- plug.Destroy ();
- }
- }
-
- public bool AllowActionBinding {
- get {
- return allowActionBinding;
- }
- set {
- allowActionBinding = value;
- if (designer != null)
- designer.Toolbar.AllowActionBinding = value;
- }
- }
-
- public void Dispose ()
- {
- if (designer != null) {
- designer.Editor.GroupModified -= OnModified;
- if (!designerRequested)
- designer.Destroy ();
- }
-
- project.ProjectReloaded -= OnProjectReloaded;
-
- if (plug != null) {
- plug.Destroy ();
- plug = null;
- }
-
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
-
- public object[] SaveState ()
- {
- if (autoCommitChanges)
- return null;
-
- XmlDocument doc = new XmlDocument ();
- doc.AppendChild (groupCopy.Write (new ObjectWriter (doc, FileFormat.Native)));
-
- Hashtable nameMap = new Hashtable ();
- foreach (DictionaryEntry e in actionCopyMap)
- nameMap [((Wrapper.Action)e.Key).Name] = ((Wrapper.Action)e.Value).Name;
-
- return new object[] { groupCopy.Name, nameMap, doc.OuterXml };
- }
-
- public void RestoreState (object[] data)
- {
- if (data == null)
- return;
-
- groupCopy = new Stetic.Wrapper.ActionGroup ();
- groupCopy.Name = (string) data [0];
-
- XmlDocument doc = new XmlDocument ();
- doc.LoadXml ((string) data [2]);
-
- // Create the map which links edited action with source actions
- actionCopyMap.Clear ();
- foreach (DictionaryEntry e in (Hashtable) data [1]) {
- Wrapper.Action dupaction = groupCopy.GetAction ((string)e.Key);
- Wrapper.Action action = group.GetAction ((string)e.Value);
- actionCopyMap [dupaction] = action;
- }
-
- groupCopy.SignalAdded += new Stetic.SignalEventHandler (OnSignalAdded);
- groupCopy.SignalChanged += new Stetic.SignalChangedEventHandler (OnSignalChanged);
- }
-
- void OnSignalAdded (object s, Stetic.SignalEventArgs a)
- {
- Wrapper.Action action = (Wrapper.Action) a.Wrapper;
- frontend.NotifySignalAdded (action, action.Name, a.Signal);
- }
-
- void OnSignalChanged (object s, Stetic.SignalChangedEventArgs a)
- {
- Wrapper.Action action = (Wrapper.Action) a.Wrapper;
- frontend.NotifySignalChanged (action, action.Name, a.OldSignal, a.Signal);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupToolbar.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupToolbar.cs
deleted file mode 100644
index c41601509c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ActionGroupToolbar.cs
+++ /dev/null
@@ -1,275 +0,0 @@
-
-using System;
-using System.Collections;
-using Stetic.Wrapper;
-using Mono.Unix;
-
-namespace Stetic
-{
- internal class ActionGroupToolbar: Gtk.Toolbar
- {
- Wrapper.ActionGroupCollection actionGroups;
- Gtk.ComboBox combo;
- bool updating;
- ActionGroup currentGroup;
- ArrayList internalButtons = new ArrayList ();
- bool singleGroupMode;
- bool allowBinding;
- ActionGroupDesignerFrontend frontend;
- Editor.ActionGroupEditor agroupEditor;
- Gtk.ToolButton addButton;
- Gtk.ToolButton removeButton;
-
- public event ActionGroupEventHandler ActiveGroupChanged;
- public event ActionGroupEventHandler ActiveGroupCreated;
-
- public ActionGroupToolbar (ActionGroupDesignerFrontend frontend, bool singleGroupMode)
- {
- Initialize (frontend, null, singleGroupMode);
- }
-
- public ActionGroupToolbar (ActionGroupDesignerFrontend frontend, Wrapper.ActionGroup actionGroup)
- {
- currentGroup = actionGroup;
- Initialize (frontend, null, true);
- }
-
- public ActionGroupToolbar (ActionGroupDesignerFrontend frontend, Wrapper.ActionGroupCollection actionGroups)
- {
- Initialize (frontend, actionGroups, false);
- }
-
- public bool AllowActionBinding {
- get { return allowBinding; }
- set { allowBinding = value; }
- }
-
- void Initialize (ActionGroupDesignerFrontend frontend, Wrapper.ActionGroupCollection actionGroups, bool singleGroupMode)
- {
- this.frontend = frontend;
- this.singleGroupMode = singleGroupMode;
- IconSize = Gtk.IconSize.SmallToolbar;
- Orientation = Gtk.Orientation.Horizontal;
- ToolbarStyle = Gtk.ToolbarStyle.BothHoriz;
-
- combo = Gtk.ComboBox.NewText ();
-
- if (!singleGroupMode) {
- combo.Changed += OnActiveChanged;
-
- Gtk.ToolItem comboItem = new Gtk.ToolItem ();
- Gtk.HBox cbox = new Gtk.HBox ();
- cbox.PackStart (new Gtk.Label (Catalog.GetString ("Action Group:") + " "), false, false, 3);
- cbox.PackStart (combo, true, true, 3);
- comboItem.Add (cbox);
- comboItem.ShowAll ();
- Insert (comboItem, -1);
- internalButtons.Add (comboItem);
-
- addButton = new Gtk.ToolButton (Gtk.Stock.Add);
- addButton.Clicked += OnAddGroup;
- Insert (addButton, -1);
- internalButtons.Add (addButton);
-
- removeButton = new Gtk.ToolButton (Gtk.Stock.Remove);
- removeButton.Clicked += OnRemoveGroup;
- Insert (removeButton, -1);
- internalButtons.Add (removeButton);
-
- ActionGroups = actionGroups;
-
- if (actionGroups != null && actionGroups.Count > 0)
- combo.Active = 0;
- } else {
- UpdateActionCommands (null);
- }
-
- ShowAll ();
- }
-
- public override void Dispose ()
- {
- if (combo == null)
- return;
-
- combo.Changed -= OnActiveChanged;
- combo = null;
- if (addButton != null) {
- addButton.Clicked -= OnAddGroup;
- removeButton.Clicked -= OnRemoveGroup;
- }
-
- if (agroupEditor != null) {
- agroupEditor.SelectionChanged -= OnEditorSelectionChanged;
- agroupEditor = null;
- }
-
- if (!singleGroupMode)
- ActionGroups = null;
- base.Dispose ();
- }
-
- public Wrapper.ActionGroupCollection ActionGroups {
- get { return actionGroups; }
- set {
- if (singleGroupMode)
- throw new InvalidOperationException ("ActionGroups can't be set in single group mode");
-
- if (actionGroups != null) {
- actionGroups.ActionGroupAdded -= OnCollectionChanged;
- actionGroups.ActionGroupRemoved -= OnCollectionChanged;
- actionGroups.ActionGroupChanged -= OnCollectionChanged;
- }
-
- this.actionGroups = value;
-
- if (actionGroups != null) {
- actionGroups.ActionGroupAdded += OnCollectionChanged;
- actionGroups.ActionGroupRemoved += OnCollectionChanged;
- actionGroups.ActionGroupChanged += OnCollectionChanged;
- }
- Refresh ();
- }
- }
-
- public void Bind (Editor.ActionGroupEditor agroupEditor)
- {
- this.agroupEditor = agroupEditor;
- agroupEditor.SelectionChanged += OnEditorSelectionChanged;
- agroupEditor.ActionGroup = ActiveGroup;
- }
-
- public void OnEditorSelectionChanged (object s, EventArgs a)
- {
- UpdateActionCommands (agroupEditor.SelectedAction);
- }
-
- public ActionGroup ActiveGroup {
- get {
- return currentGroup;
- }
- set {
- if (singleGroupMode) {
- currentGroup = value;
- UpdateActionCommands (null);
- NotifyActiveGroupChanged ();
- } else {
- int i = actionGroups.IndexOf (value);
- if (i != -1)
- combo.Active = i;
- }
- }
- }
-
- void Refresh ()
- {
- if (singleGroupMode || combo == null)
- return;
-
- while (combo.Model.IterNChildren () > 0)
- combo.RemoveText (0);
- if (actionGroups != null) {
- foreach (ActionGroup group in actionGroups)
- combo.AppendText (group.Name);
- }
- }
-
- void OnCollectionChanged (object s, ActionGroupEventArgs args)
- {
- // Avoid firing the selection change event if the selected
- // group is the same after the refresh
- ActionGroup oldGroup = currentGroup;
- updating = true;
-
- int i = combo.Active;
- Refresh ();
- if (actionGroups.Count == 0) {
- combo.Sensitive = false;
- currentGroup = null;
- }
- else {
- combo.Sensitive = true;
- if (i == -1)
- i = 0;
- if (i < actionGroups.Count)
- combo.Active = i;
- else
- combo.Active = actionGroups.Count - 1;
- currentGroup = (ActionGroup) actionGroups [combo.Active];
- }
- updating = false;
- if (currentGroup != oldGroup)
- OnActiveChanged (null, null);
- frontend.NotifyModified ();
- }
-
- void OnAddGroup (object s, EventArgs args)
- {
- ActionGroup group = new ActionGroup ();
- group.Name = Catalog.GetString ("New Action Group");
- actionGroups.Add (group);
- combo.Active = actionGroups.Count - 1;
- if (ActiveGroupCreated != null)
- ActiveGroupCreated (this, new ActionGroupEventArgs (ActiveGroup));
-
- if (agroupEditor != null)
- agroupEditor.StartEditing ();
- }
-
- void OnRemoveGroup (object s, EventArgs args)
- {
- if (combo.Active != -1)
- actionGroups.RemoveAt (combo.Active);
- }
-
- void OnActiveChanged (object s, EventArgs args)
- {
- if (!updating) {
- UpdateActionCommands (null);
- if (combo.Active != -1)
- currentGroup = (ActionGroup) actionGroups [combo.Active];
- else
- currentGroup = null;
- NotifyActiveGroupChanged ();
- }
- }
-
- void NotifyActiveGroupChanged ()
- {
- if (agroupEditor != null)
- agroupEditor.ActionGroup = ActiveGroup;
- if (ActiveGroupChanged != null)
- ActiveGroupChanged (this, new ActionGroupEventArgs (ActiveGroup));
- }
-
- void UpdateActionCommands (Wrapper.Action action)
- {
- foreach (Gtk.Widget w in Children) {
- if (!internalButtons.Contains (w)) {
- Remove (w);
- w.Destroy ();
- }
- }
- AddActionCommands (action);
-
- if (internalButtons.Count > 0 && internalButtons.Count != Children.Length) {
- Insert (new Gtk.SeparatorToolItem (), internalButtons.Count);
- }
- ShowAll ();
- }
-
- protected virtual void AddActionCommands (Wrapper.Action action)
- {
- if (allowBinding) {
- Gtk.ToolButton bindButton = new Gtk.ToolButton (null, Catalog.GetString ("Bind to Field"));
- bindButton.IsImportant = true;
- bindButton.Show ();
- Insert (bindButton, -1);
- if (action == null)
- bindButton.Sensitive = false;
-
- bindButton.Clicked += delegate { frontend.NotifyBindField (); };
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Application.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Application.cs
deleted file mode 100644
index afe4a3a00e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Application.cs
+++ /dev/null
@@ -1,584 +0,0 @@
-
-using System;
-using System.Threading;
-using System.Collections;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using System.IO;
-using System.Xml;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting;
-using System.Runtime.Remoting.Channels;
-using System.Runtime.Remoting.Channels.Tcp;
-using System.Diagnostics;
-using Mono.Remoting.Channels.Unix;
-using Mono.Cecil;
-
-namespace Stetic
-{
- public enum IsolationMode
- {
- None,
- ProcessTcp,
- ProcessUnix
- }
-
- public delegate string AssemblyResolverCallback (string assemblyName);
-
- public static class ApplicationFactory {
-
- public static Application CreateApplication (IsolationMode mode)
- {
- switch (mode) {
- case IsolationMode.None:
- return new LocalApplication ();
- case IsolationMode.ProcessTcp:
- case IsolationMode.ProcessUnix:
- return new IsolatedApplication (mode);
- default:
- throw new ArgumentException ("mode");
- }
- }
- }
-
- internal class IsolatedApplication : Application {
-
- string channelId;
- ApplicationBackendController backendController;
-
- string RegisterRemotingChannel (IsolationMode mode)
- {
- string remotingChannel;
- if (mode == IsolationMode.ProcessTcp) {
- remotingChannel = "tcp";
- IChannel ch = ChannelServices.GetChannel ("tcp");
- if (ch == null) {
- ChannelServices.RegisterChannel (new TcpChannel (0), false);
- }
- } else {
- remotingChannel = "unix";
- IChannel ch = ChannelServices.GetChannel ("unix");
- if (ch == null) {
- string unixRemotingFile = Path.GetTempFileName ();
- ChannelServices.RegisterChannel (new UnixChannel (unixRemotingFile), false);
- }
- }
- return remotingChannel;
- }
-
- public IsolatedApplication (IsolationMode mode)
- {
- if (mode == IsolationMode.None)
- throw new ArgumentException ("mode");
- channelId = RegisterRemotingChannel (mode);
- backendController = new ApplicationBackendController (this, channelId);
- backendController.StartBackend ();
- OnBackendChanged (false);
- }
-
- public override void Dispose ()
- {
- base.Dispose ();
- backendController.StopBackend (true);
- }
-
- public event BackendChangingHandler BackendChanging;
- public event BackendChangedHandler BackendChanged;
-
- void OnNewBackendStarted (object ob, EventArgs args)
- {
- OnBackendChanging ();
- ApplicationBackendController oldBackend = backendController;
- backendController = (ApplicationBackendController) ob;
- OnBackendChanged (true);
- oldBackend.StopBackend (false);
- }
-
- void OnBackendStopped (object ob, EventArgs args)
- {
- // The backend process crashed, try to restart it
- Backend = null;
- backendController = new ApplicationBackendController (this, channelId);
- backendController.StartBackend ();
- OnBackendChanged (true);
- }
-
- void OnBackendChanged (bool notify)
- {
- ApplicationBackend oldBackend = Backend;
-
- Backend = backendController.Backend;
- backendController.Stopped += OnBackendStopped;
- UpdateWidgetLibraries (false, false);
- ClearCollections ();
- if (notify && BackendChanged != null)
- BackendChanged (oldBackend);
-
- Backend.ActiveProject = ActiveProject != null ? ActiveProject.ProjectBackend : null;
- }
-
- void OnBackendChanging ()
- {
- Backend.GlobalWidgetLibraries = widgetLibraries;
- if (BackendChanging != null)
- BackendChanging ();
- }
-
- internal override void RestartBackend ()
- {
- // The backend process needs to be restarted.
- // This is done in background.
-
- ThreadPool.QueueUserWorkItem (delegate {
- try {
- // Start the new backend
- ApplicationBackendController newController = new ApplicationBackendController (this, channelId);
- newController.StartBackend ();
- Gtk.Application.Invoke (newController, EventArgs.Empty, OnNewBackendStarted);
- } catch {
- // FIXME: show an error message
- }
- });
- }
-
- internal override ComponentType CreateComponentType (string typeName)
- {
- string desc = null, className = null, category = null, targetGtkVersion = null, library = null;
- Gdk.Pixbuf px = null;
-
- byte[] icon;
-
- if (Backend.GetClassDescriptorInfo (typeName, out desc, out className, out category, out targetGtkVersion, out library, out icon) && icon != null)
- px = new Gdk.Pixbuf (icon);
-
- if (px == null)
- px = ComponentType.Unknown.Icon;
-
- if (desc == null)
- desc = typeName;
-
- return new ComponentType (this, typeName, desc, className, category, targetGtkVersion, library, px);
- }
- }
-
- internal class LocalApplication : Application {
-
- public LocalApplication ()
- {
- Backend = new ApplicationBackend (this);
- }
-
- public override void Dispose ()
- {
- base.Dispose ();
- Backend.Dispose ();
- }
-
- internal override ComponentType CreateComponentType (string typeName)
- {
- ClassDescriptor cls = Registry.LookupClassByName (typeName);
- if (cls == null)
- return null;
-
- return new ComponentType (this, typeName, cls.Label, cls.WrappedTypeName, cls.Category, cls.TargetGtkVersion, cls.Library.Name, cls.Icon);
- }
- }
-
- public abstract class Application : MarshalByRefObject, IDisposable {
-
- ApplicationBackend backend;
-
- Hashtable components = new Hashtable ();
- Hashtable types = new Hashtable ();
- internal ArrayList widgetLibraries = new ArrayList ();
- ArrayList projects = new ArrayList ();
- Project activeProject;
- Designer activeDesigner;
-
- WidgetPropertyTree propertiesWidget;
- Palette paletteWidget;
- WidgetTree projectWidget;
- SignalsEditor signalsWidget;
- bool allowInProcLibraries = true;
- bool disposed;
-
- public AssemblyResolverCallback WidgetLibraryResolver {
- get { return Backend.WidgetLibraryResolver; }
- set { Backend.WidgetLibraryResolver = value; }
- }
-
- public MimeResolverDelegate MimeResolver {
- set { Backend.MimeResolver = value; }
- }
-
- public Editor.ShowUrlDelegate ShowUrl {
- set { Backend.ShowUrl = value; }
- }
-
- public bool ShowNonContainerWarning {
- get { return Backend.ShowNonContainerWarning; }
- set { Backend.ShowNonContainerWarning = value; }
- }
-
- // Loads the libraries registered in the projects or in the application.
- // It will reload the libraries if they have changed. Libraries won't be
- // unloaded unless forceUnload is set to true
- public void UpdateWidgetLibraries (bool forceUnload)
- {
- UpdateWidgetLibraries (true, forceUnload);
- }
-
- internal virtual void RestartBackend ()
- {
- }
-
- protected void ClearCollections ()
- {
- lock (types) {
- types.Clear ();
- }
-
- Component[] comps;
- lock (components) {
- // All components should have been cleared by the backend,
- // just make sure it did
- comps = new Component [components.Count];
- components.Values.CopyTo (comps, 0);
- components.Clear ();
- }
-
- foreach (Component c in comps) {
- c.Dispose ();
- }
- }
-
- internal void UpdateWidgetLibraries (bool allowBackendRestart, bool forceUnload)
- {
- // Collect libraries from the project and from the application
-
- ArrayList assemblies = new ArrayList ();
- assemblies.AddRange (widgetLibraries);
-
- ArrayList projectBackends = new ArrayList ();
- foreach (Project p in projects)
- if (p.IsBackendLoaded)
- projectBackends.Add (p.ProjectBackend);
-
- if (!Backend.UpdateLibraries (assemblies, projectBackends, allowBackendRestart, forceUnload))
- RestartBackend ();
- }
-
- public virtual void Dispose ()
- {
- if (disposed)
- return;
-
- disposed = true;
- ClearCollections ();
- ArrayList copy = (ArrayList) projects.Clone ();
- foreach (Project p in copy)
- p.Dispose ();
- if (propertiesWidget != null)
- propertiesWidget.Destroy ();
- if (paletteWidget != null)
- paletteWidget.Destroy ();
- if (projectWidget != null)
- projectWidget.Destroy ();
- if (signalsWidget != null)
- signalsWidget.Destroy ();
- widgetLibraries.Clear ();
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
-
- internal ApplicationBackend Backend {
- get { return backend; }
- set { backend = value; }
- }
-
- void ProjectDisposed (object sender, EventArgs args)
- {
- projects.Remove (sender as Project);
- if (!disposed)
- UpdateWidgetLibraries (false, false);
- }
-
-// public Project LoadProject (string path, IProjectDesignInfo info)
-// {
-// Project p = new Project (this, info);
-// p.Load (path);
-// projects.Add (p);
-// p.Disposed += ProjectDisposed;
-// return p;
-// }
-
- public Project CreateProject (IProjectDesignInfo info)
- {
- Project p = new Project (this, info);
- projects.Add (p);
- p.Disposed += ProjectDisposed;
- return p;
- }
-
- public ComponentType[] GetComponentTypes (string fileName)
- {
- if (IsWidgetLibrary (fileName))
- return CecilWidgetLibrary.GetComponentTypes (this, fileName).ToArray ();
- else
- return new ComponentType [0];
- }
-
- public void AddWidgetLibrary (string assemblyPath)
- {
- if (!widgetLibraries.Contains (assemblyPath)) {
- widgetLibraries.Add (assemblyPath);
- Backend.GlobalWidgetLibraries = widgetLibraries;
- UpdateWidgetLibraries (false, false);
- }
- }
-
- public void RemoveWidgetLibrary (string assemblyPath)
- {
- widgetLibraries.Remove (assemblyPath);
- Backend.GlobalWidgetLibraries = widgetLibraries;
- UpdateWidgetLibraries (false, false);
- }
-
- public string[] GetWidgetLibraries ()
- {
- return (string[]) widgetLibraries.ToArray (typeof(string));
- }
-
- public bool IsWidgetLibrary (string assemblyRef)
- {
- AssemblyResolver resolver = new AssemblyResolver (Backend);
- return InternalIsWidgetLibrary (resolver, assemblyRef);
- }
-
- internal static bool InternalIsWidgetLibrary (AssemblyResolver resolver, string assemblyRef)
- {
- string path;
-
- if (assemblyRef.EndsWith (".dll") || assemblyRef.EndsWith (".exe")) {
- if (!File.Exists (assemblyRef))
- return false;
- path = assemblyRef;
- }
- else {
- path = resolver.Resolve (assemblyRef, null);
- if (path == null)
- return false;
- }
-
- return CecilWidgetLibrary.IsWidgetLibrary (path);
- }
-
- public CodeGenerationResult GenerateProjectCode (string file, string namespaceName, CodeDomProvider provider, GenerationOptions options, params Project[] projects)
- {
- ArrayList files = new ArrayList ();
- CodeGenerationResult res = GenerateProjectCode (options, projects);
-
- string basePath = Path.GetDirectoryName (file);
- string ext = Path.GetExtension (file);
-
- foreach (SteticCompilationUnit unit in res.Units) {
- string fname;
- if (unit.Name.Length == 0)
- fname = file;
- else
- fname = Path.Combine (basePath, unit.Name) + ext;
- files.Add (fname);
- unit.Name = fname;
- StreamWriter fileStream = new StreamWriter (fname);
- try {
- provider.GenerateCodeFromCompileUnit (unit, fileStream, new CodeGeneratorOptions ());
- } finally {
- fileStream.Close ();
- }
- }
- return res;
- }
-
- public CodeGenerationResult GenerateProjectCode (GenerationOptions options, params Project[] projects)
- {
- ProjectBackend[] pbs = new ProjectBackend [projects.Length];
- for (int n=0; n<projects.Length; n++)
- pbs [n] = projects [n].ProjectBackend;
-
- return Backend.GenerateProjectCode (options, pbs);
- }
-
- public Designer ActiveDesigner {
- get {
- return activeDesigner;
- }
- set {
- if (activeDesigner != value) {
- activeDesigner = value;
- if (activeDesigner != null)
- activeDesigner.SetActive ();
- else
- ActiveProject = null;
- }
- }
- }
-
- internal Project ActiveProject {
- get { return activeProject; }
- set {
- activeProject = value;
- Backend.ActiveProject = value != null ? value.ProjectBackend : null;
- Backend.SetActiveDesignSession (null);
- }
- }
-
- internal void SetActiveDesignSession (Project p, WidgetEditSession session)
- {
- activeProject = p;
- Backend.ActiveProject = p != null ? p.ProjectBackend : null;
- Backend.SetActiveDesignSession (session);
- }
-
- public WidgetPropertyTree PropertiesWidget {
- get {
- if (propertiesWidget == null) {
- propertiesWidget = new WidgetPropertyTree (this);
- propertiesWidget.Destroyed += delegate { propertiesWidget = null; };
- }
- return propertiesWidget;
- }
- }
-
- public Palette PaletteWidget {
- get {
- if (paletteWidget == null) {
- paletteWidget = new Palette (this);
- paletteWidget.Destroyed += delegate { paletteWidget = null; };
- }
- return paletteWidget;
- }
- }
-
- public WidgetTree WidgetTreeWidget {
- get {
- if (projectWidget == null) {
- projectWidget = new WidgetTree (this);
- projectWidget.Destroyed += delegate { projectWidget = null; };
- }
- return projectWidget;
- }
- }
-
- public SignalsEditor SignalsWidget {
- get {
- if (signalsWidget == null) {
- signalsWidget = new SignalsEditor (this);
- signalsWidget.Destroyed += delegate { signalsWidget = null; };
- }
- return signalsWidget;
- }
- }
-
- public bool AllowInProcLibraries {
- get { return allowInProcLibraries; }
- set {
- allowInProcLibraries = value;
- if (backend != null)
- backend.AllowInProcLibraries = value;
- }
- }
-
- internal void NotifyLibraryUnloaded (string name)
- {
- // Remove cached types from the unloaded library
- ArrayList toDelete = new ArrayList ();
- lock (types) {
- foreach (ComponentType ct in types.Values) {
- if (ct.Library == name)
- toDelete.Add (ct.Name);
- }
- foreach (string s in toDelete)
- types.Remove (s);
- }
- }
-
- internal abstract ComponentType CreateComponentType (string typeName);
-
- internal ComponentType GetComponentType (string typeName)
- {
- lock (types) {
- ComponentType t = (ComponentType) types [typeName];
- if (t != null) return t;
-
- if (typeName == "Gtk.Action" || typeName == "Gtk.ActionGroup") {
- t = new ComponentType (this, typeName, "", typeName, "Actions", "2.4", null, ComponentType.Unknown.Icon);
- types [typeName] = t;
- return t;
- }
-
- t = CreateComponentType (typeName);
- types [typeName] = t;
- return t;
- }
- }
-
- internal Component GetComponent (object cbackend, string name, string type)
- {
- try {
- lock (components) {
- if (cbackend == null)
- return null;
-
- Component c = (Component) components [cbackend];
- if (c != null)
- return c;
-
- // If the remote object is already disposed, don't try to create a
- // local component.
- if (cbackend is ObjectWrapper && ((ObjectWrapper)cbackend).IsDisposed)
- return null;
-
- if (cbackend is Wrapper.Action) {
- c = new ActionComponent (this, cbackend, name);
- ((ObjectWrapper)cbackend).Frontend = c;
- } else if (cbackend is Wrapper.ActionGroup) {
- c = new ActionGroupComponent (this, cbackend, name);
- ((Wrapper.ActionGroup)cbackend).Frontend = c;
- } else if (cbackend is ObjectWrapper) {
- c = new WidgetComponent (this, cbackend, name, type != null ? GetComponentType (type) : null);
- ((ObjectWrapper)cbackend).Frontend = c;
- } else if (cbackend == null)
- throw new System.ArgumentNullException ("cbackend");
- else
- throw new System.InvalidOperationException ("Invalid component type: " + cbackend.GetType ());
-
- components [cbackend] = c;
- return c;
- }
- }
- catch (System.Runtime.Remoting.RemotingException)
- {
- // There may be a remoting exception if the remote wrapper
- // has already been disconnected when trying to create the
- // component frontend. This may happen since calls are
- // dispatched in the GUI thread, so they may be delayed.
- return null;
- }
- }
-
- internal void DisposeComponent (Component c)
- {
- lock (components) {
- components.Remove (c.Backend);
- }
- }
- }
-
- internal delegate void BackendChangingHandler ();
- internal delegate void BackendChangedHandler (ApplicationBackend oldBackend);
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ApplicationBackend.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ApplicationBackend.cs
deleted file mode 100644
index eb738d5642..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ApplicationBackend.cs
+++ /dev/null
@@ -1,653 +0,0 @@
-
-using System;
-using System.IO;
-using System.Collections;
-using System.Collections.Generic;
-using System.CodeDom;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting;
-using System.Runtime.Remoting.Channels;
-using System.Runtime.Remoting.Channels.Tcp;
-using Mono.Remoting.Channels.Unix;
-
-namespace Stetic
-{
- internal class ApplicationBackend: MarshalByRefObject, IDisposable, IObjectViewer
- {
- PaletteBackend paletteWidget;
- WidgetPropertyTreeBackend propertiesWidget;
- SignalsEditorEditSession signalsWidget;
- ProjectViewBackend projectWidget;
- ArrayList globalWidgetLibraries = new ArrayList ();
- AssemblyResolverCallback widgetLibraryResolver;
- object targetViewerObject;
- bool allowInProcLibraries = true;
- Application appFrontend;
- string coreLibrary;
-
- ProjectBackend activeProject;
- WidgetEditSession activeDesignSession;
- static ApplicationBackendController controller;
-
- public ApplicationBackend (Application app)
- {
- appFrontend = app;
- coreLibrary = Path.GetFullPath (typeof(Registry).Assembly.Location);
- Registry.Initialize (new AssemblyWidgetLibrary (coreLibrary, typeof(Registry).Assembly));
-
- WidgetDesignerBackend.DefaultObjectViewer = this;
- }
-
- public static void Main ()
- {
- Gdk.Threads.Init ();
- Gtk.Application.Init ();
-
- System.Threading.Thread.CurrentThread.Name = "gui-thread";
-
- // Read the remoting channel to use
-
- string channel = Console.In.ReadLine ();
-
- IServerChannelSinkProvider formatterSink = new BinaryServerFormatterSinkProvider ();
- formatterSink.Next = new GuiDispatchServerSinkProvider ();
-
- string unixPath = null;
- if (channel == "unix") {
- unixPath = System.IO.Path.GetTempFileName ();
- Hashtable props = new Hashtable ();
- props ["path"] = unixPath;
- props ["name"] = "__internal_unix";
- ChannelServices.RegisterChannel (new UnixChannel (props, null, formatterSink), false);
- } else {
- Hashtable props = new Hashtable ();
- props ["port"] = 0;
- props ["name"] = "__internal_tcp";
- ChannelServices.RegisterChannel (new TcpChannel (props, null, formatterSink), false);
- }
-
- // Read the reference to the application
-
- string sref = Console.In.ReadLine ();
- byte[] data = Convert.FromBase64String (sref);
- MemoryStream ms = new MemoryStream (data);
- BinaryFormatter bf = new BinaryFormatter ();
-
- controller = (ApplicationBackendController) bf.Deserialize (ms);
- ApplicationBackend backend = new ApplicationBackend (controller.Application);
-
- controller.Connect (backend);
-
- Gdk.Threads.Enter ();
- Gtk.Application.Run ();
- Gdk.Threads.Leave ();
-
- controller.Disconnect (backend);
- }
-
- public virtual void Dispose ()
- {
- if (controller != null) {
- Gtk.Application.Quit ();
- }
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
-
- public AssemblyResolverCallback WidgetLibraryResolver {
- get { return widgetLibraryResolver; }
- set { widgetLibraryResolver = value; }
- }
-
- public MimeResolverDelegate MimeResolver {
- set { ResourceInfo.MimeResolver = value; }
- }
-
- public Editor.ShowUrlDelegate ShowUrl {
- set { Editor.NonContainerWarningDialog.ShowUrl = value; }
- }
-
- public bool ShowNonContainerWarning {
- get { return Wrapper.Container.ShowNonContainerWarning; }
- set { Wrapper.Container.ShowNonContainerWarning = value; }
- }
-
- public ProjectBackend LoadProject (string path)
- {
- ProjectBackend p = new ProjectBackend (this);
-
- if (System.IO.Path.GetExtension (path) == ".glade") {
- GladeFiles.Import (p, path);
- } else {
- p.Load (path);
- }
- return p;
- }
-
- public CodeGenerationResult GenerateProjectCode (GenerationOptions options, ProjectBackend[] projects)
- {
- return CodeGenerator.GenerateProjectCode (options, projects);
- }
-
- public ArrayList GlobalWidgetLibraries {
- get { return globalWidgetLibraries; }
- set { globalWidgetLibraries = value; }
- }
-
- public bool AllowInProcLibraries {
- get { return allowInProcLibraries; }
- set { allowInProcLibraries = value; }
- }
-
- public bool UpdateLibraries (ArrayList libraries, ArrayList projects, bool allowBackendRestart, bool forceUnload)
- {
- try {
- Registry.BeginChangeSet ();
-
- libraries.Add (Registry.CoreWidgetLibrary.Name);
-// libraries.Add (Registry.CoreWidgetLibrary2.Name);
-
- // Notify libraries that need to be unloaded and loaded again
- foreach (WidgetLibrary lib in Registry.RegisteredWidgetLibraries) {
- if (lib.NeedsReload)
- appFrontend.NotifyLibraryUnloaded (lib.Name);
- }
-
- if (!Registry.ReloadWidgetLibraries () && allowBackendRestart)
- return false;
-
- // Store a list of registered libraries, used later to know which
- // ones need to be unloaded
-
- ArrayList loaded = new ArrayList ();
- foreach (WidgetLibrary alib in Registry.RegisteredWidgetLibraries)
- loaded.Add (alib.Name);
-
- // Load required libraries
-
- Hashtable visited = new Hashtable ();
- LoadLibraries (new AssemblyResolver (this), visited, libraries);
-
- foreach (ProjectBackend project in projects)
- LoadLibraries (project.Resolver, visited, project.WidgetLibraries);
-
- // Unload libraries which are not required
-
- foreach (string name in loaded) {
- if (!visited.Contains (name)) {
- if (forceUnload && allowBackendRestart)
- return false;
- appFrontend.NotifyLibraryUnloaded (name);
- Registry.UnregisterWidgetLibrary (Registry.GetWidgetLibrary (name));
- }
- }
-
- return true;
- }
- finally {
- Registry.EndChangeSet ();
- }
- }
-
- internal void LoadLibraries (AssemblyResolver resolver, IEnumerable libraries)
- {
- try {
- Registry.BeginChangeSet ();
- Hashtable visited = new Hashtable ();
- LoadLibraries (resolver, visited, libraries);
- } finally {
- Registry.EndChangeSet ();
- }
- }
-
- void LoadLibraries (AssemblyResolver resolver, Hashtable visited, IEnumerable libraries)
- {
- // Convert all assembly names to assembly paths before registering the libraries.
- // The registry and the library cache will only handle full paths.
- foreach (string s in libraries) {
- string sr = resolver.Resolve (s, null);
- if (sr != null)
- AddLibrary (resolver, visited, sr);
- }
- Registry.ReloadWidgetLibraries ();
- }
-
- WidgetLibrary AddLibrary (AssemblyResolver resolver, Hashtable visited, string s)
- {
- if (Registry.IsRegistered (s)) {
- WidgetLibrary lib = Registry.GetWidgetLibrary (s);
- CheckDependencies (resolver, visited, lib);
- return lib;
- }
-
- // Avoid registering direct references of libstetic
- if (Path.GetFileName (s) == "libstetic.dll" && s != coreLibrary)
- return null;
-
- WidgetLibrary alib = CreateLibrary (resolver, s);
- if (alib == null)
- return null;
-
- RegisterLibrary (resolver, visited, alib);
- return alib;
- }
-
- void RegisterLibrary (AssemblyResolver resolver, Hashtable visited, WidgetLibrary lib)
- {
- if (lib == null || visited.Contains (lib.Name))
- return;
-
- visited [lib.Name] = lib;
-
- foreach (string s in lib.GetLibraryDependencies ()) {
- if (!Application.InternalIsWidgetLibrary (resolver, s))
- continue;
- AddLibrary (resolver, visited, s);
- }
-
- try {
- Registry.RegisterWidgetLibrary (lib);
- } catch (Exception ex) {
- // Catch errors when loading a library to avoid aborting
- // the whole update method. After all, that's not a fatal
- // error (some widgets just won't be shown).
- // FIXME: return the error somewhere
- Console.WriteLine (ex);
- }
- }
-
- WidgetLibrary CreateLibrary (AssemblyResolver resolver, string name)
- {
- try {
- if (allowInProcLibraries)
- return new AssemblyWidgetLibrary (resolver, name);
- else
- return new CecilWidgetLibrary (resolver, name);
- } catch (Exception) {
- // FIXME: handle the error, but keep loading.
- return null;
- }
- }
-
- void CheckDependencies (AssemblyResolver resolver, Hashtable visited, WidgetLibrary lib)
- {
- if (visited.Contains (lib.Name))
- return;
-
- visited [lib.Name] = lib;
-
-// foreach (string dep in lib.GetLibraryDependencies ()) {
-// WidgetLibrary depLib = Registry.GetWidgetLibrary (dep);
-// if (depLib == null)
-// AddLibrary (resolver, visited, dep);
-// else
-// CheckDependencies (resolver, visited, depLib);
-// }
- }
-
- public ProjectBackend ActiveProject {
- get { return activeProject; }
- set {
- if (activeProject == value)
- return;
- activeProject = value;
- if (paletteWidget != null) {
- paletteWidget.ProjectBackend = activeProject;
- paletteWidget.WidgetLibraries = GetActiveLibraries ();
- }
- if (propertiesWidget != null)
- propertiesWidget.ProjectBackend = activeProject;
- if (signalsWidget != null)
- signalsWidget.ProjectBackend = activeProject;
- }
- }
-
- public void SetActiveDesignSession (WidgetEditSession session)
- {
- activeDesignSession = session;
- if (projectWidget != null)
- projectWidget.Bind (session);
- }
-
- public WidgetLibrary[] GetActiveLibraries ()
- {
- return GetProjectLibraries (activeProject);
- }
-
- public WidgetLibrary[] GetProjectLibraries (ProjectBackend project)
- {
- ArrayList projectLibs = new ArrayList ();
- if (project != null)
- projectLibs.AddRange (project.WidgetLibraries);
-
- ArrayList list = new ArrayList ();
- list.Add (Registry.CoreWidgetLibrary);
- foreach (WidgetLibrary alib in Registry.RegisteredWidgetLibraries) {
- if (project != null && !alib.SupportsGtkVersion (project.TargetGtkVersion))
- continue;
- string aname = alib.Name;
- if (projectLibs.Contains (aname) || globalWidgetLibraries.Contains (aname))
- list.Add (alib);
- }
- return (WidgetLibrary[]) list.ToArray (typeof(WidgetLibrary));
- }
-
- public ProjectBackend CreateProject ()
- {
- return new ProjectBackend (this);
- }
-
- object IObjectViewer.TargetObject {
- get { return targetViewerObject; }
- set {
- targetViewerObject = value;
- if (propertiesWidget != null)
- propertiesWidget.TargetObject = targetViewerObject;
- if (signalsWidget != null)
- signalsWidget.Editor.TargetObject = targetViewerObject;
- }
- }
-
- public PaletteBackend GetPaletteWidget ()
- {
- if (paletteWidget == null) {
- paletteWidget = new PaletteBackend (this);
- paletteWidget.ProjectBackend = activeProject;
- paletteWidget.WidgetLibraries = GetActiveLibraries ();
- }
- return paletteWidget;
- }
-
- public void CreatePaletteWidgetPlug (uint socketId)
- {
- Gtk.Plug plug = new Gtk.Plug (socketId);
- plug.Decorated = false;
-// Gtk.Window plug = new Gtk.Window ("");
- plug.Add (GetPaletteWidget ());
- plug.Show ();
- }
-
- public void DestroyPaletteWidgetPlug ()
- {
- if (paletteWidget != null) {
- Gtk.Plug plug = (Gtk.Plug)paletteWidget.Parent;
- plug.Remove (paletteWidget);
- plug.Destroy ();
- }
- }
-
- public WidgetPropertyTreeBackend GetPropertiesWidget ()
- {
- if (propertiesWidget == null) {
- propertiesWidget = new WidgetPropertyTreeBackend ();
- propertiesWidget.ProjectBackend = activeProject;
- propertiesWidget.TargetObject = targetViewerObject;
- }
- return propertiesWidget;
- }
-
- public void CreatePropertiesWidgetPlug (uint socketId)
- {
- Gtk.Plug plug = new Gtk.Plug (socketId);
- plug.Decorated = false;
-// Gtk.Window plug = new Gtk.Window ("");
- plug.Add (GetPropertiesWidget ());
- plug.Show ();
- }
-
- public void DestroyPropertiesWidgetPlug ()
- {
- if (propertiesWidget != null) {
- Gtk.Plug plug = (Gtk.Plug) propertiesWidget.Parent;
- plug.Remove (propertiesWidget);
- plug.Destroy ();
- }
- }
-
- public SignalsEditorEditSession GetSignalsWidget (SignalsEditorFrontend frontend)
- {
- if (signalsWidget == null) {
- signalsWidget = new SignalsEditorEditSession (frontend);
- signalsWidget.ProjectBackend = activeProject;
- signalsWidget.Editor.TargetObject = targetViewerObject;
- }
- return signalsWidget;
- }
-
- public SignalsEditorEditSession CreateSignalsWidgetPlug (SignalsEditorFrontend frontend, uint socketId)
- {
- Gtk.Plug plug = new Gtk.Plug (socketId);
- plug.Decorated = false;
-// Gtk.Window plug = new Gtk.Window ("");
- SignalsEditorEditSession session = GetSignalsWidget (frontend);
- plug.Add (session.Editor);
- plug.Show ();
- return session;
- }
-
- public void DestroySignalsWidgetPlug ()
- {
- if (signalsWidget != null) {
- Gtk.Plug plug = (Gtk.Plug) signalsWidget.Editor.Parent;
- plug.Remove (signalsWidget.Editor);
- plug.Destroy ();
- }
- }
-
- public ProjectViewBackend GetProjectWidget (ProjectViewFrontend frontend)
- {
- if (projectWidget == null) {
- projectWidget = new ProjectViewBackend (frontend);
- projectWidget.Bind (activeDesignSession);
- }
- return projectWidget;
- }
-
- public void CreateProjectWidgetPlug (ProjectViewFrontend frontend, uint socketId)
- {
- Gtk.Plug plug = new Gtk.Plug (socketId);
- plug.Decorated = false;
-// Gtk.Window plug = new Gtk.Window ("");
- plug.Add (GetProjectWidget (frontend));
- plug.Show ();
- }
-
- public void DestroyProjectWidgetPlug ()
- {
- if (projectWidget != null) {
- Gtk.Plug plug = (Gtk.Plug)projectWidget.Parent;
- plug.Remove (projectWidget);
- plug.Destroy ();
- }
- }
-
- public ArrayList GetComponentTypes ()
- {
- ArrayList list = new ArrayList ();
- foreach (ClassDescriptor cd in Registry.AllClasses)
- list.Add (cd.Name);
- return list;
- }
-
- public bool GetClassDescriptorInfo (string name, out string desc, out string className, out string category, out string targetGtkVersion, out string library, out byte[] icon)
- {
- ClassDescriptor cls = Registry.LookupClassByName (name);
- if (cls == null) {
- icon = null;
- desc = null;
- className = null;
- category = null;
- targetGtkVersion = null;
- library = null;
- return false;
- }
- desc = cls.Label;
- className = cls.WrappedTypeName;
- category = cls.Category;
- targetGtkVersion = cls.TargetGtkVersion;
- library = cls.Library.Name;
- icon = cls.Icon != null ? cls.Icon.SaveToBuffer ("png") : null;
- return true;
- }
-
- public object[] GetClassDescriptorInitializationValues (string name)
- {
- ClassDescriptor cls = Registry.LookupClassByName (name);
- ArrayList list = new ArrayList ();
-
- foreach (Stetic.PropertyDescriptor prop in cls.InitializationProperties)
- {
- if (prop.PropertyType.IsValueType) {
- // Avoid sending to the main process types which should not be loaded there
- if (prop.PropertyType.Assembly == typeof(object).Assembly ||
- prop.PropertyType.Assembly == typeof(Gtk.Widget).Assembly ||
- prop.PropertyType.Assembly == typeof(Gdk.Window).Assembly ||
- prop.PropertyType.Assembly == typeof(GLib.Object).Assembly) {
-
- list.Add (Activator.CreateInstance (prop.PropertyType));
- } else
- return new object [0];
- } else
- list.Add (null);
- }
- return list.ToArray ();
- }
-
- public void ShowPaletteGroup (string name, string label)
- {
- GetPaletteWidget ().ShowGroup (name, label);
- }
-
- public void HidePaletteGroup (string name)
- {
- GetPaletteWidget ().HideGroup (name);
- }
-
- internal void GetClipboardOperations (object obj, out bool canCut, out bool canCopy, out bool canPaste)
- {
- Stetic.Wrapper.Widget wrapper = obj as Stetic.Wrapper.Widget;
- if (wrapper != null) {
- canCut = wrapper.InternalChildProperty == null && !wrapper.IsTopLevel;
- canCopy = !wrapper.IsTopLevel;
- canPaste = false;
- }
- else if (obj is Placeholder) {
- // FIXME: make it work for placeholders
- canCut = canCopy = false;
- canPaste = true;
- }
- else {
- canCut = canCopy = canPaste = false;
- }
- }
-
- internal void GetComponentInfo (object obj, out string name, out string type)
- {
- Stetic.Wrapper.Widget wrapper = obj as Stetic.Wrapper.Widget;
- name = wrapper.Wrapped.Name;
- type = wrapper.ClassDescriptor.Name;
- }
-
- internal void RenameWidget (Wrapper.Widget w, string newName)
- {
- w.Wrapped.Name = newName;
- }
-
- internal byte[] GetActionIcon (Wrapper.Action ac)
- {
- Gdk.Pixbuf pix = ac.RenderIcon (Gtk.IconSize.Menu);
- if (pix == null)
- return null;
- return pix.SaveToBuffer ("png");
- }
-
- internal ArrayList GetWidgetChildren (Wrapper.Widget ww)
- {
- Stetic.Wrapper.Container cw = ww as Stetic.Wrapper.Container;
- if (cw == null)
- return null;
-
- ArrayList list = new ArrayList ();
- foreach (object ob in cw.RealChildren) {
- ObjectWrapper ow = ObjectWrapper.Lookup (ob);
- if (ow != null)
- list.Add (Component.GetSafeReference (ow));
- }
- return list;
- }
-
- internal void RemoveWidgetSignal (ObjectWrapper wrapper, Signal signal)
- {
- foreach (Signal s in wrapper.Signals) {
- if (s.Handler == signal.Handler && s.SignalDescriptor.Name == signal.SignalDescriptor.Name) {
- wrapper.Signals.Remove (s);
- return;
- }
- }
- }
-
- internal Wrapper.ActionGroup[] GetActionGroups (Wrapper.Widget widget)
- {
- return widget.LocalActionGroups.ToArray ();
- }
-
- internal ObjectBindInfo[] GetBoundComponents (ObjectWrapper wrapper)
- {
- return CodeGenerator.GetFieldsToBind (wrapper).ToArray ();
- }
-
- internal ObjectWrapper GetPropertyTreeTarget ()
- {
- return targetViewerObject as ObjectWrapper;
- }
-
- internal void BeginComponentDrag (ProjectBackend project, string desc, string className, ObjectWrapper wrapper, Gtk.Widget source, Gdk.DragContext ctx, ComponentDropCallback callback)
- {
- if (wrapper != null) {
- Stetic.Wrapper.ActionPaletteItem it = new Stetic.Wrapper.ActionPaletteItem (Gtk.UIManagerItemType.Menuitem, null, (Wrapper.Action) wrapper);
- DND.Drag (source, ctx, it);
- }
- else if (callback != null) {
- DND.Drag (source, ctx, delegate () {
- callback ();
-
- // If the class name has an assembly name, remove it now
- int i = className.IndexOf (',');
- if (i != -1)
- className = className.Substring (0, i);
-
- ClassDescriptor cls = Registry.LookupClassByName (className);
- if (cls != null)
- return cls.NewInstance (project) as Gtk.Widget;
- else {
- // Class not found, show an error
- string msg = string.Format ("The widget '{0}' could not be found.", className);
- Gtk.MessageDialog dlg = new Gtk.MessageDialog (null, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Close, msg);
- dlg.Run ();
- dlg.Destroy ();
- return null;
- }
- },
- (desc != null && desc.Length > 0) ? desc : className
- );
- }
- else {
- ClassDescriptor cls = Registry.LookupClassByName (className);
- DND.Drag (source, ctx, cls.NewInstance (project) as Gtk.Widget);
- }
- }
-
- public string ResolveAssembly (string assemblyName)
- {
- if (widgetLibraryResolver != null)
- return widgetLibraryResolver (assemblyName);
- else
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ApplicationBackendController.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ApplicationBackendController.cs
deleted file mode 100644
index 5fdbbea4d5..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ApplicationBackendController.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-
-using System;
-using System.IO;
-using System.Diagnostics;
-using System.Threading;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Remoting;
-using System.Runtime.Remoting.Channels;
-using System.Runtime.Remoting.Channels.Tcp;
-
-namespace Stetic
-{
- internal class ApplicationBackendController: MarshalByRefObject
- {
- bool stopping;
- ApplicationBackend backend;
- string channelId;
- IsolatedApplication app;
-
- ManualResetEvent runningEvent = new ManualResetEvent (false);
-
- public event EventHandler Stopped;
-
- public ApplicationBackendController (IsolatedApplication app, string channelId)
- {
- this.app = app;
- this.channelId = channelId;
- }
-
- public ApplicationBackend Backend {
- get { return backend; }
- }
-
- public Application Application {
- get { return app; }
- }
-
- public void StartBackend ()
- {
- runningEvent.Reset ();
-
- string asm = GetType().Assembly.Location;
-
- BinaryFormatter bf = new BinaryFormatter ();
- ObjRef oref = RemotingServices.Marshal (this);
- MemoryStream ms = new MemoryStream ();
- bf.Serialize (ms, oref);
- string sref = Convert.ToBase64String (ms.ToArray ());
-
- Process process = new Process ();
- process.StartInfo = new ProcessStartInfo ("sh", "-c \"mono --debug " + asm + "\"");
- process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
- process.StartInfo.UseShellExecute = false;
- process.StartInfo.RedirectStandardInput = true;
- process.EnableRaisingEvents = true;
- process.Start ();
- process.StandardInput.WriteLine (channelId);
- process.StandardInput.WriteLine (sref);
- process.StandardInput.Flush ();
- process.Exited += OnExited;
-
- if (!runningEvent.WaitOne (10000, false))
- throw new ApplicationException ("Couldn't create a remote process.");
- }
-
- public void StopBackend (bool waitUntilDone)
- {
- stopping = true;
- runningEvent.Reset ();
- backend.Dispose ();
- if (waitUntilDone)
- runningEvent.WaitOne (9000, false);
- }
-
- void OnExited (object o, EventArgs args)
- {
- Gtk.Application.Invoke (OnExitedInGui);
- }
-
- void OnExitedInGui (object o, EventArgs args)
- {
- if (!stopping && Stopped != null)
- Stopped (this, EventArgs.Empty);
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- }
-
- internal void Connect (ApplicationBackend backend)
- {
- this.backend = backend;
- runningEvent.Set ();
- }
-
- internal void Disconnect (ApplicationBackend backend)
- {
- this.backend = null;
- runningEvent.Set ();
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/AssemblyResolver.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/AssemblyResolver.cs
deleted file mode 100644
index afc8cd6dc6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/AssemblyResolver.cs
+++ /dev/null
@@ -1,242 +0,0 @@
-//
-// BaseAssemblyResolver.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-// This code is a modified version of the assembly resolver implemented in Cecil.
-// Keep in synch as much as possible.
-
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.IO;
-using System.Text;
-using Mono.Cecil;
-
-namespace Stetic {
-
- internal class AssemblyResolver : BaseAssemblyResolver {
-
- Hashtable _assemblies;
- ApplicationBackend app;
-
- public IDictionary AssemblyCache {
- get { return _assemblies; }
- }
-
- public AssemblyResolver (ApplicationBackend app)
- {
- this.app = app;
- _assemblies = new Hashtable ();
- }
-
- public StringCollection Directories = new StringCollection ();
-
- public override AssemblyDefinition Resolve (AssemblyNameReference name)
- {
- return Resolve (name, (string)null);
- }
-
- public AssemblyDefinition Resolve (AssemblyNameReference name, string basePath)
- {
- AssemblyDefinition asm = (AssemblyDefinition) _assemblies [name.FullName];
- if (asm == null) {
- if (app != null) {
- string ares = app.ResolveAssembly (name.Name);
- if (ares != null) {
- asm = AssemblyFactory.GetAssembly (ares);
- asm.Resolver = this;
- _assemblies [name.FullName] = asm;
- return asm;
- }
- }
- string file = Resolve (name.FullName, basePath);
- if (file != null)
- asm = AssemblyFactory.GetAssembly (file);
- else
- asm = base.Resolve (name);
- asm.Resolver = this;
- _assemblies [name.FullName] = asm;
- }
-
- return asm;
- }
-
- public void ClearCache ()
- {
- _assemblies.Clear ();
- }
-
- public TypeDefinition Resolve (TypeReference type)
- {
- if (type is TypeDefinition)
- return (TypeDefinition) type;
-
- AssemblyNameReference reference = type.Scope as AssemblyNameReference;
- if (reference != null) {
- AssemblyDefinition assembly = Resolve (reference);
- return assembly.MainModule.Types [type.FullName];
- }
-
- ModuleDefinition module = type.Scope as ModuleDefinition;
- if (module != null)
- return module.Types [type.FullName];
-
- throw new NotImplementedException ();
- }
-
- public void CacheAssembly (AssemblyDefinition assembly)
- {
- _assemblies [assembly.Name.FullName] = assembly;
- assembly.Resolver = this;
- }
-
- public string Resolve (string assemblyName, string basePath)
- {
- if (Path.IsPathRooted (assemblyName) && (assemblyName.EndsWith (".dll") || assemblyName.EndsWith (".exe")))
- return Path.GetFullPath (assemblyName);
-
- if (app != null) {
- string ares = app.ResolveAssembly (assemblyName);
- if (ares != null)
- return Path.GetFullPath (ares);
- }
-
- StringCollection col = new StringCollection ();
- col.Add (basePath);
- foreach (string s in Directories)
- col.Add (s);
-
- try {
- return Resolve (AssemblyNameReference.Parse (assemblyName), col);
- } catch {
- }
- return null;
- }
-
- public string Resolve (AssemblyNameReference name, StringCollection basePaths)
- {
- string [] exts = new string [] { ".dll", ".exe" };
-
- if (basePaths != null) {
- foreach (string dir in basePaths) {
- foreach (string ext in exts) {
- string file = Path.Combine (dir, name.Name + ext);
- if (File.Exists (file))
- return file;
- }
- }
- }
-
- if (name.Name == "mscorlib")
- return GetCorlib (name);
-
- string asm = GetAssemblyInGac (name);
- if (asm != null)
- return Path.GetFullPath (asm);
-
- throw new FileNotFoundException ("Could not resolve: " + name);
- }
-
- string GetCorlib (AssemblyNameReference reference)
- {
- if (typeof (object).Assembly.GetName ().Version == reference.Version)
- return typeof (object).Assembly.Location;
-
- string path = Directory.GetParent (
- Directory.GetParent (
- typeof (object).Module.FullyQualifiedName).FullName
- ).FullName;
-
- if (OnMono ()) {
- if (reference.Version.Major == 1)
- path = Path.Combine (path, "1.0");
- else if (reference.Version.Major == 2)
- path = Path.Combine (path, "2.0");
- else
- throw new NotSupportedException ("Version not supported: " + reference.Version);
- } else {
- if (reference.Version.ToString () == "1.0.3300.0")
- path = Path.Combine (path, "v1.0.3705");
- else if (reference.Version.ToString () == "1.0.5000.0")
- path = Path.Combine (path, "v1.1.4322");
- else if (reference.Version.ToString () == "2.0.0.0")
- path = Path.Combine (path, "v2.0.50727");
- else
- throw new NotSupportedException ("Version not supported: " + reference.Version);
- }
-
- return Path.GetFullPath (Path.Combine (path, "mscorlib.dll"));
- }
-
- static string GetAssemblyInGac (AssemblyNameReference reference)
- {
- if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0)
- return null;
-
- string currentGac = GetCurrentGacPath ();
- if (OnMono ()) {
- string s = GetAssemblyFile (reference, currentGac);
- if (File.Exists (s))
- return s;
- } else {
- string [] gacs = new string [] {"GAC_MSIL", "GAC_32", "GAC"};
- for (int i = 0; i < gacs.Length; i++) {
- string gac = Path.Combine (Directory.GetParent (currentGac).FullName, gacs [i]);
- string asm = GetAssemblyFile (reference, gac);
- if (Directory.Exists (gac) && File.Exists (asm))
- return asm;
- }
- }
-
- return null;
- }
-
- static string GetAssemblyFile (AssemblyNameReference reference, string gac)
- {
- StringBuilder sb = new StringBuilder ();
- sb.Append (reference.Version);
- sb.Append ("__");
- for (int i = 0; i < reference.PublicKeyToken.Length; i++)
- sb.Append (reference.PublicKeyToken [i].ToString ("x2"));
-
- return Path.Combine (
- Path.Combine (
- Path.Combine (gac, reference.Name), sb.ToString ()),
- string.Concat (reference.Name, ".dll"));
- }
-
- static string GetCurrentGacPath ()
- {
- return Directory.GetParent (
- Directory.GetParent (
- Path.GetDirectoryName (
- typeof (Uri).Module.FullyQualifiedName)
- ).FullName
- ).FullName;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/AssemblyWidgetLibrary.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/AssemblyWidgetLibrary.cs
deleted file mode 100644
index f57e43768e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/AssemblyWidgetLibrary.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Xml;
-using System.IO;
-
-namespace Stetic
-{
- internal class AssemblyWidgetLibrary: WidgetLibrary
- {
- static LibraryCache Cache = LibraryCache.Cache;
-
- Assembly assembly;
- string name;
- AssemblyResolver resolver;
- LibraryCache.LibraryInfo cache_info;
-
- public AssemblyWidgetLibrary (string name, Assembly assembly)
- {
- this.name = name;
- this.assembly = assembly;
- UpdateCache ();
- }
-
- public AssemblyWidgetLibrary (AssemblyResolver resolver, string assemblyPath)
- {
- this.name = assemblyPath;
-
- string ares = resolver.Resolve (assemblyPath, null);
- if (ares != null)
- assemblyPath = ares;
-
- this.resolver = resolver;
- if (assemblyPath.EndsWith (".dll") || assemblyPath.EndsWith (".exe")) {
- if (File.Exists (assemblyPath))
- assembly = Assembly.LoadFrom (assemblyPath);
- } else
- assembly = Assembly.Load (assemblyPath);
-
- if (assembly == null)
- throw new InvalidOperationException ("Couldn't load assembly at " + assemblyPath);
-
- UpdateCache ();
- }
-
- void UpdateCache ()
- {
- Cache.Refresh (resolver, assembly.Location);
- cache_info = Cache [assembly.Location];
- }
-
- public override string Name {
- get { return name; }
- }
-
- public override bool NeedsReload {
- get {
- return File.Exists (assembly.Location) && !Cache.IsCurrent (assembly.Location);
- }
- }
-
- public override bool CanReload {
- get { return false; }
- }
-
- public override void Load ()
- {
- Load (cache_info.ObjectsDocument);
- }
-
- protected override ClassDescriptor LoadClassDescriptor (XmlElement element)
- {
- return new TypedClassDescriptor (assembly, element);
- }
-
- public override Type GetType (string typeName)
- {
- Type t = assembly.GetType (typeName, false);
- if (t != null) return t;
-
- // Look in referenced assemblies
-/*
- Disabled. The problem is that Assembly.Load tries to load the exact version
- of the assembly, and loaded references may not have the same exact version.
-
- foreach (AssemblyName an in assembly.GetReferencedAssemblies ()) {
- Assembly a = Assembly.Load (an);
- t = a.GetType (typeName);
- if (t != null) return t;
- }
-*/
- return null;
- }
-
- public override System.IO.Stream GetResource (string name)
- {
- return assembly.GetManifestResourceStream (name);
- }
-
- public override string[] GetLibraryDependencies ()
- {
- if (!cache_info.HasWidgets)
- return new string [0];
-
- ArrayList list = new ArrayList ();
- ScanLibraries (list, assembly);
- return (string[]) list.ToArray (typeof(string));
- }
-
- void ScanLibraries (ArrayList list, Assembly asm)
- {
- foreach (AssemblyName aname in asm.GetReferencedAssemblies ()) {
- Assembly depasm = null;
- try {
- depasm = Assembly.Load (aname);
- } catch {
- }
-
- if (depasm == null) {
- string file = resolver.Resolve (aname.FullName, Path.GetDirectoryName (asm.Location));
- if (file != null)
- depasm = Assembly.LoadFrom (file);
- else
- throw new InvalidOperationException ("Assembly not found: " + aname.FullName);
- }
-
- ManifestResourceInfo res = depasm.GetManifestResourceInfo ("objects.xml");
- if (res != null)
- list.Add (depasm.Location);
- }
- }
-
- public override void Flush ()
- {
- base.Flush ();
- if (resolver != null)
- resolver.ClearCache ();
- }
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilClassDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilClassDescriptor.cs
deleted file mode 100644
index 08a3d8cc04..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilClassDescriptor.cs
+++ /dev/null
@@ -1,382 +0,0 @@
-using System;
-using System.Collections;
-using System.IO;
-using System.Xml;
-using System.Reflection;
-using Mono.Cecil;
-
-namespace Stetic
-{
- internal class CecilClassDescriptor: Stetic.ClassDescriptor
- {
- string wrappedTypeName;
- ClassDescriptor typeClassDescriptor;
- ClassDescriptor wrapperClassDescriptor;
- Gdk.Pixbuf icon;
- TypeDefinition type;
- XmlElement steticDefinition;
- CecilWidgetLibrary cecilLib;
- bool useCustomWidgetBox;
- string widgetId;
- bool canGenerateCode;
-
- public CecilClassDescriptor (CecilWidgetLibrary lib, XmlElement element, ClassDescriptor typeClassDescriptor, XmlElement steticDefinition, TypeDefinition cls)
- {
- this.cecilLib = lib;
- this.steticDefinition = steticDefinition;
- this.typeClassDescriptor = typeClassDescriptor;
- wrappedTypeName = element.GetAttribute ("type");
- type = cls;
- Load (element);
- type = null;
- canGenerateCode = true;
-
- string baseType = element.GetAttribute ("base-type");
- if (baseType.Length > 0) {
- wrapperClassDescriptor = Registry.LookupClassByName (baseType);
- if (wrapperClassDescriptor == null)
- throw new InvalidOperationException ("Unknown base type: " + baseType);
- } else {
- wrapperClassDescriptor = typeClassDescriptor;
- }
-
- if (steticDefinition == null && !AllowChildren && NeedsBlackBox (typeClassDescriptor.Name)) {
- // It is not possible to create instances of that widget, instead we'll have
- // to create the typical custom widget black box.
-
- if (!CanCreateWidgetInstance (wrapperClassDescriptor.Name))
- throw new InvalidOperationException ("Can't load widget type '" + Name + "'. Instances of that type can't be created because the type can't be loaded into the process.");
-
- useCustomWidgetBox = true;
- }
-
- widgetId = Name.ToLower ();
- int i = widgetId.LastIndexOf ('.');
- if (i != -1) {
- if (i != widgetId.Length - 1)
- widgetId = widgetId.Substring (i+1);
- else
- widgetId = widgetId.Replace (".", "");
- }
-
- string iconName = element.GetAttribute ("icon");
- icon = lib.GetEmbeddedIcon (iconName);
-
- // If the class is a custom widget created using stetic, it means that it has
- // simple property and there is no custom logic, so it is safe to generate code
- // for this class.
- if (steticDefinition != null)
- canGenerateCode = true;
-
- // If it has a custom wrapper, then it definitely has custom logic, so it can't generate code
- if (element.HasAttribute ("wrapper"))
- canGenerateCode = false;
- }
-
- public override string WrappedTypeName {
- get { return wrappedTypeName; }
- }
-
- public override Gdk.Pixbuf Icon {
- get { return icon; }
- }
-
- public bool CanGenerateCode {
- get { return canGenerateCode; }
- }
-
- public override object CreateInstance (Stetic.IProject proj)
- {
- Gtk.Widget res;
-
- if (useCustomWidgetBox) {
- res = CreateFakeWidget (wrapperClassDescriptor.Name);
- res.ShowAll ();
- }
- else if (steticDefinition != null) {
- Gtk.Container w = Stetic.WidgetUtils.ImportWidget (proj, steticDefinition) as Gtk.Container;
- MakeChildrenUnselectable (w);
- res = w;
- }
- else {
- res = (Gtk.Widget) typeClassDescriptor.CreateInstance (proj);
-
- // If it is a custom widget and there is no stetic project for it, just
- // show it as a regular custom widget.
- Stetic.CustomWidget custom = res as Stetic.CustomWidget;
- if (custom != null) {
- Stetic.Custom c = new Stetic.Custom ();
- // Give it some default size
- c.WidthRequest = 20;
- c.HeightRequest = 20;
- custom.Add (c);
- custom.ShowAll ();
- res = custom;
- }
- }
-
- res.Name = widgetId;
- return res;
- }
-
- public override Stetic.ObjectWrapper CreateWrapper ()
- {
- return wrapperClassDescriptor.CreateWrapper ();
- }
-
- protected override Stetic.ItemDescriptor CreateItemDescriptor (XmlElement elem, Stetic.ItemGroup group)
- {
- string mname = elem.GetAttribute ("name");
- if (elem.Name == "property") {
- if (type != null) {
- PropertyDefinition propInfo = FindProperty (type, mname);
- if (propInfo != null)
- return new CecilPropertyDescriptor (cecilLib, elem, group, this, propInfo);
- }
- else
- return new CecilPropertyDescriptor (cecilLib, elem, group, this, null);
- }
- else if (elem.Name == "signal") {
- if (type != null) {
- EventDefinition signalInfo = FindEvent (type, mname);
- if (signalInfo != null)
- return new CecilSignalDescriptor (cecilLib, elem, group, this, signalInfo);
- }
- else
- return new CecilSignalDescriptor (cecilLib, elem, group, this, null);
- }
- else
- return base.CreateItemDescriptor (elem, group);
-
- return null;
- }
-
- PropertyDefinition FindProperty (TypeDefinition cls, string name)
- {
- foreach (PropertyDefinition propInfo in cls.Properties)
- if (propInfo.Name == name)
- return propInfo;
-
- if (cls.BaseType == null)
- return null;
-
- string baseType = cls.BaseType.FullName;
- Type t = Registry.GetType (baseType, false);
- if (t != null) {
- PropertyInfo prop = t.GetProperty (name);
- if (prop != null) {
- TypeReference tref = new TypeReference (prop.PropertyType.Name, prop.PropertyType.Namespace, null, prop.PropertyType.IsValueType);
- PropertyDefinition pdef = new PropertyDefinition (name, tref, (Mono.Cecil.PropertyAttributes) 0);
- PropertyDefinition.CreateGetMethod (pdef);
- PropertyDefinition.CreateSetMethod (pdef);
- return pdef;
- }
- }
-
- TypeDefinition bcls = cecilLib.FindTypeDefinition (baseType);
- if (bcls != null)
- return FindProperty (bcls, name);
- else
- return null;
- }
-
- EventDefinition FindEvent (TypeDefinition cls, string name)
- {
- foreach (EventDefinition eventInfo in cls.Events)
- if (eventInfo.Name == name)
- return eventInfo;
-
- if (cls.BaseType == null)
- return null;
-
- string baseType = cls.BaseType.FullName;
- Type t = Registry.GetType (baseType, false);
- if (t != null) {
- EventInfo ev = t.GetEvent (name);
- if (ev != null) {
- TypeReference tref = new TypeReference (ev.EventHandlerType.Name, ev.EventHandlerType.Namespace, null, ev.EventHandlerType.IsValueType);
- return new EventDefinition (name, tref, (Mono.Cecil.EventAttributes) 0);
- }
- }
-
- TypeDefinition bcls = cecilLib.FindTypeDefinition (baseType);
- if (bcls != null)
- return FindEvent (bcls, name);
- else
- return null;
- }
-
- void MakeChildrenUnselectable (Gtk.Widget w)
- {
- // Remove the registered signals, since those signals are bound
- // to the custom widget class, not the widget container class.
- Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup (w);
- if (ww == null)
- return;
- ww.Signals.Clear ();
-
- foreach (Gtk.Widget child in (Gtk.Container)w) {
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (child);
- if (wrapper != null) {
- wrapper.Signals.Clear ();
- wrapper.Unselectable = true;
- }
- if (child is Gtk.Container)
- MakeChildrenUnselectable (child);
- }
- }
-
- bool CanCreateWidgetInstance (string typeName)
- {
- switch (typeName) {
- case "Gtk.Fixed":
- return false;
- }
- return true;
- }
-
- bool NeedsBlackBox (string typeName)
- {
- switch (typeName) {
- case "Gtk.Widget":
- case "Gtk.Container":
- case "Gtk.Alignment":
- case "Gtk.Fixed":
- case "Gtk.Frame":
- case "Gtk.HBox":
- case "Gtk.VBox":
- case "Gtk.Box":
- case "Gtk.ButtonBox":
- case "Gtk.Paned":
- case "Gtk.VPaned":
- case "Gtk.HPaned":
- case "Gtk.Notebook":
- case "Gtk.ScrolledWindow":
- case "Gtk.Table":
- case "Gtk.Bin":
- return true;
- }
- return false;
- }
-
- Gtk.Widget CreateFakeWidget (string typeName)
- {
- Stetic.Custom c = new Stetic.Custom ();
- // Give it some default size
- c.WidthRequest = 20;
- c.HeightRequest = 20;
-
- Gtk.Container box = null;
-
- switch (typeClassDescriptor.Name) {
- case "Gtk.Alignment":
- box = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f);
- break;
- case "Gtk.Fixed":
- box = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f);
- break;
- case "Gtk.Frame":
- box = new Gtk.Frame ();
- break;
- case "Gtk.Box":
- case "Gtk.HBox": {
- Gtk.HBox cc = new Gtk.HBox ();
- cc.PackStart (c, true, true, 0);
- return cc;
- }
- case "Gtk.VBox": {
- Gtk.VBox cc = new Gtk.VBox ();
- cc.PackStart (c, true, true, 0);
- return cc;
- }
- case "Gtk.Paned":
- case "Gtk.VPaned": {
- Gtk.VPaned cc = new Gtk.VPaned ();
- cc.Add1 (c);
- return cc;
- }
- case "Gtk.HPaned": {
- Gtk.HPaned cc = new Gtk.HPaned ();
- cc.Add1 (c);
- return cc;
- }
- case "Gtk.Notebook": {
- Gtk.Notebook nb = new Gtk.Notebook ();
- nb.ShowTabs = false;
- nb.AppendPage (c, null);
- return nb;
- }
- case "Gtk.ScrolledWindow": {
- Gtk.ScrolledWindow cc = new Gtk.ScrolledWindow ();
- cc.VscrollbarPolicy = Gtk.PolicyType.Never;
- cc.HscrollbarPolicy = Gtk.PolicyType.Never;
- cc.AddWithViewport (c);
- return cc;
- }
- case "Gtk.Table": {
- Gtk.Table t = new Gtk.Table (1, 1, false);
- t.Attach (c, 0, 1, 0, 1);
- return t;
- }
- case "Gtk.ButtonBox":
- return new Gtk.HButtonBox ();
- }
- if (box != null) {
- box.Add (c);
- return box;
- } else {
- Stetic.CustomWidget custom = new Stetic.CustomWidget ();
- if (custom.Child != null)
- custom.Remove (custom.Child);
- custom.Add (c);
- return custom;
- }
- }
- }
-
- class CustomControlWrapper: Stetic.Wrapper.Container
- {
- protected override bool AllowPlaceholders {
- get {
- return false;
- }
- }
- }
-
- class ClassDescriptorWrapper: Stetic.ClassDescriptor
- {
- ClassDescriptor wrapped;
-
- public ClassDescriptorWrapper (ClassDescriptor wrapped)
- {
- this.wrapped = wrapped;
- label = wrapped.Label;
-
- }
-
- public override string WrappedTypeName {
- get { return wrapped.WrappedTypeName; }
- }
-
- public override Gdk.Pixbuf Icon {
- get { return wrapped.Icon; }
- }
-
- public override object CreateInstance (Stetic.IProject proj)
- {
- CustomWidget custom = new CustomWidget ();
- Stetic.Custom c = new Stetic.Custom ();
- // Give it some default size
- c.WidthRequest = 20;
- c.HeightRequest = 20;
- custom.Add (c);
- return c;
- }
-
- public override Stetic.ObjectWrapper CreateWrapper ()
- {
- return new Wrapper.Container ();
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilPropertyDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilPropertyDescriptor.cs
deleted file mode 100644
index 292a99b740..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilPropertyDescriptor.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-using Mono.Cecil;
-
-namespace Stetic
-{
- class CecilPropertyDescriptor: Stetic.PropertyDescriptor
- {
- string name;
- Type type;
- object initialValue;
- bool canWrite;
-
- public CecilPropertyDescriptor (CecilWidgetLibrary lib, XmlElement elem, Stetic.ItemGroup group, Stetic.ClassDescriptor klass, PropertyDefinition pinfo): base (elem, group, klass)
- {
- string tname;
-
- if (pinfo != null) {
- name = pinfo.Name;
- tname = pinfo.PropertyType.FullName;
- canWrite = pinfo.SetMethod != null;
- }
- else {
- name = elem.GetAttribute ("name");
- tname = elem.GetAttribute ("type");
- canWrite = elem.Attributes ["canWrite"] == null;
- }
-
- Load (elem);
-
- type = Stetic.Registry.GetType (tname, false);
-
- if (type == null) {
- Console.WriteLine ("Could not find type: " + tname);
- type = typeof(string);
- }
- if (type.IsValueType)
- initialValue = Activator.CreateInstance (type);
-
- // Consider all properties runtime-properties, since they have been created
- // from class properties.
- isRuntimeProperty = true;
-
- if (pinfo != null)
- SaveCecilXml (elem);
- }
-
- public CecilPropertyDescriptor (XmlElement elem, Stetic.ItemGroup group, Stetic.ClassDescriptor klass, PropertyDescriptor prop): base (elem, group, klass)
- {
- this.name = prop.Name;
- this.type = prop.PropertyType;
- this.canWrite = prop.CanWrite;
- if (type.IsValueType)
- initialValue = Activator.CreateInstance (type);
- this.label = prop.Label;
- this.description = prop.Description;
- this.maximum = prop.Maximum;
- this.minimum = prop.Minimum;
- this.initWithName = prop.InitWithName;
- this.translatable = prop.Translatable;
- }
-
- internal void SaveCecilXml (XmlElement elem)
- {
- elem.SetAttribute ("name", name);
- elem.SetAttribute ("type", type.FullName);
- if (!canWrite)
- elem.SetAttribute ("canWrite", "false");
- }
-
- public override string Name {
- get { return name; }
- }
-
- // The property's type
- public override Type PropertyType {
- get { return type; }
- }
-
- public override bool IsDefaultValue (object value)
- {
- return false;
- }
-
- // Gets the value of the property on @obj
- public override object GetValue (object obj)
- {
- Stetic.ObjectWrapper wrapper = (Stetic.ObjectWrapper) Stetic.ObjectWrapper.Lookup (obj);
- Hashtable props = (Hashtable) wrapper.ExtendedData [typeof(CecilPropertyDescriptor)];
- object val = props != null ? props [name] : null;
- if (val == null && initialValue != null)
- return initialValue;
- else
- return val;
- }
-
- // Whether or not the property is writable
- public override bool CanWrite {
- get { return canWrite; }
- }
-
- // Sets the value of the property on @obj
- public override void SetValue (object obj, object value)
- {
- Stetic.ObjectWrapper wrapper = (Stetic.ObjectWrapper) Stetic.ObjectWrapper.Lookup (obj);
- Hashtable props = (Hashtable) wrapper.ExtendedData [typeof(CecilPropertyDescriptor)];
- if (props == null) {
- props = new Hashtable ();
- wrapper.ExtendedData [typeof(CecilPropertyDescriptor)] = props;
- }
-
- props [name] = value;
- }
-
- public override object GetRuntimeValue (object obj)
- {
- return null;
- }
-
- public override void SetRuntimeValue (object obj, object value)
- {
- }
-
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilSignalDescriptor.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilSignalDescriptor.cs
deleted file mode 100644
index defc98e4b3..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilSignalDescriptor.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System;
-using System.Collections;
-using System.Xml;
-using System.Reflection;
-using Mono.Cecil;
-
-namespace Stetic
-{
- class CecilSignalDescriptor: Stetic.SignalDescriptor
- {
- public CecilSignalDescriptor (CecilWidgetLibrary lib, XmlElement elem, Stetic.ItemGroup group, Stetic.ClassDescriptor klass, EventDefinition sinfo) : base (elem, group, klass)
- {
- if (sinfo != null) {
- string handler = sinfo.EventType.FullName;
- handlerTypeName = handler.Replace ('/','+');
- Type t = Registry.GetType (handler, false);
- if (t != null) {
- MethodInfo mi = t.GetMethod ("Invoke");
- handlerReturnTypeName = mi.ReturnType.FullName;
- ParameterInfo[] pars = mi.GetParameters ();
- handlerParameters = new ParameterDescriptor [pars.Length];
- for (int n=0; n<pars.Length; n++)
- handlerParameters [n] = new ParameterDescriptor (pars[n].Name, pars[n].ParameterType.FullName);
- } else {
- // If the type is generic, the type arguments must be ignored when looking for the type
- string tn = handler;
- int i = handler.IndexOf ('<');
- if (i != -1) {
- tn = handler.Substring (0, i);
- // Convert the type name to a type reference
- handler = handler.Replace ('<', '[');
- handler = handler.Replace ('>', ']');
- }
- TypeDefinition td = lib.FindTypeDefinition (tn);
- if (td != null) {
- MethodDefinition mi = null;
- foreach (MethodDefinition md in td.Methods) {
- if (md.Name == "Invoke") {
- mi = md;
- break;
- }
- }
- if (mi != null) {
- handlerReturnTypeName = CecilWidgetLibrary.GetInstanceType (td, sinfo.EventType, mi.ReturnType.ReturnType);
- handlerParameters = new ParameterDescriptor [mi.Parameters.Count];
- for (int n=0; n<handlerParameters.Length; n++) {
- ParameterDefinition par = mi.Parameters [n];
- handlerParameters [n] = new ParameterDescriptor (par.Name, CecilWidgetLibrary.GetInstanceType (td, sinfo.EventType, par.ParameterType));
- }
- }
- } else {
- handlerParameters = new ParameterDescriptor [0];
- }
- }
- SaveCecilXml (elem);
- }
- else {
- handlerTypeName = elem.GetAttribute ("handlerTypeName");
- handlerReturnTypeName = elem.GetAttribute ("handlerReturnTypeName");
-
- ArrayList list = new ArrayList ();
- foreach (XmlNode npar in elem.ChildNodes) {
- XmlElement epar = npar as XmlElement;
- if (epar == null) continue;
- list.Add (new ParameterDescriptor (epar.GetAttribute ("name"), epar.GetAttribute ("type")));
- }
-
- handlerParameters = (ParameterDescriptor[]) list.ToArray (typeof(ParameterDescriptor));
- }
-
- Load (elem);
- }
-
- internal void SaveCecilXml (XmlElement elem)
- {
- elem.SetAttribute ("handlerTypeName", handlerTypeName);
- elem.SetAttribute ("handlerReturnTypeName", handlerReturnTypeName);
- if (handlerParameters != null) {
- foreach (ParameterDescriptor par in handlerParameters) {
- XmlElement epar = elem.OwnerDocument.CreateElement ("param");
- epar.SetAttribute ("name", par.Name);
- epar.SetAttribute ("type", par.TypeName);
- elem.AppendChild (epar);
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilWidgetLibrary.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilWidgetLibrary.cs
deleted file mode 100644
index 0352d31fc5..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CecilWidgetLibrary.cs
+++ /dev/null
@@ -1,368 +0,0 @@
-// CecilWidgetLibrary.cs
-//
-// Authors:
-// Lluis Sanchez Gual <lluis@novell.com>
-// Mike Kestner <mkestner@novell.com>
-//
-// Copyright (c) 2008 Novell, Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-using System;
-using System.IO;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Xml;
-using Mono.Cecil;
-
-namespace Stetic
-{
- internal class CecilWidgetLibrary: WidgetLibrary
- {
- static LibraryCache cache = LibraryCache.Cache;
-
- string name;
- string filename;
- string[] dependencies;
- AssemblyResolver resolver;
- bool canGenerateCode;
- bool info_changed;
- bool objects_dirty;
- AssemblyDefinition assembly;
- LibraryCache.LibraryInfo cache_info;
-
- public CecilWidgetLibrary (AssemblyResolver resolver, string path)
- {
- name = path;
- this.resolver = resolver;
-
- if (System.IO.File.Exists (path))
- filename = path;
- else if (resolver != null)
- filename = resolver.Resolve (path, null);
-
- if (filename == null)
- filename = path;
- else
- filename = System.IO.Path.GetFullPath (filename);
-
- RefreshFromCache ();
- }
-
- public override string Name {
- get { return name; }
- }
-
- public override bool NeedsReload {
- get {
- cache.Refresh (resolver, filename);
- return info_changed;
- }
- }
-
- public override bool CanReload {
- get { return true; }
- }
-
- public override bool CanGenerateCode {
- get { return canGenerateCode; }
- }
-
- public override void Load ()
- {
- canGenerateCode = true;
-
- RefreshFromCache ();
- if (cache_info == null || !File.Exists (filename))
- return;
-
- assembly = AssemblyFactory.GetAssembly (filename);
-
- objects_dirty = false;
- Load (cache_info.ObjectsDocument);
- if (objects_dirty)
- cache_info.WriteObjectsFile ();
-
- foreach (string dep in GetLibraryDependencies ()) {
- WidgetLibrary lib = Registry.GetWidgetLibrary (dep);
- if (lib != null && !lib.CanGenerateCode)
- canGenerateCode = false;
- }
- assembly = null;
- info_changed = false;
- }
-
- void RefreshFromCache ()
- {
- LibraryCache.LibraryInfo newInfo = cache.Refresh (resolver, filename);
- if (newInfo != cache_info) {
- if (cache_info != null)
- cache_info.Changed -= OnCacheInfoChanged;
- cache_info = newInfo;
- cache_info.Changed += OnCacheInfoChanged;
- }
- }
-
- void OnCacheInfoChanged (object o, EventArgs a)
- {
- info_changed = true;
- }
-
- public override void Dispose ()
- {
- base.Dispose ();
- if (cache_info != null) {
- cache_info.Changed -= OnCacheInfoChanged;
- cache_info = null;
- }
- }
-
-
- protected override ClassDescriptor LoadClassDescriptor (XmlElement element)
- {
- string name = element.GetAttribute ("type");
-
- TypeDefinition cls = null;
- Stetic.ClassDescriptor typeClassDescriptor = null;
- string tname;
-
- if (element.HasAttribute ("baseClassType")) {
- tname = element.GetAttribute ("baseClassType");
- typeClassDescriptor = Stetic.Registry.LookupClassByName (tname);
- } else {
- cls = assembly.MainModule.Types [name];
- if (cls != null) {
- // Find the nearest type that can be loaded
- typeClassDescriptor = FindType (assembly, cls);
- tname = cls.Name;
- if (typeClassDescriptor != null) {
- element.SetAttribute ("baseClassType", typeClassDescriptor.Name);
- objects_dirty = true;
- }
- }
- }
-
- if (typeClassDescriptor == null) {
- Console.WriteLine ("Descriptor not found: " + name);
- return null;
- }
-
- XmlElement steticDefinition = null;
-
- XmlDocument gui = cache [filename].GuiDocument;
- if (gui != null) {
- string wrappedTypeName = element.GetAttribute ("type");
- steticDefinition = (XmlElement) gui.DocumentElement.SelectSingleNode ("widget[@id='" + wrappedTypeName + "']");
- }
-
- CecilClassDescriptor cd = new CecilClassDescriptor (this, element, typeClassDescriptor, steticDefinition, cls);
-
- if (canGenerateCode && !cd.CanGenerateCode)
- canGenerateCode = false;
- return cd;
- }
-
- Stetic.ClassDescriptor FindType (AssemblyDefinition asm, TypeDefinition cls)
- {
- if (cls.BaseType == null)
- return null;
- Stetic.ClassDescriptor klass = Stetic.Registry.LookupClassByName (cls.BaseType.FullName);
- if (klass != null) return klass;
-
- TypeDefinition bcls = FindTypeDefinition (cls.BaseType.FullName);
- if (bcls == null)
- return null;
-
- return FindType (asm, bcls);
- }
-
- AssemblyDefinition ResolveAssembly (AssemblyNameReference aref)
- {
- return resolver.Resolve (aref, Path.GetDirectoryName (filename));
- }
-
- internal TypeDefinition FindTypeDefinition (string fullName)
- {
- TypeDefinition t = FindTypeDefinition (new Hashtable (), assembly, fullName);
- return t;
- }
-
- TypeDefinition FindTypeDefinition (Hashtable visited, AssemblyDefinition asm, string fullName)
- {
- if (visited.Contains (asm))
- return null;
-
- visited [asm] = asm;
-
- TypeDefinition cls = asm.MainModule.Types [fullName];
- if (cls != null)
- return cls;
-
- foreach (AssemblyNameReference aref in asm.MainModule.AssemblyReferences) {
- AssemblyDefinition basm = ResolveAssembly (aref);
- if (basm != null) {
- cls = basm.MainModule.Types [fullName];
- if (cls != null)
- return cls;
-/* cls = FindTypeDefinition (visited, basm, fullName);
- if (cls != null)
- return cls;
-*/ }
- }
- return null;
- }
-
- public override string[] GetLibraryDependencies ()
- {
- if (NeedsReload || dependencies == null)
- LoadDependencies ();
- return dependencies;
- }
-
- void LoadDependencies ()
- {
- RefreshFromCache ();
- if (cache_info == null || cache_info.ObjectsDocument == null) {
- dependencies = new string[0];
- return;
- }
- XmlElement elem = cache_info.ObjectsDocument.DocumentElement ["dependencies"];
- if (elem != null) {
- ArrayList list = new ArrayList ();
- foreach (XmlElement dep in elem.SelectNodes ("dependency"))
- list.Add (dep.InnerText);
- dependencies = (string[]) list.ToArray (typeof(string));
- } else
- dependencies = new string[0];
- }
-
- public static bool IsWidgetLibrary (string path)
- {
- // Info can be null if the library could not be scanned for some reason
- var info = cache [path];
- return info != null && info.HasWidgets;
- }
-
- public static string GetInstanceType (TypeDefinition td, TypeReference sourceType, TypeReference tref)
- {
- string tn = null;
- if (sourceType is GenericInstanceType) {
- GenericInstanceType it = (GenericInstanceType) sourceType;
- foreach (GenericParameter gc in td.GenericParameters) {
- if (gc.Name == tref.FullName) {
- tn = it.GenericArguments [gc.Position].FullName;
- break;
- }
- }
- }
- if (tn == null)
- tn = tref.FullName;
- tn = tn.Replace ('<', '[');
- tn = tn.Replace ('>', ']');
- return tn;
- }
-
- public static List<ComponentType> GetComponentTypes (Application app, string filename)
- {
- List<ComponentType> list = new List<ComponentType> ();
-
- LibraryCache.LibraryInfo info = cache.Refresh (new AssemblyResolver (app.Backend), filename);
- if (info.ObjectsDocument == null)
- return list;
-
- string defTargetGtkVersion = info.ObjectsDocument.DocumentElement.GetAttribute ("gtk-version");
- if (defTargetGtkVersion.Length == 0)
- defTargetGtkVersion = "2.4";
-
- AssemblyDefinition adef = AssemblyFactory.GetAssembly (filename);
-
- foreach (XmlElement elem in info.ObjectsDocument.SelectNodes ("objects/object")) {
- if (elem.GetAttribute ("internal") == "true" || elem.HasAttribute ("deprecated") || !elem.HasAttribute ("palette-category"))
- continue;
-
- string iconname = elem.GetAttribute ("icon");
- Gdk.Pixbuf icon = GetEmbeddedIcon (adef, iconname);
-
- string targetGtkVersion = elem.GetAttribute ("gtk-version");
- if (targetGtkVersion.Length == 0)
- targetGtkVersion = defTargetGtkVersion;
-
- ComponentType ct = new ComponentType (app,
- elem.GetAttribute ("type"),
- elem.GetAttribute ("label"),
- elem.GetAttribute ("type"),
- elem.GetAttribute ("palette-category"),
- targetGtkVersion,
- filename,
- icon);
-
- list.Add (ct);
- }
-
- return list;
- }
-
- public Gdk.Pixbuf GetEmbeddedIcon (string iconname)
- {
- return GetEmbeddedIcon (assembly, iconname);
- }
-
- static Gdk.Pixbuf GetEmbeddedIcon (AssemblyDefinition asm, string iconname)
- {
- Gdk.Pixbuf icon = null;
- if (iconname != null && iconname.Length > 0) {
- try {
- // Using the pixbuf resource constructor generates a gdk warning.
- EmbeddedResource res = GetResource (asm, iconname);
- Gdk.PixbufLoader loader = new Gdk.PixbufLoader (res.Data);
- icon = loader.Pixbuf;
- } catch {
- // Ignore
- }
- }
-
- if (icon == null) {
- ClassDescriptor cc = Registry.LookupClassByName ("Gtk.Bin");
- icon = cc.Icon;
- }
- return icon;
- }
-
- static EmbeddedResource GetResource (AssemblyDefinition asm, string name)
- {
- foreach (Resource res in asm.MainModule.Resources) {
- EmbeddedResource eres = res as EmbeddedResource;
- if (eres != null && eres.Name == name)
- return eres;
- }
- return null;
- }
-
- public override void Flush ()
- {
- base.Flush ();
- if (resolver != null)
- resolver.ClearCache ();
- }
-
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGenerationResult.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGenerationResult.cs
deleted file mode 100644
index 3e2dedcd84..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGenerationResult.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- [Serializable]
- public class CodeGenerationResult
- {
- SteticCompilationUnit[] units;
- string[] warnings;
-
- internal CodeGenerationResult (SteticCompilationUnit[] units, string[] warnings)
- {
- this.units = units;
- this.warnings = warnings;
- }
-
- public SteticCompilationUnit[] Units {
- get { return units; }
- }
-
- public string[] Warnings {
- get { return warnings; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGenerator.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGenerator.cs
deleted file mode 100644
index 7ea4b3d4df..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGenerator.cs
+++ /dev/null
@@ -1,432 +0,0 @@
-using System;
-using System.Reflection;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.IO;
-using System.Collections;
-
-namespace Stetic
-{
- internal static class CodeGenerator
- {
-// public static void GenerateProjectCode (string file, CodeDomProvider provider, GenerationOptions options, ProjectBackend[] projects)
-// {
-// CodeGenerationResult res = GenerateProjectCode (options, projects);
-//
-// string basePath = Path.GetDirectoryName (file);
-//
-// foreach (SteticCompilationUnit unit in res.Units) {
-// string fname;
-// if (unit.Name.Length == 0)
-// fname = file;
-// else
-// fname = Path.Combine (basePath, unit.Name);
-// StreamWriter fileStream = new StreamWriter (fname);
-// try {
-// provider.GenerateCodeFromCompileUnit (unit, fileStream, new CodeGeneratorOptions ());
-// } finally {
-// fileStream.Close ();
-// }
-// }
-// }
-
- public static CodeGenerationResult GenerateProjectCode (GenerationOptions options, ProjectBackend[] projects)
- {
- ArrayList warningList = new ArrayList ();
-
- List<SteticCompilationUnit> units = new List<SteticCompilationUnit> ();
-// SteticCompilationUnit globalUnit = new SteticCompilationUnit ("");
-// units.Add (globalUnit);
-
- if (options == null)
- options = new GenerationOptions ();
- CodeNamespace globalNs = new CodeNamespace (options.GlobalNamespace);
-// globalUnit.Namespaces.Add (globalNs);
-
- // Global class
-
- CodeTypeDeclaration globalType = new CodeTypeDeclaration ("Gui");
- globalType.Attributes = MemberAttributes.Private;
- globalType.TypeAttributes = TypeAttributes.NestedAssembly;
- globalNs.Types.Add (globalType);
-
- // Create the project initialization method
- // This method will only be added at the end if there
- // is actually something to initialize
-
- CodeMemberMethod initMethod = new CodeMemberMethod ();
- initMethod.Name = "Initialize";
- initMethod.ReturnType = new CodeTypeReference (typeof(void));
- initMethod.Attributes = MemberAttributes.Assembly | MemberAttributes.Static;
- initMethod.Parameters.Add (new CodeParameterDeclarationExpression (typeof(Gtk.Widget), "iconRenderer"));
-
- GeneratorContext initContext = new ProjectGeneratorContext (globalNs, globalType, initMethod.Statements, options);
- initContext.RootObject = new CodeArgumentReferenceExpression ("iconRenderer");
-
- // Generate icon factory creation
-
- foreach (ProjectBackend gp in projects) {
- if (gp.IconFactory.Icons.Count > 0)
- gp.IconFactory.GenerateBuildCode (initContext);
- }
- warningList.AddRange (initContext.Warnings);
-
- // Generate the code
- CodeGeneratorPartialClass.GenerateProjectGuiCode (globalNs, globalType, options, units, projects, warningList);
-
- GenerateProjectActionsCode (globalNs, options, projects);
-
- // Final step. If there is some initialization code, add all needed infrastructure
-
- globalType.Members.Add (initMethod);
-
- CodeMemberField initField = new CodeMemberField (typeof(bool), "initialized");
- initField.Attributes = MemberAttributes.Private | MemberAttributes.Static;
- globalType.Members.Add (initField);
-
- CodeFieldReferenceExpression initVar = new CodeFieldReferenceExpression (
- new CodeTypeReferenceExpression (globalNs.Name + ".Gui"),
- "initialized"
- );
-
- CodeConditionStatement initCondition = new CodeConditionStatement ();
- initCondition.Condition = new CodeBinaryOperatorExpression (
- initVar,
- CodeBinaryOperatorType.IdentityEquality,
- new CodePrimitiveExpression (false)
- );
- initCondition.TrueStatements.Add (new CodeAssignStatement (
- initVar,
- new CodePrimitiveExpression (true)
- ));
- initCondition.TrueStatements.AddRange (initMethod.Statements);
- initMethod.Statements.Clear ();
- initMethod.Statements.Add (initCondition);
-
- //create separate compilation unit for each type in the global namespace
- //and insert them at the begining of the units list.
- int index = 0;
- foreach (CodeTypeDeclaration type in globalNs.Types)
- {
- SteticCompilationUnit unit = new SteticCompilationUnit (type.Name);
- CodeNamespace ns = new CodeNamespace (globalNs.Name);
-
- ns.Types.Add (type);
- unit.Namespaces.Add (ns);
- units.Insert (index++, unit);
- }
-
- return new CodeGenerationResult (units.ToArray (), (string[]) warningList.ToArray (typeof(string)));
- }
-
- internal static void BindSignalHandlers (CodeExpression targetObjectVar, ObjectWrapper wrapper, Stetic.WidgetMap map, CodeStatementCollection statements, GenerationOptions options)
- {
- foreach (Signal signal in wrapper.Signals) {
- SignalDescriptor descriptor = signal.SignalDescriptor;
-
- CodeExpression createDelegate = new CodeDelegateCreateExpression (
- new CodeTypeReference (descriptor.HandlerTypeName, CodeTypeReferenceOptions.GlobalReference),
- new CodeThisReferenceExpression (),
- signal.Handler);
-
- CodeAttachEventStatement cevent = new CodeAttachEventStatement (
- new CodeEventReferenceExpression (
- map.GetWidgetExp (wrapper),
- descriptor.Name),
- createDelegate);
-
- statements.Add (cevent);
- }
-
- Wrapper.Widget widget = wrapper as Wrapper.Widget;
- if (widget != null && widget.IsTopLevel) {
- // Bind local action signals
- foreach (Wrapper.ActionGroup grp in widget.LocalActionGroups) {
- foreach (Wrapper.Action ac in grp.Actions)
- BindSignalHandlers (targetObjectVar, ac, map, statements, options);
- }
- }
-
- Gtk.Container cont = wrapper.Wrapped as Gtk.Container;
- if (cont != null) {
- foreach (Gtk.Widget child in cont.AllChildren) {
- Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup (child);
- if (ww != null)
- BindSignalHandlers (targetObjectVar, ww, map, statements, options);
- }
- }
-
- }
-
- static void GenerateProjectActionsCode (CodeNamespace cns, GenerationOptions options, params ProjectBackend[] projects)
- {
- bool multiProject = projects.Length > 1;
-
- CodeTypeDeclaration type = new CodeTypeDeclaration ("ActionGroups");
- type.Attributes = MemberAttributes.Private;
- type.TypeAttributes = TypeAttributes.NestedAssembly;
- cns.Types.Add (type);
-
- // Generate the global action group getter
-
- CodeMemberMethod met = new CodeMemberMethod ();
- met.Name = "GetActionGroup";
- type.Members.Add (met);
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(Type), "type"));
- if (multiProject)
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(string), "file"));
- met.ReturnType = new CodeTypeReference (typeof(Gtk.ActionGroup));
- met.Attributes = MemberAttributes.Public | MemberAttributes.Static;
-
- CodeMethodInvokeExpression call = new CodeMethodInvokeExpression (
- new CodeMethodReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (cns.Name + ".ActionGroups")),
- "GetActionGroup"
- ),
- new CodePropertyReferenceExpression (
- new CodeArgumentReferenceExpression ("type"),
- "FullName"
- )
- );
- if (multiProject)
- call.Parameters.Add (new CodeArgumentReferenceExpression ("file"));
-
- met.Statements.Add (new CodeMethodReturnStatement (call));
-
- // Generate the global action group getter (overload)
-
- met = new CodeMemberMethod ();
- met.Name = "GetActionGroup";
- type.Members.Add (met);
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(string), "name"));
- if (multiProject)
- met.Parameters.Add (new CodeParameterDeclarationExpression (typeof(string), "file"));
- met.ReturnType = new CodeTypeReference (typeof(Gtk.ActionGroup));
- met.Attributes = MemberAttributes.Public | MemberAttributes.Static;
-
- CodeArgumentReferenceExpression cfile = new CodeArgumentReferenceExpression ("file");
- CodeArgumentReferenceExpression cid = new CodeArgumentReferenceExpression ("name");
-
- CodeStatementCollection projectCol = met.Statements;
- int n=1;
-
- foreach (ProjectBackend gp in projects) {
-
- CodeStatementCollection widgetCol;
-
- if (multiProject) {
- CodeConditionStatement pcond = new CodeConditionStatement ();
- pcond.Condition = new CodeBinaryOperatorExpression (
- cfile,
- CodeBinaryOperatorType.IdentityEquality,
- new CodePrimitiveExpression (gp.Id)
- );
- projectCol.Add (pcond);
-
- widgetCol = pcond.TrueStatements;
- projectCol = pcond.FalseStatements;
- } else {
- widgetCol = projectCol;
- }
-
- foreach (Wrapper.ActionGroup grp in gp.ActionGroups) {
- string fname = "group" + (n++);
- CodeMemberField grpField = new CodeMemberField (new CodeTypeReference (typeof(Gtk.ActionGroup), CodeTypeReferenceOptions.GlobalReference), fname);
- grpField.Attributes |= MemberAttributes.Static;
- type.Members.Add (grpField);
- CodeFieldReferenceExpression grpVar = new CodeFieldReferenceExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (cns.Name + ".ActionGroups", CodeTypeReferenceOptions.GlobalReference)),
- fname
- );
-
- CodeConditionStatement pcond = new CodeConditionStatement ();
- pcond.Condition = new CodeBinaryOperatorExpression (
- cid,
- CodeBinaryOperatorType.IdentityEquality,
- new CodePrimitiveExpression (grp.Name)
- );
- widgetCol.Add (pcond);
-
- // If the group has not yet been created, create it
- CodeConditionStatement pcondGrp = new CodeConditionStatement ();
- pcondGrp.Condition = new CodeBinaryOperatorExpression (
- grpVar,
- CodeBinaryOperatorType.IdentityEquality,
- new CodePrimitiveExpression (null)
- );
-
- pcondGrp.TrueStatements.Add (
- new CodeAssignStatement (
- grpVar,
- new CodeObjectCreateExpression (grp.Name)
- )
- );
-
- pcond.TrueStatements.Add (pcondGrp);
- pcond.TrueStatements.Add (new CodeMethodReturnStatement (grpVar));
-
- widgetCol = pcond.FalseStatements;
- }
- widgetCol.Add (new CodeMethodReturnStatement (new CodePrimitiveExpression (null)));
- }
- if (met.Statements.Count == 0)
- met.Statements.Add (new CodeMethodReturnStatement (new CodePrimitiveExpression (null)));
- }
-
- internal static List<ObjectBindInfo> GetFieldsToBind (ObjectWrapper wrapper)
- {
- List<ObjectBindInfo> tobind = new List<ObjectBindInfo> ();
- GetFieldsToBind (tobind, wrapper);
- return tobind;
- }
-
- static void GetFieldsToBind (List<ObjectBindInfo> tobind, ObjectWrapper wrapper)
- {
- string memberName = null;
-
- if (wrapper is Wrapper.Widget) {
- Wrapper.Widget ww = wrapper as Wrapper.Widget;
- if (!String.IsNullOrEmpty (ww.UIManagerName))
- tobind.Add (new ObjectBindInfo ("Gtk.UIManager", ww.UIManagerName));
-
- if (!ww.IsTopLevel && ww.InternalChildProperty == null && !ww.Unselectable)
- memberName = ((Wrapper.Widget) wrapper).Wrapped.Name;
- }
- else if (wrapper is Wrapper.Action)
- memberName = ((Wrapper.Action) wrapper).Name;
-
- if (memberName != null) {
- ObjectBindInfo binfo = new ObjectBindInfo (wrapper.WrappedTypeName, memberName);
- tobind.Add (binfo);
- }
-
- Wrapper.ActionGroup agroup = wrapper as Wrapper.ActionGroup;
- if (agroup != null) {
- foreach (Wrapper.Action ac in agroup.Actions)
- GetFieldsToBind (tobind, ac);
- }
-
- Wrapper.Widget widget = wrapper as Wrapper.Widget;
- if (widget != null && widget.IsTopLevel) {
- // Generate fields for local actions
- foreach (Wrapper.ActionGroup grp in widget.LocalActionGroups) {
- GetFieldsToBind (tobind, grp);
- }
- }
-
- Gtk.Container cont = wrapper.Wrapped as Gtk.Container;
- if (cont != null) {
- foreach (Gtk.Widget child in cont.AllChildren) {
- Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup (child);
- if (ww != null)
- GetFieldsToBind (tobind, ww);
- }
- }
- }
-
- public static WidgetMap GenerateCreationCode (CodeNamespace cns, CodeTypeDeclaration type, Gtk.Widget w, CodeExpression widgetVarExp, CodeStatementCollection statements, GenerationOptions options, ArrayList warnings)
- {
- statements.Add (new CodeCommentStatement ("Widget " + w.Name));
- GeneratorContext ctx = new ProjectGeneratorContext (cns, type, statements, options);
- Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup (w);
- ctx.GenerateCreationCode (ww, widgetVarExp);
- ctx.EndGeneration ();
- warnings.AddRange (ctx.Warnings);
- return ctx.WidgetMap;
- }
-
- public static WidgetMap GenerateCreationCode (CodeNamespace cns, CodeTypeDeclaration type, Wrapper.ActionGroup grp, CodeExpression groupVarExp, CodeStatementCollection statements, GenerationOptions options, ArrayList warnings)
- {
- statements.Add (new CodeCommentStatement ("Action group " + grp.Name));
- GeneratorContext ctx = new ProjectGeneratorContext (cns, type, statements, options);
- ctx.GenerateCreationCode (grp, groupVarExp);
- ctx.EndGeneration ();
- warnings.AddRange (ctx.Warnings);
- return ctx.WidgetMap;
- }
- }
-
- class ProjectGeneratorContext: GeneratorContext
- {
- CodeTypeDeclaration type;
-
- public ProjectGeneratorContext (CodeNamespace cns, CodeTypeDeclaration type, CodeStatementCollection statements, GenerationOptions options): base (cns, "w", statements, options)
- {
- this.type = type;
- }
-
- public override CodeExpression GenerateInstanceExpression (ObjectWrapper wrapper, CodeExpression newObject)
- {
- string typeName = wrapper.WrappedTypeName;
- string memberName = null;
- if (wrapper is Wrapper.Widget)
- memberName = ((Wrapper.Widget) wrapper).Wrapped.Name;
- else if (wrapper is Wrapper.Action)
- memberName = ((Wrapper.Action) wrapper).Name;
-
- if (memberName == null)
- return base.GenerateInstanceExpression (wrapper, newObject);
-
-// if (Options.UsePartialClasses) {
- // Don't generate fields for top level widgets and for widgets accessible
- // through other widget's properties
- Wrapper.Widget ww = wrapper as Wrapper.Widget;
- if (ww == null || (!ww.IsTopLevel && ww.InternalChildProperty == null && !ww.Unselectable)) {
- type.Members.Add (
- new CodeMemberField (
- new CodeTypeReference (typeName, CodeTypeReferenceOptions.GlobalReference),
- memberName
- )
- );
- CodeExpression var = new CodeFieldReferenceExpression (
- new CodeThisReferenceExpression (),
- memberName
- );
-
- Statements.Add (
- new CodeAssignStatement (
- var,
- newObject
- )
- );
- return var;
- } else
- return base.GenerateInstanceExpression (wrapper, newObject);
-// } else {
-// CodeExpression var = base.GenerateInstanceExpression (wrapper, newObject);
-// Statements.Add (
-// new CodeAssignStatement (
-// new CodeIndexerExpression (
-// new CodeVariableReferenceExpression ("bindings"),
-// new CodePrimitiveExpression (memberName)
-// ),
-// var
-// )
-// );
-// return var;
-// }
- }
- }
-
- [Serializable]
- public class SteticCompilationUnit: CodeCompileUnit
- {
- string name;
-
- public SteticCompilationUnit (string name)
- {
- this.name = name;
- }
-
- public string Name {
- get { return name; }
- internal set { name = value; }
- }
-
- public CodeNamespace Namespace
- {
- get { return (Namespaces.Count > 0) ? Namespaces [0] : null; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGeneratorPartialClass.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGeneratorPartialClass.cs
deleted file mode 100644
index 7371b4892c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/CodeGeneratorPartialClass.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-
-using System;
-using System.Reflection;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.Collections;
-using System.IO;
-
-namespace Stetic
-{
- internal static class CodeGeneratorPartialClass
- {
- public static void GenerateProjectGuiCode (CodeNamespace globalNs, CodeTypeDeclaration globalType, GenerationOptions options, List<SteticCompilationUnit> units, ProjectBackend[] projects, ArrayList warnings)
- {
- // Generate code for each project
- foreach (ProjectBackend gp in projects) {
-
- // Generate top levels
- foreach (Gtk.Widget w in gp.Toplevels) {
- Stetic.Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup (w);
- string topLevelName = wwidget.Name;
- if (gp.ComponentNeedsCodeGeneration (topLevelName)) {
- //designer file for widget could be changed beyond stetic process
- //and we nead update wrapper before code generation
- //during reloading wrappered widget w could be changed;
- Gtk.Widget currentw = w;
- if (gp.ReloadTopLevel (topLevelName)) {
- currentw = gp.GetWidget (topLevelName);
- }
- GenerateWidgetCode (globalNs, options, units, currentw, warnings);
- }
- }
-
- // Generate global action groups
- foreach (Wrapper.ActionGroup agroup in gp.ActionGroups) {
- string groupName = agroup.Name;
- if (gp.ComponentNeedsCodeGeneration (groupName)) {
- //designer file for action group could be changed beyond stetic process
- //and we nead update wrapper
- gp.ReloadActionGroup (groupName);
- GenerateGlobalActionGroupCode (globalNs, options, units, agroup, warnings);
- }
- }
- }
- }
-
- static CodeTypeDeclaration CreatePartialClass (List<SteticCompilationUnit> units, GenerationOptions options, string name)
- {
- SteticCompilationUnit unit;
-
- unit = new SteticCompilationUnit (name);
- units.Add (unit);
-
- string ns = "";
- int i = name.LastIndexOf ('.');
- if (i != -1) {
- ns = name.Substring (0, i);
- name = name.Substring (i+1);
- }
-
- CodeTypeDeclaration type = new CodeTypeDeclaration (name);
- type.IsPartial = true;
- type.Attributes = MemberAttributes.Public;
- type.TypeAttributes = TypeAttributes.Public;
-
- CodeNamespace cns = new CodeNamespace (ns);
- cns.Types.Add (type);
- unit.Namespaces.Add (cns);
- return type;
- }
-
-
- static void GenerateWidgetCode (CodeNamespace globalNs, GenerationOptions options, List<SteticCompilationUnit> units, Gtk.Widget w, ArrayList warnings)
- {
- // Generate the build method
-
- CodeTypeDeclaration type = CreatePartialClass (units, options, w.Name);
- CodeMemberMethod met = new CodeMemberMethod ();
- met.Name = "Build";
- type.Members.Add (met);
- met.ReturnType = new CodeTypeReference (typeof(void));
- met.Attributes = MemberAttributes.Family;
-
- Stetic.Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup (w);
-
- if (options.GenerateEmptyBuildMethod) {
- GenerateWrapperFields (type, wwidget);
- return;
- }
-
- met.Statements.Add (
- new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression (new CodeTypeReference (globalNs.Name + ".Gui", CodeTypeReferenceOptions.GlobalReference)),
- "Initialize",
- new CodeThisReferenceExpression ()
- )
- );
-
- if (wwidget.GeneratePublic)
- type.TypeAttributes = TypeAttributes.Public;
- else
- type.TypeAttributes = TypeAttributes.NotPublic;
-
- if (!String.IsNullOrEmpty (wwidget.UIManagerName))
- type.Members.Add (new CodeMemberField (new CodeTypeReference ("Gtk.UIManager", CodeTypeReferenceOptions.GlobalReference), wwidget.UIManagerName));
-
- Stetic.WidgetMap map = Stetic.CodeGenerator.GenerateCreationCode (globalNs, type, w, new CodeThisReferenceExpression (), met.Statements, options, warnings);
- CodeGenerator.BindSignalHandlers (new CodeThisReferenceExpression (), wwidget, map, met.Statements, options);
- }
-
- static void GenerateWrapperFields (CodeTypeDeclaration type, ObjectWrapper wrapper)
- {
- foreach (ObjectBindInfo binfo in CodeGenerator.GetFieldsToBind (wrapper)) {
- type.Members.Add (
- new CodeMemberField (
- new CodeTypeReference (binfo.TypeName, CodeTypeReferenceOptions.GlobalReference),
- binfo.Name
- )
- );
- }
- }
-
-
- static void GenerateGlobalActionGroupCode (CodeNamespace globalNs, GenerationOptions options, List<SteticCompilationUnit> units, Wrapper.ActionGroup agroup, ArrayList warnings)
- {
- CodeTypeDeclaration type = CreatePartialClass (units, options, agroup.Name);
-
- // Generate the build method
-
- CodeMemberMethod met = new CodeMemberMethod ();
- met.Name = "Build";
- type.Members.Add (met);
- met.ReturnType = new CodeTypeReference (typeof(void));
- met.Attributes = MemberAttributes.Public;
-
- Stetic.WidgetMap map = Stetic.CodeGenerator.GenerateCreationCode (globalNs, type, agroup, new CodeThisReferenceExpression (), met.Statements, options, warnings);
-
- foreach (Wrapper.Action ac in agroup.Actions)
- CodeGenerator.BindSignalHandlers (new CodeThisReferenceExpression (), ac, map, met.Statements, options);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Component.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Component.cs
deleted file mode 100644
index 1a1d495ccf..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Component.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-
-using System;
-using System.Collections;
-
-namespace Stetic
-{
- public class Component: MarshalByRefObject, IObjectFrontend
- {
- protected string name;
- protected ComponentType type;
- protected string typeName;
- protected object backend;
- protected Application app;
-
- public event EventHandler Changed;
-
- internal Component (Application app, object backend, string name, ComponentType type)
- {
- this.app = app;
- this.backend = backend;
- this.name = name;
- this.type = type;
- }
-
- public virtual void Dispose ()
- {
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- if (app != null)
- app.DisposeComponent (this);
- }
-
- public SignalCollection GetSignals ()
- {
- if (backend is ObjectWrapper)
- return ((ObjectWrapper)backend).Signals;
- else
- return new SignalCollection ();
- }
-
- public void RemoveSignal (Signal signal)
- {
- if (backend is ObjectWrapper && app != null)
- app.Backend.RemoveWidgetSignal ((ObjectWrapper) backend, signal);
- }
-
- public virtual Component[] GetChildren ()
- {
- return new Component [0];
- }
-
- void IObjectFrontend.NotifyChanged ()
- {
- OnChanged ();
- }
-
- protected virtual void OnChanged ()
- {
- if (Changed != null)
- Changed (this, EventArgs.Empty);
- }
-
- public virtual string Name {
- get { return name; }
- set { name = value; }
- }
-
- public virtual ComponentType Type {
- get {
- return type;
- }
- }
-
- public virtual bool GeneratePublic {
- get { return true; }
- set {}
- }
-
- internal object Backend {
- get { return backend; }
- }
-
- internal static MarshalByRefObject GetSafeReference (MarshalByRefObject ob)
- {
- // Make sure we don't leak the wrapper type to the frontend process
-
- if (ob is Wrapper.Window) {
- System.Runtime.Remoting.RemotingServices.Marshal (ob, null, typeof(Wrapper.Window));
- } else if (ob is Wrapper.Container) {
- System.Runtime.Remoting.RemotingServices.Marshal (ob, null, typeof(Wrapper.Container));
- } else if (ob is Wrapper.Widget) {
- System.Runtime.Remoting.RemotingServices.Marshal (ob, null, typeof(Wrapper.Widget));
- } else if (ob is ObjectWrapper) {
- System.Runtime.Remoting.RemotingServices.Marshal (ob, null, typeof(ObjectWrapper));
- }
- return ob;
- }
-
- public override string ToString ()
- {
- return base.ToString() + " " + backend;
- }
-
- public ObjectBindInfo[] GetObjectBindInfo ()
- {
- ObjectWrapper ww = backend as ObjectWrapper;
- if (ww != null)
- return app.Backend.GetBoundComponents (ww);
- else
- return new ObjectBindInfo [0];
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentEventHandler.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentEventHandler.cs
deleted file mode 100644
index d4226f0da7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentEventHandler.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public delegate void ComponentEventHandler (object sender, ComponentEventArgs args);
- public delegate void ComponentNameEventHandler (object sender, ComponentNameEventArgs args);
- public delegate void ComponentRemovedEventHandler (object sender, ComponentRemovedEventArgs args);
-
- public class ComponentEventArgs: EventArgs
- {
- Project project;
- Component component;
-
- internal ComponentEventArgs (Project p, Component c)
- {
- project = p;
- component = c;
- }
-
- public Project Project {
- get { return project; }
- }
-
- public Component Component {
- get { return component; }
- }
- }
-
- public class ComponentNameEventArgs: ComponentEventArgs
- {
- string oldName;
-
- internal ComponentNameEventArgs (Project p, Component c, string oldName): base (p, c)
- {
- this.oldName = oldName;
- }
-
- public string OldName {
- get { return oldName; }
- }
-
- public string NewName {
- get { return Component.Name; }
- }
- }
-
- public class ComponentRemovedEventArgs: EventArgs
- {
- Project project;
- string componentName;
-
- internal ComponentRemovedEventArgs (Project p, string name)
- {
- project = p;
- componentName = name;
- }
-
- public Project Project {
- get { return project; }
- }
-
- public string ComponentName {
- get { return componentName; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentSignalEventHandler.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentSignalEventHandler.cs
deleted file mode 100644
index 07c6263a71..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentSignalEventHandler.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public delegate void ComponentSignalEventHandler (object sender, ComponentSignalEventArgs args);
-
- public class ComponentSignalEventArgs: ComponentEventArgs
- {
- public Signal oldSignal;
- public Signal signal;
-
- public ComponentSignalEventArgs (Project p, Component c, Signal oldSignal, Signal signal): base (p, c)
- {
- this.oldSignal = oldSignal;
- this.signal = signal;
- }
-
- public Signal Signal {
- get { return signal; }
- }
-
- public Signal OldSignal {
- get { return oldSignal; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentType.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentType.cs
deleted file mode 100644
index 47ed725282..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ComponentType.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public class ComponentType
- {
- Application app;
- string name;
- string description;
- string className;
- string category;
- Gdk.Pixbuf icon;
- ActionComponent action;
- string targetGtkVersion;
- string library;
- static ComponentType unknown;
-
- internal ComponentType (Application app, string name, string desc, string className, string category, string targetGtkVersion, string library, Gdk.Pixbuf icon)
- {
- this.app = app;
- this.name = name;
- this.description = desc;
- this.icon = icon;
- this.className = className;
- this.category = category;
- this.targetGtkVersion = targetGtkVersion;
- this.library = library;
- }
-
- internal ComponentType (Application app, ActionComponent action)
- {
- this.action = action;
- this.app = app;
- this.name = action.Name;
- this.description = action.Label != null ? action.Label.Replace ("_", "") : action.Name;
- this.icon = action.Icon;
- this.className = "Gtk.Action";
- this.category = "Actions / " + action.ActionGroup.Name;
- this.targetGtkVersion = "2.4"; // Not version-specific
- }
-
- public string Name {
- get { return name; }
- }
-
- public string ClassName {
- get { return className; }
- }
-
- public string Category {
- get { return category; }
- }
-
- public string Description {
- get { return description; }
- }
-
- public string Library {
- get { return library; }
- }
-
- public Gdk.Pixbuf Icon {
- get { return icon; }
- }
-
- internal ActionComponent Action {
- get { return action; }
- }
-
- internal static ComponentType Unknown {
- get {
- if (unknown == null) {
- unknown = new ComponentType (null, "Unknown", "Unknown", "", "", "2.4", null, WidgetUtils.MissingIcon);
- }
- return unknown;
- }
- }
-
- public object[] InitializationValues {
- get {
- if (app == null)
- return new object [0];
- return app.Backend.GetClassDescriptorInitializationValues (name);
- }
- }
-
- public string TargetGtkVersion {
- get {
- return targetGtkVersion;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ContainerUndoRedoManager.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ContainerUndoRedoManager.cs
deleted file mode 100644
index ddfe62d2e7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ContainerUndoRedoManager.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-
-using System;
-using System.Xml;
-using System.Collections;
-
-namespace Stetic
-{
- class ContainerUndoRedoManager: UndoRedoManager
- {
- protected override object GetDiff (ObjectWrapper w)
- {
- // Only track changes in widgets.
- Wrapper.Widget widget = w as Wrapper.Widget;
- if (widget != null) return w.GetUndoDiff ();
- else return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ContextMenu.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ContextMenu.cs
deleted file mode 100644
index 3b64a286f5..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ContextMenu.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-using Gtk;
-using System;
-using System.Collections;
-using System.Reflection;
-using Mono.Unix;
-
-namespace Stetic {
-
- class ContextMenu : Gtk.Menu {
-
- Gtk.Widget widget;
- IEditableObject editable;
-
- public ContextMenu (Placeholder ph)
- {
- MenuItem item;
-
- editable = ph;
- this.widget = ph;
-
- item = LabelItem (ph);
- item.Sensitive = false;
- Add (item);
-
- item = new MenuItem (Catalog.GetString ("_Select"));
- item.Sensitive = false;
- Add (item);
-
- BuildContextMenu (Stetic.Wrapper.Container.LookupParent (ph), true, ph);
- }
-
- public ContextMenu (Stetic.Wrapper.Widget wrapper) : this (wrapper, wrapper.Wrapped) {}
-
- public ContextMenu (Stetic.Wrapper.Widget wrapper, Gtk.Widget context)
- {
- MenuItem item;
-
- editable = wrapper;
- widget = wrapper.Wrapped;
-
- if (widget == context) {
- item = LabelItem (widget);
- item.Sensitive = false;
- Add (item);
- }
-
- item = new MenuItem (Catalog.GetString ("_Select"));
- item.Activated += DoSelect;
- Add (item);
-
- ClassDescriptor klass = wrapper.ClassDescriptor;
- if (klass != null) {
- foreach (ItemDescriptor id in klass.ContextMenu) {
- CommandDescriptor cmd = (CommandDescriptor)id;
- if (!cmd.VisibleFor (widget))
- continue;
- item = new MenuItem (cmd.Label);
- if (cmd.Enabled (widget, context)) {
- Gtk.Widget wdup = widget, cdup = context; // FIXME bxc 75689
- item.Activated += delegate (object o, EventArgs args) {
- cmd.Run (wdup, cdup);
- };
- } else
- item.Sensitive = false;
- Add (item);
- }
- }
-
- BuildContextMenu (wrapper.ParentWrapper, widget == context, context);
- }
-
- void BuildContextMenu (Stetic.Wrapper.Widget parentWrapper, bool top, Widget context)
- {
- MenuItem item;
-
- item = new ImageMenuItem (Gtk.Stock.Cut, null);
- if (editable.CanCut)
- item.Activated += DoCut;
- else
- item.Sensitive = false;
- Add (item);
-
- item = new ImageMenuItem (Gtk.Stock.Copy, null);
- if (editable.CanCopy)
- item.Activated += DoCopy;
- else
- item.Sensitive = false;
- Add (item);
-
- item = new ImageMenuItem (Gtk.Stock.Paste, null);
- if (editable.CanPaste)
- item.Activated += DoPaste;
- else
- item.Sensitive = false;
- Add (item);
-
- if (editable.CanDelete) {
- item = new ImageMenuItem (Gtk.Stock.Delete, null);
- item.Activated += DoDelete;
- Add (item);
- }
-
- if (top) {
- for (; parentWrapper != null; parentWrapper = parentWrapper.ParentWrapper) {
- Add (new SeparatorMenuItem ());
-
- item = LabelItem (parentWrapper.Wrapped);
- item.Submenu = new ContextMenu (parentWrapper, context);
- Add (item);
- }
- }
-
- ShowAll ();
- }
-
- protected override void OnSelectionDone ()
- {
- Destroy ();
- }
-
- void DoSelect (object obj, EventArgs args)
- {
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (widget);
- if (wrapper != null)
- wrapper.Select ();
- }
-
- void DoCut (object obj, EventArgs args)
- {
- editable.Cut ();
- }
-
- void DoCopy (object obj, EventArgs args)
- {
- editable.Copy ();
- }
-
- void DoPaste (object obj, EventArgs args)
- {
- editable.Paste ();
- }
-
- void DoDelete (object obj, EventArgs args)
- {
- editable.Delete ();
- }
-
- static MenuItem LabelItem (Gtk.Widget widget)
- {
- ImageMenuItem item;
- Label label;
-
- label = new Label (widget is Placeholder ? Catalog.GetString ("Placeholder") : widget.Name);
- label.UseUnderline = false;
- label.SetAlignment (0.0f, 0.5f);
- item = new ImageMenuItem ();
- item.Add (label);
-
- Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (widget);
-
- if (wrapper != null) {
- ClassDescriptor klass = wrapper.ClassDescriptor;
- if (klass != null) {
- Gdk.Pixbuf pixbuf = klass.Icon;
- int width, height;
- Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out width, out height);
- item.Image = new Gtk.Image (pixbuf.ScaleSimple (width, height, Gdk.InterpType.Bilinear));
- }
- }
-
- return item;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Designer.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Designer.cs
deleted file mode 100644
index 21aaf500c7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Designer.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Designer.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-//
-
-using System;
-
-namespace Stetic
-{
- public abstract class Designer: PluggableWidget
- {
- protected Designer (Application app): base (app)
- {
- }
-
- internal virtual void SetActive ()
- {
- }
-
- public abstract ProjectItemInfo ProjectItem { get; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Glade.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Glade.cs
deleted file mode 100644
index 4fcd4ff76a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Glade.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Xml;
-using System.Collections;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using Mono.Unix;
-
-using Gtk;
-
-namespace Stetic {
-
- internal static class GladeFiles {
-
- public static void Import (ProjectBackend project, string filename)
- {
- XmlDocument doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
- doc.XmlResolver = null;
- doc.Load (filename);
- project.Id = System.IO.Path.GetFileName (filename);
- doc = GladeUtils.XslImportTransform (doc);
-
- XmlNode node = doc.SelectSingleNode ("/glade-interface");
- if (node == null)
- throw new ApplicationException (Catalog.GetString ("Not a glade file according to node name."));
-
- ObjectReader reader = new ObjectReader (project, FileFormat.Glade);
- foreach (XmlElement toplevel in node.SelectNodes ("widget")) {
- Wrapper.Container wrapper = Stetic.ObjectWrapper.ReadObject (reader, toplevel, null) as Wrapper.Container;
- if (wrapper != null)
- project.AddWidget ((Gtk.Widget)wrapper.Wrapped);
- }
- }
-
- public static void Export (ProjectBackend project, string filename)
- {
- XmlDocument doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
-
- XmlElement toplevel = doc.CreateElement ("glade-interface");
- doc.AppendChild (toplevel);
-
- ObjectWriter owriter = new ObjectWriter (doc, FileFormat.Glade);
- foreach (Widget w in project.Toplevels) {
- Stetic.Wrapper.Container wrapper = Stetic.Wrapper.Container.Lookup (w);
- if (wrapper == null)
- continue;
-
- XmlElement elem = wrapper.Write (owriter);
- if (elem != null)
- toplevel.AppendChild (elem);
- }
-
- doc = GladeUtils.XslExportTransform (doc);
-
- // FIXME; if you use UTF8, it starts with a BOM???
- XmlTextWriter writer = new XmlTextWriter (filename, System.Text.Encoding.ASCII);
- writer.Formatting = Formatting.Indented;
- doc.Save (writer);
- writer.Close ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Grid.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Grid.cs
deleted file mode 100644
index 5f82fd0253..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Grid.cs
+++ /dev/null
@@ -1,347 +0,0 @@
-using Gtk;
-using System;
-using System.Collections;
-
-namespace Stetic {
-
- internal class Grid : Gtk.Container {
-
- public Grid () : base ()
- {
- BorderWidth = 2;
- WidgetFlags |= WidgetFlags.NoWindow;
- lines = new ArrayList ();
- group = null;
- }
-
- // Padding constants
- const int groupPad = 6;
- const int hPad = 6;
- const int linePad = 3;
-
- // Theme-based sizes; computed at first SizeRequest
- static int indent = -1;
- static int lineHeight = -1;
-
- Grid[] group;
- public static void Connect (params Grid[] grids)
- {
- for (int i = 0; i < grids.Length; i++) {
- grids[i].group = new Grid[grids.Length - 1];
- Array.Copy (grids, 0, grids[i].group, 0, i);
- Array.Copy (grids, i + 1, grids[i].group, i, grids.Length - i - 1);
- }
- }
-
- class Pair {
- Gtk.Widget label;
- Gtk.Widget editor;
-
- public Pair (Grid grid, string name, Widget editor) : this (grid, name, editor, null) {}
-
- public Pair (Grid grid, string name, Widget editor, string description)
- {
- Gtk.Label l = new Label (name);
- l.UseMarkup = true;
- l.Justify = Justification.Left;
- l.Xalign = 0;
- l.Show ();
-
- if (description == null)
- label = l;
- else {
- Gtk.EventBox ebox = new Gtk.EventBox ();
- ebox.Add (l);
- ebox.Show ();
- ebox.TooltipText = description;
- label = ebox;
- }
- label.Parent = grid;
-
- this.editor = editor;
- editor.Parent = grid;
- editor.Show ();
- }
-
- public Widget Label {
- get {
- return label;
- }
- }
-
- public Widget Editor {
- get {
- return editor;
- }
- }
- }
-
- // list of widgets and Stetic.Grid.Pairs
- ArrayList lines;
-
- public void Append (Widget w)
- {
- w.Parent = this;
- w.Show ();
-
- lines.Add (w);
- QueueDraw ();
- }
-
- public void Append (Widget w, string description)
- {
- if ((w.WidgetFlags & WidgetFlags.NoWindow) != 0) {
- Gtk.EventBox ebox = new Gtk.EventBox ();
- ebox.Add (w);
- ebox.Show ();
- w = ebox;
- }
- w.Parent = this;
- w.Show ();
- w.TooltipText = description;
- lines.Add (w);
- QueueDraw ();
- }
-
- public void AppendLabel (string text)
- {
- Gtk.Label label = new Label (text);
- label.UseMarkup = true;
- label.Justify = Justification.Left;
- label.Xalign = 0;
- Append (label);
- }
-
- public void AppendGroup (string name, bool expanded)
- {
- Gtk.Expander exp = new Expander ("<b>" + name + "</b>");
- exp.UseMarkup = true;
- exp.Expanded = expanded;
- exp.AddNotification ("expanded", ExpansionChanged);
- Append (exp);
- }
-
- public void AppendPair (string label, Widget editor, string description)
- {
- Stetic.Grid.Pair pair = new Pair (this, label, editor, description);
- lines.Add (pair);
- QueueDraw ();
- }
-
- protected override void OnRemoved (Widget w)
- {
- w.Unparent ();
- }
-
- void ExpansionChanged (object obj, GLib.NotifyArgs args)
- {
- Gtk.Expander exp = obj as Gtk.Expander;
-
- int ind = lines.IndexOf (exp);
- if (ind == -1)
- return;
-
- ind++;
- while (ind < lines.Count && !(lines[ind] is Gtk.Expander)) {
- if (lines[ind] is Widget) {
- Widget w = (Widget)lines[ind];
- if (exp.Expanded)
- w.Show ();
- else
- w.Hide ();
- } else if (lines[ind] is Pair) {
- Pair p = (Pair)lines[ind];
- if (exp.Expanded) {
- p.Label.Show ();
- p.Editor.Show ();
- } else {
- p.Label.Hide ();
- p.Editor.Hide ();
- }
- }
- ind++;
- }
-
- QueueDraw ();
- }
-
- protected void Clear ()
- {
- foreach (object obj in lines) {
- if (obj is Widget)
- ((Widget)obj).Destroy ();
- else if (obj is Pair) {
- Pair p = (Pair)obj;
- p.Label.Destroy ();
- p.Editor.Destroy ();
- }
- }
-
- lines.Clear ();
- }
-
- protected override void ForAll (bool include_internals, Gtk.Callback callback)
- {
- if (!include_internals)
- return;
-
- foreach (object obj in lines) {
- if (obj is Widget)
- callback ((Widget)obj);
- else if (obj is Pair) {
- Pair p = (Pair)obj;
- callback (p.Label);
- callback (p.Editor);
- }
- }
- }
-
- // These are figured out at requisition time and used again at
- // allocation time.
- int lwidth, ewidth;
-
- void SizeRequestGrid (Grid grid, ref Gtk.Requisition req)
- {
- bool visible = true;
-
- req.Width = req.Height = 0;
- foreach (object obj in grid.lines) {
- if (obj is Expander) {
- Gtk.Widget w = (Gtk.Widget)obj;
- Gtk.Requisition childreq;
-
- childreq = w.SizeRequest ();
- if (req.Width < childreq.Width)
- req.Width = childreq.Width;
- req.Height += groupPad + childreq.Height;
-
- visible = ((Gtk.Expander)obj).Expanded;
-
- if (indent == -1) {
- // Seems like there should be an easier way...
- int focusWidth = (int)w.StyleGetProperty ("focus-line-width");
- int focusPad = (int)w.StyleGetProperty ("focus-padding");
- int expanderSize = (int)w.StyleGetProperty ("expander-size");
- int expanderSpacing = (int)w.StyleGetProperty ("expander-spacing");
- indent = focusWidth + focusPad + expanderSize + 2 * expanderSpacing;
- }
- } else if (obj is Widget) {
- Gtk.Widget w = (Gtk.Widget)obj;
- Gtk.Requisition childreq;
-
- childreq = w.SizeRequest ();
- if (lwidth < childreq.Width)
- lwidth = childreq.Width;
- if (visible)
- req.Height += linePad + childreq.Height;
- } else if (obj is Pair) {
- Pair p = (Pair)obj;
- Gtk.Requisition lreq, ereq;
-
- lreq = p.Label.SizeRequest ();
- ereq = p.Editor.SizeRequest ();
-
- if (lineHeight == -1)
- lineHeight = (int)(1.5 * lreq.Height);
-
- if (lreq.Width > lwidth)
- lwidth = lreq.Width;
- if (ereq.Width > ewidth)
- ewidth = ereq.Width;
-
- if (visible)
- req.Height += Math.Max (lineHeight, ereq.Height) + linePad;
- }
- }
-
- req.Width = Math.Max (req.Width, indent + lwidth + hPad + ewidth);
- req.Height += 2 * (int)BorderWidth;
- req.Width += 2 * (int)BorderWidth;
- }
-
- protected override void OnSizeRequested (ref Gtk.Requisition req)
- {
- lwidth = ewidth = 0;
-
- if (group != null) {
- foreach (Grid grid in group)
- SizeRequestGrid (grid, ref req);
- }
-
- SizeRequestGrid (this, ref req);
- }
-
- protected override void OnSizeAllocated (Gdk.Rectangle alloc)
- {
- int xbase = alloc.X + (int)BorderWidth;
- int ybase = alloc.Y + (int)BorderWidth;
-
- base.OnSizeAllocated (alloc);
-
- int y = ybase;
- bool visible = true;
-
- foreach (object obj in lines) {
- if (!visible && !(obj is Expander))
- continue;
-
- if (obj is Widget) {
- Gtk.Widget w = (Gtk.Widget)obj;
- if (!w.Visible)
- continue;
-
- Gdk.Rectangle childalloc;
- Gtk.Requisition childreq;
-
- childreq = w.ChildRequisition;
-
- if (obj is Expander) {
- childalloc.X = xbase;
- childalloc.Width = alloc.Width - 2 * (int)BorderWidth;
- visible = ((Gtk.Expander)obj).Expanded;
- y += groupPad;
- } else {
- childalloc.X = xbase + indent;
- childalloc.Width = lwidth;
- y += linePad;
- }
- childalloc.Y = y;
- childalloc.Height = childreq.Height;
- w.SizeAllocate (childalloc);
-
- y += childalloc.Height;
- } else if (obj is Pair) {
- Pair p = (Pair)obj;
- if (!p.Editor.Visible) {
- p.Label.Hide ();
- continue;
- } else if (!p.Label.Visible)
- p.Label.Show ();
-
- Gtk.Requisition lreq, ereq;
- Gdk.Rectangle lalloc, ealloc;
-
- lreq = p.Label.ChildRequisition;
- ereq = p.Editor.ChildRequisition;
-
- lalloc.X = xbase + indent;
- if (ereq.Height < lineHeight * 2)
- lalloc.Y = y + (ereq.Height - lreq.Height) / 2;
- else
- lalloc.Y = y + (lineHeight - lreq.Height) / 2;
- lalloc.Width = lwidth;
- lalloc.Height = lreq.Height;
- p.Label.SizeAllocate (lalloc);
-
- ealloc.X = lalloc.X + lwidth + hPad;
- ealloc.Y = y + Math.Max (0, (lineHeight - ereq.Height) / 2);
- ealloc.Width = Math.Max (ewidth, alloc.Width - 2 * (int)BorderWidth - ealloc.X);
- ealloc.Height = ereq.Height;
- p.Editor.SizeAllocate (ealloc);
-
- y += Math.Max (ereq.Height, lineHeight) + linePad;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/GuiDispatchServerSink.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/GuiDispatchServerSink.cs
deleted file mode 100644
index e1262948e4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/GuiDispatchServerSink.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-
-using System;
-using System.Threading;
-using System.IO;
-using System.Runtime.Remoting;
-using System.Runtime.Remoting.Channels;
-using System.Runtime.Remoting.Messaging;
-using System.Collections;
-
-namespace Stetic
-{
- public class GuiDispatchServerSink: IServerChannelSink, IChannelSinkBase
- {
- IServerChannelSink nextSink;
-
- public GuiDispatchServerSink (IServerChannelSink nextSink, IChannelReceiver receiver)
- {
- this.nextSink = nextSink;
- }
-
- public IServerChannelSink NextChannelSink {
- get { return nextSink; }
- }
-
- public IDictionary Properties {
- get { return null; }
- }
-
- public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, object state,
- IMessage msg, ITransportHeaders headers, Stream stream)
-
- {
- sinkStack.AsyncProcessResponse (msg, headers, stream);
- }
-
- public Stream GetResponseStream (IServerResponseChannelSinkStack sinkStack, object state,
- IMessage msg, ITransportHeaders headers)
- {
- // this method shouldn't be called
- throw new NotSupportedException ();
- }
-
- public ServerProcessing ProcessMessage (IServerChannelSinkStack sinkStack,
- IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream,
- out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
- {
- IMethodCallMessage msg = (IMethodCallMessage) requestMsg;
-// Console.WriteLine ("MESSAGE: " + msg.TypeName + " - " + msg.MethodName);
-
- sinkStack.Push (this, null);
-
- if (Attribute.IsDefined (msg.MethodBase, typeof(NoGuiDispatchAttribute))) {
- ServerProcessing ret;
- try {
- ret = nextSink.ProcessMessage (sinkStack,
- requestMsg,
- requestHeaders,
- requestStream,
- out responseMsg,
- out responseHeaders,
- out responseStream);
- } finally {
- sinkStack.Pop (this);
- }
- return ret;
- }
- else
- {
- Dispatcher d = new Dispatcher ();
- d.nextSink = nextSink;
- d.sinkStack = sinkStack;
- d.requestMsg = requestMsg;
- d.requestHeaders = requestHeaders;
- d.requestStream = requestStream;
-
- Gtk.Application.Invoke (d.Dispatch);
- responseMsg = null;
- responseHeaders = null;
- responseStream = null;
-
- return ServerProcessing.Async;
- }
- }
-
- class Dispatcher
- {
- public IServerChannelSink nextSink;
-
- public IServerChannelSinkStack sinkStack;
- public IMessage requestMsg;
- public ITransportHeaders requestHeaders;
- public Stream requestStream;
-
- public void Dispatch (object o, EventArgs a)
- {
- IMessage responseMsg;
- ITransportHeaders responseHeaders = null;
- Stream responseStream = null;
-
- try {
- nextSink.ProcessMessage (sinkStack,
- requestMsg,
- requestHeaders,
- requestStream,
- out responseMsg,
- out responseHeaders,
- out responseStream);
- }
- catch (Exception ex) {
- responseMsg = new ReturnMessage (ex, (IMethodCallMessage)requestMsg);
- }
-
- sinkStack.AsyncProcessResponse (responseMsg, responseHeaders, responseStream);
- }
- }
- }
-
- class GuiDispatch
- {
- public static void InvokeSync (EventHandler h)
- {
- if (GLib.MainContext.Depth > 0)
- h (null, null);
- else {
- object wo = new object ();
- lock (wo) {
- Gtk.Application.Invoke (delegate {
- try {
- h (null, null);
- } finally {
- lock (wo) {
- System.Threading.Monitor.PulseAll (wo);
- }
- }
- });
- System.Threading.Monitor.Wait (wo);
- }
- }
- }
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/GuiDispatchServerSinkProvider.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/GuiDispatchServerSinkProvider.cs
deleted file mode 100644
index d35c2b3950..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/GuiDispatchServerSinkProvider.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-
-using System;
-using System.Runtime.Remoting;
-using System.Runtime.Remoting.Channels;
-
-namespace Stetic
-{
- public class GuiDispatchServerSinkProvider: IServerFormatterSinkProvider, IServerChannelSinkProvider
- {
- private IServerChannelSinkProvider next;
-
- public IServerChannelSinkProvider Next {
- get { return next; }
- set { next = value; }
- }
-
- public IServerChannelSink CreateSink (IChannelReceiver channel)
- {
- IServerChannelSink chain = next.CreateSink (channel);
- GuiDispatchServerSink sink = new GuiDispatchServerSink (chain, channel);
- return sink;
- }
-
- public void GetChannelData (IChannelDataStore channelData)
- {
- if(next != null)
- next.GetChannelData(channelData);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/IProjectDesignInfo.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/IProjectDesignInfo.cs
deleted file mode 100644
index 903850429a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/IProjectDesignInfo.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-
-namespace Stetic
-{
- //Provides access to informations managed by ide
- public interface IProjectDesignInfo
- {
- //Returns component source file for given component
- string GetComponentFile (string componentName);
- bool HasComponentFile (string componentFile);
-
- //Returns gtkx file name for given component file
- string GetDesignerFileFromComponent (string componentFile);
-
- //Search for all components source file folders
- string[] GetComponentFolders ();
-
- // Checks if code generation for a component is needed
- bool ComponentNeedsCodeGeneration (string componentName);
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/LibraryCache.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/LibraryCache.cs
deleted file mode 100644
index 93301495a3..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/LibraryCache.cs
+++ /dev/null
@@ -1,793 +0,0 @@
-// LibraryCache.cs : Assembly file caching class
-//
-// Author: Mike Kestner <mkestner@novell.com>
-//
-// Copyright (c) 2008 Novell, Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.IO;
-using System.Xml;
-using System.Xml.Serialization;
-using ENV = System.Environment;
-using Mono.Cecil;
-
-namespace Stetic {
-
- public class LibraryCache {
-
- public class LibraryInfo {
-
- public LibraryInfo () {}
-
- string file;
- Guid guid;
- DateTime timestamp;
- XmlDocument gui;
- XmlDocument objects;
-
- string CacheDirectory {
- get { return Path.Combine (dir, Guid.ToString ()); }
- }
-
- [XmlAttribute]
- public string File {
- get { return file; }
- set { file = value; }
- }
-
- [XmlAttribute]
- public Guid Guid {
- get { return guid; }
- set {
- string path = Path.Combine (dir, guid.ToString ());
- if (Directory.Exists (path))
- Directory.Delete (path, true);
- guid = value;
- }
- }
-
- public bool IsCurrent {
- get {
- return Timestamp == System.IO.File.GetLastWriteTime (file).ToUniversalTime ();
- }
- }
-
- [XmlIgnore]
- public XmlDocument GuiDocument {
- get {
- if (gui == null) {
- if (System.IO.File.Exists (GuiPath)) {
- try {
- gui = new XmlDocument ();
- using (Stream stream = System.IO.File.Open (GuiPath, FileMode.Open))
- gui.Load (stream);
- } catch (Exception) {
- gui = null;
- }
- }
- }
- return gui;
- }
- set {
- gui = value;
- WriteGuiFile ();
- }
- }
-
- string GuiPath {
- get { return Path.Combine (CacheDirectory, "steticGui"); }
- }
-
- public bool HasWidgets {
- get { return System.IO.File.Exists (ObjectsPath); }
- }
-
- [XmlIgnore]
- public XmlDocument ObjectsDocument {
- get {
- if (objects == null) {
- if (System.IO.File.Exists (ObjectsPath)) {
- try {
- objects = new XmlDocument ();
- using (Stream stream = System.IO.File.Open (ObjectsPath, FileMode.Open))
- objects.Load (stream);
- } catch (Exception) {
- objects = null;
- }
- }
- }
- return objects;
- }
- set {
- objects = value;
- WriteObjectsFile ();
- if (objects == null && gui != null)
- GuiDocument = null;
- }
- }
-
- internal ToolboxItemInfo GetToolboxItem (string name, string asmName)
- {
- XmlDocument doc = ObjectsDocument;
- if (doc != null) {
- XmlElement elem = (XmlElement) doc.SelectSingleNode ("/objects/object[@type='" + name + "']");
- if (elem == null)
- elem = (XmlElement) doc.SelectSingleNode ("/objects/object[@type='" + name + "," + asmName + "']");
- if (elem != null) {
- ToolboxItemInfo info = new ToolboxItemInfo (elem.GetAttribute ("base-type"));
- info.PaletteCategory = elem.GetAttribute ("palette-category");
- return info;
- }
-
- }
- return null;
- }
-
- string ObjectsPath {
- get { return Path.Combine (CacheDirectory, "objects"); }
- }
-
- [XmlAttribute]
- public DateTime Timestamp {
- get { return timestamp; }
- set { timestamp = value; }
- }
-
- void WriteGuiFile ()
- {
- if (gui == null) {
- if (System.IO.File.Exists (GuiPath))
- System.IO.File.Delete (GuiPath);
- return;
- }
- if (!Directory.Exists (CacheDirectory))
- Directory.CreateDirectory (CacheDirectory);
-
- using (Stream stream = System.IO.File.Create (GuiPath))
- gui.Save (stream);
- }
-
- public void WriteObjectsFile ()
- {
- if (objects == null) {
- if (System.IO.File.Exists (ObjectsPath))
- System.IO.File.Delete (ObjectsPath);
- return;
- }
-
- if (!Directory.Exists (CacheDirectory))
- Directory.CreateDirectory (CacheDirectory);
-
- using (Stream stream = System.IO.File.Create (ObjectsPath))
- objects.Save (stream);
- }
-
- public event EventHandler Changed;
-
- public void OnChanged ()
- {
- if (Changed != null)
- Changed (this, EventArgs.Empty);
- }
- }
-
- static string dir = Path.Combine (Path.Combine (ENV.GetFolderPath (ENV.SpecialFolder.ApplicationData), "stetic"), "library-cache");
-
- public class LibraryInfoCollection : IEnumerable {
-
- Dictionary<string, LibraryInfo> libs = new Dictionary<string, LibraryInfo> ();
-
- public LibraryInfo this [string path] {
- get {
- path = Path.GetFullPath (path);
- if (libs.ContainsKey (path))
- return libs [path];
- return null;
- }
- }
-
- public void Add (object obj)
- {
- Add (obj as LibraryInfo);
- }
-
- public void Add (LibraryInfo info)
- {
- libs [info.File] = info;
- }
-
- public IEnumerator GetEnumerator ()
- {
- return libs.Values.GetEnumerator ();
- }
-
- public void Remove (string file)
- {
- file = Path.GetFullPath (file);
- libs.Remove (file);
- }
- }
-
- public static LibraryCache Cache = Load ();
-
- [XmlArray]
- [XmlArrayItem (ElementName="LibraryInfo", Type=typeof(LibraryInfo))]
- public LibraryInfoCollection Members = new LibraryInfoCollection ();
-
- public LibraryCache () {}
-
- public LibraryInfo this [string file] {
- get {
- file = Path.GetFullPath (file);
- if (IsCurrent (file))
- return Members [file];
-
- Refresh (null, file);
- return Members [file];
- }
- }
-
- public bool IsCurrent (string file)
- {
- file = Path.GetFullPath (file);
- LibraryInfo info = Members [file];
- return info != null && info.Timestamp == File.GetLastWriteTime (file).ToUniversalTime ();
- }
-
- EmbeddedResource GetResource (AssemblyDefinition asm, string name)
- {
- foreach (Resource res in asm.MainModule.Resources) {
- EmbeddedResource eres = res as EmbeddedResource;
- if (eres != null && eres.Name == name)
- return eres;
- }
- return null;
- }
-
- void AddDependencies (XmlElement elem, AssemblyResolver resolver, string filename, AssemblyDefinition asm)
- {
- string dir = Path.GetDirectoryName (filename);
- foreach (AssemblyNameReference aref in asm.MainModule.AssemblyReferences) {
- LibraryInfo info = GetInfo (resolver, aref.FullName, dir);
- if (info != null && info.HasWidgets) {
- XmlElement edep = elem.OwnerDocument.CreateElement ("dependency");
- edep.InnerText = info.File;
- elem.AppendChild (edep);
- }
- }
- }
-
- XmlDocument GetGuiDoc (AssemblyDefinition adef)
- {
- XmlDocument doc = null;
- try {
- EmbeddedResource res = GetResource (adef, "gui.stetic");
- if (res != null) {
- MemoryStream stream = new MemoryStream (res.Data);
- doc = new XmlDocument ();
- using (stream)
- doc.Load (stream);
- }
- } catch {
- doc = null;
- }
-
- return doc;
- }
-
- bool ReferenceChainContainsGtk (AssemblyResolver resolver, AssemblyNameReference aref, Hashtable visited)
- {
- if (aref.Name == "gtk-sharp")
- return true;
- else if (visited.Contains (aref.Name))
- return false;
-
- visited [aref.Name] = aref;
-
- AssemblyDefinition adef = resolver.Resolve (aref);
- if (adef == null)
- return false;
-
- foreach (AssemblyNameReference child in adef.MainModule.AssemblyReferences)
- if (ReferenceChainContainsGtk (resolver, child, visited))
- return true;
-
- return false;
- }
-
- internal class ToolboxItemInfo {
-
- public ToolboxItemInfo (string base_type)
- {
- BaseType = base_type;
- }
-
- public string BaseType;
- public string PaletteCategory;
- }
-
- ToolboxItemInfo GetToolboxItemInfo (AssemblyResolver resolver, string baseDirectory, AssemblyDefinition asm, TypeDefinition tdef, bool checkBaseType)
- {
- if (tdef == null)
- return null;
-
- ToolboxItemInfo info = null;
- string category = "General";
-
- foreach (CustomAttribute attr in tdef.CustomAttributes) {
- switch (attr.Constructor.DeclaringType.FullName) {
- case "System.ComponentModel.ToolboxItemAttribute":
- try {
- attr.Resolve ();
- } catch {
- // Ignore
- return null;
- }
- if (attr.ConstructorParameters.Count > 0) {
- object param = attr.ConstructorParameters [0];
- if (param == null)
- return null;
- else if (param.GetType () == typeof (bool)) {
- if ((bool) param)
- info = new ToolboxItemInfo ("Gtk.Widget");
- else
- return null;
- } else if (param.GetType () == typeof (System.Type))
- info = new ToolboxItemInfo ("Gtk.Widget");
- else
- return null;
- }
- break;
- case "System.ComponentModel.CategoryAttribute":
- try {
- attr.Resolve ();
- } catch {
- // Ignore
- return null;
- }
- if (attr.ConstructorParameters.Count > 0) {
- object param = attr.ConstructorParameters [0];
- if (param.GetType () == typeof (string))
- category = (string) param;
- }
- break;
- default:
- continue;
- }
- }
-
- if (info == null && checkBaseType && tdef.BaseType != null) {
- string baseName = tdef.BaseType.FullName;
-
- foreach (AssemblyNameReference aref in asm.MainModule.AssemblyReferences) {
- LibraryInfo libInfo = GetInfo (resolver, aref.FullName, baseDirectory);
- if (libInfo != null && libInfo.HasWidgets) {
- ToolboxItemInfo binfo = libInfo.GetToolboxItem (baseName, aref.Name);
- if (binfo != null) {
- info = new ToolboxItemInfo (baseName);
- category = binfo.PaletteCategory;
- break;
- }
- }
- }
- }
-
- if (info != null)
- info.PaletteCategory = category;
-
- return info;
- }
-
- XmlElement GetItemGroup (XmlElement groups, string cat, string default_label)
- {
- XmlElement group;
-
- if (String.IsNullOrEmpty (cat))
- group = (XmlElement) groups.SelectSingleNode ("itemgroup[(not(@name) or @name='') and not(@ref)]");
- else
- group = (XmlElement) groups.SelectSingleNode ("itemgroup[@name='" + cat + "']");
-
- if (group == null) {
- group = groups.OwnerDocument.CreateElement ("itemgroup");
- if (String.IsNullOrEmpty (cat))
- group.SetAttribute ("label", default_label);
- else {
- group.SetAttribute ("name", cat);
- group.SetAttribute ("label", cat);
- }
- groups.AppendChild (group);
- }
- return group;
- }
-
- void AddProperty (PropertyDefinition prop, string cat, XmlElement obj)
- {
- XmlElement groups = obj ["itemgroups"];
- if (groups == null) {
- groups = obj.OwnerDocument.CreateElement ("itemgroups");
- obj.AppendChild (groups);
- }
-
- XmlElement group = GetItemGroup (groups, cat, prop.DeclaringType.Name + " Properties");
- XmlElement elem = group.OwnerDocument.CreateElement ("property");
- elem.SetAttribute ("name", prop.Name);
- group.AppendChild (elem);
- }
-
- static string[] supported_types = new string[] {
- "System.Boolean",
- "System.Char",
- "System.SByte",
- "System.Byte",
- "System.Int16",
- "System.UInt16",
- "System.Int32",
- "System.UInt32",
- "System.Int64",
- "System.UInt64",
- "System.Decimal",
- "System.Single",
- "System.Double",
- "System.DateTime",
- "System.String",
- "System.TimeSpan",
- "Gtk.Adjustment",
- };
-
- void AddProperties (TypeDefinition tdef, XmlElement obj)
- {
- foreach (PropertyDefinition prop in tdef.Properties) {
- if (prop.GetMethod == null || !prop.GetMethod.IsPublic || prop.SetMethod == null || !prop.SetMethod.IsPublic)
- continue;
- else if (Array.IndexOf (supported_types, prop.PropertyType.FullName) < 0)
- continue;
- bool browsable = true;
- string category = String.Empty;
- foreach (CustomAttribute attr in prop.CustomAttributes) {
- switch (attr.Constructor.DeclaringType.FullName) {
- case "System.ComponentModel.BrowsableAttribute":
- attr.Resolve ();
- if (attr.ConstructorParameters.Count > 0) {
- object param = attr.ConstructorParameters [0];
- if (param.GetType () == typeof (bool))
- browsable = (bool) param;
- }
- break;
- case "System.ComponentModel.CategoryAttribute":
- attr.Resolve ();
- if (attr.ConstructorParameters.Count > 0) {
- object param = attr.ConstructorParameters [0];
- if (param.GetType () == typeof (string))
- category = (string) param;
- }
- break;
- default:
- continue;
- }
- if (!browsable)
- break;
- }
- if (browsable)
- AddProperty (prop, category, obj);
- }
- }
-
- void AddEvent (EventDefinition ev, string cat, XmlElement obj)
- {
- XmlElement groups = obj ["signals"];
- if (groups == null) {
- groups = obj.OwnerDocument.CreateElement ("signals");
- obj.AppendChild (groups);
- }
-
- XmlElement group = GetItemGroup (groups, cat, ev.DeclaringType.Name + " Signals");
- XmlElement elem = group.OwnerDocument.CreateElement ("signal");
- elem.SetAttribute ("name", ev.Name);
- group.AppendChild (elem);
- }
-
- void AddEvents (TypeDefinition tdef, XmlElement obj)
- {
-
- foreach (EventDefinition ev in tdef.Events) {
- if (ev.AddMethod == null || !ev.AddMethod.IsPublic)
- continue;
- bool browsable = true;
- string category = String.Empty;
- foreach (CustomAttribute attr in ev.CustomAttributes) {
- switch (attr.Constructor.DeclaringType.FullName) {
- case "System.ComponentModel.BrowsableAttribute":
- attr.Resolve ();
- if (attr.ConstructorParameters.Count > 0) {
- object param = attr.ConstructorParameters [0];
- if (param.GetType () == typeof (bool))
- browsable = (bool) param;
- }
- break;
- case "System.ComponentModel.CategoryAttribute":
- attr.Resolve ();
- if (attr.ConstructorParameters.Count > 0) {
- object param = attr.ConstructorParameters [0];
- if (param.GetType () == typeof (string))
- category = (string) param;
- }
- break;
- default:
- continue;
- }
- if (!browsable)
- break;
- }
- if (browsable)
- AddEvent (ev, category, obj);
- }
- }
-
- void AddObjects (XmlDocument doc, AssemblyResolver resolver, string basePath, AssemblyDefinition adef)
- {
- Dictionary<TypeDefinition,ToolboxItemInfo> localObjects = new Dictionary<TypeDefinition, ToolboxItemInfo> ();
-
- foreach (TypeDefinition tdef in adef.MainModule.Types) {
- if (tdef.IsAbstract || !tdef.IsClass)
- continue;
-
- ToolboxItemInfo tbinfo = GetToolboxItemInfo (resolver, basePath, adef, tdef, true);
- if (tbinfo == null)
- continue;
-
- localObjects [tdef] = tbinfo;
- }
-
- foreach (KeyValuePair<TypeDefinition,ToolboxItemInfo> item in localObjects) {
- TypeDefinition tdef = item.Key;
- ToolboxItemInfo tbinfo = item.Value;
- XmlElement elem = doc.CreateElement ("object");
- elem.SetAttribute ("type", tdef.FullName);
- elem.SetAttribute ("allow-children", "false");
- elem.SetAttribute ("palette-category", tbinfo.PaletteCategory);
- if (tdef.IsNotPublic)
- elem.SetAttribute ("internal", "true");
- doc.DocumentElement.AppendChild (elem);
-
- TypeDefinition curDef = tdef;
- while (curDef != null && curDef.FullName != tbinfo.BaseType) {
- if (curDef != tdef && localObjects.ContainsKey (curDef)) {
- tbinfo.BaseType = curDef.FullName;
- break;
- }
- else if (curDef.Module.Assembly.Name.Name == "gtk-sharp") {
- tbinfo.BaseType = curDef.FullName;
- break;
- }
- else if (curDef != tdef && GetToolboxItemInfo (resolver, basePath, curDef.Module.Assembly, curDef, false) != null) {
- tbinfo.BaseType = curDef.FullName;
- break;
- }
- if (curDef.Module.Assembly != adef) {
-
- LibraryInfo li = Refresh (resolver, curDef.Module.Image.FileInformation.FullName, basePath);
- if (li.HasWidgets && li.GetToolboxItem (curDef.FullName, curDef.Module.Assembly.Name.Name) != null) {
- tbinfo.BaseType = curDef.FullName;
- break;
- }
- }
- AddProperties (curDef, elem);
- AddEvents (curDef, elem);
- if (curDef.BaseType != null && curDef.BaseType.FullName != tbinfo.BaseType)
- curDef = FindTypeDefinition (resolver, adef, basePath, curDef.BaseType.FullName);
- else
- curDef = null;
- }
-
- elem.SetAttribute ("base-type", tbinfo.BaseType);
- }
- }
-
- XmlDocument GetObjectsDoc (AssemblyResolver resolver, AssemblyDefinition adef, string path, string baseDirectory)
- {
- XmlDocument doc = null;
- bool isMainLib = Path.GetFileName (path) == "libstetic.dll";
-
- try {
- EmbeddedResource res = GetResource (adef, "objects.xml");
- if (res != null) {
- MemoryStream stream = new MemoryStream (res.Data);
- doc = new XmlDocument ();
- using (stream)
- doc.Load (stream);
- }
-
- if (resolver == null)
- resolver = new AssemblyResolver (null);
-
- baseDirectory = baseDirectory ?? Path.GetDirectoryName (path);
-
- if (!isMainLib) {
- // Make sure all referenced assemblies are up to date.
- foreach (AssemblyNameReference aref in adef.MainModule.AssemblyReferences) {
- Refresh (resolver, aref.FullName, baseDirectory);
- }
- }
-
- if (doc == null) {
-// Hashtable visited = new Hashtable ();
- foreach (AssemblyNameReference aref in adef.MainModule.AssemblyReferences) {
- if (aref.Name != "gtk-sharp") {
- LibraryInfo info = GetInfo (resolver, aref.FullName, baseDirectory);
- if (info == null || !info.HasWidgets)
- continue;
- }
-
- if (doc == null) {
- doc = new XmlDocument ();
- doc.AppendChild (doc.CreateElement ("objects"));
- }
- AddObjects (doc, resolver, baseDirectory, adef);
- break;
- }
- }
-
- if (doc != null && !isMainLib) {
- XmlElement elem = doc.CreateElement ("dependencies");
- doc.DocumentElement.AppendChild (elem);
- AddDependencies (elem, resolver, path, adef);
- }
- } catch (Exception e) {
- Console.WriteLine ("Got exception loading objects: " + e);
- doc = null;
- }
-
- return doc;
- }
-
- LibraryInfo GetInfo (AssemblyResolver resolver, string assembly, string baseDirectory)
- {
- string file = assembly;
- if (File.Exists (assembly))
- file = assembly;
- else {
- if (resolver == null)
- resolver = new AssemblyResolver (null);
- try {
- string path = resolver.Resolve (assembly, baseDirectory);
- if (path != null)
- file = path;
- else
- return null;
- } catch (Exception) {
- return null;
- }
- }
-
- file = Path.GetFullPath (file);
-
- LibraryInfo info = Members [file];
- if (info == null) {
- info = new LibraryInfo ();
- info.File = file ?? assembly;
- Members.Add (info);
- }
- return info;
- }
-
- internal LibraryInfo Refresh (AssemblyResolver resolver, string assembly)
- {
- return Refresh (resolver, assembly, null);
- }
-
- LibraryInfo Refresh (AssemblyResolver resolver, string assembly, string baseDirectory)
- {
- LibraryInfo info = GetInfo (resolver, assembly, baseDirectory);
-
- if (info == null || info.IsCurrent || !File.Exists (info.File))
- return info;
-
- info.Timestamp = File.GetLastWriteTime (info.File).ToUniversalTime ();
- info.Guid = Guid.NewGuid ();
- Save ();
- AssemblyDefinition adef = AssemblyFactory.GetAssembly (info.File);
- XmlDocument objects = GetObjectsDoc (resolver, adef, info.File, baseDirectory);
- if (objects != null) {
- info.ObjectsDocument = objects;
- XmlDocument gui = GetGuiDoc (adef);
- if (gui != null)
- info.GuiDocument = gui;
- }
- info.OnChanged ();
- return info;
- }
-
- void Save ()
- {
- if (!Directory.Exists (dir))
- Directory.CreateDirectory (dir);
-
- // remove any dead assemblies from the cache
- StringCollection zombies = new StringCollection ();
- foreach (LibraryInfo info in Members) {
- if (File.Exists (info.File))
- continue;
- zombies.Add (info.File);
- string zombie_dir = Path.Combine (dir, info.Guid.ToString ());
- if (Directory.Exists (zombie_dir))
- Directory.Delete (Path.Combine (dir, info.Guid.ToString ()), true);
- }
-
- foreach (string file in zombies)
- Members.Remove (file);
-
- XmlSerializer serializer = new XmlSerializer (typeof (LibraryCache));
- using (FileStream fs = File.Create (Path.Combine (dir, "index.xml")))
- serializer.Serialize (fs, this);
- }
-
- static LibraryCache Load ()
- {
- string index_path = Path.Combine (dir, "index.xml");
- if (File.Exists (index_path)) {
- try {
- LibraryCache result;
- XmlSerializer serializer = new XmlSerializer (typeof (LibraryCache));
- using (XmlTextReader rdr = new XmlTextReader (index_path))
- result = (LibraryCache) serializer.Deserialize (rdr);
- return result;
- } catch (Exception e) {
- Console.WriteLine ("Cache index serialization failed " + e);
- }
- }
-
- return new LibraryCache ();
- }
-
- internal TypeDefinition FindTypeDefinition (AssemblyResolver resolver, AssemblyDefinition assembly, string basePath, string fullName)
- {
- TypeDefinition t = FindTypeDefinition (new Hashtable (), resolver, basePath, assembly, fullName);
- return t;
- }
-
- TypeDefinition FindTypeDefinition (Hashtable visited, AssemblyResolver resolver, string basePath, AssemblyDefinition asm, string fullName)
- {
- if (visited.Contains (asm))
- return null;
-
- visited [asm] = asm;
-
- TypeDefinition cls = asm.MainModule.Types [fullName];
- if (cls != null)
- return cls;
-
- foreach (AssemblyNameReference aref in asm.MainModule.AssemblyReferences) {
- AssemblyDefinition basm = resolver.Resolve (aref, basePath);
- if (basm != null) {
- cls = basm.MainModule.Types [fullName];
- if (cls != null)
- return cls;
- }
- }
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Makefile.am b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Makefile.am
deleted file mode 100644
index c9cc87438f..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-include $(top_srcdir)/xbuild.include
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ButtonFunction.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ButtonFunction.cs
deleted file mode 100644
index 9fa8ef4907..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ButtonFunction.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// This file was generated by the Gtk# code generator.
-// Any changes made will be lost if regenerated.
-
-namespace Stetic.Metacity
-{
-
- using System;
- using System.Runtime.InteropServices;
-
-#region Autogenerated code
- internal enum ButtonFunction {
-
- Menu,
- Minimize,
- Maximize,
- Close,
- Last,
- }
-#endregion
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ButtonLayout.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ButtonLayout.cs
deleted file mode 100644
index e954c20a3e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ButtonLayout.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// This file was generated by the Gtk# code generator.
-// Any changes made will be lost if regenerated.
-
-namespace Stetic.Metacity
-{
-
- using System;
- using System.Collections;
- using System.Runtime.InteropServices;
-
-#region Autogenerated code
- [StructLayout(LayoutKind.Sequential)]
- internal struct ButtonLayout {
-
- [MarshalAs (UnmanagedType.ByValArray, SizeConst=4)]
- public Metacity.ButtonFunction[] LeftButtons;
- [MarshalAs (UnmanagedType.ByValArray, SizeConst=4)]
- public Metacity.ButtonFunction[] RightButtons;
-
- public static Metacity.ButtonLayout Zero = new Metacity.ButtonLayout ();
-
- public static Metacity.ButtonLayout New(IntPtr raw) {
- if (raw == IntPtr.Zero) {
- return Metacity.ButtonLayout.Zero;
- }
- Metacity.ButtonLayout self = new Metacity.ButtonLayout();
- self = (Metacity.ButtonLayout) Marshal.PtrToStructure (raw, self.GetType ());
- return self;
- }
-
- internal static GLib.GType GType {
- get { return GLib.GType.Pointer; }
- }
-#endregion
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/FrameFlags.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/FrameFlags.cs
deleted file mode 100644
index bc6172fbe8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/FrameFlags.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// This file was generated by the Gtk# code generator.
-// Any changes made will be lost if regenerated.
-
-namespace Stetic.Metacity
-{
-
- using System;
- using System.Runtime.InteropServices;
-
-#region Autogenerated code
- [Flags]
- internal enum FrameFlags {
-
- AllowsDelete = 1 << 0,
- AllowsMenu = 1 << 1,
- AllowsMinimize = 1 << 2,
- AllowsMaximize = 1 << 3,
- AllowsVerticalResize = 1 << 4,
- AllowsHorizontalResize = 1 << 5,
- HasFocus = 1 << 6,
- Shaded = 1 << 7,
- Stuck = 1 << 8,
- Maximized = 1 << 9,
- AllowsShade = 1 << 10,
- AllowsMove = 1 << 11,
- Fullscreen = 1 << 12,
- IsFlashing = 1 << 13,
- }
-#endregion
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/FrameType.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/FrameType.cs
deleted file mode 100644
index 7ecc08d277..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/FrameType.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// This file was generated by the Gtk# code generator.
-// Any changes made will be lost if regenerated.
-
-namespace Stetic.Metacity
-{
-
- using System;
- using System.Runtime.InteropServices;
-
-#region Autogenerated code
- internal enum FrameType {
-
- Normal,
- Dialog,
- ModalDialog,
- Utility,
- Menu,
- Border,
- Last,
- }
-#endregion
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ObjectManager.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ObjectManager.cs
deleted file mode 100644
index 201c52370e..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/ObjectManager.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// This file was generated by the Gtk# code generator.
-// Any changes made will be lost if regenerated.
-
-namespace GtkSharp.MetacitySharp {
-
- class ObjectManager {
-
- static bool initialized = false;
- // Call this method from the appropriate module init function.
- public static void Initialize ()
- {
- if (initialized)
- return;
-
- initialized = true;
- GLib.GType.Register (Stetic.Metacity.Preview.GType, typeof (Stetic.Metacity.Preview));
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/Preview.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/Preview.cs
deleted file mode 100644
index 509beac264..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/Preview.cs
+++ /dev/null
@@ -1,227 +0,0 @@
-// This file was generated by the Gtk# code generator.
-// Any changes made will be lost if regenerated.
-
-namespace Stetic.Metacity {
-
- using System;
- using System.Reflection;
- using System.Collections;
- using System.Runtime.InteropServices;
-
- internal class Preview : Gtk.Bin
- {
- static Theme theme;
- public static bool ThemeError = false;
-
- public static Metacity.Preview Create (TopLevelWindow window)
- {
- Metacity.Preview metacityPreview;
-
- try {
- Metacity.Preview.Init ();
- metacityPreview = new Metacity.Preview ();
- }
- catch {
- return null;
- }
-
- switch (window.TypeHint) {
- case Gdk.WindowTypeHint.Normal:
- metacityPreview.FrameType = Metacity.FrameType.Normal;
- break;
- case Gdk.WindowTypeHint.Dialog:
- metacityPreview.FrameType = window.Modal ? Metacity.FrameType.ModalDialog : Metacity.FrameType.Dialog;
- break;
- case Gdk.WindowTypeHint.Menu:
- metacityPreview.FrameType = Metacity.FrameType.Menu;
- break;
- case Gdk.WindowTypeHint.Splashscreen:
- metacityPreview.FrameType = Metacity.FrameType.Border;
- break;
- case Gdk.WindowTypeHint.Utility:
- metacityPreview.FrameType = Metacity.FrameType.Utility;
- break;
- default:
- metacityPreview.FrameType = Metacity.FrameType.Normal;
- break;
- }
-
- Metacity.FrameFlags flags =
- Metacity.FrameFlags.AllowsDelete |
- Metacity.FrameFlags.AllowsVerticalResize |
- Metacity.FrameFlags.AllowsHorizontalResize |
- Metacity.FrameFlags.AllowsMove |
- Metacity.FrameFlags.AllowsShade |
- Metacity.FrameFlags.HasFocus;
-
- if (window.Resizable)
- flags = flags | Metacity.FrameFlags.AllowsMaximize;
-
- metacityPreview.FrameFlags = flags;
- metacityPreview.ShowAll ();
- metacityPreview.AddWindow (window);
-
- metacityPreview.Theme = GetTheme ();
-
- return metacityPreview;
- }
-
- public void AddWindow (TopLevelWindow window)
- {
- base.Add (window);
-
- Title = window.Title ?? string.Empty;
- window.PropertyChanged += OnWindowPropChange;
- Destroyed += delegate {
- window.PropertyChanged -= OnWindowPropChange;
- };
- }
-
- void OnWindowPropChange (object ob, EventArgs e)
- {
- Title = ((TopLevelWindow)ob).Title ?? string.Empty;
- }
-
- static Theme GetTheme ()
- {
- if (theme == null) {
- try {
- Assembly assm = Assembly.LoadWithPartialName ("gconf-sharp");
- Type client_type = assm.GetType ("GConf.Client");
- MethodInfo method = client_type.GetMethod ("Get", BindingFlags.Instance | BindingFlags.Public);
- object client = Activator.CreateInstance (client_type, new object[] {
-
- });
- string themeName = (string)method.Invoke (client, new object[] { "/apps/metacity/general/theme" });
- theme = Metacity.Theme.Load (themeName);
- } catch {
- // Set theme error flag - in case of a theme error a solid background needs to be drawn.
- ThemeError = true;
- // Don't crash if metacity is not available
- return null;
- }
- }
- return theme;
- }
-
- /* static void GConfNotify (object obj, GConf.NotifyEventArgs args)
- {
- if (args.Key == "/apps/metacity/general/theme") {
- theme = Metacity.Theme.Load ((string)args.Value);
- foreach (Metacity.Preview prev in wrappers.Values)
- prev.Theme = Theme;
- }
- }
- */
-
- ~Preview ( )
- {
- Dispose();
- }
-
- [Obsolete]
- protected Preview(GLib.GType gtype) : base(gtype) {}
- public Preview(IntPtr raw) : base(raw) {}
-
- [DllImport("libmetacity-private.so.0")]
- static extern IntPtr meta_preview_new();
-
- public Preview () : base (IntPtr.Zero)
- {
- if (GetType () != typeof (Preview)) {
- CreateNativeObject (new string [0], new GLib.Value[0]);
- return;
- }
- Raw = meta_preview_new();
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern void meta_preview_set_title(IntPtr raw, IntPtr title);
-
- public string Title {
- set {
- IntPtr title_as_native = GLib.Marshaller.StringToPtrGStrdup (value);
- meta_preview_set_title(Handle, title_as_native);
- GLib.Marshaller.Free (title_as_native);
- }
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern void meta_preview_set_button_layout(IntPtr raw, ref Stetic.Metacity.ButtonLayout button_layout);
-
- public Stetic.Metacity.ButtonLayout ButtonLayout
- {
- set {
- meta_preview_set_button_layout(Handle, ref value);
- }
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern void meta_preview_set_theme(IntPtr raw, IntPtr theme);
-
- public Metacity.Theme Theme {
- set {
- meta_preview_set_theme(Handle, (value == null ? IntPtr.Zero : value.Handle));
- }
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern IntPtr meta_preview_get_mini_icon();
-
- public static Gdk.Pixbuf MiniIcon {
- get {
- IntPtr raw_ret = meta_preview_get_mini_icon();
- Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
- return ret;
- }
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern IntPtr meta_preview_get_icon();
-
- public static Gdk.Pixbuf Icon {
- get {
- IntPtr raw_ret = meta_preview_get_icon();
- Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
- return ret;
- }
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern void meta_preview_set_frame_type(IntPtr raw, int type);
-
- public Stetic.Metacity.FrameType FrameType
- {
- set {
- meta_preview_set_frame_type(Handle, (int) value);
- }
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern IntPtr meta_preview_get_type();
-
- public static new GLib.GType GType {
- get {
- IntPtr raw_ret = meta_preview_get_type();
- GLib.GType ret = new GLib.GType(raw_ret);
- return ret;
- }
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern void meta_preview_set_frame_flags(IntPtr raw, int flags);
-
- public Stetic.Metacity.FrameFlags FrameFlags
- {
- set {
- meta_preview_set_frame_flags(Handle, (int) value);
- }
- }
-
-
- public static void Init()
- {
- GtkSharp.MetacitySharp.ObjectManager.Initialize ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/Theme.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/Theme.cs
deleted file mode 100644
index b9254d710d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Metacity/Theme.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-
-namespace Stetic.Metacity
-{
- using System;
- using System.Runtime.InteropServices;
-
- internal class Theme : GLib.Opaque {
-
- public Theme (IntPtr raw) : base (raw) {}
-
- [DllImport("libmetacity-private.so.0")]
- static extern IntPtr meta_theme_get_current ();
-
- public static Theme Current {
- get {
- IntPtr raw = meta_theme_get_current ();
- return (Theme)GetOpaque (raw, typeof (Metacity.Theme), true);
- }
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern IntPtr meta_theme_load (string theme_name, IntPtr err);
-
- public static Theme Load (string name)
- {
- IntPtr raw = meta_theme_load (name, IntPtr.Zero);
- if (raw == IntPtr.Zero)
- return null;
- else
- return (Theme)GetOpaque (raw, typeof (Metacity.Theme), true);
- }
-
- [DllImport("libmetacity-private.so.0")]
- static extern void meta_theme_free (IntPtr raw);
-
- protected override void Free (IntPtr raw)
- {
- meta_theme_free (Raw);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Palette.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Palette.cs
deleted file mode 100644
index 3f747df6cf..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Palette.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-
-using System;
-using Gtk;
-
-namespace Stetic
-{
- public class Palette: PluggableWidget
- {
- bool showWindowCategory = true;
-
- internal Palette (Application app): base (app)
- {
- }
-
- protected override void OnCreatePlug (uint socketId)
- {
- app.Backend.CreatePaletteWidgetPlug (socketId);
- Update ();
- }
-
- protected override void OnDestroyPlug (uint socketId)
- {
- app.Backend.DestroyPaletteWidgetPlug ();
- }
-
- protected override Gtk.Widget OnCreateWidget ()
- {
- Update ();
- return app.Backend.GetPaletteWidget ();
- }
-
- public bool ShowWindowCategory {
- get { return showWindowCategory; }
- set {
- showWindowCategory = value;
- Update ();
- }
- }
-
- void Update ()
- {
- if (!showWindowCategory)
- app.Backend.HidePaletteGroup ("window");
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PaletteBackend.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PaletteBackend.cs
deleted file mode 100644
index 40d6e8050d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PaletteBackend.cs
+++ /dev/null
@@ -1,409 +0,0 @@
-using Gtk;
-using Gdk;
-using System;
-using System.Collections;
-using System.Reflection;
-using Mono.Unix;
-
-namespace Stetic {
-
- internal class PaletteBackend : Gtk.ScrolledWindow, IComparer {
-
- Hashtable groups;
- ProjectBackend project;
- WidgetLibrary[] libraries;
- ArrayList visibleGroups = new ArrayList ();
- Wrapper.Widget selection;
- ActionGroupBox localActionsBox;
- ActionGroupBox globalActionsBox;
- Gtk.VBox box;
- ApplicationBackend app;
-
- public PaletteBackend (ApplicationBackend app)
- {
- this.app = app;
- box = new Gtk.VBox (false, 0);
- AddWithViewport (box);
- groups = new Hashtable ();
- Registry.RegistryChanged += OnRegistryChanged;
-
- ShowGroup ("window", Catalog.GetString ("Windows"));
- ShowGroup ("widget", Catalog.GetString ("Widgets"));
- ShowGroup ("container", Catalog.GetString ("Containers"));
-// ShowGroup ("toolbaritem", "Toolbar Items");
- ShowGroup ("actions", Catalog.GetString ("Actions"));
- }
-
- public override void Dispose ()
- {
- Registry.RegistryChanged -= OnRegistryChanged;
-
- foreach (PaletteGroup grp in groups.Values)
- grp.Destroy ();
-
- if (localActionsBox != null) {
- localActionsBox.Destroy ();
- localActionsBox = null;
- }
- if (globalActionsBox != null) {
- globalActionsBox.Destroy ();
- globalActionsBox = null;
- }
-
- project = null;
- selection = null;
- base.Dispose ();
- }
-
- public PaletteBackend (ApplicationBackend app, ProjectBackend project): this (app)
- {
- this.ProjectBackend = project;
- }
-
- public ProjectBackend ProjectBackend {
- get { return project; }
- set {
- if (project != null) {
- project.SelectionChanged -= OnSelectionChanged;
- project.ProjectReloaded -= OnProjectReloaded;
- }
- project = value;
- if (project != null) {
- UpdateSelection (Wrapper.Widget.Lookup (project.Selection));
- project.SelectionChanged += OnSelectionChanged;
- project.ProjectReloaded += OnProjectReloaded;
- } else
- UpdateSelection (null);
- LoadWidgets (project);
- }
- }
-
- public WidgetLibrary[] WidgetLibraries {
- get { return libraries; }
- set {
- libraries = value;
- LoadWidgets (project);
- }
- }
-
- void OnProjectReloaded (object s, EventArgs args)
- {
- LoadWidgets (project);
- }
-
- void OnSelectionChanged (object ob, Stetic.Wrapper.WidgetEventArgs args)
- {
- UpdateSelection (args.WidgetWrapper);
- }
-
- void UpdateSelection (Wrapper.Widget sel)
- {
- selection = sel;
- if (localActionsBox != null)
- localActionsBox.SetActionGroups (selection != null ? selection.LocalActionGroups : null);
- ShowAll ();
- }
-
- public void ShowGroup (string name, string label)
- {
- visibleGroups.Add (new string[] { name, label });
- if (project != null)
- LoadWidgets (project);
- }
-
- public void HideGroup (string name)
- {
- for (int n=0; n < visibleGroups.Count; n++) {
- if (((string[])visibleGroups[n])[0] == name) {
- visibleGroups.RemoveAt (n);
- if (project != null)
- LoadWidgets (project);
- return;
- }
- }
- }
-
- void OnRegistryChanged (object o, EventArgs args)
- {
- WidgetLibraries = app.GetActiveLibraries ();
- }
-
- public void LoadWidgets (ProjectBackend project)
- {
- if (project == null) {
- box.Hide ();
- return;
- }
-
- box.Show ();
-
- foreach (PaletteGroup g in groups.Values) {
- box.Remove (g);
- g.Destroy ();
- }
-
- groups.Clear ();
-
- foreach (string[] grp in visibleGroups)
- AddOrGetGroup (grp[0], grp[1]);
-
- ArrayList classes = new ArrayList ();
- if (libraries == null) {
- foreach (ClassDescriptor klass in Registry.AllClasses)
- if (klass.SupportsGtkVersion (project.TargetGtkVersion))
- classes.Add (klass);
- } else if (project != null) {
- foreach (WidgetLibrary lib in libraries) {
- bool isInternalLib = project.IsInternalLibrary (lib.Name);
- foreach (ClassDescriptor cd in lib.AllClasses) {
- if (!cd.Deprecated && cd.Category.Length > 0 && (isInternalLib || !cd.IsInternal) && cd.SupportsGtkVersion (project.TargetGtkVersion))
- classes.Add (cd);
- }
- }
- }
-
- classes.Sort (this);
-
- foreach (ClassDescriptor klass in classes) {
-
- if (!groups.Contains (klass.Category))
- continue;
-
- WidgetFactory factory;
- if (klass.Category == "window")
- factory = new WindowFactory (project, klass);
- else
- factory = new WidgetFactory (project, klass);
-
- AddOrGetGroup(klass.Category).Append (factory);
- }
-
- if (localActionsBox != null)
- localActionsBox.Destroy ();
- if (globalActionsBox != null)
- globalActionsBox.Destroy ();
-
- PaletteGroup widgetGroup = AddOrGetGroup ("actions", Catalog.GetString ("Actions"));
- localActionsBox = new ActionGroupBox ();
- globalActionsBox = new ActionGroupBox ();
- widgetGroup.Append (localActionsBox);
- widgetGroup.Append (globalActionsBox);
-
- if (project != null) {
- widgetGroup.Sensitive = true;
- localActionsBox.SetActionGroups (selection != null ? selection.LocalActionGroups : null);
- globalActionsBox.SetActionGroups (project.ActionGroups);
- } else {
- widgetGroup.Sensitive = false;
- localActionsBox.SetActionGroups (null);
- globalActionsBox.SetActionGroups (null);
- }
-
- // This is a workaround. In looks like the palette is not correctly
- // redrawn if it is rebuilt while it is not visible (the dock is hidden in MD).
- GLib.Idle.Add (delegate {
- ShowAll ();
- return false;
- });
- }
-
- int IComparer.Compare (object x, object y)
- {
- return string.Compare (((ClassDescriptor)x).Label,
- ((ClassDescriptor)y).Label);
- }
-
- private PaletteGroup AddOrGetGroup (string id, string name)
- {
- PaletteGroup group = (PaletteGroup) groups[id];
-
- if (group == null) {
- group = new PaletteGroup (name);
- box.PackStart (group, false, false, 0);
- groups.Add (id, group);
- }
-
- return group;
- }
-
- private PaletteGroup AddOrGetGroup (string name)
- {
- return AddOrGetGroup (name, name);
- }
- }
-
- class PaletteGroup : Gtk.Expander
- {
- private Gtk.Alignment align;
- private Gtk.VBox vbox;
- Gtk.Label emptyLabel;
- bool isEmpty = true;
-
- public PaletteGroup (string name) : base ("<b>" + name + "</b>")
- {
- vbox = new VBox (false, 0);
- emptyLabel = new Gtk.Label ();
- emptyLabel.Markup = "<small><i><span foreground='darkgrey'> " + Catalog.GetString ("Empty") + "</span></i></small>";
- vbox.PackStart (emptyLabel, false, false, 0);
-
- align = new Gtk.Alignment (0, 0, 0, 0);
- align.SetPadding (0, 0, 20, 0);
- align.Child = vbox;
-
- UseMarkup = true;
- Expanded = true;
- Child = align;
- }
-
- public void SetName (string name)
- {
- Label = "<b>" + name + "</b>";
- }
-
- public void Append (Widget w)
- {
- if (isEmpty) {
- vbox.Remove (emptyLabel);
- isEmpty = false;
- }
- vbox.PackStart (w, false, false, 0);
- }
-
- public void Clear ()
- {
- foreach (Gtk.Widget w in vbox.Children) {
- vbox.Remove (w);
- w.Destroy ();
- }
-
- isEmpty = true;
- vbox.PackStart (emptyLabel, false, false, 0);
- }
- }
-
- class ActionPaletteGroup : PaletteGroup
- {
- Wrapper.ActionGroup group;
-
- public ActionPaletteGroup (string name, Wrapper.ActionGroup group): base (name)
- {
- DND.DestSet (this, true);
- this.group = group;
- group.ActionAdded += OnActionGroupChanged;
- group.ActionRemoved += OnActionGroupChanged;
- group.ActionChanged += OnActionGroupChanged;
- group.ObjectChanged += OnActionGroupChanged;
- Fill ();
- }
-
- public Wrapper.ActionGroup Group {
- get { return group; }
- }
-
- public override void Dispose ()
- {
- group.ActionAdded -= OnActionGroupChanged;
- group.ActionRemoved -= OnActionGroupChanged;
- group.ActionChanged -= OnActionGroupChanged;
- group.ObjectChanged -= OnActionGroupChanged;
- base.Dispose ();
- }
-
- public void Fill ()
- {
- foreach (Stetic.Wrapper.Action action in group.Actions) {
- Gdk.Pixbuf icon = action.RenderIcon (Gtk.IconSize.Menu);
- if (icon == null) icon = ActionComponent.DefaultActionIcon;
- Stetic.Wrapper.ActionPaletteItem it = new Stetic.Wrapper.ActionPaletteItem (Gtk.UIManagerItemType.Menuitem, null, action);
- Append (new InstanceWidgetFactory (action.MenuLabel, icon, it));
- }
- }
-
- void OnActionGroupChanged (object s, EventArgs args)
- {
- SetName (((Stetic.Wrapper.ActionGroup)s).Name);
- }
-
- void OnActionGroupChanged (object s, Stetic.Wrapper.ActionEventArgs args)
- {
- Clear ();
- Fill ();
- ShowAll ();
- }
-
- protected override bool OnDragDrop (Gdk.DragContext context, int x, int y, uint time)
- {
- Wrapper.ActionPaletteItem dropped = DND.Drop (context, null, time) as Wrapper.ActionPaletteItem;
- if (dropped == null)
- return false;
-
- if (dropped.Node.Action.ActionGroup != group) {
- using (dropped.Node.Action.UndoManager.AtomicChange) {
- dropped.Node.Action.ActionGroup.Actions.Remove (dropped.Node.Action);
- group.Actions.Add (dropped.Node.Action);
- }
- }
-
- return base.OnDragDrop (context, x, y, time);
- }
- }
-
- class ActionGroupBox: Gtk.VBox
- {
- Stetic.Wrapper.ActionGroupCollection groups;
-
- public void SetActionGroups (Stetic.Wrapper.ActionGroupCollection groups)
- {
- if (this.groups != null) {
- this.groups.ActionGroupAdded -= OnGroupAdded;
- this.groups.ActionGroupRemoved -= OnGroupRemoved;
- }
- this.groups = groups;
- if (this.groups != null) {
- this.groups.ActionGroupAdded += OnGroupAdded;
- this.groups.ActionGroupRemoved += OnGroupRemoved;
- }
- Update ();
- }
-
- public override void Dispose ()
- {
- foreach (ActionPaletteGroup grp in Children)
- grp.Destroy ();
- base.Dispose ();
- }
-
- public void Update ()
- {
- foreach (ActionPaletteGroup grp in Children) {
- Remove (grp);
- grp.Destroy ();
- }
-
- if (groups != null) {
- foreach (Stetic.Wrapper.ActionGroup group in groups) {
- ActionPaletteGroup pg = new ActionPaletteGroup (group.Name, group);
- PackStart (pg, false, false, 0);
- }
- }
- ShowAll ();
- }
-
- void OnGroupAdded (object s, Stetic.Wrapper.ActionGroupEventArgs args)
- {
- ActionPaletteGroup pg = new ActionPaletteGroup (args.ActionGroup.Name, args.ActionGroup);
- pg.ShowAll ();
- PackStart (pg, false, false, 0);
- }
-
- void OnGroupRemoved (object s, Stetic.Wrapper.ActionGroupEventArgs args)
- {
- foreach (ActionPaletteGroup grp in Children) {
- if (grp.Group == args.ActionGroup) {
- Remove (grp);
- grp.Destroy ();
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PluggableWidget.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PluggableWidget.cs
deleted file mode 100644
index be70fee7a2..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PluggableWidget.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public abstract class PluggableWidget: Gtk.EventBox
- {
- internal Application app;
- bool initialized;
- Gtk.Socket socket;
- bool customWidget;
- Gtk.Notebook book;
-
- public PluggableWidget (Application app)
- {
- book = new Gtk.Notebook ();
- book.ShowTabs = false;
- book.ShowBorder = false;
- book.Show ();
- Add (book);
-
- this.app = app;
- if (app is IsolatedApplication) {
- (app as IsolatedApplication).BackendChanged += OnBackendChanged;
- (app as IsolatedApplication).BackendChanging += OnBackendChanging;
- }
- }
-
- protected void AddCustomWidget (Gtk.Widget w)
- {
- w.ShowAll ();
- book.AppendPage (w, null);
- book.Page = book.NPages - 1;
-
- if (initialized) {
- Gtk.Widget cw = book.GetNthPage (0);
- book.RemovePage (0);
- cw.Destroy ();
- }
- else
- initialized = true;
- customWidget = true;
- }
-
- protected void ResetCustomWidget ()
- {
- customWidget = false;
- }
-
- protected override void OnRealized ()
- {
- base.OnRealized ();
- if (!initialized) {
- initialized = true;
- if (app is IsolatedApplication)
- ConnectPlug ();
- else {
- Gtk.Widget w = OnCreateWidget ();
- w.Show ();
- book.AppendPage (w, null);
- }
- }
- }
-
- protected override void OnUnrealized ()
- {
- if (app is IsolatedApplication && initialized) {
- OnDestroyPlug (socket.Id);
- initialized = false;
- }
- base.OnUnrealized ();
- }
-
- protected void PrepareUpdateWidget ()
- {
- // This method is called when the child widget is going to be changed.
- // It takes a 'screenshot' of the widget. This image will be shown until
- // UpdateWidget is called.
-
- if (book.NPages == 1) {
- Gtk.Widget w = book.GetNthPage (0);
- Gdk.Window win = w.GdkWindow;
- if (win != null && win.IsViewable) {
- Gdk.Pixbuf img = Gdk.Pixbuf.FromDrawable (win, win.Colormap, w.Allocation.X, w.Allocation.Y, 0, 0, w.Allocation.Width, w.Allocation.Height);
- Gtk.Image oldImage = new Gtk.Image (img);
- oldImage.Show ();
- book.AppendPage (oldImage, null);
- book.Page = 1;
- book.RemovePage (0);
- }
- }
- }
-
- protected void UpdateWidget ()
- {
- if (!initialized)
- return;
-
- if (app is LocalApplication) {
- Gtk.Widget w = OnCreateWidget ();
- if (w.Parent != book) {
- book.AppendPage (w, null);
- w.Show ();
- }
- book.Page = book.NPages - 1;
- if (book.NPages > 1) {
- Gtk.Widget cw = book.GetNthPage (0);
- book.Remove (cw);
- OnDestroyWidget (cw);
- }
- }
- }
-
- protected abstract void OnCreatePlug (uint socketId);
- protected abstract void OnDestroyPlug (uint socketId);
-
- protected abstract Gtk.Widget OnCreateWidget ();
- protected virtual void OnDestroyWidget (Gtk.Widget w) { w.Destroy (); }
-
- public override void Dispose ()
- {
- if (app is IsolatedApplication) {
- IsolatedApplication iapp = app as IsolatedApplication;
- iapp.BackendChanged -= OnBackendChanged;
- iapp.BackendChanging -= OnBackendChanging;
- }
- base.Dispose ();
- }
-
- internal virtual void OnBackendChanged (ApplicationBackend oldBackend)
- {
- if (!initialized)
- return;
-
- Gtk.Widget w = book.GetNthPage (0);
- book.RemovePage (0);
- w.Destroy ();
- socket.Dispose ();
- ConnectPlug ();
- }
-
- internal virtual void OnBackendChanging ()
- {
- }
-
- void ConnectPlug ()
- {
- socket = new Gtk.Socket ();
- socket.Show ();
- book.AppendPage (socket, null);
- OnCreatePlug (socket.Id);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Project.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Project.cs
deleted file mode 100644
index a784aea82d..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Project.cs
+++ /dev/null
@@ -1,870 +0,0 @@
-
-using System;
-using System.Xml;
-using System.IO;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-
-namespace Stetic
-{
- public class Project: MarshalByRefObject
- {
- Application app;
- ProjectBackend backend;
- //string fileName;
- string folderName;
- IResourceProvider resourceProvider;
- Component selection;
- string tmpProjectFile;
- bool reloadRequested;
- List<WidgetInfo> widgets = new List<WidgetInfo> ();
- List<ActionGroupInfo> groups = new List<ActionGroupInfo> ();
- ImportFileDelegate importFileDelegate;
-
- public event WidgetInfoEventHandler WidgetAdded;
- public event WidgetInfoEventHandler WidgetRemoved;
- public event ComponentNameEventHandler ComponentNameChanged;
- public event EventHandler ComponentTypesChanged;
-
- public event EventHandler ActionGroupsChanged;
- public event EventHandler ModifiedChanged;
- public event EventHandler Changed;
-
-
- // Internal events
- internal event BackendChangingHandler BackendChanging;
- internal event BackendChangedHandler BackendChanged;
- internal event ComponentSignalEventHandler SignalAdded;
- internal event ComponentSignalEventHandler SignalRemoved;
- internal event ComponentSignalEventHandler SignalChanged;
-
- public event EventHandler ProjectReloading;
- public event EventHandler ProjectReloaded;
-
- internal Project (Application app, IProjectDesignInfo info): this (app, null, info)
- {
- }
-
- internal Project (Application app, ProjectBackend backend, IProjectDesignInfo info)
- {
- this.app = app;
- if (backend != null) {
- this.backend = backend;
- backend.SetFrontend (this);
- }
-
- if (app is IsolatedApplication) {
- IsolatedApplication iapp = app as IsolatedApplication;
- iapp.BackendChanging += OnBackendChanging;
- iapp.BackendChanged += OnBackendChanged;
- }
-
- DesignInfo = info;
- }
-
- internal IProjectDesignInfo DesignInfo { get; private set; }
-
- internal ProjectBackend ProjectBackend {
- get {
- if (backend == null) {
- backend = app.Backend.CreateProject ();
- backend.SetFrontend (this);
- if (resourceProvider != null)
- backend.ResourceProvider = resourceProvider;
- if (folderName != null)
- backend.Load (folderName);
- }
- return backend;
- }
- }
-
- internal bool IsBackendLoaded {
- get { return backend != null; }
- }
-
- internal Application App {
- get { return app; }
- }
-
- internal event EventHandler Disposed;
-
- public void Dispose ()
- {
- if (app is IsolatedApplication) {
- IsolatedApplication iapp = app as IsolatedApplication;
- iapp.BackendChanging -= OnBackendChanging;
- iapp.BackendChanged -= OnBackendChanged;
- }
-
- if (tmpProjectFile != null && File.Exists (tmpProjectFile)) {
- File.Delete (tmpProjectFile);
- tmpProjectFile = null;
- }
- if (backend != null)
- backend.Dispose ();
- if (Disposed != null)
- Disposed (this, EventArgs.Empty);
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
-
-// public string FileName {
-// get { return fileName; }
-// }
-
- public IResourceProvider ResourceProvider {
- get { return resourceProvider; }
- set {
- resourceProvider = value;
- if (backend != null)
- backend.ResourceProvider = value;
- }
- }
-
- public Stetic.ProjectIconFactory IconFactory {
- get { return ProjectBackend.IconFactory; }
- set { backend.IconFactory = value; }
- }
-
- public ImportFileDelegate ImportFileCallback {
- get { return importFileDelegate; }
- set { importFileDelegate = value; }
- }
-
- public bool CanGenerateCode {
- get { return ProjectBackend.CanGenerateCode; }
- }
-
- public Component Selection {
- get { return selection; }
- }
-
- public string ImagesRootPath {
- get { return ProjectBackend.ImagesRootPath; }
- set { ProjectBackend.ImagesRootPath = value; }
- }
-
- public string TargetGtkVersion {
- get { return ProjectBackend.TargetGtkVersion; }
- set { ProjectBackend.TargetGtkVersion = value; }
- }
-
- public void Close ()
- {
- if (backend != null)
- backend.Close ();
- }
-
- public void Load (string folderName)
- {
- this.folderName = folderName;
- if (backend != null)
- backend.Load (folderName);
-
- foreach (string basePath in DesignInfo.GetComponentFolders ()) {
- if (!Directory.Exists (basePath))
- continue;
-
- DirectoryInfo dir = new DirectoryInfo (basePath);
-
- foreach (FileInfo file in dir.GetFiles ()) {
- if (file.Extension == ".gtkx") {
-
- using (StreamReader sr = new StreamReader (file.FullName)) {
- XmlTextReader reader = new XmlTextReader (sr);
-
- reader.MoveToContent ();
- if (reader.IsEmptyElement)
- return;
-
- reader.ReadStartElement ("stetic-interface");
- if (reader.IsEmptyElement)
- return;
- while (reader.NodeType != XmlNodeType.EndElement) {
- if (reader.NodeType == XmlNodeType.Element) {
- if (reader.LocalName == "widget")
- ReadWidget (reader);
- else if (reader.LocalName == "action-group")
- ReadActionGroup (reader);
- else
- reader.Skip ();
- }
- else {
- reader.Skip ();
- }
- reader.MoveToContent ();
- }
- }
- }
- }
- }
- }
-
- public void ReloadComponent (string componentName)
- {
- if (backend != null)
- backend.ReloadComponent (componentName);
- }
-
- void ReadWidget (XmlTextReader reader)
- {
- WidgetInfo w = new WidgetInfo (this, reader.GetAttribute ("id"), reader.GetAttribute ("class"));
- widgets.Add (w);
- if (reader.IsEmptyElement) {
- reader.Skip ();
- return;
- }
- reader.ReadStartElement ();
- reader.MoveToContent ();
- while (reader.NodeType != XmlNodeType.EndElement) {
- if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "action-group") {
- w.AddGroup (reader.GetAttribute ("name"));
- }
- reader.Skip ();
- reader.MoveToContent ();
- }
- reader.ReadEndElement ();
- }
-
- void ReadActionGroup (XmlTextReader reader)
- {
- groups.Add (new ActionGroupInfo (this, reader.GetAttribute ("name")));
- reader.Skip ();
- }
-
- public void ConvertProject (string oldSteticFileName, string newGuiFolderName)
- {
- //ProjectBackend property when created invokes Load method which is not valid
- //for old file layout
-
- ProjectBackend backend = app.Backend.CreateProject ();
- backend.SetFrontend (this);
- backend.ConvertProject (oldSteticFileName, newGuiFolderName);
- }
-
- public void Save (string folderName)
- {
- this.folderName = folderName;
- if (backend != null)
- backend.Save (folderName);
- }
-
- public void ImportGlade (string fileName)
- {
- ProjectBackend.ImportGlade (fileName);
- }
-
- public void ExportGlade (string fileName)
- {
- ProjectBackend.ExportGlade (fileName);
- }
-
- public IEnumerable<WidgetInfo> Widgets {
- get { return widgets; }
- }
-
- public IEnumerable<ActionGroupInfo> ActionGroups {
- get { return groups; }
- }
-
- public WidgetInfo GetWidget (string name)
- {
- foreach (WidgetInfo w in widgets)
- if (w.Name == name)
- return w;
- return null;
- }
-
- public ActionGroupInfo GetActionGroup (string name)
- {
- foreach (ActionGroupInfo w in groups)
- if (w.Name == name)
- return w;
- return null;
- }
-
-// public WidgetDesigner CreateWidgetDesigner (WidgetInfo widgetInfo, bool autoCommitChanges)
-// {
-// return new WidgetDesigner (this, widgetInfo.Name, autoCommitChanges);
-// }
-
- public WidgetDesigner CreateWidgetDesigner (WidgetInfo widgetInfo)
- {
- return new WidgetDesigner (this, widgetInfo.Name);
- }
-
- public ActionGroupDesigner CreateActionGroupDesigner (ActionGroupInfo actionGroup, bool autoCommitChanges)
- {
- return new ActionGroupDesigner (this, null, actionGroup.Name, null, autoCommitChanges);
- }
-
- public WidgetInfo AddNewComponent (ComponentType type, string name)
- {
- object ob = ProjectBackend.AddNewWidget (type.Name, name);
- WidgetComponent wc = (WidgetComponent) App.GetComponent (ob, null, null);
- WidgetInfo wi = GetWidget (wc.Name);
- if (wi == null) {
- wi = new WidgetInfo (this, wc);
- widgets.Add (wi);
- }
- return wi;
- }
-
- public WidgetInfo AddNewComponent (XmlElement template)
- {
- object ob = ProjectBackend.AddNewWidgetFromTemplate (template.OuterXml);
- WidgetComponent wc = (WidgetComponent) App.GetComponent (ob, null, null);
- WidgetInfo wi = GetWidget (wc.Name);
- if (wi == null) {
- wi = new WidgetInfo (this, wc);
- widgets.Add (wi);
- }
- return wi;
- }
-
- public object AddNewComponent (string fileName)
- {
- object ob = ProjectBackend.AddNewComponent (fileName);
- object component = App.GetComponent (ob, null, null);
-
- if (component is WidgetComponent) {
- var wc = (WidgetComponent) component;
- WidgetInfo wi = GetWidget (wc.Name);
- if (wi == null) {
- wi = new WidgetInfo (this, wc);
- widgets.Add (wi);
- }
- return wi;
- }
-
- if (component is ActionGroupComponent) {
- var ac = (ActionGroupComponent) component;
- // Don't wait for the group added event to come to update the groups list since
- // it may be too late.
- ActionGroupInfo gi = GetActionGroup (ac.Name);
- if (gi == null) {
- gi = new ActionGroupInfo (this, ac.Name);
- groups.Add (gi);
- }
- return gi;
- }
-
- return null;
- }
-
- public ComponentType[] GetComponentTypes ()
- {
- ArrayList types = new ArrayList ();
-
- ArrayList typeNames = ProjectBackend.GetComponentTypes ();
- for (int n=0; n<typeNames.Count; n++)
- types.Add (app.GetComponentType ((string) typeNames [n]));
-
- // Global action groups
- foreach (ActionGroupComponent grp in GetActionGroups ()) {
- foreach (ActionComponent ac in grp.GetActions ())
- types.Add (new ComponentType (app, ac));
- }
-
- return (ComponentType[]) types.ToArray (typeof(ComponentType));
- }
-
- // Returns a list of all support widget types (including base classes)
- public string[] GetWidgetTypes ()
- {
- return ProjectBackend.GetWidgetTypes ();
- }
-
- public void RemoveComponent (WidgetInfo component)
- {
- ProjectBackend.RemoveWidget (component.Name);
- }
-
- public WidgetComponent GetComponent (string name)
- {
- object ob = ProjectBackend.GetTopLevelWrapper (name, false);
- if (ob != null)
- return (WidgetComponent) App.GetComponent (ob, name, null);
- else
- return null;
- }
-
- public ActionGroupComponent AddNewActionGroup (string id)
- {
- object ob = ProjectBackend.AddNewActionGroup (id);
- ActionGroupComponent ac = (ActionGroupComponent) App.GetComponent (ob, id, null);
-
- // Don't wait for the group added event to come to update the groups list since
- // it may be too late.
- ActionGroupInfo gi = GetActionGroup (ac.Name);
- if (gi == null) {
- gi = new ActionGroupInfo (this, ac.Name);
- groups.Add (gi);
- }
- return ac;
- }
-
- public ActionGroupComponent AddNewActionGroup (XmlElement template)
- {
- object ob = ProjectBackend.AddNewActionGroupFromTemplate (template.OuterXml);
- ActionGroupComponent ac = (ActionGroupComponent) App.GetComponent (ob, null, null);
-
- // Don't wait for the group added event to come to update the groups list since
- // it may be too late.
- ActionGroupInfo gi = GetActionGroup (ac.Name);
- if (gi == null) {
- gi = new ActionGroupInfo (this, ac.Name);
- groups.Add (gi);
- }
- return ac;
- }
-
- public void RemoveActionGroup (ActionGroupInfo group)
- {
- ActionGroupComponent ac = (ActionGroupComponent) group.Component;
- ProjectBackend.RemoveActionGroup ((Stetic.Wrapper.ActionGroup) ac.Backend);
- }
-
- internal ActionGroupComponent[] GetActionGroups ()
- {
- Wrapper.ActionGroup[] acs = ProjectBackend.GetActionGroups ();
-
- ArrayList comps = new ArrayList (acs.Length);
- for (int n=0; n<acs.Length; n++) {
- ActionGroupComponent ag = (ActionGroupComponent) App.GetComponent (acs[n], null, null);
- if (ag != null)
- comps.Add (ag);
- }
-
- return (ActionGroupComponent[]) comps.ToArray (typeof(ActionGroupComponent));
- }
-
- public void AddWidgetLibrary (string assemblyPath)
- {
- AddWidgetLibrary (assemblyPath, false);
- }
-
- public void AddWidgetLibrary (string assemblyPath, bool isInternal)
- {
- reloadRequested = false;
- ProjectBackend.AddWidgetLibrary (assemblyPath, isInternal);
- app.UpdateWidgetLibraries (false, false);
- if (!reloadRequested)
- ProjectBackend.Reload ();
- }
-
- public void RemoveWidgetLibrary (string assemblyPath)
- {
- reloadRequested = false;
- ProjectBackend.RemoveWidgetLibrary (assemblyPath);
- app.UpdateWidgetLibraries (false, false);
- if (!reloadRequested)
- ProjectBackend.Reload ();
- }
-
- public string[] WidgetLibraries {
- get {
- return (string[]) ProjectBackend.WidgetLibraries.ToArray (typeof(string));
- }
- }
-
- public void SetWidgetLibraries (string[] libraries, string[] internalLibraries)
- {
- reloadRequested = false;
-
- ArrayList libs = new ArrayList ();
- libs.AddRange (libraries);
- libs.AddRange (internalLibraries);
- ProjectBackend.WidgetLibraries = libs;
-
- libs = new ArrayList ();
- libs.AddRange (internalLibraries);
- ProjectBackend.InternalWidgetLibraries = libs;
-
- app.UpdateWidgetLibraries (false, false);
- if (!reloadRequested)
- ProjectBackend.Reload ();
- }
-
-/* public bool CanCopySelection {
- get { return Selection != null ? Selection.CanCopy : false; }
- }
-
- public bool CanCutSelection {
- get { return Selection != null ? Selection.CanCut : false; }
- }
-
- public bool CanPasteToSelection {
- get { return Selection != null ? Selection.CanPaste : false; }
- }
-
- public void CopySelection ()
- {
- if (Selection != null)
- backend.ClipboardCopySelection ();
- }
-
- public void CutSelection ()
- {
- if (Selection != null)
- backend.ClipboardCutSelection ();
- }
-
- public void PasteToSelection ()
- {
- if (Selection != null)
- backend.ClipboardPaste ();
- }
-
- public void DeleteSelection ()
- {
- backend.DeleteSelection ();
- }
-*/
-
- public void EditIcons ()
- {
- ProjectBackend.EditIcons ();
- }
-
- internal void NotifyWidgetAdded (object obj, string name, string typeName)
- {
- GuiDispatch.InvokeSync (
- delegate {
- Component c = App.GetComponent (obj, name, typeName);
- if (c != null) {
- WidgetInfo wi = GetWidget (c.Name);
- if (wi == null) {
- wi = new WidgetInfo (this, c);
- widgets.Add (wi);
- }
- if (WidgetAdded != null)
- WidgetAdded (this, new WidgetInfoEventArgs (this, wi));
- }
- }
- );
- }
-
- internal void NotifyWidgetRemoved (string name)
- {
- GuiDispatch.InvokeSync (
- delegate {
- WidgetInfo wi = GetWidget (name);
- if (wi != null) {
- widgets.Remove (wi);
- if (WidgetRemoved != null)
- WidgetRemoved (this, new WidgetInfoEventArgs (this, wi));
- }
- }
- );
- }
-
- internal void NotifyModifiedChanged ()
- {
- GuiDispatch.InvokeSync (
- delegate {
- if (ModifiedChanged != null)
- ModifiedChanged (this, EventArgs.Empty);
- }
- );
- }
-
- internal void NotifyChanged (string rootWidgetName)
- {
- GuiDispatch.InvokeSync (
- delegate {
- if (Changed != null)
- Changed (this, EventArgs.Empty);
-
- // TODO: Optimize
- foreach (ProjectItemInfo it in widgets) {
- if (it.Name == rootWidgetName)
- it.NotifyChanged ();
- }
- foreach (ProjectItemInfo it in groups) {
- if (it.Name == rootWidgetName)
- it.NotifyChanged ();
- }
- }
- );
- }
-
- internal void NotifyWidgetNameChanged (object obj, string oldName, string newName, bool isRoot)
- {
- WidgetComponent c = obj != null ? (WidgetComponent) App.GetComponent (obj, null, null) : null;
- if (c != null)
- c.UpdateName (newName);
-
- if (isRoot) {
- WidgetInfo wi = GetWidget (oldName);
- if (wi != null)
- wi.NotifyNameChanged (newName);
- }
-
- GuiDispatch.InvokeSync (
- delegate {
- if (c != null) {
- if (ComponentNameChanged != null)
- ComponentNameChanged (this, new ComponentNameEventArgs (this, c, oldName));
- }
- }
- );
- }
-
- internal void NotifyActionGroupAdded (string group)
- {
- GuiDispatch.InvokeSync (delegate {
- ActionGroupInfo gi = GetActionGroup (group);
- if (gi == null) {
- gi = new ActionGroupInfo (this, group);
- groups.Add (gi);
- }
- if (ActionGroupsChanged != null)
- ActionGroupsChanged (this, EventArgs.Empty);
- });
- }
-
- internal void NotifyActionGroupRemoved (string group)
- {
- GuiDispatch.InvokeSync (delegate {
- ActionGroupInfo gi = GetActionGroup (group);
- if (gi != null) {
- groups.Remove (gi);
- if (ActionGroupsChanged != null)
- ActionGroupsChanged (this, EventArgs.Empty);
- }
- });
- }
-
- internal void NotifySignalAdded (object obj, string name, Signal signal)
- {
- GuiDispatch.InvokeSync (delegate {
- if (SignalAdded != null) {
- Component c = App.GetComponent (obj, name, null);
- if (c != null)
- SignalAdded (this, new ComponentSignalEventArgs (this, c, null, signal));
- }
- });
- }
-
- internal void NotifySignalRemoved (object obj, string name, Signal signal)
- {
- GuiDispatch.InvokeSync (delegate {
- if (SignalRemoved != null) {
- Component c = App.GetComponent (obj, name, null);
- if (c != null)
- SignalRemoved (this, new ComponentSignalEventArgs (this, c, null, signal));
- }
- });
- }
-
- internal void NotifySignalChanged (object obj, string name, Signal oldSignal, Signal signal)
- {
- GuiDispatch.InvokeSync (delegate {
- if (SignalChanged != null) {
- Component c = App.GetComponent (obj, name, null);
- if (c != null)
- SignalChanged (this, new ComponentSignalEventArgs (this, c, oldSignal, signal));
- }
- });
- }
-
- internal void NotifyProjectReloaded ()
- {
- GuiDispatch.InvokeSync (delegate {
- if (ProjectReloaded != null)
- ProjectReloaded (this, EventArgs.Empty);
- });
- }
-
- internal void NotifyProjectReloading ()
- {
- GuiDispatch.InvokeSync (delegate {
- if (ProjectReloading != null)
- ProjectReloading (this, EventArgs.Empty);
- });
- }
-
- internal void NotifyComponentTypesChanged ()
- {
- GuiDispatch.InvokeSync (delegate {
- if (ComponentTypesChanged != null)
- ComponentTypesChanged (this, EventArgs.Empty);
- });
- }
-
- internal string ImportFile (string filePath)
- {
- if (importFileDelegate != null) {
- string res = null;
- GuiDispatch.InvokeSync (delegate {
- res = importFileDelegate (filePath);
- });
- return res;
- }
- else
- return filePath;
- }
-
- internal void NotifyUpdateLibraries ()
- {
- app.UpdateWidgetLibraries (false, false);
- }
-
- void OnBackendChanging ()
- {
- selection = null;
-
- if (BackendChanging != null)
- BackendChanging ();
- }
-
- void OnBackendChanged (ApplicationBackend oldBackend)
- {
- if (oldBackend != null) {
- tmpProjectFile = Path.GetTempFileName ();
- backend.Save (tmpProjectFile);
- backend.Dispose ();
- }
-
- backend = app.Backend.CreateProject ();
- backend.SetFrontend (this);
-
- if (tmpProjectFile != null && File.Exists (tmpProjectFile)) {
-// backend.Load (tmpProjectFile, fileName);
- throw new NotImplementedException ("OnBackendChanged");
- File.Delete (tmpProjectFile);
- tmpProjectFile = null;
- } else if (folderName != null) {
- backend.Load (folderName);
- }
-
- if (resourceProvider != null)
- backend.ResourceProvider = resourceProvider;
-
- if (BackendChanged != null)
- BackendChanged (oldBackend);
-
- if (ProjectReloaded != null)
- ProjectReloaded (this, EventArgs.Empty);
- }
- }
-
- public abstract class ProjectItemInfo
- {
- string name;
- protected Project project;
-
- public event EventHandler Changed;
-
- internal ProjectItemInfo (Project project, string name)
- {
- this.name = name;
- this.project = project;
- }
-
- public string Name {
- get { return name; }
- set { Component.Name = value; name = value; }
- }
-
- internal void NotifyNameChanged (string name)
- {
- this.name = name;
- NotifyChanged ();
- }
-
- internal void NotifyChanged ()
- {
- if (Changed != null)
- Changed (this, EventArgs.Empty);
- }
-
- public abstract Component Component { get; }
- }
-
- public class WidgetInfo: ProjectItemInfo
- {
- string type;
- List<ActionGroupInfo> groups;
-
- internal WidgetInfo (Project project, string name, string type): base (project, name)
- {
- this.type = type;
- }
-
- internal WidgetInfo (Project project, Component c): base (project, c.Name)
- {
- type = c.Type.Name;
- }
-
- public IEnumerable<ActionGroupInfo> ActionGroups {
- get {
- if (groups != null)
- return groups;
- else
- return new ActionGroupInfo [0];
- }
- }
-
- public string Type {
- get { return type; }
- }
-
- public bool IsWindow {
- get { return type == "Gtk.Dialog" || type == "Gtk.Window"; }
- }
-
- public override Component Component {
- get { return project.GetComponent (Name); }
- }
-
- internal void AddGroup (string group)
- {
- if (groups == null)
- groups = new List<ActionGroupInfo> ();
- groups.Add (new ActionGroupInfo (project, group, Name));
- }
- }
-
- public class ActionGroupInfo: ProjectItemInfo
- {
- string widgetName;
-
- internal ActionGroupInfo (Project project, string name): base (project, name)
- {
- }
-
- internal ActionGroupInfo (Project project, string name, string widgetName): base (project, name)
- {
- this.widgetName = widgetName;
- }
-
- public override Component Component {
- get {
- ActionGroupComponent[] ags;
- if (widgetName != null) {
- WidgetComponent c = project.GetComponent (widgetName) as WidgetComponent;
- if (c == null)
- return null;
- ags = c.GetActionGroups ();
- }
- else {
- ags = project.GetActionGroups ();
- }
- foreach (ActionGroupComponent ag in ags)
- if (ag.Name == Name)
- return ag;
- return null;
- }
- }
- }
-
- public delegate string ImportFileDelegate (string fileName);
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ProjectBackend.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ProjectBackend.cs
deleted file mode 100644
index 677c0a4af6..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ProjectBackend.cs
+++ /dev/null
@@ -1,1237 +0,0 @@
-using Gtk;
-using System;
-using System.IO;
-using System.Xml;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.CodeDom;
-using Mono.Unix;
-
-namespace Stetic {
-
- internal class ProjectBackend : MarshalByRefObject, IProject, IDisposable
- {
- List<WidgetData> topLevels;
- bool modified;
- Gtk.Widget selection;
- string id;
- string folderName;
- XmlDocument tempDoc;
- bool loading;
- IResourceProvider resourceProvider;
-
- // Global action groups of the project
- Stetic.Wrapper.ActionGroupCollection actionGroups;
- bool ownedGlobalActionGroups = true; // It may be false when reusing groups from another project
-
- Stetic.ProjectIconFactory iconFactory;
- Project frontend;
- ArrayList widgetLibraries;
- ArrayList internalLibs;
- ApplicationBackend app;
- AssemblyResolver resolver;
- string imagesRootPath;
- string targetGtkVersion;
- List<string> modifiedTopLevels;
- //During project conversion flag is set
- bool converting;
-
- // The action collection of the last selected widget
- Stetic.Wrapper.ActionGroupCollection oldTopActionCollection;
-
- public event Wrapper.WidgetNameChangedHandler WidgetNameChanged;
- public event Wrapper.WidgetEventHandler WidgetAdded;
- public event Wrapper.WidgetEventHandler WidgetContentsChanged;
- public event ObjectWrapperEventHandler ObjectChanged;
- public event EventHandler ComponentTypesChanged;
-
- public event SignalEventHandler SignalAdded;
- public event SignalEventHandler SignalRemoved;
- public event SignalChangedEventHandler SignalChanged;
-
- public event Wrapper.WidgetEventHandler SelectionChanged;
- public event ProjectChangedEventHandler Changed;
-
- // Fired when the project has been reloaded, due for example to
- // a change in the registry
- public event EventHandler ProjectReloading;
- public event EventHandler ProjectReloaded;
-
- public ProjectBackend (ApplicationBackend app)
- {
- this.app = app;
- topLevels = new List<WidgetData> ();
-
- ActionGroups = new Stetic.Wrapper.ActionGroupCollection ();
-
- Registry.RegistryChanging += OnRegistryChanging;
- Registry.RegistryChanged += OnRegistryChanged;
-
- iconFactory = new ProjectIconFactory ();
- widgetLibraries = new ArrayList ();
- internalLibs = new ArrayList ();
- modifiedTopLevels = new List<string> ();
- }
-
- public void Dispose ()
- {
- // First of all, disconnect from the frontend,
- // to avoid sending notifications while disposing
- frontend = null;
-
- if (oldTopActionCollection != null)
- oldTopActionCollection.ActionGroupChanged -= OnComponentTypesChanged;
-
- Registry.RegistryChanging -= OnRegistryChanging;
- Registry.RegistryChanged -= OnRegistryChanged;
- Close ();
- iconFactory = null;
- ActionGroups = null;
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
-
-
- public string FileName {
- get { throw new Exception("FileName is obsolete"); }
- set { throw new Exception("FileName is obsolete"); }
- }
-
- public string FolderName {
- get { return folderName; }
- set {
- this.folderName = value;
- if (folderName != null )
- Id = System.IO.Path.GetFullPath (folderName);
- else
- Id = null;
- }
- }
-
- internal ArrayList WidgetLibraries {
- get { return widgetLibraries; }
- set { widgetLibraries = value; }
- }
-
- internal ArrayList InternalWidgetLibraries {
- get { return internalLibs; }
- set { internalLibs = value; }
- }
-
- public bool IsInternalLibrary (string lib)
- {
- return internalLibs.Contains (lib);
- }
-
- public bool CanGenerateCode {
- get {
- // It can generate code if all libraries on which depend can generate code
- foreach (string s in widgetLibraries) {
- WidgetLibrary lib = Registry.GetWidgetLibrary (s);
- if (lib != null && !lib.CanGenerateCode)
- return false;
- }
- return true;
- }
- }
-
- public string TargetGtkVersion {
- get { return targetGtkVersion ?? string.Empty; }
- set {
- if (TargetGtkVersion == value)
- return;
- targetGtkVersion = value;
-
-// Update the project
- OnRegistryChanging (null, null);
- OnRegistryChanged (null, null);
- }
- }
-
- public string ImagesRootPath {
- get {
- if (string.IsNullOrEmpty (imagesRootPath)) {
- if (string.IsNullOrEmpty (folderName))
- return ".";
- else
- return Path.GetFullPath (folderName);
- }
- else {
- if (Path.IsPathRooted (imagesRootPath))
- return imagesRootPath;
- else if (!string.IsNullOrEmpty (folderName))
- return Path.GetFullPath (Path.Combine (folderName, imagesRootPath));
- else
- return imagesRootPath;
- }
- }
- set { imagesRootPath = value; }
- }
-
-
- public void AddWidgetLibrary (string lib)
- {
- AddWidgetLibrary (lib, false);
- }
-
- public void AddWidgetLibrary (string lib, bool isInternal)
- {
- if (!widgetLibraries.Contains (lib))
- widgetLibraries.Add (lib);
- if (isInternal) {
- if (!internalLibs.Contains (lib))
- internalLibs.Add (lib);
- }
- else {
- internalLibs.Remove (lib);
- }
- }
-
- public void RemoveWidgetLibrary (string lib)
- {
- widgetLibraries.Remove (lib);
- internalLibs.Remove (lib);
- }
-
- public ArrayList GetComponentTypes ()
- {
- ArrayList list = new ArrayList ();
- foreach (WidgetLibrary lib in app.GetProjectLibraries (this)) {
- // Don't include in the list widgets which are internal (when the library is
- // not internal to the project), widgets not assigned to any category, and deprecated ones.
- bool isInternalLib = IsInternalLibrary (lib.Name);
- if (lib.NeedsReload)
- lib.Reload ();
- foreach (ClassDescriptor cd in lib.AllClasses) {
- if (!cd.Deprecated && cd.Category.Length > 0 && (isInternalLib || !cd.IsInternal) && cd.SupportsGtkVersion (TargetGtkVersion))
- list.Add (cd.Name);
- }
- }
- return list;
- }
-
- public string[] GetWidgetTypes ()
- {
- List<string> list = new List<string> ();
- foreach (WidgetLibrary lib in app.GetProjectLibraries (this)) {
- // Don't include in the list widgets which are internal (when the library is
- // not internal to the project) and deprecated ones.
- bool isInternalLib = IsInternalLibrary (lib.Name);
- foreach (ClassDescriptor cd in lib.AllClasses) {
- if (!cd.Deprecated && (isInternalLib || !cd.IsInternal))
- list.Add (cd.Name);
- }
- }
- return list.ToArray ();
- }
-
- public IResourceProvider ResourceProvider {
- get { return resourceProvider; }
- set { resourceProvider = value; }
- }
-
- public Stetic.Wrapper.ActionGroupCollection ActionGroups {
- get { return actionGroups; }
- set {
- if (actionGroups != null) {
- actionGroups.ActionGroupAdded -= OnGroupAdded;
- actionGroups.ActionGroupRemoved -= OnGroupRemoved;
- actionGroups.ActionGroupChanged -= OnComponentTypesChanged;
- }
- actionGroups = value;
- if (actionGroups != null) {
- actionGroups.ActionGroupAdded += OnGroupAdded;
- actionGroups.ActionGroupRemoved += OnGroupRemoved;
- actionGroups.ActionGroupChanged += OnComponentTypesChanged;
- }
- ownedGlobalActionGroups = true;
- }
- }
-
- public void AttachActionGroups (Stetic.Wrapper.ActionGroupCollection groups)
- {
- ActionGroups = groups;
- ownedGlobalActionGroups = false;
- }
-
- public Stetic.ProjectIconFactory IconFactory {
- get { return iconFactory; }
- set { iconFactory = value; }
- }
-
- internal void SetFrontend (Project project)
- {
- frontend = project;
- }
-
- public void Close ()
- {
- if (actionGroups != null && ownedGlobalActionGroups) {
- foreach (Stetic.Wrapper.ActionGroup ag in actionGroups)
- ag.Dispose ();
- actionGroups.Clear ();
- }
-
- foreach (WidgetData wd in topLevels) {
- if (wd.Widget != null)
- wd.Widget.Destroy ();
- }
-
- selection = null;
- topLevels.Clear ();
- //widgetLibraries.Clear ();
-
-
- iconFactory = new ProjectIconFactory ();
- }
-
- public void Load (string folderName)
- {
- this.folderName = folderName;
- XmlDocument doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
- XmlElement toplevel = doc.CreateElement ("stetic-interface");
- doc.AppendChild (toplevel);
- modifiedTopLevels.Clear ();
-
- ReadIconFactory (doc);
- ReadActionGroups (doc);
- ReadTopLevels (doc);
- Read (doc);
-
- Id = System.IO.Path.GetFullPath (folderName);
- }
-
- public void LoadOldVersion (string fileName)
- {
- if (!File.Exists (fileName))
- return;
-
- XmlDocument doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
- doc.Load (fileName);
-
- Read (doc);
-
- Id = System.IO.Path.GetFileName (fileName);
- }
-
- void ReadIconFactory (XmlDocument doc)
- {
- XmlNode node = doc.SelectSingleNode ("/stetic-interface");
- if (node == null)
- return;
-
- string basePath = folderName;
- string xmlfile = Path.Combine(basePath, "IconFactory.gtkx");
-
- if (File.Exists (xmlfile)) {
-
- XmlDocument doc2 = new XmlDocument ();
- doc2.PreserveWhitespace = true;
- doc2.Load (xmlfile);
-
- XmlNode ifnode2 = doc2.SelectSingleNode ("/stetic-interface/icon-factory");
-
- if (ifnode2 != null) {
- XmlNode ifnode = doc.ImportNode (ifnode2, true);
- node.AppendChild (ifnode);
- }
- }
- }
-
- void ReadActionGroups (XmlDocument doc)
- {
- ReadSplitFiles (doc, "action-group", "name");
- }
-
- void ReadTopLevels (XmlDocument doc)
- {
- ReadSplitFiles (doc, "widget", "id");
- }
-
- void ReadSplitFiles (XmlDocument doc, string splitElement, string idAttribute)
- {
- XmlNode node = doc.SelectSingleNode ("/stetic-interface");
- if (node == null)
- return;
-
- foreach (string basePath in frontend.DesignInfo.GetComponentFolders ()) {
- DirectoryInfo dir = new DirectoryInfo (basePath);
-
- foreach (FileInfo file in dir.GetFiles ()) {
- if (file.Extension == ".gtkx") {
-
- XmlDocument wdoc = new XmlDocument ();
- wdoc.PreserveWhitespace = true;
- wdoc.Load (file.FullName);
-
- XmlNode wnode = wdoc.SelectSingleNode ("/stetic-interface");
-
- foreach (XmlElement toplevel in wnode.SelectNodes (splitElement)) {
- string id = toplevel.GetAttribute (idAttribute);
-
- if (frontend.DesignInfo.HasComponentFile (id)) {
- XmlNode imported = doc.ImportNode (toplevel, true);
- node.AppendChild (imported);
- }
- }
- }
- }
- }
- }
-
- void AddActionGroup (XmlElement groupElem)
- {
- ObjectReader reader = new ObjectReader (this, FileFormat.Native);
-
- Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup ();
- actionGroup.Read (reader, groupElem);
- actionGroups.Add (actionGroup);
- }
-
- void AddWidget (XmlElement toplevel)
- {
- topLevels.Add (new WidgetData (toplevel.GetAttribute ("id"), toplevel, null));
- }
-
- void Read (XmlDocument doc)
- {
- loading = true;
-
- try {
- Close ();
-
- XmlNode node = doc.SelectSingleNode ("/stetic-interface");
- if (node == null)
- throw new ApplicationException (Catalog.GetString ("Not a Stetic file according to node name."));
-
- // Load the assembly directories
- resolver = new AssemblyResolver (app);
- app.LoadLibraries (resolver, widgetLibraries);
-
- if (ownedGlobalActionGroups) {
- foreach (XmlElement groupElem in node.SelectNodes ("action-group"))
- AddActionGroup (groupElem);
- }
-
- XmlElement iconsElem = node.SelectSingleNode ("icon-factory") as XmlElement;
- if (iconsElem != null)
- iconFactory.Read (this, iconsElem);
-
- foreach (XmlElement toplevel in node.SelectNodes ("widget"))
- AddWidget (toplevel);
-
- } finally {
- loading = false;
- }
- }
-
- public Gtk.Widget GetWidget (WidgetData data)
- {
- if (data.Widget == null) {
- try {
- loading = true;
- ObjectReader reader = new ObjectReader (this, FileFormat.Native);
- Wrapper.Container wrapper = Stetic.ObjectWrapper.ReadObject (reader, data.XmlData, null) as Wrapper.Container;
- data.Widget = wrapper.Wrapped;
- data.Widget.Destroyed += (s,e) => data.Widget = null;
- } finally {
- loading = false;
- }
- }
-
- return data.Widget;
- }
-
- public bool ReloadTopLevel (string topLevelName)
- {
- XmlElement topLevelElem = ReadDesignerFile (topLevelName, "widget");
- if (topLevelName != null) {
- WidgetData data = GetWidgetData (topLevelName);
-
- if (data != null) {
- //Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup (data.Widget);
- data.SetXmlData (topLevelName, topLevelElem);
- GetWidget (data);
- return true;
- }
- }
- return false;
- }
-
- public void ReloadComponent (string componentName)
- {
- ReloadTopLevel (componentName);
- //TODO: Make reloading works for action groups
- }
-
-
- public void ReloadActionGroup (string groupName)
- {
- //TODO : Implement method ReloadActionGroup
- }
-
- XmlElement ReadDesignerFile (string componentName, string elementName)
- {
- string gtkxFile = GetDesignerFileName (componentName);
- if (gtkxFile != null) {
- XmlDocument wdoc = new XmlDocument ();
- wdoc.PreserveWhitespace = true;
- wdoc.Load (gtkxFile);
-
- XmlNode wnode = wdoc.SelectSingleNode ("/stetic-interface");
- foreach (XmlElement toplevel in wnode.SelectNodes (elementName)) {
- return toplevel;
- }
-
- string msg = string.Format (@"Cannot find /stetic-interface/{0} element in {1} file.",
- elementName, gtkxFile);
- throw new InvalidOperationException (msg);
- }
-
- return null;
- }
-
- public void ConvertProject (string oldSteticFileName, string newGuiFolderName)
- {
- converting = true;
- try {
- LoadOldVersion (oldSteticFileName);
- Save (newGuiFolderName);
- } finally {
- converting = false;
- }
- }
-
- public void Save (string folderName)
- {
- this.folderName = folderName;
- XmlDocument doc = Write (false);
-
- XmlTextWriter writer = null;
- try {
- WriteIconFactory (doc);
- WriteActionGroups (doc);
- WriteTopLevels (doc);
-
- } finally {
- if (writer != null)
- writer.Close ();
- }
- }
-
- private void WriteIconFactory (XmlDocument doc)
- {
- XmlNode node = doc.SelectSingleNode ("/stetic-interface");
- if (node == null)
- return;
-
- XmlNode ifnode = node.SelectSingleNode ("icon-factory");
- if (ifnode == null)
- return;
-
- XmlDocument doc2 = new XmlDocument ();
- doc2.PreserveWhitespace = true;
-
- XmlElement node2 = doc2.CreateElement ("stetic-interface");
- doc2.AppendChild (node2);
-
- XmlNode ifnode2 = doc2.ImportNode (ifnode, true);
- node2.AppendChild (ifnode2);
-
- string basePath = this.folderName;
- string xmlFile = Path.Combine (basePath, "IconFactory.gtkx");
- WriteXmlFile (xmlFile, doc2);
-
- node.RemoveChild (ifnode);
- }
-
- void WriteActionGroups (XmlDocument doc)
- {
- WriteSplitFiles (doc, "action-group", "name");
- }
-
- void WriteTopLevels (XmlDocument doc)
- {
- WriteSplitFiles (doc, "widget", "id");
- }
-
- void WriteSplitFiles (XmlDocument doc, string splitElement, string idAttribute)
- {
- XmlNode node = doc.SelectSingleNode ("/stetic-interface");
- if (node == null)
- return;
-
- foreach (XmlElement toplevel in node.SelectNodes (splitElement)) {
-
- string id = toplevel.GetAttribute (idAttribute);
- if (modifiedTopLevels.Contains (id) || converting) {
- string xmlFile = GetDesignerFileName (id);
- if (xmlFile != null) {
- XmlDocument doc2 = new XmlDocument ();
- doc2.PreserveWhitespace = true;
-
- XmlElement node2 = doc2.CreateElement ("stetic-interface");
- doc2.AppendChild (node2);
-
- XmlNode wnode2 = doc2.ImportNode (toplevel, true);
- node2.AppendChild (wnode2);
-
- WriteXmlFile (xmlFile, doc2);
- if (modifiedTopLevels.Contains (id))
- modifiedTopLevels.Remove (id);
- }
- }
- }
- }
-
- private string GetDesignerFileName (string componentName)
- {
- string componentFile = frontend.DesignInfo.GetComponentFile (componentName);
- return frontend.DesignInfo.GetDesignerFileFromComponent (componentFile);
- }
-
- void WriteXmlFile (string xmlFile, XmlDocument doc)
- {
- XmlTextWriter writer = null;
- try {
- writer = new XmlTextWriter (xmlFile + "~", System.Text.Encoding.UTF8);
- writer.Formatting = Formatting.Indented;
-
- doc.Save (writer);
- writer.Close ();
-
- File.Copy (xmlFile + "~", xmlFile, true);
- File.Delete (xmlFile + "~");
- } finally {
- if (writer != null)
- writer.Close ();
- }
- }
-
- XmlDocument Write (bool includeUndoInfo)
- {
- XmlDocument doc = new XmlDocument ();
- doc.PreserveWhitespace = true;
-
- XmlElement toplevel = doc.CreateElement ("stetic-interface");
- doc.AppendChild (toplevel);
-
- ObjectWriter writer = new ObjectWriter (doc, FileFormat.Native);
- writer.CreateUndoInfo = includeUndoInfo;
- if (ownedGlobalActionGroups) {
- foreach (Wrapper.ActionGroup agroup in actionGroups) {
- XmlElement elem = agroup.Write (writer);
- toplevel.AppendChild (elem);
- }
- }
-
- if (iconFactory.Icons.Count > 0)
- toplevel.AppendChild (iconFactory.Write (doc));
-
- foreach (WidgetData data in topLevels) {
- if (data.Widget != null) {
- Stetic.Wrapper.Container wrapper = Stetic.Wrapper.Container.Lookup (data.Widget);
- if (wrapper == null)
- continue;
-
- XmlElement elem = wrapper.Write (writer);
- if (elem != null)
- toplevel.AppendChild (elem);
- } else {
- toplevel.AppendChild (doc.ImportNode (data.XmlData, true));
- }
- }
-
- // Remove undo annotations from the xml document
- if (!includeUndoInfo)
- CleanUndoData (doc.DocumentElement);
-
- return doc;
- }
-
- public void ImportGlade (string fileName)
- {
- GladeFiles.Import (this, fileName);
- }
-
- public void ExportGlade (string fileName)
- {
- GladeFiles.Export (this, fileName);
- }
-
- public void EditIcons ()
- {
- using (Stetic.Editor.EditIconFactoryDialog dlg = new Stetic.Editor.EditIconFactoryDialog (null, this, this.IconFactory)) {
- dlg.Run ();
- }
- }
-
-// internal WidgetEditSession CreateWidgetDesignerSession (WidgetDesignerFrontend frontend, string windowName, Stetic.ProjectBackend editingBackend, bool autoCommitChanges)
-// {
-// return new WidgetEditSession (this, frontend, windowName, editingBackend, autoCommitChanges);
-// }
-
- internal WidgetEditSession CreateWidgetDesignerSession (WidgetDesignerFrontend frontend, string windowName)
- {
- return new WidgetEditSession (this, frontend, windowName);
- }
-
- internal ActionGroupEditSession CreateGlobalActionGroupDesignerSession (ActionGroupDesignerFrontend frontend, string groupName, bool autoCommitChanges)
- {
- return new ActionGroupEditSession (frontend, this, null, groupName, autoCommitChanges);
- }
-
- internal ActionGroupEditSession CreateLocalActionGroupDesignerSession (ActionGroupDesignerFrontend frontend, string windowName, bool autoCommitChanges)
- {
- return new ActionGroupEditSession (frontend, this, windowName, null, autoCommitChanges);
- }
-
- public Wrapper.Container GetTopLevelWrapper (string name, bool throwIfNotFound)
- {
- Gtk.Widget w = GetWidget (name);
- if (w != null) {
- Wrapper.Container ww = Wrapper.Container.Lookup (w);
- if (ww != null)
- return (Wrapper.Container) Component.GetSafeReference (ww);
- }
- if (throwIfNotFound)
- throw new InvalidOperationException ("Component not found: " + name);
- return null;
- }
-
- public object AddNewComponent (string fileName)
- {
- XmlDocument doc = new XmlDocument();
- doc.PreserveWhitespace = true;
- doc.Load (fileName);
-
- XmlElement toplevel = (XmlElement)doc.SelectSingleNode ("/stetic-interface/widget");
- if (toplevel != null)
- return AddNewWidgetFromTemplate (toplevel.OuterXml);
-
- XmlElement groupElem = (XmlElement)doc.SelectSingleNode ("/stetic-interface/action-group");
- if (groupElem != null)
- return AddNewActionGroupFromTemplate (groupElem.OuterXml);
-
- return null;
- }
-
- public object AddNewWidget (string type, string name)
- {
- ClassDescriptor cls = Registry.LookupClassByName (type);
- Gtk.Widget w = (Gtk.Widget) cls.NewInstance (this);
- w.Name = name;
- this.AddWidget (w);
- return Component.GetSafeReference (ObjectWrapper.Lookup (w));
- }
-
- public object AddNewWidgetFromTemplate (string template)
- {
- XmlDocument doc = new XmlDocument ();
- doc.LoadXml (template);
- Gtk.Widget widget = Stetic.WidgetUtils.ImportWidget (this, doc.DocumentElement);
- AddWidget (widget);
-
- string name = widget.Name;
- return Component.GetSafeReference (ObjectWrapper.Lookup (widget));
- }
-
- public void RemoveWidget (string name)
- {
- WidgetData data = GetWidgetData (name);
- if (data == null)
- return;
-
- if (frontend != null)
- frontend.NotifyWidgetRemoved (data.Name);
-
- if (modifiedTopLevels.Contains (name))
- modifiedTopLevels.Remove (name);
- }
-
- public Stetic.Wrapper.ActionGroup AddNewActionGroup (string name)
- {
- Stetic.Wrapper.ActionGroup group = new Stetic.Wrapper.ActionGroup ();
- group.Name = name;
- ActionGroups.Add (group);
- this.modifiedTopLevels.Add (name);
- return group;
- }
-
- public Stetic.Wrapper.ActionGroup AddNewActionGroupFromTemplate (string template)
- {
- XmlDocument doc = new XmlDocument ();
- doc.LoadXml (template);
- ObjectReader or = new ObjectReader (this, FileFormat.Native);
- Stetic.Wrapper.ActionGroup group = new Stetic.Wrapper.ActionGroup ();
- group.Read (or, doc.DocumentElement);
- ActionGroups.Add (group);
- this.modifiedTopLevels.Add (group.Name);
- return group;
- }
-
- public void RemoveActionGroup (Stetic.Wrapper.ActionGroup group)
- {
- ActionGroups.Remove (group);
- string name = group.Name;
- if (modifiedTopLevels.Contains (name))
- modifiedTopLevels.Remove (name);
- }
-
- public Wrapper.ActionGroup[] GetActionGroups ()
- {
- // Needed since ActionGroupCollection can't be made serializable
- return ActionGroups.ToArray ();
- }
-
- void CleanUndoData (XmlElement elem)
- {
- elem.RemoveAttribute ("undoId");
- foreach (XmlNode cn in elem.ChildNodes) {
- XmlElement ce = cn as XmlElement;
- if (ce != null)
- CleanUndoData (ce);
- }
- }
-
- void OnRegistryChanging (object o, EventArgs args)
- {
- if (loading) return;
-
- // Store a copy of the current tree. The tree will
- // be recreated once the registry change is completed.
-
- tempDoc = Write (true);
- Selection = null;
- }
-
- void OnRegistryChanged (object o, EventArgs args)
- {
- if (loading) return;
-
- if (tempDoc != null)
- LoadStatus (tempDoc);
- }
-
- public object SaveStatus ()
- {
- return Write (true);
- }
-
- public void LoadStatus (object ob)
- {
- if (frontend != null)
- frontend.NotifyProjectReloading ();
- if (ProjectReloading != null)
- ProjectReloading (this, EventArgs.Empty);
-
- ProjectIconFactory icf = iconFactory;
-
- Read ((XmlDocument)ob);
-
- // Reuse the same icon factory, since a registry change has no effect to it
- // and it may be inherited from another project
- iconFactory = icf;
-
- if (frontend != null)
- frontend.NotifyProjectReloaded ();
- if (ProjectReloaded != null)
- ProjectReloaded (this, EventArgs.Empty);
- NotifyComponentTypesChanged ();
- }
-
- bool preserveWidgetLibraries;
-
- public void Reload ()
- {
- try {
- preserveWidgetLibraries = true;
- OnRegistryChanging (null, null);
- OnRegistryChanged (null, null);
- }
- finally
- {
- preserveWidgetLibraries = false;
- }
- }
-
- public string Id {
- get { return id; }
- set { id = value; }
- }
-
- public bool WasModified (string topLevel)
- {
- return modifiedTopLevels.Contains (topLevel);
- }
-
- public bool ComponentNeedsCodeGeneration (string topLevel)
- {
- return frontend.DesignInfo.ComponentNeedsCodeGeneration (topLevel);
- }
-
- public AssemblyResolver Resolver {
- get { return resolver; }
- }
-
- public string ImportFile (string filePath)
- {
- return frontend.ImportFile (filePath);
- }
-
- public void AddWindow (Gtk.Window window)
- {
- AddWindow (window, false);
- }
-
- public void AddWindow (Gtk.Window window, bool select)
- {
- AddWidget (window);
- if (select)
- Selection = window;
- }
-
- public void AddWidget (Gtk.Widget widget)
- {
- if (!typeof(Gtk.Container).IsInstanceOfType (widget))
- throw new System.ArgumentException ("widget", "Only containers can be top level widgets");
- topLevels.Add (new WidgetData (null, null, widget));
-
- if (!loading) {
- Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup (widget);
-
- if (ww == null)
- throw new InvalidOperationException ("Widget not wrapped");
- if (frontend != null)
- frontend.NotifyWidgetAdded (Component.GetSafeReference (ww), widget.Name, ww.ClassDescriptor.Name);
- OnWidgetAdded (new Stetic.Wrapper.WidgetEventArgs (ww));
- }
- }
-
- void IProject.NotifyObjectChanged (ObjectWrapperEventArgs args)
- {
- if (loading)
- return;
- NotifyChanged (args.Wrapper.RootWrapperName);
- if (ObjectChanged != null)
- ObjectChanged (this, args);
- }
-
- void IProject.NotifyNameChanged (Stetic.Wrapper.WidgetNameChangedArgs args)
- {
- if (loading)
- return;
- NotifyChanged (args.WidgetWrapper.RootWrapperName);
- OnWidgetNameChanged (args, args.WidgetWrapper.IsTopLevel);
- }
-
- void IProject.NotifySignalAdded (SignalEventArgs args)
- {
- if (loading)
- return;
- if (frontend != null)
- frontend.NotifySignalAdded (Component.GetSafeReference (args.Wrapper), null, args.Signal);
- OnSignalAdded (args);
- }
-
- void IProject.NotifySignalRemoved (SignalEventArgs args)
- {
- if (loading)
- return;
- if (frontend != null)
- frontend.NotifySignalRemoved (Component.GetSafeReference (args.Wrapper), null, args.Signal);
- OnSignalRemoved (args);
- }
-
- void IProject.NotifySignalChanged (SignalChangedEventArgs args)
- {
- if (loading)
- return;
- OnSignalChanged (args);
- }
-
- void IProject.NotifyWidgetContentsChanged (Wrapper.Widget w)
- {
- if (loading)
- return;
- if (WidgetContentsChanged != null)
- WidgetContentsChanged (this, new Wrapper.WidgetEventArgs (w));
- }
-
- void OnWidgetNameChanged (Stetic.Wrapper.WidgetNameChangedArgs args, bool isTopLevel)
- {
- if (frontend != null)
- frontend.NotifyWidgetNameChanged (Component.GetSafeReference (args.WidgetWrapper), args.OldName, args.NewName, isTopLevel);
- if (args.WidgetWrapper != null && WidgetNameChanged != null)
- WidgetNameChanged (this, args);
-
- if (modifiedTopLevels.Contains (args.OldName))
- modifiedTopLevels.Remove (args.OldName);
-
- if (!modifiedTopLevels.Contains (args.NewName))
- modifiedTopLevels.Add (args.NewName);
- }
-
- void OnSignalAdded (object sender, SignalEventArgs args)
- {
- if (frontend != null)
- frontend.NotifySignalAdded (Component.GetSafeReference (args.Wrapper), null, args.Signal);
- OnSignalAdded (args);
- }
-
- protected virtual void OnSignalAdded (SignalEventArgs args)
- {
- if (SignalAdded != null)
- SignalAdded (this, args);
- }
-
- void OnSignalRemoved (object sender, SignalEventArgs args)
- {
- if (frontend != null)
- frontend.NotifySignalRemoved (Component.GetSafeReference (args.Wrapper), null, args.Signal);
- OnSignalRemoved (args);
- }
-
- protected virtual void OnSignalRemoved (SignalEventArgs args)
- {
- if (SignalRemoved != null)
- SignalRemoved (this, args);
- }
-
- void OnSignalChanged (object sender, SignalChangedEventArgs args)
- {
- OnSignalChanged (args);
- }
-
- protected virtual void OnSignalChanged (SignalChangedEventArgs args)
- {
- if (frontend != null)
- frontend.NotifySignalChanged (Component.GetSafeReference (args.Wrapper), null, args.OldSignal, args.Signal);
- if (SignalChanged != null)
- SignalChanged (this, args);
- }
-
- public Gtk.Widget[] Toplevels {
- get {
- List<Gtk.Widget> list = new List<Gtk.Widget> ();
- foreach (WidgetData w in topLevels)
- list.Add (GetWidget (w));
- return list.ToArray ();
- }
- }
-
- public Gtk.Widget GetWidget (string name)
- {
- WidgetData w = GetWidgetData (name);
- if (w != null)
- return GetWidget (w);
- else
- return null;
- }
-
- public WidgetData GetWidgetData (string name)
- {
- foreach (WidgetData w in topLevels) {
- if (w.Name == name)
- return w;
- }
- return null;
- }
-
- // IProject
-
- public Gtk.Widget Selection {
- get {
- return selection;
- }
- set {
- if (selection == value)
- return;
-
- Wrapper.ActionGroupCollection newCollection = null;
-
- // FIXME: should there be an IsDestroyed property?
- if (selection != null && selection.Handle != IntPtr.Zero) {
- Stetic.Wrapper.Container parent = Stetic.Wrapper.Container.LookupParent (selection);
- if (parent == null)
- parent = Stetic.Wrapper.Container.Lookup (selection);
- if (parent != null)
- parent.UnSelect (selection);
- }
-
- selection = value;
-
- if (selection != null && selection.Handle != IntPtr.Zero) {
- Stetic.Wrapper.Container parent = Stetic.Wrapper.Container.LookupParent (selection);
- if (parent == null)
- parent = Stetic.Wrapper.Container.Lookup (selection);
- if (parent != null)
- parent.Select (selection);
- Wrapper.Widget w = Wrapper.Widget.Lookup (selection);
- if (w != null)
- newCollection = w.LocalActionGroups;
- }
-
- if (SelectionChanged != null)
- SelectionChanged (this, new Wrapper.WidgetEventArgs (Wrapper.Widget.Lookup (selection)));
-
- if (oldTopActionCollection != newCollection) {
- if (oldTopActionCollection != null)
- oldTopActionCollection.ActionGroupChanged -= OnComponentTypesChanged;
- if (newCollection != null)
- newCollection.ActionGroupChanged += OnComponentTypesChanged;
- oldTopActionCollection = newCollection;
- OnComponentTypesChanged (null, null);
- }
- }
- }
-
- public void PopupContextMenu (Stetic.Wrapper.Widget wrapper)
- {
- Gtk.Menu m = new ContextMenu (wrapper);
- m.Popup ();
- }
-
- public void PopupContextMenu (Placeholder ph)
- {
- Gtk.Menu m = new ContextMenu (ph);
- m.Popup ();
- }
-
- internal static string AbsoluteToRelativePath (string baseDirectoryPath, string absPath)
- {
- if (!Path.IsPathRooted (absPath))
- return absPath;
-
- absPath = Path.GetFullPath (absPath);
- baseDirectoryPath = Path.GetFullPath (baseDirectoryPath);
- char[] separators = { Path.DirectorySeparatorChar, Path.VolumeSeparatorChar, Path.AltDirectorySeparatorChar };
-
- string[] bPath = baseDirectoryPath.Split (separators);
- string[] aPath = absPath.Split (separators);
- int indx = 0;
- for(; indx < Math.Min(bPath.Length, aPath.Length); ++indx) {
- if(!bPath[indx].Equals(aPath[indx]))
- break;
- }
-
- if (indx == 0) {
- return absPath;
- }
-
- string erg = "";
-
- if(indx == bPath.Length) {
- erg += "." + Path.DirectorySeparatorChar;
- } else {
- for (int i = indx; i < bPath.Length; ++i) {
- erg += ".." + Path.DirectorySeparatorChar;
- }
- }
- erg += String.Join(Path.DirectorySeparatorChar.ToString(), aPath, indx, aPath.Length-indx);
-
- return erg;
- }
-
- void OnComponentTypesChanged (object s, EventArgs a)
- {
- if (!loading)
- NotifyComponentTypesChanged ();
- }
-
- public void NotifyComponentTypesChanged ()
- {
- if (frontend != null)
- frontend.NotifyComponentTypesChanged ();
- if (ComponentTypesChanged != null)
- ComponentTypesChanged (this, EventArgs.Empty);
- }
-
- void OnGroupAdded (object s, Stetic.Wrapper.ActionGroupEventArgs args)
- {
- args.ActionGroup.SignalAdded += OnSignalAdded;
- args.ActionGroup.SignalRemoved += OnSignalRemoved;
- args.ActionGroup.SignalChanged += OnSignalChanged;
- if (frontend != null)
- frontend.NotifyActionGroupAdded (args.ActionGroup.Name);
- OnComponentTypesChanged (null, null);
- }
-
- void OnGroupRemoved (object s, Stetic.Wrapper.ActionGroupEventArgs args)
- {
- args.ActionGroup.SignalAdded -= OnSignalAdded;
- args.ActionGroup.SignalRemoved -= OnSignalRemoved;
- args.ActionGroup.SignalChanged -= OnSignalChanged;
- if (frontend != null)
- frontend.NotifyActionGroupRemoved (args.ActionGroup.Name);
- OnComponentTypesChanged (null, null);
- }
-
- void NotifyChanged (string rootWidgetName)
- {
- if (!modifiedTopLevels.Contains (rootWidgetName))
- modifiedTopLevels.Add (rootWidgetName);
- if (frontend != null)
- frontend.NotifyChanged (rootWidgetName);
- if (Changed != null)
- Changed (this, new ProjectChangedEventArgs (rootWidgetName));
- }
-
- protected virtual void OnWidgetAdded (Stetic.Wrapper.WidgetEventArgs args)
- {
- NotifyChanged (args.WidgetWrapper.RootWrapperName);
- if (WidgetAdded != null)
- WidgetAdded (this, args);
- }
- }
-
- class WidgetData
- {
- string name;
-
- public WidgetData (string name, XmlElement data, Gtk.Widget widget)
- {
- SetXmlData (name, data);
- Widget = widget;
- }
-
- public void SetXmlData (string name, XmlElement data)
- {
- this.name = name;
- XmlData = data;
- Widget = null;
- }
-
- public XmlElement XmlData;
- public Gtk.Widget Widget;
-
- public string Name {
- get {
- if (Widget != null)
- return Widget.Name;
- else
- return name;
- }
- }
- }
-
- public class ProjectChangedEventArgs : EventArgs
- {
- public string ChangedTopLevelName { get; private set; }
-
- public ProjectChangedEventArgs (string changedTopLevel)
- {
- ChangedTopLevelName = changedTopLevel;
- }
- }
-
- public delegate void ProjectChangedEventHandler (object sender, ProjectChangedEventArgs args);
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ProjectViewBackend.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ProjectViewBackend.cs
deleted file mode 100644
index 3d93a71e7c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/ProjectViewBackend.cs
+++ /dev/null
@@ -1,345 +0,0 @@
-using Gtk;
-using System;
-using Mono.Unix;
-using System.Collections.Generic;
-
-namespace Stetic {
-
- internal class ProjectViewBackend : ScrolledWindow
- {
- ProjectViewBackendNodeView nodeView;
-
- public ProjectViewBackend (ProjectViewFrontend frontend)
- {
- ShadowType = Gtk.ShadowType.In;
- nodeView = new ProjectViewBackendNodeView (frontend);
- Add (nodeView);
- ShowAll ();
- }
-
- public event Wrapper.WidgetEventHandler WidgetActivated {
- add { nodeView.WidgetActivated += value; }
- remove { nodeView.WidgetActivated -= value; }
- }
-
- public void Bind (WidgetEditSession newSession)
- {
- nodeView.Bind (newSession);
- }
- }
-
- internal class ProjectViewBackendNodeView : TreeView
- {
- ProjectViewFrontend frontend;
- TreeStore store;
- WidgetEditSession editSession;
-
- const int ColIcon = 0;
- const int ColName = 1;
- const int ColWrapper = 2;
- const int ColFilled = 3;
-
- public event Wrapper.WidgetEventHandler WidgetActivated;
-
- public ProjectViewBackendNodeView (ProjectViewFrontend frontend)
- {
- this.frontend = frontend;
- HeadersVisible = false;
-
- store = new TreeStore (typeof(Gdk.Pixbuf), typeof(string), typeof(ObjectWrapper), typeof(bool));
- Model = store;
-
- TreeViewColumn col;
- CellRenderer renderer;
-
- col = new TreeViewColumn ();
-
- renderer = new CellRendererPixbuf ();
- col.PackStart (renderer, false);
- col.AddAttribute (renderer, "pixbuf", 0);
-
- renderer = new CellRendererText ();
- col.PackStart (renderer, true);
- col.AddAttribute (renderer, "text", 1);
-
- AppendColumn (col);
-
- Selection.Mode = SelectionMode.Single;
- Selection.Changed += RowSelected;
- TestExpandRow += OnTestExpandRow;
- ShowAll ();
- }
-
- public void Bind (WidgetEditSession newSession)
- {
- if (editSession != null) {
- editSession.SelectionChanged -= WidgetSelected;
- editSession.EditingBackend.ProjectReloaded -= OnProjectReloaded;
- editSession.EditingBackend.WidgetNameChanged -= OnWidgetNameChanged;
- editSession.EditingBackend.WidgetContentsChanged -= OnContentsChanged;
- }
- editSession = newSession;
- if (editSession != null) {
- editSession.SelectionChanged += WidgetSelected;
- editSession.EditingBackend.ProjectReloaded += OnProjectReloaded;
- editSession.EditingBackend.WidgetNameChanged += OnWidgetNameChanged;
- editSession.EditingBackend.WidgetContentsChanged += OnContentsChanged;
- }
- LoadProject ();
- }
-
- public override void Dispose ()
- {
- if (editSession != null) {
- editSession.SelectionChanged -= WidgetSelected;
- editSession.EditingBackend.ProjectReloaded -= OnProjectReloaded;
- editSession.EditingBackend.WidgetNameChanged -= OnWidgetNameChanged;
- editSession.EditingBackend.WidgetContentsChanged -= OnContentsChanged;
- }
- base.Dispose ();
- }
-
- public void LoadProject ()
- {
- Clear ();
- if (editSession == null || editSession.RootWidget == null)
- return;
-
- AddNode (TreeIter.Zero, editSession.RootWidget.Wrapped);
- }
-
- public void AddNode (TreeIter iter, Gtk.Widget widget)
- {
- Stetic.Wrapper.Widget wrapper = GetVisibleWrapper (widget);
- if (wrapper == null)
- return;
-
- Gdk.Pixbuf icon = wrapper.ClassDescriptor.Icon.ScaleSimple (16, 16, Gdk.InterpType.Bilinear);
- string txt = widget.Name;
-
- if (!iter.Equals (TreeIter.Zero))
- iter = store.AppendValues (iter, icon, txt, wrapper, true);
- else
- iter = store.AppendValues (icon, txt, wrapper, true);
-
- FillChildren (iter, wrapper);
- }
-
- void FillChildren (TreeIter it, Wrapper.Widget wrapper)
- {
- Stetic.Wrapper.Container container = wrapper as Wrapper.Container;
- if (container != null) {
- foreach (Gtk.Widget w in container.RealChildren) {
- Stetic.Wrapper.Widget ww = GetVisibleWrapper (w);
- if (ww != null) {
- // Add a dummy node to allow lazy loading
- store.SetValue (it, ColFilled, false);
- store.AppendValues (it, null, "", null, false);
- return;
- }
- }
- }
- store.SetValue (it, ColFilled, true);
- }
-
- Wrapper.Widget GetVisibleWrapper (Gtk.Widget w)
- {
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (w);
- if (wrapper == null || wrapper.Unselectable)
- return null;
- else
- return wrapper;
- }
-
- void EnsureFilled (TreeIter it)
- {
- bool filled = (bool) store.GetValue (it, ColFilled);
- if (filled)
- return;
-
- // Remove the dummy node
- TreeIter cit;
- store.IterChildren (out cit, it);
- store.Remove (ref cit);
-
- // Add the real children
- Stetic.Wrapper.Container container = store.GetValue (it, ColWrapper) as Wrapper.Container;
- if (container != null) {
- foreach (Gtk.Widget w in container.RealChildren)
- AddNode (it, w);
- }
-
- store.SetValue (it, ColFilled, true);
- }
-
- void OnTestExpandRow (object s, Gtk.TestExpandRowArgs args)
- {
- EnsureFilled (args.Iter);
- args.RetVal = false;
- }
-
- public void Clear ()
- {
- TreeIter it;
- while (store.GetIterFirst (out it)) {
- store.Remove (ref it);
- }
- }
-
- void RefreshNode (TreeIter it)
- {
- Wrapper.Widget wrapper = (Wrapper.Widget) store.GetValue (it, ColWrapper);
- store.SetValue (it, ColName, wrapper.Wrapped.Name);
- TreeIter cit;
- while (store.IterChildren (out cit, it)) {
- store.Remove (ref cit);
- }
- FillChildren (it, wrapper);
- }
-
- void OnWidgetNameChanged (object s, Wrapper.WidgetNameChangedArgs args)
- {
- TreeIter? node = FindNode (args.WidgetWrapper, false);
- if (node == null)
- return;
- store.SetValue (node.Value, ColName, args.NewName);
- }
-
- void OnContentsChanged (object s, Wrapper.WidgetEventArgs args)
- {
- TreeIter? node = FindNode (args.WidgetWrapper, false);
- if (node != null)
- RefreshNode (node.Value);
- }
-
- void OnProjectReloaded (object o, EventArgs a)
- {
- LoadProject ();
- }
-
- Stetic.Wrapper.Widget SelectedWrapper {
- get {
- TreeIter iter;
- if (!Selection.GetSelected (out iter))
- return null;
- Wrapper.Widget w = (Wrapper.Widget) store.GetValue (iter, ColWrapper);
- return w;
- }
- }
-
- bool syncing = false;
-
- void RowSelected (object obj, EventArgs args)
- {
- if (!syncing) {
- syncing = true;
- Stetic.Wrapper.Widget selection = SelectedWrapper;
- if (selection != null)
- selection.Select ();
- syncing = false;
- NotifySelectionChanged (selection);
- }
- }
-
- void WidgetSelected (object s, Wrapper.WidgetEventArgs args)
- {
- if (!syncing) {
- syncing = true;
- if (args.Widget != null) {
- Wrapper.Widget w = Wrapper.Widget.Lookup (args.Widget);
- if (w != null) {
- TreeIter? it = FindNode (w, true);
- if (it != null) {
- ExpandToPath (store.GetPath (it.Value));
- Selection.SelectIter (it.Value);
- ScrollToCell (store.GetPath (it.Value), Columns[0], false, 0, 0);
- NotifySelectionChanged (w);
- }
- }
- }
- else {
- Selection.UnselectAll ();
- NotifySelectionChanged (null);
- }
- syncing = false;
- }
- }
-
- TreeIter? FindNode (Wrapper.Widget w, bool loadBranches)
- {
- Wrapper.Widget parent = w.ParentWrapper;
- TreeIter it;
-
- if (parent == null) {
- if (!store.GetIterFirst (out it))
- return null;
- } else {
- TreeIter? pi = FindNode (parent, loadBranches);
- if (pi == null)
- return null;
- if (loadBranches)
- EnsureFilled (pi.Value);
- if (!store.IterChildren (out it, pi.Value))
- return null;
- }
-
- do {
- Wrapper.Widget cw = (Wrapper.Widget) store.GetValue (it, ColWrapper);
- if (cw == w)
- return it;
- } while (store.IterNext (ref it));
-
- return null;
- }
-
- void NotifySelectionChanged (Stetic.Wrapper.Widget w)
- {
- if (frontend == null)
- return;
- if (w != null)
- frontend.NotifySelectionChanged (Component.GetSafeReference (w), w.Wrapped.Name, w.ClassDescriptor.Name);
- else
- frontend.NotifySelectionChanged (null, null, null);
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton evt)
- {
- if (evt.Button == 3 && evt.Type == Gdk.EventType.ButtonPress)
- return OnPopupMenu ();
- return base.OnButtonPressEvent (evt);
- }
-
- protected override bool OnPopupMenu ()
- {
- Stetic.Wrapper.Widget selection = SelectedWrapper;
-
- if (selection != null) {
- Menu m = new ContextMenu (selection);
- if (selection.IsTopLevel) {
- // Allow deleting top levels from the project view
- ImageMenuItem item = new ImageMenuItem (Gtk.Stock.Delete, null);
- item.Activated += delegate (object obj, EventArgs args) {
- selection.Delete ();
- };
- item.Show ();
- m.Add (item);
- }
- m.Popup ();
- return true;
- } else
- return base.OnPopupMenu ();
- }
-
- protected override void OnRowActivated (TreePath path, TreeViewColumn col)
- {
- base.OnRowActivated (path, col);
- Stetic.Wrapper.Widget w = SelectedWrapper;
- if (w != null) {
- if (frontend != null)
- frontend.NotifyWidgetActivated (Component.GetSafeReference (w), w.Wrapped.Name, w.ClassDescriptor.Name);
- if (WidgetActivated != null)
- WidgetActivated (this, new Wrapper.WidgetEventArgs (w));
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyEditor.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyEditor.cs
deleted file mode 100644
index 27656da718..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyEditor.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using Gtk;
-using System;
-using System.Collections;
-using System.Reflection;
-
-namespace Stetic {
-
- class PropertyEditor : VBox
- {
- IPropertyEditor propEditor;
- EditSession session;
-
- public PropertyEditor (PropertyDescriptor prop) : base (false, 0)
- {
- propEditor = CreateEditor (prop);
- Add ((Gtk.Widget) propEditor);
- }
-
- public void AttachObject (object ob)
- {
- if (session != null)
- session.AttachObject (ob);
- }
-
- public IPropertyEditor CreateEditor (PropertyDescriptor prop)
- {
- PropertyEditorCell cell = PropertyEditorCell.GetPropertyCell (prop);
- cell.Initialize (this, prop, null);
-
- session = cell.StartEditing (new Gdk.Rectangle (), StateType.Normal);
- if (session == null)
- return new DummyEditor ();
-
- Gtk.Widget w = (Gtk.Widget) session.Editor as Gtk.Widget;
- w.ShowAll ();
- return session.Editor;
- }
-
- public void Update ()
- {
- if (session != null)
- session.UpdateEditor ();
- }
- }
-
- class DummyEditor: Gtk.Label, IPropertyEditor
- {
- public void Initialize (PropertyDescriptor prop)
- {
- Text = "(" + prop.PropertyType.Name + ")";
- }
-
- public void AttachObject (object obj)
- {
- }
-
- public object Value {
- get { return null; }
- set { }
- }
-
- public event EventHandler ValueChanged { add {} remove {} }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyGrid.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyGrid.cs
deleted file mode 100644
index fe8ca717bd..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyGrid.cs
+++ /dev/null
@@ -1,275 +0,0 @@
-using Gtk;
-using GLib;
-using System;
-using System.Collections;
-using System.Reflection;
-
-namespace Stetic {
-
- internal class PropertyGrid : Gtk.VBox {
-
- Hashtable cachedGroups = new Hashtable ();
-
- Stetic.Wrapper.Widget selection;
- Stetic.Wrapper.Widget newSelection;
- Stetic.Wrapper.Container.ContainerChild packingSelection;
-
- PropertyGridHeader header;
- Gtk.Widget noSelection;
-
- ProjectBackend project;
-
- public PropertyGrid ()
- {
- header = new PropertyGridHeader ();
- header.Show ();
- PackStart (header, false, false, 0);
-
- Label lab = new Label ();
- lab.Markup = "<i>No selection</i>";
- PackStart (lab, false, false, 0);
- noSelection = lab;
-
- Stetic.Registry.RegistryChanging += new EventHandler (OnRegistryChanging);
- }
-
- public PropertyGrid (ProjectBackend project): this ()
- {
- this.ProjectBackend = project;
- }
-
- public override void Dispose ()
- {
- base.Dispose ();
- }
-
- void OnRegistryChanging (object o, EventArgs args)
- {
- cachedGroups.Clear ();
- Clear ();
- foreach (Gtk.Widget w in Children)
- if (! (w is PropertyGridHeader))
- Remove (w);
- }
-
- public ProjectBackend ProjectBackend {
- get { return project; }
- set {
- if (project != null)
- project.SelectionChanged -= Selected;
-
- project = value;
- project.SelectionChanged += Selected;
- Selected (null, null);
- }
- }
-
- void Clear ()
- {
- if (selection != null) {
- selection.Notify -= Notified;
- selection = null;
- }
- foreach (Gtk.Widget w in Children)
- w.Hide ();
- }
-
- void Notified (object wrapper, string propertyName)
- {
- foreach (object ob in Children) {
- PropertyGridGroup grid = ob as PropertyGridGroup;
- if (grid != null)
- grid.Notified (propertyName);
- }
- }
-
- void Selected (object s, Wrapper.WidgetEventArgs args)
- {
- newSelection = args != null ? args.WidgetWrapper : null;
- GLib.Timeout.Add (50, new GLib.TimeoutHandler (SelectedHandler));
- }
-
- bool SelectedHandler ()
- {
- ClassDescriptor klass;
-
- Clear ();
-
- selection = newSelection;
-
- if (selection == null || selection.Wrapped is ErrorWidget) {
- noSelection.Show ();
- return false;
- }
-
- header.Show ();
-
- selection.Notify += Notified;
-
- klass = selection.ClassDescriptor;
-
- header.AttachObject (selection.Wrapped);
- AppendItemGroups (klass, selection.Wrapped);
-
- packingSelection = Stetic.Wrapper.Container.ChildWrapper (selection);
- if (packingSelection != null) {
- klass = packingSelection.ClassDescriptor;
- if (klass.ItemGroups.Count > 0) {
- AppendItemGroups (klass, packingSelection.Wrapped);
- packingSelection.Notify += Notified;
- }
- }
- return false;
- }
-
- void AppendItemGroups (ClassDescriptor klass, object obj)
- {
- int n = 1;
- foreach (ItemGroup igroup in klass.ItemGroups) {
- PropertyGridGroup grid = (PropertyGridGroup) cachedGroups [igroup];
- if (grid == null) {
- grid = new PropertyGridGroup ();
- grid.AddGroup (igroup);
- cachedGroups [igroup] = grid;
- PackStart (grid, false, false, 0);
- }
- ReorderChild (grid, n++);
- grid.ShowAll ();
- grid.AttachObject (obj);
- }
- }
- }
-
- class PropertyGridGroup: Stetic.Grid
- {
- Hashtable editors;
- Hashtable sensitives, invisibles;
- object obj;
-
- public PropertyGridGroup ()
- {
- editors = new Hashtable ();
- sensitives = new Hashtable ();
- invisibles = new Hashtable ();
- }
-
- public void AddGroup (ItemGroup igroup)
- {
- AppendGroup (igroup.Label, true);
- foreach (ItemDescriptor item in igroup) {
- if (item.IsInternal)
- continue;
- if (item is PropertyDescriptor)
- AppendProperty ((PropertyDescriptor)item);
- else if (item is CommandDescriptor)
- AppendCommand ((CommandDescriptor)item);
- }
- }
-
- public virtual void AttachObject (object ob)
- {
- this.obj = ob;
-
- foreach (object ed in editors.Values) {
- PropertyEditor pe = ed as PropertyEditor;
- if (pe != null)
- pe.AttachObject (ob);
- }
- UpdateSensitivity ();
- }
-
- protected void AppendProperty (PropertyDescriptor prop)
- {
- PropertyEditor rep = new PropertyEditor (prop);
-
- // FIXME: Make sure all notify events are based on prop names, not propspec
- editors[prop.Name] = rep;
-
- AppendPair (prop.Label, rep, prop.Description);
- rep.ShowAll ();
-
- if (prop.HasDependencies)
- sensitives[prop] = prop;
- if (prop.HasVisibility)
- invisibles[prop] = prop;
- }
-
- void AppendCommand (CommandDescriptor cmd)
- {
- Gtk.Button button = new Gtk.Button (cmd.Label);
- button.Clicked += delegate (object o, EventArgs args) {
- cmd.Run (this.obj);
- };
- button.Show ();
- Append (button, cmd.Description);
-
- if (cmd.HasDependencies) {
- editors[cmd.Name] = button;
- sensitives[cmd] = cmd;
- }
- if (cmd.HasVisibility) {
- editors[cmd.Name] = button;
- invisibles[cmd] = cmd;
- }
- }
-
- void UpdateSensitivity ()
- {
- foreach (ItemDescriptor item in sensitives.Keys) {
- Widget w = editors[item.Name] as Widget;
- if (w != null) {
- object ob = sensitives.Contains (item) ? obj : null;
- w.Sensitive = item.EnabledFor (ob);
- }
- }
- foreach (ItemDescriptor item in invisibles.Keys) {
- Widget w = editors[item.Name] as Widget;
- if (w != null) {
- object ob = invisibles.Contains (item) ? obj : null;
- if (!item.VisibleFor (ob))
- w.Hide ();
- else
- w.Show ();
- }
- }
- }
-
- public void Notified (string propertyName)
- {
- PropertyEditor ed = editors [propertyName] as PropertyEditor;
- if (ed != null)
- ed.Update ();
- UpdateSensitivity ();
- }
- }
-
- class PropertyGridHeader: PropertyGridGroup
- {
- PropertyDescriptor name;
- Gtk.Image image;
- Gtk.Label label;
-
- public PropertyGridHeader ()
- {
- name = (PropertyDescriptor)Registry.LookupClassByName ("Gtk.Widget") ["Name"];
- AppendProperty (name);
-
- Gtk.HBox box = new Gtk.HBox (false, 6);
- image = new Gtk.Image ();
- box.PackStart (image, false, false, 0);
- label = new Gtk.Label ();
- box.PackStart (label, false, false, 0);
- box.ShowAll ();
- AppendPair ("Widget Class", box, null);
- }
-
- public override void AttachObject (object ob)
- {
- base.AttachObject (ob);
- Gtk.Widget w = (Gtk.Widget) ob;
- ObjectWrapper wrapper = ObjectWrapper.Lookup (w);
- image.Pixbuf = wrapper.ClassDescriptor.Icon;
- label.Text = wrapper.WrappedTypeName;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyTree.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyTree.cs
deleted file mode 100644
index 231db4d780..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/PropertyTree.cs
+++ /dev/null
@@ -1,567 +0,0 @@
-
-using System;
-using System.Collections;
-using Gtk;
-using Gdk;
-using Mono.Unix;
-
-namespace Stetic
-{
- public class PropertyTree: Gtk.ScrolledWindow
- {
- Gtk.TreeStore store;
- InternalTree tree;
- TreeViewColumn editorColumn;
- Hashtable propertyRows;
- Hashtable sensitives, invisibles;
- ArrayList expandStatus = new ArrayList ();
-
- public PropertyTree ()
- {
- propertyRows = new Hashtable ();
- sensitives = new Hashtable ();
- invisibles = new Hashtable ();
-
- store = new TreeStore (typeof (string), typeof(PropertyDescriptor), typeof(bool), typeof(InstanceData));
-
- tree = new InternalTree (this, store);
-
- CellRendererText crt;
-
- TreeViewColumn col;
-
- col = new TreeViewColumn ();
- col.Title = Catalog.GetString ("Property");
- crt = new CellRendererPropertyGroup (tree);
- col.PackStart (crt, true);
- col.SetCellDataFunc (crt, new TreeCellDataFunc (GroupData));
- col.Resizable = true;
- col.Expand = false;
- col.Sizing = TreeViewColumnSizing.Fixed;
- col.FixedWidth = 150;
- tree.AppendColumn (col);
-
- editorColumn = new TreeViewColumn ();
- editorColumn.Title = Catalog.GetString ("Value");
-
- CellRendererProperty crp = new CellRendererProperty (tree);
-
- editorColumn.PackStart (crp, true);
- editorColumn.SetCellDataFunc (crp, new TreeCellDataFunc (PropertyData));
- editorColumn.Sizing = TreeViewColumnSizing.Fixed;
- editorColumn.Resizable = false;
- editorColumn.Expand = true;
- tree.AppendColumn (editorColumn);
-
- tree.HeadersVisible = false;
- this.ShadowType = Gtk.ShadowType.In;
- this.HscrollbarPolicy = Gtk.PolicyType.Never;
-
- Add (tree);
- ShowAll ();
-
- tree.Selection.Changed += OnSelectionChanged;
- }
-
- public void AddProperties (ItemGroupCollection itemGroups, object instance, string targetGtkVersion)
- {
- foreach (ItemGroup igroup in itemGroups)
- AddGroup (igroup, instance, targetGtkVersion);
- }
-
- public void SaveStatus ()
- {
- expandStatus.Clear ();
-
- TreeIter iter;
- if (!tree.Model.GetIterFirst (out iter))
- return;
-
- do {
- if (tree.GetRowExpanded (tree.Model.GetPath (iter))) {
- expandStatus.Add (tree.Model.GetValue (iter, 0));
- }
- } while (tree.Model.IterNext (ref iter));
- }
-
- public void RestoreStatus ()
- {
- TreeIter iter;
- if (!tree.Model.GetIterFirst (out iter))
- return;
-
- // If the tree only has one group, show it always expanded
- TreeIter iter2 = iter;
- if (!tree.Model.IterNext (ref iter2)) {
- tree.ExpandRow (tree.Model.GetPath (iter), true);
- return;
- }
-
- do {
- object grp = tree.Model.GetValue (iter, 0);
- if (expandStatus.Contains (grp))
- tree.ExpandRow (tree.Model.GetPath (iter), true);
- } while (tree.Model.IterNext (ref iter));
- }
-
- public virtual void Clear ()
- {
- store.Clear ();
- propertyRows.Clear ();
- sensitives.Clear ();
- invisibles.Clear ();
- }
-
- public virtual void Update ()
- {
- // Just repaint the cells
- QueueDraw ();
- }
-
- public void AddGroup (ItemGroup igroup, object instance, string targetGtkVersion)
- {
- ArrayList props = new ArrayList ();
- foreach (ItemDescriptor item in igroup) {
- if (item.IsInternal)
- continue;
- if (item is PropertyDescriptor && item.SupportsGtkVersion (targetGtkVersion))
- props.Add (item);
- }
-
- if (props.Count == 0)
- return;
-
- InstanceData idata = new InstanceData (instance);
- TreeIter iter = store.AppendValues (igroup.Label, null, true, idata);
- foreach (PropertyDescriptor item in props)
- AppendProperty (iter, (PropertyDescriptor)item, idata);
- }
-
- protected void AppendProperty (PropertyDescriptor prop, object instance)
- {
- AppendProperty (TreeIter.Zero, prop, new InstanceData (instance));
- }
-
- protected void AppendProperty (TreeIter piter, PropertyDescriptor prop, object instance)
- {
- AppendProperty (piter, prop, new InstanceData (instance));
- }
-
- void AppendProperty (TreeIter piter, PropertyDescriptor prop, InstanceData idata)
- {
- TreeIter iter;
- if (piter.Equals (TreeIter.Zero))
- iter = store.AppendValues (prop.Label, prop, false, idata);
- else
- iter = store.AppendValues (piter, prop.Label, prop, false, idata);
- if (prop.HasDependencies)
- sensitives[prop] = prop;
- if (prop.HasVisibility)
- invisibles[prop] = prop;
- propertyRows [prop] = store.GetStringFromIter (iter);
- }
-
- protected virtual void OnObjectChanged ()
- {
- }
-
- void OnSelectionChanged (object s, EventArgs a)
- {
- TreePath[] rows = tree.Selection.GetSelectedRows ();
- if (!tree.dragging && rows != null && rows.Length > 0) {
- tree.SetCursor (rows[0], editorColumn, true);
- }
- }
-
- internal void NotifyChanged ()
- {
- OnObjectChanged ();
- }
-
- void PropertyData (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
- {
- CellRendererProperty rc = (CellRendererProperty) cell;
- bool group = (bool) model.GetValue (iter, 2);
- if (group) {
- rc.SetData (null, null, null);
- } else {
- PropertyDescriptor prop = (PropertyDescriptor) model.GetValue (iter, 1);
- PropertyEditorCell propCell = PropertyEditorCell.GetPropertyCell (prop);
- InstanceData idata = (InstanceData) model.GetValue (iter, 3);
- propCell.Initialize (tree, prop, idata.Instance);
- rc.SetData (idata.Instance, prop, propCell);
- }
- }
-
- void GroupData (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
- {
- CellRendererPropertyGroup rc = (CellRendererPropertyGroup) cell;
- rc.IsGroup = (bool) model.GetValue (iter, 2);
- rc.Text = (string) model.GetValue (iter, 0);
-
- PropertyDescriptor prop = (PropertyDescriptor) model.GetValue (iter, 1);
- if (prop != null) {
- InstanceData idata = (InstanceData) model.GetValue (iter, 3);
- rc.SensitiveProperty = prop.EnabledFor (idata.Instance) && prop.VisibleFor (idata.Instance);
- } else
- rc.SensitiveProperty = true;
- }
- }
-
- class InternalTree: TreeView
- {
- internal ArrayList Groups = new ArrayList ();
- Pango.Layout layout;
- bool editing;
- PropertyTree tree;
- internal bool dragging;
- int dragPos;
- Gdk.Cursor resizeCursor = new Gdk.Cursor (CursorType.SbHDoubleArrow);
-
- public InternalTree (PropertyTree tree, TreeModel model): base (model)
- {
- this.tree = tree;
- layout = new Pango.Layout (this.PangoContext);
- layout.Wrap = Pango.WrapMode.Char;
- Pango.FontDescription des = this.Style.FontDescription.Copy();
- des.Size = 10 * (int) Pango.Scale.PangoScale;
- layout.FontDescription = des;
- }
-
- public bool Editing {
- get { return editing; }
- set { editing = value; Update (); tree.NotifyChanged (); }
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose e)
- {
- Groups.Clear ();
-
- bool res = base.OnExposeEvent (e);
-
- foreach (TreeGroup grp in Groups) {
- layout.SetMarkup ("<b>" + GLib.Markup.EscapeText (grp.Group) + "</b>");
- e.Window.DrawLayout (this.Style.TextGC (grp.State), grp.X, grp.Y, layout);
- }
-
- return res;
- }
-
- protected override bool OnMotionNotifyEvent (EventMotion evnt)
- {
- if (dragging) {
- int nw = (int)(evnt.X) + dragPos;
- if (nw <= 40) nw = 40;
- GLib.Idle.Add (delegate {
- Columns[0].FixedWidth = nw;
- return false;
- });
- } else {
- int w = Columns[0].Width;
- if (Math.Abs (w - evnt.X) < 5)
- this.GdkWindow.Cursor = resizeCursor;
- else
- this.GdkWindow.Cursor = null;
- }
- return base.OnMotionNotifyEvent (evnt);
- }
-
- protected override bool OnButtonPressEvent (EventButton evnt)
- {
- int w = Columns[0].Width;
- if (Math.Abs (w - evnt.X) < 5) {
- TreePath[] rows = Selection.GetSelectedRows ();
- if (rows != null && rows.Length > 0)
- SetCursor (rows[0], Columns[0], false);
- dragging = true;
- dragPos = w - (int) evnt.X;
- this.GdkWindow.Cursor = resizeCursor;
- }
- return base.OnButtonPressEvent (evnt);
- }
-
- protected override bool OnButtonReleaseEvent (EventButton evnt)
- {
- if (dragging) {
- this.GdkWindow.Cursor = null;
- dragging = false;
- }
- return base.OnButtonReleaseEvent (evnt);
- }
-
- public virtual void Update ()
- {
- }
-
- protected override void OnDestroyed ()
- {
- base.OnDestroyed ();
- if (resizeCursor != null) {
- resizeCursor.Dispose ();
- resizeCursor = null;
- }
- }
-
- }
-
- class TreeGroup
- {
- public string Group;
- public int X;
- public int Y;
- public StateType State;
- }
-
- class CellRendererProperty: CellRenderer
- {
- PropertyDescriptor property;
- object instance;
- int rowHeight;
- PropertyEditorCell editorCell;
- bool sensitive;
- bool visible;
- TreeView tree;
-
- public CellRendererProperty (TreeView tree)
- {
- this.tree = tree;
- Xalign = 0;
- Xpad = 3;
-
- Mode |= Gtk.CellRendererMode.Editable;
- Entry dummyEntry = new Gtk.Entry ();
- dummyEntry.HasFrame = false;
- rowHeight = dummyEntry.SizeRequest ().Height;
- }
-
- public void SetData (object instance, PropertyDescriptor property, PropertyEditorCell editor)
- {
- this.instance = instance;
- this.property = property;
- if (property == null)
- this.CellBackgroundGdk = tree.Style.MidColors [(int)Gtk.StateType.Normal];
- else
- this.CellBackground = null;
-
- visible = property != null ? property.VisibleFor (instance): true;
- sensitive = property != null ? property.EnabledFor (instance) && property.VisibleFor (instance): true;
- editorCell = editor;
- }
-
- public override void GetSize (Widget widget, ref Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
- {
- if (editorCell != null)
- editorCell.GetSize ((int)(cell_area.Width - this.Xpad * 2), out width, out height);
- else {
- width = height = 0;
- }
-
- width += (int) this.Xpad * 2;
- height += (int) this.Ypad * 2;
-
- x_offset = 0;
- y_offset = 0;
-
- if (height < rowHeight)
- height = rowHeight;
- }
-
- protected override void Render (Drawable window, Widget widget, Rectangle background_area, Rectangle cell_area, Rectangle expose_area, CellRendererState flags)
- {
- if (instance == null || !visible)
- return;
- int width = 0, height = 0;
- int iwidth = cell_area.Width - (int) this.Xpad * 2;
-
- if (editorCell != null)
- editorCell.GetSize ((int)(cell_area.Width - this.Xpad * 2), out width, out height);
-
- Rectangle bounds = new Rectangle ();
- bounds.Width = width > iwidth ? iwidth : width;
- bounds.Height = height;
- bounds.X = (int) (cell_area.X + this.Xpad);
- bounds.Y = cell_area.Y + (cell_area.Height - height) / 2;
-
- StateType state = GetState (flags);
-
- if (editorCell != null)
- editorCell.Render (window, bounds, state);
- }
-
- public override CellEditable StartEditing (Gdk.Event ev, Widget widget, string path, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags)
- {
- if (property == null || editorCell == null || !sensitive)
- return null;
-
- StateType state = GetState (flags);
- EditSession session = editorCell.StartEditing (cell_area, state);
- if (session == null)
- return null;
- Gtk.Widget propEditor = (Gtk.Widget) session.Editor;
- propEditor.Show ();
- HackEntry e = new HackEntry (propEditor, session);
- e.Show ();
- return e;
- }
-
- StateType GetState (CellRendererState flags)
- {
- if (!sensitive)
- return StateType.Insensitive;
- else if ((flags & CellRendererState.Selected) != 0)
- return StateType.Selected;
- else
- return StateType.Normal;
- }
- }
-
- class CellRendererPropertyGroup: CellRendererText
- {
- TreeView tree;
- Pango.Layout layout;
- bool isGroup;
- bool sensitive;
-
- public bool IsGroup {
- get { return isGroup; }
- set {
- isGroup = value;
- if (value)
- this.CellBackgroundGdk = tree.Style.MidColors [(int)Gtk.StateType.Normal];
- else
- this.CellBackground = null;
- }
- }
-
- public bool SensitiveProperty {
- get { return sensitive; }
- set { sensitive = value; }
- }
-
- public CellRendererPropertyGroup (TreeView tree)
- {
- this.tree = tree;
- layout = new Pango.Layout (tree.PangoContext);
- layout.Wrap = Pango.WrapMode.Char;
-
- Pango.FontDescription des = tree.Style.FontDescription.Copy();
- des.Size = 10 * (int) Pango.Scale.PangoScale;
- layout.FontDescription = des;
- }
-
- protected void GetCellSize (Widget widget, int availableWidth, out int width, out int height)
- {
- layout.SetMarkup (Text);
- layout.Width = -1;
- layout.GetPixelSize (out width, out height);
- }
-
- public override void GetSize (Widget widget, ref Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
- {
- GetCellSize (widget, (int)(cell_area.Width - this.Xpad * 2), out width, out height);
- width += (int) this.Xpad * 2;
- height += (int) this.Ypad * 2;
-
- x_offset = y_offset = 0;
-
- if (IsGroup)
- width = 0;
- }
-
- protected override void Render (Drawable window, Widget widget, Rectangle background_area, Rectangle cell_area, Rectangle expose_area, CellRendererState flags)
- {
- int width, height;
- GetCellSize (widget, (int)(cell_area.Width - this.Xpad * 2), out width, out height);
-
- int x = (int) (cell_area.X + this.Xpad);
- int y = cell_area.Y + (cell_area.Height - height) / 2;
-
- StateType state;
- if (!sensitive)
- state = StateType.Insensitive;
- else if ((flags & CellRendererState.Selected) != 0)
- state = StateType.Selected;
- else
- state = StateType.Normal;
-
- if (IsGroup) {
- TreeGroup grp = new TreeGroup ();
- grp.X = x;
- grp.Y = y;
- grp.Group = Text;
- grp.State = state;
- InternalTree tree = (InternalTree) widget;
- tree.Groups.Add (grp);
- } else {
- window.DrawLayout (widget.Style.TextGC (state), x, y, layout);
- int bx = background_area.X + background_area.Width - 1;
- Gdk.GC gc = new Gdk.GC (window);
- gc.RgbFgColor = tree.Style.MidColors [(int)Gtk.StateType.Normal];
- window.DrawLine (gc, bx, background_area.Y, bx, background_area.Y + background_area.Height);
- }
- }
- }
-
- class HackEntry: Entry
- {
- EventBox box;
- EditSession session;
-
- public HackEntry (Gtk.Widget child, EditSession session)
- {
- this.session = session;
- box = new EventBox ();
- box.ButtonPressEvent += new ButtonPressEventHandler (OnClickBox);
- box.ModifyBg (StateType.Normal, Style.White);
- box.Add (child);
- }
-
- [GLib.ConnectBefore]
- void OnClickBox (object s, ButtonPressEventArgs args)
- {
- // Avoid forwarding the button press event to the
- // tree, since it would hide the cell editor.
- args.RetVal = true;
- }
-
- protected override void OnParentSet (Gtk.Widget parent)
- {
- base.OnParentSet (parent);
-
- if (Parent != null) {
- if (this.ParentWindow != null)
- box.ParentWindow = this.ParentWindow;
- box.Parent = Parent;
- box.Show ();
- ((InternalTree)Parent).Editing = true;
- }
- else {
- session.Dispose ();
- ((InternalTree)parent).Editing = false;
- box.Unparent ();
- }
- }
-
- protected override void OnShown ()
- {
- // Do nothing.
- }
-
- protected override void OnSizeAllocated (Gdk.Rectangle allocation)
- {
- base.OnSizeAllocated (allocation);
- box.SizeRequest ();
- box.Allocation = allocation;
- }
- }
-
- class InstanceData
- {
- public InstanceData (object instance)
- {
- Instance = instance;
- }
-
- public object Instance;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Shadow.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Shadow.cs
deleted file mode 100644
index 45d2a62357..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Shadow.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-/* Shadow code from anders */
-
-using System;
-using Gdk;
-
-class ConvFilter
-{
- public int size;
- public double[] data;
-}
-
-class Shadow
-{
- public const int BLUR_RADIUS = 5;
- public const int SHADOW_OFFSET = (BLUR_RADIUS * 4 / 5);
- public const double SHADOW_OPACITY = 0.5;
-
- static ConvFilter filter;
-
- static double Gaussian (double x, double y, double r)
- {
- return ((1 / (2 * System.Math.PI * r)) *
- System.Math.Exp ((- (x * x + y * y)) / (2 * r * r)));
- }
-
- static ConvFilter CreateBlurFilter (int radius)
- {
- ConvFilter filter;
- int x, y;
- double sum;
-
- filter = new ConvFilter ();
- filter.size = radius * 2 + 1;
- filter.data = new double [filter.size * filter.size];
-
- sum = 0.0;
-
- for (y = 0 ; y < filter.size; y++) {
- for (x = 0 ; x < filter.size; x++) {
- sum += filter.data [y * filter.size + x] = Gaussian (x - (filter.size >> 1),
- y - (filter.size >> 1),
- radius);
- }
- }
-
- for (y = 0; y < filter.size; y++) {
- for (x = 0; x < filter.size; x++)
- filter.data [y * filter.size + x] /= sum;
- }
- return filter;
- }
-
- unsafe static Pixbuf CreateEffect (int src_width, int src_height, ConvFilter filter, int radius, int offset, double opacity)
- {
- Pixbuf dest;
- int x, y, i, j;
- int src_x, src_y;
- int suma;
- int dest_width, dest_height;
- int dest_rowstride;
- byte* dest_pixels;
-
- dest_width = src_width + 2 * radius + offset;
- dest_height = src_height + 2 * radius + offset;
-
- dest = new Pixbuf (Colorspace.Rgb, true, 8, dest_width, dest_height);
- dest.Fill (0);
-
- dest_pixels = (byte*) dest.Pixels;
-
- dest_rowstride = dest.Rowstride;
-
- for (y = 0; y < dest_height; y++)
- {
- for (x = 0; x < dest_width; x++)
- {
- suma = 0;
-
- src_x = x - radius;
- src_y = y - radius;
-
- /* We don't need to compute effect here, since this pixel will be
- * discarded when compositing */
- if (src_x >= 0 && src_x < src_width && src_y >= 0 && src_y < src_height)
- continue;
-
- for (i = 0; i < filter.size; i++)
- {
- for (j = 0; j < filter.size; j++)
- {
- src_y = -(radius + offset) + y - (filter.size >> 1) + i;
- src_x = -(radius + offset) + x - (filter.size >> 1) + j;
-
- if (src_y < 0 || src_y >= src_height ||
- src_x < 0 || src_x >= src_width)
- continue;
-
- suma += (int) (((byte)0xFF) * filter.data [i * filter.size + j]);
- }
- }
-
- byte r = (byte) (suma * opacity);
- dest_pixels [y * dest_rowstride + x * 4 + 3] = r;
- }
- }
- return dest;
- }
-
- public static Pixbuf AddShadow (int width, int height)
- {
- if (filter == null)
- filter = CreateBlurFilter (BLUR_RADIUS);
-
- return CreateEffect (width, height, filter, BLUR_RADIUS, SHADOW_OFFSET, SHADOW_OPACITY);
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/SignalsEditor.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/SignalsEditor.cs
deleted file mode 100644
index d5aa7dd7c7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/SignalsEditor.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public class SignalsEditor: PluggableWidget
- {
- SignalsEditorFrontend frontend;
- SignalsEditorEditSession session;
-
- public event EventHandler SignalActivated;
-
- internal SignalsEditor (Application app): base (app)
- {
- frontend = new SignalsEditorFrontend (this);
- }
-
- public Signal SelectedSignal {
- get {
- if (session != null)
- return session.SelectedSignal;
- else
- return null;
- }
- }
-
- protected override void OnCreatePlug (uint socketId)
- {
- session = app.Backend.CreateSignalsWidgetPlug (frontend, socketId);
- }
-
- protected override void OnDestroyPlug (uint socketId)
- {
- app.Backend.DestroySignalsWidgetPlug ();
- }
-
- protected override Gtk.Widget OnCreateWidget ()
- {
- session = app.Backend.GetSignalsWidget (frontend);
- return session.Editor;
- }
-
- bool disposed = false;
-
- public override void Dispose ()
- {
- if (disposed)
- return;
- disposed = true;
-
- if (session != null)
- session.Dispose ();
- frontend.disposed = true;
- System.Runtime.Remoting.RemotingServices.Disconnect (frontend);
- base.Dispose ();
- }
-
- internal void NotifySignalActivated ()
- {
- if (SignalActivated != null)
- SignalActivated (this, EventArgs.Empty);
- }
- }
-
- internal class SignalsEditorFrontend: MarshalByRefObject
- {
- SignalsEditor editor;
- internal bool disposed;
-
- public SignalsEditorFrontend (SignalsEditor editor)
- {
- this.editor = editor;
- }
-
- public void NotifySignalActivated ()
- {
- Gtk.Application.Invoke (
- delegate {
- if (!disposed) editor.NotifySignalActivated ();
- }
- );
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/SignalsEditorBackend.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/SignalsEditorBackend.cs
deleted file mode 100644
index d675804793..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/SignalsEditorBackend.cs
+++ /dev/null
@@ -1,481 +0,0 @@
-using System;
-using System.Text;
-using System.Collections;
-using Stetic.Wrapper;
-using Mono.Unix;
-
-namespace Stetic
-{
- internal class SignalsEditorBackend: Gtk.ScrolledWindow, IObjectViewer
- {
- Gtk.TreeView tree;
- Gtk.TreeStore store;
- SignalsEditorFrontend frontend;
-
- ProjectBackend project;
- ObjectWrapper selection;
- bool internalChange;
-
- const int ColSignal = 0;
- const int ColHandler = 1;
- const int ColAfter = 2;
- const int ColHasHandler = 3;
- const int ColIsSignal = 4;
- const int ColSignalTextWeight = 5;
-
- public SignalsEditorBackend (SignalsEditorFrontend frontend)
- {
- this.frontend = frontend;
-
- tree = new Gtk.TreeView ();
- store = new Gtk.TreeStore (typeof(string), typeof(string), typeof(bool), typeof(bool), typeof(bool), typeof(int));
- tree.Model = store;
- tree.RowActivated += new Gtk.RowActivatedHandler (OnRowActivated);
-
- Gtk.CellRendererText crtSignal = new Gtk.CellRendererText ();
-
- Gtk.CellRendererText crtHandler = new Gtk.CellRendererText ();
- crtHandler.Editable = true;
- crtHandler.Edited += new Gtk.EditedHandler (OnHandlerEdited);
-
- Gtk.CellRendererToggle crtogAfter = new Gtk.CellRendererToggle ();
- crtogAfter.Activatable = true;
- crtogAfter.Toggled += new Gtk.ToggledHandler (OnAfterToggled);
-
- tree.AppendColumn (Catalog.GetString ("Signal"), crtSignal, "text", ColSignal, "weight", ColSignalTextWeight);
- tree.AppendColumn (Catalog.GetString ("Handler"), crtHandler, "markup", ColHandler, "visible", ColIsSignal);
- tree.AppendColumn (Catalog.GetString ("After"), crtogAfter, "active", ColAfter, "visible", ColHasHandler);
- tree.Columns[0].Resizable = true;
- tree.Columns[1].Resizable = true;
- tree.Columns[2].Resizable = true;
- Add (tree);
- ShowAll ();
- }
-
- public SignalsEditorBackend (SignalsEditorFrontend frontend, ProjectBackend project): this (frontend)
- {
- ProjectBackend = project;
- }
-
- public ProjectBackend ProjectBackend {
- get { return project; }
- set {
- if (project != null) {
- project.SelectionChanged -= OnWidgetSelected;
- project.SignalAdded -= new SignalEventHandler (OnSignalAddedOrRemoved);
- project.SignalRemoved -= new SignalEventHandler (OnSignalAddedOrRemoved);
- project.SignalChanged -= new SignalChangedEventHandler (OnSignalChanged);
- project.ProjectReloaded -= new EventHandler (OnProjectReloaded);
- }
-
- project = value;
- if (project != null) {
- TargetObject = project.Selection;
- project.SelectionChanged += OnWidgetSelected;
- project.SignalAdded += new SignalEventHandler (OnSignalAddedOrRemoved);
- project.SignalRemoved += new SignalEventHandler (OnSignalAddedOrRemoved);
- project.SignalChanged += new SignalChangedEventHandler (OnSignalChanged);
- project.ProjectReloaded += new EventHandler (OnProjectReloaded);
- } else if (selection != null) {
- selection = null;
- RefreshTree ();
- }
- }
- }
-
- void OnProjectReloaded (object s, EventArgs a)
- {
- OnWidgetSelected (null, null);
- }
-
- public Signal SelectedSignal {
- get {
- Gtk.TreeModel foo;
- Gtk.TreeIter iter;
- if (!tree.Selection.GetSelected (out foo, out iter))
- return null;
- return GetSignal (iter);
- }
- }
-
- public object TargetObject {
- get {
- return selection != null ? selection.Wrapped : null;
- }
- set {
- if (project != null) {
- ObjectWrapper wrapper = ObjectWrapper.Lookup (value);
- if (wrapper == selection)
- return;
- selection = wrapper;
- RefreshTree ();
- }
- }
- }
-
- void OnWidgetSelected (object s, Wrapper.WidgetEventArgs args)
- {
- ObjectWrapper wrapper = args != null ? args.WidgetWrapper : null;
- if (wrapper == selection)
- return;
- selection = wrapper;
- RefreshTree ();
- }
-
- void OnSignalAddedOrRemoved (object sender, SignalEventArgs args)
- {
- if (!internalChange && args.Wrapper == selection)
- RefreshTree ();
- }
-
- void OnSignalChanged (object sender, SignalChangedEventArgs args)
- {
- if (!internalChange && args.Wrapper == selection)
- RefreshTree ();
- }
-
- void RefreshTree ()
- {
- ArrayList status = SaveStatus ();
- store.Clear ();
-
- if (selection == null)
- return;
-
- ClassDescriptor klass = selection.ClassDescriptor;
-
- foreach (ItemGroup group in klass.SignalGroups) {
- Gtk.TreeIter iter = store.AppendValues (group.Label, null, false, false, false, (int) Pango.Weight.Normal);
- if (FillGroup (iter, group))
- store.SetValue (iter, ColSignalTextWeight, (int) Pango.Weight.Bold);
- }
- RestoreStatus (status);
- }
-
- bool FillGroup (Gtk.TreeIter groupIter, ItemGroup group)
- {
- bool hasSignals = false;
- foreach (SignalDescriptor sd in group) {
- if (!sd.SupportsGtkVersion (project.TargetGtkVersion))
- continue;
-
- bool foundSignal = false;
- Gtk.TreeIter parent = groupIter;
-
- foreach (Signal signal in selection.Signals) {
- if (signal.SignalDescriptor != sd) continue;
-
- Gtk.TreeIter iter = store.AppendValues (parent, null, signal.Handler, false, true, true, (int) Pango.Weight.Normal);
- if (!foundSignal) {
- parent = iter;
- store.SetValue (iter, ColSignal, sd.Name);
- store.SetValue (iter, ColSignalTextWeight, (int) Pango.Weight.Bold);
- hasSignals = foundSignal = true;
- }
- }
-
- InsertEmptySignalRow (parent, foundSignal ? null : sd.Name);
- }
- return hasSignals;
- }
-
- void SetSignalData (Gtk.TreeIter iter, Signal signal)
- {
- store.SetValue (iter, ColHandler, signal.Handler);
- store.SetValue (iter, ColAfter, false);
- store.SetValue (iter, ColHasHandler, true);
- store.SetValue (iter, ColIsSignal, true);
- }
-
- void InsertEmptySignalRow (Gtk.TreeIter parent, string name)
- {
- store.AppendValues (parent, name, EmptyHandlerMarkup, false, false, true, (int) Pango.Weight.Normal);
- }
-
- void OnRowActivated (object sender, Gtk.RowActivatedArgs args)
- {
- Gtk.TreeIter iter;
- if (!store.GetIter (out iter, args.Path))
- return;
-
- SignalDescriptor sd = GetSignalDescriptor (iter);
- if (sd != null) {
- if (GetSignal (iter) == null)
- AddHandler (iter, GetHandlerName (sd.Name));
- frontend.NotifySignalActivated ();
- }
- }
-
- string GetHandlerName (string signalName)
- {
- Wrapper.Widget selWidget = selection as Wrapper.Widget;
- if (selWidget != null) {
-// if (selWidget.IsTopLevel)
-// return "On" + signalName;
-// else
-// return "On" + GetIdentifier (selWidget.Wrapped.Name) + signalName;
- return string.Format ("{0}_{1}",
- GetIdentifier (selWidget.Wrapped.Name), signalName);
- }
-
- Wrapper.Action action = selection as Wrapper.Action;
- if (action != null) {
- return "On" + GetIdentifier (action.Name) + signalName;
- }
-
- return "On" + signalName;
- }
-
- string GetIdentifier (string name)
- {
- StringBuilder sb = new StringBuilder ();
-
- bool wstart = true;
- foreach (char c in name) {
- if (c == '_' || c == '-' || c == ' ' || !char.IsLetterOrDigit (c)) {
- wstart = true;
- continue;
- }
- if (wstart) {
- sb.Append (char.ToUpper (c));
- wstart = false;
- } else
- sb.Append (c);
- }
- return sb.ToString ();
- }
-
- void OnHandlerEdited (object sender, Gtk.EditedArgs args)
- {
- if (args.NewText == EmptyHandlerText)
- return;
-
- Gtk.TreeIter iter;
- if (!store.GetIterFromString (out iter, args.Path))
- return;
-
- AddHandler (iter, args.NewText);
- }
-
- void AddHandler (Gtk.TreeIter iter, string name)
- {
- internalChange = true;
-
- Gtk.TreeIter piter = iter;
- while (store.IterDepth (piter) != 0)
- store.IterParent (out piter, piter);
-
- Signal signal = GetSignal (iter);
- if (signal == null) {
- if (name != "") {
- SignalDescriptor sd = GetSignalDescriptor (iter);
- signal = new Signal (sd);
- signal.Handler = name;
- selection.Signals.Add (signal);
- SetSignalData (iter, signal);
- store.SetValue (iter, ColSignalTextWeight, (int) Pango.Weight.Bold);
- if (store.IterDepth (iter) != 1)
- store.IterParent (out iter, iter);
- InsertEmptySignalRow (iter, null);
- }
- } else {
- if (name != "") {
- signal.Handler = name;
- store.SetValue (iter, ColHandler, signal.Handler);
- } else {
- selection.Signals.Remove (signal);
- if (store.IterDepth (iter) == 1) {
- if (store.IterNChildren (iter) == 1) {
- Gtk.TreeIter parent;
- store.IterParent (out parent, iter);
- store.Remove (ref iter);
- InsertEmptySignalRow (parent, signal.SignalDescriptor.Name);
- } else {
- Gtk.TreeIter citer;
- store.IterChildren (out citer, iter);
- Signal csignal = GetSignal (citer);
- store.Remove (ref citer);
- SetSignalData (iter, csignal);
- if (store.IterNChildren (iter) == 1)
- tree.CollapseRow (store.GetPath (iter));
- }
- } else
- store.Remove (ref iter);
- }
- }
- UpdateGroupStatus (piter);
- internalChange = false;
- }
-
- void OnAfterToggled (object o, Gtk.ToggledArgs args)
- {
- Gtk.TreeIter it;
- if (store.GetIterFromString (out it, args.Path)) {
- Signal signal = GetSignal (it);
- if (signal != null) {
- internalChange = true;
- signal.After = !signal.After;
- internalChange = false;
- store.SetValue (it, ColAfter, signal.After);
- }
- }
- }
-
- void UpdateGroupStatus (Gtk.TreeIter iter)
- {
- Gtk.TreeIter signalIter;
- if (store.IterChildren (out signalIter, iter)) {
- do {
- if (store.IterNChildren (signalIter) > 0) {
- store.SetValue (iter, ColSignalTextWeight, (int) Pango.Weight.Bold);
- return;
- }
- } while (store.IterNext (ref signalIter));
- }
- store.SetValue (iter, ColSignalTextWeight, (int) Pango.Weight.Normal);
- }
-
- Signal GetSignal (Gtk.TreeIter iter)
- {
- if (! (bool) store.GetValue (iter, ColHasHandler))
- return null;
- string handler = (string) store.GetValue (iter, ColHandler);
- foreach (Signal sig in selection.Signals)
- if (sig.Handler == handler)
- return sig;
- return null;
- }
-
- SignalDescriptor GetSignalDescriptor (Gtk.TreeIter iter)
- {
- Gtk.TreeIter group_iter;
- if (! (bool) store.GetValue (iter, ColIsSignal) || !store.IterParent (out group_iter, iter))
- return null;
- string name = (string) store.GetValue (iter, ColSignal);
- string group_name = (string) store.GetValue (group_iter, ColSignal);
-
- foreach (ItemGroup igroup in selection.ClassDescriptor.SignalGroups) {
- if (igroup.Label != group_name)
- continue;
- SignalDescriptor desc = (SignalDescriptor) igroup [name];
- if (desc != null)
- return desc;
- }
-
- return null;
- }
-
- ArrayList SaveStatus ()
- {
- ArrayList list = new ArrayList ();
-
- Gtk.TreeIter it;
- if (!store.GetIterFirst (out it))
- return list;
-
- do {
- SaveStatus (list, "", it);
- } while (store.IterNext (ref it));
-
- return list;
- }
-
- void SaveStatus (ArrayList list, string path, Gtk.TreeIter iter)
- {
- string basePath = path + "/" + store.GetValue (iter, ColSignal);
-
- if (!tree.GetRowExpanded (store.GetPath (iter)))
- return;
-
- list.Add (basePath);
-
- if (store.IterChildren (out iter, iter)) {
- do {
- SaveStatus (list, basePath, iter);
- } while (store.IterNext (ref iter));
- }
- }
-
- void RestoreStatus (ArrayList list)
- {
- foreach (string namePath in list) {
- string[] names = namePath.Split ('/');
-
- Gtk.TreeIter iter = Gtk.TreeIter.Zero;
-
- bool found = true;
- foreach (string name in names) {
- if (name == "") continue;
- if (!FindChildByName (name, ref iter)) {
- found = false;
- break;
- }
- }
-
- if (found)
- tree.ExpandRow (store.GetPath (iter), false);
- }
- }
-
- bool FindChildByName (string name, ref Gtk.TreeIter iter)
- {
- if (iter.Equals (Gtk.TreeIter.Zero)) {
- if (!store.GetIterFirst (out iter))
- return false;
- } else if (!store.IterChildren (out iter, iter))
- return false;
-
- do {
- if (name == (string) store.GetValue (iter, ColSignal))
- return true;
- }
- while (store.IterNext (ref iter));
-
- return false;
- }
-
- string EmptyHandlerMarkup {
- get { return "<i><span foreground=\"grey\">" + EmptyHandlerText + "</span></i>"; }
- }
-
- string EmptyHandlerText {
- get { return Catalog.GetString ("Click here to add a new handler"); }
- }
- }
-
- internal class SignalsEditorEditSession: MarshalByRefObject
- {
- SignalsEditorBackend backend;
-
- public SignalsEditorEditSession (SignalsEditorFrontend frontend)
- {
- backend = new SignalsEditorBackend (frontend);
- }
-
- public SignalsEditorBackend Editor {
- get { return backend; }
- }
-
- public ProjectBackend ProjectBackend {
- get { return backend.ProjectBackend; }
- set { backend.ProjectBackend = value; }
- }
-
- public Signal SelectedSignal {
- get {
- return backend.SelectedSignal;
- }
- }
-
- public void Dispose ()
- {
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/UndoQueue.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/UndoQueue.cs
deleted file mode 100644
index 0ae6a6fc02..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/UndoQueue.cs
+++ /dev/null
@@ -1,282 +0,0 @@
-
-using System;
-using System.Xml;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace Stetic
-{
- public class UndoQueue: MarshalByRefObject
- {
- List<UndoRedoChange> changeList = new List<UndoRedoChange> ();
- int undoListCount = 0;
- static UndoQueue empty = new UndoQueue ();
-
- public void AddChange (UndoRedoChange change)
- {
- if (undoListCount < changeList.Count) {
- // Destroy all undone changes
- changeList.RemoveRange (undoListCount, changeList.Count - undoListCount);
- }
- changeList.Add (change);
- undoListCount = changeList.Count;
- }
-
- public IEnumerable<UndoRedoChange> Changes {
- get { return changeList; }
- }
-
- public static UndoQueue Empty {
- get { return empty; }
- }
-
- public bool CanUndo {
- get { return undoListCount > 0; }
- }
-
- public bool CanRedo {
- get { return undoListCount < changeList.Count; }
- }
-
- public void Undo ()
- {
- if (undoListCount == 0)
- return;
-
- UndoRedoChange change = (UndoRedoChange) changeList [--undoListCount];
- if (change.CheckValid ()) {
- UndoRedoChange res = change.ApplyChange ();
- if (res != null)
- changeList [undoListCount] = res;
- else
- // Undo failed
- changeList.RemoveAt (undoListCount);
- } else {
- changeList.RemoveAt (undoListCount);
- Undo ();
- }
- }
-
- public void Redo ()
- {
- if (undoListCount == changeList.Count)
- return;
-
- UndoRedoChange change = (UndoRedoChange) changeList [undoListCount++];
- if (change.CheckValid ()) {
- UndoRedoChange res = change.ApplyChange ();
- if (res != null)
- changeList [undoListCount - 1] = res;
- else {
- // Redo failed
- undoListCount--;
- changeList.RemoveAt (undoListCount);
- }
- }
- else {
- changeList.RemoveAt (--undoListCount);
- Redo ();
- }
- }
-
- public void Purge ()
- {
- for (int n=0; n<changeList.Count; n++) {
- UndoRedoChange change = (UndoRedoChange) changeList [n];
- if (!change.CheckValid()) {
- changeList.RemoveAt (n);
- if (n < undoListCount)
- undoListCount--;
- }
- }
- }
- }
-
- public abstract class UndoRedoChange: MarshalByRefObject
- {
- public abstract UndoRedoChange ApplyChange ();
-
- public virtual bool CheckValid ()
- {
- return true;
- }
- }
-
-
- class ObjectWrapperUndoRedoChange: UndoRedoChange
- {
- UndoRedoManager manager;
- public string TargetObject;
- public object Diff;
- public ObjectWrapperUndoRedoChange Next;
-
- public ObjectWrapperUndoRedoChange (UndoRedoManager manager, string targetObject, object diff)
- {
- this.manager = manager;
- this.TargetObject = targetObject;
- this.Diff = diff;
- }
-
- public UndoRedoManager Manager {
- get { return manager; }
- set { manager = value; }
- }
-
- public override UndoRedoChange ApplyChange ()
- {
- return manager.ApplyChange (this);
- }
-
- public override bool CheckValid ()
- {
- return manager.CheckValid ();
- }
- }
-
- class UndoRedoManager: IDisposable
- {
- UndoQueue queue;
- ObjectWrapper rootObject;
- bool updating;
- UndoManager undoManager = new UndoManager ();
-
- public UndoRedoManager ()
- {
- undoManager.UndoCheckpoint += OnUndoCheckpoint;
- }
-
- public ObjectWrapper RootObject {
- get { return rootObject; }
- set {
- rootObject = value;
- undoManager.SetRoot (rootObject);
- }
- }
-
- public UndoQueue UndoQueue {
- get { return queue; }
- set { queue = value; }
- }
-
- internal UndoManager UndoManager {
- get { return undoManager; }
- }
-
- void OnUndoCheckpoint (object sender, UndoCheckpointEventArgs args)
- {
- AddChange (args.ModifiedObjects);
- }
-
- void AddChange (ObjectWrapper[] obs)
- {
- if (updating || queue == null)
- return;
-
- ObjectWrapperUndoRedoChange firstChange = null;
- ObjectWrapperUndoRedoChange lastChange = null;
-
-// Console.WriteLine ("** UNDO CHECKPOINT: {0} objects", obs.Length);
-
- foreach (ObjectWrapper ob in obs) {
-
- // Get the diff for going from the new status to the old status
- object diff = GetDiff (ob);
-
- if (diff == null) // No differences
- continue;
-
-// Console.WriteLine ("ADDCHANGE " + ob + " uid:" + ob.UndoId);
-// PrintPatch (diff);
-
- if (ob.UndoId == null || ob.UndoId.Length == 0)
- throw new InvalidOperationException ("Object of type '" + ob.GetType () + "' does not have an undo id.");
-
- ObjectWrapperUndoRedoChange change = new ObjectWrapperUndoRedoChange (this, ob.UndoId, diff);
- if (lastChange == null)
- lastChange = firstChange = change;
- else {
- lastChange.Next = change;
- lastChange = change;
- }
- }
- if (firstChange != null)
- queue.AddChange (firstChange);
- }
-
- protected virtual object GetDiff (ObjectWrapper w)
- {
- return w.GetUndoDiff ();
- }
-
- public UndoRedoChange ApplyChange (ObjectWrapperUndoRedoChange first)
- {
- updating = true;
-
- try {
- ObjectWrapperUndoRedoChange change = first;
- ObjectWrapperUndoRedoChange lastRedo = null;
- while (change != null) {
- ObjectWrapperUndoRedoChange redo = ApplyDiff (change.TargetObject, change.Diff);
- if (redo != null) {
- redo.Next = lastRedo;
- lastRedo = redo;
- }
- change = change.Next;
- }
- return lastRedo;
- } catch (Exception ex) {
- Console.WriteLine (ex);
- return null;
- } finally {
- updating = false;
- }
- }
-
- ObjectWrapperUndoRedoChange ApplyDiff (string id, object diff)
- {
-// Console.WriteLine ("** APPLYING DIFF: uid:" + id);
-// PrintPatch (diff);
-
- ObjectWrapper ww = rootObject.FindObjectByUndoId (id);
- if (ww == null) {
- Console.WriteLine ("Object with undo id '{0}' not found", id);
- return null;
- }
-
- object reverseDiff = ww.ApplyUndoRedoDiff (diff);
-
- if (reverseDiff != null) {
-// Console.WriteLine ("** REVERSE DIFF:");
-// PrintPatch (reverseDiff);
-
- ObjectWrapperUndoRedoChange change = new ObjectWrapperUndoRedoChange (this, id, reverseDiff);
- return change;
- } else
- return null;
- }
-
- internal bool CheckValid ()
- {
- return rootObject != null;
- }
-
- public void Dispose ()
- {
- rootObject = null;
- if (queue != null)
- queue.Purge ();
- }
-
- internal void PrintPatch (object diff)
- {
- if (diff is Array) {
- foreach (object ob in (Array)diff)
- if (ob != null) PrintPatch (ob);
- } else if (diff is XmlElement)
- Console.WriteLine (((XmlElement)diff).OuterXml);
- else
- Console.WriteLine (diff.ToString ());
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/UserInterface.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/UserInterface.cs
deleted file mode 100644
index 3eab8b8b89..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/UserInterface.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- internal class UserInterface
- {
- UserInterface()
- {
- }
-
- public static WidgetDesignerBackend CreateWidgetDesigner (Gtk.Container widget)
- {
- Stetic.Wrapper.Container wc = Stetic.Wrapper.Container.Lookup (widget);
- return CreateWidgetDesigner (widget, wc.DesignWidth, wc.DesignHeight);
- }
-
- public static WidgetDesignerBackend CreateWidgetDesigner (Gtk.Container widget, int designWidth, int designHeight)
- {
- return new WidgetDesignerBackend (widget, designWidth, designHeight);
- }
-
- public static ActionGroupDesignerBackend CreateActionGroupDesigner (ProjectBackend project, ActionGroupToolbar groupToolbar)
- {
- Editor.ActionGroupEditor agroupEditor = new Editor.ActionGroupEditor ();
- agroupEditor.Project = project;
- WidgetDesignerBackend groupDesign = new WidgetDesignerBackend (agroupEditor, -1, -1);
-
- groupToolbar.Bind (agroupEditor);
-
- return new ActionGroupDesignerBackend (groupDesign, agroupEditor, groupToolbar);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetActionBar.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetActionBar.cs
deleted file mode 100644
index c9db05dd57..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetActionBar.cs
+++ /dev/null
@@ -1,251 +0,0 @@
-
-using System;
-using System.Collections;
-using Gtk;
-using Mono.Unix;
-
-namespace Stetic
-{
-
- internal class WidgetActionBar: Gtk.Toolbar
- {
- ProjectBackend project;
- Stetic.Wrapper.Widget rootWidget;
- WidgetTreeCombo combo;
- ToolItem comboItem;
- Stetic.Wrapper.Widget selection;
- Stetic.Wrapper.Container.ContainerChild packingSelection;
- Hashtable editors, wrappers;
- Hashtable sensitives, invisibles;
- ArrayList toggles;
- bool disposed;
- bool updating;
- bool allowBinding;
- WidgetDesignerFrontend frontend;
-
- public WidgetActionBar (WidgetDesignerFrontend frontend, Stetic.Wrapper.Widget rootWidget)
- {
- this.frontend = frontend;
-
- editors = new Hashtable ();
- wrappers = new Hashtable ();
- sensitives = new Hashtable ();
- invisibles = new Hashtable ();
- toggles = new ArrayList ();
-
- IconSize = IconSize.Menu;
- Orientation = Orientation.Horizontal;
- ToolbarStyle = ToolbarStyle.BothHoriz;
-
- combo = new WidgetTreeCombo ();
- comboItem = new ToolItem ();
- comboItem.Add (combo);
- comboItem.ShowAll ();
- Insert (comboItem, -1);
- ShowAll ();
- RootWidget = rootWidget;
- }
-
- public override void Dispose ()
- {
- if (disposed)
- return;
- disposed = true;
- combo.Destroy ();
- combo = null;
- RootWidget = null;
- Clear ();
- base.Dispose ();
- }
-
- public bool AllowWidgetBinding {
- get { return allowBinding; }
- set { allowBinding = value; }
- }
-
- public Stetic.Wrapper.Widget RootWidget {
- get { return rootWidget; }
- set {
- if (project != null) {
- project.SelectionChanged -= OnSelectionChanged;
- project = null;
- }
-
- rootWidget = value;
- if (combo != null)
- combo.RootWidget = rootWidget;
-
- if (rootWidget != null) {
- project = (Stetic.ProjectBackend) rootWidget.Project;
- UpdateSelection (Wrapper.Widget.Lookup (project.Selection));
- project.SelectionChanged += OnSelectionChanged;
- }
- }
- }
-
- void Clear ()
- {
- if (selection != null) {
- selection.Notify -= Notified;
- if (packingSelection != null)
- packingSelection.Notify -= Notified;
- }
-
- selection = null;
- packingSelection = null;
-
- editors.Clear ();
- wrappers.Clear ();
- sensitives.Clear ();
- invisibles.Clear ();
- toggles.Clear ();
-
- foreach (Gtk.Widget child in Children)
- if (child != comboItem) {
- Remove (child);
- child.Destroy ();
- }
- }
-
- void OnSelectionChanged (object s, Wrapper.WidgetEventArgs args)
- {
- UpdateSelection (args.WidgetWrapper);
- }
-
- void UpdateSelection (Wrapper.Widget w)
- {
- Clear ();
- selection = w;
-
- if (selection == null) {
- combo.SetSelection (null);
- return;
- }
-
- // Look for the root widget, and only update the bar if the selected
- // widget is a child of the root widget
-
- while (w != null && !w.IsTopLevel) {
- w = Stetic.Wrapper.Container.LookupParent ((Gtk.Widget) w.Wrapped);
- }
- if (w == null || w != rootWidget)
- return;
-
- combo.SetSelection (selection);
-
- selection.Notify += Notified;
- packingSelection = Stetic.Wrapper.Container.ChildWrapper (selection);
- if (packingSelection != null)
- packingSelection.Notify += Notified;
-
- AddWidgetCommands (selection);
- UpdateSensitivity ();
- }
-
- protected virtual void AddWidgetCommands (ObjectWrapper wrapper)
- {
- if (allowBinding && wrapper != RootWidget) {
- // Show the Bind to Field button only for children of the root container.
- ToolButton bindButton = new ToolButton (null, Catalog.GetString ("Bind to Field"));
- bindButton.IsImportant = true;
- bindButton.Clicked += delegate { frontend.NotifyBindField (); };
- bindButton.Show ();
- Insert (bindButton, -1);
- }
- AddCommands (wrapper);
- }
-
- void AddCommands (ObjectWrapper wrapper)
- {
- foreach (ItemGroup igroup in wrapper.ClassDescriptor.ItemGroups) {
- foreach (ItemDescriptor desc in igroup) {
- if ((desc is CommandDescriptor) && desc.SupportsGtkVersion (project.TargetGtkVersion))
- AppendCommand ((CommandDescriptor) desc, wrapper);
- }
- }
-
- Stetic.Wrapper.Widget widget = wrapper as Stetic.Wrapper.Widget;
- if (widget != null) {
- Stetic.Wrapper.Container.ContainerChild packingSelection = Stetic.Wrapper.Container.ChildWrapper (widget);
- if (packingSelection != null)
- AddCommands (packingSelection);
- }
- }
-
- void AppendCommand (CommandDescriptor cmd, ObjectWrapper widget)
- {
- Gtk.ToolButton button;
-
- if (cmd.IsToggleCommand (widget.Wrapped)) {
- button = new Gtk.ToggleToolButton ();
- ((Gtk.ToggleToolButton)button).Active = cmd.IsToogled (widget.Wrapped);
- toggles.Add (cmd);
- editors[cmd.Name] = button;
- } else {
- button = new Gtk.ToolButton (null, null);
- }
-
- Gtk.Image img = cmd.GetImage ();
- if (img != null) {
- button.IconWidget = img;
- button.Label = cmd.Label;
- if (cmd.Label != null && cmd.Label.Length > 0)
- button.TooltipText = cmd.Label;
- }
- else {
- button.Label = cmd.Label;
- button.IsImportant = true;
- }
- button.Clicked += delegate (object o, EventArgs args) {
- if (!updating)
- cmd.Run (widget.Wrapped);
- };
- button.ShowAll ();
- Insert (button, -1);
-
- if (cmd.HasDependencies) {
- editors[cmd.Name] = button;
- sensitives[cmd] = cmd;
- }
- if (cmd.HasVisibility) {
- editors[cmd.Name] = button;
- invisibles[cmd] = cmd;
- }
- wrappers [cmd] = widget;
- }
-
- void Notified (object s, string propertyName)
- {
- UpdateSensitivity ();
- }
-
- void UpdateSensitivity ()
- {
- foreach (ItemDescriptor item in sensitives.Keys) {
- Widget w = editors[item.Name] as Widget;
- if (w != null) {
- ObjectWrapper wrapper = wrappers [item] as ObjectWrapper;
- object ob = sensitives.Contains (item) ? wrapper.Wrapped : null;
- w.Sensitive = item.EnabledFor (ob);
- }
- }
- foreach (ItemDescriptor item in invisibles.Keys) {
- Widget w = editors[item.Name] as Widget;
- if (w != null) {
- ObjectWrapper wrapper = wrappers [item] as ObjectWrapper;
- object ob = invisibles.Contains (item) ? wrapper.Wrapped : null;
- w.Visible = item.VisibleFor (ob);
- }
- }
- foreach (CommandDescriptor cmd in toggles) {
- ToggleToolButton w = editors[cmd.Name] as ToggleToolButton;
- if (w != null) {
- ObjectWrapper wrapper = wrappers [cmd] as ObjectWrapper;
- updating = true;
- w.Active = cmd.IsToogled (wrapper.Wrapped);
- updating = false;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetComponent.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetComponent.cs
deleted file mode 100644
index 84f63413ca..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetComponent.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-
-namespace Stetic
-{
- public class WidgetComponent: Component
- {
- static WidgetComponent placeholder;
-
- public WidgetComponent (Application app, object backend, string name, ComponentType type): base (app, backend, name, type)
- {
- }
-
- public override string Name {
- get {
- if (name == null)
- UpdateComponentInfo ();
- return name;
- }
- set {
- name = value;
- if (app != null)
- app.Backend.RenameWidget ((Wrapper.Widget)backend, value);
- }
- }
-
- public override bool GeneratePublic {
- get { return ((Wrapper.Widget)backend).GeneratePublic; }
- set { ((Wrapper.Widget)backend).GeneratePublic = value; }
- }
-
- internal void UpdateName (string name)
- {
- this.name = name;
- }
-
- public override Component[] GetChildren ()
- {
- if (app == null)
- return new Component [0];
- ArrayList wws = app.Backend.GetWidgetChildren ((Wrapper.Widget)backend);
- if (wws == null)
- return new Component [0];
- ArrayList children = new ArrayList (wws.Count);
- for (int n=0; n<wws.Count; n++) {
- Component c = app.GetComponent (wws[n], null, null);
- if (c != null)
- children.Add (c);
- }
- return (Component[]) children.ToArray (typeof(Component));
- }
-
- void UpdateComponentInfo ()
- {
- if (app == null)
- return;
- string typeName;
- app.Backend.GetComponentInfo (backend, out name, out typeName);
- type = app.GetComponentType (typeName);
- }
-
- public override ComponentType Type {
- get {
- if (type == null)
- UpdateComponentInfo ();
- return type;
- }
- }
-
- public ActionGroupComponent[] GetActionGroups ()
- {
- if (app == null)
- return new ActionGroupComponent [0];
-
- ArrayList comps = new ArrayList ();
- Wrapper.ActionGroup[] groups = app.Backend.GetActionGroups ((Wrapper.Widget)backend);
- for (int n=0; n<groups.Length; n++) {
- ActionGroupComponent ag = (ActionGroupComponent) app.GetComponent (groups[n], null, null);
- if (ag != null)
- comps.Add (ag);
- }
-
- return (ActionGroupComponent[]) comps.ToArray (typeof(ActionGroupComponent));
- }
-
- public bool IsWindow {
- get { return backend is Wrapper.Window; }
- }
-
- internal static WidgetComponent Placeholder {
- get {
- if (placeholder == null) {
- placeholder = new WidgetComponent (null, null, "", ComponentType.Unknown);
- }
- return placeholder;
- }
- }
- }
-
- [Serializable]
- public class ObjectBindInfo
- {
- string typeName;
- string name;
-
- public ObjectBindInfo (string typeName, string name)
- {
- this.typeName = typeName;
- this.name = name;
- }
-
- public string TypeName {
- get { return typeName; }
- }
-
- public string Name {
- get { return name; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetDesigner.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetDesigner.cs
deleted file mode 100644
index cbcbbbb418..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetDesigner.cs
+++ /dev/null
@@ -1,423 +0,0 @@
-using System;
-using System.Collections;
-
-namespace Stetic
-{
- public delegate void ComponentDropCallback ();
-
- public class WidgetDesigner: Designer
- {
- WidgetEditSession session;
- WidgetDesignerFrontend frontend;
- Component selection;
- Component rootWidget;
-
- Project project;
- int reloadCount;
-
- string componentName;
- bool disposed;
-
- bool canCut, canCopy, canPaste, canDelete;
-
- public event EventHandler BindField;
- public event EventHandler Changed;
- public event EventHandler SelectionChanged;
- public event EventHandler RootComponentChanged;
- public event ComponentSignalEventHandler SignalAdded;
- public event ComponentSignalEventHandler SignalRemoved;
- public event ComponentSignalEventHandler SignalChanged;
- public event ComponentNameEventHandler ComponentNameChanged;
- public event EventHandler ComponentTypesChanged;
-
- internal WidgetDesigner (Project project, string componentName): base (project.App)
- {
- this.componentName = componentName;
- this.project = project;
- frontend = new WidgetDesignerFrontend (this);
-
- project.SignalAdded += OnSignalAdded;
- project.SignalRemoved += OnSignalRemoved;
- project.SignalChanged += OnSignalChanged;
- project.ComponentNameChanged += OnComponentNameChanged;
- project.ComponentTypesChanged += OnComponentTypesChanged;
- project.BackendChanged += OnProjectBackendChanged;
-
- CreateSession ();
- }
-
- public Component RootComponent {
- get { return rootWidget; }
- }
-
- public override ProjectItemInfo ProjectItem {
- get { return project.GetWidget (rootWidget.Name); }
- }
-
- public ComponentType[] GetComponentTypes ()
- {
- if (!disposed) {
- ArrayList types = new ArrayList ();
- types.AddRange (project.GetComponentTypes ());
-
- // Add actions from the local action groups
-
- WidgetComponent c = rootWidget as WidgetComponent;
- if (c != null) {
- foreach (ActionGroupComponent grp in c.GetActionGroups ()) {
- foreach (ActionComponent ac in grp.GetActions ())
- types.Add (new ComponentType (app, ac));
- }
- }
- return (ComponentType[]) types.ToArray (typeof(ComponentType));
- }
- else
- return new ComponentType[0];
- }
-
- public void BeginComponentDrag (ComponentType type, Gtk.Widget source, Gdk.DragContext ctx)
- {
- Stetic.ObjectWrapper wrapper = type.Action != null ? (Stetic.ObjectWrapper) type.Action.Backend : null;
- app.Backend.BeginComponentDrag (project.ProjectBackend, type.Description, type.ClassName, wrapper, source, ctx, null);
-
- }
-
- public void BeginComponentDrag (string title, string className, Gtk.Widget source, Gdk.DragContext ctx, ComponentDropCallback callback)
- {
- app.Backend.BeginComponentDrag (project.ProjectBackend, title, className, null, source, ctx, callback);
-
- }
-
- // Creates an action group designer for the widget being edited by this widget designer
- public ActionGroupDesigner CreateActionGroupDesigner ()
- {
- if (disposed)
- throw new ObjectDisposedException ("WidgetDesigner");
- return new ActionGroupDesigner (project, componentName, null, this, true);
-
- }
-
- public bool Modified {
- get { return session != null && session.Modified; }
- }
-
- internal override void SetActive ()
- {
- if (!disposed)
- project.App.SetActiveDesignSession (project, session);
- }
-
- public bool AllowWidgetBinding {
- get { return session != null && session.AllowWidgetBinding; }
- set {
- if (session != null)
- session.AllowWidgetBinding = value;
- }
- }
-
- public ImportFileDelegate ImportFileCallback {
- get { return project.ImportFileCallback; }
- set { project.ImportFileCallback = value; }
- }
-
- public object SaveStatus ()
- {
- return session.SaveState ();
- }
-
- public void LoadStatus (object ob)
- {
- session.RestoreState (ob);
- }
-
- void CreateSession ()
- {
- try {
- session = project.ProjectBackend.CreateWidgetDesignerSession (frontend, componentName);
- ResetCustomWidget ();
- rootWidget = app.GetComponent (session.RootWidget, null, null);
- } catch (Exception ex) {
- Console.WriteLine (ex);
- Gtk.Label lab = new Gtk.Label ();
- lab.Text = Mono.Unix.Catalog.GetString ("The designer could not be loaded.") + "\n\n" + ex.Message;
- lab.Wrap = true;
- lab.WidthRequest = 400;
- AddCustomWidget (lab);
- session = null;
- }
- }
-
- protected override void OnCreatePlug (uint socketId)
- {
- session.CreateWrapperWidgetPlug (socketId);
- }
-
- protected override void OnDestroyPlug (uint socketId)
- {
- session.DestroyWrapperWidgetPlug ();
- }
-
- protected override Gtk.Widget OnCreateWidget ()
- {
- return session.WrapperWidget;
- }
-
- public Component Selection {
- get {
- return selection;
- }
- }
-
- public void CopySelection ()
- {
- if (session != null)
- session.ClipboardCopySelection ();
- }
-
- public void CutSelection ()
- {
- if (session != null)
- session.ClipboardCutSelection ();
- }
-
- public void PasteToSelection ()
- {
- if (session != null)
- session.ClipboardPaste ();
- }
-
- public void DeleteSelection ()
- {
- if (session != null)
- session.DeleteSelection ();
- }
-
- public bool CanDeleteSelection {
- get { return canDelete; }
- }
-
- public bool CanCutSelection {
- get { return canCut; }
- }
-
- public bool CanCopySelection {
- get { return canCopy; }
- }
-
- public bool CanPasteToSelection {
- get { return canPaste; }
- }
-
- public UndoQueue UndoQueue {
- get {
- if (session != null)
- return session.UndoQueue;
- else
- return UndoQueue.Empty;
- }
- }
-
- protected override void OnDestroyed ()
- {
- try {
- if (disposed)
- return;
-
- if (project.App.ActiveProject == project)
- project.App.ActiveProject = null;
-
- disposed = true;
- frontend.disposed = true;
- project.SignalAdded -= OnSignalAdded;
- project.SignalRemoved -= OnSignalRemoved;
- project.SignalChanged -= OnSignalChanged;
- project.ComponentNameChanged -= OnComponentNameChanged;
- project.ComponentTypesChanged -= OnComponentTypesChanged;
- project.BackendChanged -= OnProjectBackendChanged;
-
- if (session != null) {
- session.Dispose ();
- session = null;
- }
-
- System.Runtime.Remoting.RemotingServices.Disconnect (frontend);
- frontend = null;
- rootWidget = null;
- selection = null;
- } finally {
- base.OnDestroyed ();
- }
- }
-
- public void Save ()
- {
- if (session != null)
- session.Save ();
- }
-
- void OnComponentNameChanged (object s, ComponentNameEventArgs args)
- {
- if (!disposed && ComponentNameChanged != null)
- ComponentNameChanged (this, args);
- }
-
- internal void NotifyRootWidgetChanging ()
- {
- PrepareUpdateWidget ();
- }
-
- internal void NotifyRootWidgetChanged ()
- {
- object rw = session.RootWidget;
- if (rw != null)
- rootWidget = app.GetComponent (session.RootWidget, null, null);
- else
- rootWidget = null;
-
- UpdateWidget ();
- if (RootComponentChanged != null)
- RootComponentChanged (this, EventArgs.Empty);
- }
-
- internal override void OnBackendChanging ()
- {
- reloadCount = 0;
- base.OnBackendChanging ();
- }
-
- internal override void OnBackendChanged (ApplicationBackend oldBackend)
- {
- // Can't do anything until the projects are reloaded
- // This is checked in OnProjectBackendChanged.
- }
-
- void OnProjectBackendChanged (ApplicationBackend oldBackend)
- {
- if (++reloadCount == 2) {
- object sessionData = null;
-
-// if (oldBackend != null && !autoCommitChanges) {
-// sessionData = session.SaveState ();
-// session.DestroyWrapperWidgetPlug ();
-// }
-
- // Don't dispose the session here, since it will dispose
- // the underlying project, and we can't do it because
- // it may need to process the OnBackendChanging event
- // as well.
-
- CreateSession ();
-
- if (sessionData != null && session != null)
- session.RestoreState (sessionData);
-
- base.OnBackendChanged (oldBackend);
- NotifyRootWidgetChanged ();
- }
- }
-
- void OnComponentTypesChanged (object s, EventArgs a)
- {
- if (ComponentTypesChanged != null)
- ComponentTypesChanged (this, a);
- }
-
- void OnSignalAdded (object sender, Stetic.ComponentSignalEventArgs args)
- {
- if (SignalAdded != null)
- SignalAdded (this, args);
- }
-
- void OnSignalRemoved (object sender, Stetic.ComponentSignalEventArgs args)
- {
- if (SignalRemoved != null)
- SignalRemoved (this, args);
- }
-
- void OnSignalChanged (object sender, Stetic.ComponentSignalEventArgs args)
- {
- if (SignalChanged != null)
- SignalChanged (this, args);
- }
-
- internal void NotifyBindField ()
- {
- if (BindField != null)
- BindField (this, EventArgs.Empty);
- }
-
- internal void NotifyChanged ()
- {
- if (Changed != null)
- Changed (this, EventArgs.Empty);
- }
-
- internal void NotifySelectionChanged (object ob, bool canCut, bool canCopy, bool canPaste, bool canDelete)
- {
- this.canCut = canCut;
- this.canCopy = canCopy;
- this.canPaste = canPaste;
- this.canDelete = canDelete;
-
- if (ob != null)
- selection = app.GetComponent (ob, null, null);
- else
- selection = null;
-
- if (SelectionChanged != null)
- SelectionChanged (this, EventArgs.Empty);
- }
- }
-
- internal class WidgetDesignerFrontend: MarshalByRefObject
- {
- WidgetDesigner designer;
- internal bool disposed;
-
- public WidgetDesignerFrontend (WidgetDesigner designer)
- {
- this.designer = designer;
- }
-
- public void NotifyBindField ()
- {
- GuiDispatch.InvokeSync (
- delegate { if (!disposed) designer.NotifyBindField (); }
- );
- }
-
- public void NotifyChanged ()
- {
- GuiDispatch.InvokeSync (
- delegate { if (!disposed) designer.NotifyChanged (); }
- );
- }
-
- internal void NotifySelectionChanged (object ob, bool canCut, bool canCopy, bool canPaste, bool canDelete)
- {
- GuiDispatch.InvokeSync (
- delegate { if (!disposed) designer.NotifySelectionChanged (ob, canCut, canCopy, canPaste, canDelete); }
- );
- }
-
- public void NotifyRootWidgetChanged ()
- {
- GuiDispatch.InvokeSync (
- delegate { if (!disposed) designer.NotifyRootWidgetChanged (); }
- );
- }
-
- public void NotifyRootWidgetChanging ()
- {
- GuiDispatch.InvokeSync (
- delegate { if (!disposed) designer.NotifyRootWidgetChanging (); }
- );
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetDesignerBackend.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetDesignerBackend.cs
deleted file mode 100644
index 8c85049ccd..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetDesignerBackend.cs
+++ /dev/null
@@ -1,961 +0,0 @@
-//
-// WidgetDesignerBackend.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System;
-using System.Collections;
-using System.Reflection;
-using Gtk;
-using Gdk;
-
-namespace Stetic
-{
- internal class WidgetDesignerBackend: ScrolledWindow
- {
- ObjectWrapper wrapper;
- Gtk.Widget preview;
- ResizableFixed resizableFixed;
-
- static IObjectViewer defaultObjectViewer;
-
- public event EventHandler SelectionChanged;
-
- internal static IObjectViewer DefaultObjectViewer {
- get { return defaultObjectViewer; }
- set { defaultObjectViewer = value; }
- }
-
- public object Selection {
- get {
- IObjectSelection sel = resizableFixed.GetSelection ();
- if (sel != null)
- return sel.DataObject;
- else
- return null;
- }
- }
-
- internal IDesignArea DesignArea {
- get { return resizableFixed; }
- }
-
- internal WidgetDesignerBackend (Gtk.Container container, int designWidth, int designHeight)
- {
- ShadowType = ShadowType.None;
- HscrollbarPolicy = PolicyType.Automatic;
- VscrollbarPolicy = PolicyType.Automatic;
-
- resizableFixed = new ResizableFixed ();
- resizableFixed.ObjectViewer = defaultObjectViewer;
-
- wrapper = ObjectWrapper.Lookup (container);
- TopLevelWindow window = container as TopLevelWindow;
-
- if (window != null) {
- preview = Stetic.Metacity.Preview.Create (window);
- if (preview == null)
- preview = Stetic.Windows.Preview.Create (window);
- if (preview == null) {
- // Use a regular box.
- EventBox eventBox = new EventBox ();
- eventBox.Add (container);
- preview = eventBox;
- }
- } else {
- EventBox eventBox = new EventBox ();
- eventBox.Add (container);
- preview = eventBox;
- }
-
- resizableFixed.Put (preview, container);
-
- if (designWidth != -1) {
- preview.WidthRequest = designWidth;
- preview.HeightRequest = designHeight;
- resizableFixed.AllowResize = true;
- } else {
- resizableFixed.AllowResize = false;
- }
-
- preview.SizeAllocated += new Gtk.SizeAllocatedHandler (OnResized);
-
- AddWithViewport (resizableFixed);
-
- if (wrapper != null)
- wrapper.AttachDesigner (resizableFixed);
-
- resizableFixed.SelectionChanged += OnSelectionChanged;
- }
-
- protected override void OnDestroyed ()
- {
- if (preview != null) {
- if (wrapper != null)
- wrapper.DetachDesigner (resizableFixed);
- preview.SizeAllocated -= new Gtk.SizeAllocatedHandler (OnResized);
- resizableFixed.SelectionChanged -= OnSelectionChanged;
- resizableFixed = null;
- preview = null;
- wrapper = null;
- }
- base.OnDestroyed ();
- }
-
- public IObjectViewer ObjectViewer {
- get { return resizableFixed.ObjectViewer; }
- set { resizableFixed.ObjectViewer = value; }
- }
-
- public void UpdateObjectViewers ()
- {
- // This method has to be called to ensure that the property
- // and signal viewers show information about the object
- // selected in this designer.
- resizableFixed.UpdateObjectViewers ();
- }
-
- void OnSelectionChanged (object ob, EventArgs a)
- {
- if (SelectionChanged != null)
- SelectionChanged (this, a);
- }
-
- protected override void OnParentSet (Gtk.Widget previousParent)
- {
- base.OnParentSet (previousParent);
-
- if (previousParent != null)
- previousParent.Realized -= OnParentRealized;
-
- if (Parent != null)
- Parent.Realized += OnParentRealized;
- }
-
- void OnParentRealized (object s, EventArgs args)
- {
- if (Parent != null) {
- Parent.Realized -= OnParentRealized;
- ShowAll ();
-
- // Make sure everything is in place before continuing
- while (Gtk.Application.EventsPending ())
- Gtk.Application.RunIteration ();
- }
- }
-
- void OnResized (object s, Gtk.SizeAllocatedArgs a)
- {
- Stetic.Wrapper.Container cont = wrapper as Stetic.Wrapper.Container;
- if (cont != null) {
- if (cont.DesignHeight != DesignHeight)
- cont.DesignHeight = DesignHeight;
- if (cont.DesignWidth != DesignWidth)
- cont.DesignWidth = DesignWidth;
- }
-
- if (DesignSizeChanged != null)
- DesignSizeChanged (this, a);
- }
-
- public int DesignWidth {
- get { return preview.WidthRequest; }
- }
-
- public int DesignHeight {
- get { return preview.HeightRequest; }
- }
-
- public event EventHandler DesignSizeChanged;
- }
-
- class ResizableFixed: EventBox, IDesignArea
- {
- Gtk.Widget child;
- int difX, difY;
- bool resizingX;
- bool resizingY;
- Fixed fixd;
- Gtk.Container container;
-
- Cursor cursorX = new Cursor (CursorType.RightSide);
- Cursor cursorY = new Cursor (CursorType.BottomSide);
- Cursor cursorXY = new Cursor (CursorType.BottomRightCorner);
-
- const int padding = 6;
- const int selectionBorder = 6;
-
- Requisition currentSizeRequest;
-
- SelectionHandleBox selectionBox;
- Gtk.Widget selectionWidget;
- ObjectSelection currentObjectSelection;
- ArrayList topLevels = new ArrayList ();
- ArrayList trackingSize = new ArrayList ();
-
- internal IObjectViewer ObjectViewer;
- internal bool AllowResize;
-
- public event EventHandler SelectionChanged;
-
- public ResizableFixed ()
- {
- fixd = new Fixed ();
- Add (fixd);
- this.CanFocus = true;
- this.Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask | EventMask.KeyPressMask;
-// fixd.ModifyBg (Gtk.StateType.Normal, this.Style.Mid (Gtk.StateType.Normal));
-// VisibleWindow = false;
- selectionBox = new SelectionHandleBox (this);
- selectionBox.Show ();
- }
-
- public ResizableFixed (IntPtr p): base (p)
- {
- }
-
- protected override void OnDestroyed ()
- {
- if (cursorX != null) {
- cursorX.Dispose ();
- cursorXY.Dispose ();
- cursorY.Dispose ();
- cursorX = cursorXY = cursorY = null;
- }
- base.OnDestroyed ();
- }
-
- internal void Put (Gtk.Widget child, Gtk.Container container)
- {
- this.child = child;
- this.container = container;
- fixd.Put (child, selectionBorder + padding, selectionBorder + padding);
- child.SizeRequested += new SizeRequestedHandler (OnSizeReq);
- }
-
- public override void Dispose ()
- {
- if (child != null)
- child.SizeRequested -= new SizeRequestedHandler (OnSizeReq);
- base.Dispose ();
- }
-
- public bool IsSelected (Gtk.Widget widget)
- {
- return selectionWidget == widget;
- }
-
- public IObjectSelection GetSelection (Gtk.Widget widget)
- {
- if (selectionWidget == widget)
- return currentObjectSelection;
- else
- return null;
- }
-
- public IObjectSelection GetSelection ()
- {
- return currentObjectSelection;
- }
-
- public IObjectSelection SetSelection (Gtk.Widget widget, object obj)
- {
- return SetSelection (widget, obj, true);
- }
-
- public IObjectSelection SetSelection (Gtk.Widget widget, object obj, bool allowDrag)
- {
- if (currentObjectSelection != null) {
- currentObjectSelection.Dispose ();
- currentObjectSelection = null;
- }
-
- if (widget != null) {
- currentObjectSelection = new ObjectSelection (this, widget, obj);
- currentObjectSelection.AllowDrag = allowDrag;
- }
- else
- currentObjectSelection = null;
-
- PlaceSelectionBox (widget);
- // Make sure the selection box is shown before doing anything else.
- // The UI looks more responsive in this way.
-// while (Gtk.Application.EventsPending ())
-// Gtk.Application.RunIteration ();
-
- UpdateObjectViewers ();
-
- if (SelectionChanged != null)
- SelectionChanged (this, EventArgs.Empty);
-
- return currentObjectSelection;
- }
-
- void PlaceSelectionBox (Gtk.Widget widget)
- {
- if (selectionWidget != null) {
- foreach (Gtk.Widget sw in trackingSize)
- sw.SizeAllocated -= SelectionSizeAllocated;
- selectionWidget.Destroyed -= SelectionDestroyed;
- trackingSize.Clear ();
- }
-
- selectionWidget = widget;
-
- if (widget != null) {
- selectionBox.Hide ();
-
- // This call ensures that the old selection box is removed
- // before the new one is shown
-// while (Gtk.Application.EventsPending ())
-// Gtk.Application.RunIteration ();
-
- // The selection may have changed while dispatching events
-// if (selectionWidget != widget)
-// return;
-
- // Track the size changes of the widget and all its parents
- Gtk.Widget sw = selectionWidget;
- while (sw != this && sw != null) {
- sw.SizeAllocated += SelectionSizeAllocated;
- trackingSize.Add (sw);
- sw = sw.Parent;
- }
-
- selectionWidget.Destroyed += SelectionDestroyed;
- PlaceSelectionBoxInternal (selectionWidget);
- selectionBox.ObjectSelection = currentObjectSelection;
- selectionBox.Show ();
- } else {
- selectionBox.Hide ();
- }
- }
-
- public void ResetSelection (Gtk.Widget widget)
- {
- if (selectionWidget == widget || widget == null) {
- PlaceSelectionBox (null);
- if (currentObjectSelection != null) {
- currentObjectSelection.FireDisposed ();
- currentObjectSelection = null;
-
- // This makes the property editor to flicker
- // when changing widget selection
- // UpdateObjectViewers ();
- }
- if (widget == null) {
- Gtk.Container cc = this as Gtk.Container;
- while (cc.Parent != null)
- cc = cc.Parent as Gtk.Container;
- if (cc is Gtk.Window) {
- ((Gtk.Window)cc).Focus = this;
- }
- }
- }
- }
-
- public void UpdateObjectViewers ()
- {
- object obj;
-
- if (currentObjectSelection == null)
- obj = null;
- else
- obj = currentObjectSelection.DataObject;
-
- if (ObjectViewer != null)
- ObjectViewer.TargetObject = obj;
- }
-
- public void AddWidget (Gtk.Widget w, int x, int y)
- {
- w.Parent = this;
- TopLevelChild info = new TopLevelChild ();
- info.X = x;
- info.Y = y;
- info.Child = w;
- topLevels.Add (info);
- }
-
- public void RemoveWidget (Gtk.Widget w)
- {
- foreach (TopLevelChild info in topLevels) {
- if (info.Child == w) {
- w.Unparent ();
- topLevels.Remove (info);
- break;
- }
- }
- }
-
- public void MoveWidget (Gtk.Widget w, int x, int y)
- {
- foreach (TopLevelChild info in topLevels) {
- if (info.Child == w) {
- info.X = x;
- info.Y = y;
- QueueResize ();
- break;
- }
- }
- }
-
- public Gdk.Rectangle GetCoordinates (Gtk.Widget w)
- {
- int px, py;
- if (!w.TranslateCoordinates (this, 0, 0, out px, out py))
- return new Gdk.Rectangle (0,0,0,0);
-
- Gdk.Rectangle rect = w.Allocation;
- rect.X = px - Allocation.X;
- rect.Y = py - Allocation.Y;
- return rect;
- }
-
- void SelectionSizeAllocated (object obj, Gtk.SizeAllocatedArgs args)
- {
- PlaceSelectionBoxInternal (selectionWidget);
- }
-
- void SelectionDestroyed (object obj, EventArgs args)
- {
- ResetSelection ((Gtk.Widget)obj);
- }
-
- void PlaceSelectionBoxInternal (Gtk.Widget widget)
- {
- int px, py;
- if (!widget.TranslateCoordinates (this, 0, 0, out px, out py))
- return;
-
- Gdk.Rectangle rect = widget.Allocation;
- rect.X = px;
- rect.Y = py;
- selectionBox.Reposition (rect);
- }
-
-
- void OnSizeReq (object o, SizeRequestedArgs a)
- {
- if (!AllowResize) {
- a.RetVal = false;
- QueueDraw ();
- return;
- }
-
- currentSizeRequest = a.Requisition;
-
- Rectangle alloc = child.Allocation;
- int nw = alloc.Width;
- int nh = alloc.Height;
-
- if (a.Requisition.Width > nw) nw = a.Requisition.Width;
- if (a.Requisition.Height > nh) nh = a.Requisition.Height;
-
- if (nw != alloc.Width || nh != alloc.Height) {
- int ow = child.WidthRequest;
- int oh = child.HeightRequest;
- child.SetSizeRequest (nw, nh);
- if (ow > nw)
- child.WidthRequest = ow;
- if (oh > nh)
- child.HeightRequest = oh;
- QueueDraw ();
- }
- }
-
- protected override void OnSizeRequested (ref Requisition req)
- {
- // The Toplevel check is done to ensure that this widget is anchored,
- // otherwise the Realize call will fail.
- if (!child.IsRealized && Toplevel is Gtk.Window)
- child.Realize ();
-
- req = child.SizeRequest ();
- // Make some room for the border
- req.Width += padding * 2 + selectionBorder * 2;
- req.Height += padding * 2 + selectionBorder * 2;
- selectionBox.SizeRequest ();
- if (selectionBox.Allocation.Width > req.Width)
- req.Width = selectionBox.Allocation.Width;
- if (selectionBox.Allocation.Height > req.Height)
- req.Height = selectionBox.Allocation.Height;
-
- foreach (TopLevelChild tchild in topLevels) {
- Gtk.Requisition treq = tchild.Child.SizeRequest ();
- if (tchild.X + treq.Width > req.Width)
- req.Width = tchild.X + treq.Width;
- if (tchild.Y + treq.Height > req.Height)
- req.Height = tchild.Y + treq.Height;
- }
- }
-
- protected override void OnSizeAllocated (Gdk.Rectangle rect)
- {
- base.OnSizeAllocated (rect);
-
- if (selectionWidget != null)
- PlaceSelectionBoxInternal (selectionWidget);
-
- foreach (TopLevelChild child in topLevels) {
- Gtk.Requisition req = child.Child.SizeRequest ();
- child.Child.SizeAllocate (new Gdk.Rectangle (rect.X + child.X, rect.Y + child.Y, req.Width, req.Height));
- }
- }
-
- protected override void ForAll (bool include_internals, Gtk.Callback callback)
- {
- base.ForAll (include_internals, callback);
- foreach (TopLevelChild child in topLevels)
- callback (child.Child);
- if (include_internals)
- selectionBox.ForAll (include_internals, callback);
- }
-
- protected override bool OnMotionNotifyEvent (Gdk.EventMotion ev)
- {
- if (resizingX || resizingY) {
- if (resizingX) {
- int nw = (int)(ev.X - difX - padding - selectionBorder);
- if (nw < currentSizeRequest.Width) nw = currentSizeRequest.Width;
- child.WidthRequest = nw;
- }
-
- if (resizingY) {
- int nh = (int)(ev.Y - difY - padding - selectionBorder);
- if (nh < currentSizeRequest.Height) nh = currentSizeRequest.Height;
- child.HeightRequest = nh;
- }
- QueueDraw ();
- } else if (AllowResize) {
- if (GetAreaResizeXY ().Contains ((int) ev.X, (int) ev.Y))
- GdkWindow.Cursor = cursorXY;
- else if (GetAreaResizeX ().Contains ((int) ev.X, (int) ev.Y))
- GdkWindow.Cursor = cursorX;
- else if (GetAreaResizeY ().Contains ((int) ev.X, (int) ev.Y))
- GdkWindow.Cursor = cursorY;
- else
- GdkWindow.Cursor = null;
- }
-
- return base.OnMotionNotifyEvent (ev);
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton ev)
- {
- Gdk.Rectangle rectArea = child.Allocation;
- rectArea.Inflate (selectionBorder, selectionBorder);
-
- if (rectArea.Contains ((int) ev.X, (int) ev.Y)) {
- Stetic.Wrapper.Widget gw = Stetic.Wrapper.Widget.Lookup (container);
- if (gw != null)
- gw.Select ();
- else
- ResetSelection (null);
-
- if (AllowResize) {
- Rectangle rect = GetAreaResizeXY ();
- if (rect.Contains ((int) ev.X, (int) ev.Y)) {
- resizingX = resizingY = true;
- difX = (int) (ev.X - rect.X);
- difY = (int) (ev.Y - rect.Y);
- GdkWindow.Cursor = cursorXY;
- }
-
- rect = GetAreaResizeY ();
- if (rect.Contains ((int) ev.X, (int) ev.Y)) {
- resizingY = true;
- difY = (int) (ev.Y - rect.Y);
- GdkWindow.Cursor = cursorY;
- }
-
- rect = GetAreaResizeX ();
- if (rect.Contains ((int) ev.X, (int) ev.Y)) {
- resizingX = true;
- difX = (int) (ev.X - rect.X);
- GdkWindow.Cursor = cursorX;
- }
- }
- } else {
- Stetic.Wrapper.Widget gw = Stetic.Wrapper.Widget.Lookup (container);
- if (gw != null)
- gw.Project.Selection = null;
- }
-
- return base.OnButtonPressEvent (ev);
- }
-
- Rectangle GetAreaResizeY ()
- {
- Gdk.Rectangle rect = child.Allocation;
- return new Gdk.Rectangle (rect.X - selectionBorder, rect.Y + rect.Height, rect.Width + selectionBorder, selectionBorder);
- }
-
- Rectangle GetAreaResizeX ()
- {
- Gdk.Rectangle rect = child.Allocation;
- return new Gdk.Rectangle (rect.X + rect.Width, rect.Y - selectionBorder, selectionBorder, rect.Height + selectionBorder);
- }
-
- Rectangle GetAreaResizeXY ()
- {
- Gdk.Rectangle rect = child.Allocation;
- return new Gdk.Rectangle (rect.X + rect.Width, rect.Y + rect.Height, selectionBorder, selectionBorder);
- }
-
- protected override bool OnButtonReleaseEvent (Gdk.EventButton ev)
- {
- resizingX = resizingY = false;
- GdkWindow.Cursor = null;
- return base.OnButtonReleaseEvent (ev);
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose ev)
- {
- bool r = base.OnExposeEvent (ev);
- //FIXME Disabled checkerboard background because it's very inefficient and makes the control *very* slow to resize
- // It should take the EventExpose area into account, invalidate more selectively during resizes (GTK viewport
- // code would probably be a good start), and take advantage of the flat block color the parent is rendering.
- /*
- int size = 8;
- bool squareColor = true;
- bool startsquareColor = true;
- int x1 = 0;
- int x2 = Allocation.Width;
- int y1 = 0;
- int y2 = Allocation.Height;
- for (int y = y1; y < y2; y += size) {
- squareColor = startsquareColor;
- startsquareColor = !startsquareColor;
- for (int x = x1; x < x2; x += size) {
- GdkWindow.DrawRectangle (squareColor ? Style.DarkGC (StateType.Normal) : Style.DarkGC (StateType.Active), true, x, y, size, size);
- squareColor = !squareColor;
- }
- }
-
- foreach (Widget cw in Children)
- PropagateExpose (cw, ev);*/
-
- Gdk.Rectangle rect = child.Allocation;
- if (Stetic.Metacity.Preview.ThemeError)
- GdkWindow.DrawRectangle (this.Style.BackgroundGC (StateType.Normal), true, rect.X, rect.Y, rect.Width, rect.Height);
-
- Pixbuf sh = Shadow.AddShadow (rect.Width, rect.Height);
- GdkWindow.DrawPixbuf (this.Style.BackgroundGC (StateType.Normal), sh, 0, 0, rect.X - 5, rect.Y - 5, sh.Width, sh.Height, RgbDither.None, 0, 0);
- return r;
- }
-
- protected override bool OnKeyPressEvent (Gdk.EventKey ev)
- {
- switch (ev.Key) {
- case Gdk.Key.Delete:
- case Gdk.Key.KP_Delete:
- IObjectSelection sel = GetSelection ();
- if (sel != null && sel.DataObject != null) {
- Wrapper.Widget wrapper = Wrapper.Widget.Lookup (sel.DataObject) as Wrapper.Widget;
- if (wrapper != null)
- wrapper.Delete ();
- }
- return true;
- default:
- return base.OnKeyPressEvent (ev);
- }
- }
-
- class TopLevelChild
- {
- public int X;
- public int Y;
- public Gtk.Widget Child;
- }
- }
-
- enum BoxPos
- {
- Start,
- Center,
- End,
- }
-
- enum BoxFill
- {
- Box,
- VLine,
- HLine
- }
-
- class SelectionHandleBox
- {
- const int selectionHandleSize = 4;
- const int topSelectionHandleSize = 8;
- public const int selectionLineWidth = 2;
-
- ArrayList selection = new ArrayList ();
- Gdk.Rectangle allocation;
- SelectionHandlePart dragHandlePart;
- public ObjectSelection ObjectSelection;
-
- public SelectionHandleBox (Gtk.Widget parent)
- {
- // Lines
- selection.Add (new SelectionHandlePart (BoxFill.HLine, BoxPos.Start, BoxPos.Start, 0, -selectionLineWidth, BoxPos.End, BoxPos.Start, 0, 0));
- selection.Add (new SelectionHandlePart (BoxFill.HLine, BoxPos.Start, BoxPos.End, 0, 0, BoxPos.End, BoxPos.End, 0, selectionLineWidth));
- selection.Add (new SelectionHandlePart (BoxFill.VLine, BoxPos.Start, BoxPos.Start, -selectionLineWidth, 0, BoxPos.Start, BoxPos.End, 0, 0));
- selection.Add (new SelectionHandlePart (BoxFill.VLine, BoxPos.End, BoxPos.Start, 0, 0, BoxPos.End, BoxPos.End, selectionLineWidth, 0));
-
- // Handles
- selection.Add (new SelectionHandlePart (BoxFill.Box, BoxPos.Start, BoxPos.Start, -selectionHandleSize, -selectionHandleSize, BoxPos.Start, BoxPos.Start, 0, 0));
- selection.Add (new SelectionHandlePart (BoxFill.Box, BoxPos.End, BoxPos.Start, 0, -selectionHandleSize, BoxPos.End, BoxPos.Start, selectionHandleSize, 0));
- selection.Add (new SelectionHandlePart (BoxFill.Box, BoxPos.Start, BoxPos.End, -selectionHandleSize, 0, BoxPos.Start, BoxPos.End, 0, selectionHandleSize));
- selection.Add (new SelectionHandlePart (BoxFill.Box, BoxPos.End, BoxPos.End, 0, 0, BoxPos.End, BoxPos.End, selectionHandleSize, selectionHandleSize));
-
- selection.Add (new SelectionHandlePart (BoxFill.Box, BoxPos.Center, BoxPos.Start, -selectionHandleSize/2, -selectionHandleSize, BoxPos.Center, BoxPos.Start, selectionHandleSize/2, 0));
- selection.Add (new SelectionHandlePart (BoxFill.Box, BoxPos.Center, BoxPos.End, -selectionHandleSize/2, 0, BoxPos.Center, BoxPos.End, selectionHandleSize/2, selectionHandleSize));
- selection.Add (new SelectionHandlePart (BoxFill.Box, BoxPos.Start, BoxPos.Center, -selectionHandleSize, -selectionHandleSize/2, BoxPos.Start, BoxPos.Center, 0, selectionHandleSize/2));
- selection.Add (new SelectionHandlePart (BoxFill.Box, BoxPos.End, BoxPos.Center, 0, -selectionHandleSize/2, BoxPos.End, BoxPos.Center, selectionHandleSize, selectionHandleSize/2));
-
- dragHandlePart = new SelectionHandlePart (BoxFill.Box, BoxPos.Center, BoxPos.Start, -topSelectionHandleSize/2, -topSelectionHandleSize, BoxPos.Center, BoxPos.Start, topSelectionHandleSize/2, 0);
- selection.Add (dragHandlePart);
-
- foreach (SelectionHandlePart s in selection) {
- s.Parent = parent;
- s.ParentBox = this;
- }
- }
-
- public void Show ()
- {
- foreach (Gtk.Widget s in selection)
- s.Show ();
- dragHandlePart.Visible = (ObjectSelection != null && ObjectSelection.AllowDrag);
- }
-
- public void Hide ()
- {
- foreach (Gtk.Widget s in selection)
- s.Hide ();
- }
-
- public void Reposition (Gdk.Rectangle rect)
- {
- bool firstRect = true;
-
- foreach (SelectionHandlePart s in selection) {
- s.Reposition (rect);
- Gdk.Rectangle r = s.Allocation;
- if (firstRect) {
- allocation = r;
- firstRect = false;
- } else
- allocation = allocation.Union (r);
- }
- }
-
- public Gdk.Rectangle Allocation {
- get { return allocation; }
- }
-
- public void ForAll (bool include_internals, Gtk.Callback callback)
- {
- foreach (Gtk.Widget s in selection)
- callback (s);
- }
-
- public void SizeRequest ()
- {
- foreach (Gtk.Widget s in selection)
- s.SizeRequest ();
- }
- }
-
- class SelectionHandlePart: EventBox
- {
- BoxPos hpos, vpos;
- BoxPos hposEnd, vposEnd;
- int x, y;
- int xEnd, yEnd;
- BoxFill fill;
- public SelectionHandleBox ParentBox;
- int clickX, clickY;
- int localClickX, localClickY;
- int ox, oy;
-
- public SelectionHandlePart (BoxFill fill, BoxPos hpos, BoxPos vpos, int x, int y, BoxPos hposEnd, BoxPos vposEnd, int xEnd, int yEnd)
- {
- this.fill = fill;
- this.hpos = hpos;
- this.vpos = vpos;
- this.x = x;
- this.y = y;
-
- this.hposEnd = hposEnd;
- this.vposEnd = vposEnd;
- this.xEnd = xEnd;
- this.yEnd = yEnd;
- }
-
- public void Reposition (Gdk.Rectangle rect)
- {
- int px, py;
- int pxEnd, pyEnd;
-
- CalcPos (rect, hpos, vpos, out px, out py);
- px += x;
- py += y;
-
- CalcPos (rect, hposEnd, vposEnd, out pxEnd, out pyEnd);
- pxEnd += xEnd;
- pyEnd += yEnd;
-
- Allocation = new Gdk.Rectangle (px, py, pxEnd - px, pyEnd - py);
- ox = rect.X;
- oy = rect.Y;
- }
-
- void CalcPos (Gdk.Rectangle rect, BoxPos hp, BoxPos vp, out int px, out int py)
- {
- if (vp == BoxPos.Start)
- py = rect.Y;
- else if (vp == BoxPos.End)
- py = rect.Bottom;
- else
- py = rect.Y + rect.Height / 2;
-
- if (hp == BoxPos.Start)
- px = rect.X;
- else if (hp == BoxPos.End)
- px = rect.Right;
- else
- px = rect.X + rect.Width / 2;
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose ev)
- {
- int w, h;
- this.GdkWindow.GetSize (out w, out h);
-
- if (fill == BoxFill.Box) {
- this.GdkWindow.DrawRectangle (this.Style.WhiteGC, true, 0, 0, w, h);
- this.GdkWindow.DrawRectangle (this.Style.BlackGC, false, 0, 0, w-1, h-1);
- } else if (fill == BoxFill.HLine) {
- Gdk.GC gc = new Gdk.GC (this.GdkWindow);
- gc.SetDashes (0, new sbyte[] {1,1}, 2);
- gc.SetLineAttributes (SelectionHandleBox.selectionLineWidth, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);
- gc.Foreground = this.Style.Black;
- this.GdkWindow.DrawLine (gc, 0, h/2, w, h/2);
- gc.Foreground = this.Style.White;
- this.GdkWindow.DrawLine (gc, 1, h/2, w, h/2);
- } else {
- Gdk.GC gc = new Gdk.GC (this.GdkWindow);
- gc.SetDashes (0, new sbyte[] {1,1}, 2);
- gc.SetLineAttributes (SelectionHandleBox.selectionLineWidth, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);
- gc.Foreground = this.Style.Black;
- this.GdkWindow.DrawLine (gc, w/2, 0, w/2, h);
- gc.Foreground = this.Style.White;
- this.GdkWindow.DrawLine (gc, w/2, 1, w/2, h);
- }
-
- return true;
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton evb)
- {
- if (evb.Type == Gdk.EventType.ButtonPress && evb.Button == 1) {
- clickX = (int)evb.XRoot;
- clickY = (int)evb.YRoot;
- localClickX = (int) evb.X;
- localClickY = (int) evb.Y;
- }
- return true;
- }
-
- protected override bool OnMotionNotifyEvent (Gdk.EventMotion evm)
- {
- if ((evm.State & Gdk.ModifierType.Button1Mask) == 0)
- return false;
-
- if (!Gtk.Drag.CheckThreshold (this, clickX, clickY, (int)evm.XRoot, (int)evm.YRoot))
- return false;
-
- if (ParentBox.ObjectSelection != null && ParentBox.ObjectSelection.AllowDrag) {
- int dx = Allocation.X - ox + localClickX;
- int dy = Allocation.Y - oy + localClickY;
- ParentBox.ObjectSelection.FireDrag (evm, dx, dy);
- }
-
- return true;
- }
- }
-
- class ObjectSelection: IObjectSelection
- {
- ResizableFixed box;
- Gtk.Widget widget;
- object dataObject;
- bool allowDrag = true;
-
- public ObjectSelection (ResizableFixed box, Gtk.Widget widget, object dataObject)
- {
- this.box = box;
- this.widget = widget;
- this.dataObject = dataObject;
- }
-
- public Gtk.Widget Widget {
- get { return widget; }
- }
-
- public object DataObject {
- get { return dataObject; }
- }
-
- public void Dispose ()
- {
- box.ResetSelection (widget);
- }
-
- internal void FireDisposed ()
- {
- if (Disposed != null)
- Disposed (this, EventArgs.Empty);
- }
-
- internal void FireDrag (Gdk.EventMotion evt, int dx, int dy)
- {
- if (Drag != null)
- Drag (evt, dx, dy);
- }
-
- public bool AllowDrag {
- get { return allowDrag; }
- set { allowDrag = value; }
- }
-
- public event DragDelegate Drag;
- public event EventHandler Disposed;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetEditSession.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetEditSession.cs
deleted file mode 100644
index a999efe73c..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetEditSession.cs
+++ /dev/null
@@ -1,368 +0,0 @@
-//
-// WidgetEditSession.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System;
-using System.Xml;
-using System.Reflection;
-using System.Collections;
-using System.CodeDom;
-using Mono.Unix;
-
-namespace Stetic {
-
- internal class WidgetEditSession: MarshalByRefObject, IDisposable
- {
- string sourceWidget;
- Stetic.ProjectBackend project;
-
- Stetic.Wrapper.Container rootWidget;
- Stetic.WidgetDesignerBackend widget;
- Gtk.VBox designer;
- Gtk.Plug plug;
- WidgetActionBar toolbar;
- WidgetDesignerFrontend frontend;
- bool allowBinding;
- bool disposed;
-
- ContainerUndoRedoManager undoManager;
- UndoQueue undoQueue;
-
- public event EventHandler RootWidgetChanged;
- public event Stetic.Wrapper.WidgetEventHandler SelectionChanged;
-
- public WidgetEditSession (ProjectBackend sourceProject, WidgetDesignerFrontend frontend, string windowName)
- {
- this.frontend = frontend;
- undoManager = new ContainerUndoRedoManager ();
- undoQueue = new UndoQueue ();
- undoManager.UndoQueue = undoQueue;
-
- sourceWidget = windowName;
- this.project = sourceProject;
-
- rootWidget = sourceProject.GetTopLevelWrapper (windowName, true);
- rootWidget.Select ();
- undoManager.RootObject = rootWidget;
-
- this.project.Changed += new ProjectChangedEventHandler (OnChanged);
- this.project.ProjectReloaded += new EventHandler (OnProjectReloaded);
- this.project.ProjectReloading += new EventHandler (OnProjectReloading);
-// this.project.WidgetMemberNameChanged += new Stetic.Wrapper.WidgetNameChangedHandler (OnWidgetNameChanged);
- }
-
- public bool AllowWidgetBinding {
- get { return allowBinding; }
- set {
- allowBinding = value;
- if (toolbar != null)
- toolbar.AllowWidgetBinding = allowBinding;
- }
- }
-
- public Stetic.Wrapper.Widget GladeWidget {
- get { return rootWidget; }
- }
-
- public Stetic.Wrapper.Container RootWidget {
- get { return (Wrapper.Container) Component.GetSafeReference (rootWidget); }
- }
-
- public Gtk.Widget WrapperWidget {
- get {
- if (designer == null) {
- if (rootWidget == null)
- return widget;
- Gtk.Container wc = rootWidget.Wrapped as Gtk.Container;
- if (widget == null)
- widget = Stetic.UserInterface.CreateWidgetDesigner (wc, rootWidget.DesignWidth, rootWidget.DesignHeight);
-
- toolbar = new WidgetActionBar (frontend, rootWidget);
- toolbar.AllowWidgetBinding = allowBinding;
- designer = new Gtk.VBox ();
- designer.BorderWidth = 3;
- designer.PackStart (toolbar, false, false, 0);
- designer.PackStart (widget, true, true, 3);
- widget.DesignArea.SetSelection (project.Selection, project.Selection, false);
-
- widget.SelectionChanged += OnSelectionChanged;
-
- }
- return designer;
- }
- }
-
- [NoGuiDispatch]
- public void CreateWrapperWidgetPlug (uint socketId)
- {
- Gdk.Threads.Enter ();
- plug = new Gtk.Plug (socketId);
- plug.Add (WrapperWidget);
- plug.Decorated = false;
- plug.ShowAll ();
- Gdk.Threads.Leave ();
- }
-
- public void DestroyWrapperWidgetPlug ()
- {
- if (designer != null) {
- Gtk.Plug plug = (Gtk.Plug) WrapperWidget.Parent;
- plug.Remove (WrapperWidget);
- plug.Destroy ();
- }
- }
-
- public void Save ()
- {
- }
-
- public ProjectBackend EditingBackend {
- get { return project; }
- }
-
- public void Dispose ()
- {
- project.ComponentTypesChanged -= OnSourceProjectLibsChanged;
- project.ProjectReloaded -= OnSourceProjectReloaded;
- project.Changed -= new ProjectChangedEventHandler (OnChanged);
- project.ProjectReloaded -= OnProjectReloaded;
- project.ProjectReloading -= OnProjectReloading;
-// project.WidgetMemberNameChanged -= new Stetic.Wrapper.WidgetNameChangedHandler (OnWidgetNameChanged);
-
- if (plug != null)
- plug.Destroy ();
- rootWidget = null;
- frontend = null;
- System.Runtime.Remoting.RemotingServices.Disconnect (this);
- disposed = true;
- }
-
- public bool Disposed {
- get { return disposed; }
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
-
- public void SetDesignerActive ()
- {
- widget.UpdateObjectViewers ();
- }
-
- public bool Modified {
- get {
- if (project == null || RootWidget == null)
- return false;
-
- return project.WasModified (RootWidget.Name);
- }
- }
-
- public UndoQueue UndoQueue {
- get {
- if (undoQueue != null)
- return undoQueue;
- else
- return UndoQueue.Empty;
- }
- }
-
- void OnChanged (object s, ProjectChangedEventArgs a)
- {
- if (a.ChangedTopLevelName != RootWidget.Name)
- return;
-
- if (frontend != null)
- frontend.NotifyChanged ();
- }
-
- void OnSourceProjectReloaded (object s, EventArgs a)
- {
-
- }
-
- void OnSourceProjectLibsChanged (object s, EventArgs a)
- {
- }
-
- void OnProjectReloading (object s, EventArgs a)
- {
- if (frontend != null)
- frontend.NotifyRootWidgetChanging ();
- }
-
- void OnProjectReloaded (object s, EventArgs a)
- {
- Gtk.Widget topWidget = project.GetWidget (sourceWidget);
-
- if (topWidget != null) {
- rootWidget = Stetic.Wrapper.Container.Lookup (topWidget);
- undoManager.RootObject = rootWidget;
- if (rootWidget != null) {
- Gtk.Widget oldWidget = designer;
- if (widget != null) {
- widget.SelectionChanged -= OnSelectionChanged;
- widget = null;
- }
- OnRootWidgetChanged ();
- if (oldWidget != null) {
- // Delay the destruction of the old widget, so the designer has time to
- // show the new widget. This avoids flickering.
- GLib.Timeout.Add (500, delegate {
- oldWidget.Destroy ();
- return false;
- });
- }
-
- project.NotifyComponentTypesChanged ();
- return;
- }
- }
- SetErrorMode ();
- }
-
- void SetErrorMode ()
- {
- Gtk.Label lab = new Gtk.Label ();
- lab.Markup = "<b>" + Catalog.GetString ("The form designer could not be loaded") + "</b>";
- Gtk.EventBox box = new Gtk.EventBox ();
- box.Add (lab);
-
- widget = Stetic.UserInterface.CreateWidgetDesigner (box, 100, 100);
- rootWidget = null;
-
- OnRootWidgetChanged ();
- }
-
- void OnRootWidgetChanged ()
- {
- if (designer != null) {
- if (designer.Parent is Gtk.Plug)
- ((Gtk.Plug)designer.Parent).Remove (designer);
- designer = null;
- }
-
- if (plug != null) {
- Gdk.Threads.Enter ();
- plug.Add (WrapperWidget);
- plug.ShowAll ();
- Gdk.Threads.Leave ();
- }
-
- if (frontend != null)
- frontend.NotifyRootWidgetChanged ();
- if (RootWidgetChanged != null)
- RootWidgetChanged (this, EventArgs.Empty);
- }
-
- void OnSelectionChanged (object ob, EventArgs a)
- {
- if (frontend != null) {
- bool canCut, canCopy, canPaste, canDelete;
- ObjectWrapper obj = ObjectWrapper.Lookup (widget.Selection);
- Stetic.Wrapper.Widget wrapper = obj as Stetic.Wrapper.Widget;
- IEditableObject editable = widget.Selection as IEditableObject;
- if (editable == null)
- editable = obj as IEditableObject;
- if (editable != null) {
- canCut = editable.CanCut;
- canCopy = editable.CanCopy;
- canPaste = editable.CanPaste;
- canDelete = editable.CanDelete;
- }
- else {
- canCut = canCopy = canPaste = canDelete = false;
- }
-
- frontend.NotifySelectionChanged (Component.GetSafeReference (obj), canCut, canCopy, canPaste, canDelete);
- if (SelectionChanged != null)
- SelectionChanged (this, new Stetic.Wrapper.WidgetEventArgs (wrapper));
- }
- }
-
- public object SaveState ()
- {
- return new object[] {
- project.SaveStatus (),
- undoQueue
- };
- }
-
- public void RestoreState (object sessionData)
- {
- object[] status = (object[]) sessionData;
- project.LoadStatus (status [0]);
- undoQueue = (UndoQueue) status [1];
- foreach (UndoRedoChange ch in undoQueue.Changes) {
- ObjectWrapperUndoRedoChange och = ch as ObjectWrapperUndoRedoChange;
- if (och != null)
- och.Manager = undoManager;
- }
- undoManager.UndoQueue = undoQueue;
- }
-
- internal void ClipboardCopySelection ()
- {
- IEditableObject editable = widget.Selection as IEditableObject;
- if (editable == null)
- editable = ObjectWrapper.Lookup (widget.Selection) as IEditableObject;
- if (editable != null)
- editable.Copy ();
- }
-
- public void ClipboardCutSelection ()
- {
- IEditableObject editable = widget.Selection as IEditableObject;
- if (editable == null)
- editable = ObjectWrapper.Lookup (widget.Selection) as IEditableObject;
- if (editable != null)
- editable.Cut ();
- }
-
- public void ClipboardPaste ()
- {
- IEditableObject editable = widget.Selection as IEditableObject;
- if (editable == null)
- editable = ObjectWrapper.Lookup (widget.Selection) as IEditableObject;
- if (editable != null)
- editable.Paste ();
- }
-
- public void DeleteSelection ()
- {
- IEditableObject editable = widget.Selection as IEditableObject;
- if (editable == null)
- editable = ObjectWrapper.Lookup (widget.Selection) as IEditableObject;
- if (editable != null)
- editable.Delete ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetFactory.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetFactory.cs
deleted file mode 100644
index 780b287e16..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetFactory.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-using Gtk;
-using Gdk;
-using System;
-using System.Collections;
-using System.Reflection;
-
-namespace Stetic {
-
- // This is the base class for palette items. Implements the basic
- // functionality for showing the icon and label of the item.
-
- internal class PaletteItemFactory : EventBox
- {
- public PaletteItemFactory ()
- {
- }
-
- public virtual void Initialize (string name, Gdk.Pixbuf icon)
- {
- DND.SourceSet (this);
- AboveChild = true;
-
- Gtk.HBox hbox = new HBox (false, 6);
- hbox.BorderWidth = 3;
-
- if (icon != null) {
- icon = icon.ScaleSimple (16, 16, Gdk.InterpType.Bilinear);
- hbox.PackStart (new Gtk.Image (icon), false, false, 0);
- }
-
- Gtk.Label label = new Gtk.Label ("<small>" + name + "</small>");
- label.UseMarkup = true;
- label.Justify = Justification.Left;
- label.Xalign = 0;
- hbox.PackEnd (label, true, true, 0);
-
- Add (hbox);
- }
-
- protected override void OnDragBegin (Gdk.DragContext ctx)
- {
- Gtk.Widget ob = CreateItemWidget ();
- if (ob != null)
- DND.Drag (this, ctx, ob);
- }
-
- protected virtual Gtk.Widget CreateItemWidget ()
- {
- return null;
- }
-
- protected override bool OnEnterNotifyEvent (Gdk.EventCrossing ev)
- {
- this.State = Gtk.StateType.Prelight;
- return base.OnEnterNotifyEvent (ev);
- }
-
- protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing ev)
- {
- this.State = Gtk.StateType.Normal;
- return base.OnLeaveNotifyEvent (ev);
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose e)
- {
- base.OnExposeEvent (e);
- if (State == Gtk.StateType.Prelight)
- Gtk.Style.PaintShadow (this.Style, this.GdkWindow, State, Gtk.ShadowType.Out, e.Area, this, "", e.Area.X, e.Area.Y, e.Area.Width, e.Area.Height);
- return false;
- }
- }
-
-
- // Palette item factory which creates a widget.
- internal class WidgetFactory : PaletteItemFactory {
-
- protected ProjectBackend project;
- protected ClassDescriptor klass;
-
- public WidgetFactory (ProjectBackend project, ClassDescriptor klass)
- {
- this.project = project;
- this.klass = klass;
- Initialize (klass.Label, klass.Icon);
- if (project == null)
- Sensitive = false;
- }
-
- protected override Gtk.Widget CreateItemWidget ()
- {
- return klass.NewInstance (project) as Widget;
- }
- }
-
- internal class WindowFactory : WidgetFactory
- {
- public WindowFactory (ProjectBackend project, ClassDescriptor klass) : base (project, klass)
- {
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton evt)
- {
- Gtk.Window win = klass.NewInstance (project) as Gtk.Window;
- project.AddWindow (win, true);
- return true;
- }
-
- public override void Initialize (string name, Gdk.Pixbuf icon)
- {
- base.Initialize (name, icon);
- DND.SourceUnset (this);
- }
- }
-
- // Palette item factory which allows dragging an already existing object.
- internal class InstanceWidgetFactory : PaletteItemFactory
- {
- Gtk.Widget instance;
-
- public InstanceWidgetFactory (string name, Gdk.Pixbuf icon, Gtk.Widget instance)
- {
- this.instance = instance;
- Initialize (name, icon);
- }
-
- protected override Gtk.Widget CreateItemWidget ()
- {
- return instance;
- }
-
- public override void Dispose ()
- {
- base.Dispose ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetInfoEventHandler.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetInfoEventHandler.cs
deleted file mode 100644
index 1d096dcf2b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetInfoEventHandler.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public delegate void WidgetInfoEventHandler (object sender, WidgetInfoEventArgs args);
-
- public class WidgetInfoEventArgs: EventArgs
- {
- Project project;
- WidgetInfo widget;
-
- internal WidgetInfoEventArgs (Project p, WidgetInfo w)
- {
- project = p;
- widget = w;
- }
-
- public Project Project {
- get { return project; }
- }
-
- public WidgetInfo WidgetInfo {
- get { return widget; }
- }
- }
-
-/* public class ComponentNameEventArgs: ComponentEventArgs
- {
- string oldName;
-
- internal ComponentNameEventArgs (Project p, Component c, string oldName): base (p, c)
- {
- this.oldName = oldName;
- }
-
- public string OldName {
- get { return oldName; }
- }
- }
-*/}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetPropertyTree.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetPropertyTree.cs
deleted file mode 100644
index 3409681428..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetPropertyTree.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-
-using System;
-using Gtk;
-
-namespace Stetic
-{
- public class WidgetPropertyTree: PluggableWidget
- {
- internal WidgetPropertyTree (Application app): base (app)
- {
- }
-
- protected override void OnCreatePlug (uint socketId)
- {
- app.Backend.CreatePropertiesWidgetPlug (socketId);
- }
-
- protected override void OnDestroyPlug (uint socketId)
- {
- app.Backend.DestroyPropertiesWidgetPlug ();
- }
-
- protected override Gtk.Widget OnCreateWidget ()
- {
- return app.Backend.GetPropertiesWidget ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetPropertyTreeBackend.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetPropertyTreeBackend.cs
deleted file mode 100644
index d4e7d13a5b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetPropertyTreeBackend.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- internal class WidgetPropertyTreeBackend: PropertyTree, IObjectViewer
- {
- ProjectBackend project;
- Stetic.ObjectWrapper selection;
- Stetic.ObjectWrapper newSelection;
- Stetic.Wrapper.Container.ContainerChild packingSelection;
-
- public WidgetPropertyTreeBackend ()
- {
- Stetic.Registry.RegistryChanging += new EventHandler (OnRegistryChanging);
- }
-
- public ProjectBackend ProjectBackend {
- get { return project; }
- set {
- if (project != null) {
- project.SelectionChanged -= Selected;
- }
-
- project = value;
- if (project != null) {
- TargetObject = project.Selection;
- project.SelectionChanged += Selected;
- } else {
- TargetObject = null;
- }
- }
- }
-
- public override void Clear ()
- {
- base.Clear ();
- Wrapper.Widget selWidget = selection as Wrapper.Widget;
- if (selWidget != null)
- selWidget.Notify -= Notified;
- if (packingSelection != null)
- packingSelection.Notify -= Notified;
- }
-
- protected override void OnObjectChanged ()
- {
- if (selection != null)
- selection.NotifyChanged ();
- }
-
- public object TargetObject {
- get { return selection.Wrapped; }
- set {
- ObjectWrapper wrapper = ObjectWrapper.Lookup (value);
- if (newSelection == wrapper)
- return;
-
- newSelection = wrapper;
- if (newSelection != null)
- GLib.Timeout.Add (50, new GLib.TimeoutHandler (SelectedHandler));
- else
- SelectedHandler ();
- }
- }
-
- void Selected (object s, Wrapper.WidgetEventArgs args)
- {
- TargetObject = args != null && args.Widget != null? args.Widget : null;
- }
-
- bool SelectedHandler ()
- {
- SaveStatus ();
-
- Clear ();
-
- selection = newSelection;
- if (selection == null || selection.Wrapped is ErrorWidget || project == null) {
- return false;
- }
-
- Wrapper.Widget selWidget = selection as Wrapper.Widget;
- if (selWidget != null) {
- selWidget.Notify += Notified;
-
- PropertyDescriptor name = (PropertyDescriptor)Registry.LookupClassByName ("Gtk.Widget") ["Name"];
- AppendProperty (name, selection.Wrapped);
- }
-
- AddProperties (selection.ClassDescriptor.ItemGroups, selection.Wrapped, project.TargetGtkVersion);
-
- if (selWidget != null) {
- packingSelection = Stetic.Wrapper.Container.ChildWrapper (selWidget);
- if (packingSelection != null) {
- ClassDescriptor childklass = packingSelection.ClassDescriptor;
- if (childklass.ItemGroups.Count > 0) {
- AddProperties (childklass.ItemGroups, packingSelection.Wrapped, project.TargetGtkVersion);
- packingSelection.Notify += Notified;
- }
- }
- }
-
- RestoreStatus ();
- return false;
- }
-
- void Notified (object wrapper, string propertyName)
- {
- Update ();
- }
-
- void OnRegistryChanging (object o, EventArgs args)
- {
- Clear ();
- }
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetTree.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetTree.cs
deleted file mode 100644
index 08e692fb0a..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetTree.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-
-using System;
-
-namespace Stetic
-{
- public class WidgetTree: PluggableWidget
- {
- ProjectViewFrontend frontend;
-
- internal WidgetTree (Application app): base (app)
- {
- frontend = new ProjectViewFrontend (app);
- }
-
- public event ComponentEventHandler ComponentActivated {
- add { frontend.ComponentActivated += value; }
- remove { frontend.ComponentActivated -= value; }
- }
-
- public event ComponentEventHandler SelectionChanged {
- add { frontend.SelectionChanged += value; }
- remove { frontend.SelectionChanged -= value; }
- }
-
- protected override void OnCreatePlug (uint socketId)
- {
- app.Backend.CreateProjectWidgetPlug (frontend, socketId);
- }
-
- protected override void OnDestroyPlug (uint socketId)
- {
- app.Backend.DestroyProjectWidgetPlug ();
- }
-
- protected override Gtk.Widget OnCreateWidget ()
- {
- return app.Backend.GetProjectWidget (frontend);
- }
-
- public override void Dispose ()
- {
- frontend.disposed = true;
- System.Runtime.Remoting.RemotingServices.Disconnect (frontend);
- base.Dispose ();
- }
- }
-
-
- internal class ProjectViewFrontend: MarshalByRefObject
- {
- Application app;
- internal bool disposed;
-
- public event ComponentEventHandler ComponentActivated;
- public event ComponentEventHandler SelectionChanged;
-
- public ProjectViewFrontend (Application app)
- {
- this.app = app;
- }
-
- public void NotifyWidgetActivated (object ob, string widgetName, string widgetType)
- {
- Gtk.Application.Invoke (
- delegate {
- if (disposed) return;
- Component c = app.GetComponent (ob, widgetName, widgetType);
- if (c != null && ComponentActivated != null)
- ComponentActivated (null, new ComponentEventArgs (app.ActiveProject, c));
- }
- );
- }
-
- public void NotifySelectionChanged (object ob, string widgetName, string widgetType)
- {
- Gtk.Application.Invoke (
- delegate {
- if (disposed) return;
- Component c = ob != null ? app.GetComponent (ob, widgetName, widgetType) : null;
- if (SelectionChanged != null)
- SelectionChanged (null, new ComponentEventArgs (app.ActiveProject, c));
- }
- );
- }
-
- public override object InitializeLifetimeService ()
- {
- // Will be disconnected when calling Dispose
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetTreeCombo.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetTreeCombo.cs
deleted file mode 100644
index 159f8ec975..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/WidgetTreeCombo.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-
-using System;
-using Gtk;
-
-namespace Stetic
-{
- internal class WidgetTreeCombo: Button
- {
- Label label;
- Image image;
- Stetic.Wrapper.Widget rootWidget;
- Stetic.IProject project;
- Stetic.Wrapper.Widget selection;
- WidgetTreePopup popup;
-
- public WidgetTreeCombo ()
- {
- label = new Label ();
- image = new Gtk.Image ();
-
- HBox bb = new HBox ();
- bb.PackStart (image, false, false, 3);
- bb.PackStart (label, true, true, 3);
- label.Xalign = 0;
- label.HeightRequest = 18;
- bb.PackStart (new VSeparator (), false, false, 1);
- bb.PackStart (new Arrow (ArrowType.Down, ShadowType.None), false, false, 1);
- Child = bb;
- this.WidthRequest = 300;
- Sensitive = false;
- }
-
- public override void Dispose ()
- {
- if (popup != null)
- popup.Destroy ();
- base.Dispose ();
- }
-
-
- public Stetic.Wrapper.Widget RootWidget {
- get { return rootWidget; }
- set {
- rootWidget = value;
- Sensitive = rootWidget != null;
- if (rootWidget != null)
- project = rootWidget.Project;
- Update ();
- }
- }
-
- public void SetSelection (Stetic.Wrapper.Widget widget)
- {
- selection = widget;
- Update ();
- }
-
- void Update ()
- {
- if (selection != null) {
- label.Text = selection.Wrapped.Name;
- image.Pixbuf = selection.ClassDescriptor.Icon.ScaleSimple (16, 16, Gdk.InterpType.Bilinear);
- image.Show ();
- } else {
- label.Text = " ";
- image.Hide ();
- }
- }
-
- protected override void OnPressed ()
- {
- base.OnPressed ();
- if (popup == null) {
- popup = new WidgetTreePopup (project);
- popup.WidgetActivated += OnPopupActivated;
- popup.SetDefaultSize (Allocation.Width, 500);
- }
- else if (popup.Visible) {
- popup.Hide ();
- return;
- }
-
- int x, y;
- ParentWindow.GetOrigin (out x, out y);
- x += Allocation.X;
- y += Allocation.Y + Allocation.Height;
-
- popup.Fill (RootWidget.Wrapped);
- popup.Move (x, y);
- popup.ShowAll ();
- }
-
- protected override bool OnFocusOutEvent (Gdk.EventFocus evnt)
- {
- if (popup != null)
- popup.Hide ();
- return base.OnFocusOutEvent (evnt);
- }
-
-
- void OnPopupActivated (object s, EventArgs a)
- {
- popup.Hide ();
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (popup.Selection);
- GLib.Timeout.Add (10, delegate {
- wrapper.Select ();
- return false;
- });
- }
- }
-
- class WidgetTreePopup: Window
- {
- TreeView tree;
- TreeStore store;
- Gtk.Widget selection;
- Stetic.IProject project;
-
- public event EventHandler WidgetActivated;
-
- public WidgetTreePopup (Stetic.IProject project): base (WindowType.Popup)
- {
- this.project = project;
- Gtk.Frame frame = new Frame ();
- frame.ShadowType = Gtk.ShadowType.Out;
- Add (frame);
-
- Gtk.ScrolledWindow sc = new ScrolledWindow ();
- sc.VscrollbarPolicy = PolicyType.Automatic;
- sc.HscrollbarPolicy = PolicyType.Automatic;
- frame.Add (sc);
-
- tree = new TreeView ();
- store = new TreeStore (typeof(Gdk.Pixbuf), typeof(string), typeof(Widget));
- tree.Model = store;
- tree.HeadersVisible = false;
-
- TreeViewColumn col = new TreeViewColumn ();
- CellRendererPixbuf cr = new CellRendererPixbuf ();
- col.PackStart (cr, false);
- col.AddAttribute (cr, "pixbuf", 0);
-
- CellRendererText tr = new CellRendererText ();
- col.PackStart (tr, true);
- col.AddAttribute (tr, "markup", 1);
-
- tree.AppendColumn (col);
-
- tree.ButtonReleaseEvent += OnButtonRelease;
- tree.RowActivated += OnButtonRelease;
- sc.Add (tree);
- tree.GrabFocus ();
-
- }
-
- public void Fill (Gtk.Widget widget)
- {
- store.Clear ();
- Fill (TreeIter.Zero, widget);
- }
-
- public void Fill (TreeIter iter, Gtk.Widget widget)
- {
- Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (widget);
- if (wrapper == null) return;
-
- if (!wrapper.Unselectable) {
-
- Gdk.Pixbuf icon = wrapper.ClassDescriptor.Icon.ScaleSimple (16, 16, Gdk.InterpType.Bilinear);
- string txt;
- if (widget == project.Selection)
- txt = "<b>" + GLib.Markup.EscapeText (widget.Name) + "</b>";
- else
- txt = GLib.Markup.EscapeText (widget.Name);
-
- if (!iter.Equals (TreeIter.Zero))
- iter = store.AppendValues (iter, icon, txt, widget);
- else
- iter = store.AppendValues (icon, txt, widget);
- }
-
- Gtk.Container cc = widget as Gtk.Container;
- if (cc != null && wrapper.ClassDescriptor.AllowChildren) {
- foreach (Gtk.Widget child in cc.Children)
- Fill (iter, child);
- }
- if (widget == project.Selection) {
- tree.ExpandToPath (store.GetPath (iter));
- tree.ExpandRow (store.GetPath (iter), false);
- tree.Selection.SelectIter (iter);
- }
- }
-
- public Gtk.Widget Selection {
- get { return selection; }
- }
-
- void OnButtonRelease (object s, EventArgs a)
- {
- NotifyActivated ();
- }
-
- void NotifyActivated ()
- {
- TreeIter iter;
- if (!tree.Selection.GetSelected (out iter))
- return;
- selection = (Gtk.Widget) store.GetValue (iter, 2);
- if (WidgetActivated != null)
- WidgetActivated (this, EventArgs.Empty);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Windows/Preview.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Windows/Preview.cs
deleted file mode 100644
index aee001e559..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Windows/Preview.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Gtk;
-using Gdk;
-
-namespace Stetic.Windows
-{
- class Preview: Bin
- {
- Gtk.Widget child;
- WindowsTheme wtheme;
- string caption;
-
- public Preview ( )
- {
- DoubleBuffered = false;
- AppPaintable = true;
- }
-
- public static Preview Create (TopLevelWindow window)
- {
- if (System.IO.Path.DirectorySeparatorChar != '\\')
- return null;
- try {
- Preview p = new Preview ();
- p.Add (window);
- return p;
- }
- catch {
- return null;
- }
- }
-
- public string Title {
- get { return caption; }
- set {
- caption = value;
- QueueDraw ();
- }
- }
-
- protected override void OnDestroyed ( )
- {
- if (wtheme != null)
- wtheme.Dipose ();
- base.OnDestroyed ();
- }
-
- protected override void OnAdded (Widget widget)
- {
- base.OnAdded (widget);
- child = widget;
- if (child is TopLevelWindow) {
- ((TopLevelWindow) child).PropertyChanged += Preview_TitleChanged;
- Title = ((TopLevelWindow) child).Title;
- }
- }
-
- void Preview_TitleChanged (object sender, EventArgs e)
- {
- Title = ((TopLevelWindow) child).Title;
- }
-
- protected override void OnRemoved (Widget widget)
- {
- base.OnRemoved (widget);
- if (widget == child) {
- if (child is TopLevelWindow)
- ((TopLevelWindow) child).PropertyChanged -= Preview_TitleChanged;
- child = null;
- }
- }
-
- protected override void OnSizeRequested (ref Requisition requisition)
- {
- if (child != null)
- requisition = child.SizeRequest ();
- }
-
- protected override void OnSizeAllocated (Gdk.Rectangle allocation)
- {
- base.OnSizeAllocated (allocation);
- if (child != null) {
- if (wtheme != null)
- child.Allocation = wtheme.GetWindowClientArea (allocation);
- else
- child.Allocation = allocation;
- }
- }
-
- protected override void OnRealized ( )
- {
- base.OnRealized ();
- wtheme = new WindowsTheme (GdkWindow);
- if (child != null)
- child.Allocation = wtheme.GetWindowClientArea (Allocation);
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose evnt)
- {
-// Gdk.Rectangle rect = new Gdk.Rectangle (Allocation.X+50, Allocation.Y+50, Allocation.Width - 1, Allocation.Height - 1);
- wtheme.DrawWindowFrame (this, caption, Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
- foreach (Widget child in Children)
- PropagateExpose (child, evnt);
- return false;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Windows/WindowsTheme.cs b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Windows/WindowsTheme.cs
deleted file mode 100644
index bdc4a3a1eb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/Windows/WindowsTheme.cs
+++ /dev/null
@@ -1,201 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Runtime.InteropServices;
-
-namespace Stetic.Windows
-{
- class WindowsTheme
- {
- IntPtr hWnd;
- IntPtr hTheme;
-
- public WindowsTheme (Gdk.Window win)
- {
- hWnd = gdk_win32_drawable_get_handle (win.Handle);
- hTheme = OpenThemeData (hWnd, "WINDOW");
- }
-
- public void Dipose ( )
- {
- CloseThemeData (hTheme);
- }
-
- public void DrawWindowFrame (Gtk.Widget w, string caption, int x, int y, int width, int height)
- {
- Gdk.Drawable drawable = w.GdkWindow;
- Gdk.Pixmap pix = new Gdk.Pixmap (drawable, width, height, drawable.Depth);
-
- Gdk.GC gcc = new Gdk.GC (pix);
- gcc.Foreground = w.Style.Backgrounds [(int)Gtk.StateType.Normal];
- pix.DrawRectangle (gcc, true, 0, 0, width, height);
-
- IntPtr hdc = gdk_win32_hdc_get (pix.Handle, gcc.Handle, 0);
-
- RECT r = new RECT (0, 0, width, height);
- SIZE size;
- GetThemePartSize (hTheme, hdc, WP_CAPTION, CS_ACTIVE, ref r, 1, out size);
-
- r.Bottom = size.cy;
- DrawThemeBackground (hTheme, hdc, WP_CAPTION, CS_ACTIVE, ref r, ref r);
-
- RECT rf = new RECT (FrameBorder, FrameBorder, width - FrameBorder * 2, size.cy);
- LOGFONT lf = new LOGFONT ();
- GetThemeSysFont (hTheme, TMT_CAPTIONFONT, ref lf);
- IntPtr titleFont = CreateFontIndirect (ref lf);
- IntPtr oldFont = SelectObject (hdc, titleFont);
- SetBkMode (hdc, 1 /*TRANSPARENT*/);
- DrawThemeText (hTheme, hdc, WP_CAPTION, CS_ACTIVE, caption, -1, DT_LEFT | DT_SINGLELINE | DT_WORD_ELLIPSIS, 0, ref rf);
- SelectObject (hdc, oldFont);
- DeleteObject (titleFont);
-
- int ny = r.Bottom;
- r = new RECT (0, ny, width, height);
- DrawThemeBackground (hTheme, hdc, WP_FRAMEBOTTOM, 0, ref r, ref r);
-
- gdk_win32_hdc_release (pix.Handle, gcc.Handle, 0);
-
- Gdk.Pixbuf img = Gdk.Pixbuf.FromDrawable (pix, pix.Colormap, 0, 0, 0, 0, width, height);
- drawable.DrawPixbuf (new Gdk.GC (drawable), img, 0, 0, x, y, width, height, Gdk.RgbDither.None, 0, 0);
- drawable.DrawRectangle (w.Style.BackgroundGC (Gtk.StateType.Normal), true, x + FrameBorder, y + size.cy, width - FrameBorder * 2, height - FrameBorder - size.cy);
- }
-
- public Gdk.Rectangle GetWindowClientArea (Gdk.Rectangle allocation)
- {
- IntPtr hdc = GetDC (hWnd);
- RECT r = new RECT (allocation.X, allocation.Y, allocation.X + allocation.Width, allocation.Y + allocation.Height);
- SIZE size;
- GetThemePartSize (hTheme, hdc, WP_CAPTION, CS_ACTIVE, ref r, 1, out size);
- ReleaseDC (hWnd, hdc);
-
- return new Gdk.Rectangle (allocation.X + FrameBorder, allocation.Y + size.cy, allocation.Width - FrameBorder * 2, allocation.Height - size.cy - FrameBorder);
- }
-
- const int FrameBorder = 8;
-
- const int WP_CAPTION = 1;
- const int WP_FRAMEBOTTOM = 9;
- const int CS_ACTIVE = 1;
- const int TMT_CAPTIONFONT = 801;
-
- const int DT_LEFT = 0x0;
- const int DT_WORD_ELLIPSIS = 0x40000;
- const int DT_SINGLELINE = 0x20;
-
-
- [DllImport ("uxtheme", ExactSpelling = true)]
- extern static Int32 DrawThemeBackground (IntPtr hTheme, IntPtr hdc, int iPartId,
- int iStateId, ref RECT pRect, ref RECT pClipRect);
-
- [DllImport ("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
- static extern IntPtr OpenThemeData (IntPtr hWnd, String classList);
-
- [DllImport ("uxtheme.dll", ExactSpelling = true)]
- extern static Int32 CloseThemeData (IntPtr hTheme);
-
- [DllImport ("uxtheme", ExactSpelling = true)]
- extern static Int32 GetThemePartSize (IntPtr hTheme, IntPtr hdc, int part, int state, ref RECT pRect, int eSize, out SIZE size);
-
- [DllImport ("uxtheme", ExactSpelling = true)]
- extern static Int32 GetThemeBackgroundExtent (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pBoundingRect, out RECT pContentRect);
-
- [DllImport ("uxtheme", ExactSpelling = true)]
- extern static Int32 GetThemeMargins (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, out MARGINS pMargins);
-
- [DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
- extern static Int32 DrawThemeText (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, String text, int textLength, UInt32 textFlags, UInt32 textFlags2, ref RECT pRect);
-
- [DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
- extern static Int32 GetThemeSysFont (IntPtr hTheme, int iFontId, ref LOGFONT plf);
-
- [DllImport ("gdi32.dll")]
- static extern IntPtr CreateFontIndirect ([In] ref LOGFONT lplf);
-
- [DllImport ("gdi32.dll")]
- static extern int SetBkMode (IntPtr hdc, int iBkMode);
-
- [DllImport ("gdi32.dll", ExactSpelling = true, PreserveSig = true, SetLastError = true)]
- static extern IntPtr SelectObject (IntPtr hdc, IntPtr hgdiobj);
-
- [DllImport ("gdi32.dll")]
- static extern bool DeleteObject (IntPtr hObject);
-
- [DllImport ("user32.dll")]
- static extern IntPtr GetDC (IntPtr hWnd);
-
- [DllImport ("user32.dll")]
- static extern int ReleaseDC (IntPtr hWnd, IntPtr hDC);
-
- [DllImport ("libgdk-win32-2.0-0.dll")]
- static extern IntPtr gdk_win32_drawable_get_handle (IntPtr raw);
-
- [DllImport ("libgdk-win32-2.0-0.dll")]
- static extern IntPtr gdk_win32_hdc_get (IntPtr drawable, IntPtr gc, int usage);
-
- [DllImport ("libgdk-win32-2.0-0.dll")]
- static extern void gdk_win32_hdc_release (IntPtr drawable, IntPtr gc, int usage);
- }
-
-
- [Serializable, StructLayout (LayoutKind.Sequential)]
- public struct RECT
- {
- public int Left;
- public int Top;
- public int Right;
- public int Bottom;
-
- public RECT (int left_, int top_, int right_, int bottom_)
- {
- Left = left_;
- Top = top_;
- Right = right_;
- Bottom = bottom_;
- }
-
- public int Height { get { return Bottom - Top; } }
- public int Width { get { return Right - Left; } }
- }
-
- [StructLayout (LayoutKind.Sequential)]
- public struct SIZE
- {
- public int cx;
- public int cy;
-
- public SIZE (int cx, int cy)
- {
- this.cx = cx;
- this.cy = cy;
- }
- }
-
- [StructLayout (LayoutKind.Sequential)]
- public struct MARGINS
- {
- public int leftWidth;
- public int rightWidth;
- public int topHeight;
- public int bottomHeight;
- }
-
- [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Auto)]
- public struct LOGFONT
- {
- public int lfHeight;
- public int lfWidth;
- public int lfEscapement;
- public int lfOrientation;
- public int lfWeight;
- public byte lfItalic;
- public byte lfUnderline;
- public byte lfStrikeOut;
- public byte lfCharSet;
- public byte lfOutPrecision;
- public byte lfClipPrecision;
- public byte lfQuality;
- public byte lfPitchAndFamily;
- [MarshalAs (UnmanagedType.ByValTStr, SizeConst = 32)]
- public string lfFaceName;
- }
-}
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/action.png b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/action.png
deleted file mode 100644
index fa6a6c8a12..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/action.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/bin/Release/libstetic2.dll.config b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/bin/Release/libstetic2.dll.config
deleted file mode 100644
index 8c4c6ab9a9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/bin/Release/libstetic2.dll.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<configuration>
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.dylib" os="osx" />
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.dylib" os="osx"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.dylib" os="osx"/>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/bin/Release/libsteticui2.dll.config b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/bin/Release/libsteticui2.dll.config
deleted file mode 100644
index 8c4c6ab9a9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/bin/Release/libsteticui2.dll.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<configuration>
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.dylib" os="osx" />
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.dylib" os="osx"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.dylib" os="osx"/>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui.csproj b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui.csproj
deleted file mode 100644
index 3814bcf1ed..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui.csproj
+++ /dev/null
@@ -1,156 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}</ProjectGuid>
- <OutputType>Library</OutputType>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <AssemblyName>libsteticui2</AssemblyName>
- <RootNamespace>libsteticui</RootNamespace>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.GtkCore2</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <additionalargs>-unsafe</additionalargs>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Mono.Posix" />
- <Reference Include="System" />
- <Reference Include="System.Runtime.Remoting" />
- <Reference Include="System.Xml" />
- <Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\..\contrib\Mono.Cecil\Mono.Cecil.csproj">
- <Project>{3EC06433-F168-4C5B-A885-99CE4AB617E1}</Project>
- <Name>Mono.Cecil</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\..\MonoDevelop.GtkCore2\libstetic\libstetic.csproj">
- <Project>{F870E2E7-FA64-4B2F-968A-90B36AB7AAA9}</Project>
- <Name>libstetic2</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ActionComponent.cs" />
- <Compile Include="ActionGroupComponent.cs" />
- <Compile Include="ActionGroupDesigner.cs" />
- <Compile Include="ActionGroupDesignerBackend.cs" />
- <Compile Include="ActionGroupEditSession.cs" />
- <Compile Include="ActionGroupToolbar.cs" />
- <Compile Include="Application.cs" />
- <Compile Include="ApplicationBackend.cs" />
- <Compile Include="ApplicationBackendController.cs" />
- <Compile Include="AssemblyResolver.cs" />
- <Compile Include="AssemblyWidgetLibrary.cs" />
- <Compile Include="CecilClassDescriptor.cs" />
- <Compile Include="CecilPropertyDescriptor.cs" />
- <Compile Include="CecilSignalDescriptor.cs" />
- <Compile Include="CecilWidgetLibrary.cs" />
- <Compile Include="CodeGenerationResult.cs" />
- <Compile Include="CodeGenerator.cs" />
- <Compile Include="CodeGeneratorInternalClass.cs" />
- <Compile Include="CodeGeneratorPartialClass.cs" />
- <Compile Include="Component.cs" />
- <Compile Include="ComponentEventHandler.cs" />
- <Compile Include="ComponentSignalEventHandler.cs" />
- <Compile Include="ComponentType.cs" />
- <Compile Include="ContainerUndoRedoManager.cs" />
- <Compile Include="ContextMenu.cs" />
- <Compile Include="Designer.cs" />
- <Compile Include="Glade.cs" />
- <Compile Include="Grid.cs" />
- <Compile Include="GuiDispatchServerSink.cs" />
- <Compile Include="GuiDispatchServerSinkProvider.cs" />
- <Compile Include="LibraryCache.cs" />
- <Compile Include="Metacity\ButtonFunction.cs" />
- <Compile Include="Metacity\ButtonLayout.cs" />
- <Compile Include="Metacity\FrameFlags.cs" />
- <Compile Include="Metacity\FrameType.cs" />
- <Compile Include="Metacity\ObjectManager.cs" />
- <Compile Include="Metacity\Preview.cs" />
- <Compile Include="Metacity\Theme.cs" />
- <Compile Include="Palette.cs" />
- <Compile Include="PaletteBackend.cs" />
- <Compile Include="PluggableWidget.cs" />
- <Compile Include="Project.cs" />
- <Compile Include="ProjectBackend.cs" />
- <Compile Include="ProjectViewBackend.cs" />
- <Compile Include="PropertyEditor.cs" />
- <Compile Include="PropertyGrid.cs" />
- <Compile Include="PropertyTree.cs" />
- <Compile Include="Shadow.cs" />
- <Compile Include="SignalsEditor.cs" />
- <Compile Include="SignalsEditorBackend.cs" />
- <Compile Include="UndoQueue.cs" />
- <Compile Include="UserInterface.cs" />
- <Compile Include="WidgetActionBar.cs" />
- <Compile Include="WidgetComponent.cs" />
- <Compile Include="WidgetDesigner.cs" />
- <Compile Include="WidgetDesignerBackend.cs" />
- <Compile Include="WidgetEditSession.cs" />
- <Compile Include="WidgetFactory.cs" />
- <Compile Include="WidgetInfoEventHandler.cs" />
- <Compile Include="WidgetPropertyTree.cs" />
- <Compile Include="WidgetPropertyTreeBackend.cs" />
- <Compile Include="WidgetTree.cs" />
- <Compile Include="WidgetTreeCombo.cs" />
- <Compile Include="Windows\Preview.cs" />
- <Compile Include="Windows\WindowsTheme.cs" />
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="action.png">
- <LogicalName>action.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="missing.png">
- <LogicalName>missing.png</LogicalName>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <None Include="libsteticui.dll.config">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui.dll.config b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui.dll.config
deleted file mode 100644
index 8c4c6ab9a9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui.dll.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<configuration>
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.dylib" os="osx" />
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.dylib" os="osx"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.dylib" os="osx"/>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui2.csproj b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui2.csproj
deleted file mode 100644
index f8b48230c8..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui2.csproj
+++ /dev/null
@@ -1,172 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}</ProjectGuid>
- <OutputType>Library</OutputType>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <AssemblyName>libsteticui2</AssemblyName>
- <RootNamespace>libsteticui</RootNamespace>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.GtkCore2</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <additionalargs>-unsafe</additionalargs>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Mono.Posix" />
- <Reference Include="System" />
- <Reference Include="System.Runtime.Remoting" />
- <Reference Include="System.Xml" />
- <Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="System.Core" />
- <Reference Include="Mono.Cecil, Version=0.6.9.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="MonoDevelop.Core, Version=2.4.0.0, Culture=neutral">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="MonoDevelop.Ide, Version=2.4.0.0, Culture=neutral">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="NRefactory, Version=2.1.1.0, Culture=neutral, PublicKeyToken=efe927acf176eea2">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="Mono.TextEditor, Version=1.0.0.0, Culture=neutral">
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="Mono.Debugging, Version=0.0.0.0, Culture=neutral, PublicKeyToken=9307d64546e0580d">
- <Package>monodevelop</Package>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\libstetic\libstetic2.csproj">
- <Project>{90CBA7FD-CB46-4711-97BB-2420DC01F016}</Project>
- <Name>libstetic2</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ActionComponent.cs" />
- <Compile Include="ActionGroupComponent.cs" />
- <Compile Include="ActionGroupDesigner.cs" />
- <Compile Include="ActionGroupDesignerBackend.cs" />
- <Compile Include="ActionGroupEditSession.cs" />
- <Compile Include="ActionGroupToolbar.cs" />
- <Compile Include="Application.cs" />
- <Compile Include="ApplicationBackend.cs" />
- <Compile Include="ApplicationBackendController.cs" />
- <Compile Include="AssemblyResolver.cs" />
- <Compile Include="AssemblyWidgetLibrary.cs" />
- <Compile Include="CecilClassDescriptor.cs" />
- <Compile Include="CecilPropertyDescriptor.cs" />
- <Compile Include="CecilSignalDescriptor.cs" />
- <Compile Include="CecilWidgetLibrary.cs" />
- <Compile Include="CodeGenerationResult.cs" />
- <Compile Include="CodeGenerator.cs" />
- <Compile Include="CodeGeneratorPartialClass.cs" />
- <Compile Include="Component.cs" />
- <Compile Include="ComponentEventHandler.cs" />
- <Compile Include="ComponentSignalEventHandler.cs" />
- <Compile Include="ComponentType.cs" />
- <Compile Include="ContainerUndoRedoManager.cs" />
- <Compile Include="ContextMenu.cs" />
- <Compile Include="Designer.cs" />
- <Compile Include="Glade.cs" />
- <Compile Include="Grid.cs" />
- <Compile Include="GuiDispatchServerSink.cs" />
- <Compile Include="GuiDispatchServerSinkProvider.cs" />
- <Compile Include="LibraryCache.cs" />
- <Compile Include="Metacity\ButtonFunction.cs" />
- <Compile Include="Metacity\ButtonLayout.cs" />
- <Compile Include="Metacity\FrameFlags.cs" />
- <Compile Include="Metacity\FrameType.cs" />
- <Compile Include="Metacity\ObjectManager.cs" />
- <Compile Include="Metacity\Preview.cs" />
- <Compile Include="Metacity\Theme.cs" />
- <Compile Include="Palette.cs" />
- <Compile Include="PaletteBackend.cs" />
- <Compile Include="PluggableWidget.cs" />
- <Compile Include="Project.cs" />
- <Compile Include="ProjectBackend.cs" />
- <Compile Include="ProjectViewBackend.cs" />
- <Compile Include="PropertyEditor.cs" />
- <Compile Include="PropertyGrid.cs" />
- <Compile Include="PropertyTree.cs" />
- <Compile Include="Shadow.cs" />
- <Compile Include="SignalsEditor.cs" />
- <Compile Include="SignalsEditorBackend.cs" />
- <Compile Include="UndoQueue.cs" />
- <Compile Include="UserInterface.cs" />
- <Compile Include="WidgetActionBar.cs" />
- <Compile Include="WidgetComponent.cs" />
- <Compile Include="WidgetDesigner.cs" />
- <Compile Include="WidgetDesignerBackend.cs" />
- <Compile Include="WidgetEditSession.cs" />
- <Compile Include="WidgetFactory.cs" />
- <Compile Include="WidgetInfoEventHandler.cs" />
- <Compile Include="WidgetPropertyTree.cs" />
- <Compile Include="WidgetPropertyTreeBackend.cs" />
- <Compile Include="WidgetTree.cs" />
- <Compile Include="WidgetTreeCombo.cs" />
- <Compile Include="Windows\Preview.cs" />
- <Compile Include="Windows\WindowsTheme.cs" />
- <Compile Include="IProjectDesignInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="action.png">
- <LogicalName>action.png</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="missing.png">
- <LogicalName>missing.png</LogicalName>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <None Include="libsteticui2.dll.config">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <Folder Include="Windows\" />
- </ItemGroup>
-</Project>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui2.dll.config b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui2.dll.config
deleted file mode 100644
index 8c4c6ab9a9..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/libsteticui2.dll.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<configuration>
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="!osx,windows" />
- <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.dylib" os="osx" />
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-quartz-2.0.dylib" os="osx"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0" os="!osx,windows"/>
- <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-quartz-2.0.dylib" os="osx"/>
-</configuration>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/missing.png b/main/src/addins/MonoDevelop.GtkCore2/libsteticui/missing.png
deleted file mode 100644
index 589da692bb..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/libsteticui/missing.png
+++ /dev/null
Binary files differ
diff --git a/main/src/addins/MonoDevelop.GtkCore2/monodevelop-slim.sln b/main/src/addins/MonoDevelop.GtkCore2/monodevelop-slim.sln
deleted file mode 100644
index cf252d90be..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/monodevelop-slim.sln
+++ /dev/null
@@ -1,146 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Core", "..\main\src\core\MonoDevelop.Core\MonoDevelop.Core.csproj", "{7525BB88-6142-4A26-93B9-A30C6983390A}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Projects.Formats.MSBuild", "..\main\src\core\MonoDevelop.Projects.Formats.MSBuild\MonoDevelop.Projects.Formats.MSBuild.csproj", "{A437F1A3-78DF-4F00-8053-D32A8B1EB679}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "..\main\contrib\Mono.Cecil\Mono.Cecil\Mono.Cecil.csproj", "{D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Mdb", "..\main\contrib\Mono.Cecil\Mono.Cecil.Mdb.csproj", "{201F7AC0-D2D5-4F51-85A8-17475DADBED3}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.TextEditor", "..\main\src\core\Mono.Texteditor\Mono.TextEditor.csproj", "{A2329308-3751-4DBD-9A75-5F7B8B024625}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Debugging", "..\main\src\core\Mono.Debugging\Mono.Debugging.csproj", "{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\main\contrib\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Ide", "..\main\src\core\MonoDevelop.Ide\MonoDevelop.Ide.csproj", "{27096E7F-C91C-4AC6-B289-6897A701DF21}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Startup", "..\main\src\core\MonoDevelop.Startup\MonoDevelop.Startup.csproj", "{DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.DesignerSupport", "..\main\src\addins\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.csproj", "{2C24D515-4A2C-445C-8419-C09231913CFA}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Deployment", "..\main\src\addins\Deployment\MonoDevelop.Deployment\MonoDevelop.Deployment.csproj", "{9BC670A8-1851-40EC-9685-279F4C98433D}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "stetic2", "stetic2", "{FA38092D-B853-42E3-B7B7-D88A57F97BE9}"
- ProjectSection(MonoDevelopProperties) = preProject
- Policies = $0
- $0.VersionControlPolicy = $1
- $1.inheritsSet = Mono
- $0.ChangeLogPolicy = $2
- $2.UpdateMode = ProjectRoot
- $2.MessageStyle = $3
- $3.LineAlign = 0
- $2.inheritsSet = Mono
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libstetic2", "..\main\src\addins\MonoDevelop.GtkCore2\libstetic\libstetic2.csproj", "{90CBA7FD-CB46-4711-97BB-2420DC01F016}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsteticui2", "..\main\src\addins\MonoDevelop.GtkCore2\libsteticui\libsteticui2.csproj", "{8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GtkCore2", "..\main\src\addins\MonoDevelop.GtkCore2\MonoDevelop.GtkCore2.csproj", "{4F2E994F-E4F5-407A-8D80-80E3377DEF6E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Debugger", "..\main\src\addins\MonoDevelop.Debugger\MonoDevelop.Debugger.csproj", "{2357AABD-08C7-4808-A495-8FF2D3CDFDB0}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Refactoring", "..\main\src\addins\MonoDevelop.Refactoring\MonoDevelop.Refactoring.csproj", "{100568FC-F4E8-439B-94AD-41D11724E45B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- Debug|x86 = Debug|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {100568FC-F4E8-439B-94AD-41D11724E45B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {100568FC-F4E8-439B-94AD-41D11724E45B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {100568FC-F4E8-439B-94AD-41D11724E45B}.Debug|x86.ActiveCfg = Debug|Any CPU
- {100568FC-F4E8-439B-94AD-41D11724E45B}.Debug|x86.Build.0 = Debug|Any CPU
- {100568FC-F4E8-439B-94AD-41D11724E45B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {100568FC-F4E8-439B-94AD-41D11724E45B}.Release|Any CPU.Build.0 = Release|Any CPU
- {201F7AC0-D2D5-4F51-85A8-17475DADBED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {201F7AC0-D2D5-4F51-85A8-17475DADBED3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {201F7AC0-D2D5-4F51-85A8-17475DADBED3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {201F7AC0-D2D5-4F51-85A8-17475DADBED3}.Release|Any CPU.Build.0 = Release|Any CPU
- {2357AABD-08C7-4808-A495-8FF2D3CDFDB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2357AABD-08C7-4808-A495-8FF2D3CDFDB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2357AABD-08C7-4808-A495-8FF2D3CDFDB0}.Debug|x86.ActiveCfg = Debug|Any CPU
- {2357AABD-08C7-4808-A495-8FF2D3CDFDB0}.Debug|x86.Build.0 = Debug|Any CPU
- {2357AABD-08C7-4808-A495-8FF2D3CDFDB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2357AABD-08C7-4808-A495-8FF2D3CDFDB0}.Release|Any CPU.Build.0 = Release|Any CPU
- {27096E7F-C91C-4AC6-B289-6897A701DF21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {27096E7F-C91C-4AC6-B289-6897A701DF21}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {27096E7F-C91C-4AC6-B289-6897A701DF21}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {27096E7F-C91C-4AC6-B289-6897A701DF21}.Release|Any CPU.Build.0 = Release|Any CPU
- {2C24D515-4A2C-445C-8419-C09231913CFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2C24D515-4A2C-445C-8419-C09231913CFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2C24D515-4A2C-445C-8419-C09231913CFA}.Debug|x86.ActiveCfg = Debug|Any CPU
- {2C24D515-4A2C-445C-8419-C09231913CFA}.Debug|x86.Build.0 = Debug|Any CPU
- {2C24D515-4A2C-445C-8419-C09231913CFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2C24D515-4A2C-445C-8419-C09231913CFA}.Release|Any CPU.Build.0 = Release|Any CPU
- {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Debug|x86.ActiveCfg = Debug|Any CPU
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Debug|x86.Build.0 = Debug|Any CPU
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E}.Release|Any CPU.Build.0 = Release|Any CPU
- {7525BB88-6142-4A26-93B9-A30C6983390A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7525BB88-6142-4A26-93B9-A30C6983390A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7525BB88-6142-4A26-93B9-A30C6983390A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7525BB88-6142-4A26-93B9-A30C6983390A}.Release|Any CPU.Build.0 = Release|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Debug|x86.ActiveCfg = Debug|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Debug|x86.Build.0 = Debug|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0}.Release|Any CPU.Build.0 = Release|Any CPU
- {90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Debug|x86.ActiveCfg = Debug|Any CPU
- {90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Debug|x86.Build.0 = Debug|Any CPU
- {90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Release|Any CPU.Build.0 = Release|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Debug|x86.ActiveCfg = Debug|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Debug|x86.Build.0 = Debug|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {90CBA7FD-CB46-4711-97BB-2420DC01F016}.Release|Any CPU.Build.0 = Release|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.Debug|x86.ActiveCfg = Debug|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.Debug|x86.Build.0 = Debug|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.Release|Any CPU.Build.0 = Release|Any CPU
- {A2329308-3751-4DBD-9A75-5F7B8B024625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A2329308-3751-4DBD-9A75-5F7B8B024625}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A2329308-3751-4DBD-9A75-5F7B8B024625}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A2329308-3751-4DBD-9A75-5F7B8B024625}.Release|Any CPU.Build.0 = Release|Any CPU
- {A437F1A3-78DF-4F00-8053-D32A8B1EB679}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A437F1A3-78DF-4F00-8053-D32A8B1EB679}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A437F1A3-78DF-4F00-8053-D32A8B1EB679}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A437F1A3-78DF-4F00-8053-D32A8B1EB679}.Release|Any CPU.Build.0 = Release|Any CPU
- {D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}.Release|Any CPU.Build.0 = Release|Any CPU
- {DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}.Debug|x86.ActiveCfg = Debug|x86
- {DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}.Debug|x86.Build.0 = Debug|x86
- {DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DA8EDEA6-7DA8-435D-B1A0-F3A0CA07F424}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {90CBA7FD-CB46-4711-97BB-2420DC01F016} = {FA38092D-B853-42E3-B7B7-D88A57F97BE9}
- {8951D80F-B2D6-4B4E-B119-28FFE3B7B1C0} = {FA38092D-B853-42E3-B7B7-D88A57F97BE9}
- {4F2E994F-E4F5-407A-8D80-80E3377DEF6E} = {FA38092D-B853-42E3-B7B7-D88A57F97BE9}
- EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = ..\main\src\core\MonoDevelop.Startup\MonoDevelop.Startup.csproj
- EndGlobalSection
-EndGlobal
diff --git a/main/src/addins/MonoDevelop.GtkCore2/templates/ActionGroup.xft.xml b/main/src/addins/MonoDevelop.GtkCore2/templates/ActionGroup.xft.xml
deleted file mode 100644
index e0214ea640..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/templates/ActionGroup.xft.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0"?>
-<Template Originator="Lluis Sanchez" Created="3/09/2001" LastModified="3/09/2001">
-
- <TemplateConfiguration>
- <_Name>ActionGroup</_Name>
- <Icon>md-gui-file</Icon>
- <_Category>Gtk</_Category>
- <LanguageName>*</LanguageName>
- <_Description>Creates a global Action Group.</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- <PartialTypeSupport Requirement="Disabled" />
- </Conditions>
-
- <TemplateFiles>
- <Widget DefaultName="${Name}">
- <SteticTemplate>
- <action-group name="${FullName}">
- </action-group>
- </SteticTemplate>
- <CodeDomFile>
- <CompileUnit>
- <Namespaces>
- <Namespace Name="">
- <Imports>
- <NamespaceImport Namespace="System" />
- </Imports>
- </Namespace>
- <Namespace Name="${Namespace}">
- <Types>
- <TypeDeclaration Name="${Name}" IsClass="true">
- <BaseTypes>
- <TypeReference BaseType="Gtk.ActionGroup" />
- </BaseTypes>
- <Members>
- <Constructor Attributes="Public, Final">
- <BaseConstructorArgs>
- <PrimitiveExpression Value="${FullName}"/>
- </BaseConstructorArgs>
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="Build">
- <TargetObject>
- <TypeReferenceExpression Type="Stetic.Gui" />
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- <Parameters>
- <ThisReferenceExpression/>
- <TypeOfExpression Type="${FullName}" />
- </Parameters>
- </MethodInvokeExpression>
- </Statements>
- </Constructor>
- </Members>
- </TypeDeclaration>
- </Types>
- </Namespace>
- </Namespaces>
- </CompileUnit>
- </CodeDomFile>
- </Widget>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/templates/ActionGroupPartial.xft.xml b/main/src/addins/MonoDevelop.GtkCore2/templates/ActionGroupPartial.xft.xml
deleted file mode 100644
index 5f8d81245b..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/templates/ActionGroupPartial.xft.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0"?>
-<Template Originator="Lluis Sanchez" Created="3/09/2001" LastModified="3/09/2001">
-
- <TemplateConfiguration>
- <_Name>ActionGroup</_Name>
- <Icon>md-gui-file</Icon>
- <_Category>Gtk</_Category>
- <LanguageName>*</LanguageName>
- <_Description>Creates a global Action Group.</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- <PartialTypeSupport Requirement="Enabled" />
- </Conditions>
-
- <TemplateFiles>
- <Widget DefaultName="${Name}">
- <SteticTemplate>
- <action-group name="${FullName}">
- </action-group>
- </SteticTemplate>
- <CodeDomFile>
- <CompileUnit>
- <Namespaces>
- <Namespace Name="">
- <Imports>
- <NamespaceImport Namespace="System" />
- </Imports>
- </Namespace>
- <Namespace Name="${Namespace}">
- <Types>
- <TypeDeclaration Name="${Name}" IsClass="true" IsPartial="true">
- <BaseTypes>
- <TypeReference BaseType="Gtk.ActionGroup" />
- </BaseTypes>
- <Members>
- <Constructor Attributes="Public, Final">
- <BaseConstructorArgs>
- <PrimitiveExpression Value="${FullName}"/>
- </BaseConstructorArgs>
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="Build">
- <TargetObject>
- <ThisReferenceExpression/>
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- </MethodInvokeExpression>
- </Statements>
- </Constructor>
- </Members>
- </TypeDeclaration>
- </Types>
- </Namespace>
- </Namespaces>
- </CompileUnit>
- </CodeDomFile>
- </Widget>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/templates/Dialog.xft.xml b/main/src/addins/MonoDevelop.GtkCore2/templates/Dialog.xft.xml
deleted file mode 100644
index dd1f056707..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/templates/Dialog.xft.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0"?>
-<Template Originator="Lluis Sanchez" Created="3/09/2001" LastModified="3/09/2001">
-
- <TemplateConfiguration>
- <_Name>Dialog</_Name>
- <Icon>md-gui-file</Icon>
- <_Category>Gtk</_Category>
- <LanguageName>*</LanguageName>
- <_Description>Creates a Gtk dialog.</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- <PartialTypeSupport Requirement="Disabled" />
- </Conditions>
-
- <TemplateFiles>
- <Widget DefaultName="${Name}">
- <SteticTemplate>
- <widget class="Gtk.Dialog" id="${FullName}" design-size="400 300">
- <property name="Events">0</property>
- <property name="Title" translatable="yes">dialog1</property>
- <property name="WindowPosition">CenterOnParent</property>
- <property name="Buttons">2</property>
- <property name="HelpButton">False</property>
- <property name="HasSeparator">False</property>
- <child internal-child="VBox">
- <widget class="Gtk.VBox" id="dialog1_VBox">
- <property name="MemberName" />
- <property name="Events">0</property>
- <property name="BorderWidth">2</property>
- <child>
- <placeholder />
- </child>
- </widget>
- </child>
- <child internal-child="ActionArea">
- <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
- <property name="MemberName" />
- <property name="Events">0</property>
- <property name="Spacing">10</property>
- <property name="BorderWidth">5</property>
- <property name="Size">2</property>
- <property name="LayoutStyle">End</property>
- <child>
- <widget class="Gtk.Button" id="buttonCancel">
- <property name="MemberName" />
- <property name="CanDefault">True</property>
- <property name="CanFocus">True</property>
- <property name="Events">0</property>
- <property name="UseStock">True</property>
- <property name="Type">StockItem</property>
- <property name="StockId">gtk-cancel</property>
- <property name="IsDialogButton">True</property>
- <property name="ResponseId">-6</property>
- <property name="label">gtk-cancel</property>
- </widget>
- <packing>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Button" id="buttonOk">
- <property name="MemberName" />
- <property name="CanDefault">True</property>
- <property name="CanFocus">True</property>
- <property name="Events">0</property>
- <property name="UseStock">True</property>
- <property name="Type">StockItem</property>
- <property name="StockId">gtk-ok</property>
- <property name="IsDialogButton">True</property>
- <property name="ResponseId">-5</property>
- <property name="label">gtk-ok</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </SteticTemplate>
- <CodeDomFile>
- <CompileUnit>
- <Namespaces>
- <Namespace Name="">
- <Imports>
- <NamespaceImport Namespace="System" />
- </Imports>
- </Namespace>
- <Namespace Name="${Namespace}">
- <Types>
- <TypeDeclaration Name="${Name}" IsClass="true">
- <BaseTypes>
- <TypeReference BaseType="Gtk.Dialog" />
- </BaseTypes>
- <Members>
- <Constructor Attributes="Public, Final">
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="Build">
- <TargetObject>
- <TypeReferenceExpression Type="Stetic.Gui" />
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- <Parameters>
- <ThisReferenceExpression/>
- <TypeOfExpression Type="${FullName}" />
- </Parameters>
- </MethodInvokeExpression>
- </Statements>
- </Constructor>
- </Members>
- </TypeDeclaration>
- </Types>
- </Namespace>
- </Namespaces>
- </CompileUnit>
- </CodeDomFile>
- </Widget>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/templates/DialogPartial.xft.xml b/main/src/addins/MonoDevelop.GtkCore2/templates/DialogPartial.xft.xml
deleted file mode 100644
index 3fb9feee35..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/templates/DialogPartial.xft.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-<?xml version="1.0"?>
-<Template Originator="Lluis Sanchez" Created="3/09/2001" LastModified="3/09/2001">
-
- <TemplateConfiguration>
- <_Name>Dialog</_Name>
- <Icon>md-gui-file</Icon>
- <_Category>Gtk</_Category>
- <LanguageName>*</LanguageName>
- <_Description>Creates a Gtk dialog.</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- <PartialTypeSupport Requirement="Enabled" />
- </Conditions>
-
- <TemplateFiles>
- <Widget DefaultName="${Name}">
- <SteticTemplate>
- <widget class="Gtk.Dialog" id="${FullName}" design-size="400 300">
- <property name="Events">0</property>
- <property name="Title" translatable="yes">dialog1</property>
- <property name="WindowPosition">CenterOnParent</property>
- <property name="Buttons">2</property>
- <property name="HelpButton">False</property>
- <property name="HasSeparator">False</property>
- <child internal-child="VBox">
- <widget class="Gtk.VBox" id="dialog1_VBox">
- <property name="MemberName" />
- <property name="Events">0</property>
- <property name="BorderWidth">2</property>
- <child>
- <placeholder />
- </child>
- </widget>
- </child>
- <child internal-child="ActionArea">
- <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
- <property name="MemberName" />
- <property name="Events">0</property>
- <property name="Spacing">10</property>
- <property name="BorderWidth">5</property>
- <property name="Size">2</property>
- <property name="LayoutStyle">End</property>
- <child>
- <widget class="Gtk.Button" id="buttonCancel">
- <property name="MemberName" />
- <property name="CanDefault">True</property>
- <property name="CanFocus">True</property>
- <property name="Events">0</property>
- <property name="UseStock">True</property>
- <property name="Type">StockItem</property>
- <property name="StockId">gtk-cancel</property>
- <property name="IsDialogButton">True</property>
- <property name="ResponseId">-6</property>
- <property name="label">gtk-cancel</property>
- </widget>
- <packing>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Button" id="buttonOk">
- <property name="MemberName" />
- <property name="CanDefault">True</property>
- <property name="CanFocus">True</property>
- <property name="Events">0</property>
- <property name="UseStock">True</property>
- <property name="Type">StockItem</property>
- <property name="StockId">gtk-ok</property>
- <property name="IsDialogButton">True</property>
- <property name="ResponseId">-5</property>
- <property name="label">gtk-ok</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </SteticTemplate>
- <CodeDomFile>
- <CompileUnit>
- <Namespaces>
- <Namespace Name="">
- <Imports>
- <NamespaceImport Namespace="System" />
- </Imports>
- </Namespace>
- <Namespace Name="${Namespace}">
- <Types>
- <TypeDeclaration Name="${Name}" IsClass="true" IsPartial="true">
- <BaseTypes>
- <TypeReference BaseType="Gtk.Dialog" />
- </BaseTypes>
- <Members>
- <Constructor Attributes="Public, Final">
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="Build">
- <TargetObject>
- <ThisReferenceExpression />
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- </MethodInvokeExpression>
- </Statements>
- </Constructor>
- </Members>
- </TypeDeclaration>
- </Types>
- </Namespace>
- </Namespaces>
- </CompileUnit>
- </CodeDomFile>
- </Widget>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/templates/DrawingArea.xft.xml b/main/src/addins/MonoDevelop.GtkCore2/templates/DrawingArea.xft.xml
deleted file mode 100644
index 842ba2aca7..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/templates/DrawingArea.xft.xml
+++ /dev/null
@@ -1,171 +0,0 @@
-<?xml version="1.0"?>
-<Template Originator="Mike Kestner" Created="2/11/2009" LastModified="2/11/2009">
- <TemplateConfiguration>
- <_Name>Custom Drawn Widget</_Name>
- <Icon>md-gui-file</Icon>
- <_Category>Gtk</_Category>
- <LanguageName>*</LanguageName>
- <_Description>Creates a custom Gtk.DrawingArea subclass.</_Description>
- </TemplateConfiguration>
- <TemplateFiles>
- <CodeDomFile>
- <CompileUnit>
- <Namespaces>
- <Namespace Name="">
- <Imports>
- <NamespaceImport Namespace="System" />
- </Imports>
- </Namespace>
- <Namespace Name="${Namespace}">
- <Types>
- <TypeDeclaration Name="${Name}" IsClass="true">
- <BaseTypes>
- <TypeReference BaseType="Gtk.DrawingArea" />
- </BaseTypes>
- <CustomAttributes>
- <AttributeDeclaration Name="System.ComponentModel.ToolboxItem">
- <Arguments>
- <AttributeArgument>
- <Value><PrimitiveExpression Value="True" ValueType="System.Boolean"/></Value>
- </AttributeArgument>
- </Arguments>
- </AttributeDeclaration>
- </CustomAttributes>
- <Members>
- <Constructor Attributes="Public, Final">
- <Statements>
- <CommentStatement>
- <Comment>
- <Comment Text="Insert initialization code here." />
- </Comment>
- </CommentStatement>
- </Statements>
- </Constructor>
- <MemberMethod Name="OnButtonPressEvent" Attributes="Family, Override">
- <Parameters>
- <ParameterDeclarationExpression Name="ev" Type="Gdk.EventButton"/>
- </Parameters>
- <ReturnType><TypeReference BaseType="System.Boolean"/></ReturnType>
- <Statements>
- <CommentStatement>
- <Comment>
- <Comment Text="Insert button press handling code here." />
- </Comment>
- </CommentStatement>
- <MethodReturnStatement>
- <Expression>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="OnButtonPressEvent">
- <TargetObject>
- <BaseReferenceExpression/>
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- <Parameters>
- <ArgumentReferenceExpression ParameterName="ev" />
- </Parameters>
- </MethodInvokeExpression>
- </Expression>
- </MethodReturnStatement>
- </Statements>
- </MemberMethod>
- <MemberMethod Name="OnExposeEvent" Attributes="Family, Override">
- <Parameters>
- <ParameterDeclarationExpression Name="ev" Type="Gdk.EventExpose"/>
- </Parameters>
- <ReturnType><TypeReference BaseType="System.Boolean"/></ReturnType>
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="OnExposeEvent">
- <TargetObject>
- <BaseReferenceExpression/>
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- <Parameters>
- <ArgumentReferenceExpression ParameterName="ev" />
- </Parameters>
- </MethodInvokeExpression>
- <CommentStatement>
- <Comment>
- <Comment Text="Insert drawing code here." />
- </Comment>
- </CommentStatement>
- <MethodReturnStatement>
- <Expression>
- <PrimitiveExpression Value="True" ValueType="System.Boolean"/>
- </Expression>
- </MethodReturnStatement>
- </Statements>
- </MemberMethod>
- <MemberMethod Name="OnSizeAllocated" Attributes="Family, Override">
- <Parameters>
- <ParameterDeclarationExpression Name="allocation" Type="Gdk.Rectangle" />
- </Parameters>
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="OnSizeAllocated">
- <TargetObject>
- <BaseReferenceExpression/>
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- <Parameters>
- <ArgumentReferenceExpression ParameterName="allocation" />
- </Parameters>
- </MethodInvokeExpression>
- <CommentStatement>
- <Comment>
- <Comment Text="Insert layout code here." />
- </Comment>
- </CommentStatement>
- </Statements>
- </MemberMethod>
- <MemberMethod Name="OnSizeRequested" Attributes="Family, Override">
- <Parameters>
- <ParameterDeclarationExpression Name="requisition" Type="Gtk.Requisition" Direction="Ref" />
- </Parameters>
- <Statements>
- <CommentStatement>
- <Comment>
- <Comment Text="Calculate desired size here." />
- </Comment>
- </CommentStatement>
- <AssignStatement>
- <Left>
- <FieldReferenceExpression FieldName="Height">
- <TargetObject>
- <ArgumentReferenceExpression ParameterName="requisition" />
- </TargetObject>
- </FieldReferenceExpression>
- </Left>
- <Right>
- <PrimitiveExpression Value="50" ValueType="System.Int32" />
- </Right>
- </AssignStatement>
- <AssignStatement>
- <Left>
- <FieldReferenceExpression FieldName="Width">
- <TargetObject>
- <ArgumentReferenceExpression ParameterName="requisition" />
- </TargetObject>
- </FieldReferenceExpression>
- </Left>
- <Right>
- <PrimitiveExpression Value="50" ValueType="System.Int32" />
- </Right>
- </AssignStatement>
- </Statements>
- </MemberMethod>
- </Members>
- </TypeDeclaration>
- </Types>
- </Namespace>
- </Namespaces>
- </CompileUnit>
- </CodeDomFile>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/templates/Widget.xft.xml b/main/src/addins/MonoDevelop.GtkCore2/templates/Widget.xft.xml
deleted file mode 100644
index e391069234..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/templates/Widget.xft.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0"?>
-<Template Originator="Lluis Sanchez" Created="3/09/2001" LastModified="3/09/2001">
-
- <TemplateConfiguration>
- <_Name>Widget</_Name>
- <Icon>md-gui-file</Icon>
- <_Category>Gtk</_Category>
- <LanguageName>*</LanguageName>
- <_Description>Creates a custom Gtk Widget.</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- <PartialTypeSupport Requirement="Disabled" />
- </Conditions>
-
- <TemplateFiles>
- <Widget DefaultName="${Name}">
- <SteticTemplate>
- <widget class="Gtk.Bin" id="${FullName}" design-size="300 300">
- <property name="Visible">false</property>
- <child>
- <placeholder />
- </child>
- </widget>
- </SteticTemplate>
- <CodeDomFile>
- <CompileUnit>
- <Namespaces>
- <Namespace Name="">
- <Imports>
- <NamespaceImport Namespace="System" />
- </Imports>
- </Namespace>
- <Namespace Name="${Namespace}">
- <Types>
- <TypeDeclaration Name="${Name}" IsClass="true">
- <BaseTypes>
- <TypeReference BaseType="Gtk.Bin" />
- </BaseTypes>
- <CustomAttributes>
- <AttributeDeclaration Name="System.ComponentModel.ToolboxItem">
- <Arguments>
- <AttributeArgument>
- <Value><PrimitiveExpression Value="True" ValueType="System.Boolean"/></Value>
- </AttributeArgument>
- </Arguments>
- </AttributeDeclaration>
- </CustomAttributes>
- <Members>
- <Constructor Attributes="Public, Final">
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="Build">
- <TargetObject>
- <TypeReferenceExpression Type="Stetic.Gui" />
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- <Parameters>
- <ThisReferenceExpression/>
- <TypeOfExpression Type="${FullName}" />
- </Parameters>
- </MethodInvokeExpression>
- </Statements>
- </Constructor>
- </Members>
- </TypeDeclaration>
- </Types>
- </Namespace>
- </Namespaces>
- </CompileUnit>
- </CodeDomFile>
- </Widget>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/templates/WidgetPartial.xft.xml b/main/src/addins/MonoDevelop.GtkCore2/templates/WidgetPartial.xft.xml
deleted file mode 100644
index 1f911a10c4..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/templates/WidgetPartial.xft.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0"?>
-<Template Originator="Lluis Sanchez" Created="3/09/2001" LastModified="3/09/2001">
-
- <TemplateConfiguration>
- <_Name>Widget</_Name>
- <Icon>md-gui-file</Icon>
- <_Category>Gtk</_Category>
- <LanguageName>*</LanguageName>
- <_Description>Creates a custom Gtk Widget.</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- <PartialTypeSupport Requirement="Enabled" />
- </Conditions>
-
- <TemplateFiles>
- <Widget DefaultName="${Name}">
- <SteticTemplate>
- <widget class="Gtk.Bin" id="${FullName}" design-size="300 300">
- <property name="Visible">false</property>
- <child>
- <placeholder />
- </child>
- </widget>
- </SteticTemplate>
- <CodeDomFile>
- <CompileUnit>
- <Namespaces>
- <Namespace Name="">
- <Imports>
- <NamespaceImport Namespace="System" />
- </Imports>
- </Namespace>
- <Namespace Name="${Namespace}">
- <Types>
- <TypeDeclaration Name="${Name}" IsClass="true" IsPartial="true">
- <BaseTypes>
- <TypeReference BaseType="Gtk.Bin" />
- </BaseTypes>
- <CustomAttributes>
- <AttributeDeclaration Name="System.ComponentModel.ToolboxItem">
- <Arguments>
- <AttributeArgument>
- <Value><PrimitiveExpression Value="True" ValueType="System.Boolean"/></Value>
- </AttributeArgument>
- </Arguments>
- </AttributeDeclaration>
- </CustomAttributes>
- <Members>
- <Constructor Attributes="Public, Final">
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="Build">
- <TargetObject>
- <ThisReferenceExpression/>
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- </MethodInvokeExpression>
- </Statements>
- </Constructor>
- </Members>
- </TypeDeclaration>
- </Types>
- </Namespace>
- </Namespaces>
- </CompileUnit>
- </CodeDomFile>
- </Widget>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/templates/Window.xft.xml b/main/src/addins/MonoDevelop.GtkCore2/templates/Window.xft.xml
deleted file mode 100644
index 22fba55176..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/templates/Window.xft.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0"?>
-<Template Originator="Lluis Sanchez" Created="3/09/2001" LastModified="3/09/2001">
-
- <TemplateConfiguration>
- <_Name>Window</_Name>
- <Icon>md-gui-file</Icon>
- <_Category>Gtk</_Category>
- <LanguageName>*</LanguageName>
- <_Description>Creates a Gtk Window</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- <PartialTypeSupport Requirement="Disabled" />
- </Conditions>
-
- <TemplateFiles>
- <Widget DefaultName="${Name}">
- <SteticTemplate>
- <widget class="Gtk.Window" id="${FullName}" design-size="400 300">
- <property name="Title" translatable="yes">${Name}</property>
- <property name="WindowPosition">CenterOnParent</property>
- <child>
- <placeholder />
- </child>
- </widget>
- </SteticTemplate>
- <CodeDomFile>
- <CompileUnit>
- <Namespaces>
- <Namespace Name="">
- <Imports>
- <NamespaceImport Namespace="System" />
- </Imports>
- </Namespace>
- <Namespace Name="${Namespace}">
- <Types>
- <TypeDeclaration Name="${Name}" IsClass="true">
- <BaseTypes>
- <TypeReference BaseType="Gtk.Window" />
- </BaseTypes>
- <Members>
- <Constructor Attributes="Public, Final">
- <BaseConstructorArgs>
- <FieldReferenceExpression FieldName="Toplevel">
- <TargetObject>
- <TypeReferenceExpression Type="Gtk.WindowType" />
- </TargetObject>
- </FieldReferenceExpression>
- </BaseConstructorArgs>
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="Build">
- <TargetObject>
- <TypeReferenceExpression Type="Stetic.Gui" />
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- <Parameters>
- <ThisReferenceExpression/>
- <TypeOfExpression Type="${FullName}" />
- </Parameters>
- </MethodInvokeExpression>
- </Statements>
- </Constructor>
- </Members>
- </TypeDeclaration>
- </Types>
- </Namespace>
- </Namespaces>
- </CompileUnit>
- </CodeDomFile>
- </Widget>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.GtkCore2/templates/WindowPartial.xft.xml b/main/src/addins/MonoDevelop.GtkCore2/templates/WindowPartial.xft.xml
deleted file mode 100644
index 382113c771..0000000000
--- a/main/src/addins/MonoDevelop.GtkCore2/templates/WindowPartial.xft.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0"?>
-<Template Originator="Lluis Sanchez" Created="3/09/2001" LastModified="3/09/2001">
-
- <TemplateConfiguration>
- <_Name>Window</_Name>
- <Icon>md-gui-file</Icon>
- <_Category>Gtk</_Category>
- <LanguageName>*</LanguageName>
- <_Description>Creates a Gtk Window</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- <PartialTypeSupport Requirement="Enabled" />
- </Conditions>
-
- <TemplateFiles>
- <Widget DefaultName="${Name}">
- <SteticTemplate>
- <widget class="Gtk.Window" id="${FullName}" design-size="400 300">
- <property name="Title" translatable="yes">${Name}</property>
- <property name="WindowPosition">CenterOnParent</property>
- <child>
- <placeholder />
- </child>
- </widget>
- </SteticTemplate>
- <CodeDomFile>
- <CompileUnit>
- <Namespaces>
- <Namespace Name="">
- <Imports>
- <NamespaceImport Namespace="System" />
- </Imports>
- </Namespace>
- <Namespace Name="${Namespace}">
- <Types>
- <TypeDeclaration Name="${Name}" IsClass="true" IsPartial="true">
- <BaseTypes>
- <TypeReference BaseType="Gtk.Window" />
- </BaseTypes>
- <Members>
- <Constructor Attributes="Public, Final">
- <BaseConstructorArgs>
- <FieldReferenceExpression FieldName="Toplevel">
- <TargetObject>
- <TypeReferenceExpression Type="Gtk.WindowType" />
- </TargetObject>
- </FieldReferenceExpression>
- </BaseConstructorArgs>
- <Statements>
- <MethodInvokeExpression>
- <Method>
- <MethodReferenceExpression MethodName="Build">
- <TargetObject>
- <ThisReferenceExpression/>
- </TargetObject>
- </MethodReferenceExpression>
- </Method>
- </MethodInvokeExpression>
- </Statements>
- </Constructor>
- </Members>
- </TypeDeclaration>
- </Types>
- </Namespace>
- </Namespaces>
- </CompileUnit>
- </CodeDomFile>
- </Widget>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor.csproj b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor.csproj
index 29cfbde299..c912d93ed8 100644
--- a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor.csproj
+++ b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MHex</RootNamespace>
<AssemblyName>MonoDevelop.HexEditor</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.Moonlight/AssemblyInfo.cs b/main/src/addins/MonoDevelop.Moonlight/AssemblyInfo.cs
deleted file mode 100644
index 5378f7d657..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/AssemblyInfo.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-// Autogenerated from MonoDevelop.Moonlight.addin.xml
-
-using System.Reflection;
-
-[assembly: AssemblyProduct ("MonoDevelop")]
-[assembly: AssemblyTitle ("Moonlight/Silverlight Project Support")]
-[assembly: AssemblyDescription ("Support for editing, compiling, and running Moonlight/Silverlight projects.")]
-[assembly: AssemblyVersion ("2.6")]
-[assembly: AssemblyCopyright ("MIT X11")]
diff --git a/main/src/addins/MonoDevelop.Moonlight/Makefile.am b/main/src/addins/MonoDevelop.Moonlight/Makefile.am
deleted file mode 100644
index c9cc87438f..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-include $(top_srcdir)/xbuild.include
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanel.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanel.cs
deleted file mode 100644
index 63152fc9d8..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanel.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// MoonlightOptionsPanel.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using Gtk;
-using MonoDevelop.Ide.Gui.Dialogs;
-
-namespace MonoDevelop.Moonlight.Gui
-{
-
-
- public class MoonlightOptionsPanel : ItemOptionsPanel
- {
- MoonlightOptionsPanelWidget panel;
-
- public override Widget CreatePanelWidget ()
- {
- panel = new MoonlightOptionsPanelWidget ();
- panel.Load ((MoonlightProject) ConfiguredProject);
- return panel;
- }
-
- public override void ApplyChanges ()
- {
- panel.Store ((MoonlightProject) ConfiguredProject);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanelWidget.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanelWidget.cs
deleted file mode 100755
index a1836583d9..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanelWidget.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-//
-// MoonlightOptionsPanelWidget.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using ICSharpCode.NRefactory.TypeSystem;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace MonoDevelop.Moonlight.Gui
-{
-
- public partial class MoonlightOptionsPanelWidget : Gtk.Bin
- {
- Gtk.ListStore classListStore;
- bool classesFilled = false;
-
- public MoonlightOptionsPanelWidget ()
- {
- this.Build();
-
- this.validateXamlCheck.Toggled += delegate {
- this.throwXamlErrorsCheck.Sensitive = this.validateXamlCheck.Active;
- };
-
- this.generateManifestCheck.Toggled += delegate {
- this.manifestTable.Sensitive = this.generateManifestCheck.Active;
- };
-
- this.generateTestPageCheck.Toggled += delegate {
- this.testPageBox.Sensitive = this.generateTestPageCheck.Active;
- };
- }
-
- public void Load (MoonlightProject project)
- {
-
- this.validateXamlCheck.Active = project.ValidateXaml;
- this.throwXamlErrorsCheck.Active = project.ThrowErrorsInValidation;
-
- //TODO: enable after implementing xaml validation
-// this.throwXamlErrorsCheck.Sensitive = this.validateXamlCheck.Active;
- this.xamlAlignment.Sensitive = false;
-
- this.applicationOptionsBox.Visible = project.SilverlightApplication;
-
- if (!project.SilverlightApplication)
- return;
-
- this.xapFilenameEntry.Text = project.XapFilename ?? "";
-
- this.generateManifestCheck.Active = project.GenerateSilverlightManifest;
- this.manifestTemplateFilenameEntry.Text = project.SilverlightManifestTemplate ?? "";
- this.manifestTemplateFilenameEntry.Sensitive = this.generateManifestCheck.Active;
-
- this.generateTestPageCheck.Active = project.CreateTestPage;
- this.testPageFilenameEntry.Text = project.TestPageFileName ?? "";
- this.testPageFilenameEntry.Sensitive = this.generateTestPageCheck.Active;
-
- this.entryPointCombo.Entry.Text = project.SilverlightAppEntry;
- classListStore = new Gtk.ListStore (typeof(string));
- entryPointCombo.Model = classListStore;
- entryPointCombo.TextColumn = 0;
-
- FillClasses (project);
- }
-
- void FillClasses (MoonlightProject project)
- {
- if (classesFilled)
- return;
- classesFilled = true;
- try {
- var dom = TypeSystemService.GetCompilation (project);
- IType appType = dom.LookupType ("System.Windows", "Application");
- if (appType == null)
- return;
- foreach (IType type in appType.GetAllBaseTypes ())
- classListStore.AppendValues (type.FullName);
- } catch (InvalidOperationException) {
- // Project not found in parser database
- }
- }
-
- public void Store (MoonlightProject project)
- {
- project.ValidateXaml = this.throwXamlErrorsCheck.Active;
- project.ThrowErrorsInValidation = this.throwXamlErrorsCheck.Active;
-
- if (!project.SilverlightApplication)
- return;
-
- if (!string.IsNullOrEmpty (this.xapFilenameEntry.Text))
- project.XapFilename = this.xapFilenameEntry.Text;
-
- project.GenerateSilverlightManifest = this.generateManifestCheck.Active;
- project.SilverlightManifestTemplate = this.manifestTemplateFilenameEntry.Text;
-
- project.CreateTestPage = this.generateTestPageCheck.Active;
- project.TestPageFileName = this.testPageFilenameEntry.Text;
-
- project.SilverlightAppEntry = this.entryPointCombo.Entry.Text;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.addin.xml b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.addin.xml
deleted file mode 100644
index 8f186c23ed..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.addin.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<Addin id = "Moonlight"
- namespace = "MonoDevelop"
- name = "Moonlight/Silverlight Project Support"
- author = "Michael Hutchinson"
- copyright = "MIT X11"
- url = "http://www.monodevelop.com/"
- description = "Support for editing, compiling, and running Moonlight/Silverlight projects."
- category = "Web Development"
- version = "4.2.3">
-
- <Dependencies>
- <Addin id="Core" version="4.2.3"/>
- <Addin id="Ide" version="4.2.3"/>
- <Addin id="DesignerSupport" version="4.2.3"/>
- <Addin id="Deployment" version="4.2.3"/>
- <Addin id="AspNet" version="4.2.3" />
- </Dependencies>
-
- <Runtime>
- <Import file="Templates/Silverlight.js" />
- </Runtime>
-
- <Extension path = "/MonoDevelop/Ide/FileTemplates">
- <FileTemplate id = "Moonlight-ApplicationXaml"
- resource = "Moonlight-ApplicationXaml.xft.xml"/>
- <FileTemplate id = "Moonlight-UserControlXaml"
- resource = "Moonlight-UserControlXaml.xft.xml"/>
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/MSBuildItemTypes">
- <DotNetProjectSubtype id="Moonlight"
- guid="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}"
- type="MonoDevelop.Moonlight.MoonlightProject">
- <AddImport language="C#" projects="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" />
- <RemoveImport language="C#" projects="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- </DotNetProjectSubtype>
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/ProjectTemplates">
- <ProjectTemplate id = "Moonlight-ApplicationProject" resource = "Moonlight-ApplicationProject.xpt.xml"/>
- <ProjectTemplate id = "Moonlight-LibraryProject" resource = "Moonlight-LibraryProject.xpt.xml"/>
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/FileFilters">
- <FileFilter id = "XamlFiles"
- insertbefore = "AllFiles"
- _label = "XAML Files"
- extensions = "*.xaml" />
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/ProjectBindings">
- <ProjectBinding id = "MoonlightProject" class = "MonoDevelop.Moonlight.MoonlightProjectBinding" />
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/SerializableClasses">
- <DataType class = "MonoDevelop.Moonlight.MoonlightProject" />
- <DataType class = "MonoDevelop.Moonlight.MoonlightProjectConfiguration" />
- </Extension>
-
- <Extension path = "/MonoDevelop/Core/MimeTypes">
- <MimeType id="application/xaml+xml" _description="XAML document" icon="md-xml-file-icon" isText="true">
- <File pattern="*.xaml" />
- </MimeType>
- </Extension>
-
- <Extension path = "/MonoDevelop/TypeSystem/Parser">
- <Parser class = "MonoDevelop.Moonlight.MoonlightParser" insertbefore="XmlParser" mimeType="application/xaml+xml" />
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/TextEditorExtensions">
- <Class fileExtensions = ".xaml" class = "MonoDevelop.Moonlight.MoonlightEditorExtension" />
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/Gui/ItemOptionPanels/Build">
- <Condition id="ItemType" value="MonoDevelop.Moonlight.MoonlightProject">
- <Section id = "MoonlightOptions"
- _label = "Moonlight"
- class = "MonoDevelop.Moonlight.Gui.MoonlightOptionsPanel"/>
- </Condition>
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/ProjectServiceExtensions">
- <Condition id="ItemType" value="MonoDevelop.Moonlight.MoonlightProject">
- <Class class = "MonoDevelop.Moonlight.MoonlightBuildExtension" insertafter="MidStep" />
- </Condition>
- </Extension>
-
- <Extension path = "/MonoDevelop/Core/Frameworks">
- <Framework id="SL2.0" file="Templates/framework_SL_2_0.xml">
- <Backend class="MonoDevelop.Moonlight.MoonlightFrameworkBackend" />
- </Framework>
- <Framework id="SL3.0" file="Templates/framework_SL_3_0.xml">
- <Backend class="MonoDevelop.Moonlight.MoonlightFrameworkBackend" />
- </Framework>
- <Framework id="SL4.0" file="Templates/framework_SL_4_0.xml">
- <Backend class="MonoDevelop.Moonlight.MoonlightFrameworkBackend" />
- </Framework>
- </Extension>
-
- <Extension path = "/MonoDevelop/Core/ExecutionHandlers">
- <ExecutionHandler id="Moonlight" class = "MonoDevelop.Moonlight.MoonlightExecutionHandler"/>
- </Extension>
-</Addin>
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.csproj b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.csproj
deleted file mode 100644
index bf15cedc5b..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.csproj
+++ /dev/null
@@ -1,155 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{71193761-C294-42BD-98C9-A4CC15577701}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AssemblyName>MonoDevelop.Moonlight</AssemblyName>
- <RootNamespace>MonoDevelop.Moonlight</RootNamespace>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\build\AddIns\MonoDevelop.Moonlight</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\build\AddIns\MonoDevelop.Moonlight</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Execution>
- <Execution clr-version="Net_2_0" />
- </Execution>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Mono.Posix" />
- <Reference Include="System.Xml" />
- <Reference Include="System" />
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="System.Drawing" />
- <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="System.Core" />
- <Reference Include="ICSharpCode.SharpZipLib">
- <Private>False</Private>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
- <Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
- <Name>MonoDevelop.Core</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\..\core\MonoDevelop.Ide\MonoDevelop.Ide.csproj">
- <Project>{27096E7F-C91C-4AC6-B289-6897A701DF21}</Project>
- <Name>MonoDevelop.Ide</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.csproj">
- <Project>{2C24D515-4A2C-445C-8419-C09231913CFA}</Project>
- <Name>MonoDevelop.DesignerSupport</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\MonoDevelop.XmlEditor\MonoDevelop.XmlEditor.csproj">
- <Project>{86DFC74A-B0B6-4C73-9E05-9098DA8FA5F1}</Project>
- <Name>MonoDevelop.XmlEditor</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\AspNet\MonoDevelop.AspNet\MonoDevelop.AspNet.csproj">
- <Project>{1CF94D07-5480-4D10-A3CD-2EBD5E87B02E}</Project>
- <Name>MonoDevelop.AspNet</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\Deployment\MonoDevelop.Deployment\MonoDevelop.Deployment.csproj">
- <Project>{9BC670A8-1851-40EC-9685-279F4C98433D}</Project>
- <Name>MonoDevelop.Deployment</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\..\..\contrib\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
- <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
- <Name>ICSharpCode.NRefactory</Name>
- <Private>False</Private>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="gtk-gui\gui.stetic">
- <LogicalName>gui.stetic</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="MonoDevelop.Moonlight.addin.xml">
- <LogicalName>MonoDevelop.Moonlight.addin.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="Templates\Moonlight-ApplicationProject.xpt.xml">
- <LogicalName>Moonlight-ApplicationProject.xpt.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="Templates\Moonlight-ApplicationXaml.xft.xml">
- <LogicalName>Moonlight-ApplicationXaml.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="Templates\Moonlight-UserControlXaml.xft.xml">
- <LogicalName>Moonlight-UserControlXaml.xft.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="Templates\Moonlight-LibraryProject.xpt.xml">
- <LogicalName>Moonlight-LibraryProject.xpt.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="Templates\PreviewTemplate.html">
- <LogicalName>PreviewTemplate.html</LogicalName>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="gtk-gui\generated.cs" />
- <Compile Include="MonoDevelop.Moonlight\MoonlightProject.cs" />
- <Compile Include="MonoDevelop.Moonlight\MoonlightProjectConfiguration.cs" />
- <Compile Include="MonoDevelop.Moonlight\MoonlightProjectBinding.cs" />
- <Compile Include="MonoDevelop.Moonlight\MoonlightParser.cs" />
- <Compile Include="MonoDevelop.Moonlight\MoonlightEditorExtension.cs" />
- <Compile Include="MonoDevelop.Moonlight\XamlG.cs" />
- <Compile Include="MonoDevelop.Moonlight.Gui\MoonlightOptionsPanelWidget.cs" />
- <Compile Include="MonoDevelop.Moonlight.Gui\MoonlightOptionsPanel.cs" />
- <Compile Include="gtk-gui\MonoDevelop.Moonlight.Gui.MoonlightOptionsPanelWidget.cs" />
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="MonoDevelop.Moonlight\MoonlightBuildExtension.cs" />
- <Compile Include="MonoDevelop.Moonlight\MoonlightExecutionCommand.cs" />
- <Compile Include="MonoDevelop.Moonlight\MoonlightExecutionHandler.cs" />
- <Compile Include="MonoDevelop.Moonlight\MoonlightFrameworkBackend.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="Makefile.am" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <Content Include="Templates\Silverlight.js">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
- <Content Include="Templates\framework_SL_2_0.xml">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
- <Content Include="Templates\framework_SL_3_0.xml">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
- <Content Include="Templates\framework_SL_4_0.xml">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
- </ItemGroup>
-</Project>
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightBuildExtension.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightBuildExtension.cs
deleted file mode 100644
index 5d38266d12..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightBuildExtension.cs
+++ /dev/null
@@ -1,605 +0,0 @@
-//
-// MoonlightBuildExtension.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.IO;
-using System.Collections.Generic;
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Core.ProgressMonitoring;
-using System.Xml;
-using System.Text;
-
-namespace MonoDevelop.Moonlight
-{
-
-
- public class MoonlightBuildExtension : ProjectServiceExtension
- {
- FilePath GetObjDir (MoonlightProject proj, DotNetProjectConfiguration conf)
- {
- return proj.BaseDirectory.Combine ("obj", conf.Id);
- }
-
- protected override BuildResult Compile (IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData)
- {
- MoonlightProject proj = item as MoonlightProject;
- if (proj == null)
- return base.Compile (monitor, item, buildData);
-
- var objDir = GetObjDir (proj, buildData.Configuration);
- if (!Directory.Exists (objDir))
- Directory.CreateDirectory (objDir);
-
- var codeDomProvider = proj.LanguageBinding.GetCodeDomProvider ();
- string appName = proj.Name;
-
- var toResGen = new List<FilePath> ();
- List<BuildResult> results = new List<BuildResult> ();
-
- foreach (ProjectFile pf in proj.Files) {
- if (pf.BuildAction == BuildAction.Resource || pf.BuildAction == BuildAction.Page || pf.BuildAction == BuildAction.ApplicationDefinition)
- toResGen.Add (pf.FilePath);
-
- if (pf.FilePath.Extension == ".xaml" && pf.Generator == "MSBuild:MarkupCompilePass1") {
- var outFile = objDir.Combine (proj.LanguageBinding.GetFileName (pf.FilePath.FileName + ".g"));
- buildData.Items.Add (new ProjectFile (outFile, BuildAction.Compile));
- if (!File.Exists (outFile) || File.GetLastWriteTime (outFile) < File.GetLastWriteTime (pf.FilePath)) {
- string rel = pf.ProjectVirtualPath;
- monitor.Log.WriteLine ("Generating codebehind accessors for {0}...", rel);
- BuildResult result = XamlG.GenerateFile (codeDomProvider, appName, pf.FilePath, rel, outFile);
- if (result.Failed)
- return result;
- results.Add (result);
- }
- }
- }
-
- string resFile = objDir.Combine (appName + ".g.resources");
- if (toResGen.Count > 0) {
- DateTime lastMod = DateTime.MinValue;
- if (File.Exists (resFile))
- lastMod = File.GetLastWriteTime (resFile);
- foreach (string f in toResGen) {
- if (File.GetLastWriteTime (f) > lastMod) {
- BuildResult result = Respack (monitor, proj, toResGen, resFile);
- if (result.Failed)
- return result;
- results.Add (result);
- break;
- }
- }
- buildData.Items.Add (new ProjectFile (resFile, BuildAction.EmbeddedResource) {
- ResourceId = appName + ".g.resources"
- });
- } else {
- if (File.Exists (resFile))
- File.Delete (resFile);
- }
-
- return base.Compile (monitor, item, buildData).Append (results);
- }
-
- BuildResult Respack (IProgressMonitor monitor, MoonlightProject proj, List<FilePath> toResGen, FilePath outfile)
- {
- monitor.Log.WriteLine ("Packing resources...");
-
- var runtime = proj.TargetRuntime;
- BuildResult result = new BuildResult ();
-
- string respack = runtime.GetToolPath (proj.TargetFramework, "respack");
- if (String.IsNullOrEmpty (respack)) {
- result.AddError (null, 0, 0, null, "Could not find respack");
- result.FailedBuildCount++;
- return result;
- }
-
- var si = new System.Diagnostics.ProcessStartInfo ();
- var env = runtime.GetToolsExecutionEnvironment (proj.TargetFramework);
- env.MergeTo (si);
-
- si.FileName = respack.EndsWith (".exe")? "mono" : respack;
- si.WorkingDirectory = outfile.ParentDirectory;
-
- var sb = new System.Text.StringBuilder ();
- if (respack.EndsWith (".exe")) {
- sb.Append (respack);
- sb.Append (" ");
- }
- sb.Append (outfile);
-
- foreach (var infile in toResGen) {
- sb.AppendFormat (" \"{0}\",\"{1}\"", infile.FullPath, infile.ToRelative (proj.BaseDirectory));
- }
- si.Arguments = sb.ToString ();
- string err;
- int exit = ExecuteCommand (monitor, si, out err);
- if (exit != 0) {
- result.AddError (null, 0, 0, exit.ToString (), "respack failed: " + err);
- result.FailedBuildCount++;
- }
- return result;
- }
-
- int ExecuteCommand (IProgressMonitor monitor, System.Diagnostics.ProcessStartInfo startInfo, out string errorOutput)
- {
- startInfo.UseShellExecute = false;
- startInfo.RedirectStandardError = true;
- startInfo.RedirectStandardOutput = true;
-
- errorOutput = string.Empty;
- int exitCode = -1;
-
- var swError = new StringWriter ();
- var chainedError = new LogTextWriter ();
- chainedError.ChainWriter (monitor.Log);
- chainedError.ChainWriter (swError);
-
- AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);
-
- try {
- var p = Runtime.ProcessService.StartProcess (startInfo, monitor.Log, chainedError, null);
- operationMonitor.AddOperation (p); //handles cancellation
-
- p.WaitForOutput ();
- errorOutput = swError.ToString ();
- exitCode = p.ExitCode;
- p.Dispose ();
-
- if (monitor.IsCancelRequested) {
- monitor.Log.WriteLine (GettextCatalog.GetString ("Build cancelled"));
- monitor.ReportError (GettextCatalog.GetString ("Build cancelled"), null);
- if (exitCode == 0)
- exitCode = -1;
- }
- } finally {
- chainedError.Close ();
- swError.Close ();
- operationMonitor.Dispose ();
- }
-
- return exitCode;
- }
-
- protected override void Clean (IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
- {
- MoonlightProject proj = item as MoonlightProject;
- DotNetProjectConfiguration conf = null;
- if (proj != null)
- conf = proj.GetConfiguration (configuration) as DotNetProjectConfiguration;
-
- base.Clean (monitor, item, configuration);
-
- if (conf == null)
- return;
-
- var objDir = GetObjDir (proj, conf);
- if (!Directory.Exists (objDir))
- return;
-
- foreach (ProjectFile pf in proj.Files) {
- if (pf.FilePath.Extension == ".xaml" && pf.Generator == "MSBuild:MarkupCompilePass1") {
- var outFile = objDir.Combine (proj.LanguageBinding.GetFileName (pf.FilePath.FileName + ".g"));
- if (File.Exists (outFile))
- File.Delete (outFile);
- }
- }
-
- if (proj.GenerateSilverlightManifest) {
- var manifest = conf.OutputDirectory.Combine ("AppManifest.xaml");
- if (File.Exists (manifest))
- File.Delete (manifest);
- }
-
- if (proj.CreateTestPage) {
- string testPageFile = GetTestPageFileName (proj, conf);
- if (File.Exists (testPageFile))
- File.Delete (testPageFile);
- }
-
- var resFile = objDir.Combine (proj.Name + ".g.resources");
- if (File.Exists (resFile))
- File.Delete (resFile);
-
- if (proj.XapOutputs) {
- var xapName = GetXapName (proj, conf);
- if (File.Exists (xapName))
- File.Delete (xapName);
- }
- }
-
- protected override bool GetNeedsBuilding (SolutionEntityItem item, ConfigurationSelector configuration)
- {
- MoonlightProject proj = item as MoonlightProject;
- DotNetProjectConfiguration conf = null;
- if (proj != null)
- conf = proj.GetConfiguration (configuration) as DotNetProjectConfiguration;
- if (conf == null)
- return base.GetNeedsBuilding (item, configuration);
-
- if (base.GetNeedsBuilding (item, configuration))
- return true;
-
- var objDir = GetObjDir (proj, conf);
-
- DateTime xapLastMod = DateTime.MaxValue;
- if (proj.XapOutputs) {
- var xapName = GetXapName (proj, conf);
- if (!File.Exists (xapName))
- return true;
- xapLastMod = File.GetLastWriteTime (xapName);
- }
-
- var manifest = conf.OutputDirectory.Combine ("AppManifest.xaml");
- if (proj.GenerateSilverlightManifest) {
- if (!File.Exists (manifest))
- return true;
- if (!String.IsNullOrEmpty (proj.SilverlightManifestTemplate)) {
- string template = proj.GetAbsoluteChildPath (proj.SilverlightManifestTemplate);
- if (File.Exists (template) && File.GetLastWriteTime (template) > File.GetLastWriteTime (manifest))
- return true;
- }
- }
-
- if (proj.CreateTestPage) {
- string testPageFile = GetTestPageFileName (proj, conf);
- if (!File.Exists (testPageFile))
- return true;
- }
-
- string appName = proj.Name;
- var resFile = objDir.Combine (appName + ".g.resources");
- DateTime resLastMod = DateTime.MinValue;
- if (File.Exists (resFile))
- resLastMod = File.GetLastWriteTime (resFile);
-
- foreach (ProjectFile pf in proj.Files) {
- if ((pf.BuildAction == BuildAction.Page || pf.BuildAction == BuildAction.ApplicationDefinition || pf.BuildAction == BuildAction.Resource)
- && File.GetLastWriteTime (pf.FilePath) > resLastMod)
- {
- return true;
- }
- if (pf.FilePath.Extension == ".xaml" && pf.Generator == "MSBuild:MarkupCompilePass1") {
- var outFile = objDir.Combine (proj.LanguageBinding.GetFileName (pf.FilePath.FileName + ".g"));
- if (!File.Exists (outFile) || File.GetLastWriteTime (outFile) < File.GetLastWriteTime (pf.FilePath))
- return true;
- }
- if (pf.BuildAction == BuildAction.Content && File.GetLastWriteTime (pf.FilePath) > xapLastMod)
- return true;
- }
- return false;
- }
-
- protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
- {
- MoonlightProject proj = item as MoonlightProject;
- DotNetProjectConfiguration conf = null;
- if (proj != null)
- conf = proj.GetConfiguration (configuration) as DotNetProjectConfiguration;
- if (conf == null)
- return base.Build (monitor, item, configuration);
-
- BuildResult result = base.Build (monitor, item, configuration);
- if (result.ErrorCount > 0 || monitor.IsCancelRequested)
- return result;
-
- if (proj.GenerateSilverlightManifest)
- if (result.Append (GenerateManifest (monitor, proj, conf, configuration)).Failed || monitor.IsCancelRequested)
- return result;
-
- if (proj.XapOutputs)
- if (result.Append (Zip (monitor, proj, conf, configuration)).Failed || monitor.IsCancelRequested)
- return result;
-
- if (proj.XapOutputs && proj.CreateTestPage)
- result.Append (CreateTestPage (monitor, proj, conf));
-
- return result;
- }
-
- BuildResult GenerateManifest (IProgressMonitor monitor, MoonlightProject proj, DotNetProjectConfiguration conf, ConfigurationSelector slnConf)
- {
- const string depNS = "http://schemas.microsoft.com/client/2007/deployment";
-
- monitor.Log.WriteLine ("Generating manifest...");
-
- var res = new BuildResult ();
- var manifest = conf.OutputDirectory.Combine ("AppManifest.xaml");
-
- string template = String.IsNullOrEmpty (proj.SilverlightManifestTemplate)?
- null : proj.GetAbsoluteChildPath (proj.SilverlightManifestTemplate);
-
- XmlDocument doc = new XmlDocument ();
- if (template != null) {
- if (!File.Exists (template)) {
- monitor.ReportError ("Could not find manifest template '" + template + "'.", null);
- res.AddError ("Could not find manifest template '" + template + "'.");
- res.FailedBuildCount++;
- return res;
- }
- try {
- doc.Load (template);
- } catch (XmlException ex) {
- monitor.ReportError ("Could not load manifest template '" + template + "'.", null);
- res.AddError (template, ex.LineNumber, ex.LinePosition, null, "Error loading manifest template '" + ex.Source);
- res.FailedBuildCount++;
- return res;
- } catch (Exception ex) {
- monitor.ReportError ("Could not load manifest template '" + template + "'.", ex);
- res.AddError ("Could not load manifest template '" + template + "': " + ex.ToString ());
- res.FailedBuildCount++;
- return res;
- }
-
- } else {
- doc.LoadXml (@"<Deployment xmlns=""http://schemas.microsoft.com/client/2007/deployment"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""></Deployment>");
- }
-
- try {
- XmlNode deploymentNode = doc.DocumentElement;
- if (deploymentNode == null || deploymentNode.Name != "Deployment" || deploymentNode.NamespaceURI != depNS) {
- monitor.ReportError ("Missing or invalid root <Deployment> element in manifest template '" + template + "'.", null);
- res.AddError ("Missing root <Deployment> element in manifest template '" + template + "'.");
- res.FailedBuildCount++;
- return res;
- }
- if (deploymentNode.Attributes["EntryPointAssembly"] == null)
- deploymentNode.Attributes.Append (doc.CreateAttribute ("EntryPointAssembly")).Value = conf.CompiledOutputName.FileNameWithoutExtension;
- if (!String.IsNullOrEmpty (proj.SilverlightAppEntry) && deploymentNode.Attributes["EntryPointType"] == null)
- deploymentNode.Attributes.Append (doc.CreateAttribute ("EntryPointType")).Value = proj.SilverlightAppEntry;
-
- if (deploymentNode.Attributes["RuntimeVersion"] == null) {
- string runtimeVersion = null;
- string fxVersion = proj.TargetFramework.Id.Version;
-
- if (proj.TargetRuntime is MonoDevelop.Core.Assemblies.MonoTargetRuntime) {
- var package = proj.TargetRuntime.RuntimeAssemblyContext.GetPackage ("moonlight-web-" + fxVersion);
- if (package != null && package.IsFrameworkPackage) {
- runtimeVersion = package.Version;
- } else {
- LoggingService.LogWarning ("Moonlight core framework package not found, cannot determine " +
- "runtime version string. Falling back to default value.");
- }
- }
-
- if (runtimeVersion == null) {
- //FIXME how will we determine this for other runtimes?
- runtimeVersion = "2.0.31005.0";
- }
-
- deploymentNode.Attributes.Append (doc.CreateAttribute ("RuntimeVersion")).Value = runtimeVersion;
- }
-
- XmlNamespaceManager mgr = new XmlNamespaceManager (doc.NameTable);
- mgr.AddNamespace ("dep", depNS);
- XmlNode partsNode = deploymentNode.SelectSingleNode ("dep:Deployment.Parts", mgr);
- if (partsNode == null)
- partsNode = deploymentNode.AppendChild (doc.CreateElement ("Deployment.Parts", depNS));
-
- AddAssemblyPart (doc, partsNode, conf.CompiledOutputName);
- foreach (ProjectReference pr in proj.References) {
- if (pr.LocalCopy) {
- var pk = pr.Package;
- if (pk == null || !pk.IsFrameworkPackage || pk.Name.EndsWith ("-redist")) {
- foreach (string s in pr.GetReferencedFileNames (slnConf))
- AddAssemblyPart (doc, partsNode, s);
- }
- }
- }
-
- } catch (XmlException ex) {
- monitor.ReportError ("Error processing manifest template.", ex);
- res.AddError (template, ex.LineNumber, ex.LinePosition, null, "Error processing manifest template: '" + ex.Source);
- res.FailedBuildCount++;
- return res;
- }
-
- doc.Save (manifest);
-
- return res;
- }
-
- static void AddAssemblyPart (XmlDocument doc, XmlNode partsNode, FilePath assem)
- {
- XmlNode child = doc.CreateElement ("AssemblyPart", "http://schemas.microsoft.com/client/2007/deployment");
- child.Attributes.Append (doc.CreateAttribute ("Name", "http://schemas.microsoft.com/winfx/2006/xaml")).Value = assem.FileNameWithoutExtension;
- child.Attributes.Append (doc.CreateAttribute ("Source")).Value = Path.GetFileName (assem);
- partsNode.AppendChild (child);
- }
-
- BuildResult CreateTestPage (IProgressMonitor monitor, MoonlightProject proj, DotNetProjectConfiguration conf)
- {
- monitor.Log.WriteLine ("Creating test page...");
-
- string testPageFile = GetTestPageFileName (proj, conf);
- try {
- using (var sr = new StreamReader (System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream ("PreviewTemplate.html"))) {
- var sb = new StringBuilder (sr.ReadToEnd ());
- string xapName = String.IsNullOrEmpty (proj.XapFilename)? proj.Name + ".xap" : proj.XapFilename;
- sb.Replace ("@TITLE@", proj.Name);
- sb.Replace ("@XAP_FILE@", xapName);
- File.WriteAllText (testPageFile, sb.ToString ());
- }
- } catch (Exception ex) {
- monitor.ReportError ("Error generating test page '" + testPageFile + "'.", ex);
- BuildResult res = new BuildResult ();
- res.AddError ("Error generating test page '" + testPageFile + "':" + ex.ToString ());
- res.FailedBuildCount++;
- return res;
- }
- return null;
- }
-
- FilePath GetTestPageFileName (MoonlightProject proj, DotNetProjectConfiguration conf)
- {
- string testPage = proj.TestPageFileName;
- if (String.IsNullOrEmpty (testPage))
- testPage = "TestPage.html";
- return conf.OutputDirectory.Combine (testPage);
- }
-
- FilePath GetXapName (MoonlightProject proj, DotNetProjectConfiguration conf)
- {
- string xapName = proj.XapFilename;
- if (String.IsNullOrEmpty (xapName))
- xapName = proj.Name + ".xap";
- return conf.OutputDirectory.Combine (xapName);
- }
-
- BuildResult Zip (IProgressMonitor monitor, MoonlightProject proj, DotNetProjectConfiguration conf, ConfigurationSelector slnConf)
- {
- var xapName = GetXapName (proj, conf);
-
- var src = new List<string> ();
- var targ = new List<string> ();
-
- src.Add (conf.CompiledOutputName);
- targ.Add (conf.CompiledOutputName.FileName);
-
- // FIXME: this is a hack for the Mono Soft Debugger. In future the mdb files should be *beside* the xap,
- // when sdb supports that model. Note that there's no point doing this for pdb files, because the debuggers
- // that read pdb files don't expect them to be in the xap.
- var doSdbCopy = conf.DebugMode && proj.TargetRuntime is MonoDevelop.Core.Assemblies.MonoTargetRuntime;
-
- if (doSdbCopy) {
- FilePath mdb = conf.CompiledOutputName + ".mdb";
- if (File.Exists (mdb)) {
- src.Add (mdb);
- targ.Add (mdb.FileName);
- }
- }
-
- if (proj.GenerateSilverlightManifest) {
- src.Add (conf.OutputDirectory.Combine ("AppManifest.xaml"));
- targ.Add ("AppManifest.xaml");
- }
-
- foreach (ProjectFile pf in proj.Files) {
- if (pf.BuildAction == BuildAction.Content) {
- src.Add (pf.FilePath);
- targ.Add (pf.ProjectVirtualPath);
- }
- }
-
- BuildResult res = new BuildResult ();
-
- // The "copy to output" files don't seem to be included in xaps, so we can't use project.GetSupportFiles.
- // Instead we need to iterate over the refs and handle them manually.
- foreach (ProjectReference pr in proj.References) {
- if (pr.LocalCopy) {
- var pk = pr.Package;
- if (pk == null || !pk.IsFrameworkPackage || pk.Name.EndsWith ("-redist")) {
- string err = pr.ValidationErrorMessage;
- if (!String.IsNullOrEmpty (err)) {
- string msg = String.Format ("Could not add reference '{0}' to '{1}': {2}",
- pr.Reference, xapName.FileName, err);
- res.AddError (msg);
- monitor.Log.WriteLine (msg);
- continue;
- }
- foreach (string s in pr.GetReferencedFileNames (slnConf)) {
- src.Add (s);
- targ.Add (Path.GetFileName (s));
-
- if (doSdbCopy && s.EndsWith (".dll")) {
- FilePath mdb = s + ".mdb";
- if (File.Exists (mdb)) {
- src.Add (mdb);
- targ.Add (mdb.FileName);
- }
- }
- }
- }
- }
- }
-
- if (res.ErrorCount > 0) {
- res.FailedBuildCount++;
- return res;
- }
-
- if (File.Exists (xapName)) {
- DateTime lastMod = File.GetLastWriteTime (xapName);
- bool needsWrite = false;
- foreach (string file in src) {
- if (File.GetLastWriteTime (file) > lastMod) {
- needsWrite = true;
- break;
- }
- }
- if (!needsWrite)
- return null;
- }
-
- monitor.Log.WriteLine ("Compressing XAP file...");
-
- try {
- using (FileStream fs = new FileStream (xapName, FileMode.Create)) {
- var zipfile = new ICSharpCode.SharpZipLib.Zip.ZipOutputStream (fs);
- zipfile.SetLevel (9);
-
- byte[] buffer = new byte[4096];
-
- for (int i = 0; i < src.Count && !monitor.IsCancelRequested; i++) {
- zipfile.PutNextEntry (new ICSharpCode.SharpZipLib.Zip.ZipEntry (targ[i]));
- using (FileStream inStream = File.OpenRead (src[i])) {
- int readCount;
- do {
- readCount = inStream.Read (buffer, 0, buffer.Length);
- zipfile.Write (buffer, 0, readCount);
- } while (readCount > 0);
- }
- }
- if (!monitor.IsCancelRequested) {
- zipfile.Finish ();
- zipfile.Close ();
- }
- }
- } catch (IOException ex) {
- monitor.ReportError ("Error writing xap file.", ex);
- res.AddError ("Error writing xap file:" + ex.ToString ());
- res.FailedBuildCount++;
-
- try {
- if (File.Exists (xapName))
- File.Delete (xapName);
- } catch {}
-
- return res;
- }
-
- if (monitor.IsCancelRequested) {
- try {
- if (File.Exists (xapName))
- File.Delete (xapName);
- } catch {}
- }
-
- return res;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightEditorExtension.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightEditorExtension.cs
deleted file mode 100755
index 9fbd6bd145..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightEditorExtension.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-//
-// MoonlightEditorExtension.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-
-using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.Xml.StateEngine;
-using ICSharpCode.NRefactory.TypeSystem;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace MonoDevelop.Moonlight
-{
-
-
- public class MoonlightEditorExtension : MonoDevelop.XmlEditor.Gui.BaseXmlEditorExtension
- {
-
- public MoonlightEditorExtension ()
- {
- }
-
- #region Code completion
-
-// static ITypeResolveContext GetMLDom (MoonlightProject project)
-// {
-// return TypeSystemService.GetAssemblyDom (
-// MonoDevelop.Core.Runtime.SystemAssemblyService.GetAssemblyNameForVersion (
-// "System.Windows", GetProjectTargetFramework (project)));
-// }
-
- public static IEnumerable<IType> ListControlClasses (ICompilation database, INamespace namespac)
- {
- if (database == null)
- yield break;
-
- var swd = database.LookupType ("System.Windows", "DependencyObject");
-
- //return classes if they derive from system.web.ui.control
- foreach (var cls in namespac.Types) {
- if (cls != null && !cls.IsAbstract && cls.IsPublic && cls.IsBaseType (swd))
- yield return cls;
- }
- }
-
- static IEnumerable<T> GetUniqueMembers<T> (IEnumerable<T> members) where T : IMember
- {
- Dictionary <string, bool> existingItems = new Dictionary<string,bool> ();
- foreach (T item in members) {
- if (existingItems.ContainsKey (item.Name))
- continue;
- existingItems[item.Name] = true;
- yield return item;
- }
- }
-
- static void AddControlMembers (CompletionDataList list, IType controlClass,
- Dictionary<string, string> existingAtts)
- {
- //add atts only if they're not already in the tag
- foreach (IProperty prop in GetUniqueMembers<IProperty> (controlClass.GetProperties ()))
- if (prop.IsPublic && (existingAtts == null || !existingAtts.ContainsKey (prop.Name)))
- list.Add (prop.Name, prop.GetStockIcon (), prop.Documentation);
-
- //similarly add events
- foreach (var eve
- in GetUniqueMembers<IEvent> (controlClass.GetEvents ())) {
- string eveName = eve.Name;
- if (eve.IsPublic && (existingAtts == null || !existingAtts.ContainsKey (eveName)))
- list.Add (eveName, eve.GetStockIcon (), eve.Documentation);
- }
- }
-
- ICompilation GetDb ()
- {
- return Document.Compilation;
- }
-
- void GetType (IAttributedXObject attributedOb, Action<IType, ICompilation> action)
- {
- var database = GetDb ();
- if (database == null)
- return;
- foreach (string namespc in namespaces) {
- var controlType = database.MainAssembly.GetTypeDefinition (namespc, attributedOb.Name.Name, 0);
- if (controlType != null) {
- action (controlType, database);
- break;
- }
- }
- }
-
- string[] namespaces = { "System.Windows.Media", "System.Windows.Media.Animation",
- "System.Windows.Controls", "System.Windows.Shapes" };
-
- protected override void GetElementCompletions (CompletionDataList list)
- {
- base.GetElementCompletions (list);
- var database = GetDb ();
- if (database == null)
- return;
-
- IType type = database.LookupType ("System.Windows", "DependencyObject");
- if (type == null)
- return;
-
- foreach (string namespc in namespaces) {
- INamespace ns = database.RootNamespace;
- foreach (var sn in namespc.Split ('.')) {
- ns = ns.GetChildNamespace (sn);
- }
- foreach (IType t in ListControlClasses (database, ns))
- list.Add (t.Name, Gtk.Stock.GoForward, t.GetDefinition ().Documentation);
- }
- }
-
-// static MonoDevelop.Core.TargetFramework GetProjectTargetFramework (MoonlightProject project)
-// {
-// return project == null? MonoDevelop.Core.TargetFramework.Default : project.TargetFramework;
-// }
-
- protected override CompletionDataList GetAttributeCompletions (IAttributedXObject attributedOb,
- Dictionary<string, string> existingAtts)
- {
- var list = base.GetAttributeCompletions (attributedOb, existingAtts) ?? new CompletionDataList ();
- if (!existingAtts.ContainsKey ("x:Name"))
- list.Add ("x:Name");
-
- GetType (attributedOb, delegate (IType type, ICompilation dom) {
- AddControlMembers (list, type, existingAtts);
- });
- return list.Count > 0? list : null;
- }
-
- protected override CompletionDataList GetAttributeValueCompletions (IAttributedXObject attributedOb, XAttribute att)
- {
- var list = base.GetAttributeValueCompletions (attributedOb, att) ?? new CompletionDataList ();
- var ctx = document.Compilation;
- GetType (attributedOb, delegate (IType type, ICompilation dom) {
- foreach (IProperty prop in type.GetProperties ()) {
- if (prop.Name != att.Name.FullName)
- continue;
-
- //boolean completion
- if (prop.ReturnType.Equals (ctx.FindType (typeof (bool)))) {
- list.Add ("true", "md-literal");
- list.Add ("false", "md-literal");
- return;
- }
-
- //color completion
- if (prop.ReturnType.ReflectionName == "System.Windows.Media.Color") {
- System.Drawing.ColorConverter conv = new System.Drawing.ColorConverter ();
- foreach (System.Drawing.Color c in conv.GetStandardValues (null)) {
- if (c.IsSystemColor)
- continue;
- string hexcol = string.Format ("#{0:x2}{1:x2}{2:x2}", c.R, c.G, c.B);
- list.Add (c.Name, hexcol);
- }
- return;
- }
-
- //enum completion
- var retCls = prop.ReturnType;
- if (retCls != null && retCls.Kind == TypeKind.Enum) {
- foreach (var enumVal in retCls.GetFields ())
- if (enumVal.IsPublic && enumVal.IsStatic)
- list.Add (enumVal.Name, "md-literal", enumVal.Documentation);
- return;
- }
- }
- });
- return list.Count > 0? list : null;
- }
-
- #endregion
-
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightExecutionCommand.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightExecutionCommand.cs
deleted file mode 100644
index 8064341e9a..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightExecutionCommand.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// MoonlightExecutionCommand.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using MonoDevelop.Core.Execution;
-using System.Collections.Generic;
-
-namespace MonoDevelop.Moonlight
-{
-
- public class MoonlightExecutionCommand : ExecutionCommand
- {
- public MoonlightExecutionCommand (string appName, string url)
- {
- this.AppName = appName;
- this.Url = url;
- }
-
- public string Url { get; private set; }
- public string AppName { get; private set; }
- public IList<string> UserAssemblyPaths { get; set; }
-
- public override string CommandString {
- get { return "[silverlight]"; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightExecutionHandler.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightExecutionHandler.cs
deleted file mode 100644
index 56dfdf1ec4..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightExecutionHandler.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// MoonlightExecutionHandler.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using MonoDevelop.Core.Execution;
-using MonoDevelop.AspNet.Gui;
-
-namespace MonoDevelop.Moonlight
-{
-
- public class MoonlightExecutionHandler : IExecutionHandler
- {
- public bool CanExecute (ExecutionCommand command)
- {
- var cmd = command as MoonlightExecutionCommand;
- return cmd != null && cmd.Url != null;
- }
-
- public IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console)
- {
- var cmd = (MoonlightExecutionCommand) command;
- return BrowserLauncher.LaunchDefaultBrowser (cmd.Url);
- }
- }
-
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightFrameworkBackend.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightFrameworkBackend.cs
deleted file mode 100644
index 53c87cc94d..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightFrameworkBackend.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-//
-// SilverlightFrameworkBackend.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Linq;
-using System.IO;
-using System.Collections.Generic;
-using MonoDevelop.Core.Assemblies;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.Moonlight
-{
- class MoonlightFrameworkBackend: MonoFrameworkBackend
- {
- string fxVersion;
- FilePath location;
- string pluginVersion;
-
- protected override void Initialize (TargetRuntime runtime, TargetFramework framework)
- {
- if (framework.Id.Identifier != "Silverlight")
- throw new InvalidOperationException (string.Format ("Cannot handle unknown framework {0}", framework.Id));
-
- base.Initialize (runtime, framework);
- fxVersion = framework.Id.Version;
-
- foreach (var dir in GetMoonDirectories ()) {
- var fxdir = dir.Combine (fxVersion);
- var buildVersion = fxdir.Combine ("buildversion");
- if (Directory.Exists (fxdir) && Directory.Exists (fxdir + "-redist") && File.Exists (buildVersion)) {
- if (LoadVersionString (buildVersion) && RegisterRedistAssemblies (dir))
- this.location = dir;
- break;
- }
- }
- }
-
- bool LoadVersionString (FilePath buildVersion)
- {
- try {
- using (var reader = File.OpenText (buildVersion)) {
- var line = reader.ReadLine ();
- if (!string.IsNullOrEmpty (line)) {
- this.pluginVersion = line;
- return true;
- } else {
- LoggingService.LogError ("Could not get SL build version from file '" + buildVersion + "'");
- }
- }
- } catch (IOException ex) {
- LoggingService.LogError ("Could not get SL build version from file '" + buildVersion + "'", ex);
- }
- return false;
- }
-
- bool RegisterRedistAssemblies (FilePath location)
- {
- var info = new SystemPackageInfo () {
- Name = "moonlight-web-" + fxVersion + "-redist",
- Description = "Moonlight " + fxVersion + " Redistributable Assemblies",
- Version = pluginVersion,
- IsFrameworkPackage = true,
- IsGacPackage = false,
- IsCorePackage = false,
- TargetFramework = framework.Id,
- };
- var dir = location.Combine (fxVersion + "-redist");
- try {
- var files = Directory.GetFiles (dir, "*.dll");
- runtime.RegisterPackage (info, files);
- return true;
- } catch (IOException ex) {
- LoggingService.LogError ("Could not enumerate redist assemblies from directory '" + dir + "'", ex);
- return false;
- }
- }
-
- IEnumerable<FilePath> GetMoonDirectories ()
- {
- string path;
- if (targetRuntime.EnvironmentVariables.TryGetValue ("MOONLIGHT_SDK_PATH", out path))
- yield return (FilePath) path;
- yield return ((FilePath)targetRuntime.Prefix).Combine ("lib", "moonlight");
- var env = System.Environment.GetEnvironmentVariable ("MOONLIGHT_SDK_PATH");
- if (!string.IsNullOrEmpty (env))
- yield return (FilePath) env;
- }
-
- public override bool IsInstalled {
- get { return !location.IsNullOrEmpty; }
- }
-
- public override IEnumerable<string> GetToolsPaths ()
- {
- yield return location;
- yield return location.Combine (fxVersion);
- foreach (var f in BaseGetToolsPaths ())
- yield return f;
- }
-
- //WORKAROUND for gmcs code generation bug - base not properly accessible from generators.
- //Should be fixed in Mono 2.8 final.
- IEnumerable<string> BaseGetToolsPaths ()
- {
- return base.GetToolsPaths ();
- }
-
- Dictionary<string, string> envVars;
-
- public override Dictionary<string, string> GetToolsEnvironmentVariables ()
- {
- if (envVars == null) {
- envVars = base.GetToolsEnvironmentVariables ();
- if (envVars.ContainsKey ("MONO_PATH")) {
- envVars = new Dictionary<string,string> (envVars);
- envVars.Remove ("MONO_PATH");
- }
- }
- return envVars;
- }
-
- public override IEnumerable<string> GetFrameworkFolders ()
- {
- yield return location.Combine (fxVersion);
- yield return location.Combine (fxVersion + "-redist");
- }
-
- public override SystemPackageInfo GetFrameworkPackageInfo (string packageName)
- {
- SystemPackageInfo info = base.GetFrameworkPackageInfo (packageName);
- info.Name = "moonlight-web-" + fxVersion;
- info.Description = "Moonlight " + fxVersion;
- info.Version = pluginVersion;
- return info;
- }
-
- public override string GetToolPath (string toolName)
- {
- // never run smcs.exe directly.
- // base method also checks for the exe in each path, but don't want that
- // it needs magic mono runtime args and maybe a special runtime.
- if (toolName == "csc" || toolName == "mcs" || toolName == "smcs")
- return GetToolsPaths ().Select (p => Path.Combine (p, "smcs")).Where (File.Exists).FirstOrDefault ();
-
- return base.GetToolPath (toolName);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightParser.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightParser.cs
deleted file mode 100644
index 229f98d801..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightParser.cs
+++ /dev/null
@@ -1,186 +0,0 @@
-//
-// MoonlightParser.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Xml;
-
-using MonoDevelop.Xml.StateEngine;
-using MonoDevelop.Ide.TypeSystem;
-using ICSharpCode.NRefactory.TypeSystem;
-using ICSharpCode.NRefactory.TypeSystem.Implementation;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.Moonlight
-{
- public class MoonlightParser : AbstractTypeSystemParser
- {
- public override ParsedDocument Parse (bool storeAst, string fileName, TextReader tr, Project project = null)
- {
- XmlParsedDocument doc = new XmlParsedDocument (fileName);
- try {
- Parser xmlParser = new Parser (new XmlFreeState (), true);
- xmlParser.Parse (tr);
- doc.XDocument = xmlParser.Nodes.GetRoot ();
- doc.Add (xmlParser.Errors);
-
- if (doc.XDocument != null && doc.XDocument.RootElement != null) {
- if (!doc.XDocument.RootElement.IsEnded)
- doc.XDocument.RootElement.End (xmlParser.Location);
- GenerateCU (doc);
- }
- }
- catch (Exception ex) {
- MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing xaml document", ex);
- }
- return doc;
- }
-
- static void GenerateCU (XmlParsedDocument doc)
- {
- if (doc.XDocument == null || doc.XDocument.RootElement == null) {
- doc.Add (new Error (ErrorType.Error, "No root node found.", 1, 1));
- return;
- }
-
- XAttribute rootClass = doc.XDocument.RootElement.Attributes [new XName ("x", "Class")];
- if (rootClass == null) {
- doc.Add (new Error (ErrorType.Error, "Root node does not contain an x:Class attribute.", 1, 1));
- return;
- }
-
- bool isApplication = doc.XDocument.RootElement.Name.Name == "Application";
-
- string rootNamespace, rootType, rootAssembly;
- XamlG.ParseXmlns (rootClass.Value, out rootType, out rootNamespace, out rootAssembly);
-
- var cu = new DefaultParsedDocument (doc.FileName);
-
- DomRegion rootRegion = doc.XDocument.RootElement.Region;
- if (doc.XDocument.RootElement.IsClosed)
- rootRegion = new DomRegion (doc.XDocument.RootElement.Region.FileName, doc.XDocument.RootElement.Region.Begin, doc.XDocument.RootElement.ClosingTag.Region.End);
-
- var declType = new DefaultUnresolvedTypeDefinition (rootNamespace, rootType) {
- Kind = TypeKind.Class,
- Accessibility = Accessibility.Public,
- Region = rootRegion
- };
- cu.TopLevelTypeDefinitions.Add (declType);
-
- var initcomp = new DefaultUnresolvedMethod (declType, "InitializeComponent") {
- ReturnType = KnownTypeReference.Void,
- Accessibility = Accessibility.Public
- };
- declType.Members.Add (initcomp);
-
- var _contentLoaded = new DefaultUnresolvedField (declType, "_contentLoaded") {
- ReturnType = KnownTypeReference.Boolean
- };
-// was missing in the original code: correct ?
-// declType.Fields.Add (_contentLoaded);
-
- if (isApplication)
- return;
-
-// cu.Add (new DomUsing (DomRegion.Empty, "System"));
-// cu.Add (new DomUsing (DomRegion.Empty, "System.Windows"));
-// cu.Add (new DomUsing (DomRegion.Empty, "System.Windows.Controls"));
-// cu.Add (new DomUsing (DomRegion.Empty, "System.Windows.Documents"));
-// cu.Add (new DomUsing (DomRegion.Empty, "System.Windows.Input"));
-// cu.Add (new DomUsing (DomRegion.Empty, "System.Windows.Media"));
-// cu.Add (new DomUsing (DomRegion.Empty, "System.Windows.Media.Animation"));
-// cu.Add (new DomUsing (DomRegion.Empty, "System.Windows.Shapes"));
-// cu.Add (new DomUsing (DomRegion.Empty, "System.Windows.Controls.Primitives"));
-
- // Dictionary<string,string> namespaceMap = new Dictionary<string, string> ();
- // namespaceMap["x"] = "http://schemas.microsoft.com/winfx/2006/xaml";
-
- XName nameAtt = new XName ("x", "Name");
-
- foreach (XElement el in doc.XDocument.RootElement.AllDescendentElements) {
- XAttribute name = el.Attributes [nameAtt];
- if (name != null && name.IsComplete) {
- string type = ResolveType (el);
- if (type == null || type.Length == 0)
- cu.Add (new Error (ErrorType.Error, "Could not find namespace for '" + el.Name.FullName + "'.", el.Region.Begin));
- else
- declType.Members.Add (new DefaultUnresolvedField (declType, name.Value) {
- Accessibility = Accessibility.Internal,
- Region = el.Region,
- ReturnType = new DefaultUnresolvedTypeDefinition (type)
- });
- }
- }
- }
-
- static string GetNamespace (XElement el)
- {
- XName attName;
- if (el.Name.HasPrefix) {
- attName = new XName ("xmlns", el.Name.Prefix);
- } else {
- attName = new XName ("xmlns");
- XAttribute att = el.Attributes[attName];
- if (att != null)
- return att.Value;
- }
-
- foreach (XNode node in el.Parents) {
- XElement parentElement = node as XElement;
- if (parentElement != null) {
- XAttribute att = parentElement.Attributes[attName];
- if (att != null)
- return att.Value;
- }
- }
- return null;
- }
-
- static string PresentationNS = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
-
- static string ResolveType (XElement el)
- {
- string name = el.Name.Name;
- string ns = GetNamespace (el);
- if (ns != null) {
- if (ns.StartsWith ("clr-namespace:")) {
- int end = ns.IndexOf (';', 14);
- if (end > 0)
- return ns.Substring (14, ns.Length - end + 1);
- else
- return (ns.Substring (14));
- } else if (ns == PresentationNS) {
- return el.Name.Name;
- }
- }
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProject.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProject.cs
deleted file mode 100644
index e1834884fe..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProject.cs
+++ /dev/null
@@ -1,437 +0,0 @@
-//
-// MoonlightProject.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-using System.Xml;
-using System.IO;
-
-using MonoDevelop.Core;
-using MonoDevelop.Core.ProgressMonitoring;
-using MonoDevelop.Core.Serialization;
-using MonoDevelop.Projects;
-using MonoDevelop.AspNet.Gui;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Core.Assemblies;
-
-namespace MonoDevelop.Moonlight
-{
-
-
- public class MoonlightProject : DotNetProject
- {
-
- public MoonlightProject ()
- : base ()
- {
- }
-
- public MoonlightProject (string languageName)
- : base (languageName)
- {
- }
-
- public MoonlightProject (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
- : base (languageName, info, projectOptions)
- {
- XmlNode silverAppNode = projectOptions.SelectSingleNode ("SilverlightApplication");
- if (silverAppNode == null || !Boolean.TryParse (silverAppNode.InnerText, out silverlightApplication))
- throw new Exception ("Moonlight template is missing SilverlightApplication node");
-
-
- XmlNode validateXmlNode = projectOptions.SelectSingleNode ("ValidateXaml");
- if (validateXmlNode != null && !Boolean.TryParse (validateXmlNode.InnerText, out validateXaml))
- throw new Exception ("Bad value in ValidateXaml template element");
-
- XmlNode throwErrorsNode = projectOptions.SelectSingleNode ("ThrowErrorsInValidation");
- if (throwErrorsNode != null && !Boolean.TryParse (throwErrorsNode.InnerText, out throwErrorsInValidation))
- throw new Exception ("Bad value in ThrowErrorsInValidation template element");
-
- if (!silverlightApplication)
- //it's a classlib, and the rest of the options don't apply
- return;
-
- XmlNode manifestNode = projectOptions.SelectSingleNode ("SilverlightManifestTemplate");
- if (manifestNode != null) {
- generateSilverlightManifest = true;
- silverlightManifestTemplate = manifestNode.InnerText;
- }
-
- xapOutputs = true;
- xapFilename = info.ProjectName + ".xap";
-
- XmlNode testPageNode = projectOptions.SelectSingleNode ("SilverlightTestPage");
- if (testPageNode != null)
- testPageFileName = testPageNode.InnerText;
- else
- createTestPage = true;
-
- //default namespace isn't initialised yet, but this should be okay OOTB
- silverlightAppEntry = info.ProjectName + ".App";
- generateSilverlightManifest = true;
- }
-
- public override TargetFrameworkMoniker GetDefaultTargetFrameworkForFormat (FileFormat format)
- {
- switch (format.Id) {
- case "MSBuild08":
- return new TargetFrameworkMoniker ("Silverlight", "3.0");
- default:
- return new TargetFrameworkMoniker ("Silverlight", "4.0");
- }
- }
-
- public override TargetFrameworkMoniker GetDefaultTargetFrameworkId ()
- {
- return new TargetFrameworkMoniker ("Silverlight", "4.0");
- }
-
- public override SolutionItemConfiguration CreateConfiguration (string name)
- {
- var conf = new MoonlightProjectConfiguration (name);
- conf.CopyFrom (base.CreateConfiguration (name));
- return conf;
- }
-
- public override bool SupportsFramework (MonoDevelop.Core.Assemblies.TargetFramework framework)
- {
- return framework.Id.Identifier == "Silverlight";
- }
-
- public override bool SupportsFormat (FileFormat format)
- {
- return format.Id == "MSBuild08" || format.Id == "MSBuild10";
- }
-
- public override string ProjectType {
- get { return "Moonlight"; }
- }
-
- public override bool IsLibraryBasedProjectType {
- get { return true; }
- }
-
- ExecutionCommand CreateExecutionCommand (ConfigurationSelector solutionConfig, MoonlightProjectConfiguration configuration)
- {
- string url = GetUrl (configuration);
- if (url != null) {
- return new MoonlightExecutionCommand (this.Name, url) {
- UserAssemblyPaths = GetUserAssemblyPaths (solutionConfig)
- };
- }
- return null;
- }
-
- string GetUrl (MoonlightProjectConfiguration config)
- {
- if (!this.SilverlightApplication || config == null)
- return null;
-
- string url = this.StartPageUrl;
-
- if (string.IsNullOrEmpty (url) && this.CreateTestPage) {
- string testPage = this.TestPageFileName;
- if (String.IsNullOrEmpty (testPage))
- testPage = "TestPage.html";
- url = Path.Combine (config.OutputDirectory, testPage);
- }
-
- if (!url.StartsWith ("http://", StringComparison.OrdinalIgnoreCase)
- && !url.StartsWith ("https://", StringComparison.OrdinalIgnoreCase))
- {
- url = "file://" + url.Replace (Path.PathSeparator, '/');
- }
-
- return url;
- }
-
- protected override bool OnGetCanExecute (ExecutionContext context, ConfigurationSelector solutionConfiguration)
- {
- var conf = (MoonlightProjectConfiguration) GetConfiguration (solutionConfiguration);
- return context.ExecutionHandler.CanExecute (CreateExecutionCommand (solutionConfiguration, conf));
- }
-
- // do this directly instead of relying on the commands handler
- // to stop MD from opening an output pad
- protected override void DoExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
- {
- var conf = (MoonlightProjectConfiguration) GetConfiguration (configuration);
-
- IConsole console = null;
-
- try {
- // The MoonlightExecutionHandler doesn't output anything to a console, so special-case it
- // Other handlers, like the debug handler, do need a console, so we still need to create one in that case
- // HACK: we can't get the type of the MoonlightExecutionHandler directly, so for now assume that
- // we don't want to show a console for DefaultExecutionHandler
- if (!(context.ExecutionHandler is MoonlightExecutionHandler)
- && !(context.ExecutionHandler.GetType ().Name == "DefaultExecutionHandler"))
- {
- console = conf.ExternalConsole
- ? context.ExternalConsoleFactory.CreateConsole (!conf.PauseConsoleOutput)
- : context.ConsoleFactory.CreateConsole (!conf.PauseConsoleOutput);
- }
-
- var cmd = CreateExecutionCommand (configuration, conf);
- using (var opMon = new AggregatedOperationMonitor (monitor)) {
- var ex = context.ExecutionHandler.Execute (cmd, console);
- opMon.AddOperation (ex);
- ex.WaitForCompleted ();
- }
- } finally {
- if (console != null)
- console.Dispose ();
- }
- }
-
- #region VS-compatible MSBuild properties
-
- [ItemProperty("SilverlightApplication")]
- bool silverlightApplication = false;
-
- [ItemProperty("XapOutputs", DefaultValue=false)]
- bool xapOutputs = false;
-
- [ItemProperty("GenerateSilverlightManifest", DefaultValue=false)]
- bool generateSilverlightManifest = false;
-
- [ItemProperty("XapFilename", DefaultValue="")]
- string xapFilename = string.Empty;
-
- [ProjectPathItemProperty("SilverlightManifestTemplate")]
- string silverlightManifestTemplate;
-
- [ItemProperty("SilverlightAppEntry", DefaultValue="")]
- string silverlightAppEntry = string.Empty;
-
- [ItemProperty("TestPageFileName", DefaultValue="")]
- string testPageFileName = string.Empty;
-
- [ItemProperty("CreateTestPage", DefaultValue=false)]
- bool createTestPage = false;
-
- [ProjectPathItemProperty("StartPageUrl", DefaultValue="", IsExternal=true)]
- string startPageUrl = string.Empty;
-
- [ItemProperty("ValidateXaml")]
- bool validateXaml = true;
-
- [ItemProperty("ThrowErrorsInValidation")]
- bool throwErrorsInValidation = false;
-
- //FIXME: how can we ensure this goes after the TargetFrameworkVersion element?
- //why do we even need to deserialize it?
- [ItemProperty("SilverlightVersion")]
- string silverlightVersion = "$(TargetFrameworkVersion)";
-
- //whether it's an application or a classlib
- public bool SilverlightApplication {
- get { return silverlightApplication; }
- set {
- if (silverlightApplication == value)
- return;
- NotifyModified ("SilverlightApplication");
- silverlightApplication = value;
- }
- }
-
- public bool XapOutputs {
- get { return xapOutputs; }
- set {
- if (xapOutputs == value)
- return;
- NotifyModified ("XapOutputs");
- xapOutputs = value;
- }
- }
-
- public bool GenerateSilverlightManifest {
- get { return generateSilverlightManifest; }
- set {
- if (generateSilverlightManifest == value)
- return;
- NotifyModified ("GenerateSilverlightManifest");
- generateSilverlightManifest = value;
- }
- }
-
- public string XapFilename {
- get { return xapFilename; }
- set {
- if (xapFilename == value)
- return;
- NotifyModified ("XapFilename");
- xapFilename = value;
- }
- //VBSilver.xap
- }
-
- public string SilverlightManifestTemplate {
- get { return silverlightManifestTemplate; }
- set {
- if (silverlightManifestTemplate == value)
- return;
- NotifyModified ("SilverlightManifestTemplate");
- silverlightManifestTemplate = value;
- }
- //My Project\AppManifest.xml
- }
-
- public string SilverlightAppEntry {
- get { return silverlightAppEntry; }
- set {
- if (silverlightAppEntry == value)
- return;
- NotifyModified ("SilverlightAppEntry");
- silverlightAppEntry = value;
- }
- //VBSilver.App
- }
-
- public string TestPageFileName {
- get { return testPageFileName; }
- set {
- if (testPageFileName == value)
- return;
- NotifyModified ("TestPageFileName");
- testPageFileName = value;
- }
- // TestPage.html
- }
-
- public bool CreateTestPage {
- get { return createTestPage; }
- set {
- if (createTestPage == value)
- return;
- NotifyModified ("CreateTestPage");
- createTestPage = value;
- }
- }
-
- public bool ValidateXaml {
- get { return validateXaml; }
- set {
- if (validateXaml == value)
- return;
- NotifyModified ("ValidateXaml");
- validateXaml = value;
- }
- }
-
- public bool ThrowErrorsInValidation {
- get { return throwErrorsInValidation; }
- set {
- if (throwErrorsInValidation == value)
- return;
- NotifyModified ("ThrowErrorsInValidation");
- throwErrorsInValidation = value;
- }
- }
-
- public string StartPageUrl {
- get { return startPageUrl; }
- set {
- if (startPageUrl == value)
- return;
- NotifyModified ("StartPageUrl");
- startPageUrl = value;
- }
- }
-
- #endregion
-
- #region File events
-
- static string[] groupedExtensions = { ".xaml" };
-
- protected override void OnFileAddedToProject (ProjectFileEventArgs args)
- {
- //short-circuit if the project is being deserialised
- if (Loading) {
- base.OnFileAddedToProject (args);
- return;
- }
-
- List<string> filesToAdd = new List<string> ();
- foreach (ProjectFileEventInfo e in args) {
- //set some properties automatically
- if (Path.GetExtension (e.ProjectFile.FilePath) == ".xaml") {
- e.ProjectFile.Generator = "MSBuild:MarkupCompilePass1";
- e.ProjectFile.ContentType = "Designer";
-
- //fixme: detect Application xaml?
- //if (e.ProjectFile.BuildAction == BuildAction.Page
- // && Path.GetFileName (e.ProjectFile.Name).Contains ("Application"))
- //{
- // e.ProjectFile.BuildAction = BuildAction.ApplicationDefinition;
- //}
- }
-
- //find any related files, e.g codebehind
- IEnumerable<string> files = MonoDevelop.DesignerSupport.CodeBehind.GuessDependencies
- (this, e.ProjectFile, groupedExtensions);
- if (files != null)
- filesToAdd.AddRange (files);
- }
-
- //let the base fire the event before we add files
- //don't want to fire events out of order of files being added
- base.OnFileAddedToProject (args);
-
- //make sure that the parent and child files are in the project
- foreach (string file in filesToAdd) {
- //NOTE: this only adds files if they are not already in the project
- AddFile (file);
- }
- }
-
- public override string GetDefaultBuildAction (string fileName)
- {
- if (Path.GetExtension (fileName) == ".xaml") {
- return BuildAction.Page;
- } else {
- return base.GetDefaultBuildAction (fileName);
- }
- }
-
- protected override IList<string> GetCommonBuildActions ()
- {
- return new string[] {
- BuildAction.None,
- BuildAction.Compile,
- BuildAction.Content,
- BuildAction.EmbeddedResource,
- BuildAction.Resource,
- BuildAction.ApplicationDefinition,
- };
- }
-
- #endregion
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProjectBinding.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProjectBinding.cs
deleted file mode 100644
index dae16e37c4..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProjectBinding.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// MoonlightProjectBinding.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Xml;
-
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.Moonlight
-{
-
-
- public class MoonlightProjectBinding : DotNetProjectBinding
- {
-
- public override string Name {
- get { return "Moonlight"; }
- }
-
- protected override DotNetProject CreateProject (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
- {
- return new MoonlightProject (languageName, info, projectOptions);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProjectConfiguration.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProjectConfiguration.cs
deleted file mode 100644
index 2c38c66bd3..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightProjectConfiguration.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// MoonlightProjectConfiguration.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.Moonlight
-{
-
-
- public class MoonlightProjectConfiguration : DotNetProjectConfiguration
- {
-
- public MoonlightProjectConfiguration ()
- {
- }
-
- public MoonlightProjectConfiguration (string name) : base (name)
- {
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/XamlG.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/XamlG.cs
deleted file mode 100644
index 7765742003..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/XamlG.cs
+++ /dev/null
@@ -1,289 +0,0 @@
-//
-// Xamlg.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using System.Collections;
-using System.IO;
-using System.Xml;
-
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.Moonlight
-{
-
-
- static class XamlG
- {
- private static bool sl2 = true;
-
- public static BuildResult GenerateFile (CodeDomProvider provider, string app_name,
- string xaml_file, string xaml_path_in_project, string out_file)
- {
- XmlDocument xmldoc = new XmlDocument ();
- xmldoc.Load (xaml_file);
-
- BuildResult result = new BuildResult ();
-
- XmlNamespaceManager nsmgr = new XmlNamespaceManager (xmldoc.NameTable);
- nsmgr.AddNamespace("x", "http://schemas.microsoft.com/winfx/2006/xaml");
-
- XmlNode root = xmldoc.SelectSingleNode ("/*", nsmgr);
- if (root == null) {
- result.AddError (xaml_file, 0, 0, "", "No root node found.");
- return result;
- }
-
- XmlAttribute root_class = root.Attributes ["x:Class"];
- if (root_class == null) {
- File.WriteAllText (out_file, "");
- return result;
- }
-
- bool is_application = root.LocalName == "Application";
- string root_ns;
- string root_type;
- string root_asm;
-
- ParseXmlns (root_class.Value, out root_type, out root_ns, out root_asm);
-
- Hashtable names_and_types = GetNamesAndTypes (root, nsmgr);
-// Hashtable keys_and_types = GetKeysAndTypes (root, nsmgr);
-
- CodeCompileUnit ccu = new CodeCompileUnit ();
- CodeNamespace decl_ns = new CodeNamespace (root_ns);
- ccu.Namespaces.Add (decl_ns);
-
- decl_ns.Imports.Add (new CodeNamespaceImport ("System"));
- decl_ns.Imports.Add (new CodeNamespaceImport ("System.Windows"));
- decl_ns.Imports.Add (new CodeNamespaceImport ("System.Windows.Controls"));
- decl_ns.Imports.Add (new CodeNamespaceImport ("System.Windows.Documents"));
- decl_ns.Imports.Add (new CodeNamespaceImport ("System.Windows.Input"));
- decl_ns.Imports.Add (new CodeNamespaceImport ("System.Windows.Media"));
- decl_ns.Imports.Add (new CodeNamespaceImport ("System.Windows.Media.Animation"));
- decl_ns.Imports.Add (new CodeNamespaceImport ("System.Windows.Shapes"));
- decl_ns.Imports.Add (new CodeNamespaceImport ("System.Windows.Controls.Primitives"));
-
- CodeTypeDeclaration decl_type = new CodeTypeDeclaration (root_type);
- decl_type.IsPartial = true;
-
- decl_ns.Types.Add (decl_type);
-
- CodeMemberMethod initcomp = new CodeMemberMethod ();
- initcomp.Name = "InitializeComponent";
- decl_type.Members.Add (initcomp);
-
- if (sl2) {
- CodeMemberField field = new CodeMemberField ();
- field.Name = "_contentLoaded";
- field.Type = new CodeTypeReference (typeof (bool));
-
- decl_type.Members.Add (field);
-
- CodeConditionStatement is_content_loaded = new CodeConditionStatement (new CodeVariableReferenceExpression ("_contentLoaded"),
- new CodeStatement [] { new CodeMethodReturnStatement () });
- initcomp.Statements.Add (is_content_loaded);
-
- CodeAssignStatement set_content_loaded = new CodeAssignStatement (new CodeVariableReferenceExpression ("_contentLoaded"),
- new CodePrimitiveExpression (true));
-
- initcomp.Statements.Add (set_content_loaded);
-
- string component_path = String.Format ("/{0};component/{1}", app_name, xaml_path_in_project);
- CodeMethodInvokeExpression load_component = new CodeMethodInvokeExpression (
- new CodeTypeReferenceExpression ("System.Windows.Application"), "LoadComponent",
- new CodeExpression [] { new CodeThisReferenceExpression (),
- new CodeObjectCreateExpression (new CodeTypeReference ("System.Uri"), new CodeExpression [] {
- new CodePrimitiveExpression (component_path),
- new CodeFieldReferenceExpression (new CodeTypeReferenceExpression ("System.UriKind"), "Relative") })
- });
- initcomp.Statements.Add (load_component);
- }
-
- if (!is_application) {
- foreach (DictionaryEntry entry in names_and_types) {
- string name = (string) entry.Key;
- CodeTypeReference type = (CodeTypeReference) entry.Value;
-
- CodeMemberField field = new CodeMemberField ();
-
- if (sl2)
- field.Attributes = MemberAttributes.Assembly;
-
- field.Name = name;
- field.Type = type;
-
- decl_type.Members.Add (field);
-
- CodeMethodInvokeExpression find_invoke = new CodeMethodInvokeExpression (
- new CodeThisReferenceExpression(), "FindName",
- new CodeExpression[] { new CodePrimitiveExpression (name) } );
-
- CodeCastExpression cast = new CodeCastExpression (type, find_invoke);
-
- CodeAssignStatement assign = new CodeAssignStatement (
- new CodeVariableReferenceExpression (name), cast);
-
- initcomp.Statements.Add (assign);
- }
- }
-
-
- using (StreamWriter writer = new StreamWriter (out_file)) {
- provider.GenerateCodeFromCompileUnit (ccu, writer, new CodeGeneratorOptions ());
- }
-
- return result;
- }
-
- private static Hashtable GetNamesAndTypes (XmlNode root, XmlNamespaceManager nsmgr)
- {
- Hashtable res = new Hashtable ();
-
- XmlNodeList names = root.SelectNodes ("//*[@x:Name]", nsmgr);
- foreach (XmlNode node in names) {
-
- // Don't take the root canvas
- if (node == root)
- continue;
-
- XmlAttribute attr = node.Attributes ["x:Name"];
- string name = attr.Value;
- string ns = GetNamespace (node);
- string member_type = node.LocalName;
-
- if (ns != null)
- member_type = String.Concat (ns, ".", member_type);
-
- CodeTypeReference type = new CodeTypeReference (member_type);
- if (ns != null)
- type.Options |= CodeTypeReferenceOptions.GlobalReference;
-
- res [name] = type;
- }
-
- return res;
- }
-
- /*
- private static Hashtable GetKeysAndTypes (XmlNode root, XmlNamespaceManager nsmgr)
- {
- Hashtable res = new Hashtable ();
-
- XmlNodeList keys = root.SelectNodes ("//*[@x:Key]", nsmgr);
- foreach (XmlNode node in keys) {
-
- // Don't take the root canvas
- if (node == root)
- continue;
-
- XmlAttribute attr = node.Attributes ["x:Key"];
- string key = attr.Value;
- string ns = GetNamespace (node);
- string member_type = node.LocalName;
-
- if (ns != null)
- member_type = String.Concat (ns, ".", member_type);
-
- res [key] = member_type;
- }
-
- return res;
- }
- */
-
- internal static string GetNamespace (XmlNode node)
- {
- if (!IsCustom (node.NamespaceURI))
- return null;
-
- return ParseNamespaceFromXmlns (node.NamespaceURI);
- }
-
- private static bool IsCustom (string ns)
- {
- switch (ns) {
- case "http://schemas.microsoft.com/winfx/2006/xaml":
- case "http://schemas.microsoft.com/winfx/2006/xaml/presentation":
- case "http://schemas.microsoft.com/client/2007":
- return false;
- }
-
- return true;
- }
-
- private static string ParseNamespaceFromXmlns (string xmlns)
- {
- string type_name = null;
- string ns = null;
- string asm = null;
-
- ParseXmlns (xmlns, out type_name, out ns, out asm);
-
- return ns;
- }
-
-// private static string ParseTypeFromXmlns (string xmlns)
-// {
-// string type_name = null;
-// string ns = null;
-// string asm = null;
-//
-// ParseXmlns (xmlns, out type_name, out ns, out asm);
-//
-// return type_name;
-// }
-
- internal static void ParseXmlns (string xmlns, out string type_name, out string ns, out string asm)
- {
- type_name = null;
- ns = null;
- asm = null;
-
- string [] decls = xmlns.Split (';');
- foreach (string decl in decls) {
- if (decl.StartsWith ("clr-namespace:")) {
- ns = decl.Substring (14, decl.Length - 14);
- continue;
- }
- if (decl.StartsWith ("assembly=")) {
- asm = decl.Substring (9, decl.Length - 9);
- continue;
- }
- int nsind = decl.LastIndexOf (".");
- if (nsind > 0) {
- ns = decl.Substring (0, nsind);
- type_name = decl.Substring (nsind + 1, decl.Length - nsind - 1);
- } else {
- type_name = decl;
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-ApplicationProject.xpt.xml b/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-ApplicationProject.xpt.xml
deleted file mode 100644
index 2fb87c8a2f..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-ApplicationProject.xpt.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-<?xml version="1.0"?>
-<Template originator="Michael Hutchinson"
- created="2008/03/04"
- lastModified="2008/03/04">
-
- <!-- Template Header -->
- <TemplateConfiguration>
- <_Name>Moonlight Application Project</_Name>
- <_Category>C#/Moonlight</_Category>
- <LanguageName>C#</LanguageName>
- <_Description>Creates a Moonlight application project.</_Description>
- </TemplateConfiguration>
-
- <!-- Actions -->
- <Actions>
- </Actions>
-
- <!-- Template Content -->
- <Combine name = "${ProjectName}" directory = ".">
- <Options>
- <StartupProject>${ProjectName}</StartupProject>
- </Options>
-
- <Project name = "${ProjectName}" directory = "." type = "Moonlight">
- <Options>
- <SilverlightApplication>True</SilverlightApplication>
- </Options>
- <References>
- <Reference type="Package" refto="System.Windows" />
- <Reference type="Package" refto="mscorlib" />
- <Reference type="Package" refto="System" />
- <Reference type="Package" refto="System.Core" />
- <Reference type="Package" refto="System.Xml" />
- <Reference type="Package" refto="System.Net" />
- <Reference type="Package" refto="System.Windows.Browser" />
- </References>
- <Files>
- <File name="App.xaml" DefaultExtension=".xaml" BuildAction="ApplicationDefinition">
-<![CDATA[<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- x:Class="${Namespace}.App"
->
- <Application.Resources>
- </Application.Resources>
-</Application>
-]]></File>
-
- <CodeTranslationFile name="App.xaml.${LanguageExtension}" DependsOn="App.xaml" >
-<![CDATA[using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace ${Namespace}
-{
-
- public partial class App : Application
- {
-
- public App ()
- {
- this.Startup += new StartupEventHandler (OnStartup);
- InitializeComponent ();
- }
-
- void OnStartup (object sender, StartupEventArgs args)
- {
- this.RootVisual = new Page ();
- }
- }
-}]]>
- </CodeTranslationFile>
- <File name="Page.xaml" DefaultExtension=".xaml" BuildAction="Page">
-<![CDATA[<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Width="500" Height="350"
- x:Class="${Namespace}.${Name}"
->
- <Grid x:Name="LayoutRoot" Background="Black">
- <TextBlock FontSize="30" Foreground="White">Hello Moon!</TextBlock>
- </Grid>
-</UserControl>
-]]></File>
-
- <CodeTranslationFile name="Page.xaml.${LanguageExtension}" DependsOn="Page.xaml" >
-<![CDATA[using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace ${Namespace}
-{
-
- public partial class Page : UserControl
- {
-
- public Page ()
- {
- InitializeComponent ();
- }
-
- }
-}]]>
- </CodeTranslationFile>
- </Files>
- </Project>
- </Combine>
-</Template>
diff --git a/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-ApplicationXaml.xft.xml b/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-ApplicationXaml.xft.xml
deleted file mode 100644
index 217cd6e95c..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-ApplicationXaml.xft.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0"?>
-<Template originator="Michael Hutchinson"
- created="2008/03/04"
- lastModified="2008/03/04">
-
- <!-- Template Header -->
- <TemplateConfiguration>
- <_Name>Moonlight Application</_Name>
- <Icon>md-html-file-icon</Icon>
- <_Category>Moonlight</_Category>
- <LanguageName>*</LanguageName>
- <ProjectType>Moonlight</ProjectType>
- <_Description>Creates a Moonlight/Silverlight Application with a CodeBehind class.</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- </Conditions>
-
- <!-- Template Content -->
- <TemplateFiles>
- <File name="${Name}.xaml" DefaultExtension=".xaml" BuildAction="ApplicationDefinition">
-<![CDATA[<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- x:Class="${Namespace}.${Name}"
->
- <Application.Resources>
- </Application.Resources>
-</Application>
-]]></File>
-
- <CodeTranslationFile name="${Name}.xaml.${LanguageExtension}" DependsOn="${Name}.xaml" >
-<![CDATA[using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace ${Namespace}
-{
-
- public partial class ${EscapedIdentifier} : Application
- {
-
- public ${EscapedIdentifier} ()
- {
- InitializeComponent ();
- }
-
- }
-}]]>
- </CodeTranslationFile>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-LibraryProject.xpt.xml b/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-LibraryProject.xpt.xml
deleted file mode 100644
index 7285ca9b50..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-LibraryProject.xpt.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0"?>
-<Template originator="Michael Hutchinson"
- created="2008/03/04"
- lastModified="2008/03/04">
-
- <!-- Template Header -->
- <TemplateConfiguration>
- <_Name>Moonlight Library Project</_Name>
- <_Category>C#/Moonlight</_Category>
- <LanguageName>C#</LanguageName>
- <_Description>Creates a Moonlight class library project.</_Description>
- </TemplateConfiguration>
-
- <!-- Actions -->
- <Actions>
- </Actions>
-
- <!-- Template Content -->
- <Combine name = "${ProjectName}" directory = ".">
- <Options>
- <StartupProject>${ProjectName}</StartupProject>
- </Options>
-
- <Project name = "${ProjectName}" directory = "." type = "Moonlight">
- <Options>
- <SilverlightApplication>False</SilverlightApplication>
- </Options>
- <References>
- <Reference type="Package" refto="System.Windows" />
- <Reference type="Package" refto="mscorlib" />
- <Reference type="Package" refto="System" />
- <Reference type="Package" refto="System.Core" />
- <Reference type="Package" refto="System.Xml" />
- <Reference type="Package" refto="System.Net" />
- <Reference type="Package" refto="System.Windows.Browser" />
- </References>
- <Files>
- </Files>
- </Project>
- </Combine>
-</Template>
diff --git a/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-UserControlXaml.xft.xml b/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-UserControlXaml.xft.xml
deleted file mode 100644
index 6b9d8cbbf6..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Templates/Moonlight-UserControlXaml.xft.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0"?>
-<Template originator="Michael Hutchinson"
- created="2008/03/04"
- lastModified="2008/03/04">
-
- <!-- Template Header -->
- <TemplateConfiguration>
- <_Name>Moonlight User Control</_Name>
- <Icon>md-html-file-icon</Icon>
- <_Category>Moonlight</_Category>
- <LanguageName>*</LanguageName>
- <ProjectType>Moonlight</ProjectType>
- <_Description>Creates a Moonlight/Silverlight User Control with a CodeBehind class.</_Description>
- </TemplateConfiguration>
-
- <Conditions>
- </Conditions>
-
- <!-- Template Content -->
- <TemplateFiles>
- <File name="${Name}.xaml" DefaultExtension=".xaml" BuildAction="Page">
-<![CDATA[<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Width="500" Height="350"
- x:Class="${Namespace}.${Name}"
->
- <Grid x:Name="LayoutRoot" Background="White">
-
- </Grid>
-</UserControl>
-]]></File>
-
- <CodeTranslationFile name="${Name}.xaml.${LanguageExtension}" DependsOn="${Name}.xaml" >
-<![CDATA[using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace ${Namespace}
-{
-
- public partial class ${EscapedIdentifier} : UserControl
- {
-
- public ${EscapedIdentifier} ()
- {
- InitializeComponent ();
- }
-
- }
-}]]>
- </CodeTranslationFile>
- </TemplateFiles>
-</Template>
diff --git a/main/src/addins/MonoDevelop.Moonlight/Templates/PreviewTemplate.html b/main/src/addins/MonoDevelop.Moonlight/Templates/PreviewTemplate.html
deleted file mode 100644
index 2be0575995..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Templates/PreviewTemplate.html
+++ /dev/null
@@ -1,76 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" >
-<head>
- <title>@TITLE@</title>
-
- <style type="text/css">
- html, body {
- height: 100%;
- overflow: auto;
- }
- body {
- padding: 0;
- margin: 0;
- }
- #silverlightControlHost {
- height: 100%;
- }
- </style>
-
- <script type="text/javascript">
- function onSilverlightError(sender, args) {
-
- var appSource = "";
- if (sender != null && sender != 0) {
- appSource = sender.getHost().Source;
- }
- var errorType = args.ErrorType;
- var iErrorCode = args.ErrorCode;
-
- var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n" ;
-
- errMsg += "Code: "+ iErrorCode + " \n";
- errMsg += "Category: " + errorType + " \n";
- errMsg += "Message: " + args.ErrorMessage + " \n";
-
- if (errorType == "ParserError")
- {
- errMsg += "File: " + args.xamlFile + " \n";
- errMsg += "Line: " + args.lineNumber + " \n";
- errMsg += "Position: " + args.charPosition + " \n";
- }
- else if (errorType == "RuntimeError")
- {
- if (args.lineNumber != 0)
- {
- errMsg += "Line: " + args.lineNumber + " \n";
- errMsg += "Position: " + args.charPosition + " \n";
- }
- errMsg += "MethodName: " + args.methodName + " \n";
- }
-
- throw new Error(errMsg);
- }
- </script>
-</head>
-
-<body>
- <!-- Runtime errors from Silverlight will be displayed here.
- This will contain debugging information and should be removed or hidden when debugging is completed -->
- <div id='errorLocation' style="font-size: small;color: Gray;"></div>
-
- <div id="silverlightControlHost">
- <object data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%">
- <param name="source" value="@XAP_FILE@"/>
- <param name="onerror" value="onSilverlightError" />
- <param name="background" value="white" />
- <param name="minRuntimeVersion" value="2.0.31005.0" />
- <param name="autoUpgrade" value="true" />
- <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
- <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
- </a>
- </object>
- <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
- </div>
-</body>
-</html>
diff --git a/main/src/addins/MonoDevelop.Moonlight/Templates/Silverlight.js b/main/src/addins/MonoDevelop.Moonlight/Templates/Silverlight.js
deleted file mode 100644
index 67853c14a5..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Templates/Silverlight.js
+++ /dev/null
@@ -1,891 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Silverlight.js version 2.0.31017.0
-//
-// This file is provided by Microsoft as a helper file for websites that
-// incorporate Silverlight Objects. This file is provided under the Microsoft
-// Public License available at
-// http://code.msdn.microsoft.com/silverlightjs/Project/License.aspx.
-// You may not use or distribute this file or the code in this file except as
-// expressly permitted under that license.
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-if (!window.Silverlight)
-{
- window.Silverlight = { };
-}
-
-//////////////////////////////////////////////////////////////////
-//
-// _silverlightCount:
-//
-// Counter of globalized event handlers
-//
-//////////////////////////////////////////////////////////////////
-Silverlight._silverlightCount = 0;
-
-//////////////////////////////////////////////////////////////////
-//
-// __onSilverlightInstalledCalled:
-//
-// Prevents onSilverlightInstalled from being called multiple
-// times
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.__onSilverlightInstalledCalled = false;
-
-//////////////////////////////////////////////////////////////////
-//
-// fwlinkRoot:
-//
-// Prefix for fwlink URL's
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.fwlinkRoot='http://go2.microsoft.com/fwlink/?LinkID=';
-
-//////////////////////////////////////////////////////////////////
-//
-// __installationEventFired:
-//
-// Ensures that only one Installation State event is fired.
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.__installationEventFired = false;
-
-//////////////////////////////////////////////////////////////////
-//
-// onGetSilverlight:
-//
-// Called by Silverlight.GetSilverlight to notify the page that a user
-// has requested the Silverlight installer
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.onGetSilverlight = null;
-
-//////////////////////////////////////////////////////////////////
-//
-// onSilverlightInstalled:
-//
-// Called by Silverlight.WaitForInstallCompletion when the page detects
-// that Silverlight has been installed. The event handler is not called
-// in upgrade scenarios.
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.onSilverlightInstalled = function () {window.location.reload(false);};
-
-//////////////////////////////////////////////////////////////////
-//
-// isInstalled:
-//
-// Checks to see if the correct version is installed
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.isInstalled = function(version)
-{
- if (version == undefined)
- version = null;
-
- var isVersionSupported = false;
- var container = null;
-
- try
- {
- var control = null;
- var tryNS = false;
-
- if (window.ActiveXObject)
- {
- try
- {
- control = new ActiveXObject('AgControl.AgControl');
- if (version === null)
- {
- isVersionSupported = true;
- }
- else if (control.IsVersionSupported(version))
- {
- isVersionSupported = true;
- }
- control = null;
- }
- catch (e)
- {
- tryNS = true;
- }
- }
- else
- {
- tryNS = true;
- }
- if (tryNS)
- {
- var plugin = navigator.plugins["Silverlight Plug-In"];
- if (plugin)
- {
- if (version === null)
- {
- isVersionSupported = true;
- }
- else
- {
- var actualVer = plugin.description;
- if (actualVer === "1.0.30226.2")
- actualVer = "2.0.30226.2";
- var actualVerArray = actualVer.split(".");
- while (actualVerArray.length > 3)
- {
- actualVerArray.pop();
- }
- while (actualVerArray.length < 4)
- {
- actualVerArray.push(0);
- }
- var reqVerArray = version.split(".");
- while (reqVerArray.length > 4)
- {
- reqVerArray.pop();
- }
-
- var requiredVersionPart;
- var actualVersionPart;
- var index = 0;
-
-
- do
- {
- requiredVersionPart = parseInt(reqVerArray[index]);
- actualVersionPart = parseInt(actualVerArray[index]);
- index++;
- }
- while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);
-
- if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart))
- {
- isVersionSupported = true;
- }
- }
- }
- }
- }
- catch (e)
- {
- isVersionSupported = false;
- }
-
- return isVersionSupported;
-};
-//////////////////////////////////////////////////////////////////
-//
-// WaitForInstallCompletion:
-//
-// Occasionally checks for Silverlight installation status. If it
-// detects that Silverlight has been installed then it calls
-// Silverlight.onSilverlightInstalled();. This is only supported
-// if Silverlight was not previously installed on this computer.
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.WaitForInstallCompletion = function()
-{
- if ( ! Silverlight.isBrowserRestartRequired && Silverlight.onSilverlightInstalled )
- {
- try
- {
- navigator.plugins.refresh();
- }
- catch(e)
- {
- }
- if (Silverlight.isInstalled(null) && !Silverlight.__onSilverlightInstalledCalled)
- {
- Silverlight.onSilverlightInstalled();
- Silverlight.__onSilverlightInstalledCalled = true;
- }
- else
- {
- setTimeout(Silverlight.WaitForInstallCompletion, 3000);
- }
- }
-};
-//////////////////////////////////////////////////////////////////
-//
-// __startup:
-//
-// Performs startup tasks.
-//////////////////////////////////////////////////////////////////
-Silverlight.__startup = function()
-{
- navigator.plugins.refresh();
- Silverlight.isBrowserRestartRequired = Silverlight.isInstalled(null);
- if (!Silverlight.isBrowserRestartRequired)
- {
- Silverlight.WaitForInstallCompletion();
- if (!Silverlight.__installationEventFired)
- {
- Silverlight.onInstallRequired();
- Silverlight.__installationEventFired = true;
- }
- }
- else if (window.navigator.mimeTypes)
- {
- var mimeSL2 = navigator.mimeTypes["application/x-silverlight-2"];
- var mimeSL2b2 = navigator.mimeTypes["application/x-silverlight-2-b2"];
- var mimeSL2b1 = navigator.mimeTypes["application/x-silverlight-2-b1"];
- var mimeHighestBeta = mimeSL2b1;
- if (mimeSL2b2)
- mimeHighestBeta = mimeSL2b2;
-
- if (!mimeSL2 && (mimeSL2b1 || mimeSL2b2))
- {
- if (!Silverlight.__installationEventFired)
- {
- Silverlight.onUpgradeRequired();
- Silverlight.__installationEventFired = true;
- }
- }
- else if (mimeSL2 && mimeHighestBeta)
- {
- if (mimeSL2.enabledPlugin &&
- mimeHighestBeta.enabledPlugin)
- {
- if (mimeSL2.enabledPlugin.description !=
- mimeHighestBeta.enabledPlugin.description)
- {
- if (!Silverlight.__installationEventFired)
- {
- Silverlight.onRestartRequired();
- Silverlight.__installationEventFired = true;
- }
- }
- }
- }
- }
- if (!Silverlight.disableAutoStartup)
- {
- if (window.removeEventListener)
- {
- window.removeEventListener('load', Silverlight.__startup, false);
- }
- else
- {
- window.detachEvent('onload', Silverlight.__startup);
- }
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// This block wires up Silverlight.__startup to be executed once the page
-// loads. This is the desired behavior for most sites. If, however, a site
-// prefers to control the timing of the Silverlight.__startup call then it should
-// put the following block of javascript into the webpage before this file is
-// included:
-//
-// <script type="text/javascript">
-// if (!window.Silverlight)
-// {
-// window.Silverlight = {};
-// }
-// Silverlight.disableAutoStartup = true;
-// </script>
-//
-/////////////////////////////////////////////////////////////////////////////////
-
-if (!Silverlight.disableAutoStartup)
-{
- if (window.addEventListener)
- {
- window.addEventListener('load', Silverlight.__startup, false);
- }
- else
- {
- window.attachEvent('onload', Silverlight.__startup);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// createObject:
-//
-// Inserts a Silverlight <object> tag or installation experience into the HTML
-// DOM based on the current installed state of Silverlight.
-//
-/////////////////////////////////////////////////////////////////////////////////
-
-Silverlight.createObject = function(source, parentElement, id, properties, events, initParams, userContext)
-{
- var slPluginHelper = new Object();
- var slProperties = properties;
- var slEvents = events;
-
- slPluginHelper.version = slProperties.version;
- slProperties.source = source;
- slPluginHelper.alt = slProperties.alt;
-
- //rename properties to their tag property names. For bacwards compatibility
- //with Silverlight.js version 1.0
- if ( initParams )
- slProperties.initParams = initParams;
- if ( slProperties.isWindowless && !slProperties.windowless)
- slProperties.windowless = slProperties.isWindowless;
- if ( slProperties.framerate && !slProperties.maxFramerate)
- slProperties.maxFramerate = slProperties.framerate;
- if ( id && !slProperties.id)
- slProperties.id = id;
-
- // remove elements which are not to be added to the instantiation tag
- delete slProperties.ignoreBrowserVer;
- delete slProperties.inplaceInstallPrompt;
- delete slProperties.version;
- delete slProperties.isWindowless;
- delete slProperties.framerate;
- delete slProperties.data;
- delete slProperties.src;
- delete slProperties.alt;
-
-
- // detect that the correct version of Silverlight is installed, else display install
-
- if (Silverlight.isInstalled(slPluginHelper.version))
- {
- //move unknown events to the slProperties array
- for (var name in slEvents)
- {
- if ( slEvents[name])
- {
- if ( name == "onLoad" && typeof slEvents[name] == "function" && slEvents[name].length != 1 )
- {
- var onLoadHandler = slEvents[name];
- slEvents[name]=function (sender){ return onLoadHandler(document.getElementById(id), userContext, sender)};
- }
- var handlerName = Silverlight.__getHandlerName(slEvents[name]);
- if ( handlerName != null )
- {
- slProperties[name] = handlerName;
- slEvents[name] = null;
- }
- else
- {
- throw "typeof events."+name+" must be 'function' or 'string'";
- }
- }
- }
- slPluginHTML = Silverlight.buildHTML(slProperties);
- }
- //The control could not be instantiated. Show the installation prompt
- else
- {
- slPluginHTML = Silverlight.buildPromptHTML(slPluginHelper);
- }
-
- // insert or return the HTML
- if(parentElement)
- {
- parentElement.innerHTML = slPluginHTML;
- }
- else
- {
- return slPluginHTML;
- }
-
-};
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// buildHTML:
-//
-// create HTML that instantiates the control
-//
-///////////////////////////////////////////////////////////////////////////////
-Silverlight.buildHTML = function( slProperties)
-{
- var htmlBuilder = [];
-
- htmlBuilder.push('<object type=\"application/x-silverlight\" data="data:application/x-silverlight,"');
- if ( slProperties.id != null )
- {
- htmlBuilder.push(' id="' + Silverlight.HtmlAttributeEncode(slProperties.id) + '"');
- }
- if ( slProperties.width != null )
- {
- htmlBuilder.push(' width="' + slProperties.width+ '"');
- }
- if ( slProperties.height != null )
- {
- htmlBuilder.push(' height="' + slProperties.height + '"');
- }
- htmlBuilder.push(' >');
-
- delete slProperties.id;
- delete slProperties.width;
- delete slProperties.height;
-
- for (var name in slProperties)
- {
- if (slProperties[name])
- {
- htmlBuilder.push('<param name="'+Silverlight.HtmlAttributeEncode(name)+'" value="'+Silverlight.HtmlAttributeEncode(slProperties[name])+'" />');
- }
- }
- htmlBuilder.push('<\/object>');
- return htmlBuilder.join('');
-};
-
-
-
-//////////////////////////////////////////////////////////////////
-//
-// createObjectEx:
-//
-// takes a single parameter of all createObject
-// parameters enclosed in {}
-//
-//////////////////////////////////////////////////////////////////
-
-Silverlight.createObjectEx = function(params)
-{
- var parameters = params;
- var html = Silverlight.createObject(parameters.source, parameters.parentElement, parameters.id, parameters.properties, parameters.events, parameters.initParams, parameters.context);
- if (parameters.parentElement == null)
- {
- return html;
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-//
-// buildPromptHTML
-//
-// Builds the HTML to prompt the user to download and install Silverlight
-//
-///////////////////////////////////////////////////////////////////////////////////////////////
-Silverlight.buildPromptHTML = function(slPluginHelper)
-{
- var slPluginHTML = "";
- var urlRoot = Silverlight.fwlinkRoot;
- var version = slPluginHelper.version ;
- if ( slPluginHelper.alt )
- {
- slPluginHTML = slPluginHelper.alt;
- }
- else
- {
- if (! version)
- {
- version="";
- }
- slPluginHTML = "<a href='javascript:Silverlight.getSilverlight(\"{1}\");' style='text-decoration: none;'><img src='{2}' alt='Get Microsoft Silverlight' style='border-style: none'/></a>";
- slPluginHTML = slPluginHTML.replace('{1}', version);
- slPluginHTML = slPluginHTML.replace('{2}', urlRoot + '108181');
- }
-
- return slPluginHTML;
-};
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-//
-// getSilverlight:
-//
-// Navigates the browser to the appropriate Silverlight installer
-//
-///////////////////////////////////////////////////////////////////////////////////////////////
-Silverlight.getSilverlight = function(version)
-{
- if (Silverlight.onGetSilverlight )
- {
- Silverlight.onGetSilverlight();
- }
-
- var shortVer = "";
- var reqVerArray = String(version).split(".");
- if (reqVerArray.length > 1)
- {
- var majorNum = parseInt(reqVerArray[0] );
- if ( isNaN(majorNum) || majorNum < 2 )
- {
- shortVer = "1.0";
- }
- else
- {
- shortVer = reqVerArray[0]+'.'+reqVerArray[1];
- }
- }
-
- var verArg = "";
-
- if (shortVer.match(/^\d+\056\d+$/) )
- {
- verArg = "&v="+shortVer;
- }
-
- Silverlight.followFWLink("114576" + verArg);
-};
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-//
-// followFWLink:
-//
-// Navigates to a url based on fwlinkid
-//
-///////////////////////////////////////////////////////////////////////////////////////////////
-Silverlight.followFWLink = function(linkid)
-{
- top.location=Silverlight.fwlinkRoot+String(linkid);
-};
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-//
-// HtmlAttributeEncode:
-//
-// Encodes special characters in input strings as charcodes
-//
-///////////////////////////////////////////////////////////////////////////////////////////////
-Silverlight.HtmlAttributeEncode = function( strInput )
-{
- var c;
- var retVal = '';
-
- if(strInput == null)
- {
- return null;
- }
-
- for(var cnt = 0; cnt < strInput.length; cnt++)
- {
- c = strInput.charCodeAt(cnt);
-
- if (( ( c > 96 ) && ( c < 123 ) ) ||
- ( ( c > 64 ) && ( c < 91 ) ) ||
- ( ( c > 43 ) && ( c < 58 ) && (c!=47)) ||
- ( c == 95 ))
- {
- retVal = retVal + String.fromCharCode(c);
- }
- else
- {
- retVal = retVal + '&#' + c + ';';
- }
- }
-
- return retVal;
-};
-///////////////////////////////////////////////////////////////////////////////
-//
-// default_error_handler:
-//
-// Default error handling function
-//
-///////////////////////////////////////////////////////////////////////////////
-
-Silverlight.default_error_handler = function (sender, args)
-{
- var iErrorCode;
- var errorType = args.ErrorType;
-
- iErrorCode = args.ErrorCode;
-
- var errMsg = "\nSilverlight error message \n" ;
-
- errMsg += "ErrorCode: "+ iErrorCode + "\n";
-
-
- errMsg += "ErrorType: " + errorType + " \n";
- errMsg += "Message: " + args.ErrorMessage + " \n";
-
- if (errorType == "ParserError")
- {
- errMsg += "XamlFile: " + args.xamlFile + " \n";
- errMsg += "Line: " + args.lineNumber + " \n";
- errMsg += "Position: " + args.charPosition + " \n";
- }
- else if (errorType == "RuntimeError")
- {
- if (args.lineNumber != 0)
- {
- errMsg += "Line: " + args.lineNumber + " \n";
- errMsg += "Position: " + args.charPosition + " \n";
- }
- errMsg += "MethodName: " + args.methodName + " \n";
- }
- alert (errMsg);
-};
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-//
-// __cleanup:
-//
-// Releases event handler resources when the page is unloaded
-//
-///////////////////////////////////////////////////////////////////////////////////////////////
-Silverlight.__cleanup = function ()
-{
- for (var i = Silverlight._silverlightCount - 1; i >= 0; i--) {
- window['__slEvent' + i] = null;
- }
- Silverlight._silverlightCount = 0;
- if (window.removeEventListener) {
- window.removeEventListener('unload', Silverlight.__cleanup , false);
- }
- else {
- window.detachEvent('onunload', Silverlight.__cleanup );
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-//
-// __getHandlerName:
-//
-// Generates named event handlers for delegates.
-//
-///////////////////////////////////////////////////////////////////////////////////////////////
-Silverlight.__getHandlerName = function (handler)
-{
- var handlerName = "";
- if ( typeof handler == "string")
- {
- handlerName = handler;
- }
- else if ( typeof handler == "function" )
- {
- if (Silverlight._silverlightCount == 0)
- {
- if (window.addEventListener)
- {
- window.addEventListener('onunload', Silverlight.__cleanup , false);
- }
- else
- {
- window.attachEvent('onunload', Silverlight.__cleanup );
- }
- }
- var count = Silverlight._silverlightCount++;
- handlerName = "__slEvent"+count;
-
- window[handlerName]=handler;
- }
- else
- {
- handlerName = null;
- }
- return handlerName;
-};
-//////////////////////////////////////////////////////////////////
-//
-// onRequiredVersionAvailable:
-//
-// Called by version verification control to notify the page that
-// an appropriate build of Silverlight is available. The page
-// should respond by injecting the appropriate Silverlight control
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.onRequiredVersionAvailable = function() {
- myTrackingObject.track("Silverlight is available and loaded");
-};
-//////////////////////////////////////////////////////////////////
-//
-// onRestartRequired:
-//
-// Called by version verification control to notify the page that
-// an appropriate build of Silverlight is installed but not loaded.
-// The page should respond by injecting a clear and visible
-// "Thanks for installing. Please restart your browser and return
-// to mysite.com" or equivalent into the browser DOM
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.onRestartRequired = function() {
- document.getElementById("SilverlightControlHost").innerHTML = RestartRequiredNotification;
- myTrackingObject.track("Silverlight is available but not loaded");
-};
-//////////////////////////////////////////////////////////////////
-//
-// onUpgradeRequired:
-//
-// Called by version verification control to notify the page that
-// Silverlight must be upgraded. The page should respond by
-// injecting a clear, visible, and actionable upgrade message into
-// the DOM. The message must inform the user that they need to
-// upgrade Silverlight to use the page. They are already somewhat
-// familiar with the Silverlight product when they encounter this.
-// Silverlight should be mentioned so the user expects to see that
-// string in the installer UI. However, the Silverlight-powered
-// application should be the focus of the solicitation. The user
-// wants the app. Silverlight is a means to the app.
-//
-// The upgrade solicitation will have a button that directs
-// the user to the Silverlight installer. Upon click the button
-// should both kick off a download of the installer URL and replace
-// the Upgrade text with "Thanks for downloading. When the upgarde
-// is complete please restart your browser and return to
-// mysite.com" or equivalent.
-//
-// Note: For a more interesting upgrade UX we can use Silverlight
-// 1.0-style XAML for this upgrade experience. Contact PiotrP for
-// details.
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.onUpgradeRequired = function()
-{
- document.getElementById("SilverlightControlHost").innerHTML = UpgradeRequiredNotification;
- myTrackingObject.track("Older Silverlight Present");
-};
-//////////////////////////////////////////////////////////////////
-//
-// onInstallRequired:
-//
-// Called by Silverlight.checkInstallStatus to notify the page
-// that Silverlight has not been installed by this user.
-// The page should respond by
-// injecting a clear, visible, and actionable upgrade message into
-// the DOM. The message must inform the user that they need to
-// download and install components needed to use the page.
-// Silverlight should be mentioned so the user expects to see that
-// string in the installer UI. However, the Silverlight-powered
-// application should be the focus of the solicitation. The user
-// wants the app. Silverlight is a means to the app.
-//
-// The installation solicitation will have a button that directs
-// the user to the Silverlight installer. Upon click the button
-// should both kick off a download of the installer URL and replace
-// the Upgrade text with "Thanks for downloading. When installation
-// is complete you may need to refresh the page to view this
-// content" or equivalent.
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.onInstallRequired = function()
-{
- myTrackingObject.track("No Silverlight present");
-};
-
-//////////////////////////////////////////////////////////////////
-//
-// IsVersionAvailableOnError:
-//
-// This function should be called at the beginning of a web page's
-// Silverlight error handler. It will determine if the required
-// version of Silverlight is installed and available in the
-// current process.
-//
-// During its execution the function will trigger one of the
-// Silverlight installation state events, if appropriate.
-//
-// Sender and Args should be passed through from the calling
-// onError handler's parameters.
-//
-// The associated Sivlerlight <object> tag must have
-// minRuntimeVersion set and should have autoUpgrade set to false.
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.IsVersionAvailableOnError = function(sender, args)
-{
- var retVal = false;
- try
- {
- if (args.ErrorCode == 8001 && !Silverlight.__installationEventFired)
- {
- Silverlight.onUpgradeRequired();
- Silverlight.__installationEventFired = true;
- }
- else if (args.ErrorCode == 8002 && !Silverlight.__installationEventFired)
- {
- Silverlight.onRestartRequired();
- Silverlight.__installationEventFired = true;
- }
- // this handles upgrades from 1.0. That control did not
- // understand the minRuntimeVerison parameter. It also
- // did not know how to parse XAP files, so would throw
- // Parse Error (5014). A Beta 2 control may throw 2106
- else if (args.ErrorCode == 5014 || args.ErrorCode == 2106)
- {
- if (Silverlight.__verifySilverlight2UpgradeSuccess(args.getHost()))
- {
- retVal = true;
- }
- }
- else
- {
- retVal = true;
- }
- }
- catch (e)
- {
- }
- return retVal;
-};
-//////////////////////////////////////////////////////////////////
-//
-// IsVersionAvailableOnLoad:
-//
-// This function should be called at the beginning of a web page's
-// Silverlight onLoad handler. It will determine if the required
-// version of Silverlight is installed and available in the
-// current process.
-//
-// During its execution the function will trigger one of the
-// Silverlight installation state events, if appropriate.
-//
-// Sender should be passed through from the calling
-// onError handler's parameters.
-//
-// The associated Sivlerlight <object> tag must have
-// minRuntimeVersion set and should have autoUpgrade set to false.
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.IsVersionAvailableOnLoad = function(sender)
-{
- var retVal = false;
- try
- {
- if (Silverlight.__verifySilverlight2UpgradeSuccess(sender.getHost()))
- {
- retVal = true;
- }
- }
- catch (e)
- {
- }
- return retVal;
-};
-//////////////////////////////////////////////////////////////////
-//
-// __verifySilverlight2UpgradeSuccess:
-//
-// This internal function helps identify installation state by
-// taking advantage of behavioral differences between the
-// 1.0 and 2.0 releases of Silverlight.
-//
-//////////////////////////////////////////////////////////////////
-Silverlight.__verifySilverlight2UpgradeSuccess = function(host)
-{
- var retVal = false;
- var version = "2.0.31005";
- var installationEvent = null;
-
- try
- {
- if (host.IsVersionSupported(version + ".99"))
- {
- installationEvent = Silverlight.onRequiredVersionAvailable;
- retVal = true;
- }
- else if (host.IsVersionSupported(version + ".0"))
- {
- installationEvent = Silverlight.onRestartRequired;
- }
- else
- {
- installationEvent = Silverlight.onUpgradeRequired;
- }
-
- if (installationEvent && !Silverlight.__installationEventFired)
- {
- installationEvent();
- Silverlight.__installationEventFired = true;
- }
- }
- catch (e)
- {
- }
- return retVal;
-}; \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_2_0.xml b/main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_2_0.xml
deleted file mode 100644
index 00446e7ecf..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_2_0.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<TargetFramework id="Silverlight,Version=v2.0" _name="Moonlight / Silverlight 2.0" clrVersion="Clr_2_1">
-<Assemblies>
- <Assembly name="System" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="mscorlib" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Core" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Net" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Runtime.Serialization" version="2.0.5.0" publicKeyToken="b77a5c561934e089" />
- <Assembly name="System.ServiceModel" version="2.0.5.0" publicKeyToken="31bf3856ad364e35" />
- <Assembly name="System.ServiceModel.Web" version="2.0.5.0" publicKeyToken="31bf3856ad364e35" />
- <Assembly name="System.Windows" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Windows.Browser" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Xml" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="Microsoft.VisualBasic" version="2.0.5.0" publicKeyToken="31bf3856ad364e35" />
-</Assemblies>
-</TargetFramework>
diff --git a/main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_3_0.xml b/main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_3_0.xml
deleted file mode 100644
index ffe183fe6a..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_3_0.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<TargetFramework id="Silverlight,Version=v3.0" _name="Moonlight / Silverlight 3.0" clrVersion="Clr_2_1">
-<Assemblies>
- <Assembly name="System" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="mscorlib" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Core" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Net" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Runtime.Serialization" version="2.0.5.0" publicKeyToken="b77a5c561934e089" />
- <Assembly name="System.ServiceModel" version="2.0.5.0" publicKeyToken="31bf3856ad364e35" />
- <Assembly name="System.ServiceModel.Web" version="2.0.5.0" publicKeyToken="31bf3856ad364e35" />
- <Assembly name="System.Windows" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Windows.Browser" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Xml" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="Microsoft.VisualBasic" version="2.0.5.0" publicKeyToken="31bf3856ad364e35" />
-</Assemblies>
-</TargetFramework> \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_4_0.xml b/main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_4_0.xml
deleted file mode 100644
index e114b3b359..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/Templates/framework_SL_4_0.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<TargetFramework id="Silverlight,Version=v4.0" _name="Moonlight / Silverlight 4.0" clrVersion="Clr_2_1">
-<Assemblies>
- <Assembly name="System" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="mscorlib" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Core" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Net" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Runtime.Serialization" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.ServiceModel" version="2.0.5.0" publicKeyToken="31bf3856ad364e35" />
- <Assembly name="System.ServiceModel.Web" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Windows" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Windows.Browser" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="System.Xml" version="2.0.5.0" publicKeyToken="7cec85d7bea7798e" />
- <Assembly name="Microsoft.VisualBasic" version="2.0.5.0" publicKeyToken="31bf3856ad364e35" />
-</Assemblies>
-</TargetFramework>
diff --git a/main/src/addins/MonoDevelop.Moonlight/gtk-gui/MonoDevelop.Moonlight.Gui.MoonlightOptionsPanelWidget.cs b/main/src/addins/MonoDevelop.Moonlight/gtk-gui/MonoDevelop.Moonlight.Gui.MoonlightOptionsPanelWidget.cs
deleted file mode 100644
index e3d2e8aa93..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/gtk-gui/MonoDevelop.Moonlight.Gui.MoonlightOptionsPanelWidget.cs
+++ /dev/null
@@ -1,308 +0,0 @@
-
-// This file has been generated by the GUI designer. Do not modify.
-namespace MonoDevelop.Moonlight.Gui
-{
- public partial class MoonlightOptionsPanelWidget
- {
- private global::Gtk.VBox vbox1;
- private global::Gtk.VBox applicationOptionsBox;
- private global::Gtk.Label label1;
- private global::Gtk.Alignment alignment1;
- private global::Gtk.VBox vbox2;
- private global::Gtk.HBox hbox1;
- private global::Gtk.Label label2;
- private global::Gtk.Entry xapFilenameEntry;
- private global::Gtk.Alignment alignment2;
- private global::Gtk.VBox vbox3;
- private global::Gtk.CheckButton generateManifestCheck;
- private global::Gtk.Alignment alignment4;
- private global::Gtk.Table manifestTable;
- private global::Gtk.ComboBoxEntry entryPointCombo;
- private global::Gtk.Label label6;
- private global::Gtk.Label label7;
- private global::Gtk.Entry manifestTemplateFilenameEntry;
- private global::Gtk.Label label3;
- private global::Gtk.Alignment alignment5;
- private global::Gtk.VBox vbox4;
- private global::Gtk.CheckButton generateTestPageCheck;
- private global::Gtk.Alignment alignment3;
- private global::Gtk.HBox testPageBox;
- private global::Gtk.Label label5;
- private global::Gtk.Entry testPageFilenameEntry;
- private global::Gtk.Label label4;
- private global::Gtk.Alignment xamlAlignment;
- private global::Gtk.VBox vbox6;
- private global::Gtk.CheckButton validateXamlCheck;
- private global::Gtk.CheckButton throwXamlErrorsCheck;
-
- protected virtual void Build ()
- {
- global::Stetic.Gui.Initialize (this);
- // Widget MonoDevelop.Moonlight.Gui.MoonlightOptionsPanelWidget
- global::Stetic.BinContainer.Attach (this);
- this.Name = "MonoDevelop.Moonlight.Gui.MoonlightOptionsPanelWidget";
- // Container child MonoDevelop.Moonlight.Gui.MoonlightOptionsPanelWidget.Gtk.Container+ContainerChild
- this.vbox1 = new global::Gtk.VBox ();
- this.vbox1.Name = "vbox1";
- this.vbox1.Spacing = 12;
- // Container child vbox1.Gtk.Box+BoxChild
- this.applicationOptionsBox = new global::Gtk.VBox ();
- this.applicationOptionsBox.Name = "applicationOptionsBox";
- this.applicationOptionsBox.Spacing = 12;
- // Container child applicationOptionsBox.Gtk.Box+BoxChild
- this.label1 = new global::Gtk.Label ();
- this.label1.Name = "label1";
- this.label1.Xalign = 0F;
- this.label1.LabelProp = global::Mono.Unix.Catalog.GetString ("<b>XAP Generation</b>");
- this.label1.UseMarkup = true;
- this.applicationOptionsBox.Add (this.label1);
- global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.applicationOptionsBox [this.label1]));
- w1.Position = 0;
- w1.Expand = false;
- w1.Fill = false;
- // Container child applicationOptionsBox.Gtk.Box+BoxChild
- this.alignment1 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F);
- this.alignment1.Name = "alignment1";
- this.alignment1.LeftPadding = ((uint)(16));
- // Container child alignment1.Gtk.Container+ContainerChild
- this.vbox2 = new global::Gtk.VBox ();
- this.vbox2.Name = "vbox2";
- this.vbox2.Spacing = 6;
- // Container child vbox2.Gtk.Box+BoxChild
- this.hbox1 = new global::Gtk.HBox ();
- this.hbox1.Name = "hbox1";
- this.hbox1.Spacing = 6;
- // Container child hbox1.Gtk.Box+BoxChild
- this.label2 = new global::Gtk.Label ();
- this.label2.Name = "label2";
- this.label2.LabelProp = global::Mono.Unix.Catalog.GetString ("XAP _filename:");
- this.label2.UseUnderline = true;
- this.hbox1.Add (this.label2);
- global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.label2]));
- w2.Position = 0;
- w2.Expand = false;
- w2.Fill = false;
- // Container child hbox1.Gtk.Box+BoxChild
- this.xapFilenameEntry = new global::Gtk.Entry ();
- this.xapFilenameEntry.CanFocus = true;
- this.xapFilenameEntry.Name = "xapFilenameEntry";
- this.xapFilenameEntry.IsEditable = true;
- this.xapFilenameEntry.InvisibleChar = '●';
- this.hbox1.Add (this.xapFilenameEntry);
- global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.xapFilenameEntry]));
- w3.Position = 1;
- this.vbox2.Add (this.hbox1);
- global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1]));
- w4.Position = 0;
- w4.Expand = false;
- w4.Fill = false;
- // Container child vbox2.Gtk.Box+BoxChild
- this.alignment2 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F);
- this.alignment2.Name = "alignment2";
- // Container child alignment2.Gtk.Container+ContainerChild
- this.vbox3 = new global::Gtk.VBox ();
- this.vbox3.Name = "vbox3";
- this.vbox3.Spacing = 6;
- // Container child vbox3.Gtk.Box+BoxChild
- this.generateManifestCheck = new global::Gtk.CheckButton ();
- this.generateManifestCheck.CanFocus = true;
- this.generateManifestCheck.Name = "generateManifestCheck";
- this.generateManifestCheck.Label = global::Mono.Unix.Catalog.GetString ("_Generate manifest");
- this.generateManifestCheck.DrawIndicator = true;
- this.generateManifestCheck.UseUnderline = true;
- this.vbox3.Add (this.generateManifestCheck);
- global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.generateManifestCheck]));
- w5.Position = 0;
- w5.Expand = false;
- w5.Fill = false;
- // Container child vbox3.Gtk.Box+BoxChild
- this.alignment4 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F);
- this.alignment4.Name = "alignment4";
- this.alignment4.LeftPadding = ((uint)(36));
- // Container child alignment4.Gtk.Container+ContainerChild
- this.manifestTable = new global::Gtk.Table (((uint)(3)), ((uint)(2)), false);
- this.manifestTable.Name = "manifestTable";
- this.manifestTable.RowSpacing = ((uint)(6));
- this.manifestTable.ColumnSpacing = ((uint)(6));
- // Container child manifestTable.Gtk.Table+TableChild
- this.entryPointCombo = global::Gtk.ComboBoxEntry.NewText ();
- this.entryPointCombo.Name = "entryPointCombo";
- this.manifestTable.Add (this.entryPointCombo);
- global::Gtk.Table.TableChild w6 = ((global::Gtk.Table.TableChild)(this.manifestTable [this.entryPointCombo]));
- w6.TopAttach = ((uint)(1));
- w6.BottomAttach = ((uint)(2));
- w6.LeftAttach = ((uint)(1));
- w6.RightAttach = ((uint)(2));
- w6.YOptions = ((global::Gtk.AttachOptions)(4));
- // Container child manifestTable.Gtk.Table+TableChild
- this.label6 = new global::Gtk.Label ();
- this.label6.Name = "label6";
- this.label6.Xalign = 0F;
- this.label6.LabelProp = global::Mono.Unix.Catalog.GetString ("Entry _point:");
- this.label6.UseUnderline = true;
- this.manifestTable.Add (this.label6);
- global::Gtk.Table.TableChild w7 = ((global::Gtk.Table.TableChild)(this.manifestTable [this.label6]));
- w7.TopAttach = ((uint)(1));
- w7.BottomAttach = ((uint)(2));
- w7.XOptions = ((global::Gtk.AttachOptions)(4));
- w7.YOptions = ((global::Gtk.AttachOptions)(4));
- // Container child manifestTable.Gtk.Table+TableChild
- this.label7 = new global::Gtk.Label ();
- this.label7.Name = "label7";
- this.label7.LabelProp = global::Mono.Unix.Catalog.GetString ("Te_mplate file:");
- this.label7.UseUnderline = true;
- this.manifestTable.Add (this.label7);
- global::Gtk.Table.TableChild w8 = ((global::Gtk.Table.TableChild)(this.manifestTable [this.label7]));
- w8.XOptions = ((global::Gtk.AttachOptions)(4));
- w8.YOptions = ((global::Gtk.AttachOptions)(4));
- // Container child manifestTable.Gtk.Table+TableChild
- this.manifestTemplateFilenameEntry = new global::Gtk.Entry ();
- this.manifestTemplateFilenameEntry.CanFocus = true;
- this.manifestTemplateFilenameEntry.Name = "manifestTemplateFilenameEntry";
- this.manifestTemplateFilenameEntry.IsEditable = true;
- this.manifestTemplateFilenameEntry.InvisibleChar = '●';
- this.manifestTable.Add (this.manifestTemplateFilenameEntry);
- global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.manifestTable [this.manifestTemplateFilenameEntry]));
- w9.LeftAttach = ((uint)(1));
- w9.RightAttach = ((uint)(2));
- w9.YOptions = ((global::Gtk.AttachOptions)(4));
- this.alignment4.Add (this.manifestTable);
- this.vbox3.Add (this.alignment4);
- global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.alignment4]));
- w11.Position = 1;
- this.alignment2.Add (this.vbox3);
- this.vbox2.Add (this.alignment2);
- global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.alignment2]));
- w13.Position = 1;
- this.alignment1.Add (this.vbox2);
- this.applicationOptionsBox.Add (this.alignment1);
- global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.applicationOptionsBox [this.alignment1]));
- w15.Position = 1;
- // Container child applicationOptionsBox.Gtk.Box+BoxChild
- this.label3 = new global::Gtk.Label ();
- this.label3.Name = "label3";
- this.label3.Xalign = 0F;
- this.label3.LabelProp = global::Mono.Unix.Catalog.GetString ("<b>Test Page</b>");
- this.label3.UseMarkup = true;
- this.applicationOptionsBox.Add (this.label3);
- global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.applicationOptionsBox [this.label3]));
- w16.Position = 2;
- w16.Expand = false;
- w16.Fill = false;
- // Container child applicationOptionsBox.Gtk.Box+BoxChild
- this.alignment5 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F);
- this.alignment5.Name = "alignment5";
- this.alignment5.LeftPadding = ((uint)(16));
- // Container child alignment5.Gtk.Container+ContainerChild
- this.vbox4 = new global::Gtk.VBox ();
- this.vbox4.Name = "vbox4";
- this.vbox4.Spacing = 6;
- // Container child vbox4.Gtk.Box+BoxChild
- this.generateTestPageCheck = new global::Gtk.CheckButton ();
- this.generateTestPageCheck.CanFocus = true;
- this.generateTestPageCheck.Name = "generateTestPageCheck";
- this.generateTestPageCheck.Label = global::Mono.Unix.Catalog.GetString ("Generate _test page");
- this.generateTestPageCheck.DrawIndicator = true;
- this.generateTestPageCheck.UseUnderline = true;
- this.vbox4.Add (this.generateTestPageCheck);
- global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.generateTestPageCheck]));
- w17.Position = 0;
- w17.Expand = false;
- w17.Fill = false;
- // Container child vbox4.Gtk.Box+BoxChild
- this.alignment3 = new global::Gtk.Alignment (0F, 0.5F, 1F, 1F);
- this.alignment3.Name = "alignment3";
- this.alignment3.LeftPadding = ((uint)(36));
- // Container child alignment3.Gtk.Container+ContainerChild
- this.testPageBox = new global::Gtk.HBox ();
- this.testPageBox.Name = "testPageBox";
- this.testPageBox.Spacing = 6;
- // Container child testPageBox.Gtk.Box+BoxChild
- this.label5 = new global::Gtk.Label ();
- this.label5.Name = "label5";
- this.label5.LabelProp = global::Mono.Unix.Catalog.GetString ("Test _page filename:");
- this.label5.UseUnderline = true;
- this.testPageBox.Add (this.label5);
- global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.testPageBox [this.label5]));
- w18.Position = 0;
- w18.Expand = false;
- w18.Fill = false;
- // Container child testPageBox.Gtk.Box+BoxChild
- this.testPageFilenameEntry = new global::Gtk.Entry ();
- this.testPageFilenameEntry.CanFocus = true;
- this.testPageFilenameEntry.Name = "testPageFilenameEntry";
- this.testPageFilenameEntry.IsEditable = true;
- this.testPageFilenameEntry.InvisibleChar = '●';
- this.testPageBox.Add (this.testPageFilenameEntry);
- global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.testPageBox [this.testPageFilenameEntry]));
- w19.Position = 1;
- this.alignment3.Add (this.testPageBox);
- this.vbox4.Add (this.alignment3);
- global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.alignment3]));
- w21.Position = 1;
- w21.Expand = false;
- w21.Fill = false;
- this.alignment5.Add (this.vbox4);
- this.applicationOptionsBox.Add (this.alignment5);
- global::Gtk.Box.BoxChild w23 = ((global::Gtk.Box.BoxChild)(this.applicationOptionsBox [this.alignment5]));
- w23.Position = 3;
- this.vbox1.Add (this.applicationOptionsBox);
- global::Gtk.Box.BoxChild w24 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.applicationOptionsBox]));
- w24.Position = 0;
- // Container child vbox1.Gtk.Box+BoxChild
- this.label4 = new global::Gtk.Label ();
- this.label4.Name = "label4";
- this.label4.Xalign = 0F;
- this.label4.LabelProp = global::Mono.Unix.Catalog.GetString ("<b>XAML Validation</b>");
- this.label4.UseMarkup = true;
- this.vbox1.Add (this.label4);
- global::Gtk.Box.BoxChild w25 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.label4]));
- w25.Position = 1;
- w25.Expand = false;
- w25.Fill = false;
- // Container child vbox1.Gtk.Box+BoxChild
- this.xamlAlignment = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F);
- this.xamlAlignment.Name = "xamlAlignment";
- this.xamlAlignment.LeftPadding = ((uint)(16));
- // Container child xamlAlignment.Gtk.Container+ContainerChild
- this.vbox6 = new global::Gtk.VBox ();
- this.vbox6.Name = "vbox6";
- this.vbox6.Spacing = 6;
- // Container child vbox6.Gtk.Box+BoxChild
- this.validateXamlCheck = new global::Gtk.CheckButton ();
- this.validateXamlCheck.CanFocus = true;
- this.validateXamlCheck.Name = "validateXamlCheck";
- this.validateXamlCheck.Label = global::Mono.Unix.Catalog.GetString ("_Validate XAML");
- this.validateXamlCheck.DrawIndicator = true;
- this.validateXamlCheck.UseUnderline = true;
- this.vbox6.Add (this.validateXamlCheck);
- global::Gtk.Box.BoxChild w26 = ((global::Gtk.Box.BoxChild)(this.vbox6 [this.validateXamlCheck]));
- w26.Position = 0;
- w26.Expand = false;
- w26.Fill = false;
- // Container child vbox6.Gtk.Box+BoxChild
- this.throwXamlErrorsCheck = new global::Gtk.CheckButton ();
- this.throwXamlErrorsCheck.CanFocus = true;
- this.throwXamlErrorsCheck.Name = "throwXamlErrorsCheck";
- this.throwXamlErrorsCheck.Label = global::Mono.Unix.Catalog.GetString ("Throw _errors in XAML validation");
- this.throwXamlErrorsCheck.DrawIndicator = true;
- this.throwXamlErrorsCheck.UseUnderline = true;
- this.vbox6.Add (this.throwXamlErrorsCheck);
- global::Gtk.Box.BoxChild w27 = ((global::Gtk.Box.BoxChild)(this.vbox6 [this.throwXamlErrorsCheck]));
- w27.Position = 1;
- w27.Expand = false;
- w27.Fill = false;
- this.xamlAlignment.Add (this.vbox6);
- this.vbox1.Add (this.xamlAlignment);
- global::Gtk.Box.BoxChild w29 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.xamlAlignment]));
- w29.Position = 2;
- this.Add (this.vbox1);
- if ((this.Child != null)) {
- this.Child.ShowAll ();
- }
- this.label2.MnemonicWidget = this.xapFilenameEntry;
- this.label5.MnemonicWidget = this.testPageFilenameEntry;
- this.Hide ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/gtk-gui/generated.cs b/main/src/addins/MonoDevelop.Moonlight/gtk-gui/generated.cs
deleted file mode 100644
index 8d3a3ae5d9..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/gtk-gui/generated.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-
-// This file has been generated by the GUI designer. Do not modify.
-namespace Stetic
-{
- internal class Gui
- {
- private static bool initialized;
-
- internal static void Initialize (Gtk.Widget iconRenderer)
- {
- if ((Stetic.Gui.initialized == false)) {
- Stetic.Gui.initialized = true;
- }
- }
- }
-
- internal class BinContainer
- {
- private Gtk.Widget child;
- private Gtk.UIManager uimanager;
-
- public static BinContainer Attach (Gtk.Bin bin)
- {
- BinContainer bc = new BinContainer ();
- bin.SizeRequested += new Gtk.SizeRequestedHandler (bc.OnSizeRequested);
- bin.SizeAllocated += new Gtk.SizeAllocatedHandler (bc.OnSizeAllocated);
- bin.Added += new Gtk.AddedHandler (bc.OnAdded);
- return bc;
- }
-
- private void OnSizeRequested (object sender, Gtk.SizeRequestedArgs args)
- {
- if ((this.child != null)) {
- args.Requisition = this.child.SizeRequest ();
- }
- }
-
- private void OnSizeAllocated (object sender, Gtk.SizeAllocatedArgs args)
- {
- if ((this.child != null)) {
- this.child.Allocation = args.Allocation;
- }
- }
-
- private void OnAdded (object sender, Gtk.AddedArgs args)
- {
- this.child = args.Widget;
- }
-
- public void SetUiManager (Gtk.UIManager uim)
- {
- this.uimanager = uim;
- this.child.Realized += new System.EventHandler (this.OnRealized);
- }
-
- private void OnRealized (object sender, System.EventArgs args)
- {
- if ((this.uimanager != null)) {
- Gtk.Widget w;
- w = this.child.Toplevel;
- if (((w != null) && typeof(Gtk.Window).IsInstanceOfType (w))) {
- ((Gtk.Window)(w)).AddAccelGroup (this.uimanager.AccelGroup);
- this.uimanager = null;
- }
- }
- }
- }
-
- internal class ActionGroups
- {
- public static Gtk.ActionGroup GetActionGroup (System.Type type)
- {
- return Stetic.ActionGroups.GetActionGroup (type.FullName);
- }
-
- public static Gtk.ActionGroup GetActionGroup (string name)
- {
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Moonlight/gtk-gui/gui.stetic b/main/src/addins/MonoDevelop.Moonlight/gtk-gui/gui.stetic
deleted file mode 100644
index c4aa42f540..0000000000
--- a/main/src/addins/MonoDevelop.Moonlight/gtk-gui/gui.stetic
+++ /dev/null
@@ -1,404 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<stetic-interface>
- <configuration>
- <images-root-path>..</images-root-path>
- <target-gtk-version>2.12</target-gtk-version>
- </configuration>
- <import>
- <widget-library name="../../../../build/bin/MonoDevelop.Ide.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.AspNet/MonoDevelop.AspNet.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.Deployment/MonoDevelop.Deployment.dll" />
- <widget-library name="../../../../build/AddIns/MonoDevelop.Moonlight/MonoDevelop.Moonlight.dll" internal="true" />
- </import>
- <widget class="Gtk.Bin" id="MonoDevelop.Moonlight.Gui.MoonlightOptionsPanelWidget" design-size="508 426">
- <property name="MemberName" />
- <property name="Visible">False</property>
- <child>
- <widget class="Gtk.VBox" id="vbox1">
- <property name="MemberName" />
- <property name="Spacing">12</property>
- <child>
- <widget class="Gtk.VBox" id="applicationOptionsBox">
- <property name="MemberName" />
- <property name="Spacing">12</property>
- <child>
- <widget class="Gtk.Label" id="label1">
- <property name="MemberName" />
- <property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes">&lt;b&gt;XAP Generation&lt;/b&gt;</property>
- <property name="UseMarkup">True</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Alignment" id="alignment1">
- <property name="MemberName" />
- <property name="LeftPadding">16</property>
- <child>
- <widget class="Gtk.VBox" id="vbox2">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.HBox" id="hbox1">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.Label" id="label2">
- <property name="MemberName" />
- <property name="LabelProp" translatable="yes">XAP _filename:</property>
- <property name="UseUnderline">True</property>
- <property name="MnemonicWidget">xapFilenameEntry</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Entry" id="xapFilenameEntry">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="IsEditable">True</property>
- <property name="InvisibleChar">●</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Alignment" id="alignment2">
- <property name="MemberName" />
- <child>
- <widget class="Gtk.VBox" id="vbox3">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.CheckButton" id="generateManifestCheck">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="Label" translatable="yes">_Generate manifest</property>
- <property name="DrawIndicator">True</property>
- <property name="HasLabel">True</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Alignment" id="alignment4">
- <property name="MemberName" />
- <property name="LeftPadding">36</property>
- <child>
- <widget class="Gtk.Table" id="manifestTable">
- <property name="MemberName" />
- <property name="NRows">3</property>
- <property name="NColumns">2</property>
- <property name="RowSpacing">6</property>
- <property name="ColumnSpacing">6</property>
- <child>
- <placeholder />
- </child>
- <child>
- <placeholder />
- </child>
- <child>
- <widget class="Gtk.ComboBoxEntry" id="entryPointCombo">
- <property name="MemberName" />
- <property name="IsTextCombo">True</property>
- <property name="Items" translatable="yes" />
- </widget>
- <packing>
- <property name="TopAttach">1</property>
- <property name="BottomAttach">2</property>
- <property name="LeftAttach">1</property>
- <property name="RightAttach">2</property>
- <property name="AutoSize">False</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">True</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label6">
- <property name="MemberName" />
- <property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes">Entry _point:</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="TopAttach">1</property>
- <property name="BottomAttach">2</property>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label7">
- <property name="MemberName" />
- <property name="LabelProp" translatable="yes">Te_mplate file:</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="AutoSize">True</property>
- <property name="XOptions">Fill</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">False</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Entry" id="manifestTemplateFilenameEntry">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="IsEditable">True</property>
- <property name="InvisibleChar">●</property>
- </widget>
- <packing>
- <property name="LeftAttach">1</property>
- <property name="RightAttach">2</property>
- <property name="AutoSize">False</property>
- <property name="YOptions">Fill</property>
- <property name="XExpand">True</property>
- <property name="XFill">True</property>
- <property name="XShrink">False</property>
- <property name="YExpand">False</property>
- <property name="YFill">True</property>
- <property name="YShrink">False</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- <child>
- <placeholder />
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- <child>
- <placeholder />
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label3">
- <property name="MemberName" />
- <property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes">&lt;b&gt;Test Page&lt;/b&gt;</property>
- <property name="UseMarkup">True</property>
- </widget>
- <packing>
- <property name="Position">2</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Alignment" id="alignment5">
- <property name="MemberName" />
- <property name="LeftPadding">16</property>
- <child>
- <widget class="Gtk.VBox" id="vbox4">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.CheckButton" id="generateTestPageCheck">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="Label" translatable="yes">Generate _test page</property>
- <property name="DrawIndicator">True</property>
- <property name="HasLabel">True</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Alignment" id="alignment3">
- <property name="MemberName" />
- <property name="Xalign">0</property>
- <property name="LeftPadding">36</property>
- <child>
- <widget class="Gtk.HBox" id="testPageBox">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.Label" id="label5">
- <property name="MemberName" />
- <property name="LabelProp" translatable="yes">Test _page filename:</property>
- <property name="UseUnderline">True</property>
- <property name="MnemonicWidget">testPageFilenameEntry</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Entry" id="testPageFilenameEntry">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="IsEditable">True</property>
- <property name="InvisibleChar">●</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <placeholder />
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="Position">3</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Label" id="label4">
- <property name="MemberName" />
- <property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes">&lt;b&gt;XAML Validation&lt;/b&gt;</property>
- <property name="UseMarkup">True</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.Alignment" id="xamlAlignment">
- <property name="MemberName" />
- <property name="LeftPadding">16</property>
- <child>
- <widget class="Gtk.VBox" id="vbox6">
- <property name="MemberName" />
- <property name="Spacing">6</property>
- <child>
- <widget class="Gtk.CheckButton" id="validateXamlCheck">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="Label" translatable="yes">_Validate XAML</property>
- <property name="DrawIndicator">True</property>
- <property name="HasLabel">True</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="Position">0</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="Gtk.CheckButton" id="throwXamlErrorsCheck">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="Label" translatable="yes">Throw _errors in XAML validation</property>
- <property name="DrawIndicator">True</property>
- <property name="HasLabel">True</property>
- <property name="UseUnderline">True</property>
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- <property name="Expand">False</property>
- <property name="Fill">False</property>
- </packing>
- </child>
- <child>
- <placeholder />
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="Position">2</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
-</stetic-interface> \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.PackageManagement/AssemblyInfo.cs b/main/src/addins/MonoDevelop.PackageManagement/AssemblyInfo.cs
index d626b52c17..6ef5399a44 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/AssemblyInfo.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/AssemblyInfo.cs
@@ -7,10 +7,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyDescription("NuGet addin for MonoDevelop")]
[assembly: AssemblyVersion ("1.0")]
[assembly: AssemblyCopyright ("MIT X11")]
-[assembly: InternalsVisibleTo ("MonoDevelop.DotNetCore")]
-[assembly: InternalsVisibleTo ("MonoDevelop.DotNetCore.Tests")]
-[assembly: InternalsVisibleTo ("MonoDevelop.PackageManagement.Cmdlets")]
-[assembly: InternalsVisibleTo ("MonoDevelop.PackageManagement.Extensions")]
-[assembly: InternalsVisibleTo ("MonoDevelop.PackageManagement.Tests")]
-[assembly: InternalsVisibleTo ("MonoDevelop.Packaging")]
-[assembly: InternalsVisibleTo ("Xamarin.Forms.Addin")]
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.csproj
index 5f376dfa1c..187985a45c 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.csproj
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<ProjectGuid>{2645C9F3-9ED5-4806-AB09-DAD9BE90C67B}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -7,7 +8,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.PackageManagement.Tests</RootNamespace>
<AssemblyName>MonoDevelop.PackageManagement.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
@@ -90,7 +91,7 @@
<HintPath>..\..\..\..\external\nuget-binary\NuGet.Resolver.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
- <HintPath>..\..\..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ <HintPath>..\..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NuGet.ProjectModel">
<HintPath>..\..\..\..\external\nuget-binary\NuGet.ProjectModel.dll</HintPath>
@@ -105,6 +106,9 @@
<Reference Include="NuGet.RuntimeModel">
<HintPath>..\..\..\..\external\nuget-binary\NuGet.RuntimeModel.dll</HintPath>
</Reference>
+ <Reference Include="NuGet.Commands">
+ <HintPath>..\..\..\..\external\nuget-binary\NuGet.Commands.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/packages.config b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/packages.config
index 583acbdf9c..e1fae9c6a8 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/packages.config
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj
index 12ed09f446..5047875419 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<ProjectGuid>{F218643D-2E74-4309-820E-206A54B7133F}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -14,7 +15,7 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -141,7 +142,7 @@
<HintPath>..\..\..\external\nuget-binary\NuGet.Indexing.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
- <HintPath>..\..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ <HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Collections.Immutable">
@@ -568,7 +569,6 @@
<LogicalName>package-48~dark~sel@2x.png</LogicalName>
</EmbeddedResource>
</ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
<Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
@@ -618,4 +618,14 @@
</None>
<None Include="packages.config" />
</ItemGroup>
+ <ItemGroup>
+ <InternalsVisibleTo Include="MonoDevelop.DotNetCore" />
+ <InternalsVisibleTo Include="MonoDevelop.DotNetCore.Tests" />
+ <InternalsVisibleTo Include="MonoDevelop.PackageManagement.Cmdlets" />
+ <InternalsVisibleTo Include="MonoDevelop.PackageManagement.Extensions" />
+ <InternalsVisibleTo Include="MonoDevelop.PackageManagement.Tests" />
+ <InternalsVisibleTo Include="MonoDevelop.Packaging" />
+ <InternalsVisibleTo Include="Xamarin.Forms.Addin" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs
index 342618cf25..e4e13de40b 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetCoreNuGetProject.cs
@@ -322,21 +322,10 @@ namespace MonoDevelop.PackageManagement
public bool ProjectRequiresReloadAfterRestore ()
{
- // Disabled. Newer Sdk style projects no longer need to be
- // re-evaluated since the sdk imports are not downloaded
- // from NuGet. Possibly a check should be made for the
- // generated nuget.g.targets and nuget.g.props files. These
- // are still generated by the latest .NET Core SDK on restore
- // but they do not contain any Sdk imports. Disabling this
- // also reduces the chance of the project model and project
- // builder reading/writing the MSBuildProject at the same time
- // causing inconsistencies.
- return false;
-
- //if (project.DotNetCoreNuGetMSBuildFilesExist ())
- // return false;
-
- //return true;
+ if (project.DotNetCoreNuGetMSBuildFilesExist ())
+ return false;
+
+ return true;
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SearchPackagesSearchCategory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SearchPackagesSearchCategory.cs
index cf35d50a71..166c59adb8 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SearchPackagesSearchCategory.cs
+++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SearchPackagesSearchCategory.cs
@@ -48,7 +48,7 @@ namespace MonoDevelop.PackageManagement
if (IsProjectSelected ()) {
searchResultCallback.ReportResult (new SearchPackageSearchResult (pattern));
}
- return SpecializedTasks.EmptyTask;
+ return Task.CompletedTask;
}
class SearchPackageSearchResult : SearchResult
diff --git a/main/src/addins/MonoDevelop.PackageManagement/packages.config b/main/src/addins/MonoDevelop.PackageManagement/packages.config
index 583acbdf9c..e1fae9c6a8 100644
--- a/main/src/addins/MonoDevelop.PackageManagement/packages.config
+++ b/main/src/addins/MonoDevelop.PackageManagement/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.Tests/MonoDevelop.Packaging.Tests.csproj b/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.Tests/MonoDevelop.Packaging.Tests.csproj
index 5e8daf78ec..75445da365 100644
--- a/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.Tests/MonoDevelop.Packaging.Tests.csproj
+++ b/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.Tests/MonoDevelop.Packaging.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.Packaging.Tests</RootNamespace>
<AssemblyName>MonoDevelop.Packaging.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TestRunnerCommand>..\..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
</PropertyGroup>
@@ -86,4 +87,4 @@
<Folder Include="MonoDevelop.Packaging.Tests\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.csproj b/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.csproj
index a36d478cec..b6fc5f5f3c 100644
--- a/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.csproj
+++ b/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.Packaging</RootNamespace>
<AssemblyName>MonoDevelop.Packaging</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -122,6 +123,9 @@
<Compile Include="MonoDevelop.Packaging\ProjectIsDotNetProjectOnlyCondition.cs" />
</ItemGroup>
<ItemGroup>
+ <InternalsVisibleTo Include="MonoDevelop.Packaging.Tests" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
<Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
<Name>MonoDevelop.Core</Name>
@@ -208,4 +212,4 @@
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="PostBuild.proj" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/MonoDevelop.Packaging/Properties/AssemblyInfo.cs b/main/src/addins/MonoDevelop.Packaging/Properties/AssemblyInfo.cs
index 97a3ba66d3..c962b614df 100644
--- a/main/src/addins/MonoDevelop.Packaging/Properties/AssemblyInfo.cs
+++ b/main/src/addins/MonoDevelop.Packaging/Properties/AssemblyInfo.cs
@@ -6,4 +6,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyDescription("NuGet packaging addin for MonoDevelop")]
[assembly: AssemblyVersion ("1.0")]
[assembly: AssemblyCopyright ("MIT")]
-[assembly: InternalsVisibleTo ("MonoDevelop.Packaging.Tests")]
diff --git a/main/src/addins/MonoDevelop.Refactoring/AssemblyInfo.cs b/main/src/addins/MonoDevelop.Refactoring/AssemblyInfo.cs
index 430de1984b..c787015813 100644
--- a/main/src/addins/MonoDevelop.Refactoring/AssemblyInfo.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/AssemblyInfo.cs
@@ -7,7 +7,3 @@ using System.Reflection;
[assembly: AssemblyDescription ("Provides refactoring support to MonoDevelop")]
[assembly: AssemblyVersion ("2.6")]
[assembly: AssemblyCopyright ("X11")]
-[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("FSharpBinding")]
-[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MonoDevelop.CSharpBinding")]
-[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MonoDevelop.PackageManagement")]
-[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MonoDevelop.MonoDroid")]
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisCommands.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisCommands.cs
index 4bba040f78..348cc789a9 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisCommands.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisCommands.cs
@@ -25,261 +25,22 @@
// THE SOFTWARE.
using System;
-using MonoDevelop.Components;
-using MonoDevelop.Components.Commands;
-using System.Linq;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
using System.Collections.Generic;
-using MonoDevelop.AnalysisCore.Gui;
-using MonoDevelop.AnalysisCore.Fixes;
-using MonoDevelop.Ide;
-using MonoDevelop.CodeIssues;
-using MonoDevelop.CodeActions;
-using System.Threading;
using System.IO;
-using MonoDevelop.Refactoring;
-using MonoDevelop.Ide.Gui.Dialogs;
+using System.Linq;
using Microsoft.CodeAnalysis;
-using MonoDevelop.Components.Extensions;
+using MonoDevelop.CodeActions;
+using MonoDevelop.CodeIssues;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Ide.Gui.Dialogs;
+using Microsoft.CodeAnalysis.Diagnostics;
namespace MonoDevelop.AnalysisCore
{
public enum AnalysisCommands
{
- FixOperations,
- ShowFixes,
- QuickFix,
ExportRules
}
-
- class ShowFixesHandler : CommandHandler
- {
- protected override void Update (CommandInfo info)
- {
- var doc = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument;
- if (doc == null || doc.Editor == null) {
- info.Enabled = false;
- return;
- }
- var codeActionExtension = doc.GetContent <CodeActionEditorExtension> ();
- if (codeActionExtension == null) {
- info.Enabled = false;
- return;
- }
- var fixes = codeActionExtension.GetCurrentFixes ();
- info.Enabled = !fixes.IsEmpty;
- }
-
- protected override void Run ()
- {
-// var doc = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument;
-// var view = doc.GetContent<MonoDevelop.SourceEditor.SourceEditorView> ();
-// if (view == null) {
-// LoggingService.LogWarning ("ShowFixesHandler could not find a SourceEditorView");
-// return;
-// }
-// var widget = view.TextEditor;
-// var pt = view.DocumentToScreenLocation (doc.Editor.Caret.Location);
-//
-// var ces = new CommandEntrySet ();
-// ces.AddItem (AnalysisCommands.FixOperations);
-// var menu = MonoDevelop.Ide.IdeApp.CommandService.CreateMenu (ces);
-//
-// menu.Popup (null, null, delegate (Menu mn, out int x, out int y, out bool push_in) {
-// x = pt.X;
-// y = pt.Y;
-// push_in = true;
-// //if the menu would be off the bottom of the screen, "drop" it upwards
-// if (y + mn.Requisition.Height > widget.Screen.Height)
-// y -= mn.Requisition.Height + (int)widget.LineHeight;
-// }, 0, Global.CurrentEventTime);
- }
- }
-
- class FixOperationsHandler : CommandHandler
- {
- protected override void Update (CommandArrayInfo info)
- {
-// MonoDevelop.Ide.Gui.Document document;
-// IList<FixableResult> results;
-// if (!GetFixes (out document, out results))
-// return;
-// PopulateInfos (info, document, results);
- }
-
- protected override void Run (object dataItem)
- {
- if (dataItem is Result) {
- ((Result)dataItem).ShowResultOptionsDialog ();
- return;
- }
- if (dataItem is System.Action) {
- ((System.Action)dataItem) ();
- return;
- }
- var action = dataItem as IAnalysisFixAction;
- if (action != null) {
- action.Fix ();
- return;
- }
-// var ca = dataItem as CodeAction;
-// if (ca != null) {
-// var doc = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument;
-//
-// var context = doc.ParsedDocument.CreateRefactoringContext != null ? doc.ParsedDocument.CreateRefactoringContext (doc, default(CancellationToken)) : null;
-// using (var script = context.CreateScript ()) {
-// ca.Run (context, script);
-// }
-// return;
-// }
-
-
- }
-
-// public static bool GetFixes (out MonoDevelop.Ide.Gui.Document document, out IList<FixableResult> results)
-// {
-// results = null;
-// document = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument;
-// if (document == null)
-// return false;
-//
-// var ext = document.GetContent<ResultsEditorExtension> ();
-// if (ext == null)
-// return false;
-//
-// var list = ext.GetResultsAtOffset (document.Editor.CaretOffset).OfType<FixableResult> ().ToList ();
-// list.Sort (ResultCompareImportanceDesc);
-// results = list;
-//
-// if (results.Count > 0)
-// return true;
-//
-// var codeActionExtension = document.GetContent <CodeActionEditorExtension> ();
-// if (codeActionExtension != null) {
-// var fixes = codeActionExtension.GetCurrentFixes ();
-// if (fixes != null)
-// return !fixes.IsEmpty;
-// }
-// return false;
-// }
-//
- static int ResultCompareImportanceDesc (Result r1, Result r2)
- {
- int c = ((int)r1.Level).CompareTo ((int)r2.Level);
- if (c != 0)
- return c;
- return string.Compare (r1.Message, r2.Message, StringComparison.Ordinal);
- }
-
-// public static void PopulateInfos (CommandArrayInfo infos, MonoDevelop.Ide.Gui.Document doc, IEnumerable<FixableResult> results)
-// {
-//// //FIXME: ellipsize long messages
-//// int mnemonic = 1;
-////
-//// var codeActionExtension = doc.GetContent <CodeActionEditorExtension> ();
-//// var fixes = codeActionExtension.GetCurrentFixes ();
-//// if (fixes != null) {
-//// foreach (var _fix in fixes.Where (CodeActionEditorExtension.IsAnalysisOrErrorFix)) {
-//// var fix = _fix;
-//// if (fix is AnalysisContextActionProvider.AnalysisCodeAction)
-//// continue;
-//// var escapedLabel = fix.Title.Replace ("_", "__");
-//// var label = (mnemonic <= 10)
-//// ? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel
-//// : " " + escapedLabel;
-//// infos.Add (label, fix);
-//// }
-//// }
-////
-//// foreach (var result in results) {
-//// bool firstAction = true;
-//// foreach (var action in GetActions (doc, result)) {
-//// if (firstAction) {
-//// //FIXME: make this header item insensitive but not greyed out
-//// infos.Add (new CommandInfo (result.Message.Replace ("_", "__"), false, false) {
-//// Icon = GetIcon (result.Level)
-//// }, null);
-//// firstAction = false;
-//// }
-//// var escapedLabel = action.Label.Replace ("_", "__");
-//// var label = (mnemonic <= 10)
-//// ? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel
-//// : " " + escapedLabel;
-//// infos.Add (label, action);
-//// }
-//// if (result.HasOptionsDialog) {
-//// var declSet = new CommandInfoSet ();
-//// declSet.Text = GettextCatalog.GetString ("_Options for \"{0}\"", result.OptionsTitle);
-////
-//// bool hasBatchFix = false;
-//// foreach (var fix in result.Fixes.OfType<IAnalysisFixAction> ().Where (f => f.SupportsBatchFix)) {
-//// hasBatchFix = true;
-//// var title = string.Format (GettextCatalog.GetString ("Apply in file: {0}"), fix.Label);
-//// declSet.CommandInfos.Add (title, new System.Action(fix.BatchFix));
-//// }
-//// if (hasBatchFix)
-//// declSet.CommandInfos.AddSeparator ();
-////
-//// var ir = result as InspectorResults;
-//// if (ir != null) {
-//// var inspector = ir.Inspector;
-////
-//// if (inspector.CanSuppressWithAttribute) {
-//// declSet.CommandInfos.Add (GettextCatalog.GetString ("_Suppress with attribute"), new System.Action(delegate {
-//// inspector.SuppressWithAttribute (doc, ir.Region);
-//// }));
-//// }
-////
-//// if (inspector.CanDisableWithPragma) {
-//// declSet.CommandInfos.Add (GettextCatalog.GetString ("_Suppress with #pragma"), new System.Action(delegate {
-//// inspector.DisableWithPragma (doc, ir.Region);
-//// }));
-//// }
-////
-//// if (inspector.CanDisableOnce) {
-//// declSet.CommandInfos.Add (GettextCatalog.GetString ("_Disable Once"), new System.Action(delegate {
-//// inspector.DisableOnce (doc, ir.Region);
-//// }));
-//// }
-////
-//// if (inspector.CanDisableAndRestore) {
-//// declSet.CommandInfos.Add (GettextCatalog.GetString ("Disable _and Restore"), new System.Action(delegate {
-//// inspector.DisableAndRestore (doc, ir.Region);
-//// }));
-//// }
-//// }
-////
-//// declSet.CommandInfos.Add (GettextCatalog.GetString ("_Configure Rule"), result);
-////
-//// infos.Add (declSet);
-//// }
-//// }
-// }
-//
-// public static IEnumerable<IAnalysisFixAction> GetActions (MonoDevelop.Ide.Gui.Document doc, FixableResult result)
-// {
-// foreach (var fix in result.Fixes)
-// foreach (var handler in AnalysisExtensions.GetFixHandlers (fix.FixType))
-// foreach (var action in handler.GetFixes (doc.Editor, doc, fix))
-// yield return action;
-//
-// }
-//
-// static string GetIcon (Severity severity)
-// {
-// switch (severity) {
-// case Severity.Error:
-// return Ide.Gui.Stock.Error;
-// case Severity.Warning:
-// return Ide.Gui.Stock.Warning;
-// case Severity.Hint:
-// return Ide.Gui.Stock.Information;
-// default:
-// return null;
-// }
-// }
- }
class ExportRulesHandler : CommandHandler
{
@@ -294,7 +55,7 @@ namespace MonoDevelop.AnalysisCore
Dictionary<CodeDiagnosticDescriptor, DiagnosticSeverity?> severities = new Dictionary<CodeDiagnosticDescriptor, DiagnosticSeverity?> ();
- foreach (var node in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDecsriptorsAsync (CodeRefactoringService.MimeTypeToLanguage(lang), true).Result) {
+ foreach (var node in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDescriptorsAsync (CodeRefactoringService.MimeTypeToLanguage(lang), true).Result) {
severities [node] = node.DiagnosticSeverity;
// if (node.GetProvider ().SupportedDiagnostics.Length > 1) {
// foreach (var subIssue in node.GetProvider ().SupportedDiagnostics) {
@@ -313,15 +74,15 @@ namespace MonoDevelop.AnalysisCore
sw.WriteLine ("<h2>" + g.Key + "</h2>");
sw.WriteLine ("<table border='1'>");
- foreach (var node in g.OrderBy (n => n.Name, StringComparer.Ordinal)) {
- var title = node.Name;
- var desc = node.GetProvider ().SupportedDiagnostics.First ().Description.ToString () != title ? node.GetProvider ().SupportedDiagnostics.First ().Description : "";
- sw.WriteLine ("<tr><td>" + title + "</td><td>" + desc + "</td><td>" + node.DiagnosticSeverity + "</td></tr>");
- if (node.GetProvider ().SupportedDiagnostics.Length > 1) {
- foreach (var subIssue in node.GetProvider ().SupportedDiagnostics) {
+ foreach (var node in g.Select (n => new { Descriptor = n, Provider = n.GetProvider ()}).OrderBy (n => n.Provider.GetAnalyzerId(), StringComparer.Ordinal)) {
+ var title = node.Provider.GetAnalyzerId ();
+ var desc = node.Provider.SupportedDiagnostics.First ().Description.ToString () != title ? node.Provider.SupportedDiagnostics.First ().Description : "";
+ sw.WriteLine ("<tr><td>" + title + "</td><td>" + desc + "</td><td>" + node.Descriptor.DiagnosticSeverity + "</td></tr>");
+ if (node.Provider.SupportedDiagnostics.Length > 1) {
+ foreach (var subIssue in node.Provider.SupportedDiagnostics) {
title = subIssue.Description.ToString ();
desc = subIssue.Description.ToString () != title ? subIssue.Description : "";
- sw.WriteLine ("<tr><td> - " + title + "</td><td>" + desc + "</td><td>" + node.GetSeverity (subIssue) + "</td></tr>");
+ sw.WriteLine ("<tr><td> - " + title + "</td><td>" + desc + "</td><td>" + node.Descriptor.GetSeverity (subIssue) + "</td></tr>");
}
}
}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisExtensions.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisExtensions.cs
deleted file mode 100644
index 1fdeaa2662..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisExtensions.cs
+++ /dev/null
@@ -1,240 +0,0 @@
-//
-// AnalysisServiceExtensions.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using MonoDevelop.Core;
-using Mono.Addins;
-using System.Linq;
-using MonoDevelop.Ide.Codons;
-using MonoDevelop.AnalysisCore.Extensions;
-
-namespace MonoDevelop.AnalysisCore
-{
- internal static class AnalysisExtensions
- {
- const string EXT_RULES = "/MonoDevelop/AnalysisCore/Rules";
- const string EXT_TYPES = "/MonoDevelop/AnalysisCore/Types";
- const string EXT_FIX_HANDLERS = "/MonoDevelop/AnalysisCore/FixHandlers";
-
- static KeyedNodeList<string,AnalysisRuleAddinNode> rulesByInput
- = new KeyedNodeList<string,AnalysisRuleAddinNode> ();
-
- // This is a re-usable cache of computed trees. it will need to be flushed nodesByInput is cached.
- // We should probably clean it via a LRU too.
- static Dictionary<RuleTreeType,RuleTreeRoot> analysisTreeCache
- = new Dictionary<RuleTreeType, RuleTreeRoot> ();
-
- static Dictionary<string,AnalysisTypeExtensionNode> ruleInputTypes
- = new Dictionary<string, AnalysisTypeExtensionNode> ();
-
- static KeyedNodeList<string,FixHandlerExtensionNode> fixHandlers
- = new KeyedNodeList<string,FixHandlerExtensionNode> ();
-
- static AnalysisExtensions ()
- {
- AddinManager.AddExtensionNodeHandler (EXT_RULES, OnRuleNodeChanged);
- AddinManager.AddExtensionNodeHandler (EXT_TYPES, OnTypeNodeChanged);
- AddinManager.AddExtensionNodeHandler (EXT_FIX_HANDLERS, OnFixHandlerNodeChanged);
- }
-
- static void OnRuleNodeChanged (object sender, ExtensionNodeEventArgs args)
- {
- switch (args.Change) {
- case ExtensionChange.Add:
- AddRule (args.ExtensionNode);
- break;
- case ExtensionChange.Remove:
- RemoveRule (args.ExtensionNode);
- break;
- }
- analysisTreeCache.Clear ();
- }
-
- static void OnTypeNodeChanged (object sender, ExtensionNodeEventArgs args)
- {
- var node = (AnalysisTypeExtensionNode) args.ExtensionNode;
- switch (args.Change) {
- case ExtensionChange.Add:
- if (ruleInputTypes.ContainsKey (node.Name))
- throw new InvalidOperationException ("Duplicate analysis node type '" + node.Name + "' registered");
- ruleInputTypes[node.Name] = node;
- break;
- case ExtensionChange.Remove:
- ruleInputTypes.Remove (node.Name);
- break;
- }
- analysisTreeCache.Clear ();
- }
-
- static void OnFixHandlerNodeChanged (object sender, ExtensionNodeEventArgs args)
- {
- var node = (FixHandlerExtensionNode) args.ExtensionNode;
- switch (args.Change) {
- case ExtensionChange.Add:
- fixHandlers.Add (node.FixName, node);
- break;
- case ExtensionChange.Remove:
- fixHandlers.Remove (node.FixName, node);
- break;
- }
- }
-
- static void AddRule (ExtensionNode extNode)
- {
- if (extNode is CategoryNode) {
- foreach (ExtensionNode child in extNode.ChildNodes)
- AddRule (child);
- return;
- }
-
- var node = (AnalysisRuleAddinNode)extNode;
- rulesByInput.Add (node.Input, node);
- }
-
- static void RemoveRule (ExtensionNode extNode)
- {
- if (extNode is CategoryNode) {
- foreach (ExtensionNode child in extNode.ChildNodes)
- RemoveRule (child);
- return;
- }
- var node = (AnalysisRuleAddinNode)extNode;
- rulesByInput.Remove (node.Input, node);
- }
-
- internal static Type GetType (string name)
- {
- //this is hardcoded as the tree leaf node
- if (name == RuleTreeLeaf.TYPE)
- return typeof (IEnumerable<Result>);
-
- //throws if not present
- return ruleInputTypes[name].Type;
- }
-
- // Gets an analysis tree from the cache, or creates one.
- // Cache may have null value if there were no nodes for the type.
- public static RuleTreeRoot GetAnalysisTree (RuleTreeType treeType)
- {
- RuleTreeRoot tree;
- if (analysisTreeCache .TryGetValue (treeType, out tree))
- return tree;
-
- analysisTreeCache [treeType] = tree = BuildTree (treeType);
-
-#if DEBUG_ANALYSIS_TREE
- if (tree != null)
- Console.WriteLine (tree.GetTreeStructure ());
-#endif
- return tree;
- }
-
- static RuleTreeRoot BuildTree (RuleTreeType treeType)
- {
- var nodes = GetTreeNodes (treeType, treeType.Input, 0);
- if (nodes == null || nodes.Length == 0)
- return null;
-
- return new RuleTreeRoot (nodes, treeType);
- }
-
- //recursively builds the rule tree for branches that terminate in leaves (rules with result outputs)
- static IRuleTreeNode[] GetTreeNodes (RuleTreeType treeType, string input, int depth)
- {
- var addinNodes = rulesByInput.Get (input);
- if (addinNodes == null)
- return null;
-
- var validNodes = addinNodes.Where (n => n.Supports (treeType.FileExtension)).ToList ();
- if (validNodes.Count == 0)
- return null;
-
- var list = new List<IRuleTreeNode> ();
-
- foreach (var n in validNodes) {
- //leaf node, return directly
- if (n.Output == RuleTreeLeaf.TYPE) {
- list.Add (new RuleTreeLeaf (n));
- continue;
- }
-
- if (depth > 50)
- throw new InvalidOperationException ("Analysis tree too deep. Check for circular dependencies " +
- n.GetErrSource ());
-
- //get the nodes that will handle the output - by recursively calling this
- var childNodes = GetTreeNodes (treeType, n.Output, depth + 1);
-
- //if no child nodes are returned, don't even return this, because its output won't be used
- if (childNodes == null || childNodes.Length == 0)
- continue;
-
- list.Add (new RuleTreeBranch (childNodes, n));
- }
-
- return list.ToArray ();
- }
-
- public static IEnumerable<IFixHandler> GetFixHandlers (string fixType)
- {
- var nodes = fixHandlers.Get (fixType);
- if (nodes != null)
- return nodes.Select (node => node.FixHandler);
- return new IFixHandler[0];
- }
- }
-
- class KeyedNodeList<K,V>
- {
- Dictionary<K,List<V>> dict = new Dictionary<K,List<V>> ();
-
- public List<V> Get (K key)
- {
- List<V> list;
- dict.TryGetValue (key, out list);
- return list;
- }
-
- public void Remove (K key, V value)
- {
- List<V> list;
- if (!dict.TryGetValue (key, out list) || !list.Remove (value))
- throw new Exception ("Item missing");
- if (list.Count == 0)
- dict.Remove (key);
- }
-
- public void Add (K key, V value)
- {
- List<V> list;
- if (!dict.TryGetValue (key, out list))
- dict[key] = list = new List<V> ();
- list.Add (value);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisService.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisService.cs
deleted file mode 100644
index 0a890b2752..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisService.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-// AnalysisService.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using MonoDevelop.Core;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace MonoDevelop.AnalysisCore
-{
- public static class AnalysisService
- {
- public static IEnumerable<Result> Analyze<T> (T input, RuleTreeType treeType, CancellationToken cancellationToken = default (CancellationToken))
- {
- Debug.Assert (typeof(T) == AnalysisExtensions.GetType (treeType.Input));
-
- var tree = AnalysisExtensions.GetAnalysisTree (treeType);
- if (tree == null)
- return RuleTreeLeaf.Empty;
-
- //force to analyze immediately by evaluating into a list
- return tree.Analyze (input, cancellationToken).ToList ();
- }
-
- public static Task<IEnumerable<Result>> QueueAnalysis <T> (T input, RuleTreeType treeType, CancellationToken cancellationToken = default (CancellationToken))
- {
- return Task.Factory.StartNew (() => Analyze (input, treeType, cancellationToken), cancellationToken);
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/AnalysisRuleAddinNode.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/AnalysisRuleAddinNode.cs
deleted file mode 100644
index 9b1c5b476f..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/AnalysisRuleAddinNode.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-//
-// RuleAddinNode.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Linq;
-using Mono.Addins;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Threading;
-
-namespace MonoDevelop.AnalysisCore.Extensions
-{
- class NamedAnalysisRuleAddinNode : AnalysisRuleAddinNode
- {
- [NodeAttribute ("_name", Required=true, Localizable=true, Description="User-visible name of the rule")]
- string name = null;
-
- public string Name { get { return name; } }
-
- public override string Output { get { return RuleTreeLeaf.TYPE; } }
- }
-
- //hidden in GUIs
- class AdaptorAnalysisRuleAddinNode : AnalysisRuleAddinNode
- {
- [NodeAttribute (Required=true, Description="The ID of the output type.")]
- string output = null;
-
- public override string Output { get { return output; } }
- }
-
- abstract class AnalysisRuleAddinNode : ExtensionNode
- {
- //generally rules should not need to use fileExtensions, since their input types (e.g.CSharpDom) should be enough
- //but it's needed for the proprocessor/typemapping rules like ParsedDocument->CSharpDom
- [NodeAttribute (Description="Comma separated list of file extensions to which this rule applies. It applies to all if none is specified.")]
- string[] fileExtensions = null;
-
- [NodeAttribute (Required=true, Description="The ID of the input type")]
- string input = null;
-
- [NodeAttribute ("func", Required=true, Description="The static Func<T,CancellationToken,T> that processes the rule.")]
- string funcName = null;
-
- public string[] FileExtensions { get { return fileExtensions; } }
- public string Input { get { return input; } }
- public abstract string Output {get; }
- public string FuncName { get { return funcName; } }
-
- //Lazy so we avoid loading assemblies until needed
- Func<object, CancellationToken, object> cachedInstance;
-
- public Func<object, CancellationToken, object> Analyze {
- get {
- if (cachedInstance == null)
- CreateFunc ();
- return cachedInstance;
- }
- }
-
- //TODO: allow generics
- void CreateFunc ()
- {
- Func<object, CancellationToken, object> rule = null;
- try {
- if (string.IsNullOrEmpty (funcName))
- throw new InvalidOperationException ("Rule extension does not specify a func " + GetErrSource ());
-
- int dotIdx = funcName.LastIndexOf ('.');
- if (dotIdx <= 0)
- throw new InvalidOperationException ("Rule func name ' " + funcName + " 'is invalid " + GetErrSource ());
-
- string typeName = funcName.Substring (0, dotIdx);
- var type = this.Addin.GetType (typeName, true);
-
- var inputType = AnalysisExtensions.GetType (Input);
- var outputType = AnalysisExtensions.GetType (Output);
-
- string methodName = funcName.Substring (dotIdx + 1);
- var methodInfo = type.GetMethod (methodName,
- BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic,
- Type.DefaultBinder, new Type[] { inputType, typeof(CancellationToken)},
- new ParameterModifier [] { new ParameterModifier () });
-
- if (methodInfo == null)
- throw new InvalidOperationException ("Rule func ' " + funcName + "' could not be resolved " + GetErrSource ());
-
- if (methodInfo.ReturnType != outputType)
- throw new InvalidOperationException ("Rule func ' " + funcName + "' has wrong output type " + GetErrSource ());
-
- var wrapper = new DynamicMethod (methodName + "_obj" + (dynamicMethodKey++),
- typeof(object), new Type[] { typeof(object), typeof(CancellationToken) }, true);
-
- var il = wrapper.GetILGenerator ();
- il.Emit (OpCodes.Ldarg_0);
- il.Emit (OpCodes.Castclass, inputType);
- il.Emit (OpCodes.Ldarg_1);
- il.Emit ((methodInfo.IsFinal || !methodInfo.IsVirtual) ? OpCodes.Call : OpCodes.Callvirt, methodInfo);
- il.Emit (OpCodes.Ret);
-
- rule = (Func<object, CancellationToken, object>)wrapper.CreateDelegate (typeof(Func<object, CancellationToken, object>));
- } finally {
- cachedInstance = rule ?? NullRule;
- }
- }
-
- static int dynamicMethodKey = 0;
-
- internal string GetErrSource ()
- {
- return string.Format ("({0}:{1})", Addin.Id, Path);
- }
-
- static object NullRule (object o, CancellationToken cancellationToken)
- {
- return null;
- }
-
- public bool Supports (string extension)
- {
- if (fileExtensions != null && fileExtensions.Length > 0)
- return fileExtensions.Any (fe => string.Compare (fe, extension, StringComparison.OrdinalIgnoreCase) == 0);
- return true;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/AnalysisTypeExtensionNode.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/AnalysisTypeExtensionNode.cs
deleted file mode 100644
index 89d9164774..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/AnalysisTypeExtensionNode.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// RuleInputTypeExtensionNode.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using Mono.Addins;
-
-namespace MonoDevelop.AnalysisCore.Extensions
-{
- public class AnalysisTypeExtensionNode : TypeExtensionNode
- {
- [NodeAttribute(Required=true)]
- string name = null;
-
- public string Name { get { return name; } }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/FixHandlerExtensionNode.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/FixHandlerExtensionNode.cs
deleted file mode 100644
index 9ab4a84d82..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Extensions/FixHandlerExtensionNode.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// AnalysisFixHandlerExtensionNode.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using Mono.Addins;
-
-namespace MonoDevelop.AnalysisCore.Extensions
-{
- public class FixHandlerExtensionNode : TypeExtensionNode
- {
- [NodeAttribute (Required=true)]
- string fixName = null;
-
- public string FixName { get { return fixName; } }
-
- public IFixHandler FixHandler {
- get { return (IFixHandler) CreateInstance (); }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/FixableResult.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/FixableResult.cs
deleted file mode 100644
index ca3ca05b3e..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/FixableResult.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-// FixableResult.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.Ide.Editor;
-using Microsoft.CodeAnalysis;
-
-namespace MonoDevelop.AnalysisCore
-{
-// public class FixableResult : Result
-// {
-// public FixableResult (TextSpan region, string message, DiagnosticSeverity level,
-// IssueMarker mark, params IAnalysisFix[] fixes)
-// : base (region, message, level, mark)
-// {
-// this.Fixes = fixes;
-// }
-//
-// public IAnalysisFix[] Fixes { get; protected set; }
-// }
-
- //FIXME: should this really use MonoDevelop.Ide.Gui.Document? Fixes could be more generic.
- public interface IAnalysisFix
- {
- string FixType { get; }
- }
-
- public interface IFixHandler
- {
- IEnumerable<IAnalysisFixAction> GetFixes (TextEditor editor, DocumentContext doc, object fix);
- }
-
- public interface IAnalysisFixAction
- {
- string Label { get; }
- bool SupportsBatchFix { get; }
- TextSpan DocumentRegion { get; }
- string IdString { get; }
- void Fix ();
- void BatchFix ();
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/GenericFix.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/GenericFix.cs
deleted file mode 100644
index ca7bd317f0..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/GenericFix.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-//
-// GenericFix.cs
-//
-// Author:
-// Mike Krüger <mkrueger@novell.com>
-//
-// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-using MonoDevelop.CodeIssues;
-using MonoDevelop.Ide;
-using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.Ide.Editor;
-using Microsoft.CodeAnalysis;
-
-namespace MonoDevelop.AnalysisCore.Fixes
-{
-// public class GenericResults : FixableResult
-// {
-// public GenericResults (TextSpan region, string message, DiagnosticSeverity level,
-// IssueMarker mark, params GenericFix[] fixes)
-// : base (region, message, level, mark)
-// {
-// this.Fixes = fixes;
-// }
-// }
-
- public class GenericFix : IAnalysisFix, IAnalysisFixAction
- {
- Action fix;
- Action batchFix;
- string label;
- public TextSpan DocumentRegion { get; set; }
- public string IdString { get; set; }
-
- public GenericFix (string label, Action fix, Action batchFix = null)
- {
- this.batchFix = batchFix;
- this.fix = fix;
- this.label = label;
- }
-
-
- #region IAnalysisFix implementation
- public string FixType {
- get {
- return "Generic";
- }
- }
- #endregion
-
- #region IAnalysisFixAction implementation
- public void Fix ()
- {
- fix ();
- }
-
- public bool SupportsBatchFix {
- get {
- return batchFix != null;
- }
- }
-
- public void BatchFix () {
- if (!SupportsBatchFix) {
- throw new InvalidOperationException ("Batch fixing is not supported.");
- }
- batchFix ();
- }
-
- public string Label {
- get {
- return label;
- }
- }
- #endregion
- }
-
- public class GenericFixHandler : IFixHandler
- {
- #region IFixHandler implementation
- public IEnumerable<IAnalysisFixAction> GetFixes (TextEditor editor, DocumentContext context, object fix)
- {
- yield return (GenericFix)fix;
- }
- #endregion
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/RenameMemberFix.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/RenameMemberFix.cs
deleted file mode 100644
index 15471b44fa..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/RenameMemberFix.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-//
-// FixHandler.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using MonoDevelop.Core;
-using MonoDevelop.Refactoring;
-using MonoDevelop.Refactoring.Rename;
-using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.Ide.Editor;
-
-namespace MonoDevelop.AnalysisCore.Fixes
-{
- public class RenameMemberFix : IAnalysisFix
- {
- public string NewName { get; private set; }
- public string OldName { get; private set; }
- public string IdString { get; set; }
-// public IEntity Item { get; private set; }
-//
-// public RenameMemberFix (IEntity item, string oldName, string newName)
-// {
-// this.OldName = oldName;
-// this.NewName = newName;
-// this.Item = item;
-// }
-
- public string FixType { get { return "RenameMember"; } }
- }
-
- class RenameMemberHandler : IFixHandler
- {
- //FIXME: why is this invalid on the parseddocuments loaded when the doc is first loaded?
- //maybe the item's type's SourceProject is null?
- public IEnumerable<IAnalysisFixAction> GetFixes (TextEditor editor, DocumentContext doc, object fix)
- {
- var renameFix = (RenameMemberFix)fix;
- var refactoring = new RenameRefactoring ();
- var options = new RefactoringOptions (editor, doc) {
- // SelectedItem = renameFix.Item,
- };
-
-// if (renameFix.Item == null) {
-// ResolveResult resolveResult;
-// options.SelectedItem = CurrentRefactoryOperationsHandler.GetItem (options.Editor, options.DocumentContext, out resolveResult);
-// }
-//
-// if (!refactoring.IsValid (options))
-// yield break;
-//
- var prop = new RenameRefactoring.RenameProperties () {
- NewName = renameFix.NewName,
- };
- if (string.IsNullOrEmpty (renameFix.NewName)) {
- yield return new RenameFixAction () {
- Label = GettextCatalog.GetString ("Rename '{0}'...", renameFix.OldName),
- Refactoring = refactoring,
- Options = options,
- Properties = prop,
- Preview = false,
- };
- yield break;
- }
- yield return new RenameFixAction () {
- Label = GettextCatalog.GetString ("Rename '{0}' to '{1}'", renameFix.OldName, renameFix.NewName),
- Refactoring = refactoring,
- Options = options,
- Properties = prop,
- Preview = false,
- };
-
- yield return new RenameFixAction () {
- Label = GettextCatalog.GetString ("Rename '{0}' to '{1}' with preview",
- renameFix.OldName, renameFix.NewName),
- Refactoring = refactoring,
- Options = options,
- Properties = prop,
- Preview = true,
- };
- }
-
- class RenameFixAction : IAnalysisFixAction
- {
- public RenameRefactoring Refactoring;
- public RefactoringOptions Options;
- public RenameRefactoring.RenameProperties Properties;
- public bool Preview;
- public string Label { get; set; }
- public TextSpan DocumentRegion { get; set; }
- public string IdString { get; set; }
-
- public void Fix ()
- {
- if (string.IsNullOrEmpty (Properties.NewName)) {
- //Refactoring.RunInplace (Options);
- return;
- }
-
-// //FIXME: performchanges should probably use a monitor too, as it can be slow
-// var changes = Refactoring.PerformChanges (Options, Properties);
-// if (Preview) {
-// using (var dlg = new RefactoringPreviewDialog (changes))
-// MessageService.ShowCustomDialog (dlg);
-// } else {
-// var monitor = IdeApp.Workbench.ProgressMonitors.GetBackgroundProgressMonitor ("Rename", null);
-// RefactoringService.AcceptChanges (monitor, changes);
-// }
- }
-
- public bool SupportsBatchFix {
- get {
- return false;
- }
- }
-
- public void BatchFix ()
- {
- throw new InvalidOperationException ("Batch fixing is not supported");
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs
index 5a21201fbe..480641fd64 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs
@@ -26,18 +26,16 @@
using System;
using System.Collections.Generic;
-using MonoDevelop.Ide.Gui.Content;
+using System.Collections.Immutable;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using System.IO;
-using System.Linq;
-using MonoDevelop.Ide.Editor;
-using MonoDevelop.Core.Text;
-using MonoDevelop.Ide.Editor.Highlighting;
-using MonoDevelop.Ide.Editor.Extension;
using Microsoft.CodeAnalysis;
using MonoDevelop.CodeIssues;
-using System.Collections.Immutable;
+using MonoDevelop.Core.Text;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.Ide.Editor.Extension;
+using MonoDevelop.Ide.Editor.Highlighting;
namespace MonoDevelop.AnalysisCore.Gui
{
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/README.txt b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/README.txt
deleted file mode 100644
index 5354297d9a..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/README.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-AnalysisCore currently provides several services -
-
-* The AnalysisService, a service for analyzing arbitrary input objects
- based on extensible rules.
-
-* a TextEditorExtension that uses the AnalysisService to process the
- editor's ParsedDocument when it's updated by the ProjectDomService,
- and shows any resulting errors or warnings as underlines in the editor.
-
-== The AnalysisService ==
-
-AnalysisService is fundamentally based on the idea of an "Analyzer tree".
-This is a tree where each node contains a "rule". Each rule is a Func<T,TRet>
-that transforms an input object to an output object. The tree is constructed
-in such a way that the output type of each node's rule matches the input type
-of its children, and leaf nodes always output IEnumerable<Result>. Thus, when
-Analyze (someInputObject) is called on the root node, the intermediates
-objects propagate down the tree, and the Results are aggregated and returned.
-
-The trees are constructed based on rule nodes registered in the addin file.
-Each node had an input and output "type", which is a string alias for a real
-CLR type. Multiple aliases can be registered for one real type - the aliases
-specify how the rule nodes can be connected, and the CLR types simply allow
-strongly typing the rule functions.
-
-== Extension Points ==
-
-The is an extension point "/MonoDevelop/AnalysisCore/Type" where type aliases
-must be registered before use. Although aliases may only be registered once,
-they may be used by any number of rules.
-
-There are two kinds of rule extension nodes, <Adaptor> and <Rule>. Both may be
-registered at the same extension point, "/MonoDevelop/AnalysisCore/Rules".
-Both kinds of node must specify an input alias and a function name, which
-must correspond to a static method in the addin assembly. The static method's
-argument and return type must match the CLR types to which the input and
-output aliases map.
-
-== Rules ==
-
-Rules always have an implicit output type of "Results", which is the built-in
-alias for IEnumerable<Result>, and they also have a user-readable, localizable
-name value, so that they may be displayed in UI for configuring which rules
-are enabled.
-
-== Adaptors ==
-
-Adaptors must specify an output type, but are not user-visible so are not named.
-Their purpose is to do processing work that can be shared by multiple rules -
-for example, an adaptor can generate a special type that is known to several
-rules and includes additional preprocessing result, so that the rules so not
-have to repeat the work. Adaptors may also be used to map input types to types
-that are known by existing rules - for example, an adaptor could process the
-output of the ASP.NET parser to prodice input known to existing C# rules.
-Adaptors may also be used to make branches conditional - if they output null,
-then none of their children will be executed.
-
-When building the tree, the possible extension nodes used are filtered using
-optional filenames on the extension nodes. If an adaptor is filtered out,
-then none of the nodes that consume its output can be used, so they need not
-be filtered explicitly. For example, if there were an adaptor that cast an
-ICompilationUnit input to a CSharpCompilationUnit output, then it should be
-filtered on the .cs file extension, and any rules with a CSharpCompilationUnit
-input would not be used.
-
-Adaptors can produce more than one output quite easily. If the outputs are
-a collection, then simply make the collection type the output type. If there
-are several different output objects, they can be aggregated on properties of
-a new type which can be used as the output type. Consumers may consume this
-type directly, or multiple additional adaptor rules may be used to pick off
-the individual objects. \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Result.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Result.cs
index 7ed4a24101..ddb79f375c 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Result.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Result.cs
@@ -25,9 +25,8 @@
// THE SOFTWARE.
using System;
-using MonoDevelop.AnalysisCore.Extensions;
-using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
namespace MonoDevelop.AnalysisCore
{
@@ -68,7 +67,5 @@ namespace MonoDevelop.AnalysisCore
public TextSpan Region { get; private set; }
public bool Underline { get; private set; }
-
- internal AnalysisRuleAddinNode Source { get; set; }
}
}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/RuleTree.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/RuleTree.cs
deleted file mode 100644
index 83279c1ce8..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/RuleTree.cs
+++ /dev/null
@@ -1,205 +0,0 @@
-//
-// RuleTreeNode.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Text;
-using MonoDevelop.AnalysisCore.Extensions;
-using System.Threading;
-
-namespace MonoDevelop.AnalysisCore
-{
- // This is a tree for holding the structure of rules, connected with matched inputs and outputs.
- // It yields Results from the tree's leaves via the intermediate nodes.
- interface IRuleTreeNode
- {
- IEnumerable<Result> Analyze (object input, CancellationToken cancellationToken);
- }
-
- sealed class RuleTreeLeaf : IRuleTreeNode
- {
- AnalysisRuleAddinNode rule;
-
- internal const string TYPE = "Results";
-
- public RuleTreeLeaf (AnalysisRuleAddinNode rule)
- {
- this.rule = rule;
- Debug.Assert (rule != null);
- Debug.Assert (rule.Output == TYPE);
- }
-
- public AnalysisRuleAddinNode Rule { get { return rule; } }
-
- //re-use to reduce pointless allocations
- public static Result[] Empty = new Result[0];
-
- public IEnumerable<Result> Analyze (object input, CancellationToken cancellationToken)
- {
- //we construct the tree such that only a rule with an output of Result can be a leaf
- //therefore its result must be castable to IEnumerable<Result>.
- var results = (IEnumerable<Result>)rule.Analyze (input, cancellationToken);
- if (results == null)
- return Empty;
-
- //tag all the results with the source rule
- foreach (var result in results)
- result.Source = rule;
-
- return results;
- }
- }
-
- sealed class RuleTreeBranch : IRuleTreeNode
- {
- AnalysisRuleAddinNode rule;
- IRuleTreeNode[] children;
-
- public RuleTreeBranch (IRuleTreeNode[] children, AnalysisRuleAddinNode rule)
- {
- this.rule = rule;
- this.children = children;
- Debug.Assert (rule != null);
- Debug.Assert (children != null && children.Length > 0);
- Debug.Assert (children.All (c =>
- (c is RuleTreeLeaf && ((RuleTreeLeaf)c).Rule.Input == rule.Output)
- || (c is RuleTreeBranch && ((RuleTreeBranch)c).Rule.Input == rule.Output)
- ));
- }
-
- public AnalysisRuleAddinNode Rule { get { return rule; } }
- public IRuleTreeNode[] Children { get { return children; } }
-
- // This handles walking the tree - running this node's rule, and collecting results from child nodes
- public IEnumerable<Result> Analyze (object input, CancellationToken cancellationToken = default (CancellationToken))
- {
- // It's not a leaf node, so it has children which all expect the object output by this rule
- var intermediate = rule.Analyze (input, cancellationToken);
-
- // Rules may return null, in which case there is no point running their children
- // This allows "adaptor" rules, which can check an input's type or state to choose whether to return an output
- if (intermediate == null)
- return RuleTreeLeaf.Empty;
-
- //collect the results from all the children
- //TODO: this could be parallelized trivially, since the tree nodes and the rules do not have any state
- return children.SelectMany (child => child.Analyze (intermediate, cancellationToken));
- }
- }
-
- sealed class RuleTreeRoot
- {
- IRuleTreeNode[] children;
- RuleTreeType treeType;
-
- public RuleTreeRoot (IRuleTreeNode[] children, RuleTreeType treeType)
- {
- this.children = children;
- this.treeType = treeType;
- Debug.Assert (treeType != null);
- Debug.Assert (children != null && children.Length > 0);
- Debug.Assert (children.All (c =>
- (c is RuleTreeLeaf && ((RuleTreeLeaf)c).Rule.Input == treeType.Input)
- || (c is RuleTreeBranch && ((RuleTreeBranch)c).Rule.Input == treeType.Input)
- ));
- }
-
- public RuleTreeType TreeType { get { return treeType; } }
-
- public IEnumerable<Result> Analyze (object input, CancellationToken cancellationToken)
- {
- return children.SelectMany (child => child.Analyze (input, cancellationToken));
- }
-
- public string GetTreeStructure ()
- {
- var builder = new StringBuilder ();
- builder.AppendFormat ("[AnalysisTree (Input='{0}', Extension='{1}')\n", treeType.Input, treeType.FileExtension);
- PrintTreeStructure (builder, children, " ");
- builder.Append ("]\n");
- return builder.ToString ();
- }
-
- void PrintTreeStructure (StringBuilder builder, IRuleTreeNode[] children, string indent)
- {
- foreach (var c in children) {
- builder.Append (indent);
-
- var leaf = c as RuleTreeLeaf;
- if (leaf != null) {
- builder.AppendFormat ("[Leaf (Rule='{0}')]\n", leaf.Rule.FuncName);
- continue;
- }
-
- var branch = (RuleTreeBranch) c;
- builder.AppendFormat ("[Branch (Output='{0}',Rule='{1}')\n", branch.Rule.Output, branch.Rule.FuncName);
-
- PrintTreeStructure (builder, branch.Children, indent + " ");
-
- builder.Append (indent);
- builder.Append ("]\n");
- }
- }
- }
-
- // Type of the analysis tree. Basically a key for the analysis tree cache.
- public class RuleTreeType
- {
- string input, fileExtension;
-
- public string Input { get { return input; } }
- public string FileExtension { get { return fileExtension; } }
-
- public RuleTreeType (string input, string fileExtension)
- {
- Debug.Assert (!string.IsNullOrEmpty (input));
- Debug.Assert (!string.IsNullOrEmpty (fileExtension));
-
- this.input = input;
- this.fileExtension = fileExtension;
- }
-
- public override bool Equals (object obj)
- {
- if (obj == null)
- return false;
- if (ReferenceEquals (this, obj))
- return true;
- var other = obj as RuleTreeType;
- return other != null && input == other.input && fileExtension == other.fileExtension;
- }
-
- public override int GetHashCode ()
- {
- unchecked {
- return (input != null ? input.GetHashCode () : 0)
- ^ (fileExtension != null ? fileExtension.GetHashCode () : 0);
- }
- }
- }
-} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/RuleTreeType.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/RuleTreeType.cs
deleted file mode 100644
index 0d869d7529..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/RuleTreeType.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// NodeTreeType.cs
-//
-// Author:
-// Michael Hutchinson <mhutchinson@novell.com>
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Diagnostics;
-
-namespace MonoDevelop.AnalysisCore
-{
-
-}
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/TODO.txt b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/TODO.txt
deleted file mode 100644
index 4597f6659a..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/TODO.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-Some things that still need to be done in AnalyzerCore:
-
-* LOTS of rules - both generic .NET (for ICompilationUnit) and
- using an adaptor that would invoke the new C# parser.
-
-* A pad, for viewing the rules list more directly.
-
-* Support for configuring which rules are used, via additional
- filters when building the analysis tree.
-
-* A GUI for configuring the rules used.
-
-* Configurable rules. Rules should be able to specify a configuration
- object type in the addins file, and a GUI panel for editing the values.
- A more specialized analysis tree nodes could be used for rules with
- options, which would be Func<TIn,TOptions,TOut>
-
-* A scheduler for analysis jobs that would automatically discard outdated
- queued jobs when a newer job comes in.
-
-* UserVisibleStringCollection type and a rule to spellcheck it, so anything
- can output this node to generate spellchecking results.
-
-
-Some things that would be nice, but aren't so immediately important:
-
-* Profiling, both CPU and memory.
-
-* Parallelize the analysis trees - should be quite easy.
-
-* Clean up the type handling - use more specialized analysis tree nodes
- to avoid the wrapper DynamicMethods and the casts they do.
-
-* Commands to suppress individual results, persisted in suppression files.
-
-* Analysis on demand, with a results list. This could easily process all files
- in a project or sln.
-
-* Support for specifying rule priorities and using multiple analyser
- trees at different frequencies for one document, in order to run
- cheaper or more userful rules more frequently.
-
-* Project-wide on the fly analysis.
-
-* Solution-wide on the fly analysis.
-
-* Rules to analyze project settings.
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs
index 29398fea9b..2df7349d65 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs
@@ -23,33 +23,30 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
-using Gtk;
using System.Collections.Generic;
-using MonoDevelop.Components.Commands;
+using System.Collections.Immutable;
using System.Linq;
-using MonoDevelop.Refactoring;
+using System.Reflection;
using System.Threading;
-using MonoDevelop.Core;
-using Microsoft.CodeAnalysis.CodeFixes;
-using MonoDevelop.CodeIssues;
using System.Threading.Tasks;
+
+using Gtk;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.Ide;
-using Microsoft.CodeAnalysis.CodeActions;
-using RefactoringEssentials;
using MonoDevelop.AnalysisCore;
-using MonoDevelop.Ide.Editor;
+using MonoDevelop.CodeIssues;
using MonoDevelop.Components;
-using MonoDevelop.Ide.Editor.Extension;
-using System.Collections.Immutable;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis;
-using System.Reflection;
-using MonoDevelop.Ide.Gui;
-using Microsoft.CodeAnalysis.Diagnostics;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Core;
using MonoDevelop.Core.Text;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.Ide.Editor.Extension;
+using MonoDevelop.Refactoring;
+using RefactoringEssentials;
namespace MonoDevelop.CodeActions
{
@@ -57,15 +54,6 @@ namespace MonoDevelop.CodeActions
{
const int menuTimeout = 250;
uint smartTagPopupTimeoutId;
- uint menuCloseTimeoutId;
-
- static CodeActionEditorExtension ()
- {
- var usages = PropertyService.Get<Properties> ("CodeActionUsages", new Properties ());
- foreach (var key in usages.Keys) {
- CodeActionUsages [key] = usages.Get<int> (key);
- }
- }
void CancelSmartTagPopupTimeout ()
{
@@ -76,14 +64,6 @@ namespace MonoDevelop.CodeActions
}
}
- void CancelMenuCloseTimer ()
- {
- if (menuCloseTimeoutId != 0) {
- GLib.Source.Remove (menuCloseTimeoutId);
- menuCloseTimeoutId = 0;
- }
- }
-
void RemoveWidget ()
{
if (currentSmartTag != null) {
@@ -99,9 +79,8 @@ namespace MonoDevelop.CodeActions
public override void Dispose ()
{
- CancelMenuCloseTimer ();
CancelQuickFixTimer ();
- HidePreviewTooltip ();
+ RefactoringPreviewTooltipWindow.HidePreviewTooltip ();
Editor.CaretPositionChanged -= HandleCaretPositionChanged;
Editor.SelectionChanged -= HandleSelectionChanged;
DocumentContext.DocumentParsed -= HandleDocumentDocumentParsed;
@@ -112,29 +91,6 @@ namespace MonoDevelop.CodeActions
base.Dispose ();
}
- static readonly Dictionary<string, int> CodeActionUsages = new Dictionary<string, int> ();
-
- static void ConfirmUsage (string id)
- {
- if (id == null)
- return;
- if (!CodeActionUsages.ContainsKey (id)) {
- CodeActionUsages [id] = 1;
- } else {
- CodeActionUsages [id]++;
- }
- var usages = PropertyService.Get<Properties> ("CodeActionUsages", new Properties ());
- usages.Set (id, CodeActionUsages [id]);
- }
-
- internal static int GetUsage (string id)
- {
- int result;
- if (id == null || !CodeActionUsages.TryGetValue (id, out result))
- return 0;
- return result;
- }
-
public void CancelQuickFixTimer ()
{
quickFixCancellationTokenSource.Cancel ();
@@ -272,79 +228,21 @@ namespace MonoDevelop.CodeActions
}
}
- internal static bool IsAnalysisOrErrorFix (Microsoft.CodeAnalysis.CodeActions.CodeAction act)
- {
- return false;
- }
-
- internal class FixMenuEntry
- {
- public static readonly FixMenuEntry Separator = new FixMenuEntry ("-", null);
- public readonly string Label;
-
- public readonly System.Action Action;
- public Action<Xwt.Rectangle> ShowPreviewTooltip;
-
- public FixMenuEntry (string label, System.Action action)
- {
- this.Label = label;
- this.Action = action;
- }
- }
-
- internal class FixMenuDescriptor : FixMenuEntry
- {
- readonly List<FixMenuEntry> items = new List<FixMenuEntry> ();
-
- public IReadOnlyList<FixMenuEntry> Items {
- get {
- return items;
- }
- }
-
- public FixMenuDescriptor () : base (null, null)
- {
- }
-
- public FixMenuDescriptor (string label) : base (label, null)
- {
- }
-
- public void Add (FixMenuEntry entry)
- {
- items.Add (entry);
- }
-
- public object MotionNotifyEvent {
- get;
- set;
- }
- }
-
- void PopupQuickFixMenu (Gdk.EventButton evt, Action<FixMenuDescriptor> menuAction)
+ void PopupQuickFixMenu (Gdk.EventButton evt, Action<CodeFixMenu> menuAction)
{
- FixMenuDescriptor menu = new FixMenuDescriptor ();
- var fixMenu = menu;
- //ResolveResult resolveResult;
- //ICSharpCode.NRefactory.CSharp.AstNode node;
- int items = 0;
-
- // if (AddPossibleNamespace != null) {
- // AddPossibleNamespace (Editor, DocumentContext, menu);
- // items = menu.Items.Count;
- // }
-
- PopulateFixes (fixMenu, ref items);
+ //TODO: async
+ var menu = CodeFixMenuService.CreateFixMenu (Editor, GetCurrentFixes()).Result;
- if (items == 0) {
+ if (menu.Items.Count == 0) {
return;
}
+
Editor.SuppressTooltips = true;
if (menuAction != null)
menuAction (menu);
var p = Editor.LocationToPoint (Editor.OffsetToLocation (currentSmartTagBegin));
- Gtk.Widget widget = Editor;
+ Widget widget = Editor;
var rect = new Gdk.Rectangle (
(int)p.X + widget.Allocation.X,
(int)p.Y + widget.Allocation.Y, 0, 0);
@@ -352,7 +250,7 @@ namespace MonoDevelop.CodeActions
ShowFixesMenu (widget, rect, menu);
}
- bool ShowFixesMenu (Gtk.Widget parent, Gdk.Rectangle evt, FixMenuDescriptor entrySet)
+ bool ShowFixesMenu (Widget parent, Gdk.Rectangle evt, CodeFixMenu entrySet)
{
if (parent == null || parent.GdkWindow == null) {
Editor.SuppressTooltips = false;
@@ -362,443 +260,57 @@ namespace MonoDevelop.CodeActions
try {
parent.GrabFocus ();
int x, y;
- x = (int)evt.X;
- y = (int)evt.Y;
+ x = evt.X;
+ y = evt.Y;
// Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event
- Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime);
+ Gdk.Pointer.Ungrab (Global.CurrentEventTime);
var menu = CreateContextMenu (entrySet);
- HidePreviewTooltip ();
- menu.Show (parent, x, y, () => { Editor.SuppressTooltips = false; HidePreviewTooltip ();}, true);
+ RefactoringPreviewTooltipWindow.HidePreviewTooltip ();
+ menu.Show (parent, x, y, () => {
+ Editor.SuppressTooltips = false;
+ RefactoringPreviewTooltipWindow.HidePreviewTooltip ();
+ }, true);
} catch (Exception ex) {
LoggingService.LogError ("Error while context menu popup.", ex);
}
return true;
}
- ContextMenu CreateContextMenu (FixMenuDescriptor entrySet)
+ ContextMenu CreateContextMenu (CodeFixMenu entrySet)
{
var menu = new ContextMenu ();
foreach (var item in entrySet.Items) {
- if (item == FixMenuEntry.Separator) {
+ if (item == CodeFixMenuEntry.Separator) {
menu.Items.Add (new SeparatorContextMenuItem ());
continue;
}
var menuItem = new ContextMenuItem (item.Label);
menuItem.Context = item.Action;
- var subMenu = item as FixMenuDescriptor;
+ var subMenu = item as CodeFixMenu;
if (subMenu != null) {
menuItem.SubMenu = CreateContextMenu (subMenu);
- menuItem.Selected += delegate (object sender, Xwt.Rectangle e) {
- HidePreviewTooltip ();
+ menuItem.Selected += delegate {
+ RefactoringPreviewTooltipWindow.HidePreviewTooltip ();
};
- menuItem.Deselected += delegate { HidePreviewTooltip (); };
+ menuItem.Deselected += delegate { RefactoringPreviewTooltipWindow.HidePreviewTooltip (); };
} else {
- menuItem.Clicked += (object sender, ContextMenuItemClickedEventArgs e) => ((System.Action)((ContextMenuItem)sender).Context) ();
- menuItem.Selected += delegate (object sender, Xwt.Rectangle e) {
- HidePreviewTooltip ();
+ menuItem.Clicked += (sender, e) => ((System.Action)((ContextMenuItem)sender).Context) ();
+ menuItem.Selected += (sender, e) => {
+ RefactoringPreviewTooltipWindow.HidePreviewTooltip ();
if (item.ShowPreviewTooltip != null) {
item.ShowPreviewTooltip (e);
}
};
- menuItem.Deselected += delegate { HidePreviewTooltip (); };
+ menuItem.Deselected += delegate { RefactoringPreviewTooltipWindow.HidePreviewTooltip (); };
}
menu.Items.Add (menuItem);
}
- menu.Closed += delegate { HidePreviewTooltip (); };
+ menu.Closed += delegate { RefactoringPreviewTooltipWindow.HidePreviewTooltip (); };
return menu;
}
- void HidePreviewTooltip ()
- {
- if (currentPreviewWindow != null) {
- currentPreviewWindow.Destroy ();
- currentPreviewWindow = null;
- }
- }
-
- static string CreateLabel (string title, ref int mnemonic)
- {
- var escapedLabel = title.Replace ("_", "__");
-#if MAC
- return escapedLabel;
-#else
- return (mnemonic <= 10) ? "_" + mnemonic++ % 10 + " \u2013 " + escapedLabel : " " + escapedLabel;
-#endif
- }
-
- internal class FixAllDiagnosticProvider : FixAllContext.DiagnosticProvider
- {
- private readonly ImmutableHashSet<string> _diagnosticIds;
-
- /// <summary>
- /// Delegate to fetch diagnostics for any given document within the given fix all scope.
- /// This delegate is invoked by <see cref="GetDocumentDiagnosticsAsync(Document, CancellationToken)"/> with the given <see cref="_diagnosticIds"/> as arguments.
- /// </summary>
- private readonly Func<Microsoft.CodeAnalysis.Document, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> _getDocumentDiagnosticsAsync;
-
- /// <summary>
- /// Delegate to fetch diagnostics for any given project within the given fix all scope.
- /// This delegate is invoked by <see cref="GetProjectDiagnosticsAsync(Project, CancellationToken)"/> and <see cref="GetAllDiagnosticsAsync(Project, CancellationToken)"/>
- /// with the given <see cref="_diagnosticIds"/> as arguments.
- /// The boolean argument to the delegate indicates whether or not to return location-based diagnostics, i.e.
- /// (a) False => Return only diagnostics with <see cref="Location.None"/>.
- /// (b) True => Return all project diagnostics, regardless of whether or not they have a location.
- /// </summary>
- private readonly Func<Project, bool, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> _getProjectDiagnosticsAsync;
-
- public FixAllDiagnosticProvider (
- ImmutableHashSet<string> diagnosticIds,
- Func<Microsoft.CodeAnalysis.Document, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> getDocumentDiagnosticsAsync,
- Func<Project, bool, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> getProjectDiagnosticsAsync)
- {
- _diagnosticIds = diagnosticIds;
- _getDocumentDiagnosticsAsync = getDocumentDiagnosticsAsync;
- _getProjectDiagnosticsAsync = getProjectDiagnosticsAsync;
- }
-
- public override Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync (Microsoft.CodeAnalysis.Document document, CancellationToken cancellationToken)
- {
- return _getDocumentDiagnosticsAsync (document, _diagnosticIds, cancellationToken);
- }
-
- public override Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync (Project project, CancellationToken cancellationToken)
- {
- return _getProjectDiagnosticsAsync (project, true, _diagnosticIds, cancellationToken);
- }
-
- public override Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync (Project project, CancellationToken cancellationToken)
- {
- return _getProjectDiagnosticsAsync (project, false, _diagnosticIds, cancellationToken);
- }
- }
-
- static RefactoringPreviewTooltipWindow currentPreviewWindow;
-
- void PopulateFixes (FixMenuDescriptor menu, ref int items)
- {
- int mnemonic = 1;
- bool gotImportantFix = false, addedSeparator = false;
- foreach (var fix_ in GetCurrentFixes ().CodeFixActions.OrderByDescending (i => Tuple.Create (IsAnalysisOrErrorFix (i.CodeAction), (int)0, GetUsage (i.CodeAction.EquivalenceKey)))) {
- // filter out code actions that are already resolutions of a code issue
- if (IsAnalysisOrErrorFix (fix_.CodeAction))
- gotImportantFix = true;
- if (!addedSeparator && gotImportantFix && !IsAnalysisOrErrorFix (fix_.CodeAction)) {
- menu.Add (FixMenuEntry.Separator);
- addedSeparator = true;
- }
-
- var fix = fix_;
- var label = CreateLabel (fix.CodeAction.Title, ref mnemonic);
- var thisInstanceMenuItem = new FixMenuEntry (label,async delegate {
- await new ContextActionRunner (fix.CodeAction, Editor, DocumentContext).Run ();
- ConfirmUsage (fix.CodeAction.EquivalenceKey);
- });
-
- thisInstanceMenuItem.ShowPreviewTooltip = delegate (Xwt.Rectangle rect) {
- HidePreviewTooltip ();
- currentPreviewWindow = new RefactoringPreviewTooltipWindow (this.Editor, this.DocumentContext, fix.CodeAction);
- currentPreviewWindow.RequestPopup (rect);
- };
-
- menu.Add (thisInstanceMenuItem);
- items++;
- }
-
- bool first = true;
- foreach (var fix in GetCurrentFixes ().CodeRefactoringActions) {
- if (first) {
- if (items > 0)
- menu.Add (FixMenuEntry.Separator);
- first = false;
- }
-
- var label = CreateLabel (fix.CodeAction.Title, ref mnemonic);
- var thisInstanceMenuItem = new FixMenuEntry (label, async delegate {
- await new ContextActionRunner (fix.CodeAction, Editor, DocumentContext).Run ();
- ConfirmUsage (fix.CodeAction.EquivalenceKey);
- });
-
- thisInstanceMenuItem.ShowPreviewTooltip = delegate (Xwt.Rectangle rect) {
- HidePreviewTooltip ();
- currentPreviewWindow = new RefactoringPreviewTooltipWindow (this.Editor, this.DocumentContext, fix.CodeAction);
- currentPreviewWindow.RequestPopup (rect);
- };
-
- menu.Add (thisInstanceMenuItem);
- items++;
- }
-
- first = false;
-
- var warningsAtCaret = (DocumentContext.AnalysisDocument.GetSemanticModelAsync ().Result)
- .GetDiagnostics (new TextSpan (Editor.CaretOffset, 0))
- .Where (diag => diag.Severity == DiagnosticSeverity.Warning).ToList ();
-
- foreach (var warning in warningsAtCaret) {
- var label = GettextCatalog.GetString ("_Options for \u2018{0}\u2019", warning.Descriptor.Title);
- var subMenu = new FixMenuDescriptor (label);
- if (first) {
- menu.Add (FixMenuEntry.Separator);
- first = false;
- }
- var menuItem = new FixMenuEntry (GettextCatalog.GetString ("_Suppress with #pragma"),
- async delegate {
- var fixes = await CSharpSuppressionFixProvider.Instance.GetSuppressionsAsync (DocumentContext.AnalysisDocument, new TextSpan (Editor.CaretOffset, 0), new [] { warning }, default (CancellationToken)).ConfigureAwait (false);
- foreach (var f in fixes) {
- CodeDiagnosticDescriptor.RunAction (DocumentContext, f.Action, default (CancellationToken));
- }
- }
- );
- menuItem.ShowPreviewTooltip = async delegate (Xwt.Rectangle rect) {
- var fixes = await CSharpSuppressionFixProvider.Instance.GetSuppressionsAsync (DocumentContext.AnalysisDocument, new TextSpan (Editor.CaretOffset, 0), new [] { warning }, default (CancellationToken)).ConfigureAwait (false);
- HidePreviewTooltip ();
- var fix = fixes.FirstOrDefault ();
- if (fix == null)
- return;
- currentPreviewWindow = new RefactoringPreviewTooltipWindow (this.Editor, this.DocumentContext, fix.Action);
- currentPreviewWindow.RequestPopup (rect);
- };
-
- subMenu.Add (menuItem);
- menu.Add (subMenu);
- items++;
- }
-
- foreach (var fix_ in GetCurrentFixes ().DiagnosticsAtCaret) {
- var fix = fix_;
- var label = GettextCatalog.GetString ("_Options for \u2018{0}\u2019", fix.GetMessage ());
- var subMenu = new FixMenuDescriptor (label);
-
- CodeDiagnosticDescriptor descriptor = BuiltInCodeDiagnosticProvider.GetCodeDiagnosticDescriptor (fix.Id);
- if (descriptor == null)
- continue;
- if (first) {
- menu.Add (FixMenuEntry.Separator);
- first = false;
- }
- // if (inspector.CanSuppressWithAttribute) {
- // var menuItem = new FixMenuEntry (GettextCatalog.GetString ("_Suppress with attribute"),
- // delegate {
- //
- // inspector.SuppressWithAttribute (Editor, DocumentContext, GetTextSpan (fix.Item2));
- // });
- // subMenu.Add (menuItem);
- // }
-
- if (descriptor.CanDisableWithPragma) {
- var menuItem = new FixMenuEntry (GettextCatalog.GetString ("_Suppress with #pragma"),
- delegate {
- descriptor.DisableWithPragma (Editor, DocumentContext, fix);
- });
- menuItem.ShowPreviewTooltip = async delegate (Xwt.Rectangle rect) {
- var fixes = await CSharpSuppressionFixProvider.Instance.GetSuppressionsAsync (DocumentContext.AnalysisDocument, new TextSpan (Editor.CaretOffset, 0), new [] { fix }, default (CancellationToken)).ConfigureAwait (false);
- HidePreviewTooltip ();
- var fix2 = fixes.FirstOrDefault ();
- if (fix2 == null)
- return;
- currentPreviewWindow = new RefactoringPreviewTooltipWindow (this.Editor, this.DocumentContext, fix2.Action);
- currentPreviewWindow.RequestPopup (rect);
- };
- subMenu.Add (menuItem);
- menuItem = new FixMenuEntry (GettextCatalog.GetString ("_Suppress with file"),
- delegate {
- descriptor.DisableWithFile (Editor, DocumentContext, fix);
- });
- subMenu.Add (menuItem);
- }
- var optionsMenuItem = new FixMenuEntry (GettextCatalog.GetString ("_Configure Rule"),
- delegate {
- IdeApp.Workbench.ShowGlobalPreferencesDialog (null, "C#", dialog => {
- var panel = dialog.GetPanel<CodeIssuePanel> ("C#");
- if (panel == null)
- return;
- panel.Widget.SelectCodeIssue (descriptor.IdString);
- });
- });
- subMenu.Add (optionsMenuItem);
-
-
- foreach (var fix2 in GetCurrentFixes ().CodeFixActions.OrderByDescending (i => Tuple.Create (IsAnalysisOrErrorFix (i.CodeAction), (int)0, GetUsage (i.CodeAction.EquivalenceKey)))) {
-
- var provider = fix2.Diagnostic.GetCodeFixProvider ().GetFixAllProvider ();
- if (provider == null)
- continue;
- if (!provider.GetSupportedFixAllScopes ().Contains (FixAllScope.Document))
- continue;
- var subMenu2 = new FixMenuDescriptor (GettextCatalog.GetString ("Fix all"));
- var diagnosticAnalyzer = fix2.Diagnostic.GetCodeDiagnosticDescriptor (LanguageNames.CSharp).GetProvider ();
- if (!diagnosticAnalyzer.SupportedDiagnostics.Contains (fix.Descriptor))
- continue;
-
- var menuItem = new FixMenuEntry (
- GettextCatalog.GetString ("In _Document"),
- async delegate {
- var fixAllDiagnosticProvider = new FixAllDiagnosticProvider (diagnosticAnalyzer.SupportedDiagnostics.Select (d => d.Id).ToImmutableHashSet (), async (Microsoft.CodeAnalysis.Document doc, ImmutableHashSet<string> diagnostics, CancellationToken token) => {
-
- var model = await doc.GetSemanticModelAsync (token);
- var compilationWithAnalyzer = model.Compilation.WithAnalyzers (new [] { diagnosticAnalyzer }.ToImmutableArray (), null, token);
-
- return await compilationWithAnalyzer.GetAnalyzerSemanticDiagnosticsAsync (model, null, token);
- }, (Project arg1, bool arg2, ImmutableHashSet<string> arg3, CancellationToken arg4) => {
- return Task.FromResult ((IEnumerable<Diagnostic>)new Diagnostic [] { });
- });
- var ctx = new FixAllContext (
- this.DocumentContext.AnalysisDocument,
- fix2.Diagnostic.GetCodeFixProvider (),
- FixAllScope.Document,
- fix2.CodeAction.EquivalenceKey,
- diagnosticAnalyzer.SupportedDiagnostics.Select (d => d.Id),
- fixAllDiagnosticProvider,
- default (CancellationToken)
- );
- var fixAll = await provider.GetFixAsync (ctx);
- using (var undo = Editor.OpenUndoGroup ()) {
- CodeDiagnosticDescriptor.RunAction (DocumentContext, fixAll, default (CancellationToken));
- }
- });
- subMenu2.Add (menuItem);
- subMenu.Add (FixMenuEntry.Separator);
- subMenu.Add (subMenu2);
- }
-
- menu.Add (subMenu);
- items++;
- }
- }
-
- internal class ContextActionRunner
- {
- readonly CodeAction act;
- TextEditor editor;
- DocumentContext documentContext;
-
- public ContextActionRunner (CodeAction act, TextEditor editor, DocumentContext documentContext)
- {
- this.editor = editor;
- this.act = act;
- this.documentContext = documentContext;
- }
-
- public async Task Run ()
- {
- var token = default (CancellationToken);
- var insertionAction = act as InsertionAction;
- if (insertionAction != null) {
- var insertion = await insertionAction.CreateInsertion (token).ConfigureAwait (false);
-
- var document = await IdeApp.Workbench.OpenDocument (insertion.Location.SourceTree.FilePath, documentContext.Project);
- var parsedDocument = await document.UpdateParseDocument ();
- if (parsedDocument != null) {
- var insertionPoints = InsertionPointService.GetInsertionPoints (
- document.Editor,
- parsedDocument,
- insertion.Type,
- insertion.Location.SourceSpan.Start
- );
-
- var options = new InsertionModeOptions (
- insertionAction.Title,
- insertionPoints,
- point => {
- if (!point.Success)
- return;
- var node = Formatter.Format (insertion.Node, TypeSystemService.Workspace, document.GetOptionSet (), token);
- point.InsertionPoint.Insert (document.Editor, document, node.ToString ());
- // document = await Simplifier.ReduceAsync(document.AnalysisDocument, Simplifier.Annotation, cancellationToken: token).ConfigureAwait(false);
- }
- );
-
- document.Editor.StartInsertionMode (options);
- return;
- }
- }
-
- var oldSolution = documentContext.AnalysisDocument.Project.Solution;
- var updatedSolution = oldSolution;
- if (RefactoringService.OptionSetCreation != null)
- documentContext.RoslynWorkspace.Options = RefactoringService.OptionSetCreation (editor, documentContext);
- using (var undo = editor.OpenUndoGroup ()) {
- foreach (var operation in await act.GetOperationsAsync (token)) {
- var applyChanges = operation as ApplyChangesOperation;
- if (applyChanges == null) {
- operation.Apply (documentContext.RoslynWorkspace, token);
- continue;
- }
- if (updatedSolution == oldSolution) {
- updatedSolution = applyChanges.ChangedSolution;
- }
- operation.Apply (documentContext.RoslynWorkspace, token);
- }
- }
- await TryStartRenameSession (documentContext.RoslynWorkspace, oldSolution, updatedSolution, token);
- }
-
- static IEnumerable<DocumentId> GetChangedDocuments (Solution newSolution, Solution oldSolution)
- {
- if (newSolution != null) {
- var solutionChanges = newSolution.GetChanges (oldSolution);
- foreach (var projectChanges in solutionChanges.GetProjectChanges ()) {
- foreach (var documentId in projectChanges.GetChangedDocuments ()) {
- yield return documentId;
- }
- }
- }
- }
-
- async Task TryStartRenameSession (Workspace workspace, Solution oldSolution, Solution newSolution, CancellationToken cancellationToken)
- {
- var changedDocuments = GetChangedDocuments (newSolution, oldSolution);
- foreach (var documentId in changedDocuments) {
- var document = newSolution.GetDocument (documentId);
- var root = await document.GetSyntaxRootAsync (cancellationToken).ConfigureAwait (false);
- SyntaxToken? renameTokenOpt = root.GetAnnotatedNodesAndTokens (RenameAnnotation.Kind)
- .Where (s => s.IsToken)
- .Select (s => s.AsToken ())
- .Cast<SyntaxToken?> ()
- .FirstOrDefault ();
- if (renameTokenOpt.HasValue) {
- var latestDocument = workspace.CurrentSolution.GetDocument (documentId);
- var latestModel = await latestDocument.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
- var latestRoot = await latestDocument.GetSyntaxRootAsync (cancellationToken).ConfigureAwait (false);
- await Runtime.RunInMainThread (async delegate {
- try {
- var node = latestRoot.FindNode (renameTokenOpt.Value.Parent.Span, false, false);
- if (node == null)
- return;
- var info = latestModel.GetSymbolInfo (node);
- var sym = info.Symbol ?? latestModel.GetDeclaredSymbol (node);
- if (sym != null) {
- await new MonoDevelop.Refactoring.Rename.RenameRefactoring ().Rename (sym);
- } else {
- var links = new List<TextLink> ();
- var link = new TextLink ("name");
- link.AddLink (new TextSegment (node.Span.Start, node.Span.Length));
- links.Add (link);
- var oldVersion = editor.Version;
- editor.StartTextLinkMode (new TextLinkModeOptions (links, (arg) => {
- //If user cancel renaming revert changes
- if (!arg.Success) {
- var textChanges = editor.Version.GetChangesTo (oldVersion).ToList ();
- foreach (var change in textChanges) {
- foreach (var v in change.TextChanges.Reverse ()) {
- editor.ReplaceText (v.Offset, v.RemovalLength, v.InsertedText);
- }
- }
- }
- }) { TextLinkPurpose = TextLinkPurpose.Rename });
- }
- } catch (Exception ex) {
- LoggingService.LogError ("Error while renaming " + renameTokenOpt.Value.Parent, ex);
- }
- });
- return;
- }
- }
- }
- }
-
ISmartTagMarker currentSmartTag;
int currentSmartTagBegin;
@@ -818,11 +330,6 @@ namespace MonoDevelop.CodeActions
return;
}
- // var container = editor.Parent;
- // if (container == null) {
- // RemoveWidget ();
- // return;
- // }
bool first = true;
var smartTagLocBegin = offset;
foreach (var fix in fixes.CodeFixActions.Concat (fixes.CodeRefactoringActions)) {
@@ -834,19 +341,6 @@ namespace MonoDevelop.CodeActions
}
first = false;
}
- // if (smartTagLocBegin.Line != loc.Line)
- // smartTagLocBegin = new DocumentLocation (loc.Line, 1);
- // got no fix location -> try to search word start
- // if (first) {
- // int offset = document.Editor.LocationToOffset (smartTagLocBegin);
- // while (offset > 0) {
- // char ch = document.Editor.GetCharAt (offset - 1);
- // if (!char.IsLetterOrDigit (ch) && ch != '_')
- // break;
- // offset--;
- // }
- // smartTagLocBegin = document.Editor.OffsetToLocation (offset);
- // }
if (currentSmartTag != null && currentSmartTagBegin == smartTagLocBegin) {
return;
@@ -901,20 +395,6 @@ namespace MonoDevelop.CodeActions
void HandleBeginHover (object sender, EventArgs e)
{
CancelSmartTagPopupTimeout ();
- CancelMenuCloseTimer ();
- }
-
- void StartMenuCloseTimer ()
- {
- CancelMenuCloseTimer ();
- menuCloseTimeoutId = GLib.Timeout.Add (menuTimeout, delegate {
- /*if (codeActionMenu != null) {
- codeActionMenu.Destroy ();
- codeActionMenu = null;
- }*/
- menuCloseTimeoutId = 0;
- return false;
- });
}
void HandleSelectionChanged (object sender, EventArgs e)
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeFixMenuService.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeFixMenuService.cs
new file mode 100644
index 0000000000..cb573fada1
--- /dev/null
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeFixMenuService.cs
@@ -0,0 +1,510 @@
+//
+// CodeFixMenu.cs
+//
+// Author:
+// Mikayla Hutchinson <m.j.hutchinson@gmail.com>
+//
+// Copyright (c) 2017 Microsoft Corp.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Globalization;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CodeActions;
+using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.CodeFixes.Suppression;
+using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Formatting;
+using Microsoft.CodeAnalysis.Text;
+using Microsoft.CodeAnalysis.Host.Mef;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+using MonoDevelop.CodeIssues;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Text;
+using MonoDevelop.Ide;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.Refactoring;
+using RefactoringEssentials;
+
+namespace MonoDevelop.CodeActions
+{
+ internal static class CodeFixMenuService
+ {
+ static readonly Dictionary<string, int> CodeActionUsages = new Dictionary<string, int> ();
+
+ static CodeFixMenuService ()
+ {
+ var usages = PropertyService.Get ("CodeActionUsages", new Properties ());
+ foreach (var key in usages.Keys) {
+ CodeActionUsages [key] = usages.Get<int> (key);
+ }
+ }
+
+ static void ConfirmUsage (string id)
+ {
+ if (id == null)
+ return;
+ if (!CodeActionUsages.ContainsKey (id)) {
+ CodeActionUsages [id] = 1;
+ } else {
+ CodeActionUsages [id]++;
+ }
+ var usages = PropertyService.Get ("CodeActionUsages", new Properties ());
+ usages.Set (id, CodeActionUsages [id]);
+ }
+
+ public static async Task<CodeFixMenu> CreateFixMenu (TextEditor editor, CodeActionContainer fixes)
+ {
+ var menu = new CodeFixMenu ();
+
+ int mnemonic = 1;
+ bool addedSeparator = false;
+
+ foreach (var fix in fixes.CodeFixActions.OrderByDescending (i => GetUsage (i.CodeAction.EquivalenceKey))) {
+ if (!addedSeparator) {
+ menu.Add (CodeFixMenuEntry.Separator);
+ addedSeparator = true;
+ }
+
+ AddFixMenuItem (editor, menu, ref mnemonic, fix.CodeAction);
+ }
+
+ bool first = true;
+ foreach (var fix in fixes.CodeRefactoringActions) {
+ if (first) {
+ if (menu.Items.Count > 0)
+ menu.Add (CodeFixMenuEntry.Separator);
+ first = false;
+ }
+
+ AddFixMenuItem (editor, menu, ref mnemonic, fix.CodeAction);
+ }
+
+ first = false;
+
+ var warningsAtCaret = (editor.DocumentContext.AnalysisDocument.GetSemanticModelAsync ().Result)
+ .GetDiagnostics (new TextSpan (editor.CaretOffset, 0))
+ .Where (diag => diag.Severity == DiagnosticSeverity.Warning).ToList ();
+
+ var caretSpan = new TextSpan (editor.CaretOffset, 0);
+
+ foreach (var warning in warningsAtCaret) {
+
+ var label = GettextCatalog.GetString ("_Options for \u2018{0}\u2019", warning.Descriptor.Title);
+ var subMenu = new CodeFixMenu (label);
+
+ await AddSuppressionMenuItems (subMenu, editor, warning, caretSpan);
+
+ if (subMenu.Items.Count > 0) {
+
+ if (first) {
+ menu.Add (CodeFixMenuEntry.Separator);
+ first = false;
+ }
+
+ menu.Add (subMenu);
+ }
+ }
+
+ foreach (var diag in fixes.DiagnosticsAtCaret) {
+ var notConfigurable = DescriptorHasTag (diag.Descriptor, WellKnownDiagnosticTags.NotConfigurable);
+
+ var label = GettextCatalog.GetString ("_Options for \u2018{0}\u2019", diag.Descriptor.Title);
+ var subMenu = new CodeFixMenu (label);
+
+ if (first) {
+ menu.Add (CodeFixMenuEntry.Separator);
+ first = false;
+ }
+
+ await AddSuppressionMenuItems (subMenu, editor, diag, caretSpan);
+
+ var descriptor = BuiltInCodeDiagnosticProvider.GetCodeDiagnosticDescriptor (diag.Id);
+
+ if (descriptor != null && IsConfigurable (diag.Descriptor)) {
+ var optionsMenuItem = new CodeFixMenuEntry (GettextCatalog.GetString ("_Configure Rule"),
+ delegate {
+ IdeApp.Workbench.ShowGlobalPreferencesDialog (null, "C#", dialog => {
+ var panel = dialog.GetPanel<CodeIssuePanel> ("C#");
+ if (panel == null)
+ return;
+ panel.Widget.SelectCodeIssue (diag.Descriptor.Id);
+ });
+ });
+ subMenu.Add (optionsMenuItem);
+ }
+
+ foreach (var fix in fixes.CodeFixActions.OrderByDescending (i => GetUsage (i.CodeAction.EquivalenceKey))) {
+
+ var provider = fix.Diagnostic.GetCodeFixProvider ().GetFixAllProvider ();
+ if (provider == null)
+ continue;
+
+ if (!provider.GetSupportedFixAllScopes ().Contains (FixAllScope.Document))
+ continue;
+
+ var subMenu2 = new CodeFixMenu (GettextCatalog.GetString ("Fix all"));
+
+ var language = editor.DocumentContext.AnalysisDocument.Project.Language;
+
+ var diagnosticAnalyzer = fix.Diagnostic.GetCodeDiagnosticDescriptor (language).GetProvider ();
+ if (!diagnosticAnalyzer.SupportedDiagnostics.Contains (diag.Descriptor))
+ continue;
+
+ var menuItem = new CodeFixMenuEntry (
+ GettextCatalog.GetString ("In _Document"),
+ async delegate { await FixAll (editor, fix, provider, diagnosticAnalyzer); }
+ );
+ subMenu2.Add (menuItem);
+ subMenu.Add (CodeFixMenuEntry.Separator);
+ subMenu.Add (subMenu2);
+ }
+
+ menu.Add (subMenu);
+ }
+ return menu;
+ }
+
+ static async Task FixAll (TextEditor editor, ValidCodeDiagnosticAction fix, FixAllProvider provider, DiagnosticAnalyzer diagnosticAnalyzer)
+ {
+ var diagnosticIds = diagnosticAnalyzer.SupportedDiagnostics.Select (d => d.Id).ToImmutableHashSet ();
+
+ var analyzers = new [] { diagnosticAnalyzer }.ToImmutableArray ();
+
+ var fixAllDiagnosticProvider = new FixAllState.FixAllDiagnosticProvider (
+ diagnosticIds,
+ async (doc, diagnostics, token) => await GetDiagnosticsForDocument (analyzers, doc, diagnostics, token).ConfigureAwait (false),
+ (Project arg1, bool arg2, ImmutableHashSet<string> arg3, CancellationToken arg4) => {
+ return Task.FromResult ((IEnumerable<Diagnostic>)new Diagnostic [] { });
+ });
+
+ var ctx = new FixAllContext (
+ editor.DocumentContext.AnalysisDocument,
+ fix.Diagnostic.GetCodeFixProvider (),
+ FixAllScope.Document,
+ fix.CodeAction.EquivalenceKey,
+ diagnosticIds,
+ fixAllDiagnosticProvider,
+ default (CancellationToken)
+ );
+
+ var fixAll = await provider.GetFixAsync (ctx);
+ using (var undo = editor.OpenUndoGroup ()) {
+ await CodeDiagnosticDescriptor.RunAction (editor.DocumentContext, fixAll, default (CancellationToken));
+ }
+ }
+
+ static async Task<ImmutableArray<Diagnostic>> GetDiagnosticsForDocument (ImmutableArray<DiagnosticAnalyzer> analyzers, Microsoft.CodeAnalysis.Document doc, ImmutableHashSet<string> diagnostics, CancellationToken token)
+ {
+ var options = new CompilationWithAnalyzersOptions (
+ new WorkspaceAnalyzerOptions (
+ new AnalyzerOptions (ImmutableArray<AdditionalText>.Empty),
+ doc.Project.Solution.Workspace),
+ delegate (Exception exception, DiagnosticAnalyzer analyzer, Diagnostic diag) {
+ LoggingService.LogError ("Exception in diagnostic analyzer " + diag.Id + ":" + diag.GetMessage (), exception);
+ },
+ true,
+ false
+ );
+
+ var model = await doc.GetSemanticModelAsync (token).ConfigureAwait (false);
+ var compilationWithAnalyzer = model.Compilation.WithAnalyzers (analyzers, options);
+
+ var diagnosticList = new List<Diagnostic> ();
+ diagnosticList.AddRange (await compilationWithAnalyzer.GetAnalyzerSemanticDiagnosticsAsync (model, null, token).ConfigureAwait (false));
+ diagnosticList.AddRange (await compilationWithAnalyzer.GetAnalyzerSemanticDiagnosticsAsync (model, null, token).ConfigureAwait (false));
+
+ return diagnosticList.ToImmutableArray ();
+ }
+
+ static async Task AddSuppressionMenuItems (CodeFixMenu menu, TextEditor editor, Diagnostic diag, TextSpan span)
+ {
+ var workspace = editor.DocumentContext.AnalysisDocument.Project.Solution.Workspace;
+ var language = editor.DocumentContext.AnalysisDocument.Project.Language;
+ var mefExporter = (IMefHostExportProvider)workspace.Services.HostServices;
+
+ //TODO: cache this
+ var suppressionProviders = mefExporter.GetExports<ISuppressionFixProvider, CodeChangeProviderMetadata> ()
+ .ToPerLanguageMapWithMultipleLanguages();
+
+ foreach (var suppressionProvider in suppressionProviders[LanguageNames.CSharp].Select (lz => lz.Value)) {
+ if (!suppressionProvider.CanBeSuppressedOrUnsuppressed (diag)) {
+ continue;
+ }
+
+ var fixes = await suppressionProvider.GetSuppressionsAsync (editor.DocumentContext.AnalysisDocument, span, new [] { diag }, default (CancellationToken)).ConfigureAwait (false);
+ foreach (var fix in fixes) {
+ AddFixMenuItem (editor, menu, fix.Action);
+ }
+ }
+ }
+
+ static bool DescriptorHasTag (DiagnosticDescriptor desc, string tag)
+ {
+ return desc.CustomTags.Any (c => CultureInfo.InvariantCulture.CompareInfo.Compare (c, tag) == 0);
+ }
+
+ static bool IsConfigurable (DiagnosticDescriptor desc)
+ {
+ return !DescriptorHasTag (desc, WellKnownDiagnosticTags.NotConfigurable);
+ }
+
+ static CodeFixMenuEntry CreateFixMenuEntry (TextEditor editor, CodeAction fix)
+ {
+ int mnemonic = -1;
+ return CreateFixMenuEntry (editor, fix, ref mnemonic);
+ }
+
+ static CodeFixMenuEntry CreateFixMenuEntry (TextEditor editor, CodeAction fix, ref int mnemonic)
+ {
+ var label = mnemonic < 0 ? fix.Title : CreateLabel (fix.Title, ref mnemonic);
+ var item = new CodeFixMenuEntry (label, async delegate {
+ await new ContextActionRunner (editor, fix).Run ();
+ ConfirmUsage (fix.EquivalenceKey);
+ });
+
+ item.ShowPreviewTooltip = delegate (Xwt.Rectangle rect) {
+ RefactoringPreviewTooltipWindow.ShowPreviewTooltip (editor, fix, rect);
+ };
+
+ return item;
+ }
+
+ static void AddFixMenuItem (TextEditor editor, CodeFixMenu menu, CodeAction fix)
+ {
+ int _m = 0;
+ AddFixMenuItem (editor, menu, ref _m, fix);
+ }
+
+ static void AddFixMenuItem (TextEditor editor, CodeFixMenu menu, ref int mnemonic, CodeAction fix)
+ {
+ var nested = fix as CodeAction.CodeActionWithNestedActions;
+ if (nested != null) {
+ AddNestedFixMenu (editor, menu, nested);
+ return;
+ }
+
+ menu.Add (CreateFixMenuEntry (editor, fix, ref mnemonic));
+ }
+
+ static void AddNestedFixMenu (TextEditor editor, CodeFixMenu menu, CodeAction.CodeActionWithNestedActions fixes)
+ {
+ int subMnemonic = 0;
+ var subMenu = new CodeFixMenu (fixes.Title);
+ foreach (var fix in fixes.NestedCodeActions) {
+ AddFixMenuItem (editor, subMenu, ref subMnemonic, fix);
+ }
+ menu.Add (subMenu);
+ }
+
+ static string CreateLabel (string title, ref int mnemonic)
+ {
+ var escapedLabel = title.Replace ("_", "__");
+#if MAC
+ return escapedLabel;
+#else
+ return (mnemonic <= 10) ? "_" + mnemonic++ % 10 + " \u2013 " + escapedLabel : " " + escapedLabel;
+#endif
+ }
+
+ static int GetUsage (string id)
+ {
+ int result;
+ if (id == null || !CodeActionUsages.TryGetValue (id, out result))
+ return 0;
+ return result;
+ }
+
+ internal class ContextActionRunner
+ {
+ readonly CodeAction act;
+ readonly TextEditor editor;
+ DocumentContext documentContext;
+
+ public ContextActionRunner (TextEditor editor, CodeAction act)
+ {
+ this.editor = editor;
+ this.act = act;
+ documentContext = editor.DocumentContext;
+ }
+
+ public async Task Run ()
+ {
+ var token = default (CancellationToken);
+ var insertionAction = act as InsertionAction;
+ if (insertionAction != null) {
+ var insertion = await insertionAction.CreateInsertion (token).ConfigureAwait (false);
+
+ var document = await IdeApp.Workbench.OpenDocument (insertion.Location.SourceTree.FilePath, documentContext.Project);
+ var parsedDocument = await document.UpdateParseDocument ();
+ if (parsedDocument != null) {
+ var insertionPoints = InsertionPointService.GetInsertionPoints (
+ document.Editor,
+ parsedDocument,
+ insertion.Type,
+ insertion.Location.SourceSpan.Start
+ );
+
+ var options = new InsertionModeOptions (
+ insertionAction.Title,
+ insertionPoints,
+ point => {
+ if (!point.Success)
+ return;
+ var node = Formatter.Format (insertion.Node, document.RoslynWorkspace, document.GetOptionSet (), token);
+ point.InsertionPoint.Insert (document.Editor, document, node.ToString ());
+ // document = await Simplifier.ReduceAsync(document.AnalysisDocument, Simplifier.Annotation, cancellationToken: token).ConfigureAwait(false);
+ }
+ );
+
+ document.Editor.StartInsertionMode (options);
+ return;
+ }
+ }
+
+ var oldSolution = documentContext.AnalysisDocument.Project.Solution;
+ var updatedSolution = oldSolution;
+ if (RefactoringService.OptionSetCreation != null)
+ documentContext.RoslynWorkspace.Options = RefactoringService.OptionSetCreation (editor, documentContext);
+ using (var undo = editor.OpenUndoGroup ()) {
+ foreach (var operation in await act.GetOperationsAsync (token)) {
+ var applyChanges = operation as ApplyChangesOperation;
+ if (applyChanges == null) {
+ operation.Apply (documentContext.RoslynWorkspace, token);
+ continue;
+ }
+ if (updatedSolution == oldSolution) {
+ updatedSolution = applyChanges.ChangedSolution;
+ }
+ operation.Apply (documentContext.RoslynWorkspace, token);
+ }
+ }
+ await TryStartRenameSession (documentContext.RoslynWorkspace, oldSolution, updatedSolution, token);
+ }
+
+ static IEnumerable<DocumentId> GetChangedDocuments (Solution newSolution, Solution oldSolution)
+ {
+ if (newSolution != null) {
+ var solutionChanges = newSolution.GetChanges (oldSolution);
+ foreach (var projectChanges in solutionChanges.GetProjectChanges ()) {
+ foreach (var documentId in projectChanges.GetChangedDocuments ()) {
+ yield return documentId;
+ }
+ }
+ }
+ }
+
+ async Task TryStartRenameSession (Workspace workspace, Solution oldSolution, Solution newSolution, CancellationToken cancellationToken)
+ {
+ var changedDocuments = GetChangedDocuments (newSolution, oldSolution);
+ foreach (var documentId in changedDocuments) {
+ var document = newSolution.GetDocument (documentId);
+ var root = await document.GetSyntaxRootAsync (cancellationToken).ConfigureAwait (false);
+ SyntaxToken? renameTokenOpt = root.GetAnnotatedNodesAndTokens (RenameAnnotation.Kind)
+ .Where (s => s.IsToken)
+ .Select (s => s.AsToken ())
+ .Cast<SyntaxToken?> ()
+ .FirstOrDefault ();
+ if (renameTokenOpt.HasValue) {
+ var latestDocument = workspace.CurrentSolution.GetDocument (documentId);
+ var latestModel = await latestDocument.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false);
+ var latestRoot = await latestDocument.GetSyntaxRootAsync (cancellationToken).ConfigureAwait (false);
+ await Runtime.RunInMainThread (async delegate {
+ try {
+ var node = latestRoot.FindNode (renameTokenOpt.Value.Parent.Span, false, false);
+ if (node == null)
+ return;
+ var info = latestModel.GetSymbolInfo (node);
+ var sym = info.Symbol ?? latestModel.GetDeclaredSymbol (node);
+ if (sym != null) {
+ await new Refactoring.Rename.RenameRefactoring ().Rename (sym);
+ } else {
+ var links = new List<TextLink> ();
+ var link = new TextLink ("name");
+ link.AddLink (new TextSegment (node.Span.Start, node.Span.Length));
+ links.Add (link);
+ var oldVersion = editor.Version;
+ editor.StartTextLinkMode (new TextLinkModeOptions (links, (arg) => {
+ //If user cancel renaming revert changes
+ if (!arg.Success) {
+ var textChanges = editor.Version.GetChangesTo (oldVersion).ToList ();
+ foreach (var v in textChanges) {
+ editor.ReplaceText (v.Offset, v.RemovalLength, v.InsertedText);
+ }
+ }
+ }) { TextLinkPurpose = TextLinkPurpose.Rename });
+ }
+ } catch (Exception ex) {
+ LoggingService.LogError ("Error while renaming " + renameTokenOpt.Value.Parent, ex);
+ }
+ });
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ internal class CodeFixMenuEntry
+ {
+ public static readonly CodeFixMenuEntry Separator = new CodeFixMenuEntry ("-", null);
+ public readonly string Label;
+
+ public readonly Action Action;
+ public Action<Xwt.Rectangle> ShowPreviewTooltip;
+
+ public CodeFixMenuEntry (string label, Action action)
+ {
+ Label = label;
+ Action = action;
+ }
+ }
+
+ internal class CodeFixMenu : CodeFixMenuEntry
+ {
+ readonly List<CodeFixMenuEntry> items = new List<CodeFixMenuEntry> ();
+
+ public IReadOnlyList<CodeFixMenuEntry> Items {
+ get {
+ return items;
+ }
+ }
+
+ public CodeFixMenu () : base (null, null)
+ {
+ }
+
+ public CodeFixMenu (string label) : base (label, null)
+ {
+ }
+
+ public void Add (CodeFixMenuEntry entry)
+ {
+ items.Add (entry);
+ }
+
+ public object MotionNotifyEvent { get; set; }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeRefactoringService.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeRefactoringService.cs
index 27a04a9c9c..c738ec0eae 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeRefactoringService.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeRefactoringService.cs
@@ -37,9 +37,7 @@ using MonoDevelop.Ide.Editor;
using MonoDevelop.CodeIssues;
using Mono.Addins;
using RefactoringEssentials;
-using MonoDevelop.Core.Text;
using System.Linq;
-using System.ComponentModel;
namespace MonoDevelop.CodeActions
{
@@ -48,10 +46,10 @@ namespace MonoDevelop.CodeActions
readonly static List<CodeDiagnosticProvider> providers = new List<CodeDiagnosticProvider> ();
static CodeRefactoringService ()
- {
+ {
providers.Add (new BuiltInCodeDiagnosticProvider ());
- AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Refactoring/CodeDiagnosticProvider", delegate(object sender, ExtensionNodeEventArgs args) {
+ AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Refactoring/CodeDiagnosticProvider", delegate (object sender, ExtensionNodeEventArgs args) {
var node = (TypeExtensionNode)args.ExtensionNode;
switch (args.Change) {
case ExtensionChange.Add:
@@ -105,7 +103,7 @@ namespace MonoDevelop.CodeActions
var model = await doc.AnalysisDocument.GetSemanticModelAsync (cancellationToken);
if (model == null)
return actions;
- var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait (false);
+ var root = await model.SyntaxTree.GetRootAsync (cancellationToken).ConfigureAwait (false);
if (span.End > root.Span.End)
return actions;
TextSpan tokenSegment = span;
@@ -114,7 +112,7 @@ namespace MonoDevelop.CodeActions
tokenSegment = token.Span;
try {
if (codeRefactoringCache == null) {
- codeRefactoringCache = (await GetCodeRefactoringsAsync (doc, MimeTypeToLanguage(editor.MimeType), cancellationToken).ConfigureAwait (false)).ToList ();
+ codeRefactoringCache = (await GetCodeRefactoringsAsync (doc, MimeTypeToLanguage (editor.MimeType), cancellationToken).ConfigureAwait (false)).ToList ();
}
foreach (var descriptor in codeRefactoringCache) {
if (!descriptor.IsEnabled)
@@ -139,7 +137,7 @@ namespace MonoDevelop.CodeActions
if (cancellationToken.IsCancellationRequested)
return Enumerable.Empty<ValidCodeAction> ();
} catch (Exception e) {
- LoggingService.LogError ("Error while getting refactorings from " + descriptor.IdString, e);
+ LoggingService.LogError ("Error while getting refactorings from " + descriptor.IdString, e);
continue;
}
}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalyzersFromAssembly.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalyzersFromAssembly.cs
index 76d68b034f..8272afd768 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalyzersFromAssembly.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/AnalyzersFromAssembly.cs
@@ -37,6 +37,7 @@ using System.Threading.Tasks;
using MonoDevelop.Ide.Editor;
using MonoDevelop.CodeActions;
using Microsoft.CodeAnalysis.CodeRefactorings;
+using Microsoft.CodeAnalysis;
namespace MonoDevelop.CodeIssues
{
@@ -65,29 +66,58 @@ namespace MonoDevelop.CodeIssues
internal void AddAssembly (System.Reflection.Assembly asm, bool force = false)
{
+ //FIXME; this is a really hacky arbitrary heuristic
+ //we should be using proper MEF composition APIs as part of the addin scan
if (!force) {
var assemblyName = asm.GetName ().Name;
- if (assemblyName == "MonoDevelop.AspNet" ||
- assemblyName == "Microsoft.CodeAnalysis.CSharp" ||
- assemblyName.Contains ("FSharpBinding") ||
- assemblyName != "RefactoringEssentials" &&
- !(asm.GetReferencedAssemblies ().Any (a => a.Name == diagnosticAnalyzerAssembly) && asm.GetReferencedAssemblies ().Any (a => a.Name == "MonoDevelop.Ide")))
+ switch (assemblyName) {
+ //whitelist
+ case "RefactoringEssentials":
+ case "Refactoring Essentials":
+ case "Microsoft.CodeAnalysis.Features":
+ case "Microsoft.CodeAnalysis.VisualBasic.Features":
+ case "Microsoft.CodeAnalysis.CSharp.Features":
+ break;
+ //blacklist
+ case "FSharpBinding":
return;
+ //addin assemblies that reference roslyn
+ default:
+ var refAsm = asm.GetReferencedAssemblies ();
+ if (refAsm.Any (a => a.Name == diagnosticAnalyzerAssembly) && refAsm.Any (a => a.Name == "MonoDevelop.Ide"))
+ break;
+ return;
+ }
}
+
foreach (var type in asm.GetTypes ()) {
var notPortedYetAttribute = (NotPortedYetAttribute)type.GetCustomAttributes (typeof(NotPortedYetAttribute), false).FirstOrDefault ();
if (notPortedYetAttribute!= null) {
continue;
}
+
+ //HACK: Workaround missing IChangeSignatureOptionsService and IExtractInterfaceOptionsService services in VSfM
+ //https://bugzilla.xamarin.com/show_bug.cgi?id=53771
+ if (type == typeof (Microsoft.CodeAnalysis.ChangeSignature.ChangeSignatureCodeAction) ||
+ type == typeof (Microsoft.CodeAnalysis.ExtractInterface.ExtractInterfaceCodeAction))
+ continue;
+
var analyzerAttr = (DiagnosticAnalyzerAttribute)type.GetCustomAttributes (typeof(DiagnosticAnalyzerAttribute), false).FirstOrDefault ();
if (analyzerAttr != null) {
- var analyzer = (DiagnosticAnalyzer)Activator.CreateInstance (type);
- foreach (var diag in analyzer.SupportedDiagnostics) {
- try {
- Analyzers.Add (new CodeDiagnosticDescriptor (diag, analyzerAttr.Languages, type));
- } catch (Exception e) {
- LoggingService.LogError ("error while adding diagnostic analyzer: " + diag.Id + " from assembly " + asm.FullName, e);
+ try {
+ var analyzer = (DiagnosticAnalyzer)Activator.CreateInstance (type);
+
+ if (analyzer.SupportedDiagnostics.Any (IsDiagnosticSupported)) {
+ Analyzers.Add (new CodeDiagnosticDescriptor (analyzerAttr.Languages, type));
}
+ foreach (var diag in analyzer.SupportedDiagnostics) {
+ //filter out E&C analyzers as we don't support E&C
+ if (diag.CustomTags.Contains (WellKnownDiagnosticTags.EditAndContinue)) {
+ continue;
+ }
+ }
+ } catch (Exception e) {
+ LoggingService.LogError ($"error while adding diagnostic analyzer {type} from assembly {asm.FullName}", e);
}
}
@@ -105,6 +135,14 @@ namespace MonoDevelop.CodeIssues
readonly static string diagnosticAnalyzerAssembly = typeof (DiagnosticAnalyzerAttribute).Assembly.GetName ().Name;
- }
+ static bool IsDiagnosticSupported (DiagnosticDescriptor diag)
+ {
+ //filter out E&C analyzers as we don't support E&C
+ if (diag.CustomTags.Contains (WellKnownDiagnosticTags.EditAndContinue)) {
+ return false;
+ }
+ return true;
+ }
+ }
} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BuiltInCodeDiagnosticProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BuiltInCodeDiagnosticProvider.cs
index bd00becc7c..92a9361874 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BuiltInCodeDiagnosticProvider.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/BuiltInCodeDiagnosticProvider.cs
@@ -1,4 +1,4 @@
-//
+//
// BuiltInCodeDiagnosticProvider.cs
//
// Author:
@@ -53,7 +53,7 @@ namespace MonoDevelop.CodeIssues
try {
result.AddAssembly (asm);
} catch (Exception e) {
- LoggingService.LogError ("error while loading diagnostics in " + asm.FullName, e);
+ LoggingService.LogError ("Error while loading diagnostics in " + asm.FullName, e);
}
}
return result;
@@ -62,14 +62,14 @@ namespace MonoDevelop.CodeIssues
internal static CodeDiagnosticDescriptor GetCodeDiagnosticDescriptor (string diagnosticId)
{
- foreach (var builtInDescriptor in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDecsriptorsAsync (null).Result) {
+ foreach (var builtInDescriptor in GetBuiltInCodeDiagnosticDescriptorsAsync (null).Result) {
if (builtInDescriptor.GetProvider ().SupportedDiagnostics.Any (diagnostic => diagnosticId == diagnostic.Id))
return builtInDescriptor;
}
return null;
}
- internal async static Task<IEnumerable<CodeDiagnosticDescriptor>> GetBuiltInCodeDiagnosticDecsriptorsAsync (string language, bool includeDisabledNodes = false, CancellationToken cancellationToken = default (CancellationToken))
+ internal async static Task<IEnumerable<CodeDiagnosticDescriptor>> GetBuiltInCodeDiagnosticDescriptorsAsync (string language, bool includeDisabledNodes = false, CancellationToken cancellationToken = default (CancellationToken))
{
builtInDiagnostics.Wait (cancellationToken);
var diags = await builtInDiagnostics;
@@ -100,7 +100,7 @@ namespace MonoDevelop.CodeIssues
public override Task<IEnumerable<CodeDiagnosticDescriptor>> GetCodeDiagnosticDescriptorsAsync (DocumentContext document, string language, CancellationToken cancellationToken)
{
- return GetBuiltInCodeDiagnosticDecsriptorsAsync (language, false, cancellationToken);
+ return GetBuiltInCodeDiagnosticDescriptorsAsync (language, false, cancellationToken);
}
public override Task<IEnumerable<CodeRefactoringDescriptor>> GetCodeRefactoringDescriptorsAsync (DocumentContext document, string language, CancellationToken cancellationToken = default (CancellationToken))
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CSharpSuppressionFixProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CSharpSuppressionFixProvider.cs
deleted file mode 100644
index 5ec493b3bd..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CSharpSuppressionFixProvider.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-// CSharpSuppressionFixProvider.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.Text;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.CodeIssues
-{
- class CSharpSuppressionFixProvider : ISuppressionFixProvider
- {
- static readonly Type typeInfo;
- static readonly MethodInfo canBeSuppressedOrUnsuppressedMethod;
- static readonly MethodInfo getFixAllProviderMethod;
- static readonly MethodInfo getSuppressionsAsync1Method;
- static readonly MethodInfo getSuppressionsAsync2Method;
-
- object instance;
-
- public static ISuppressionFixProvider Instance;
-
- static CSharpSuppressionFixProvider ()
- {
- typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CSharp.CodeFixes.Suppression.CSharpSuppressionCodeFixProvider, Microsoft.CodeAnalysis.CSharp.Features", true);
-
- if (typeInfo == null)
- LoggingService.LogError ("CSharpSuppressionCodeFixProvider not found.");
-
- canBeSuppressedOrUnsuppressedMethod = typeInfo.GetMethod ("CanBeSuppressedOrUnsuppressed");
- if (canBeSuppressedOrUnsuppressedMethod == null)
- LoggingService.LogError ("CanBeSuppressedOrUnsuppressed not found.");
- getFixAllProviderMethod = typeInfo.GetMethod ("GetFixAllProvider");
- if (getFixAllProviderMethod == null)
- LoggingService.LogError ("GetFixAllProvider not found.");
-
- getSuppressionsAsync1Method = typeInfo.GetMethod ("GetSuppressionsAsync", new [] { typeof(Project), typeof(IEnumerable<Diagnostic>), typeof(CancellationToken) });
- if (getSuppressionsAsync1Method == null)
- LoggingService.LogError ("GetSuppressionsAsync1 not found.");
- getSuppressionsAsync2Method = typeInfo.GetMethod ("GetSuppressionsAsync", new [] { typeof(Document), typeof(TextSpan), typeof(IEnumerable<Diagnostic>), typeof(CancellationToken) });
- if (getSuppressionsAsync2Method == null)
- LoggingService.LogError ("GetSuppressionsAsync2 not found.");
- Instance = new CSharpSuppressionFixProvider ();
- }
-
- public CSharpSuppressionFixProvider ()
- {
- instance = Activator.CreateInstance (typeInfo, true);
- }
-
- public bool CanBeSuppressedOrUnsuppressed (Diagnostic diagnostic)
- {
- return (bool)canBeSuppressedOrUnsuppressedMethod.Invoke (instance, new [] { diagnostic } );
- }
-
- public FixAllProvider GetFixAllProvider ()
- {
- return (FixAllProvider)canBeSuppressedOrUnsuppressedMethod.Invoke (instance, null);
- }
-
- public Task<IEnumerable<CodeFix>> GetSuppressionsAsync (Project project, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
- {
- var o2 = getSuppressionsAsync1Method.Invoke (instance, new object[] { project, diagnostics, cancellationToken } );
- var task = (Task)o2;
-
- var propertyInfo = task.GetType ().GetProperty ("Result");
- var result = (IEnumerable)propertyInfo.GetValue (task);
-
- List<CodeFix> wrappedResult = new List<CodeFix> ();
- foreach (var o in result)
- wrappedResult.Add (new CodeFix (o));
- return Task.FromResult((IEnumerable<CodeFix>)wrappedResult);
- }
-
- public Task<IEnumerable<CodeFix>> GetSuppressionsAsync (Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
- {
- var o2 = getSuppressionsAsync2Method.Invoke (instance, new object [] { document, span, diagnostics, cancellationToken });
- var task = (Task)o2;
-
-
- var propertyInfo = task.GetType ().GetProperty ("Result");
- var result = (IEnumerable)propertyInfo.GetValue (task);
-
- List<CodeFix> wrappedResult = new List<CodeFix> ();
- foreach (var o in result)
- wrappedResult.Add (new CodeFix (o));
- return Task.FromResult((IEnumerable<CodeFix>)wrappedResult);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticDescriptor.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticDescriptor.cs
index 0a2936b065..9a66455ecf 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticDescriptor.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticDescriptor.cs
@@ -23,28 +23,26 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
+using System.Collections.Immutable;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Diagnostics;
using MonoDevelop.Core;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Text;
using MonoDevelop.Ide.Editor;
-using System.Threading;
-using MonoDevelop.Ide.TypeSystem;
-using System.Reflection;
-using Microsoft.CodeAnalysis.CodeActions;
-using System.Collections.Immutable;
namespace MonoDevelop.CodeIssues
{
class CodeDiagnosticDescriptor
{
readonly Type diagnosticAnalyzerType;
- readonly Microsoft.CodeAnalysis.DiagnosticDescriptor descriptor;
DiagnosticAnalyzer instance;
-
/// <summary>
/// Gets the identifier string.
/// </summary>
@@ -61,15 +59,6 @@ namespace MonoDevelop.CodeIssues
}
/// <summary>
- /// Gets the display name for this issue.
- /// </summary>
- public string Name { get; private set; }
-
- /// <summary>
- /// Gets the description of the issue provider (used in the option panel).
- /// </summary>
-
- /// <summary>
/// Gets the languages for this issue.
/// </summary>
public string[] Languages { get; private set; }
@@ -135,25 +124,14 @@ namespace MonoDevelop.CodeIssues
PropertyService.Set ("CodeIssues." + Languages + "." + IdString + "." + diagnostic.Id + ".enabled", value);
}
- static CodeDiagnosticDescriptor ()
- {
- getCodeActionsMethod = typeof (CodeAction).GetMethod ("GetCodeActions", BindingFlags.Instance | BindingFlags.NonPublic);
- hasCodeActionsProperty = typeof (CodeAction).GetProperty ("HasCodeActions", BindingFlags.Instance | BindingFlags.NonPublic);
-
- }
-
- internal CodeDiagnosticDescriptor (Microsoft.CodeAnalysis.DiagnosticDescriptor descriptor, string[] languages, Type codeIssueType)
+ internal CodeDiagnosticDescriptor (string[] languages, Type codeIssueType)
{
- if (descriptor == null)
- throw new ArgumentNullException ("descriptor");
if (languages == null)
- throw new ArgumentNullException ("languages");
+ throw new ArgumentNullException (nameof (languages));
if (codeIssueType == null)
- throw new ArgumentNullException ("codeIssueType");
- Name = descriptor.Title.ToString () ?? "unnamed";
+ throw new ArgumentNullException (nameof (codeIssueType));
Languages = languages;
- this.descriptor = descriptor;
- this.diagnosticAnalyzerType = codeIssueType;
+ diagnosticAnalyzerType = codeIssueType;
}
/// <summary>
@@ -169,56 +147,27 @@ namespace MonoDevelop.CodeIssues
public override string ToString ()
{
- return string.Format ("[CodeIssueDescriptor: IdString={0}, Name={1}, Language={2}]", IdString, Name, Languages);
- }
-
- public bool CanDisableWithPragma { get { return !string.IsNullOrEmpty (descriptor.Id); } }
-
- const string analysisDisableTag = "Analysis ";
- readonly static MethodInfo getCodeActionsMethod;
- readonly static PropertyInfo hasCodeActionsProperty;
-
- public async void DisableWithPragma (TextEditor editor, DocumentContext context, Diagnostic fix, CancellationToken cancellationToken = default(CancellationToken))
- {
- var line = editor.GetLineByOffset (fix.Location.SourceSpan.Start);
- var span = new TextSpan (line.Offset, line.Length);
- var fixes = await CSharpSuppressionFixProvider.Instance.GetSuppressionsAsync (context.AnalysisDocument, span, new [] { fix }, cancellationToken).ConfigureAwait (false);
- foreach (var f in fixes) {
- RunAction (context, f.Action, cancellationToken);
- }
+ return $"[CodeIssueDescriptor: IdString={IdString}, Language={Languages}]";
}
- public async void DisableWithFile (TextEditor editor, DocumentContext context, Diagnostic fix, CancellationToken cancellationToken = default(CancellationToken))
- {
- var p = context.RoslynWorkspace.CurrentSolution.GetProject (TypeSystemService.GetProjectId (context.Project));
-
- var fixes = await CSharpSuppressionFixProvider.Instance.GetSuppressionsAsync (p, new [] { fix }, cancellationToken ).ConfigureAwait (false);
-
- foreach (var f in fixes) {
- RunAction (context, f.Action, cancellationToken);
- }
- }
-
- internal static async void RunAction (DocumentContext context, CodeAction action, CancellationToken cancellationToken)
+ internal static async Task RunAction (DocumentContext context, CodeAction action, CancellationToken cancellationToken)
{
var operations = await action.GetOperationsAsync (cancellationToken).ConfigureAwait (false);
if (operations == null)
return;
+
foreach (var op in operations) {
if (op == null)
continue;
try {
op.Apply (context.RoslynWorkspace, cancellationToken);
} catch (Exception e) {
- LoggingService.LogError ("Error while appyling operation : " + op, e);
+ LoggingService.LogError ("Error while applying operation : " + op, e);
}
}
- if ((bool)hasCodeActionsProperty.GetValue (action)) {
- var result = (ImmutableArray<CodeAction>)getCodeActionsMethod.Invoke (action, null);
- foreach (var nested in result) {
- RunAction (context, nested, cancellationToken);
- }
+ foreach (var nested in action.NestedCodeActions) {
+ await RunAction (context, nested, cancellationToken).ConfigureAwait (false);
}
}
}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticFixDescriptor.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticFixDescriptor.cs
index 29c0d576c8..b70fd9e0e2 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticFixDescriptor.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticFixDescriptor.cs
@@ -1,4 +1,4 @@
-//
+//
// CodeFixDescriptor.cs
//
// Author:
@@ -77,7 +77,7 @@ namespace MonoDevelop.CodeIssues
{
var fixableIds = GetCodeFixProvider ().FixableDiagnosticIds.ToList ();
- foreach (var descriptor in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDecsriptorsAsync (language).Result) {
+ foreach (var descriptor in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDescriptorsAsync (language).Result) {
if (descriptor.GetProvider ().SupportedDiagnostics.Any (diagnostic => fixableIds.Contains (diagnostic.Id)))
return descriptor;
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticRunner.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticRunner.cs
index 1cc10d3751..d0be5c6f7c 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticRunner.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeDiagnosticRunner.cs
@@ -41,6 +41,7 @@ using Microsoft.CodeAnalysis;
using System.Threading.Tasks;
using System.Diagnostics;
using MonoDevelop.Ide.Editor;
+using System.Collections.Immutable;
namespace MonoDevelop.CodeIssues
{
@@ -95,11 +96,13 @@ namespace MonoDevelop.CodeIssues
#endif
CompilationWithAnalyzers compilationWithAnalyzer;
- var analyzers = System.Collections.Immutable.ImmutableArray<DiagnosticAnalyzer>.Empty.AddRange (providers);
+ var analyzers = ImmutableArray<DiagnosticAnalyzer>.Empty.AddRange (providers);
var diagnosticList = new List<Diagnostic> ();
try {
var options = new CompilationWithAnalyzersOptions (
- null,
+ new WorkspaceAnalyzerOptions (
+ new AnalyzerOptions (ImmutableArray<AdditionalText>.Empty),
+ analysisDocument.DocumentContext.RoslynWorkspace),
delegate (Exception exception, DiagnosticAnalyzer analyzer, Diagnostic diag) {
LoggingService.LogError ("Exception in diagnostic analyzer " + diag.Id + ":" + diag.GetMessage (), exception);
},
@@ -113,7 +116,8 @@ namespace MonoDevelop.CodeIssues
diagnosticList.AddRange (await compilationWithAnalyzer.GetAnalyzerSemanticDiagnosticsAsync (model, null, cancellationToken).ConfigureAwait (false));
diagnosticList.AddRange (await compilationWithAnalyzer.GetAnalyzerSyntaxDiagnosticsAsync (model.SyntaxTree, cancellationToken).ConfigureAwait (false));
- } catch (Exception) {
+ } catch (Exception ex) {
+ LoggingService.LogError ("Error creating analyzer compilation", ex);
return Enumerable.Empty<Result> ();
} finally {
#if DEBUG
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs
index 2ec4a74f37..54bbf9c624 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssuePanelWidget.cs
@@ -23,22 +23,22 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
-using MonoDevelop.Ide.Gui.Dialogs;
-using Gtk;
-using MonoDevelop.Core;
-using System.Linq;
-using MonoDevelop.Refactoring;
using System.Collections.Generic;
-using GLib;
-using MonoDevelop.Components;
+using System.Globalization;
+using System.Linq;
using Gdk;
-using MonoDevelop.Ide.Editor;
-using MonoDevelop.CodeActions;
+using GLib;
+using Gtk;
using Microsoft.CodeAnalysis;
-using MonoDevelop.SourceEditor.QuickTasks;
-using MonoDevelop.Ide.TypeSystem;
+using MonoDevelop.CodeActions;
+using MonoDevelop.Components;
+using MonoDevelop.Core;
using MonoDevelop.Ide;
+using MonoDevelop.Ide.Gui.Dialogs;
+using MonoDevelop.Ide.TypeSystem;
+using MonoDevelop.SourceEditor.QuickTasks;
namespace MonoDevelop.CodeIssues
{
@@ -75,26 +75,31 @@ namespace MonoDevelop.CodeIssues
partial class CodeIssuePanelWidget : Bin
{
readonly string mimeType;
- readonly TreeStore treeStore = new TreeStore (typeof(string), typeof(Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>), typeof (string));
+ readonly TreeStore treeStore = new TreeStore (typeof(string), typeof(Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>), typeof (string), typeof (string));
readonly Dictionary<Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>, DiagnosticSeverity?> severities = new Dictionary<Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>, DiagnosticSeverity?> ();
readonly Dictionary<Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>, bool> enableState = new Dictionary<Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>, bool> ();
void GetAllSeverities ()
{
- foreach (var node in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDecsriptorsAsync (CodeRefactoringService.MimeTypeToLanguage (mimeType), true).Result) {
- var root = new Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor> (node, null);
- severities [root] = node.DiagnosticSeverity;
- enableState [root] = node.IsEnabled;
- if (node.GetProvider ().SupportedDiagnostics.Length > 1) {
- foreach (var subIssue in node.GetProvider ().SupportedDiagnostics) {
- var sub = new Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor> (node, subIssue);
- severities [sub] = node.GetSeverity (subIssue);
- enableState [sub] = node.GetIsEnabled (subIssue);
- }
+ foreach (var node in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDescriptorsAsync (CodeRefactoringService.MimeTypeToLanguage (mimeType), true).Result) {
+ foreach (var subIssue in node.GetProvider ().SupportedDiagnostics.Where (IsConfigurable).ToList ()) {
+ var sub = new Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor> (node, subIssue);
+ severities [sub] = node.GetSeverity (subIssue);
+ enableState [sub] = node.GetIsEnabled (subIssue);
}
}
}
+ static bool IsConfigurable (DiagnosticDescriptor desc)
+ {
+ return !DescriptorHasTag (desc, WellKnownDiagnosticTags.NotConfigurable);
+ }
+
+ static bool DescriptorHasTag (DiagnosticDescriptor desc, string tag)
+ {
+ return desc.CustomTags.Any (c => CultureInfo.InvariantCulture.CompareInfo.Compare (c, tag) == 0);
+ }
+
public void SelectCodeIssue (string idString)
{
TreeIter iter;
@@ -159,25 +164,26 @@ namespace MonoDevelop.CodeIssues
categories.Clear ();
treeStore.Clear ();
var grouped = severities.Keys
- .Where (node => node.Item2 == null && (string.IsNullOrEmpty (filter) || node.Item1.Name.IndexOf (filter, StringComparison.OrdinalIgnoreCase) > 0))
- .GroupBy (node => node.Item1.GetProvider ().SupportedDiagnostics.First ().Category)
+ .GroupBy (node => node.Item2.Category)
.OrderBy (g => g.Key, StringComparer.Ordinal);
foreach (var g in grouped) {
- TreeIter categoryIter = treeStore.AppendValues ("<b>" + g.Key + "</b>", null, null);
- categories [g.Key] = categoryIter;
-
- foreach (var node in g.OrderBy (n => n.Item1.Name, StringComparer.Ordinal)) {
- var title = node.Item1.Name;
- MarkupSearchResult (filter, ref title);
- var nodeIter = treeStore.AppendValues (categoryIter, title, node, Ambience.EscapeText (node.Item1.Name));
- if (node.Item1.GetProvider ().SupportedDiagnostics.Length > 1) {
- foreach (var subIssue in node.Item1.GetProvider ().SupportedDiagnostics) {
- title = subIssue.Title.ToString ();
- MarkupSearchResult (filter, ref title);
- treeStore.AppendValues (nodeIter, title, new Tuple<CodeDiagnosticDescriptor, DiagnosticDescriptor>(node.Item1, subIssue), Ambience.EscapeText (node.Item1.Name));
- }
+ foreach (var node in g.OrderBy (n => n.Item2.Title.ToString(), StringComparer.CurrentCulture)) {
+ var title = GettextCatalog.GetString ("{0} ({1})", node.Item2.Title, node.Item2.Id);
+ if (!string.IsNullOrEmpty (filter) && title.IndexOf (filter, StringComparison.CurrentCultureIgnoreCase) < 0) {
+ continue;
}
+ TreeIter categoryIter;
+ if (!categories.TryGetValue (g.Key, out categoryIter)) {
+ categoryIter = treeStore.AppendValues ("<b>" + g.Key + "</b>", null, null, null);
+ categories [g.Key] = categoryIter;
+ }
+ var desc = node.Item2.Description.ToString ();
+ if (string.IsNullOrEmpty (desc)) {
+ desc = title;
+ }
+ MarkupSearchResult (filter, ref title);
+ var nodeIter = treeStore.AppendValues (categoryIter, title, node, Ambience.EscapeText (title), Ambience.EscapeText (desc));
}
}
treeviewInspections.ExpandAll ();
@@ -237,7 +243,7 @@ namespace MonoDevelop.CodeIssues
treeviewInspections.ScrollToCell (path, treeviewInspections.Columns[0], false, 0f, 0f);
}
};
- treeviewInspections.TooltipColumn = 2;
+ treeviewInspections.TooltipColumn = 3;
treeviewInspections.HasTooltip = true;
var toggleRenderer = new CellRendererToggle ();
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DiagnosticResult.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DiagnosticResult.cs
index 830d8483bb..1713f2abfc 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DiagnosticResult.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/DiagnosticResult.cs
@@ -29,6 +29,8 @@ using MonoDevelop.AnalysisCore;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis;
using RefactoringEssentials;
+using System.Linq;
+using System.Globalization;
namespace MonoDevelop.CodeIssues
{
@@ -45,7 +47,7 @@ namespace MonoDevelop.CodeIssues
public DiagnosticResult (Diagnostic diagnostic) : base (GetSpan (diagnostic), diagnostic.GetMessage ())
{
if (diagnostic == null)
- throw new ArgumentNullException ("diagnostic");
+ throw new ArgumentNullException (nameof (diagnostic));
this.diagnostic = diagnostic;
SetSeverity (diagnostic.Severity, GetIssueMarker ());
@@ -64,8 +66,15 @@ namespace MonoDevelop.CodeIssues
return TextSpan.FromBounds (start, end);
}
+ static bool DescriptorHasTag (DiagnosticDescriptor desc, string tag)
+ {
+ return desc.CustomTags.Any (c => CultureInfo.InvariantCulture.CompareInfo.Compare (c, tag) == 0);
+ }
+
IssueMarker GetIssueMarker ()
{
+ if (DescriptorHasTag (diagnostic.Descriptor, WellKnownDiagnosticTags.Unnecessary))
+ return IssueMarker.GrayOut;
if (diagnostic.Descriptor.Category == DiagnosticAnalyzerCategories.RedundanciesInCode || diagnostic.Descriptor.Category == DiagnosticAnalyzerCategories.RedundanciesInDeclarations)
return IssueMarker.GrayOut;
if (diagnostic.Severity == DiagnosticSeverity.Info)
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ISuppressionFixProvider.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ISuppressionFixProvider.cs
deleted file mode 100644
index 9343139e81..0000000000
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/ISuppressionFixProvider.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// ISuppressionFixProvider.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.Text;
-
-namespace MonoDevelop.CodeIssues
-{
- interface ISuppressionFixProvider
- {
- /// <summary>
- /// Returns true if the given diagnostic can be suppressed or unsuppressed.
- /// </summary>
- bool CanBeSuppressedOrUnsuppressed(Diagnostic diagnostic);
-
- /// <summary>
- /// Gets one or more add suppression or remove suppression fixes for the specified diagnostics represented as a list of <see cref="CodeAction"/>'s.
- /// </summary>
- /// <returns>A list of zero or more potential <see cref="CodeFix"/>'es. It is also safe to return null if there are none.</returns>
- Task<IEnumerable<CodeFix>> GetSuppressionsAsync(Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken);
-
- /// <summary>
- /// Gets one or more add suppression or remove suppression fixes for the specified no-location diagnostics represented as a list of <see cref="CodeAction"/>'s.
- /// </summary>
- /// <returns>A list of zero or more potential <see cref="CodeFix"/>'es. It is also safe to return null if there are none.</returns>
- Task<IEnumerable<CodeFix>> GetSuppressionsAsync(Project project, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken);
-
- /// <summary>
- /// Gets an optional <see cref="FixAllProvider"/> that can fix all/multiple occurrences of diagnostics fixed by this fix provider.
- /// Return null if the provider doesn't support fix all/multiple occurrences.
- /// Otherwise, you can return any of the well known fix all providers from <see cref="WellKnownFixAllProviders"/> or implement your own fix all provider.
- /// </summary>
- FixAllProvider GetFixAllProvider();
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml
index 37ee9eaca1..f463ea7560 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml
@@ -1,4 +1,7 @@
<ExtensionModel>
+ <Runtime>
+ <Import assembly="RefactoringEssentials.dll" />
+ </Runtime>
<!-- Extension Points -->
<ExtensionPoint path = "/MonoDevelop/Refactoring/Refactorings" name = "Refactorings">
@@ -25,29 +28,6 @@
<ExtensionNode name="Class"/>
</ExtensionPoint>
- <ExtensionNodeSet id="MonoDevelop.AnalysisCore.Rules">
- <ExtensionNode name="Category" type="MonoDevelop.Ide.Codons.CategoryNode">
- <ExtensionNodeSet id="MonoDevelop.AnalysisCore.Rules" />
- </ExtensionNode>
- <ExtensionNode name="Rule" type="MonoDevelop.AnalysisCore.Extensions.NamedAnalysisRuleAddinNode" />
- <ExtensionNode name="Adaptor" type="MonoDevelop.AnalysisCore.Extensions.AdaptorAnalysisRuleAddinNode" />
- </ExtensionNodeSet>
-
- <ExtensionPoint path = "/MonoDevelop/AnalysisCore/Rules" name = "Analysis Rules">
- <Description>Analysis rules.</Description>
- <ExtensionNodeSet id="MonoDevelop.AnalysisCore.Rules" />
- </ExtensionPoint>
-
- <ExtensionPoint path = "/MonoDevelop/AnalysisCore/Types" name = "Analysis rule input/output types">
- <Description>Analysis rule input/output types.</Description>
- <ExtensionNode name="Type" type="MonoDevelop.AnalysisCore.Extensions.AnalysisTypeExtensionNode" />
- </ExtensionPoint>
-
- <ExtensionPoint path = "/MonoDevelop/AnalysisCore/FixHandlers" name = "Fix handlers">
- <Description>Fix handlers. Classes must implement IAnalysisFixHandler.</Description>
- <ExtensionNode name="Handler" type="MonoDevelop.AnalysisCore.Extensions.FixHandlerExtensionNode" />
- </ExtensionPoint>
-
<!-- Extensions -->
<!--
@@ -122,17 +102,6 @@
insertafter="MonoDevelop.Ide.Commands.TextEditorCommands.ShowParameterCompletionWindow" />
</Extension>
- <!-- Quick fix commands -->
-
- <Extension path = "/MonoDevelop/Ide/Commands/Refactoring">
- <Command id = "MonoDevelop.AnalysisCore.AnalysisCommands.ShowFixes"
- defaultHandler="MonoDevelop.AnalysisCore.ShowFixesHandler"
- _label = "Show Fixes"
- _description="Shows a list of fixes for problems at the current location"
- macShortcut="Control|."
- shortcut = "Control|." />
- </Extension>
-
<!-- Options panels -->
<Extension path = "/MonoDevelop/Ide/GlobalOptionsDialog/TextEditor">
@@ -145,25 +114,6 @@
</Extension>
<!-- Extensions to the addin points defined by this addin -->
-
- <Extension path = "/MonoDevelop/AnalysisCore/Types">
- <Type name="AnalysisDocument" class="MonoDevelop.AnalysisCore.Gui.AnalysisDocument" />
- <Type name="CompilationUnit" class="MonoDevelop.Projects.Dom.ICompilationUnit" />
- </Extension>
-
- <Extension path = "/MonoDevelop/AnalysisCore/Rules">
- <Adaptor func="MonoDevelop.AnalysisCore.Rules.Adapters.GetCompilationUnit"
- input="AnalysisDocument" output="CompilationUnit" />
- <Category _name="Design Guidelines" id="Design">
-<!-- <Rule _name="Naming Conventions" input="CompilationUnit"
- func="MonoDevelop.AnalysisCore.Rules.NamingConventions.ClassNaming" />-->
- </Category>
- </Extension>
-
- <Extension path = "/MonoDevelop/AnalysisCore/FixHandlers">
- <Handler fixName="RenameMember" class = "MonoDevelop.AnalysisCore.Fixes.RenameMemberHandler" />
- <Handler fixName="Generic" class = "MonoDevelop.AnalysisCore.Fixes.GenericFixHandler" />
- </Extension>
<Extension path="/MonoDevelop/Core/StockIcons">
<StockIcon stockid="md-prefs-code-actions" resource="prefs-code-actions-16.png" size="Menu" />
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj
index f2a9714bda..de735725b3 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.Refactoring</AssemblyName>
<RootNamespace>MonoDevelop.Refactoring</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -116,19 +117,9 @@
<Compile Include="MonoDevelop.AnalysisCore\Gui\ResultTooltipProvider.cs" />
<Compile Include="MonoDevelop.AnalysisCore\Gui\AnalysisOptionsPanel.cs" />
<Compile Include="MonoDevelop.AnalysisCore\Gui\ResultMarker.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\Fixes\RenameMemberFix.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\Extensions\AnalysisTypeExtensionNode.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\Extensions\FixHandlerExtensionNode.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\Extensions\AnalysisRuleAddinNode.cs" />
<Compile Include="MonoDevelop.AnalysisCore\AnalysisCommands.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\AnalysisExtensions.cs" />
<Compile Include="MonoDevelop.AnalysisCore\AnalysisOptions.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\AnalysisService.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\FixableResult.cs" />
<Compile Include="MonoDevelop.AnalysisCore\Result.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\RuleTree.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\RuleTreeType.cs" />
- <Compile Include="MonoDevelop.AnalysisCore\Fixes\GenericFix.cs" />
<Compile Include="MonoDevelop.Refactoring\RefactoringService.cs" />
<Compile Include="MonoDevelop.Refactoring\Change.cs" />
<Compile Include="MonoDevelop.Refactoring.Rename\RenameRefactoring.cs" />
@@ -158,15 +149,14 @@
<Compile Include="MonoDevelop.CodeIssues\CodeDiagnosticFixDescriptor.cs" />
<Compile Include="MonoDevelop.Refactoring\Commands.cs" />
<Compile Include="MonoDevelop.Refactoring\RefactoringSymbolInfo.cs" />
- <Compile Include="MonoDevelop.CodeIssues\ISuppressionFixProvider.cs" />
<Compile Include="MonoDevelop.CodeIssues\CodeFix.cs" />
- <Compile Include="MonoDevelop.CodeIssues\CSharpSuppressionFixProvider.cs" />
<Compile Include="MonoDevelop.Refactoring\FindReferencesProvider.cs" />
<Compile Include="MonoDevelop.Refactoring\JumpToDeclarationHandler.cs" />
<Compile Include="MonoDevelop.Refactoring\InsertionPointService.cs" />
<Compile Include="MonoDevelop.Refactoring\AnalyzeWholeSolutionHandler.cs" />
<Compile Include="MonoDevelop.Refactoring\AnalyzeCurrentProjectHandler.cs" />
<Compile Include="MonoDevelop.Refactoring\RefactoringPreviewTooltipWindow.cs" />
+ <Compile Include="MonoDevelop.CodeActions\CodeFixMenuService.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="MonoDevelop.Refactoring\" />
@@ -174,7 +164,6 @@
<Folder Include="MonoDevelop.AnalysisCore\" />
<Folder Include="MonoDevelop.CodeIssues\" />
<Folder Include="MonoDevelop.CodeActions\" />
- <Folder Include="MonoDevelop.AnalysisCore\Rules\" />
<Folder Include="MonoDevelop.CodeIssues\Pad\" />
</ItemGroup>
<ItemGroup>
@@ -300,21 +289,20 @@
<Name>MonoDevelop.SourceEditor</Name>
<Private>False</Private>
</ProjectReference>
- <ProjectReference Include="..\..\..\external\RefactoringEssentials\RefactoringEssentials\RefactoringEssentials.csproj">
+ <ProjectReference Include="..\..\..\external\RefactoringEssentials\RefactoringEssentials.2017\RefactoringEssentials.csproj">
<Project>{C465A5DC-AD28-49A2-89C0-F81838814A7E}</Project>
<Name>RefactoringEssentials</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\..\core\Mono.Texteditor\Mono.TextEditor.csproj">
- <Project>{A2329308-3751-4DBD-9A75-5F7B8B024625}</Project>
- <Name>Mono.TextEditor</Name>
- <Private>False</Private>
+ <Private>True</Private>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <InternalsVisibleTo Include="FSharpBinding" />
+ <InternalsVisibleTo Include="MonoDevelop.CSharpBinding" />
+ <InternalsVisibleTo Include="MonoDevelop.PackageManagement" />
+ <InternalsVisibleTo Include="MonoDevelop.MonoDroid" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
- <None Include="MonoDevelop.AnalysisCore\README.txt" />
- <None Include="MonoDevelop.AnalysisCore\TODO.txt" />
<None Include="MonoDevelop.Refactoring\QuickFixHandler.cs" />
<None Include="gtk-gui\MonoDevelop.Refactoring.OverridesImplementsDialog.cs" />
<None Include="gtk-gui\MonoDevelop.Refactoring.EncapsulateFieldDialog.cs" />
@@ -355,9 +343,4 @@
<None Include="MonoDevelop.CodeIssues\Pad\AnalysisStateChangeEventArgs.cs" />
<None Include="MonoDevelop.CodeIssues\Pad\CategoryGroupingProvider.cs" />
</ItemGroup>
-
- <Target Name="AfterBuild">
- <Copy SourceFiles="..\..\..\build\bin\Microsoft.CodeAnalysis.CSharp.Features.dll" DestinationFolder="..\..\..\build\bin" ContinueOnError="true" />
- <Copy SourceFiles="..\..\..\build\bin\Microsoft.CodeAnalysis.Features.dll" DestinationFolder="..\..\..\build\bin" ContinueOnError="true" />
- </Target>
- </Project>
+</Project>
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/InsertionPointService.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/InsertionPointService.cs
index 57885a3cef..444f099716 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/InsertionPointService.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/InsertionPointService.cs
@@ -30,7 +30,7 @@ using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using MonoDevelop.Ide.Editor;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using System.Threading;
using Microsoft.CodeAnalysis.Text;
using MonoDevelop.Ide.TypeSystem;
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs
index a256e7422b..5a3e11c048 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs
@@ -55,10 +55,12 @@ namespace MonoDevelop.Refactoring
int indentLength;
FontDescription fontDescription;
- public RefactoringPreviewTooltipWindow (TextEditor editor, DocumentContext documentContext, CodeAction codeAction)
+ static RefactoringPreviewTooltipWindow currentPreviewWindow;
+
+ RefactoringPreviewTooltipWindow (TextEditor editor, CodeAction codeAction)
{
this.editor = editor;
- this.documentContext = documentContext;
+ this.documentContext = documentContext = editor.DocumentContext;
this.codeAction = codeAction;
TransientFor = IdeApp.Workbench.RootWindow;
@@ -70,7 +72,22 @@ namespace MonoDevelop.Refactoring
}
}
- internal async void RequestPopup (Xwt.Rectangle rect)
+ public static void ShowPreviewTooltip (TextEditor editor, CodeAction fix, Xwt.Rectangle rect)
+ {
+ HidePreviewTooltip ();
+ currentPreviewWindow = new RefactoringPreviewTooltipWindow (editor, fix);
+ currentPreviewWindow.RequestPopup (rect);
+ }
+
+ public static void HidePreviewTooltip ()
+ {
+ if (currentPreviewWindow != null) {
+ currentPreviewWindow.Destroy ();
+ currentPreviewWindow = null;
+ }
+ }
+
+ async void RequestPopup (Xwt.Rectangle rect)
{
var token = popupSrc.Token;
diff --git a/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit.csproj b/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit.csproj
index 653eea50db..8c76f3192a 100644
--- a/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit.csproj
+++ b/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.RegexToolkit</AssemblyName>
<RootNamespace>MonoDevelop.RegexToolkit</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/ValidateActionCodeRefactoringProvider.cs b/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/ValidateActionCodeRefactoringProvider.cs
index 8b7bd5a146..117c1a35b8 100644
--- a/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/ValidateActionCodeRefactoringProvider.cs
+++ b/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/ValidateActionCodeRefactoringProvider.cs
@@ -38,7 +38,7 @@ using Microsoft.CodeAnalysis.Formatting;
using MonoDevelop.Core;
using MonoDevelop.RegexToolkit;
-namespace RefactoringEssentials.CSharp.CodeRefactorings
+namespace MonoDevelop.RegexToolkit.CodeRefactorings
{
[ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = "Validate regular expression")]
public class ValidateActionCodeRefactoringProvider : CodeRefactoringProvider
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/AssemblyInfo.cs b/main/src/addins/MonoDevelop.SourceEditor2/AssemblyInfo.cs
index a55a44cb7a..9a194e0e74 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/AssemblyInfo.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/AssemblyInfo.cs
@@ -7,13 +7,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyTitle ("MonoDevelop Source Editor")]
[assembly: AssemblyDescription ("Provides a text editor for the MonoDevelop based on Mono.TextEditor")]
[assembly: AssemblyVersion ("2.6")]
-[assembly: InternalsVisibleTo ("UnitTests")]
-[assembly: InternalsVisibleTo ("MonoDevelop.VersionControl")]
-[assembly: InternalsVisibleTo ("MonoDevelop.VersionControl.Subversion")]
-[assembly: InternalsVisibleTo ("MonoDevelop.VersionControl.Git")]
-[assembly: InternalsVisibleTo ("MonoDevelop.Refactoring")]
-[assembly: InternalsVisibleTo ("MonoDevelop.TextEditor.Tests")]
-[assembly: InternalsVisibleTo ("MonoDevelop.AspNet")]
-[assembly: InternalsVisibleTo ("MonoDevelop.AspNet.Tests")]
-[assembly: InternalsVisibleTo ("FSharpBinding")]
-[assembly: InternalsVisibleTo ("MonoDevelop.FSharp.Tests")]
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs
index 895c65b2e9..73c8aab6a2 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs
@@ -737,7 +737,7 @@ namespace MonoDevelop.SourceEditor.QuickTasks
} else if (allTasks.MoveNext ()) {
var task = allTasks.Current;
int y = (int)GetYPosition (TextEditor.OffsetToLineNumber (task.Location));
- if (!lineCache[1].Contains (y)) {
+ if (!lineCache[1].Contains (y) && task.Severity != DiagnosticSeverity.Hidden) {
lineCache[1].Add (y);
cr.SetSourceColor (GetBarColor (task.Severity));
cr.Rectangle (1, y - 1, Allocation.Width - 1, 2);
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj
index e0205ca731..31bcfbeb20 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -8,9 +9,8 @@
<ProjectGuid>{F8F92AA4-A376-4679-A9D4-60E7B7FBF477}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.SourceEditor</RootNamespace>
- <AssemblyOriginatorKeyFile>.</AssemblyOriginatorKeyFile>
<AssemblyName>MonoDevelop.SourceEditor</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<AssemblyName>MonoDevelop.SourceEditor</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -471,6 +471,18 @@
<LogicalName>prefs-completion-16~dark~sel@2x.png</LogicalName>
</EmbeddedResource>
</ItemGroup>
+ <ItemGroup>
+ <InternalsVisibleTo Include="UnitTests" />
+ <InternalsVisibleTo Include="MonoDevelop.VersionControl" />
+ <InternalsVisibleTo Include="MonoDevelop.VersionControl.Subversion" />
+ <InternalsVisibleTo Include="MonoDevelop.VersionControl.Git" />
+ <InternalsVisibleTo Include="MonoDevelop.Refactoring" />
+ <InternalsVisibleTo Include="MonoDevelop.TextEditor.Tests" />
+ <InternalsVisibleTo Include="MonoDevelop.AspNet" />
+ <InternalsVisibleTo Include="MonoDevelop.AspNet.Tests" />
+ <InternalsVisibleTo Include="FSharpBinding" />
+ <InternalsVisibleTo Include="MonoDevelop.FSharp.Tests" />
+ </ItemGroup>
<Import Project="..\..\core\Mono.TextEditor.Shared\Mono.TextEditor.Shared.projitems" Label="Shared" Condition="Exists('..\..\core\Mono.TextEditor.Shared\Mono.TextEditor.Shared.projitems')" />
<Import Project="..\..\core\Mono.TextEditor.Platform\Mono.TextEditor.Platform.projitems" Label="Platform" Condition="Exists('..\..\core\Mono.TextEditor.Platform\Mono.TextEditor.Platform.projitems')" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit.Runners/MonoDevelop.UnitTesting.NUnit.Runners.csproj b/main/src/addins/MonoDevelop.UnitTesting.NUnit.Runners/MonoDevelop.UnitTesting.NUnit.Runners.csproj
index b652356828..2248c849b4 100644
--- a/main/src/addins/MonoDevelop.UnitTesting.NUnit.Runners/MonoDevelop.UnitTesting.NUnit.Runners.csproj
+++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit.Runners/MonoDevelop.UnitTesting.NUnit.Runners.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.UnitTesting.NUnit.Runners</RootNamespace>
<AssemblyName>MonoDevelop.UnitTesting.NUnit.Runners</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -36,4 +37,4 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit.csproj b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit.csproj
index 5a6ccbdba8..d12973da4a 100644
--- a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit.csproj
+++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.UnitTesting.NUnit</AssemblyName>
<RootNamespace>MonoDevelop.UnitTesting.NUnit</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnit3Runner/NUnit3Runner.csproj b/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnit3Runner/NUnit3Runner.csproj
index b7079a762f..35c9a02960 100644
--- a/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnit3Runner/NUnit3Runner.csproj
+++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnit3Runner/NUnit3Runner.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>NUnit3Runner</RootNamespace>
<AssemblyName>NUnitRunner</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -65,4 +66,4 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/NUnitRunner.csproj b/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/NUnitRunner.csproj
index e798c370bf..ae5698846d 100644
--- a/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/NUnitRunner.csproj
+++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/NUnitRunner.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Exe</OutputType>
<AssemblyName>NUnitRunner</AssemblyName>
<RootNamespace>NUnitRunner</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj
index 3828219b6f..6b3bbbc0da 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj
+++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.UnitTesting</AssemblyName>
<RootNamespace>MonoDevelop.UnitTesting</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.csproj b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.csproj
index 801fbf65c6..b48987ac8f 100644
--- a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.csproj
+++ b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.WebReferences</AssemblyName>
<RootNamespace>MonoDevelop.WebReferences</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.csproj b/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.csproj
index 92f57f4f76..b7740e7934 100644
--- a/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.csproj
+++ b/main/src/addins/MonoDeveloperExtensions/MonoDeveloperExtensions.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDeveloperExtensions</AssemblyName>
<RootNamespace>MonoDeveloperExtensions</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/MonoDeveloperExtensions/NUnit/NUnit.csproj b/main/src/addins/MonoDeveloperExtensions/NUnit/NUnit.csproj
index 1fac44d9d1..a5154ee504 100644
--- a/main/src/addins/MonoDeveloperExtensions/NUnit/NUnit.csproj
+++ b/main/src/addins/MonoDeveloperExtensions/NUnit/NUnit.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -8,7 +9,7 @@
<ProjectGuid>{376889B5-6504-46A1-9D18-A9E4B4A50F49}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>NUnit</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<AssemblyName>MonoDeveloperExtensions_nunit</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -77,11 +78,10 @@
<ItemGroup>
<None Include="Makefile.am" />
</ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="..\..\..\..\md.targets" />
<ItemGroup>
<EmbeddedResource Include="ExtensionModel.addin.xml">
<LogicalName>ExtensionModel.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/PerformanceDiagnosticsAddIn.csproj b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/PerformanceDiagnosticsAddIn.csproj
index f8871b86b4..5186c0c025 100644
--- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/PerformanceDiagnosticsAddIn.csproj
+++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/PerformanceDiagnosticsAddIn.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>PerformanceDiagnosticsAddIn</RootNamespace>
<AssemblyName>PerformanceDiagnosticsAddIn</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -81,4 +82,4 @@
</Properties>
</MonoDevelop>
</ProjectExtensions>
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/AssemblyInfo.cs b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/AssemblyInfo.cs
index 47a4977278..fc8d1ade1a 100644
--- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/AssemblyInfo.cs
+++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/AssemblyInfo.cs
@@ -42,7 +42,7 @@ using System.Runtime.CompilerServices;
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion ("1.0.*")]
+[assembly: AssemblyVersion ("1.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
diff --git a/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/Properties/AssemblyInfo.cs b/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/Properties/AssemblyInfo.cs
index 87cbfb7803..0b99ff133d 100644
--- a/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/Properties/AssemblyInfo.cs
+++ b/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/Properties/AssemblyInfo.cs
@@ -42,7 +42,7 @@ using System.Runtime.CompilerServices;
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion ("1.0.*")]
+[assembly: AssemblyVersion ("1.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
diff --git a/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/UIThreadMonitorDaemon.csproj b/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/UIThreadMonitorDaemon.csproj
index 169c38bd31..33a6f086eb 100644
--- a/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/UIThreadMonitorDaemon.csproj
+++ b/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/UIThreadMonitorDaemon.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>UIThreadMonitorDaemon</RootNamespace>
<AssemblyName>UIThreadMonitorDaemon</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -37,4 +38,4 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj
index 69a7a8aefc..70532b3906 100644
--- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj
+++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.TextTemplating</RootNamespace>
<AssemblyName>MonoDevelop.TextTemplating</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -117,8 +118,6 @@
<Private>False</Private>
</ProjectReference>
</ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="..\..\..\..\md.targets" />
<ItemGroup>
<None Include="Templates\T4TemplateCSharp.xft.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -133,4 +132,5 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/addins/VBNetBinding/VBNetBinding.addin.xml b/main/src/addins/VBNetBinding/VBNetBinding.addin.xml
index 5deea28913..2a2575bcf5 100644
--- a/main/src/addins/VBNetBinding/VBNetBinding.addin.xml
+++ b/main/src/addins/VBNetBinding/VBNetBinding.addin.xml
@@ -51,7 +51,7 @@
</Extension>
<Extension path = "/MonoDevelop/Core/MimeTypes">
- <MimeType id="text/x-vb" _description="Visual Basic source code" icon="md-vb-file" isText="true">
+ <MimeType id="text/x-vb" _description="Visual Basic source code" icon="md-vb-file" isText="true" roslynName="Visual Basic">
<File pattern="*.vb" />
</MimeType>
</Extension>
diff --git a/main/src/addins/VBNetBinding/VBNetBinding.csproj b/main/src/addins/VBNetBinding/VBNetBinding.csproj
index e4858da922..7c3e1fed4e 100644
--- a/main/src/addins/VBNetBinding/VBNetBinding.csproj
+++ b/main/src/addins/VBNetBinding/VBNetBinding.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,13 +10,13 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.VBNetBinding</AssemblyName>
<RootNamespace>VBNetBinding</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\VBNetBinding</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>3</WarningLevel>
<Execution>
@@ -28,7 +29,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
- <OutputPath>..\..\..\build\AddIns\BackendBindings\</OutputPath>
+ <OutputPath>..\..\..\build\AddIns\VBNetBinding</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>3</WarningLevel>
<Execution>
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/MonoDevelop.VersionControl.Git.Tests.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/MonoDevelop.VersionControl.Git.Tests.csproj
index 2d2b01fe3b..8913155b17 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/MonoDevelop.VersionControl.Git.Tests.csproj
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/MonoDevelop.VersionControl.Git.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>MonoDevelop.VersionControl.Git.Tests</AssemblyName>
<TestRunnerCommand>..\..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/AssemblyInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/AssemblyInfo.cs
index 70b0a32308..bb247e23d4 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/AssemblyInfo.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/AssemblyInfo.cs
@@ -8,5 +8,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyDescription ("Git support for the Version Control Add-in")]
[assembly: AssemblyVersion ("2.6")]
[assembly: AssemblyCopyright ("LGPL")]
-
-[assembly:InternalsVisibleTo ("MonoDevelop.VersionControl.Git.Tests")]
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj
index 43f5ea8070..32d256c6d2 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.VersionControl.Git</RootNamespace>
<AssemblyName>MonoDevelop.VersionControl.Git</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -227,6 +228,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
+ <ItemGroup>
+ <InternalsVisibleTo Include="MonoDevelop.VersionControl.Git.Tests" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Choose>
<When Condition=" '$(Configuration)' == 'DebugMac' OR '$(Configuration)' == 'ReleaseMac' ">
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/MonoDevelop.VersionControl.Subversion.Tests.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/MonoDevelop.VersionControl.Subversion.Tests.csproj
index 1d3245425d..598af8a2fc 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/MonoDevelop.VersionControl.Subversion.Tests.csproj
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/MonoDevelop.VersionControl.Subversion.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>MonoDevelop.VersionControl.Subversion.Tests</AssemblyName>
<TestRunnerCommand>..\..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/AssemblyInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/AssemblyInfo.cs
index b27fed544b..e58febf58d 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/AssemblyInfo.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/AssemblyInfo.cs
@@ -49,5 +49,3 @@ using System.Runtime.CompilerServices;
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
-
-[assembly: InternalsVisibleTo ("MonoDevelop.VersionControl.Subversion.Tests")]
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj
index e078d74d74..d29c22aec5 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.VersionControl.Subversion.Unix</RootNamespace>
<AssemblyName>MonoDevelop.VersionControl.Subversion.Unix</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -72,7 +73,6 @@
<Compile Include="MonoDevelop.VersionControl.Subversion.Unix\LibSvnClient1.cs" />
<Compile Include="AddinInfo.cs" />
</ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="MonoDevelop.VersionControl.Subversion.Unix\" />
</ItemGroup>
@@ -116,6 +116,10 @@
<ItemGroup Condition=" '$(Configuration)' == 'DebugMac' Or '$(Configuration)' == 'ReleaseMac' ">
<NativeBinaries Include="..\..\..\..\external\sharpsvn-binary\mac\*.dylib" />
</ItemGroup>
+ <ItemGroup>
+ <InternalsVisibleTo Include="MonoDevelop.VersionControl.Subversion.Tests" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<Copy SourceFiles="@(NativeBinaries)" DestinationFolder="$(OutputPath)\" SkipUnchangedFiles="true" />
</Target>
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/AssemblyInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/AssemblyInfo.cs
index c6c941668e..64323cb4b5 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/AssemblyInfo.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/AssemblyInfo.cs
@@ -8,6 +8,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyDescription ("Subversion support for the Version Control Add-in")]
[assembly: AssemblyVersion ("2.6")]
[assembly: AssemblyCopyright ("LGPL")]
-[assembly: InternalsVisibleTo ("MonoDevelop.VersionControl.Subversion.Tests")]
-[assembly: InternalsVisibleTo ("MonoDevelop.VersionControl.Subversion.Unix")]
-[assembly: InternalsVisibleTo ("VersionControl.Subversion.Win32")]
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj
index 246c37e835..10a227fa6e 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.VersionControl.Subversion</AssemblyName>
<RootNamespace>MonoDevelop.VersionControl.Subversion</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -125,6 +126,11 @@
<LogicalName>gui.stetic</LogicalName>
</EmbeddedResource>
</ItemGroup>
+ <ItemGroup>
+ <InternalsVisibleTo Include="MonoDevelop.VersionControl.Subversion.Tests" />
+ <InternalsVisibleTo Include="MonoDevelop.VersionControl.Subversion.Unix" />
+ <InternalsVisibleTo Include="VersionControl.Subversion.Win32" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="MonoDevelop.VersionControl.Subversion\" />
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/AssemblyInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/AssemblyInfo.cs
index b2b45395ee..c84d95b3f6 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/AssemblyInfo.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/AssemblyInfo.cs
@@ -8,5 +8,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyDescription ("A MonoDevelop addin for using version control systems like Subversion")]
[assembly: AssemblyVersion ("2.6")]
[assembly: AssemblyCopyright ("LGPL")]
-[assembly: InternalsVisibleTo ("UnitTests")]
-[assembly: InternalsVisibleTo ("MonoDevelop.MacDev")]
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj
index 4a0a935002..9713123b10 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.VersionControl</AssemblyName>
<RootNamespace>MonoDevelop.VersionControl</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -1257,5 +1258,9 @@
<ItemGroup>
<None Include="Makefile.am" />
</ItemGroup>
+ <ItemGroup>
+ <InternalsVisibleTo Include="UnitTests" />
+ <InternalsVisibleTo Include="MonoDevelop.MacDev" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/addins/VersionControl/Subversion.Win32.Tests/VersionControl.Subversion.Win32.Tests.csproj b/main/src/addins/VersionControl/Subversion.Win32.Tests/VersionControl.Subversion.Win32.Tests.csproj
index 77b130036b..835898083f 100644
--- a/main/src/addins/VersionControl/Subversion.Win32.Tests/VersionControl.Subversion.Win32.Tests.csproj
+++ b/main/src/addins/VersionControl/Subversion.Win32.Tests/VersionControl.Subversion.Win32.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>VersionControl.Subversion.Win32.Tests</AssemblyName>
<TestRunnerCommand>..\..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -69,4 +70,4 @@
<Private>False</Private>
</ProjectReference>
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/VersionControl/Subversion.Win32/Properties/AssemblyInfo.cs b/main/src/addins/VersionControl/Subversion.Win32/Properties/AssemblyInfo.cs
index 8756b9c88c..606e447e1b 100644
--- a/main/src/addins/VersionControl/Subversion.Win32/Properties/AssemblyInfo.cs
+++ b/main/src/addins/VersionControl/Subversion.Win32/Properties/AssemblyInfo.cs
@@ -36,5 +36,3 @@ using System.Runtime.CompilerServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyFileVersion ("1.0.0.0")]
-
-[assembly: InternalsVisibleTo ("VersionControl.Subversion.Win32.Tests")]
diff --git a/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj b/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj
index 73aeab1951..fbb6a181e0 100644
--- a/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj
+++ b/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,7 +11,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SubversionAddinWindows</RootNamespace>
<AssemblyName>SubversionAddinWindows</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
@@ -67,6 +68,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <InternalsVisibleTo Include="VersionControl.Subversion.Win32.Tests" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Include="SvnSharpClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="AddinInfo.cs" />
@@ -130,4 +134,4 @@
</None>
<None Include="packages.config" />
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Core.csproj b/main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Core.csproj
index 684358bdd9..68259ccc90 100644
--- a/main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Core.csproj
+++ b/main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Core.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -102,6 +103,11 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <InternalsVisibleTo Include="Microsoft.WindowsAPICodePack.Shell" />
+ <InternalsVisibleTo Include="Microsoft.WindowsAPICodePack.Sensors" />
+ <InternalsVisibleTo Include="Microsoft.WindowsAPICodePack.ShellExtensions" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Include="AppRestartRecovery\ApplicationRestartRecoveryManager.cs" />
<Compile Include="AppRestartRecovery\ApplicationRecoveryException.cs" />
<Compile Include="AppRestartRecovery\RecoveryData.cs" />
@@ -213,4 +219,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Properties/AssemblyInfo.cs b/main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Properties/AssemblyInfo.cs
index 58b5bbb2df..e1c4448640 100644
--- a/main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Properties/AssemblyInfo.cs
+++ b/main/src/addins/WindowsPlatform/WindowsAPICodePack/Core/Properties/AssemblyInfo.cs
@@ -18,11 +18,6 @@ using System.Resources;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-
-[assembly: InternalsVisibleTo("Microsoft.WindowsAPICodePack.Shell")]
-[assembly: InternalsVisibleTo("Microsoft.WindowsAPICodePack.Sensors")]
-[assembly: InternalsVisibleTo("Microsoft.WindowsAPICodePack.ShellExtensions")]
-
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
diff --git a/main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Properties/AssemblyInfo.cs b/main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Properties/AssemblyInfo.cs
index 8e20e57dc8..614547ce23 100644
--- a/main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Properties/AssemblyInfo.cs
+++ b/main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Properties/AssemblyInfo.cs
@@ -19,8 +19,6 @@ using System.Security;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-[assembly: InternalsVisibleTo("Microsoft.WindowsAPICodePack.ShellExtensions")]
-
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
@@ -40,5 +38,3 @@ using System.Security;
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: NeutralResourcesLanguageAttribute("en")]
-
-[assembly: InternalsVisibleTo("WindowsPlatform")]
diff --git a/main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Shell.csproj b/main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Shell.csproj
index d595f40f39..b1e2852773 100644
--- a/main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Shell.csproj
+++ b/main/src/addins/WindowsPlatform/WindowsAPICodePack/Shell/Shell.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -144,6 +145,10 @@
<Reference Include="System.Xaml" />
</ItemGroup>
<ItemGroup>
+ <InternalsVisibleTo Include="Microsoft.WindowsAPICodePack.ShellExtensions" />
+ <InternalsVisibleTo Include="WindowsPlatform" />
+ </ItemGroup>
+ <ItemGroup>
<Compile Include="Common\EnumUnknown.cs" />
<Compile Include="Common\EventHandlerExtensionMethods.cs" />
<Compile Include="Common\NativePoint.cs" />
@@ -384,4 +389,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.csproj b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.csproj
index c4ab55eb00..288cbe941b 100644
--- a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.csproj
+++ b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>WindowsPlatform</AssemblyName>
<RootNamespace>WindowsPlatform</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -324,4 +325,4 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/addins/Xml/MonoDevelop.Xml.csproj b/main/src/addins/Xml/MonoDevelop.Xml.csproj
index ecd57e0813..1725572060 100644
--- a/main/src/addins/Xml/MonoDevelop.Xml.csproj
+++ b/main/src/addins/Xml/MonoDevelop.Xml.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.Xml</AssemblyName>
<RootNamespace>MonoDevelop.Xml</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj b/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj
index 4124d68165..fde76feb46 100644
--- a/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj
+++ b/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<RootNamespace>MonoDevelop.Xml.Tests</RootNamespace>
<TestRunnerCommand>..\..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/core/MonoDevelop.Core/AssemblyInfo.cs b/main/src/core/MonoDevelop.Core/AssemblyInfo.cs
index 1a7c5318cd..44be4c463c 100644
--- a/main/src/core/MonoDevelop.Core/AssemblyInfo.cs
+++ b/main/src/core/MonoDevelop.Core/AssemblyInfo.cs
@@ -7,6 +7,4 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyTitle ("MonoDevelop Runtime")]
[assembly: AssemblyDescription ("Provides the core services of the MonoDevelop platform")]
[assembly: AssemblyVersion ("2.6")]
-[assembly: AssemblyCopyright ("MIT/X11")]
-
-[assembly: InternalsVisibleTo("UnitTests")]
+[assembly: AssemblyCopyright ("MIT/X11")] \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Core/BuildVariables.cs.in b/main/src/core/MonoDevelop.Core/BuildVariables.cs.in
index 69ee59eb5b..994969ab5f 100644
--- a/main/src/core/MonoDevelop.Core/BuildVariables.cs.in
+++ b/main/src/core/MonoDevelop.Core/BuildVariables.cs.in
@@ -5,6 +5,7 @@ namespace MonoDevelop
public const string Version = "@PACKAGE_VERSION@";
public const string VersionLabel = "@PACKAGE_VERSION_LABEL@";
public const string CompatVersion = "@COMPAT_ADDIN_VERSION@";
+ public const string FullVersion = "@FULL_VERSION@";
internal const string BuildLane = "@BUILD_LANE@";
}
diff --git a/main/src/core/MonoDevelop.Core/BuildVariables.gen.cs b/main/src/core/MonoDevelop.Core/BuildVariables.gen.cs
index 01bb67b9e4..1d7a34c18e 100644
--- a/main/src/core/MonoDevelop.Core/BuildVariables.gen.cs
+++ b/main/src/core/MonoDevelop.Core/BuildVariables.gen.cs
@@ -24,7 +24,9 @@ namespace Application
label = customLabel;
var txt = File.ReadAllText (Path.Combine (dir, "BuildVariables.cs.in"));
- txt = txt.Replace ("@PACKAGE_VERSION@", GetValue (lines, "Version"));
+ var buildInfoVersion = GetValue (lines, "Version");
+ txt = txt.Replace ("@PACKAGE_VERSION@", buildInfoVersion);
+ txt = txt.Replace ("@FULL_VERSION@", GetFullVersion(buildInfoVersion));
txt = txt.Replace ("@PACKAGE_VERSION_LABEL@", label);
txt = txt.Replace ("@COMPAT_ADDIN_VERSION@", GetValue (lines, "CompatVersion"));
txt = txt.Replace ("@BUILD_LANE@", Environment.GetEnvironmentVariable ("BUILD_LANE"));
@@ -36,6 +38,32 @@ namespace Application
var val = lines.First (li => li.StartsWith (key + "="));
return val.Substring (key.Length + 1);
}
+
+ static string GetFullVersion(string buildInfoVersion)
+ {
+ var version = new Version (buildInfoVersion);
+ var relId = GetReleaseId ();
+ if (relId != null && relId.Length >= 9) {
+ int rev;
+ int.TryParse (relId.Substring (relId.Length - 4), out rev);
+ version = new Version (Math.Max (version.Major, 0), Math.Max (version.Minor, 0), Math.Max (version.Build, 0), Math.Max (rev, 0));
+ }
+ return version.ToString();
+ }
+
+ static string GetReleaseId ()
+ {
+ var biFile = System.Reflection.Assembly.GetEntryAssembly ().Location;
+ biFile = Path.GetDirectoryName (biFile);
+ biFile = Path.Combine (biFile, "fullbuildinfo", "buildinfo");
+
+ if (File.Exists (biFile)) {
+ var line = File.ReadAllLines (biFile).Select (l => l.Split (':')).FirstOrDefault (a => a.Length > 1 && a [0].Trim () == "Release ID");
+ if (line != null)
+ return line [1].Trim ();
+ }
+ return null;
+ }
}
}
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MsNetTargetRuntime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MsNetTargetRuntime.cs
index fdfae7aa54..e2559fd01b 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MsNetTargetRuntime.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/MsNetTargetRuntime.cs
@@ -1,4 +1,4 @@
-//
+//
// MsNetTargetRuntime.cs
//
// Author:
@@ -153,6 +153,15 @@ namespace MonoDevelop.Core.Assemblies
public override string GetMSBuildBinPath (string toolsVersion)
{
+ //FIXME doing this properly involves COM now
+ var programFilesX86 = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86);
+ foreach (var edition in new[] { "Enterprise", "Professional", "Community" }) {
+ string path = Path.Combine (programFilesX86, "Microsoft Visual Studio", "2017", edition, "MSBuild", "15.0", "Bin");
+ if (File.Exists (Path.Combine (path, "MSBuild.exe"))) {
+ return path;
+ }
+ }
+
using (RegistryKey msb = Registry.LocalMachine.OpenSubKey (@"SOFTWARE\Microsoft\MSBuild\ToolsVersions\" + toolsVersion, false)) {
if (msb != null) {
string path = msb.GetValue ("MSBuildToolsPath") as string;
@@ -165,14 +174,7 @@ namespace MonoDevelop.Core.Assemblies
public override string GetMSBuildToolsPath (string toolsVersion)
{
- using (RegistryKey msb = Registry.LocalMachine.OpenSubKey (@"SOFTWARE\Microsoft\MSBuild\ToolsVersions\" + toolsVersion, false)) {
- if (msb != null) {
- string path = msb.GetValue ("MSBuildToolsPath") as string;
- if (path != null && Directory.Exists (path))
- return path;
- }
- return null;
- }
+ return GetMSBuildBinPath (toolsVersion);
}
public override string GetMSBuildExtensionsPath ()
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj
index 21442f0f1c..2a9b8dc5fb 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj
@@ -1,5 +1,6 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,8 +12,11 @@
<RootNamespace>MonoDevelop.Core</RootNamespace>
<BuildInfo>..\..\..\build\bin\buildinfo</BuildInfo>
<VcRevision>..\..\..\vcrevision</VcRevision>
+ <ConfigureScript>$(MSBuildProjectDirectory)\..\..\..\..\scripts\configure.cs</ConfigureScript>
+ <ConfigureScriptExe>$(MSBuildProjectDirectory)\..\..\..\..\scripts\configure.exe</ConfigureScriptExe>
+ <FullBuildInfo>fullbuildinfo</FullBuildInfo>
<MonoLauncher Condition=" '$(VisualStudioVersion)' == '' ">mono </MonoLauncher>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<Choose>
<When Condition=" Exists('c:\Program Files\Git\bin\git.exe') ">
@@ -88,76 +92,140 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="Mono.Posix" />
+ <Reference Include="System.Composition.AttributedModel, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\System.Composition.AttributedModel.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Composition.Hosting, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\System.Composition.Hosting.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Composition.Runtime, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\System.Composition.Runtime.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Composition.TypedParts, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\System.Composition.TypedParts.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll</HintPath>
+ </Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
- <Reference Include="monodoc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
- </Reference>
+ <Reference Include="monodoc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Web" />
<Reference Include="System.ServiceModel" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Build.Engine" />
<Reference Include="Microsoft.Build" />
- <Reference Include="Microsoft.Build.Utilities.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <Reference Include="System.Reflection.Metadata">
- <HintPath>..\..\..\external\roslyn\Binaries\Release\System.Reflection.Metadata.dll</HintPath>
- <Private>False</Private>
- </Reference>
+ <Reference Include="Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
- <Reference Include="System.Collections.Immutable">
- <HintPath>..\..\..\packages\System.Collections.Immutable.1.1.37\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
- <Reference Include="System.Composition.AttributedModel">
- <HintPath>..\..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll</HintPath>
+ <Reference Include="mscorlib" />
+ <Reference Include="System.ComponentModel.Composition" />
+ <Reference Include="System.Numerics" />
+ <Reference Include="Microsoft.CodeAnalysis.Elfie">
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Elfie.1.0.0-rc9\lib\net45\Microsoft.CodeAnalysis.Elfie.dll</HintPath>
</Reference>
<Reference Include="System.Composition.Convention">
- <HintPath>..\..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll</HintPath>
+ </Reference>
+ <Reference Include="System.AppContext">
+ <HintPath>..\..\..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Console">
+ <HintPath>..\..\..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Diagnostics.FileVersionInfo">
+ <HintPath>..\..\..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Diagnostics.StackTrace">
+ <HintPath>..\..\..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.Compression">
+ <HintPath>..\..\..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.FileSystem.Primitives">
+ <HintPath>..\..\..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.FileSystem">
+ <HintPath>..\..\..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.Encoding">
+ <HintPath>..\..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
</Reference>
- <Reference Include="System.Composition.Hosting">
- <HintPath>..\..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll</HintPath>
+ <Reference Include="System.Security.Cryptography.Primitives">
+ <HintPath>..\..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
</Reference>
- <Reference Include="System.Composition.Runtime">
- <HintPath>..\..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll</HintPath>
+ <Reference Include="System.Security.Cryptography.Algorithms">
+ <HintPath>..\..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath>
</Reference>
- <Reference Include="System.Composition.TypedParts">
- <HintPath>..\..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll</HintPath>
+ <Reference Include="System.Security.Cryptography.X509Certificates">
+ <HintPath>..\..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
</Reference>
+ <Reference Include="System.Text.Encoding.CodePages">
+ <HintPath>..\..\..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Threading.Thread">
+ <HintPath>..\..\..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ValueTuple">
+ <HintPath>..\..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.ReaderWriter">
+ <HintPath>..\..\..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.XmlDocument">
+ <HintPath>..\..\..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.XPath">
+ <HintPath>..\..\..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.XPath.XDocument">
+ <HintPath>..\..\..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Runtime.InteropServices.RuntimeInformation">
+ <HintPath>..\..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Collections.Immutable">
+ <HintPath>..\..\..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
+ </Reference>
+ <!-- NOTE: NuGet installs the PCL version of System.Reflection.Metadata by default but it is windows-specific. Use netstandard version instead. -->
<Reference Include="System.Reflection.Metadata">
- <HintPath>..\..\..\packages\System.Reflection.Metadata.1.2.0\lib\portable-net45+win8\System.Reflection.Metadata.dll</HintPath>
+ <HintPath>..\..\..\packages\System.Reflection.Metadata.1.4.2\lib\netstandard1.1\System.Reflection.Metadata.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis">
- <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp">
- <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.CSharp.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.CSharp.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.VisualBasic">
- <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.VisualBasic.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.VisualBasic.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.Workspaces.Desktop">
- <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.0.0\lib\net46\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
+ <Private>False</Private>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.Workspaces">
- <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.0.0\lib\net46\Microsoft.CodeAnalysis.Workspaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp.Workspaces">
- <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.Workspaces.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Workspaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces">
- <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.Features">
- <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Features.1.3.2\lib\net45\Microsoft.CodeAnalysis.Features.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Features.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.Features.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp.Features">
- <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.CSharp.Features.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.Features.dll</HintPath>
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.CSharp.Features.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Features.dll</HintPath>
</Reference>
- <Reference Include="Newtonsoft.Json">
- <HintPath>..\..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ <Reference Include="Microsoft.CodeAnalysis.VisualBasic.Features">
+ <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.VisualBasic.Features.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.Features.dll</HintPath>
+ <Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -649,10 +717,6 @@
<None Include="MSBuild\CodeSharing.CSharp.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="..\..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.Desktop.dll">
- <Link>Microsoft.CodeAnalysis.Workspaces.Desktop.dll</Link>
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MonoDevelop.Core.addin.xml">
@@ -684,7 +748,6 @@
<LogicalName>framework_NET_4_0_client.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\..\external\cecil\Mono.Cecil.csproj">
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
@@ -717,15 +780,19 @@
</Content>
</ItemGroup>
<ItemGroup>
- <Folder Include="MonoDevelop.Projects.SharedAssetsProjects\" />
- <Folder Include="MSBuild\" />
+ <InternalsVisibleTo Include="UnitTests" />
</ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild" Inputs="BuildVariables.cs.in; $(MSBuildProjectDirectory)\..\..\..\..\version.config" Outputs="BuildVariables.cs">
+ <MakeDir Directories="$(FullBuildInfo)" />
+ <Csc Sources="$(ConfigureScript)" OutputAssembly="$(ConfigureScriptExe)" ToolExe="$(CscToolExe)" ToolPath="$(CscToolPath)" Condition="!Exists('$(ConfigureScriptExe)')" />
+ <Exec Command="$(MonoLauncher)$(ConfigureScriptExe) gen-buildinfo $(FullBuildInfo)" WorkingDirectory="$(MSBuildProjectDirectory)" />
<Csc Sources="BuildVariables.gen.cs" OutputAssembly="BuildVariables.gen.exe" ToolExe="$(CscToolExe)" ToolPath="$(CscToolPath)" />
<Exec Command="$(MonoLauncher)$(MSBuildProjectDirectory)\BuildVariables.gen.exe ." WorkingDirectory="$(MSBuildProjectDirectory)" />
<Delete Files="BuildVariables.gen.exe" />
<MakeDir Directories="$(OutputPath)" />
<Exec Command="&quot;$(Git)&quot; rev-parse HEAD &gt; $(BuildInfo)" WorkingDirectory="$(MSBuildProjectDirectory)" IgnoreExitCode="True" />
<Exec Command="&quot;$(Git)&quot; rev-parse HEAD &gt; $(VcRevision)" WorkingDirectory="$(MSBuildProjectDirectory)" IgnoreExitCode="True" />
+ <RemoveDir Directories="$(FullBuildInfo)" />
</Target>
-</Project>
+</Project> \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs
index 238c249d2c..35d046c7f4 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs
@@ -85,6 +85,7 @@ namespace MonoDevelop.Projects.MSBuild
public MSBuildItem Item;
public string Include;
public Regex ExcludeRegex;
+ public bool Condition;
}
#region implemented abstract members of MSBuildEngine
@@ -411,7 +412,7 @@ namespace MonoDevelop.Projects.MSBuild
}
}
} else if (IsWildcardInclude (include)) {
- project.GlobIncludes.Add (new GlobInfo { Item = item, Include = include, ExcludeRegex = excludeRegex });
+ project.GlobIncludes.Add (new GlobInfo { Item = item, Include = include, ExcludeRegex = excludeRegex, Condition = trueCond });
foreach (var eit in ExpandWildcardFilePath (project, context, item, include)) {
if (excludeRegex != null && excludeRegex.IsMatch (eit.Include))
continue;
@@ -1222,7 +1223,7 @@ namespace MonoDevelop.Projects.MSBuild
{
var pi = (ProjectInfo)projectInstance;
string filePath = MSBuildProjectService.FromMSBuildPath (pi.Project.BaseDirectory, include);
- foreach (var g in pi.GlobIncludes) {
+ foreach (var g in pi.GlobIncludes.Where (g => g.Condition)) {
if (IsIncludedInGlob (g.Include, pi.Project.BaseDirectory, filePath)) {
if (g.ExcludeRegex != null) {
if (g.ExcludeRegex.IsMatch (include))
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs
index 5b45cb2ddf..a0fab2b64d 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs
@@ -1,4 +1,4 @@
-// MSBuildProjectService.cs
+// MSBuildProjectService.cs
//
// Author:
// Lluis Sanchez Gual <lluis@novell.com>
@@ -1025,10 +1025,8 @@ namespace MonoDevelop.Projects.MSBuild
static string GetNewestInstalledToolsVersion (TargetRuntime runtime, bool requiresMicrosoftBuild, out string binDir)
{
string [] supportedToolsVersions;
- if ((requiresMicrosoftBuild || Runtime.Preferences.BuildWithMSBuild) && !Platform.IsWindows)
+ if (requiresMicrosoftBuild || Runtime.Preferences.BuildWithMSBuild || Platform.IsWindows)
supportedToolsVersions = new [] { "15.0"};
- else if (Platform.IsWindows)
- supportedToolsVersions = new [] { "15.0", "14.0", "12.0", "4.0" };
else
supportedToolsVersions = new [] { "14.0", "12.0", "4.0" };
@@ -1207,7 +1205,7 @@ namespace MonoDevelop.Projects.MSBuild
(version >= new Version (4, 0) && runtime is MsNetTargetRuntime);
if (useMicrosoftBuild) {
- toolsVersion = "dotnet." + (version >= new Version (15, 0) ? "14.1" : toolsVersion);
+ toolsVersion = "dotnet." + toolsVersion;
}
var exe = builderDir.Combine (toolsVersion, "MonoDevelop.Projects.Formats.MSBuild.exe");
@@ -1272,7 +1270,10 @@ namespace MonoDevelop.Projects.MSBuild
GetNewestInstalledToolsVersion (runtime, true, out binDir);
// This is required for MSBuild to properly load the searchPaths element (@radical knows why)
- SetMSBuildConfigProperty (toolset, "MSBuildBinPath", binDir, false, true);
+ SetMSBuildConfigProperty (toolset, "MSBuildBinPath", binDir, false, true);
+
+ //this must match MSBuildBinPath w/MSBuild15
+ SetMSBuildConfigProperty (toolset, "MSBuildToolsPath", binDir, false, true);
var projectImportSearchPaths = doc.Root.Elements ("msbuildToolsets").FirstOrDefault ()?.Elements ("toolset")?.FirstOrDefault ()?.Element ("projectImportSearchPaths");
if (projectImportSearchPaths != null) {
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
index cac4fec3b8..70054e12f5 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
@@ -562,30 +562,43 @@ namespace MonoDevelop.Projects
return results.ToArray ();
}
- bool evaluatedCoreCompileDependencies;
- readonly TaskCompletionSource<ProjectFile[]> evaluatedCompileItemsTask = new TaskCompletionSource<ProjectFile[]> ();
+ object evaluatedCompileItemsLock = new object ();
+ string evaluatedCompileItemsConfiguration;
+ TaskCompletionSource<ProjectFile[]> evaluatedCompileItemsTask;
/// <summary>
/// Gets the list of files that are included as Compile items from the evaluation of the CoreCompile dependecy targets
/// </summary>
async Task<ProjectFile[]> GetCompileItemsFromCoreCompileDependenciesAsync (ProgressMonitor monitor, ConfigurationSelector configuration)
{
- ProjectFile[] result = null;
- lock (evaluatedCompileItemsTask) {
- if (!evaluatedCoreCompileDependencies) {
- result = new ProjectFile[0];
- evaluatedCoreCompileDependencies = true;
+ var config = configuration != null ? GetConfiguration (configuration) : DefaultConfiguration;
+ if (config == null)
+ return new ProjectFile [0];
+
+ // Check if there is already a task for getting the items for the provided configuration
+
+ TaskCompletionSource<ProjectFile []> currentTask = null;
+ bool startTask = false;
+
+ lock (evaluatedCompileItemsLock) {
+ if (evaluatedCompileItemsConfiguration != config.Id) {
+ // The configuration changed or query not yet done
+ evaluatedCompileItemsConfiguration = config.Id;
+ evaluatedCompileItemsTask = new TaskCompletionSource<ProjectFile []> ();
+ startTask = true;
}
+ currentTask = evaluatedCompileItemsTask;
}
- if (result != null) {
+ if (startTask) {
var coreCompileDependsOn = sourceProject.EvaluatedProperties.GetValue<string> ("CoreCompileDependsOn");
if (string.IsNullOrEmpty (coreCompileDependsOn)) {
- evaluatedCompileItemsTask.SetResult (new ProjectFile [0]);
- return evaluatedCompileItemsTask.Task.Result;
+ currentTask.SetResult (new ProjectFile [0]);
+ return currentTask.Task.Result;
}
+ ProjectFile [] result = null;
var dependsList = string.Join (";", coreCompileDependsOn.Split (new [] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select (s => s.Trim ()).Where (s => s.Length > 0));
try {
// evaluate the Compile targets
@@ -602,10 +615,17 @@ namespace MonoDevelop.Projects
} catch (Exception ex) {
LoggingService.LogInternalError (string.Format ("Error running target {0}", dependsList), ex);
}
- evaluatedCompileItemsTask.SetResult (result);
+ currentTask.SetResult (result ?? new ProjectFile [0]);
}
- return await evaluatedCompileItemsTask.Task;
+ return await currentTask.Task;
+ }
+
+ void ResetCachedCompileItems ()
+ {
+ lock (evaluatedCompileItemsLock) {
+ evaluatedCompileItemsConfiguration = null;
+ }
}
ProjectFile CreateProjectFile (IMSBuildItemEvaluated item)
@@ -3542,6 +3562,8 @@ namespace MonoDevelop.Projects
IsReevaluating = false;
}
+ ResetCachedCompileItems ();
+
if (!oldCapabilities.SetEquals (projectCapabilities))
NotifyProjectCapabilitiesChanged ();
diff --git a/main/src/core/MonoDevelop.Core/packages.config b/main/src/core/MonoDevelop.Core/packages.config
index 1a54b88027..d692f1fae2 100644
--- a/main/src/core/MonoDevelop.Core/packages.config
+++ b/main/src/core/MonoDevelop.Core/packages.config
@@ -1,31 +1,73 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis" version="1.3.2" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis.Common" version="1.3.2" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis.CSharp" version="1.3.2" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis.CSharp.Features" version="1.3.2" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="1.3.2" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis.Features" version="1.3.2" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis.VisualBasic" version="1.3.2" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis.VisualBasic.Workspaces" version="1.3.2" targetFramework="net45" />
- <package id="Microsoft.CodeAnalysis.Workspaces.Common" version="1.3.2" targetFramework="net45" />
- <package id="Microsoft.Composition" version="1.0.27" targetFramework="net45" />
+ <package id="ManagedEsent" version="1.9.4" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.Analyzers" version="1.2.0-beta2" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.Common" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.CSharp" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.CSharp.Features" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.Elfie" version="1.0.0-rc9" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.Features" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.VisualBasic" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.VisualBasic.Features" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.VisualBasic.Workspaces" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.CodeAnalysis.Workspaces.Common" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.Composition" version="1.0.30" targetFramework="net461" />
+ <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
- <package id="System.Collections" version="4.0.0" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.37" targetFramework="portable45-net45+win8" />
- <package id="System.Diagnostics.Debug" version="4.0.0" targetFramework="net45" />
- <package id="System.Globalization" version="4.0.0" targetFramework="net45" />
- <package id="System.Linq" version="4.0.0" targetFramework="net45" />
- <package id="System.Reflection.Metadata" version="1.2.0" targetFramework="net45" />
- <package id="System.Resources.ResourceManager" version="4.0.0" targetFramework="net45" />
- <package id="System.Runtime" version="4.0.0" targetFramework="net45" />
- <package id="System.Runtime.Extensions" version="4.0.0" targetFramework="net45" />
- <package id="System.Threading" version="4.0.0" targetFramework="net45" />
<package id="Microsoft.VisualStudio.CoreUtility" version="15.0.26201" targetFramework="net45" />
<package id="Microsoft.VisualStudio.Text.Data" version="15.0.26201" targetFramework="net45" />
<package id="Microsoft.VisualStudio.Text.Logic" version="15.0.26201" targetFramework="net45" />
<package id="Microsoft.VisualStudio.Text.UI" version="15.0.26201" targetFramework="net45" />
<package id="Microsoft.VisualStudio.Language.StandardClassification" version="15.0.26201" targetFramework="net45" />
+ <package id="System.AppContext" version="4.3.0" targetFramework="net461" />
+ <package id="System.Collections" version="4.3.0" targetFramework="net461" />
+ <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" />
+ <package id="System.Collections.Immutable" version="1.3.1" targetFramework="net461" />
+ <package id="System.Composition.AttributedModel" version="1.0.31" targetFramework="net461" />
+ <package id="System.Composition.Hosting" version="1.0.31" targetFramework="net461" />
+ <package id="System.Composition.Runtime" version="1.0.31" targetFramework="net461" />
+ <package id="System.Composition.TypedParts" version="1.0.31" targetFramework="net461" />
+ <package id="System.Console" version="4.3.0" targetFramework="net461" />
+ <package id="System.Diagnostics.Contracts" version="4.3.0" targetFramework="net461" />
+ <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
+ <package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net461" />
+ <package id="System.Diagnostics.StackTrace" version="4.3.0" targetFramework="net461" />
+ <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net461" />
+ <package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net461" />
+ <package id="System.Globalization" version="4.3.0" targetFramework="net461" />
+ <package id="System.IO.Compression" version="4.3.0" targetFramework="net461" />
+ <package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" />
+ <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
+ <package id="System.Linq" version="4.3.0" targetFramework="net461" />
+ <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
+ <package id="System.Linq.Parallel" version="4.3.0" targetFramework="net461" />
+ <package id="System.ObjectModel" version="4.3.0" targetFramework="net461" />
+ <package id="System.Reflection" version="4.3.0" targetFramework="net461" />
+ <package id="System.Reflection.Metadata" version="1.4.2" targetFramework="net461" />
+ <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" />
+ <package id="System.Runtime" version="4.3.0" targetFramework="net461" />
+ <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
+ <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" />
+ <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" />
+ <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net461" />
+ <package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" />
+ <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
+ <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
+ <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" />
+ <package id="System.Text.Encoding" version="4.3.0" targetFramework="net461" />
+ <package id="System.Text.Encoding.CodePages" version="4.3.0" targetFramework="net461" />
+ <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net461" />
+ <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net461" />
+ <package id="System.Threading" version="4.3.0" targetFramework="net461" />
+ <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net461" />
+ <package id="System.Threading.Tasks.Parallel" version="4.3.0" targetFramework="net461" />
+ <package id="System.Threading.Thread" version="4.3.0" targetFramework="net461" />
+ <package id="System.ValueTuple" version="4.3.0" targetFramework="net461" />
+ <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net461" />
+ <package id="System.Xml.XDocument" version="4.3.0" targetFramework="net461" />
+ <package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="net461" />
+ <package id="System.Xml.XPath" version="4.3.0" targetFramework="net461" />
+ <package id="System.Xml.XPath.XDocument" version="4.3.0" targetFramework="net461" />
</packages> \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Ide/AssemblyInfo.cs b/main/src/core/MonoDevelop.Ide/AssemblyInfo.cs
index bb0a8be3af..8ffb3a79e8 100644
--- a/main/src/core/MonoDevelop.Ide/AssemblyInfo.cs
+++ b/main/src/core/MonoDevelop.Ide/AssemblyInfo.cs
@@ -8,31 +8,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyDescription ("The MonoDevelop IDE application.")]
[assembly: AssemblyVersion ("2.6")]
[assembly: AssemblyCopyright ("LGPL")]
-
-[assembly: InternalsVisibleTo("MacPlatform")]
-[assembly: InternalsVisibleTo("WindowsPlatform")]
-[assembly: InternalsVisibleTo("MonoDevelop.Debugger")]
-[assembly: InternalsVisibleTo("MonoDevelop.DesignerSupport")]
-[assembly: InternalsVisibleTo("Ide.Tests")]
-[assembly: InternalsVisibleTo("UnitTests")]
-[assembly: InternalsVisibleTo("MonoDevelop.SourceEditor")]
-[assembly: InternalsVisibleTo("Xamarin.OSXEditor")]
-[assembly: InternalsVisibleTo("MonoDevelop.Refactoring")]
-[assembly: InternalsVisibleTo("MonoDevelop.CSharpBinding")]
-[assembly: InternalsVisibleTo ("FSharpBinding")]
-[assembly: InternalsVisibleTo("MonoDevelop.Xml")]
-[assembly: InternalsVisibleTo("MonoDevelop.AspNet")]
-[assembly: InternalsVisibleTo("Xamarin.Ide")]
-[assembly: InternalsVisibleTo("MonoDevelop.SourceEditor")]
-[assembly: InternalsVisibleTo("MonoDevelop.SourceEditor2")]
-[assembly: InternalsVisibleTo("MonoDevelop.AssemblyBrowser")]
-[assembly: InternalsVisibleTo("MonoDevelop.AspNet")]
-[assembly: InternalsVisibleTo("Xamarin.Sketches")]
-[assembly: InternalsVisibleTo("MonoDevelop.CSharpBinding.AspNet")]
-[assembly: InternalsVisibleTo("MonoDevelop.GtkCore")]
-[assembly: InternalsVisibleTo("MonoDevelop.PackageManagement")]
-[assembly: InternalsVisibleTo("Xamarin.Forms.Addin.Tests")]
-[assembly: InternalsVisibleTo("MonoDevelop.Packaging")]
-[assembly: InternalsVisibleTo("MonoDevelop.Packaging.Tests")]
-[assembly: InternalsVisibleTo ("MonoDevelop.FSharp.Tests")]
-[assembly: InternalsVisibleTo ("MonoDevelop.VBNetBinding")]
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs
index 0cb55e0c0d..1e5ea75dcf 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs
@@ -34,6 +34,7 @@ using MonoDevelop.Ide.Gui;
using MonoDevelop.Core.Text;
using MonoDevelop.Ide.TypeSystem;
using MonoDevelop.Ide.CodeCompletion;
+using Roslyn.Utilities;
using MonoDevelop.Ide;
namespace MonoDevelop.Components.MainToolbar
@@ -48,7 +49,7 @@ namespace MonoDevelop.Components.MainToolbar
{
if (IdeApp.ProjectOperations.CurrentSelectedSolution != null)
searchResultCallback.ReportResult (new SearchInSolutionSearchResult (pattern));
- return SpecializedTasks.EmptyTask;
+ return Task.CompletedTask;
}
//public override Task<ISearchDataSource> GetResults (SearchPopupSearchPattern searchPattern, int resultsCount, CancellationToken token)
@@ -99,4 +100,4 @@ namespace MonoDevelop.Components.MainToolbar
}
}
}
-} \ No newline at end of file
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs
index 40e4cfaa3b..f98341b450 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs
@@ -168,6 +168,15 @@ namespace MonoDevelop.Ide.Desktop
yield return mimeType;
}
}
+
+ public string GetMimeTypeForRoslynLanguage (string language)
+ {
+ foreach (MimeTypeNode mt in mimeTypeNodes) {
+ if (mt.RoslynName == language)
+ return mt.Id;
+ }
+ return null;
+ }
public Xwt.Drawing.Image GetIconForFile (string filename)
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/AutoSave.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/AutoSave.cs
index ebdda80162..ca8fba7763 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/AutoSave.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/AutoSave.cs
@@ -25,6 +25,7 @@
// THE SOFTWARE.
using System;
+using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Threading;
@@ -32,6 +33,7 @@ using MonoDevelop.Core;
using Gtk;
using MonoDevelop.Core.Text;
using System.Threading.Tasks;
+using System.Security.Cryptography;
namespace MonoDevelop.Ide.Editor
{
@@ -62,7 +64,17 @@ namespace MonoDevelop.Ide.Editor
{
if (fileName == null)
return null;
- return Path.Combine (autoSavePath, MonoDevelop.Ide.TypeSystem.PersistenceServiceFactory.GetMD5 (fileName) + ".sav");
+ return Path.Combine (autoSavePath, GetMD5 (fileName) + ".sav");
+ }
+
+ static MD5 md5 = MD5.Create ();
+ static string GetMD5 (string data)
+ {
+ var result = new StringBuilder();
+ foreach (var b in md5.ComputeHash (Encoding.ASCII.GetBytes (data))) {
+ result.Append(b.ToString("X2"));
+ }
+ return result.ToString();
}
/// <summary>
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Extensions/MimeTypeNode.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Extensions/MimeTypeNode.cs
index 97bdf6ae03..441ddf81d6 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Extensions/MimeTypeNode.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Extensions/MimeTypeNode.cs
@@ -51,7 +51,7 @@ namespace MonoDevelop.Ide.Extensions
[NodeAttribute (Required=false)]
protected bool isText;
-
+
IFileNameEvaluator regex;
public IconId Icon {
@@ -80,6 +80,12 @@ namespace MonoDevelop.Ide.Extensions
return baseType;
}
}
+
+ /// <summary>
+ /// The name used by Roslyn to identify this language.
+ /// </summary>
+ [NodeAttribute ("roslynName", "The name used by Roslyn to identify this language", Required=false)]
+ public string RoslynName { get; private set; }
interface IFileNameEvaluator
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs
index 0ee396931e..940340ec96 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs
@@ -45,8 +45,6 @@ using System.Linq;
using MonoDevelop.Ide.Tasks;
using System.Runtime.CompilerServices;
-[assembly:InternalsVisibleTo("MonoDevelop.UnitTesting")]
-
namespace MonoDevelop.Ide.Gui.Components
{
public partial class ExtensibleTreeView : Control, ICommandRouter
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceData.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceData.cs
index 04b331b609..5972596635 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceData.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceData.cs
@@ -37,7 +37,9 @@ using MonoDevelop.Ide.Gui.Components;
using MonoDevelop.Ide.TypeSystem;
using System.Linq;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Project = MonoDevelop.Projects.Project;
+using System.Threading;
namespace MonoDevelop.Ide.Gui.Pads.ClassPad
{
@@ -111,7 +113,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad
// bool nestedNs = builder.Options ["NestedNamespaces"];
bool publicOnly = builder.Options ["PublicApiOnly"];
- builder.AddChildren (namesp.GetAllTypes ()
+ builder.AddChildren (namesp.GetAllTypes (CancellationToken.None)
.Where (type => !publicOnly || type.DeclaredAccessibility == Accessibility.Public)
.Select (type => new ClassData (project, type)));
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
index 9b921a1779..58c8650d75 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
@@ -60,6 +60,7 @@ using MonoDevelop.Ide.Editor.Extension;
using System.Collections.Immutable;
using MonoDevelop.Ide.Editor.TextMate;
using MonoDevelop.Core.Assemblies;
+using Roslyn.Utilities;
namespace MonoDevelop.Ide.Gui
{
@@ -834,11 +835,11 @@ namespace MonoDevelop.Ide.Gui
doc = null;
}
if (doc != null)
- return SpecializedTasks.EmptyTask;
+ return Task.CompletedTask;
}
if (Editor == null) {
UnsubscibeAnalysisdocument ();
- return SpecializedTasks.EmptyTask;
+ return Task.CompletedTask;
}
if (Project != null && !IsUnreferencedSharedProject(Project)) {
UnsubscribeRoslynWorkspace ();
@@ -852,7 +853,7 @@ namespace MonoDevelop.Ide.Gui
lock (adhocProjectLock) {
var token = analysisDocumentSrc.Token;
if (adhocProject != null) {
- return SpecializedTasks.EmptyTask;
+ return Task.CompletedTask;
}
if (Editor != null) {
@@ -897,7 +898,7 @@ namespace MonoDevelop.Ide.Gui
}
}
}
- return SpecializedTasks.EmptyTask;
+ return Task.CompletedTask;
}
void UnsubscribeRoslynWorkspace ()
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/RunConfigurationsPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/RunConfigurationsPanel.cs
index 12809f43ed..6af421c8f6 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/RunConfigurationsPanel.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/RunConfigurationsPanel.cs
@@ -35,7 +35,6 @@ using MonoDevelop.Core;
using MonoDevelop.Projects.Policies;
using MonoDevelop.Components;
using System.Linq;
-using RefactoringEssentials.CSharp.Diagnostics;
using Xwt.Backends;
using Xwt;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/SolutionRunConfigurationsPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/SolutionRunConfigurationsPanel.cs
index 854c8ff2d6..1076e98024 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/SolutionRunConfigurationsPanel.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/SolutionRunConfigurationsPanel.cs
@@ -35,7 +35,6 @@ using MonoDevelop.Core;
using MonoDevelop.Projects.Policies;
using MonoDevelop.Components;
using System.Linq;
-using RefactoringEssentials.CSharp.Diagnostics;
using Xwt.Backends;
using Xwt;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/DocumentTrackingService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/DocumentTrackingService.cs
deleted file mode 100644
index 057f415135..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/DocumentTrackingService.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis;
-using System.Composition;
-
-namespace MonoDevelop.Ide.TypeSystem
-{
- //MD is added to name to make it clear this is not IDocumentTrackingService from Microsoft.CodeAnalyis.Features.dll
- //But it does mimic it's behavior
- interface IMDDocumentTrackingService : IWorkspaceService
- {
- event EventHandler<DocumentId> ActiveDocumentChanged;
-
- DocumentId GetActiveDocument ();
- }
-
-// [ExportWorkspaceServiceFactory (typeof(IMDDocumentTrackingService), ServiceLayer.Host), Shared]
- class MonoDevelopDocumentTrackingServiceFactory : IWorkspaceServiceFactory
- {
- private IMDDocumentTrackingService _singleton;
-
- public IWorkspaceService CreateService (HostWorkspaceServices workspaceServices)
- {
- return _singleton ?? (_singleton = new MonoDevelopDocumentTrackingService ());
- }
-
- public class MonoDevelopDocumentTrackingService : IMDDocumentTrackingService
- {
- public MonoDevelopDocumentTrackingService ()
- {
- if (IdeApp.IsInitialized)
- IdeApp.Workbench.ActiveDocumentChanged += MonoDevelop_Ide_IdeApp_Workbench_ActiveDocumentChanged;
- }
-
- #region IDocumentTrackingService implementation
-
- public event EventHandler<DocumentId> ActiveDocumentChanged;
-
- public DocumentId GetActiveDocument ()
- {
- var document = IdeApp.Workbench?.ActiveDocument;
- if (document == null)
- return null;
- return TypeSystemService.GetDocumentId (document.Project, document.FileName);
- }
-
- #endregion
-
- void MonoDevelop_Ide_IdeApp_Workbench_ActiveDocumentChanged (object sender, EventArgs e)
- {
- ActiveDocumentChanged?.Invoke (null, GetActiveDocument ());
- }
- }
- }
-}
-
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/EditorNotificationServiceFactory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/EditorNotificationServiceFactory.cs
new file mode 100644
index 0000000000..317624b1e7
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/EditorNotificationServiceFactory.cs
@@ -0,0 +1,84 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+// Derived from https://github.com/dotnet/roslyn/blob/master/src/EditorFeatures/Core/Implementation/Notification/EditorNotificationServiceFactory.cs
+
+using System;
+using System.Composition;
+using Microsoft.CodeAnalysis.Host;
+using Microsoft.CodeAnalysis.Host.Mef;
+using Microsoft.CodeAnalysis.Notification;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.Ide.TypeSystem
+{
+ [ExportWorkspaceServiceFactory (typeof (INotificationService), ServiceLayer.Editor)]
+ [Shared]
+ internal class EditorNotificationServiceFactory : IWorkspaceServiceFactory
+ {
+ private static object s_gate = new object ();
+
+ private static EditorDialogService s_singleton;
+
+ public IWorkspaceService CreateService (HostWorkspaceServices workspaceServices)
+ {
+ lock (s_gate) {
+ if (s_singleton == null) {
+ s_singleton = new EditorDialogService ();
+ }
+ }
+
+ return s_singleton;
+ }
+
+ private class EditorDialogService : INotificationService, INotificationServiceCallback
+ {
+
+ /// <summary>
+ /// For testing purposes only. If non-null, this callback will be invoked instead of showing a dialog.
+ /// </summary>
+ public Action<string, string, NotificationSeverity> NotificationCallback { get; set; }
+
+ public void SendNotification (
+ string message,
+ string title = null,
+ NotificationSeverity severity = NotificationSeverity.Warning)
+ {
+ var callback = NotificationCallback;
+ if (callback != null) {
+ // invoke the callback
+ callback (message, title, severity);
+ } else {
+ var image = SeverityToImage (severity);
+ MessageService.GenericAlert (image, title, message, AlertButton.Ok);
+ }
+ }
+
+ public bool ConfirmMessageBox (
+ string message,
+ string title = null,
+ NotificationSeverity severity = NotificationSeverity.Warning)
+ {
+ var callback = NotificationCallback;
+ if (callback != null) {
+ // invoke the callback and assume 'Yes' was clicked. Since this is a test-only scenario, assuming yes should be fine.
+ callback (message, title, severity);
+ return true;
+ } else {
+ var image = SeverityToImage (severity);
+ return MessageService.GenericAlert (image, title, message, AlertButton.Yes, AlertButton.No) == AlertButton.Yes;
+ }
+ }
+
+ private static IconId SeverityToImage (NotificationSeverity severity)
+ {
+ switch (severity) {
+ case NotificationSeverity.Information:
+ return Gui.Stock.Information;
+ case NotificationSeverity.Warning:
+ return Gui.Stock.Warning;
+ default:
+ return Gui.Stock.Error;
+ }
+ }
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/GlobalOptionPersister.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/GlobalOptionPersister.cs
new file mode 100644
index 0000000000..ffb2301e6b
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/GlobalOptionPersister.cs
@@ -0,0 +1,115 @@
+//
+// GlobalOptionPersister.cs
+//
+// Author:
+// Mikayla Hutchinson <m.j.hutchinson@gmail.com>
+//
+// Copyright (c) 2017 Microsoft Corp.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Composition;
+using System.Linq;
+using Microsoft.CodeAnalysis.Formatting;
+using Microsoft.CodeAnalysis.Options;
+using Microsoft.CodeAnalysis.Options.Providers;
+using MonoDevelop.Projects.Policies;
+using MonoDevelop.Ide.Gui.Content;
+
+namespace MonoDevelop.Ide.TypeSystem
+{
+ [Export(typeof(IOptionPersister))]
+ class GlobalOptionPersister : IOptionPersister
+ {
+ public bool TryFetch (OptionKey optionKey, out object value)
+ {
+ if (optionKey.Option == FormattingOptions.UseTabs) {
+ value = !GetTextPolicyForLanguage (optionKey.Language).TabsToSpaces;
+ return true;
+ }
+
+ if (optionKey.Option == FormattingOptions.TabSize) {
+ value = GetTextPolicyForLanguage (optionKey.Language).TabWidth;
+ return true;
+ }
+
+ if (optionKey.Option == FormattingOptions.IndentationSize) {
+ value = GetTextPolicyForLanguage (optionKey.Language).IndentWidth;
+ return true;
+ }
+
+ if (optionKey.Option == FormattingOptions.NewLine) {
+ value = GetTextPolicyForLanguage (optionKey.Language).EolMarker;
+ return true;
+ }
+
+ //use this for checking for options we could be handling
+ //PrintOptionKey(optionKey);
+
+ value = null;
+ return false;
+ }
+
+ TextStylePolicy GetTextPolicyForLanguage (string language)
+ {
+ var mimeChain = DesktopService.GetMimeTypeInheritanceChainForRoslynLanguage (language);
+ if (mimeChain == null) {
+ throw new Exception ($"Unknown Roslyn language {language}");
+ }
+ return PolicyService.GetDefaultPolicy<TextStylePolicy> (mimeChain);
+ }
+
+ public bool TryPersist (OptionKey optionKey, object value)
+ {
+ value = null;
+ return false;
+ }
+
+ static void PrintOptionKey (OptionKey optionKey)
+ {
+ Console.WriteLine ($"Name '{optionKey.Option.Name}' Language '{optionKey.Language}' LanguageSpecific'{optionKey.Option.IsPerLanguage}'");
+
+ var locations = optionKey.Option.StorageLocations;
+ if(locations.IsDefault) {
+ return;
+ }
+
+ foreach (var loc in locations) {
+ switch (loc) {
+ case RoamingProfileStorageLocation roaming:
+ Console.WriteLine ($" roaming: {roaming.GetKeyNameForLanguage (optionKey.Language)}");
+ break;
+ case LocalUserProfileStorageLocation local:
+ Console.WriteLine ($" local: {local.KeyName}");
+ break;
+ case EditorConfigStorageLocation edconf:
+ Console.WriteLine ($" editorconfig: {edconf.KeyName}");
+ break;
+ default:
+ Console.WriteLine ($" unknown: {loc.GetType()}");
+ break;
+ }
+ }
+ }
+
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs
index 36dc2df058..c2919e190e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs
@@ -161,8 +161,6 @@ namespace MonoDevelop.Ide.TypeSystem
readonly static DateTime NonExistentFile = new DateTime (1601, 1, 1);
- static Type docProviderType;
-
void CreateNewReference ()
{
timeStamp = File.GetLastWriteTimeUtc (path);
@@ -174,9 +172,7 @@ namespace MonoDevelop.Ide.TypeSystem
try {
string xmlName = Path.ChangeExtension (path, ".xml");
if (File.Exists (xmlName)) {
- if (docProviderType == null)
- docProviderType = Assembly.Load ("Microsoft.CodeAnalysis.Workspaces.Desktop").GetType ("Microsoft.CodeAnalysis.FileBasedXmlDocumentationProvider");
- provider = (DocumentationProvider)Activator.CreateInstance (docProviderType, xmlName);
+ provider = Microsoft.CodeAnalysis.XmlDocumentationProvider.CreateFromFile (xmlName);
}
} catch (Exception e) {
LoggingService.LogError ("Error while creating xml documentation provider for: " + path, e);
@@ -189,4 +185,4 @@ namespace MonoDevelop.Ide.TypeSystem
}
}
}
-} \ No newline at end of file
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopPersistentStorageServiceFactory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopPersistentStorageServiceFactory.cs
deleted file mode 100644
index 20cc1bed0b..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopPersistentStorageServiceFactory.cs
+++ /dev/null
@@ -1,254 +0,0 @@
-//
-// MonoDevelopPersistentStorageServiceFactory.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Composition;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using MonoDevelop.Core;
-using System.Text;
-using System.Collections.Generic;
-using System.Security.Cryptography;
-
-namespace MonoDevelop.Ide.TypeSystem
-{
-// [ExportWorkspaceServiceFactory(typeof(IPersistentStorageService), ServiceLayer.Host), Shared]
- class PersistenceServiceFactory : IWorkspaceServiceFactory
- {
- static readonly IPersistentStorage NoOpPersistentStorageInstance = new NoOpPersistentStorage();
- static readonly IPersistentStorageService singleton = new PersistentStorageService ();
-
- public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
- {
- return singleton;
- }
-
- static MD5 md5 = MD5.Create ();
- public static string GetMD5 (string data)
- {
- var result = new StringBuilder();
- foreach (var b in md5.ComputeHash (Encoding.ASCII.GetBytes (data))) {
- result.Append(b.ToString("X2"));
- }
- return result.ToString();
- }
-
- class NoOpPersistentStorage : IPersistentStorage
- {
- static Task<Stream> defaultStreamTask = Task.FromResult (default(Stream));
- static Task<bool> defaultBoolTask = Task.FromResult (false);
-
- public void Dispose()
- {
- }
-
- public Task<Stream> ReadStreamAsync(Document document, string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- return defaultStreamTask;
- }
-
- public Task<Stream> ReadStreamAsync(Project project, string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- return defaultStreamTask;
- }
-
- public Task<Stream> ReadStreamAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- return defaultStreamTask;
- }
-
- public Task<bool> WriteStreamAsync(Document document, string name, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
- {
- return defaultBoolTask;
- }
-
- public Task<bool> WriteStreamAsync(Project project, string name, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
- {
- return defaultBoolTask;
- }
-
- public Task<bool> WriteStreamAsync(string name, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
- {
- return defaultBoolTask;
- }
- }
-
- class PersistentStorageService : IPersistentStorageService
- {
- Dictionary<SolutionId, IPersistentStorage> storages = new Dictionary<SolutionId, IPersistentStorage> ();
- /// <summary>
- /// threshold to start to use esent (50MB)
- /// </summary>
- const int SolutionSizeThreshold = 50 * 1024 * 1024;
-
- public IPersistentStorage GetStorage(Solution solution)
- {
- // check whether the solution actually exist on disk
- if (!File.Exists(solution.FilePath))
- return NoOpPersistentStorageInstance;
-
- // get working folder path
- string workingFolderPath;
- lock (getStorageLock) {
- workingFolderPath = TypeSystemService.GetCacheDirectory (solution.FilePath, true);
- if (workingFolderPath == null) {
- // we don't have place to save. don't use caching
- return NoOpPersistentStorageInstance;
- }
- }
-
- return GetStorage(solution, workingFolderPath);
- }
-
- object getStorageLock = new object ();
- object storageLock = new object ();
-
- IPersistentStorage GetStorage (Solution solution, string workingFolderPath)
- {
- lock (storageLock) {
- IPersistentStorage storage;
- if (storages.TryGetValue (solution.Id, out storage))
- return storage;
- if (!SolutionSizeAboveThreshold (solution)) {
- storage = NoOpPersistentStorageInstance;
- } else {
- storage = new PersistentStorage (workingFolderPath);
- }
- storages.Add (solution.Id, storage);
- return storage;
- }
- }
-
- bool SolutionSizeAboveThreshold(Solution solution)
- {
- var size = SolutionSizeTracker.GetSolutionSizeAsync(solution.Workspace, solution.Id, CancellationToken.None).Result;
- return size > SolutionSizeThreshold;
- }
- }
-
- class PersistentStorage : IPersistentStorage
- {
- static Task<Stream> defaultStreamTask = Task.FromResult (default(Stream));
-
- string workingFolderPath;
-
- public PersistentStorage (string workingFolderPath)
- {
- this.workingFolderPath = workingFolderPath;
- }
-
- public void Dispose()
- {
- }
-
-
- const string dataFileExtension = ".dat";
-
- static string GetFileName (string name)
- {
- return GetMD5 (name) + dataFileExtension;
- }
-
- static string GetDocumentDataFileName (Document document, string name)
- {
- return GetMD5 (document.FilePath + "_" + name) + dataFileExtension;
- }
-
- static string GetProjectDataFileName (Project project, string name)
- {
- return GetMD5 (project.FilePath + "_" + name) + dataFileExtension;
- }
-
- public Task<Stream> ReadStreamAsync(Document document, string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- string fileName = Path.Combine (workingFolderPath, GetDocumentDataFileName (document, name));
- if (!File.Exists (fileName))
- return defaultStreamTask;
- return Task.FromResult ((Stream)File.OpenRead (fileName));
- }
-
- public Task<Stream> ReadStreamAsync(Project project, string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- string fileName = Path.Combine (workingFolderPath, GetProjectDataFileName (project, name));
- if (!File.Exists (fileName))
- return defaultStreamTask;
- return Task.FromResult ((Stream)File.OpenRead (fileName));
- }
-
- public Task<Stream> ReadStreamAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- string fileName = Path.Combine (workingFolderPath, GetFileName (name));
- if (!File.Exists (fileName))
- return defaultStreamTask;
- return Task.FromResult ((Stream)File.OpenRead (fileName));
- }
-
- public async Task<bool> WriteStreamAsync(Document document, string name, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
- {
- string fileName = Path.Combine (workingFolderPath, GetDocumentDataFileName (document, name));
- try {
- using (var newStream = File.OpenWrite (fileName)) {
- await stream.CopyToAsync (newStream, 81920, cancellationToken);
- }
- } catch (IOException) {
- return false;
- }
- return true;
- }
-
- public async Task<bool> WriteStreamAsync(Project project, string name, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
- {
- string fileName = Path.Combine (workingFolderPath, GetProjectDataFileName (project, name));
- try {
- using (var newStream = File.OpenWrite (fileName)) {
- await stream.CopyToAsync (newStream, 81920, cancellationToken);
- }
- } catch (IOException) {
- return false;
- }
- return true;
- }
-
- public async Task<bool> WriteStreamAsync(string name, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
- {
- string fileName = Path.Combine (workingFolderPath, GetFileName (name));
- try {
- using (var newStream = File.OpenWrite (fileName)) {
- await stream.CopyToAsync (newStream, 81920, cancellationToken);
- }
- } catch (IOException) {
- return false;
- }
- return true;
- }
- }
- }
-}
-
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopProjectCacheHostServiceFactory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopProjectCacheHostServiceFactory.cs
deleted file mode 100644
index e342a43861..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopProjectCacheHostServiceFactory.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis;
-using System.Composition;
-
-namespace MonoDevelop.Ide.TypeSystem
-{
-// [ExportWorkspaceServiceFactory(typeof(IProjectCacheHostService), ServiceLayer.Host)]
-// [Shared]
-/* internal partial class MonoDevelopProjectCacheHostServiceFactory : IWorkspaceServiceFactory
- {
- private const int ImplicitCacheTimeoutInMS = 10000;
-
- public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
- {
- // we support active document tracking only for visual studio workspace host.
- if (workspaceServices.Workspace is MonoDevelopWorkspace)
- {
- return GetMonoDevelopProjectCache(workspaceServices);
- }
-
- return GetMiscProjectCache(workspaceServices);
- }
-
- private static IWorkspaceService GetMiscProjectCache(HostWorkspaceServices workspaceServices)
- {
- var projectCacheService = new ProjectCacheService(workspaceServices.Workspace, ImplicitCacheTimeoutInMS);
-
- // Also clear the cache when the solution is cleared or removed.
- workspaceServices.Workspace.WorkspaceChanged += (s, e) =>
- {
- if (e.Kind == WorkspaceChangeKind.SolutionCleared || e.Kind == WorkspaceChangeKind.SolutionRemoved)
- {
- projectCacheService.ClearImplicitCache();
- }
- };
-
- return projectCacheService;
- }
-
- private static IWorkspaceService GetMonoDevelopProjectCache(HostWorkspaceServices workspaceServices)
- {
- var projectCacheService = new ProjectCacheService(workspaceServices.Workspace, ImplicitCacheTimeoutInMS);
-
- var documentTrackingService = workspaceServices.GetService<IMDDocumentTrackingService>();
-
- // Subscribe to events so that we can cache items from the active document's project
- var manager = new ActiveProjectCacheManager(documentTrackingService, projectCacheService);
-
- // TODO: Roslyn, when VS gets request from operating system that system virutal memory is low
- // CacheFlushRequested is invoked so caches are cleared to get some memory back...
-
- // Subscribe to requests to clear the cache
-// var workspaceCacheService = workspaceServices.GetService<IWorkspaceCacheService>();
-// if (workspaceCacheService != null)
-// {
-// workspaceCacheService.CacheFlushRequested += (s, e) => manager.Clear();
-// }
-
- // Also clear the cache when the solution is cleared or removed.
- workspaceServices.Workspace.WorkspaceChanged += (s, e) =>
- {
- if (e.Kind == WorkspaceChangeKind.SolutionCleared || e.Kind == WorkspaceChangeKind.SolutionRemoved)
- {
- manager.Clear();
- }
- };
-
- return projectCacheService;
- }
-
- private class ActiveProjectCacheManager
- {
- private readonly IMDDocumentTrackingService _documentTrackingService;
- private readonly ProjectCacheService _projectCacheService;
- private readonly object _guard = new object();
-
- private ProjectId _mostRecentActiveProjectId;
- private IDisposable _mostRecentCache;
-
- public ActiveProjectCacheManager(IMDDocumentTrackingService documentTrackingService, ProjectCacheService projectCacheService)
- {
- _documentTrackingService = documentTrackingService;
- _projectCacheService = projectCacheService;
-
- if (documentTrackingService != null)
- {
- documentTrackingService.ActiveDocumentChanged += UpdateCache;
- UpdateCache(null, documentTrackingService.GetActiveDocument());
- }
- }
-
- private void UpdateCache(object sender, DocumentId activeDocument)
- {
- lock (_guard)
- {
- if (activeDocument != null && activeDocument.ProjectId != _mostRecentActiveProjectId)
- {
- ClearMostRecentCache_NoLock();
- _mostRecentCache = _projectCacheService.EnableCaching(activeDocument.ProjectId);
- _mostRecentActiveProjectId = activeDocument.ProjectId;
- }
- }
- }
-
- public void Clear()
- {
- lock (_guard)
- {
- // clear most recent cache
- ClearMostRecentCache_NoLock();
-
- // clear implicit cache
- _projectCacheService.ClearImplicitCache();
- }
- }
-
- private void ClearMostRecentCache_NoLock()
- {
- if (_mostRecentCache != null)
- {
- _mostRecentCache.Dispose();
- _mostRecentCache = null;
- }
-
- _mostRecentActiveProjectId = null;
- }
- }
- }*/
-}
-
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTemporaryStorageServiceFactory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTemporaryStorageServiceFactory.cs
index 462561a653..d6c7ba5a6d 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTemporaryStorageServiceFactory.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTemporaryStorageServiceFactory.cs
@@ -1,28 +1,5 @@
-//
-// MonoDevelopTemporaryStorageServiceFactory.cs
-//
-// Author:
-// Mike Krüger <mkrueger@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
using System;
using System.Composition;
using System.IO;
@@ -39,35 +16,27 @@ using System.Collections.Generic;
namespace MonoDevelop.Ide.TypeSystem
{
- [ExportWorkspaceServiceFactory (typeof (ITemporaryStorageService), ServiceLayer.Host), Shared]
+ [ExportWorkspaceServiceFactory (typeof (ITemporaryStorageService), MonoDevelopWorkspace.ServiceLayer), Shared]
sealed class MonoDevelopTemporaryStorageServiceFactory : IWorkspaceServiceFactory
{
static IWorkspaceServiceFactory microsoftFactory;
static MonoDevelopTemporaryStorageServiceFactory ()
{
- if (Core.Platform.IsWindows || IsCompatibleMono()) {
- try {
- var asm = Assembly.Load ("Microsoft.CodeAnalysis.Workspaces.Desktop");
- if (asm != null) {
- var type = asm.GetType ("Microsoft.CodeAnalysis.Host.TemporaryStorageServiceFactory");
- if (type != null)
- microsoftFactory = Activator.CreateInstance (type) as IWorkspaceServiceFactory;
- }
- } catch (Exception e) {
- LoggingService.LogWarning ("MonoDevelopTemporaryStorageServiceFactory: Can't load microsoft temporary storage, fallback to default.", e);
- }
+ // On Mac, the mmap TemporaryStorageServiceFactory crashes the IDE by burning all available file handles
+ if (Core.Platform.IsMac) {
+ return;
}
- }
- // remove, if mono >= 4.3 is realeased as stable.
- static bool IsCompatibleMono ()
- {
try {
- var type = typeof (System.IO.MemoryMappedFiles.MemoryMappedViewAccessor);
- return type.GetProperty ("PointerOffset", BindingFlags.Instance | BindingFlags.Public) != null;
- } catch (Exception) {
- return false;
+ var asm = Assembly.Load ("Microsoft.CodeAnalysis.Workspaces.Desktop");
+ if (asm != null) {
+ var type = asm.GetType ("Microsoft.CodeAnalysis.Host.TemporaryStorageServiceFactory");
+ if (type != null)
+ microsoftFactory = Activator.CreateInstance (type) as IWorkspaceServiceFactory;
+ }
+ } catch (Exception e) {
+ LoggingService.LogWarning ("Can't load TemporaryStorageServiceFactory, falling back to default.", e);
}
}
@@ -112,86 +81,6 @@ namespace MonoDevelop.Ide.TypeSystem
}
}
- /*
- sealed class StreamStorage : ITemporaryStreamStorage
- {
- MemoryStream _stream;
-
- public void Dispose ()
- {
- _stream?.Dispose ();
- _stream = null;
- }
-
- public Stream ReadStream (CancellationToken cancellationToken = default(CancellationToken))
- {
- if (_stream == null) {
- throw new InvalidOperationException ();
- }
-
- _stream.Position = 0;
- return _stream;
- }
-
- public Task<Stream> ReadStreamAsync (CancellationToken cancellationToken = default(CancellationToken))
- {
- if (_stream == null) {
- throw new InvalidOperationException ();
- }
-
- _stream.Position = 0;
- return Task.FromResult ((Stream)_stream);
- }
-
- public void WriteStream (Stream stream, CancellationToken cancellationToken = default(CancellationToken))
- {
- var newStream = new MemoryStream ();
- stream.CopyTo (newStream);
- _stream = newStream;
- }
-
- public async Task WriteStreamAsync (Stream stream, CancellationToken cancellationToken = default(CancellationToken))
- {
- var newStream = new MemoryStream ();
- await stream.CopyToAsync (newStream).ConfigureAwait (false);
- _stream = newStream;
- }
- }
-
- sealed class TemporaryTextStorage : ITemporaryTextStorage
- {
- SourceText _sourceText;
-
- public void Dispose ()
- {
- _sourceText = null;
- }
-
- public SourceText ReadText (CancellationToken cancellationToken = default(CancellationToken))
- {
- return _sourceText;
- }
-
- public Task<SourceText> ReadTextAsync (CancellationToken cancellationToken = default(CancellationToken))
- {
- return Task.FromResult (ReadText (cancellationToken));
- }
-
- public void WriteText (SourceText text, CancellationToken cancellationToken = default(CancellationToken))
- {
- // This is a trivial implementation, indeed. Note, however, that we retain a strong
- // reference to the source text, which defeats the intent of RecoverableTextAndVersion, but
- // is appropriate for this trivial implementation.
- _sourceText = text;
- }
-
- public Task WriteTextAsync (SourceText text, CancellationToken cancellationToken = default(CancellationToken))
- {
- WriteText (text, cancellationToken);
- return Task.FromResult (true);
- }
- }
-*/
class TemporaryTextStorage : ITemporaryTextStorage
{
string fileName;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs
index 0c7aa0e962..5a822bedfe 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs
@@ -1,4 +1,4 @@
-//
+//
// MonoDevelopWorkspace.cs
//
// Author:
@@ -53,6 +53,8 @@ namespace MonoDevelop.Ide.TypeSystem
public class MonoDevelopWorkspace : Workspace
{
+ public const string ServiceLayer = nameof(MonoDevelopWorkspace);
+
readonly static HostServices services;
internal readonly WorkspaceId Id;
@@ -71,8 +73,15 @@ namespace MonoDevelop.Ide.TypeSystem
static string[] mefHostServices = new [] {
"Microsoft.CodeAnalysis.Workspaces",
+ //FIXME: this does not load yet. We should provide alternate implementations of its services.
+ //"Microsoft.CodeAnalysis.Workspaces.Desktop",
+ "Microsoft.CodeAnalysis.Features",
+ "Microsoft.CodeAnalysis.CSharp",
"Microsoft.CodeAnalysis.CSharp.Workspaces",
- "Microsoft.CodeAnalysis.VisualBasic.Workspaces"
+ "Microsoft.CodeAnalysis.CSharp.Features",
+ "Microsoft.CodeAnalysis.VisualBasic",
+ "Microsoft.CodeAnalysis.VisualBasic.Workspaces",
+ "Microsoft.CodeAnalysis.VisualBasic.Features",
};
internal static HostServices HostServices {
@@ -84,14 +93,15 @@ namespace MonoDevelop.Ide.TypeSystem
static MonoDevelopWorkspace ()
{
List<Assembly> assemblies = new List<Assembly> ();
+ assemblies.Add (typeof (MonoDevelopWorkspace).Assembly);
foreach (var asmName in mefHostServices) {
try {
var asm = Assembly.Load (asmName);
if (asm == null)
continue;
assemblies.Add (asm);
- } catch (Exception) {
- LoggingService.LogError ("Error - can't load host service assembly: " + asmName);
+ } catch (Exception ex) {
+ LoggingService.LogError ("Error - can't load host service assembly: " + asmName, ex);
}
}
assemblies.Add (typeof(MonoDevelopWorkspace).Assembly);
@@ -108,7 +118,7 @@ namespace MonoDevelop.Ide.TypeSystem
continue;
}
}
- services = Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create (assemblies);
+ services = MefHostServices.Create (assemblies);
}
/// <summary>
@@ -120,7 +130,7 @@ namespace MonoDevelop.Ide.TypeSystem
OnSolutionAdded (sInfo);
}
- internal MonoDevelopWorkspace (MonoDevelop.Projects.Solution solution) : base (services, ServiceLayer.Desktop)
+ internal MonoDevelopWorkspace (MonoDevelop.Projects.Solution solution) : base (services, "MonoDevelop")
{
this.monoDevelopSolution = solution;
this.Id = WorkspaceId.Next ();
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/NR5CompatibiltyExtensions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/NR5CompatibiltyExtensions.cs
index bbc44a7170..de720d862a 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/NR5CompatibiltyExtensions.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/NR5CompatibiltyExtensions.cs
@@ -30,27 +30,14 @@ using System.Reflection;
using System.Text;
using System.Threading;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using MonoDevelop.Core;
+using Microsoft.CodeAnalysis.Shared.Utilities;
namespace MonoDevelop.Ide.TypeSystem
{
public static class NR5CompatibiltyExtensions
{
- readonly static Type ISymbolExtensionsTypeInfo;
- static MethodInfo isAccessibleWithin1Method, isAccessibleWithin2Method;
-
- static NR5CompatibiltyExtensions ()
- {
- ISymbolExtensionsTypeInfo = Type.GetType ("Microsoft.CodeAnalysis.Shared.Extensions.ISymbolExtensions, Microsoft.CodeAnalysis.Workspaces", true);
-
- isAccessibleWithin1Method = ISymbolExtensionsTypeInfo.GetMethod ("IsAccessibleWithin", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(ISymbol), typeof(IAssemblySymbol), typeof(ITypeSymbol) }, null);
- if (isAccessibleWithin1Method == null)
- LoggingService.LogFatalError ("NR5CompatibiltyExtensions: IsAccessibleWithin(1) method not found");
- isAccessibleWithin2Method = ISymbolExtensionsTypeInfo.GetMethod ("IsAccessibleWithin", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(ISymbol), typeof(INamedTypeSymbol), typeof(ITypeSymbol) }, null);
- if (isAccessibleWithin2Method == null)
- LoggingService.LogFatalError ("NR5CompatibiltyExtensions: IsAccessibleWithin(2) method not found");
- }
-
/// <summary>
/// Gets the full name of the metadata.
/// In case symbol is not INamedTypeSymbol it returns raw MetadataName
@@ -89,30 +76,6 @@ namespace MonoDevelop.Ide.TypeSystem
return fullName.ToString ();
}
- public static IEnumerable<INamedTypeSymbol> GetAllTypes (this INamespaceSymbol namespaceSymbol, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (namespaceSymbol == null)
- throw new ArgumentNullException (nameof (namespaceSymbol));
- var stack = new Stack<INamespaceOrTypeSymbol> ();
- stack.Push (namespaceSymbol);
-
- while (stack.Count > 0) {
- if (cancellationToken.IsCancellationRequested)
- yield break;
- var current = stack.Pop ();
- var currentNs = current as INamespaceSymbol;
- if (currentNs != null) {
- foreach (var member in currentNs.GetMembers ())
- stack.Push (member);
- } else {
- var namedType = (INamedTypeSymbol)current;
- foreach (var nestedType in namedType.GetTypeMembers ())
- stack.Push (nestedType);
- yield return namedType;
- }
- }
- }
-
/// <summary>
/// Determines if derived from baseType. Includes itself and all base classes, but does not include interfaces.
/// </summary>
@@ -130,13 +93,9 @@ namespace MonoDevelop.Ide.TypeSystem
return false;
}
- public static IEnumerable<INamedTypeSymbol> GetBaseTypes (this ITypeSymbol type)
+ public static IEnumerable<INamedTypeSymbol> GetAllTypes (this INamespaceSymbol namespaceSymbol)
{
- var current = type.BaseType;
- while (current != null) {
- yield return current;
- current = current.BaseType;
- }
+ return namespaceSymbol.GetAllTypes (CancellationToken.None);
}
public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis (this ITypeSymbol type)
@@ -196,14 +155,14 @@ namespace MonoDevelop.Ide.TypeSystem
return type.ToDisplayString (SymbolDisplayFormat.CSharpErrorMessageFormat);
}
- public static IEnumerable<INamedTypeSymbol> GetAllTypesInMainAssembly (this Compilation compilation, CancellationToken cancellationToken = default(CancellationToken))
+ public static IEnumerable<INamedTypeSymbol> GetAllTypesInMainAssembly (this Compilation compilation, CancellationToken cancellationToken = default (CancellationToken))
{
if (compilation == null)
throw new ArgumentNullException (nameof (compilation));
return compilation.Assembly.GlobalNamespace.GetAllTypes (cancellationToken);
}
- public static IEnumerable<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
+ public static IEnumerable<T> GetAccessibleMembersInThisAndBaseTypes<T> (this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
{
if (containingType == null)
return Enumerable.Empty<T> ();
@@ -326,82 +285,43 @@ namespace MonoDevelop.Ide.TypeSystem
return true;
}
- public static INamedTypeSymbol GetEnclosingNamedType(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
+ public static bool IsAccessibleWithinMD (this ISymbol symbol, ISymbol within, ITypeSymbol throughTypeOpt = null)
{
- return semanticModel.GetEnclosingSymbol<INamedTypeSymbol>(position, cancellationToken);
+ return symbol.IsAccessibleWithin (within, throughTypeOpt);
}
- public static TSymbol GetEnclosingSymbol<TSymbol>(this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
+ public static IEnumerable<INamedTypeSymbol> GetBaseTypesMD (this ITypeSymbol symbol)
+ {
+ foreach (var item in symbol.GetBaseTypes ())
+ yield return item;
+ }
+
+ public static TSymbol GetEnclosingSymbolMD<TSymbol> (this SemanticModel semanticModel, int position, CancellationToken cancellationToken)
where TSymbol : ISymbol
{
- for (var symbol = semanticModel.GetEnclosingSymbol(position, cancellationToken);
- symbol != null;
- symbol = symbol.ContainingSymbol)
- {
- if (symbol is TSymbol)
- {
+ for (var symbol = semanticModel.GetEnclosingSymbol (position, cancellationToken);
+ symbol != null;
+ symbol = symbol.ContainingSymbol) {
+ if (symbol is TSymbol) {
return (TSymbol)symbol;
}
}
- return default(TSymbol);
- }
-
- /// <summary>
- /// Checks if 'symbol' is accessible from within 'within'.
- /// </summary>
- public static bool IsAccessibleWithin(
- this ISymbol symbol,
- ISymbol within,
- ITypeSymbol throughTypeOpt = null)
- {
- if (symbol == null)
- throw new ArgumentNullException (nameof (symbol));
- if (within == null)
- throw new ArgumentNullException (nameof (within));
- if (within is IAssemblySymbol)
- {
- return symbol.IsAccessibleWithin((IAssemblySymbol)within, throughTypeOpt);
- }
- else if (within is INamedTypeSymbol)
- {
- return symbol.IsAccessibleWithin((INamedTypeSymbol)within, throughTypeOpt);
- }
- else
- {
- throw new ArgumentException();
- }
+ return default (TSymbol);
}
- /// <summary>
- /// Checks if 'symbol' is accessible from within assembly 'within'.
- /// </summary>
- public static bool IsAccessibleWithin(
- this ISymbol symbol,
- IAssemblySymbol within,
- ITypeSymbol throughTypeOpt = null)
+ public static IEnumerable<INamedTypeSymbol> GetAllTypesMD (this INamespaceSymbol namespaceSymbol, CancellationToken cancellationToken = default (CancellationToken))
{
- if (symbol == null)
- throw new ArgumentNullException (nameof (symbol));
- if (within == null)
- throw new ArgumentNullException (nameof (within));
- return (bool)isAccessibleWithin1Method.Invoke (null, new object [] { symbol, within, throughTypeOpt });
+ foreach (var item in namespaceSymbol.GetAllTypes (cancellationToken))
+ yield return item;
}
+ }
- /// <summary>
- /// Checks if 'symbol' is accessible from within name type 'within', with an optional
- /// qualifier of type "throughTypeOpt".
- /// </summary>
- public static bool IsAccessibleWithin(
- this ISymbol symbol,
- INamedTypeSymbol within,
- ITypeSymbol throughTypeOpt = null)
+ public static class SignatureComparerMD
+ {
+ public static bool HaveSameSignature (ISymbol symbol1, ISymbol symbol2, bool caseSensitive)
{
- if (symbol == null)
- throw new ArgumentNullException (nameof (symbol));
- if (within == null)
- throw new ArgumentNullException (nameof (within));
- return (bool)isAccessibleWithin2Method.Invoke (null, new object [] { symbol, within, throughTypeOpt });
+ return SignatureComparer.Instance.HaveSameSignature (symbol1, symbol2, caseSensitive);
}
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ProjectCacheService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ProjectCacheService.cs
deleted file mode 100644
index 2e2f9ef262..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ProjectCacheService.cs
+++ /dev/null
@@ -1,676 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.CodeAnalysis.Host;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using System.Collections.Immutable;
-using System.Runtime.CompilerServices;
-using System.Diagnostics.Contracts;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Diagnostics.CodeAnalysis;
-using System.Reflection;
-using System.Diagnostics;
-using System.Collections;
-using System.Linq;
-namespace MonoDevelop.Ide.TypeSystem
-{
-/*
- class ProjectCacheService : IProjectCacheHostService
- {
- internal const int ImplicitCacheSize = 3;
-
- private readonly object _gate = new object ();
-
- private readonly Workspace _workspace;
- private readonly Dictionary<ProjectId, Cache> _activeCaches = new Dictionary<ProjectId, Cache> ();
-
- private readonly SimpleMRUCache _implicitCache = new SimpleMRUCache ();
- private readonly ImplicitCacheMonitor _implicitCacheMonitor;
-
- public ProjectCacheService (Workspace workspace, int implicitCacheTimeout, bool forceCleanup = false)
- {
- _workspace = workspace;
-
- // forceCleanup is for testing
- if (workspace?.Kind == WorkspaceKind.Host || forceCleanup) {
- // monitor implicit cache for host
- _implicitCacheMonitor = new ImplicitCacheMonitor (this, implicitCacheTimeout);
- }
- }
-
- public bool IsImplicitCacheEmpty {
- get {
- lock (_gate) {
- return _implicitCache.Empty;
- }
- }
- }
-
- public void ClearImplicitCache ()
- {
- lock (_gate) {
- _implicitCache.Clear ();
- }
- }
-
- public void ClearExpiredImplicitCache (DateTime expirationTime)
- {
- lock (_gate) {
- _implicitCache.ClearExpiredItems (expirationTime);
- }
- }
-
- public IDisposable EnableCaching (ProjectId key)
- {
- lock (_gate) {
- Cache cache;
- if (!_activeCaches.TryGetValue (key, out cache)) {
- cache = new Cache (this, key);
- _activeCaches.Add (key, cache);
- }
-
- cache.Count++;
- return cache;
- }
- }
-
- public T CacheObjectIfCachingEnabledForKey<T> (ProjectId key, object owner, T instance) where T : class
- {
- lock (_gate) {
- Cache cache;
- if (_activeCaches.TryGetValue (key, out cache)) {
- cache.CreateStrongReference (owner, instance);
- } else if (!PartOfP2PReferences (key)) {
- _implicitCache.Touch (instance);
- _implicitCacheMonitor?.Touch ();
- }
-
- return instance;
- }
- }
-
- private bool PartOfP2PReferences (ProjectId key)
- {
- if (_activeCaches.Count == 0 || _workspace == null) {
- return false;
- }
-
- var solution = _workspace.CurrentSolution;
- var graph = solution.GetProjectDependencyGraph ();
-
- foreach (var projectId in _activeCaches.Keys) {
- // this should be cheap. graph is cached everytime project reference is updated.
- var p2pReferences = (ImmutableHashSet<ProjectId>)graph.GetProjectsThatThisProjectTransitivelyDependsOn (projectId);
- if (p2pReferences.Contains (key)) {
- return true;
- }
- }
-
- return false;
- }
-
- public T CacheObjectIfCachingEnabledForKey<T> (ProjectId key, ICachedObjectOwner owner, T instance) where T : class
- {
- lock (_gate) {
- Cache cache;
- if (owner.CachedObject == null && _activeCaches.TryGetValue (key, out cache)) {
- owner.CachedObject = instance;
- cache.CreateOwnerEntry (owner);
- }
-
- return instance;
- }
- }
-
- private void DisableCaching (ProjectId key, Cache cache)
- {
- lock (_gate) {
- cache.Count--;
- if (cache.Count == 0) {
- _activeCaches.Remove (key);
- cache.FreeOwnerEntries ();
- }
- }
- }
-
- private class Cache : IDisposable
- {
- internal int Count;
- private readonly ProjectCacheService _cacheService;
- private readonly ProjectId _key;
- private readonly ConditionalWeakTable<object, object> _cache = new ConditionalWeakTable<object, object> ();
- private readonly List<WeakReference<ICachedObjectOwner>> _ownerObjects = new List<WeakReference<ICachedObjectOwner>> ();
-
- public Cache (ProjectCacheService cacheService, ProjectId key)
- {
- _cacheService = cacheService;
- _key = key;
- }
-
- public void Dispose ()
- {
- _cacheService.DisableCaching (_key, this);
- }
-
- internal void CreateStrongReference (object key, object instance)
- {
- object o;
- if (!_cache.TryGetValue (key, out o)) {
- _cache.Add (key, instance);
- }
- }
-
- internal void CreateOwnerEntry (ICachedObjectOwner owner)
- {
- _ownerObjects.Add (new WeakReference<ICachedObjectOwner> (owner));
- }
-
- internal void FreeOwnerEntries ()
- {
- foreach (var entry in _ownerObjects) {
- ICachedObjectOwner owner;
- if (entry.TryGetTarget (out owner)) {
- owner.CachedObject = null;
- }
- }
- }
- }
-
- private class SimpleMRUCache
- {
- private const int CacheSize = 3;
-
- private readonly Node[] nodes = new Node[CacheSize];
-
- public bool Empty {
- get {
- for (var i = 0; i < nodes.Length; i++) {
- if (nodes [i].Data != null) {
- return false;
- }
- }
-
- return true;
- }
- }
-
- public void Touch (object instance)
- {
- var oldIndex = -1;
- var oldTime = DateTime.UtcNow;
-
- for (var i = 0; i < nodes.Length; i++) {
- if (instance == nodes [i].Data) {
- nodes [i].LastTouched = DateTime.UtcNow;
- return;
- }
-
- if (oldTime >= nodes [i].LastTouched) {
- oldTime = nodes [i].LastTouched;
- oldIndex = i;
- }
- }
-
- Contract.Requires (oldIndex >= 0);
- nodes [oldIndex] = new Node (instance, DateTime.UtcNow);
- }
-
- public void ClearExpiredItems (DateTime expirationTime)
- {
- for (var i = 0; i < nodes.Length; i++) {
- if (nodes [i].Data != null && nodes [i].LastTouched < expirationTime) {
- nodes [i] = default(Node);
- }
- }
- }
-
- public void Clear ()
- {
- Array.Clear (nodes, 0, nodes.Length);
- }
-
- private struct Node
- {
- public readonly object Data;
- public DateTime LastTouched;
-
- public Node (object data, DateTime lastTouched)
- {
- Data = data;
- LastTouched = lastTouched;
- }
- }
- }
-
- private class ImplicitCacheMonitor : IdleProcessor
- {
- private readonly ProjectCacheService _owner;
- private readonly SemaphoreSlim _gate;
-
- public ImplicitCacheMonitor (ProjectCacheService owner, int backOffTimeSpanInMS) :
- base (//AggregateAsynchronousOperationListener.CreateEmptyListener(),
- backOffTimeSpanInMS,
- CancellationToken.None)
- {
- _owner = owner;
- _gate = new SemaphoreSlim (0);
-
- Start ();
- }
-
- protected override Task ExecuteAsync ()
- {
- _owner.ClearExpiredImplicitCache (DateTime.UtcNow - TimeSpan.FromMilliseconds (BackOffTimeSpanInMS));
-
- return SpecializedTasks.EmptyTask;
- }
-
- public void Touch ()
- {
- UpdateLastAccessTime ();
-
- if (_gate.CurrentCount == 0) {
- _gate.Release ();
- }
- }
-
- protected override Task WaitAsync (CancellationToken cancellationToken)
- {
- if (_owner.IsImplicitCacheEmpty) {
- return _gate.WaitAsync (cancellationToken);
- }
-
- return SpecializedTasks.EmptyTask;
- }
- }
- }
-
- internal abstract class IdleProcessor
- {
- private const int MinimumDelayInMS = 50;
-
- // protected readonly IAsynchronousOperationListener Listener;
- protected readonly CancellationToken CancellationToken;
- protected readonly int BackOffTimeSpanInMS;
-
- // points to processor task
- private Task _processorTask;
-
- // there is one thread that writes to it and one thread reads from it
- private int _lastAccessTimeInMS;
-
- public IdleProcessor (
-// IAsynchronousOperationListener listener,
- int backOffTimeSpanInMS,
- CancellationToken cancellationToken)
- {
-// this.Listener = listener;
- this.CancellationToken = cancellationToken;
-
- BackOffTimeSpanInMS = backOffTimeSpanInMS;
- _lastAccessTimeInMS = Environment.TickCount;
- }
-
- protected abstract Task WaitAsync (CancellationToken cancellationToken);
-
- protected abstract Task ExecuteAsync ();
-
- protected void Start ()
- {
- if (_processorTask == null) {
- _processorTask = Task.Factory.SafeStartNewFromAsync (ProcessAsync, this.CancellationToken, TaskScheduler.Default);
- }
- }
-
- protected void UpdateLastAccessTime ()
- {
- _lastAccessTimeInMS = Environment.TickCount;
- }
-
- protected async Task WaitForIdleAsync ()
- {
- while (true) {
- if (this.CancellationToken.IsCancellationRequested) {
- return;
- }
-
- var diffInMS = Environment.TickCount - _lastAccessTimeInMS;
- if (diffInMS >= BackOffTimeSpanInMS) {
- return;
- }
-
- // TODO: will safestart/unwarp capture cancellation exception?
- var timeLeft = BackOffTimeSpanInMS - diffInMS;
- await Task.Delay (Math.Max (MinimumDelayInMS, timeLeft), this.CancellationToken).ConfigureAwait (continueOnCapturedContext: false);
- }
- }
-
- private async Task ProcessAsync ()
- {
- while (true) {
- try {
- if (this.CancellationToken.IsCancellationRequested) {
- return;
- }
-
- // wait for next item available
- await WaitAsync (this.CancellationToken).ConfigureAwait (continueOnCapturedContext: false);
-
-// using (this.Listener.BeginAsyncOperation("ProcessAsync"))
-// {
- // we have items but workspace is busy. wait for idle.
- await WaitForIdleAsync ().ConfigureAwait (continueOnCapturedContext: false);
-
- await ExecuteAsync ().ConfigureAwait (continueOnCapturedContext: false);
-// }
- } catch (OperationCanceledException) {
- // ignore cancellation exception
- }
- }
- }
-
- public virtual Task AsyncProcessorTask {
- get {
- if (_processorTask == null) {
- return SpecializedTasks.EmptyTask;
- }
-
- return _processorTask;
- }
- }
- }
-*/
- internal static class SpecializedTasks
- {
- public static readonly Task<bool> True = Task.FromResult<bool> (true);
- public static readonly Task<bool> False = Task.FromResult<bool> (false);
- public static readonly Task EmptyTask = Empty<object>.Default;
-
- public static Task<T> Default<T> ()
- {
- return Empty<T>.Default;
- }
-
- public static Task<ImmutableArray<T>> EmptyImmutableArray<T> ()
- {
- return Empty<T>.EmptyImmutableArray;
- }
-
- public static Task<T> FromResult<T> (T t) where T : class
- {
- return FromResultCache<T>.FromResult (t);
- }
-
-
- public static Task<IEnumerable<T>> EmptyEnumerable<T>()
- {
- return Empty<T>.EmptyEnumerable;
- }
-
- private static class Empty<T>
- {
- public static readonly Task<T> Default = Task.FromResult<T> (default(T));
- public static readonly Task<ImmutableArray<T>> EmptyImmutableArray = Task.FromResult (ImmutableArray<T>.Empty);
- public static readonly Task<IEnumerable<T>> EmptyEnumerable = Task.FromResult<IEnumerable<T>>(Enumerable.Empty<T> ());
- }
-
- private static class FromResultCache<T> where T : class
- {
- private static readonly ConditionalWeakTable<T, Task<T>> s_fromResultCache = new ConditionalWeakTable<T, Task<T>> ();
- private static readonly ConditionalWeakTable<T, Task<T>>.CreateValueCallback s_taskCreationCallback = Task.FromResult<T>;
-
- public static Task<T> FromResult (T t)
- {
- return s_fromResultCache.GetValue (t, s_taskCreationCallback);
- }
- }
- }
-
- [SuppressMessage ("ApiDesign", "RS0011", Justification = "Matching TPL Signatures")]
- internal static partial class TaskFactoryExtensions
- {
- public static Task SafeStartNew (this TaskFactory factory, Action action, CancellationToken cancellationToken, TaskScheduler scheduler)
- {
- return factory.SafeStartNew (action, cancellationToken, TaskCreationOptions.None, scheduler);
- }
-
- public static Task SafeStartNew (
- this TaskFactory factory,
- Action action,
- CancellationToken cancellationToken,
- TaskCreationOptions creationOptions,
- TaskScheduler scheduler)
- {
- Action wrapped = () => {
- try {
- action ();
- } catch (Exception) {
- throw new InvalidOperationException ("This program location is thought to be unreachable.");
- }
- };
-
- // The one and only place we can call StartNew().
- return factory.StartNew (wrapped, cancellationToken, creationOptions, scheduler);
- }
-
- public static Task<TResult> SafeStartNew<TResult> (this TaskFactory factory, Func<TResult> func, CancellationToken cancellationToken, TaskScheduler scheduler)
- {
- return factory.SafeStartNew (func, cancellationToken, TaskCreationOptions.None, scheduler);
- }
-
- public static Task<TResult> SafeStartNew<TResult> (
- this TaskFactory factory,
- Func<TResult> func,
- CancellationToken cancellationToken,
- TaskCreationOptions creationOptions,
- TaskScheduler scheduler)
- {
- Func<TResult> wrapped = () => {
- try {
- return func ();
- } catch (Exception) {
- throw new InvalidOperationException ("This program location is thought to be unreachable.");
- }
- };
-
- // The one and only place we can call StartNew<>().
- return factory.StartNew (wrapped, cancellationToken, creationOptions, scheduler);
- }
-
- public static Task SafeStartNewFromAsync (this TaskFactory factory, Func<Task> actionAsync, CancellationToken cancellationToken, TaskScheduler scheduler)
- {
- return factory.SafeStartNewFromAsync (actionAsync, cancellationToken, TaskCreationOptions.None, scheduler);
- }
-
- public static Task SafeStartNewFromAsync (
- this TaskFactory factory,
- Func<Task> actionAsync,
- CancellationToken cancellationToken,
- TaskCreationOptions creationOptions,
- TaskScheduler scheduler)
- {
- // The one and only place we can call StartNew<>().
- var task = factory.StartNew (actionAsync, cancellationToken, creationOptions, scheduler).Unwrap ();
- ReportFatalError (task, actionAsync);
- return task;
- }
-
- public static Task<TResult> SafeStartNewFromAsync<TResult> (this TaskFactory factory, Func<Task<TResult>> funcAsync, CancellationToken cancellationToken, TaskScheduler scheduler)
- {
- return factory.SafeStartNewFromAsync (funcAsync, cancellationToken, TaskCreationOptions.None, scheduler);
- }
-
- public static Task<TResult> SafeStartNewFromAsync<TResult> (
- this TaskFactory factory,
- Func<Task<TResult>> funcAsync,
- CancellationToken cancellationToken,
- TaskCreationOptions creationOptions,
- TaskScheduler scheduler)
- {
- // The one and only place we can call StartNew<>().
- var task = factory.StartNew (funcAsync, cancellationToken, creationOptions, scheduler).Unwrap ();
- ReportFatalError (task, funcAsync);
- return task;
- }
-
- internal static void ReportFatalError (Task task, object continuationFunction)
- {
- task.ContinueWith (ReportFatalErrorWorker, continuationFunction,
- CancellationToken.None,
- TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
- TaskScheduler.Default);
- }
-
- [MethodImpl (MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
- private static void ReportFatalErrorWorker (Task task, object continuationFunction)
- {
- var exception = task.Exception;
- var methodInfo = ((Delegate)continuationFunction).GetMethodInfo ();
- exception.Data ["ContinuationFunction"] = methodInfo.DeclaringType.FullName + "::" + methodInfo.Name;
-
- // In case of a crash with ExecutionEngineException w/o call stack it might be possible to get the stack trace using WinDbg:
- // > !threads // find thread with System.ExecutionEngineException
- // ...
- // 67 65 4760 692b5d60 1029220 Preemptive CD9AE70C:FFFFFFFF 012ad0f8 0 MTA (Threadpool Worker) System.ExecutionEngineException 03c51108
- // ...
- // > ~67s // switch to thread 67
- // > !dso // dump stack objects
- FatalError.Report (exception);
- }
- }
-
- internal static class FatalError
- {
- private static Action<Exception> s_fatalHandler;
- private static Action<Exception> s_nonFatalHandler;
-
- //private static Exception s_reportedException;
- //private static string s_reportedExceptionMessage;
-
- /// <summary>
- /// Set by the host to a fail fast trigger,
- /// if the host desires to crash the process on a fatal exception.
- /// </summary>
- public static Action<Exception> Handler {
- get {
- return s_fatalHandler;
- }
-
- set {
- if (s_fatalHandler != value) {
- Debug.Assert (s_fatalHandler == null, "Handler already set");
- s_fatalHandler = value;
- }
- }
- }
-
- /// <summary>
- /// Set by the host to a fail fast trigger,
- /// if the host desires to NOT crash the process on a non fatal exception.
- /// </summary>
- public static Action<Exception> NonFatalHandler {
- get {
- return s_nonFatalHandler;
- }
-
- set {
- if (s_nonFatalHandler != value) {
- Debug.Assert (s_nonFatalHandler == null, "Handler already set");
- s_nonFatalHandler = value;
- }
- }
- }
-
- // Same as setting the Handler property except that it avoids the assert. This is useful in
- // test code which needs to verify the handler is called in specific cases and will continually
- // overwrite this value.
- public static void OverwriteHandler (Action<Exception> value)
- {
- s_fatalHandler = value;
- }
-
- /// <summary>
- /// Use in an exception filter to report a fatal error.
- /// Unless the exception is <see cref="OperationCanceledException"/>
- /// it calls <see cref="Handler"/>. The exception is passed through (the method returns false).
- /// </summary>
- /// <returns>False to avoid catching the exception.</returns>
- [DebuggerHidden]
- public static bool ReportUnlessCanceled (Exception exception)
- {
- if (exception is OperationCanceledException) {
- return false;
- }
-
- return Report (exception);
- }
-
- /// <summary>
- /// Use in an exception filter to report a non fatal error.
- /// Unless the exception is <see cref="OperationCanceledException"/>
- /// it calls <see cref="NonFatalHandler"/>. The exception isn't passed through (the method returns true).
- /// </summary>
- /// <returns>True to catch the exception.</returns>
- [DebuggerHidden]
- public static bool ReportWithoutCrashUnlessCanceled (Exception exception)
- {
- if (exception is OperationCanceledException) {
- return false;
- }
-
- return ReportWithoutCrash (exception);
- }
-
- /// <summary>
- /// Use in an exception filter to report a fatal error.
- /// Unless the exception is <see cref="NotImplementedException"/>
- /// it calls <see cref="Handler"/>. The exception is passed through (the method returns false).
- /// </summary>
- /// <returns>False to avoid catching the exception.</returns>
- [DebuggerHidden]
- public static bool ReportUnlessNotImplemented (Exception exception)
- {
- if (exception is NotImplementedException) {
- return false;
- }
-
- return Report (exception);
- }
-
- /// <summary>
- /// Use in an exception filter to report a fatal error.
- /// Calls <see cref="Handler"/> and passes the exception through (the method returns false).
- /// </summary>
- /// <returns>False to avoid catching the exception.</returns>
- [DebuggerHidden]
- public static bool Report (Exception exception)
- {
- Report (exception, s_fatalHandler);
- return false;
- }
-
- /// <summary>
- /// Use in an exception filter to report a non fatal error.
- /// Calls <see cref="NonFatalHandler"/> and doesn't pass the exception through (the method returns true).
- /// </summary>
- /// <returns>True to catch the exception.</returns>
- [DebuggerHidden]
- public static bool ReportWithoutCrash (Exception exception)
- {
- Report (exception, s_nonFatalHandler);
- return true;
- }
-
- private static void Report (Exception exception, Action<Exception> handler)
- {
- // hold onto last exception to make investigation easier
- //s_reportedException = exception;
- //s_reportedExceptionMessage = exception.ToString ();
-
- handler?.Invoke (exception);
- }
- }
-}
-
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TextPolicyDocumentOptionsProvider.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TextPolicyDocumentOptionsProvider.cs
new file mode 100644
index 0000000000..d870e385f2
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TextPolicyDocumentOptionsProvider.cs
@@ -0,0 +1,98 @@
+//
+// TextPolicyDocumentOptionsProvider.cs
+//
+// Author:
+// Mikayla Hutchinson <m.j.hutchinson@gmail.com>
+//
+// Copyright (c) 2017 Microsoft Corp.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Composition;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Options;
+using MonoDevelop.Ide.Gui.Content;
+using Microsoft.CodeAnalysis.Formatting;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+
+namespace MonoDevelop.Ide.TypeSystem
+{
+ [Export (typeof (IDocumentOptionsProviderFactory))]
+ class TextPolicyDocumentOptionsProviderFactory : IDocumentOptionsProviderFactory
+ {
+ public IDocumentOptionsProvider Create (Workspace workspace)
+ {
+ return new TextPolicyDocumentOptionsProvider ();
+ }
+ }
+
+ class TextPolicyDocumentOptionsProvider : IDocumentOptionsProvider
+ {
+ public async Task<IDocumentOptions> GetOptionsForDocumentAsync (Document document, CancellationToken cancellationToken)
+ {
+ var mimeChain = DesktopService.GetMimeTypeInheritanceChainForRoslynLanguage (document.Project.Language);
+ if (mimeChain == null) {
+ return null;
+ }
+
+ var project = TypeSystemService.GetMonoProject (document.Project);
+ var policy = project.Policies.Get<TextStylePolicy> (mimeChain);
+ return new TextDocumentOptions (policy);
+ }
+
+ class TextDocumentOptions : IDocumentOptions
+ {
+ TextStylePolicy policy;
+
+ public TextDocumentOptions (TextStylePolicy policy)
+ {
+ this.policy = policy;
+ }
+
+ public bool TryGetDocumentOption (Document document, OptionKey option, out object value)
+ {
+ if (option.Option == FormattingOptions.UseTabs) {
+ value = !policy.TabsToSpaces;
+ return true;
+ }
+
+ if (option.Option == FormattingOptions.TabSize) {
+ value = policy.TabWidth;
+ return true;
+ }
+
+ if (option.Option == FormattingOptions.IndentationSize) {
+ value = policy.IndentWidth;
+ return true;
+ }
+
+ if (option.Option == FormattingOptions.NewLine) {
+ value = policy.GetEolMarker ();
+ return true;
+ }
+
+ value = null;
+ return false;
+ }
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs
index 147903b6ab..ed8da5693f 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs
@@ -131,32 +131,6 @@ namespace MonoDevelop.Ide.TypeSystem
IntitializeTrackedProjectHandling ();
}
-/*
- AddinManager.AddExtensionNodeHandler ("/MonoDevelop/TypeSystem/OutputTracking", delegate (object sender, ExtensionNodeEventArgs args) {
- var node = (TypeSystemOutputTrackingNode)args.ExtensionNode;
- switch (args.Change) {
- case ExtensionChange.Add:
- outputTrackedProjects.Add (node);
- break;
- case ExtensionChange.Remove:
- outputTrackedProjects.Remove (node);
- break;
- }
- });
-
- static readonly List<TypeSystemOutputTrackingNode> outputTrackedProjects = new List<TypeSystemOutputTrackingNode> ();
-
- static bool IsOutputTracked (DotNetProject project)
- {
- foreach (var projectType in project.GetProjectTypes ()) {
- if (outputTrackedProjects.Any (otp => otp.ProjectType != null && string.Equals (otp.ProjectType, projectType, StringComparison.OrdinalIgnoreCase))) {
- return true;
- }
- }
- return outputTrackedProjects.Any (otp => otp.LanguageName != null && string.Equals (otp.LanguageName, project.LanguageName, StringComparison.OrdinalIgnoreCase));
- }
-
-*/
public static TypeSystemParser GetParser (string mimeType, string buildAction = BuildAction.Compile)
{
@@ -192,7 +166,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static Task<ParsedDocument> ParseFile (ParseOptions options, string mimeType, CancellationToken cancellationToken = default(CancellationToken))
{
if (options == null)
- throw new ArgumentNullException ("options");
+ throw new ArgumentNullException (nameof(options));
if (options.FileName == null)
throw new ArgumentNullException ("options.FileName");
@@ -243,7 +217,7 @@ namespace MonoDevelop.Ide.TypeSystem
internal static async Task<ParsedDocumentProjection> ParseProjection (ParseOptions options, string mimeType, CancellationToken cancellationToken = default(CancellationToken))
{
if (options == null)
- throw new ArgumentNullException ("options");
+ throw new ArgumentNullException (nameof(options));
if (options.FileName == null)
throw new ArgumentNullException ("fileName");
@@ -387,7 +361,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static string GetCacheDirectory (Project project, bool forceCreation = false)
{
if (project == null)
- throw new ArgumentNullException ("project");
+ throw new ArgumentNullException (nameof(project));
return GetCacheDirectory (project.FileName, forceCreation);
}
@@ -403,7 +377,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static string GetCacheDirectory (string fileName, bool forceCreation = false)
{
if (fileName == null)
- throw new ArgumentNullException ("fileName");
+ throw new ArgumentNullException (nameof(fileName));
object locker;
bool newLock;
lock (cacheLocker) {
@@ -573,7 +547,7 @@ namespace MonoDevelop.Ide.TypeSystem
static void SerializeObject (string path, object obj)
{
if (obj == null)
- throw new ArgumentNullException ("obj");
+ throw new ArgumentNullException (nameof(obj));
var t = Counters.ParserService.ObjectSerialized.BeginTiming (path);
try {
@@ -648,9 +622,9 @@ namespace MonoDevelop.Ide.TypeSystem
static void StoreExtensionObject (string cacheDir, object extensionObject)
{
if (cacheDir == null)
- throw new ArgumentNullException ("cacheDir");
+ throw new ArgumentNullException (nameof(cacheDir));
if (extensionObject == null)
- throw new ArgumentNullException ("extensionObject");
+ throw new ArgumentNullException (nameof(extensionObject));
var fileName = Path.GetTempFileName ();
SerializeObject (fileName, extensionObject);
var cacheFile = Path.Combine (cacheDir, extensionObject.GetType ().FullName + ".cache");
@@ -705,7 +679,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static Microsoft.CodeAnalysis.ProjectId GetProjectId (MonoDevelop.Projects.Project project)
{
if (project == null)
- throw new ArgumentNullException ("project");
+ throw new ArgumentNullException (nameof(project));
foreach (var w in workspaces) {
var projectId = w.GetProjectId (project);
if (projectId != null) {
@@ -718,7 +692,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static Microsoft.CodeAnalysis.Document GetCodeAnalysisDocument (Microsoft.CodeAnalysis.DocumentId docId, CancellationToken cancellationToken = default (CancellationToken))
{
if (docId == null)
- throw new ArgumentNullException ("docId");
+ throw new ArgumentNullException (nameof(docId));
foreach (var w in workspaces) {
var documentId = w.GetDocument (docId, cancellationToken);
if (documentId != null) {
@@ -731,7 +705,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static MonoDevelop.Projects.Project GetMonoProject (Microsoft.CodeAnalysis.Project project)
{
if (project == null)
- throw new ArgumentNullException ("project");
+ throw new ArgumentNullException (nameof(project));
foreach (var w in workspaces) {
var documentId = w.GetMonoProject (project);
if (documentId != null) {
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs
index 13a4d5fd70..3e3c656480 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs
@@ -38,44 +38,6 @@ using System.Collections.Concurrent;
namespace MonoDevelop.Ide.TypeSystem
{
-
-// static class MonoDevelopWorkspaceFeatures
-// {
-// static FeaturePack pack;
-//
-// public static FeaturePack Features {
-// get {
-// if (pack == null)
-// Interlocked.CompareExchange (ref pack, ComputePack (), null);
-// return pack;
-// }
-// }
-//
-// static FeaturePack ComputePack ()
-// {
-// var assemblies = new List<Assembly> ();
-// var workspaceCoreAssembly = typeof(Workspace).Assembly;
-// assemblies.Add (workspaceCoreAssembly);
-//
-// LoadAssembly (assemblies, "Microsoft.CodeAnalysis.CSharp.Workspaces");
-// //LoadAssembly (assemblies, "Microsoft.CodeAnalysis.VisualBasic.Workspaces");
-//
-// var catalogs = assemblies.Select (a => new System.ComponentModel.Composition.Hosting.AssemblyCatalog (a));
-//
-// return new MefExportPack (catalogs);
-// }
-//
-// static void LoadAssembly (List<Assembly> assemblies, string assemblyName)
-// {
-// try {
-// var loadedAssembly = Assembly.Load (assemblyName);
-// assemblies.Add (loadedAssembly);
-// } catch (Exception e) {
-// LoggingService.LogWarning ("Couldn't load assembly:" + assemblyName, e);
-// }
-// }
-// }
-
public static partial class TypeSystemService
{
static readonly MonoDevelopWorkspace emptyWorkspace;
@@ -94,7 +56,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static MonoDevelopWorkspace GetWorkspace (MonoDevelop.Projects.Solution solution)
{
if (solution == null)
- throw new ArgumentNullException ("solution");
+ throw new ArgumentNullException (nameof(solution));
foreach (var ws in workspaces) {
if (ws.MonoDevelopSolution == solution)
return ws;
@@ -218,9 +180,9 @@ namespace MonoDevelop.Ide.TypeSystem
public static DocumentId GetDocumentId (MonoDevelop.Projects.Project project, string fileName)
{
if (project == null)
- throw new ArgumentNullException ("project");
+ throw new ArgumentNullException (nameof(project));
if (fileName == null)
- throw new ArgumentNullException ("fileName");
+ throw new ArgumentNullException (nameof(fileName));
fileName = FileService.GetFullPath (fileName);
foreach (var w in workspaces) {
var projectId = w.GetProjectId (project);
@@ -233,9 +195,9 @@ namespace MonoDevelop.Ide.TypeSystem
public static DocumentId GetDocumentId (Microsoft.CodeAnalysis.Workspace workspace, MonoDevelop.Projects.Project project, string fileName)
{
if (project == null)
- throw new ArgumentNullException ("project");
+ throw new ArgumentNullException (nameof(project));
if (fileName == null)
- throw new ArgumentNullException ("fileName");
+ throw new ArgumentNullException (nameof(fileName));
fileName = FileService.GetFullPath (fileName);
var projectId = ((MonoDevelopWorkspace)workspace).GetProjectId (project);
if (projectId != null) {
@@ -250,9 +212,9 @@ namespace MonoDevelop.Ide.TypeSystem
public static DocumentId GetDocumentId (ProjectId projectId, string fileName)
{
if (projectId == null)
- throw new ArgumentNullException ("projectId");
+ throw new ArgumentNullException (nameof(projectId));
if (fileName == null)
- throw new ArgumentNullException ("fileName");
+ throw new ArgumentNullException (nameof(fileName));
foreach (var w in workspaces) {
if (w.Contains (projectId))
return w.GetDocumentId (projectId, fileName);
@@ -263,7 +225,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static IEnumerable<DocumentId> GetDocuments (string fileName)
{
if (fileName == null)
- throw new ArgumentNullException ("fileName");
+ throw new ArgumentNullException (nameof(fileName));
fileName = FileService.GetFullPath (fileName);
foreach (var w in workspaces) {
foreach (var projectId in w.CurrentSolution.ProjectIds) {
@@ -277,7 +239,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static Microsoft.CodeAnalysis.Project GetCodeAnalysisProject (MonoDevelop.Projects.Project project)
{
if (project == null)
- throw new ArgumentNullException ("project");
+ throw new ArgumentNullException (nameof(project));
foreach (var w in workspaces) {
var projectId = w.GetProjectId (project);
if (projectId != null)
@@ -297,7 +259,7 @@ namespace MonoDevelop.Ide.TypeSystem
public static Task<Compilation> GetCompilationAsync (MonoDevelop.Projects.Project project, CancellationToken cancellationToken = default(CancellationToken))
{
if (project == null)
- throw new ArgumentNullException ("project");
+ throw new ArgumentNullException (nameof(project));
foreach (var w in workspaces) {
var projectId = w.GetProjectId (project);
if (projectId == null)
@@ -385,7 +347,7 @@ namespace MonoDevelop.Ide.TypeSystem
internal static bool IsOutputTrackedProject (DotNetProject project)
{
if (project == null)
- throw new ArgumentNullException ("project");
+ throw new ArgumentNullException (nameof(project));
return outputTrackedProjects.Any (otp => string.Equals (otp.LanguageName, project.LanguageName, StringComparison.OrdinalIgnoreCase)) ||
project.GetTypeTags().Any (tag => outputTrackedProjects.Any (otp => string.Equals (otp.ProjectType, tag, StringComparison.OrdinalIgnoreCase)));
}
@@ -393,7 +355,7 @@ namespace MonoDevelop.Ide.TypeSystem
static void CheckProjectOutput (DotNetProject project, bool autoUpdate)
{
if (project == null)
- throw new ArgumentNullException ("project");
+ throw new ArgumentNullException (nameof(project));
if (IsOutputTrackedProject (project)) {
var fileName = project.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration);
if (!File.Exists (fileName))
@@ -408,115 +370,6 @@ namespace MonoDevelop.Ide.TypeSystem
}
}
#endregion
-
-// TODO: Port framework lookup to NR6
-// #region FrameworkLookup
-// class FrameworkTask
-// {
-// public int RetryCount { get; set; }
-//
-// public Task<FrameworkLookup> Task { get; set; }
-// }
-//
-// readonly static Dictionary<string, FrameworkTask> frameworkLookup = new Dictionary<string, FrameworkTask> ();
-//
-// static void StartFrameworkLookup (DotNetProject netProject)
-// {
-// if (netProject == null)
-// throw new ArgumentNullException ("netProject");
-// lock (frameworkLookup) {
-// FrameworkTask result;
-// if (netProject.TargetFramework == null)
-// return;
-// var frameworkName = netProject.TargetFramework.Name;
-// if (!frameworkLookup.TryGetValue (frameworkName, out result))
-// frameworkLookup [frameworkName] = result = new FrameworkTask ();
-// if (result.Task != null)
-// return;
-// result.Task = Task.Factory.StartNew (delegate {
-// return GetFrameworkLookup (netProject);
-// });
-// }
-// }
-//
-// public static bool TryGetFrameworkLookup (DotNetProject project, out FrameworkLookup lookup)
-// {
-// lock (frameworkLookup) {
-// FrameworkTask result;
-// if (frameworkLookup.TryGetValue (project.TargetFramework.Name, out result)) {
-// if (!result.Task.IsCompleted) {
-// lookup = null;
-// return false;
-// }
-// lookup = result.Task.Result;
-// return true;
-// }
-// }
-// lookup = null;
-// return false;
-// }
-//
-// public static bool RecreateFrameworkLookup (DotNetProject netProject)
-// {
-// lock (frameworkLookup) {
-// FrameworkTask result;
-// var frameworkName = netProject.TargetFramework.Name;
-// if (!frameworkLookup.TryGetValue (frameworkName, out result))
-// return false;
-// if (result.RetryCount > 5) {
-// LoggingService.LogError ("Can't create framework lookup for:" + frameworkName);
-// return false;
-// }
-// result.RetryCount++;
-// LoggingService.LogInfo ("Trying to recreate framework lookup for {0}, try {1}.", frameworkName, result.RetryCount);
-// result.Task = null;
-// StartFrameworkLookup (netProject);
-// return true;
-// }
-// }
-//
-// static FrameworkLookup GetFrameworkLookup (DotNetProject netProject)
-// {
-// FrameworkLookup result;
-// string fileName;
-// var cache = GetCacheDirectory (netProject.TargetFramework);
-// fileName = Path.Combine (cache, "FrameworkLookup_" + FrameworkLookup.CurrentVersion + ".dat");
-// try {
-// if (File.Exists (fileName)) {
-// result = FrameworkLookup.Load (fileName);
-// if (result != null) {
-// return result;
-// }
-// }
-// } catch (Exception e) {
-// LoggingService.LogWarning ("Can't read framework cache - recreating...", e);
-// }
-//
-// try {
-// using (var creator = FrameworkLookup.Create (fileName)) {
-// foreach (var assembly in GetFrameworkAssemblies (netProject)) {
-// var ctx = LoadAssemblyContext (assembly.Location);
-// foreach (var type in ctx.Ctx.GetAllTypeDefinitions ()) {
-// if (!type.IsPublic)
-// continue;
-// creator.AddLookup (assembly.Package.Name, assembly.FullName, type);
-// }
-// }
-// }
-// } catch (Exception e) {
-// LoggingService.LogError ("Error while storing framework lookup", e);
-// return FrameworkLookup.Empty;
-// }
-//
-// try {
-// result = FrameworkLookup.Load (fileName);
-// return result;
-// } catch (Exception e) {
-// LoggingService.LogError ("Error loading framework lookup", e);
-// return FrameworkLookup.Empty;
-// }
-// }
-// #endregion
}
-} \ No newline at end of file
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
index 34797c1c8c..e1a7c87e78 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
@@ -1,4 +1,5 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -8,7 +9,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.Ide</AssemblyName>
<RootNamespace>MonoDevelop.Ide</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -152,9 +153,11 @@
</Reference>
<Reference Include="Microsoft.CodeAnalysis">
<HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.dll</HintPath>
+ <Private>False</Private>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.Workspaces">
<HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.Workspaces.dll</HintPath>
+ <Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
@@ -168,6 +171,10 @@
<Reference Include="YamlDotNet">
<HintPath>..\..\..\packages\YamlDotNet.Signed.4.0.1-pre291\lib\net35\YamlDotNet.dll</HintPath>
</Reference>
+ <Reference Include="Microsoft.CodeAnalysis.Features">
+ <HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.Features.dll</HintPath>
+ <Private>False</Private>
+ </Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="Microsoft.TemplateEngine.Abstractions">
<HintPath>..\..\..\packages\Microsoft.TemplateEngine.Abstractions.1.0.0-beta1-20170223-126\lib\net45\Microsoft.TemplateEngine.Abstractions.dll</HintPath>
@@ -244,10 +251,6 @@
<Project>{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}</Project>
<Name>ICSharpCode.NRefactory.Cecil</Name>
</ProjectReference>
- <ProjectReference Include="..\..\..\external\RefactoringEssentials\RefactoringEssentials\RefactoringEssentials.csproj">
- <Project>{C465A5DC-AD28-49A2-89C0-F81838814A7E}</Project>
- <Name>RefactoringEssentials</Name>
- </ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="templates\AppConfigFile.xft.xml">
@@ -9229,7 +9232,6 @@
<Compile Include="MonoDevelop.Components.AutoTest.Results\NSObjectResult.cs" />
<Compile Include="MonoDevelop.Ide.TypeSystem\MonoDevelopTemporaryStorageServiceFactory.cs" />
<Compile Include="MonoDevelop.Ide.TypeSystem\WorkspaceId.cs" />
- <Compile Include="MonoDevelop.Ide.TypeSystem\MonoDevelopPersistentStorageServiceFactory.cs" />
<Compile Include="MonoDevelop.Ide.TypeSystem\SolutionSizeTracker.cs" />
<Compile Include="MonoDevelop.Components.AutoTest.Results\GtkNotebookResult.cs" />
<Compile Include="MonoDevelop.Ide\TaskUtil.cs" />
@@ -9237,13 +9239,6 @@
<Compile Include="MonoDevelop.Ide.CodeCompletion\ICompletionKeyHandler.cs" />
<Compile Include="MonoDevelop.Ide.TypeSystem\NR5CompatibiltyExtensions.cs" />
<Compile Include="MonoDevelop.Ide.Projects\ProjectConfigurationControl.cs" />
- <Compile Include="MonoDevelop.Ide.TypeSystem\MonoDevelopProjectCacheHostServiceFactory.cs" />
- <Compile Include="MonoDevelop.Ide.TypeSystem\ProjectCacheService.cs">
- <DependentUpon>MonoDevelopProjectCacheHostServiceFactory.cs</DependentUpon>
- </Compile>
- <Compile Include="MonoDevelop.Ide.TypeSystem\DocumentTrackingService.cs">
- <DependentUpon>MonoDevelopProjectCacheHostServiceFactory.cs</DependentUpon>
- </Compile>
<Compile Include="MonoDevelop.Components.AutoTest.Results\ObjectResult.cs" />
<Compile Include="MonoDevelop.Components.AutoTest\PropertyMetadata.cs" />
<Compile Include="MonoDevelop.Components.AutoTest\ObjectProperties.cs" />
@@ -9366,6 +9361,9 @@
<Compile Include="MonoDevelop.Ide.CodeCompletion\CompletionTriggerInfo.cs" />
<Compile Include="MonoDevelop.Ide.CodeCompletion\CompletionTriggerReason.cs" />
<Compile Include="MonoDevelop.Ide.CodeCompletion\CompletionSelectionStatus.cs" />
+ <Compile Include="MonoDevelop.Ide.TypeSystem\EditorNotificationServiceFactory.cs" />
+ <Compile Include="MonoDevelop.Ide.TypeSystem\GlobalOptionPersister.cs" />
+ <Compile Include="MonoDevelop.Ide.TypeSystem\TextPolicyDocumentOptionsProvider.cs" />
<Compile Include="MonoDevelop.Ide.Templates\MicrosoftTemplateEngineProjectTemplatingProvider.cs" />
<Compile Include="MonoDevelop.Ide.Templates\MicrosoftTemplateEngineSolutionTemplate.cs" />
<Compile Include="MonoDevelop.Ide.Templates\MicrosoftTemplateEngineProcessedTemplateResult.cs" />
@@ -9411,47 +9409,8 @@
<None Include="MonoDevelop.Ide.Editor.Highlighting\VSCodeImport\objective-c\language-configuration.json" />
<None Include="MonoDevelop.Ide.Editor.Highlighting\VSCodeImport\objective-c\package.json" />
</ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Target Name="AfterBuild">
- <Copy SourceFiles="@(Data)" DestinationFolder="..\..\..\build\data\%(Data.RelativeDir)" />
- </Target>
<ItemGroup>
- <Folder Include="MonoDevelop.Ide.CodeFormatting\" />
- <Folder Include="MonoDevelop.Ide.Execution\" />
- <Folder Include="MonoDevelop.Ide.Extensions\" />
- <Folder Include="MonoDevelop.Ide.CustomTools\" />
- <Folder Include="MonoDevelop.Components.Extensions\" />
- <Folder Include="MonoDevelop.Components.Theming\" />
- <Folder Include="MonoDevelop.Components.Docking\" />
- <Folder Include="MonoDevelop.Ide.Gui\" />
- <Folder Include="MonoDevelop.Ide.Desktop\" />
- <Folder Include="MonoDevelop.Ide.Projects\" />
- <Folder Include="MonoDevelop.Ide\" />
- <Folder Include="MonoDevelop.Ide.Gui.Dialogs\" />
- <Folder Include="MonoDevelop.Ide.Projects.OptionPanels\" />
- <Folder Include="MonoDevelop.Ide.Navigation\" />
- <Folder Include="MonoDevelop.Components.AutoTest\" />
- <Folder Include="MonoDevelop.Ide.Fonts\" />
- <Folder Include="MonoDevelop.Ide.Codons\" />
- <Folder Include="ExtensionModel\" />
- <Folder Include="icons\" />
- <Folder Include="MonoDevelop.Ide.WelcomePage\" />
- <Folder Include="branding\" />
- <Folder Include="MonoDevelop.Components.MainToolbar\" />
<Folder Include="MonoDevelop.Components.MainToolbar\Theme\" />
- <Folder Include="MonoDevelop.Ide.WelcomePage\icons\" />
- <Folder Include="MonoDevelop.Ide.TextEditing\" />
- <Folder Include="MonoDevelop.Components.DockNotebook\" />
- <Folder Include="MonoDevelop.Components\Windows\" />
- <Folder Include="MonoDevelop.Ide.GettingStarted\" />
- <Folder Include="MonoDevelop.Ide.Gui.Wizard\" />
- <Folder Include="MonoDevelop.Ide.Editor.Highlighting\syntaxes\IL\" />
- <Folder Include="MonoDevelop.Ide.Editor.Highlighting\syntaxes\AppleStrings\" />
- <Folder Include="MonoDevelop.Ide.Editor.Highlighting\syntaxes\ChangeLog\" />
- <Folder Include="MonoDevelop.Ide.Editor.Highlighting\syntaxes\Yaml\" />
- <Folder Include="MonoDevelop.Ide.Editor.Highlighting\syntaxes\CgShader\" />
- <Folder Include="MonoDevelop.Ide.Editor.Highlighting\syntaxes\T4\" />
- <Folder Include="MonoDevelop.Ide.Editor.Highlighting\syntaxes\ASP\" />
</ItemGroup>
<ItemGroup>
<Content Include="gtkrc">
@@ -9470,4 +9429,38 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
-</Project>
+ <ItemGroup>
+ <InternalsVisibleTo Include="MacPlatform" />
+ <InternalsVisibleTo Include="WindowsPlatform" />
+ <InternalsVisibleTo Include="MonoDevelop.Debugger" />
+ <InternalsVisibleTo Include="MonoDevelop.DesignerSupport" />
+ <InternalsVisibleTo Include="Ide.Tests" />
+ <InternalsVisibleTo Include="UnitTests" />
+ <InternalsVisibleTo Include="MonoDevelop.SourceEditor" />
+ <InternalsVisibleTo Include="Xamarin.OSXEditor" />
+ <InternalsVisibleTo Include="MonoDevelop.Refactoring" />
+ <InternalsVisibleTo Include="MonoDevelop.CSharpBinding" />
+ <InternalsVisibleTo Include="FSharpBinding" />
+ <InternalsVisibleTo Include="MonoDevelop.Xml" />
+ <InternalsVisibleTo Include="MonoDevelop.AspNet" />
+ <InternalsVisibleTo Include="Xamarin.Ide" />
+ <InternalsVisibleTo Include="MonoDevelop.SourceEditor" />
+ <InternalsVisibleTo Include="MonoDevelop.SourceEditor2" />
+ <InternalsVisibleTo Include="MonoDevelop.AssemblyBrowser" />
+ <InternalsVisibleTo Include="MonoDevelop.AspNet" />
+ <InternalsVisibleTo Include="Xamarin.Sketches" />
+ <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.AspNet" />
+ <InternalsVisibleTo Include="MonoDevelop.GtkCore" />
+ <InternalsVisibleTo Include="MonoDevelop.UnitTesting" />
+ <InternalsVisibleTo Include="MonoDevelop.Packaging" />
+ <InternalsVisibleTo Include="MonoDevelop.Packaging.Tests" />
+ <InternalsVisibleTo Include="MonoDevelop.PackageManagement" />
+ <InternalsVisibleTo Include="Xamarin.Forms.Addin.Tests" />
+ <InternalsVisibleTo Include="MonoDevelop.FSharp.Tests" />
+ <InternalsVisibleTo Include="MonoDevelop.VBNetBinding" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Target Name="AfterBuild">
+ <Copy SourceFiles="@(Data)" DestinationFolder="..\..\..\build\data\%(Data.RelativeDir)" />
+ </Target>
+</Project> \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs
index 7a80ce8dda..a999746239 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs
@@ -138,6 +138,20 @@ namespace MonoDevelop.Ide
PlatformService.OpenFolder (folderPath, selectFiles);
}
+ public static string GetMimeTypeForRoslynLanguage (string language)
+ {
+ return PlatformService.GetMimeTypeForRoslynLanguage (language);
+ }
+
+ public static IEnumerable<string> GetMimeTypeInheritanceChainForRoslynLanguage (string language)
+ {
+ var mime = GetMimeTypeForRoslynLanguage (language);
+ if (mime == null) {
+ return null;
+ }
+ return GetMimeTypeInheritanceChain (mime);
+ }
+
public static string GetMimeTypeForUri (string uri)
{
return PlatformService.GetMimeTypeForUri (uri);
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/AssemblyInfo.v14.1.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/AssemblyInfo.v15.0.cs
index acc9101cca..acc9101cca 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/AssemblyInfo.v14.1.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/AssemblyInfo.v15.0.cs
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.csproj b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.csproj
index 0f99a02927..44f9613665 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.csproj
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -51,4 +52,5 @@
<ItemGroup>
<Folder Include="MonoDevelop.Projects.Formats.MSBuild\" />
</ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v12.0.csproj b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v12.0.csproj
deleted file mode 100644
index cafb5ed080..0000000000
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v12.0.csproj
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{C4B0275C-37D3-43F2-927D-ABF556600804}</ProjectGuid>
- <OutputType>WinExe</OutputType>
- <AssemblyName>MonoDevelop.Projects.Formats.MSBuild</AssemblyName>
- <RootNamespace>MonoDevelop.Projects.Formats.MSBuild</RootNamespace>
- <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
- <BaseIntermediateOutputPath>obj\dotnet.12.0</BaseIntermediateOutputPath>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <DebugSymbols>True</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>False</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.12.0</OutputPath>
- <DefineConstants>DEBUG,NET_3_5,NET_4_0,MSBUILD_12</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
- <NoWarn>1591;1573</NoWarn>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.12.0</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
- <DebugSymbols>true</DebugSymbols>
- <NoWarn>1591;1573</NoWarn>
- <DefineConstants>NET_3_5,NET_4_0,MSBUILD_12</DefineConstants>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Runtime.Remoting" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml" />
- <Reference Include="Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <HintPath>$(MSBuildProgramFiles32)\MSBuild\12.0\Bin\Microsoft.Build.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <HintPath>$(MSBuildProgramFiles32)\MSBuild\12.0\Bin\Microsoft.Build.Framework.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Build.Utilities.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <HintPath>$(MSBuildProgramFiles32)\MSBuild\12.0\Bin\Microsoft.Build.Utilities.v12.0.dll</HintPath>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="MonoDevelop.Projects.Formats.MSBuild\LocalLogger.cs" />
- <Compile Include="AssemblyInfo.v12.0.cs" />
- <Compile Include="MonoDevelop.Projects.Formats.MSBuild\ProjectBuilder.v4.0.cs" />
- <Compile Include="MonoDevelop.Projects.Formats.MSBuild\BuildEngine.v4.0.cs" />
- </ItemGroup>
- <Import Project="MonoDevelop.Projects.MSBuild.Shared\MonoDevelop.Projects.MSBuild.Shared.projitems" Label="Shared" Condition="Exists('MonoDevelop.Projects.MSBuild.Shared\MonoDevelop.Projects.MSBuild.Shared.projitems')" />
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <Folder Include="MonoDevelop.Projects.Formats.MSBuild\" />
- </ItemGroup>
- <ItemGroup>
- <None Include="app.v12.0.config">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- <Link>MonoDevelop.Projects.Formats.MSBuild.exe.config</Link>
- </None>
- </ItemGroup>
-</Project>
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.0.csproj b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.0.csproj
deleted file mode 100644
index 0f2bfee686..0000000000
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.0.csproj
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{8EE5A588-9445-48EC-97BD-BF066E7FFD51}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <RootNamespace>MonoDevelop.Projects.Formats.MSBuild</RootNamespace>
- <AssemblyName>MonoDevelop.Projects.Formats.MSBuild</AssemblyName>
- <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
- <BaseIntermediateOutputPath>obj\dotnet.14.0</BaseIntermediateOutputPath>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.14.0</OutputPath>
- <DefineConstants>DEBUG;</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <ExternalConsole>true</ExternalConsole>
- <PlatformTarget>x86</PlatformTarget>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.14.0</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <ExternalConsole>true</ExternalConsole>
- <PlatformTarget>x86</PlatformTarget>
- </PropertyGroup>
- <PropertyGroup>
- <StartupObject>MonoDevelop.Projects.MSBuild.MainClass</StartupObject>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
- <Reference Include="Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
- <Reference Include="Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
- <Reference Include="System" />
- <Reference Include="System.Runtime.Remoting" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <None Include="app.v14.0.config">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- <Link>MonoDevelop.Projects.Formats.MSBuild.exe.config</Link>
- </None>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="MonoDevelop.Projects.Formats.MSBuild\BuildEngine.v4.0.cs" />
- <Compile Include="MonoDevelop.Projects.Formats.MSBuild\LocalLogger.cs" />
- <Compile Include="MonoDevelop.Projects.Formats.MSBuild\ProjectBuilder.v4.0.cs" />
- <Compile Include="AssemblyInfo.v14.0.cs" />
- <Compile Include="AssemblyInfo.cs" />
- </ItemGroup>
- <Import Project="MonoDevelop.Projects.MSBuild.Shared\MonoDevelop.Projects.MSBuild.Shared.projitems" Label="Shared" Condition="Exists('MonoDevelop.Projects.MSBuild.Shared\MonoDevelop.Projects.MSBuild.Shared.projitems')" />
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project>
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.1.csproj b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v15.0.csproj
index 4d3c409a81..7fa8a663b0 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v14.1.csproj
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v15.0.csproj
@@ -1,5 +1,6 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -10,13 +11,13 @@
<RootNamespace>MonoDevelop.Projects.Formats.MSBuild</RootNamespace>
<AssemblyName>MonoDevelop.Projects.Formats.MSBuild</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
- <BaseIntermediateOutputPath>obj\dotnet.14.1</BaseIntermediateOutputPath>
+ <BaseIntermediateOutputPath>obj\dotnet.15.0\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.14.1</OutputPath>
+ <OutputPath>..\..\..\build\bin\MSBuild\dotnet.15.0</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -27,7 +28,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.14.1</OutputPath>
+ <OutputPath>..\..\..\build\bin\MSBuild\dotnet.15.0</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -36,15 +37,15 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<Optimize>true</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.14.1</OutputPath>
+ <OutputPath>..\..\..\build\bin\MSBuild\dotnet.15.0</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseWin32|x86' ">
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseWin32|x86' ">
<Optimize>true</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.14.1</OutputPath>
+ <OutputPath>..\..\..\build\bin\MSBuild\dotnet.15.0</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
@@ -56,14 +57,12 @@
<!-- TODO: Linux -->
<PropertyGroup>
<MSBuild_OSS_BinDir Condition="'$(OS)' == 'Windows_NT'">$(MSBuildToolsPath)\</MSBuild_OSS_BinDir>
-
<!-- when building with xbuild on Unix, $(MSBuildToolsPath) is like `$prefix/lib/mono/xbuild/*/bin`
when building with msbuild on Unix, $(MSBuildToolsPath) is like `$prefix/lib/mono/msbuild/*/bin`
Prefer referencing msbuild 15.* assemblies over 14.1 . At runtime, we use correct one anyway
-->
<MSBuild_OSS_BinDir Condition="'$(OS)' == 'Unix' and '$(MSBuild_OSS_BinDir)' == '' and Exists('$(MSBuildToolsPath)\..\..\..\msbuild\15.0\bin\MSBuild.exe')">$(MSBuildToolsPath)\..\..\..\msbuild\15.0\bin\</MSBuild_OSS_BinDir>
<MSBuild_OSS_BinDir Condition="'$(OS)' == 'Unix' and '$(MSBuild_OSS_BinDir)' == '' and Exists('$(MSBuildToolsPath)\..\..\..\msbuild\15.0\bin\MSBuild.dll')">$(MSBuildToolsPath)\..\..\..\msbuild\15.0\bin\</MSBuild_OSS_BinDir>
- <MSBuild_OSS_BinDir Condition="'$(OS)' == 'Unix' and '$(MSBuild_OSS_BinDir)' == '' and Exists('$(MSBuildToolsPath)\..\..\..\msbuild\14.1\bin\MSBuild.exe')">$(MSBuildToolsPath)\..\..\..\msbuild\14.1\bin\</MSBuild_OSS_BinDir>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -98,7 +97,7 @@
<Compile Include="MonoDevelop.Projects.Formats.MSBuild\BuildEngine.v4.0.cs" />
<Compile Include="MonoDevelop.Projects.Formats.MSBuild\LocalLogger.cs" />
<Compile Include="MonoDevelop.Projects.Formats.MSBuild\ProjectBuilder.v4.0.cs" />
- <Compile Include="AssemblyInfo.v14.1.cs" />
+ <Compile Include="AssemblyInfo.v15.0.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<Import Project="MonoDevelop.Projects.MSBuild.Shared\MonoDevelop.Projects.MSBuild.Shared.projitems" Label="Shared" Condition="Exists('MonoDevelop.Projects.MSBuild.Shared\MonoDevelop.Projects.MSBuild.Shared.projitems')" />
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v4.0.csproj b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v4.0.csproj
deleted file mode 100644
index a1c0e9aaaa..0000000000
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.dotnet.v4.0.csproj
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{DB96F55E-41C5-4330-A427-15A4EC028BBE}</ProjectGuid>
- <OutputType>WinExe</OutputType>
- <AssemblyName>MonoDevelop.Projects.Formats.MSBuild</AssemblyName>
- <RootNamespace>MonoDevelop.Projects.Formats.MSBuild</RootNamespace>
- <BaseIntermediateOutputPath>obj\dotnet.4.0</BaseIntermediateOutputPath>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <DebugSymbols>True</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>False</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.4.0</OutputPath>
- <DefineConstants>DEBUG,NET_3_5,NET_4_0</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
- <NoWarn>1591;1573</NoWarn>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\..\build\bin\MSBuild\dotnet.4.0</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
- <DebugSymbols>true</DebugSymbols>
- <NoWarn>1591;1573</NoWarn>
- <DefineConstants>NET_3_5,NET_4_0</DefineConstants>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Runtime.Remoting" />
- <Reference Include="Microsoft.Build.Framework" />
- <Reference Include="Microsoft.Build.Utilities.v4.0" />
- <Reference Include="Microsoft.Build" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="MonoDevelop.Projects.Formats.MSBuild\LocalLogger.cs" />
- <Compile Include="AssemblyInfo.v4.0.cs" />
- <Compile Include="MonoDevelop.Projects.Formats.MSBuild\ProjectBuilder.v4.0.cs" />
- <Compile Include="MonoDevelop.Projects.Formats.MSBuild\BuildEngine.v4.0.cs" />
- </ItemGroup>
- <Import Project="MonoDevelop.Projects.MSBuild.Shared\MonoDevelop.Projects.MSBuild.Shared.projitems" Label="Shared" Condition="Exists('MonoDevelop.Projects.MSBuild.Shared\MonoDevelop.Projects.MSBuild.Shared.projitems')" />
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <Folder Include="MonoDevelop.Projects.Formats.MSBuild\" />
- </ItemGroup>
- <ItemGroup>
- <None Include="app.v4.0.config">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- <Link>MonoDevelop.Projects.Formats.MSBuild.exe.config</Link>
- </None>
- </ItemGroup>
-</Project>
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v12.0.csproj b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v12.0.csproj
index 688a02bb83..bf7ffacab8 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v12.0.csproj
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v12.0.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -9,7 +10,7 @@
<OutputType>WinExe</OutputType>
<AssemblyName>MonoDevelop.Projects.Formats.MSBuild</AssemblyName>
<RootNamespace>MonoDevelop.Projects.Formats.MSBuild</RootNamespace>
- <BaseIntermediateOutputPath>obj\12.0</BaseIntermediateOutputPath>
+ <BaseIntermediateOutputPath>obj\12.0\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
@@ -60,4 +61,5 @@
<Link>MonoDevelop.Projects.Formats.MSBuild.exe.config</Link>
</None>
</ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v14.0.csproj b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v14.0.csproj
index e35e17bbaa..596b8c30ec 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v14.0.csproj
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v14.0.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -9,7 +10,7 @@
<OutputType>WinExe</OutputType>
<AssemblyName>MonoDevelop.Projects.Formats.MSBuild</AssemblyName>
<RootNamespace>MonoDevelop.Projects.Formats.MSBuild</RootNamespace>
- <BaseIntermediateOutputPath>obj\14.0</BaseIntermediateOutputPath>
+ <BaseIntermediateOutputPath>obj\14.0\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
@@ -60,4 +61,5 @@
<Link>MonoDevelop.Projects.Formats.MSBuild.exe.config</Link>
</None>
</ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v4.0.csproj b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v4.0.csproj
index 049a85b685..6bf0a3476a 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v4.0.csproj
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild.v4.0.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -9,7 +10,7 @@
<OutputType>WinExe</OutputType>
<AssemblyName>MonoDevelop.Projects.Formats.MSBuild</AssemblyName>
<RootNamespace>MonoDevelop.Projects.Formats.MSBuild</RootNamespace>
- <BaseIntermediateOutputPath>obj\4.0</BaseIntermediateOutputPath>
+ <BaseIntermediateOutputPath>obj\4.0\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
@@ -60,4 +61,5 @@
<Link>MonoDevelop.Projects.Formats.MSBuild.exe.config</Link>
</None>
</ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.windows.config b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.windows.config
index 65923366ae..e53d2a360d 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.windows.config
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v15.0.windows.config
@@ -31,7 +31,6 @@
</runtime>
<msbuildToolsets default="15.0">
<toolset toolsVersion="15.0">
- <property name="MSBuildToolsPath" value="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\15.0@MSBuildToolsPath)" />
<property name="MSBuildExtensionsPath" value="$(MSBuildToolsPath)\..\..\..\MSBuild" />
<property name="RoslynTargetsPath" value="$(MSBuildToolsPath)\Roslyn" />
<projectImportSearchPaths>
diff --git a/main/src/core/MonoDevelop.Startup/MonoDevelop.Startup.csproj b/main/src/core/MonoDevelop.Startup/MonoDevelop.Startup.csproj
index 668c79e9a1..8f54541070 100644
--- a/main/src/core/MonoDevelop.Startup/MonoDevelop.Startup.csproj
+++ b/main/src/core/MonoDevelop.Startup/MonoDevelop.Startup.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -10,7 +11,7 @@
<AssemblyName>MonoDevelop</AssemblyName>
<RootNamespace>MonoDevelop.Startup</RootNamespace>
<ApplicationIcon>..\..\..\theme-icons\Windows\monodevelop.ico</ApplicationIcon>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/core/MonoDevelop.Startup/app.config b/main/src/core/MonoDevelop.Startup/app.config
index 4673bdf1ec..022f576913 100644
--- a/main/src/core/MonoDevelop.Startup/app.config
+++ b/main/src/core/MonoDevelop.Startup/app.config
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.SharpZipLib" publicKeyToken="1b03e6acf1164f73" culture="neutral" />
- <bindingRedirect oldVersion="0.84.0.0" newVersion="0.86.0.518"/>
- <bindingRedirect oldVersion="2.84.0.0-4.84.0.0" newVersion="0.86.0.518"/>
+ <bindingRedirect oldVersion="0.0.0.0-0.86.0.518" newVersion="0.86.0.518" />
+ <bindingRedirect oldVersion="2.84.0.0-4.84.0.0" newVersion="0.86.0.518" />
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
- <bindingRedirect oldVersion="2.0.0.0-4.3.1.0" newVersion="4.4.0.0"/>
+ <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="2.0.0.0-4.3.1.0" newVersion="4.4.0.0" />
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
- <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
+ <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
@@ -30,12 +30,73 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.1.37.0" />
+ <bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.3.0" />
</dependentAssembly>
+ <!-- HACK: workaround Mono 4.8.0 having wrong assembly version for System.Runtime.InteropServices.RuntimeInformation -->
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.0.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Composition.AttributedModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-1.0.31.0" newVersion="1.0.31.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Diagnostics.FileVersionInfo" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.CodeAnalysis.Elfie" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Composition.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-1.0.31.0" newVersion="1.0.31.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Thread" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Composition.TypedParts" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-1.0.31.0" newVersion="1.0.31.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Composition.Hosting" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-1.0.31.0" newVersion="1.0.31.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
+ </dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
diff --git a/main/src/core/MonoDevelop.TextEditor.Tests/MonoDevelop.TextEditor.Tests.csproj b/main/src/core/MonoDevelop.TextEditor.Tests/MonoDevelop.TextEditor.Tests.csproj
index 2daddf188a..9ce172cb4e 100644
--- a/main/src/core/MonoDevelop.TextEditor.Tests/MonoDevelop.TextEditor.Tests.csproj
+++ b/main/src/core/MonoDevelop.TextEditor.Tests/MonoDevelop.TextEditor.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>MonoDevelop.TextEditor.Tests</AssemblyName>
<TestRunnerCommand>..\..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
diff --git a/main/src/tools/mdhost/mdhost.csproj b/main/src/tools/mdhost/mdhost.csproj
index f59f107b4f..b8fde07df3 100644
--- a/main/src/tools/mdhost/mdhost.csproj
+++ b/main/src/tools/mdhost/mdhost.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -10,7 +11,7 @@
<AssemblyName>mdhost</AssemblyName>
<RootNamespace>mdhost</RootNamespace>
<OutputPath>..\..\..\build\bin\</OutputPath>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/src/tools/mdmonitor/AssemblyInfo.cs b/main/src/tools/mdmonitor/AssemblyInfo.cs
index f2a4e687a0..9f427aa30e 100644
--- a/main/src/tools/mdmonitor/AssemblyInfo.cs
+++ b/main/src/tools/mdmonitor/AssemblyInfo.cs
@@ -42,7 +42,7 @@ using System.Runtime.CompilerServices;
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
diff --git a/main/src/tools/mdmonitor/mdmonitor.csproj b/main/src/tools/mdmonitor/mdmonitor.csproj
index 0c7460b7a3..e0b63e7d01 100644
--- a/main/src/tools/mdmonitor/mdmonitor.csproj
+++ b/main/src/tools/mdmonitor/mdmonitor.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>Mono.Instrumentation.Monitor</RootNamespace>
<AssemblyName>mdmonitor</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -113,4 +114,4 @@
<ItemGroup>
<Folder Include="MacIntegration\" />
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/src/tools/mdtool/mdtool.csproj b/main/src/tools/mdtool/mdtool.csproj
index 261c918717..95f98633a1 100644
--- a/main/src/tools/mdtool/mdtool.csproj
+++ b/main/src/tools/mdtool/mdtool.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -10,7 +11,7 @@
<OutputPath>..\..\..\build\bin</OutputPath>
<RootNamespace>mdtool</RootNamespace>
<AssemblyName>mdtool</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/tests/Ide.Tests/Ide.Tests.csproj b/main/tests/Ide.Tests/Ide.Tests.csproj
index de1268a5c4..e70eb864bf 100644
--- a/main/tests/Ide.Tests/Ide.Tests.csproj
+++ b/main/tests/Ide.Tests/Ide.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>Ide.Tests</AssemblyName>
<TestRunnerCommand>..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
diff --git a/main/tests/MacPlatform.Tests/AssemblyInfo.cs b/main/tests/MacPlatform.Tests/AssemblyInfo.cs
index 6cda1b9641..c11564b5b9 100644
--- a/main/tests/MacPlatform.Tests/AssemblyInfo.cs
+++ b/main/tests/MacPlatform.Tests/AssemblyInfo.cs
@@ -42,7 +42,7 @@ using System.Runtime.CompilerServices;
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
diff --git a/main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj b/main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj
index bf8b4f4522..59e35c0fe5 100644
--- a/main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj
+++ b/main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>MacPlatform.Tests</AssemblyName>
<TestRunnerCommand>..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
diff --git a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/CodeCompletionBugTests.cs b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/CodeCompletionBugTests.cs
index 4d3e2fe118..ca4dbd8b8c 100644
--- a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/CodeCompletionBugTests.cs
+++ b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/CodeCompletionBugTests.cs
@@ -34,10 +34,11 @@ using System.Text;
using ICSharpCode.NRefactory6.CSharp.Completion;
using NUnit.Framework;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using System.Collections.Immutable;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
using MonoDevelop.Ide.CodeCompletion;
namespace ICSharpCode.NRefactory6.CSharp.CodeCompletion
@@ -98,7 +99,7 @@ namespace ICSharpCode.NRefactory6.CSharp.CodeCompletion
return new CompletionData (format);
}
- CompletionData ICompletionDataFactory.CreateKeywordCompletion (ICompletionDataKeyHandler keyHandler, string data, SyntaxKind syntaxKind)
+ CompletionData ICompletionDataFactory.CreateKeywordCompletion (ICompletionDataKeyHandler keyHandler, string data)
{
return new CompletionData (data);
}
@@ -322,14 +323,17 @@ namespace ICSharpCode.NRefactory6.CSharp.CodeCompletion
Compilation compilation;
try {
compilation = project.GetCompilationAsync().Result;
- var service = new CSharpCodeGenerationService(workspace);
+ var provider = workspace.Services.GetLanguageServices(LanguageNames.CSharp);
+ var factory = new CSharpCodeGenerationServiceFactory ();
+ var languageService = factory.CreateLanguageService (provider);
+ var service = languageService as ICodeGenerationService;
var ts = compilation.GetTypeSymbol("System", "Object", 0);
foreach (var member in ts.GetMembers ()) {
var method = member as IMethodSymbol;
if (method == null)
continue;
- service.CreateMethodDeclaration(method, CodeGenerationDestination.Unspecified);
+ service.CreateMethodDeclaration(method, CodeGenerationDestination.Unspecified, new CodeGenerationOptions());
}
diff --git a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/ImportCompletionTests.cs b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/ImportCompletionTests.cs
index ef43db3d22..00d90621ee 100644
--- a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/ImportCompletionTests.cs
+++ b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/ImportCompletionTests.cs
@@ -35,8 +35,8 @@ using NUnit.Framework;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using System.Collections.Immutable;
-using ICSharpCode.NRefactory6.CSharp.CodeGeneration;
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.CSharp.Completion;
diff --git a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/NameContextTests.cs b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/NameContextTests.cs
index 4d76985fb6..7a88eca15f 100644
--- a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/NameContextTests.cs
+++ b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/NameContextTests.cs
@@ -36,7 +36,9 @@ namespace ICSharpCode.NRefactory6.CSharp.CodeCompletion
public void TestNamespaceName ()
{
var provider = CodeCompletionBugTests.CreateProvider (@"$namespace n$");
- AssertEmpty(provider);
+ AssertExists (provider, "System");
+ AssertExists (provider, "Microsoft");
+ Assert.AreEqual (2, provider.Count);
}
[Test]
@@ -299,6 +301,7 @@ class Foo
/// Bug 16491 - Wrong completion on multiple parameter lambdas
/// </summary>
[Test]
+ [Ignore ("https://github.com/dotnet/roslyn/issues/17697")]
public void TestBug16491 ()
{
CodeCompletionBugTests.CombinedProviderTest (@"
@@ -317,6 +320,7 @@ class Foo
}
[Test]
+ [Ignore ("https://github.com/dotnet/roslyn/issues/17697")]
public void TestBug16491Case2 ()
{
CodeCompletionBugTests.CombinedProviderTest (@"
diff --git a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/VariableDeclarationStatementTests.cs b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/VariableDeclarationStatementTests.cs
index ee4e39160e..250e8ae04c 100644
--- a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/VariableDeclarationStatementTests.cs
+++ b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/NR5/VariableDeclarationStatementTests.cs
@@ -99,6 +99,7 @@ class MyTest
}
[Test]
+ [Ignore ()]
public void TestNameProposalForeach ()
{
var provider = CodeCompletionBugTests.CreateCtrlSpaceProvider (
diff --git a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/PortedRoslynTests/SymbolCompletionHandlerTests.cs b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/PortedRoslynTests/SymbolCompletionHandlerTests.cs
index f5c3264fb5..75b927450e 100644
--- a/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/PortedRoslynTests/SymbolCompletionHandlerTests.cs
+++ b/main/tests/MonoDevelop.CSharpBinding.Tests/Features/CodeCompletion/PortedRoslynTests/SymbolCompletionHandlerTests.cs
@@ -366,14 +366,14 @@ class CL {}";
public void NamespaceName1 ()
{
VerifyItemIsAbsent (AddUsingDirectives ("using System;", @"namespace $$"), @"String");
- VerifyItemIsAbsent (AddUsingDirectives ("using System;", @"namespace $$"), @"System");
+ VerifyItemExists (AddUsingDirectives ("using System;", @"namespace $$"), @"System");
}
[Test]
public void NamespaceName2 ()
{
VerifyItemIsAbsent (@"namespace $$", @"String");
- VerifyItemIsAbsent (@"namespace $$", @"System");
+ VerifyItemExists (@"namespace $$", @"System");
}
[Test]
diff --git a/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding.Tests.csproj b/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding.Tests.csproj
index 0c6117d1ca..8f8dc3ed3d 100644
--- a/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding.Tests.csproj
+++ b/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.CSharpBinding.Tests</RootNamespace>
<AssemblyName>MonoDevelop.CSharpBinding.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -61,6 +62,12 @@
<Reference Include="Microsoft.CodeAnalysis.Workspaces.Desktop">
<HintPath>..\..\build\bin\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
</Reference>
+ <Reference Include="System.Composition.TypedParts">
+ <HintPath>..\..\build\bin\System.Composition.TypedParts.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.CodeAnalysis.CSharp.Features">
+ <HintPath>..\..\build\bin\Microsoft.CodeAnalysis.CSharp.Features.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Features\CodeCompletion\NR5\BrowsableAttributeTests.cs" />
@@ -143,7 +150,7 @@
<Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
<Name>MonoDevelop.Core</Name>
</ProjectReference>
- <ProjectReference Include="..\..\external\RefactoringEssentials\RefactoringEssentials\RefactoringEssentials.csproj">
+ <ProjectReference Include="..\..\external\RefactoringEssentials\RefactoringEssentials.2017\RefactoringEssentials.csproj">
<Project>{C465A5DC-AD28-49A2-89C0-F81838814A7E}</Project>
<Name>RefactoringEssentials</Name>
</ProjectReference>
@@ -156,4 +163,4 @@
<Folder Include="Features\IndentEngine\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/tests/TestRunner/Properties/AssemblyInfo.cs b/main/tests/TestRunner/Properties/AssemblyInfo.cs
index 42ac938f72..48f42a0893 100644
--- a/main/tests/TestRunner/Properties/AssemblyInfo.cs
+++ b/main/tests/TestRunner/Properties/AssemblyInfo.cs
@@ -42,7 +42,7 @@ using System.Runtime.CompilerServices;
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
diff --git a/main/tests/TestRunner/TestRunner.csproj b/main/tests/TestRunner/TestRunner.csproj
index f3540fd361..a998d19b88 100644
--- a/main/tests/TestRunner/TestRunner.csproj
+++ b/main/tests/TestRunner/TestRunner.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>TestRunner</RootNamespace>
<AssemblyName>TestRunner</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -79,4 +80,4 @@
<LogicalName>MonoDevelop.TestRunner.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/GetSourceFilesAsyncTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/GetSourceFilesAsyncTests.cs
index a12556ccd0..f8f66db669 100644
--- a/main/tests/UnitTests/MonoDevelop.Projects/GetSourceFilesAsyncTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.Projects/GetSourceFilesAsyncTests.cs
@@ -147,5 +147,21 @@ namespace MonoDevelop.Projects
tcs.TrySetResult (null);
}
}
+
+ [Test ()]
+ public async Task FilesWithConfigurationCondition ()
+ {
+ string projectFile = Util.GetSampleProject ("project-with-corecompiledepends", "project-with-conditioned-file.csproj");
+ var project = (Project)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projectFile);
+
+ var projectFiles = project.Files.Where (f => f.Subtype != Subtype.Directory).ToList ();
+ var sourceFiles = await project.GetSourceFilesAsync (project.Configurations ["Debug|x86"].Selector);
+
+ Assert.IsTrue (sourceFiles.Any (f => f.FilePath.FileName == "Conditioned.cs"));
+
+ sourceFiles = await project.GetSourceFilesAsync (project.Configurations ["Release|x86"].Selector);
+
+ Assert.IsFalse (sourceFiles.Any (f => f.FilePath.FileName == "Conditioned.cs"));
+ }
}
} \ No newline at end of file
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs
index d48842ea88..57bf60b9af 100644
--- a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs
@@ -38,6 +38,7 @@ using MonoDevelop.Projects.MSBuild;
using System.Threading.Tasks;
using MonoDevelop.Core.Serialization;
using MonoDevelop.Projects.Extensions;
+using Microsoft.CodeAnalysis.CSharp;
namespace MonoDevelop.Projects
{
@@ -251,8 +252,8 @@ namespace MonoDevelop.Projects
DotNetProjectConfiguration conf = p.Configurations ["Release|x86"] as DotNetProjectConfiguration;
Assert.IsNotNull (conf);
CSharpCompilerParameters cparams = (CSharpCompilerParameters)conf.CompilationParameters;
- Assert.AreEqual (LangVersion.Default, cparams.LangVersion);
- cparams.LangVersion = LangVersion.Version5;
+ Assert.AreEqual (LanguageVersion.Default, cparams.LangVersion);
+ cparams.LangVersion = LanguageVersion.CSharp5;
Assert.IsTrue (cparams.UnsafeCode);
cparams.UnsafeCode = false;
@@ -1077,6 +1078,36 @@ namespace MonoDevelop.Projects
}
[Test]
+ public async Task AddFileToDotNetCoreProjectWithDefaultItemsDisabled ()
+ {
+ FilePath solFile = Util.GetSampleProject ("dotnetcore-console", "dotnetcore-disable-default-items.sln");
+ FilePath sdksPath = solFile.ParentDirectory.Combine ("Sdks");
+ MSBuildProjectService.RegisterProjectImportSearchPath ("MSBuildSDKsPath", sdksPath);
+
+ try {
+ var sol = (Solution)await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
+ var p = (Project)sol.Items [0];
+ Assert.IsInstanceOf<Project> (p);
+ var mp = (Project)p;
+ var files = mp.Files.Select (f => f.FilePath.FileName).ToArray ();
+ Assert.AreEqual (new string [] {
+ "Program.cs"
+ }, files);
+
+ string newFile = mp.Files[0].FilePath.ChangeName ("NewFile");
+ File.WriteAllText (newFile, string.Empty);
+ mp.AddFile (newFile);
+ await mp.SaveAsync (Util.GetMonitor ());
+
+ var itemGroup = mp.MSBuildProject.ItemGroups.LastOrDefault ();
+ Assert.IsTrue (itemGroup.Items.Any (item => item.Include == "NewFile.cs"));
+ Assert.AreEqual (2, itemGroup.Items.Count ());
+ } finally {
+ MSBuildProjectService.UnregisterProjectImportSearchPath ("MSBuildSDKsPath", sdksPath);
+ }
+ }
+
+ [Test]
public async Task SaveProjectWithWildcards ()
{
string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject.csproj");
diff --git a/main/tests/UnitTests/MonoDevelop.SourceEditor/JSonIndentEngineTests.cs b/main/tests/UnitTests/MonoDevelop.SourceEditor/JSonIndentEngineTests.cs
index dc7cb77f4b..b3da54dbf7 100644
--- a/main/tests/UnitTests/MonoDevelop.SourceEditor/JSonIndentEngineTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.SourceEditor/JSonIndentEngineTests.cs
@@ -37,7 +37,7 @@ namespace MonoDevelop.SourceEditor
[TestFixture]
public class JSonIndentEngineTests : TestBase
{
- const string indentString = " ";
+ const string indentString = "\t";
public static IDocumentIndentEngine CreateEngine (string text)
{
diff --git a/main/tests/UnitTests/UnitTests.csproj b/main/tests/UnitTests/UnitTests.csproj
index 96cff7a0b0..8051ff2e74 100644
--- a/main/tests/UnitTests/UnitTests.csproj
+++ b/main/tests/UnitTests/UnitTests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <Import Project="..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<RootNamespace>UnitTests</RootNamespace>
<TestRunnerCommand>..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -303,8 +304,6 @@
<Compile Include="MonoDevelop.Components.PropertyGrid\EditorManagerTests.cs" />
<Compile Include="MonoDevelop.Projects\MSBuildSearchPathTests.cs" />
</ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="..\..\md.targets" />
<ItemGroup>
<None Include="Makefile.am" />
<None Include="MonoDevelop.AspNet\AspNetCompletionTests.cs" />
@@ -330,4 +329,5 @@
<Folder Include="MonoDevelop.Ide.Editor\Commands\" />
<Folder Include="MonoDevelop.Components.PropertyGrid\" />
</ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
diff --git a/main/tests/UserInterfaceTests/UserInterfaceTests.csproj b/main/tests/UserInterfaceTests/UserInterfaceTests.csproj
index 86f004d024..311a3e52bf 100644
--- a/main/tests/UserInterfaceTests/UserInterfaceTests.csproj
+++ b/main/tests/UserInterfaceTests/UserInterfaceTests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>MonoDevelop.UITests</AssemblyName>
<TestRunnerCommand>..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -66,7 +67,7 @@
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="System.Xml" />
<Reference Include="Newtonsoft.Json">
- <HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ <HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
diff --git a/main/tests/UserInterfaceTests/packages.config b/main/tests/UserInterfaceTests/packages.config
index 5d49734f5e..36322802c3 100644
--- a/main/tests/UserInterfaceTests/packages.config
+++ b/main/tests/UserInterfaceTests/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="NUnit" version="2.6.4" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/main/tests/WindowsPlatform.Tests/Properties/AssemblyInfo.cs b/main/tests/WindowsPlatform.Tests/Properties/AssemblyInfo.cs
index 6ff32285f1..41fd343ba5 100644
--- a/main/tests/WindowsPlatform.Tests/Properties/AssemblyInfo.cs
+++ b/main/tests/WindowsPlatform.Tests/Properties/AssemblyInfo.cs
@@ -42,7 +42,7 @@ using System.Runtime.CompilerServices;
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion ("1.0.*")]
+[assembly: AssemblyVersion ("1.0.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
diff --git a/main/tests/WindowsPlatform.Tests/WindowsPlatform.Tests.csproj b/main/tests/WindowsPlatform.Tests/WindowsPlatform.Tests.csproj
index 85384e4af5..a35804ba8c 100644
--- a/main/tests/WindowsPlatform.Tests/WindowsPlatform.Tests.csproj
+++ b/main/tests/WindowsPlatform.Tests/WindowsPlatform.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\MonoDevelop.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
<AssemblyName>WindowsPlatform.Tests</AssemblyName>
<TestRunnerCommand>..\..\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -60,4 +61,4 @@
<Private>False</Private>
</ProjectReference>
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/main/tests/test-projects/project-with-corecompiledepends/project-with-conditioned-file.csproj b/main/tests/test-projects/project-with-corecompiledepends/project-with-conditioned-file.csproj
new file mode 100644
index 0000000000..016b374c76
--- /dev/null
+++ b/main/tests/test-projects/project-with-corecompiledepends/project-with-conditioned-file.csproj
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProjectGuid>{A93D8DA8-0BAA-4A23-ACD0-92206A4E2747}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>ConsoleME</RootNamespace>
+ <AssemblyName>ConsoleME</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <DebugType>full</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ <Compile Include="MainActivity.cs" />
+ <Compile Include="Resources\Resource.designer.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Conditioned.cs" Condition=" '$(Configuration)' == 'Debug' " />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\AboutResources.txt" />
+ <None Include="Properties\AndroidManifest.xml" />
+ <None Include="Assets\AboutAssets.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Resources\layout\Main.axml" />
+ <EmbeddedResource Include="Resources\values\Strings.xml">
+ <Generator>MSBuild:UpdateGeneratedFiles</Generator>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Resources\mipmap-hdpi\Icon.png" />
+ <EmbeddedResource Include="Resources\mipmap-mdpi\Icon.png" />
+ <EmbeddedResource Include="Resources\mipmap-xhdpi\Icon.png" />
+ <EmbeddedResource Include="Resources\mipmap-xxhdpi\Icon.png" />
+ <EmbeddedResource Include="Resources\mipmap-xxxhdpi\Icon.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Resources\drawable\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="shared.props" />
+
+
+<Target Name="UpdateGeneratedFiles" DependsOnTargets="_UpdateGeneratedFiles">
+ <ItemGroup>
+ <Compile Include="GeneratedFile.g.cs" />
+ <FileWrites Include="GeneratedFile.g.cs" />
+ </ItemGroup>
+</Target>
+
+<Target Name="_UpdateGeneratedFiles" Inputs="$(MSBuildProjectFile);@(ResourceFile)" Outputs="GeneratedFile.g.cs">
+ <WriteLinesToFile File="GeneratedFile.g.cs" Lines="hello" Overwrite="true" />
+</Target>
+
+ <PropertyGroup>
+ <CoreCompileDependsOn>UpdateGeneratedFiles;$(CoreCompileDependsOn)</CoreCompileDependsOn>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/main/winbuild.bat b/main/winbuild.bat
index 3a99441531..ab102b56f1 100644
--- a/main/winbuild.bat
+++ b/main/winbuild.bat
@@ -1,9 +1,38 @@
-git submodule update --init --recursive
-"external\nuget-binary\NuGet.exe" restore Main.sln
-"external\nuget-binary\NuGet.exe" restore external\RefactoringEssentials\RefactoringEssentials.sln
-"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" Main.sln /m /p:Configuration=DebugWin32 /p:Platform="Any CPU" %*
-
-if NOT [%ERRORLEVEL%] == ["0"] (
- for %%x in (%CMDCMDLINE%) do if /i "%%~x" == "/c" pause
- exit /b %ERRORLEVEL%
+@echo off
+setlocal enableextensions enabledelayedexpansion
+
+rem try to find MSBuild in VS2017
+rem the "correct" way is to use a COM API. not easy here.
+
+FOR %%E in (Enterprise, Professional, Community) DO (
+ set "MSBUILD_EXE=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\%%E\MSBuild\15.0\Bin\MSBuild.exe"
+ if exist "!MSBUILD_EXE!" goto :build
)
+
+rem check for MSBuild from VS2015
+
+set "MSBUILD_EXE=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
+if exist "%MSBUILD_EXE%" goto :build
+
+echo Could not find MSBuild
+exit /b 1
+
+:build
+
+git submodule sync || goto :error
+git submodule update --init --recursive || goto :error
+"external\nuget-binary\NuGet.exe" restore Main.sln || goto :error
+
+set "CONFIG=DebugWin32"
+set "PLATFORM=Any CPU"
+
+# only perform integrated restore on RefactoringEssentials, it fails on the whole solution
+"%MSBUILD_EXE%" external\RefactoringEssentials\RefactoringEssentials.2017.sln /target:Restore %* || goto :error
+
+"%MSBUILD_EXE%" Main.sln /m "/p:Configuration=%CONFIG%" "/p:Platform=%PLATFORM%" %* || goto :error
+goto :eof
+
+:error
+
+for %%x in (%CMDCMDLINE%) do if /i "%%~x" == "/c" pause
+exit /b %ERRORLEVEL%
diff --git a/main/xbuild.include b/main/xbuild.include
index d65ae031eb..dc40c7a7b8 100644
--- a/main/xbuild.include
+++ b/main/xbuild.include
@@ -25,7 +25,7 @@ PROFILE_NAME=DebugWin32
endif
endif
-XBUILD=xbuild
+XBUILD=msbuild
XBUILD_VERBOSITY ?= normal
XBUILD_ARGS=/verbosity:$(XBUILD_VERBOSITY) /nologo /property:CodePage=65001
XBUILD_PROFILE=/property:Configuration=$(PROFILE_NAME)