Browse Source

Merge branch 'master' of github.com:icsharpcode/SharpDevelop

pull/505/merge
Peter Forstmeier 11 years ago
parent
commit
3acbe6cce0
  1. 2
      src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.addin
  2. 10
      src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj
  3. 170
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpCompletionBinding.cs
  4. 26
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpDotCompletionDataProvider.cs
  5. 58
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpExpressionFinder.cs
  6. 62
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpModelTypeLocater.cs
  7. 68
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpParser.cs
  8. 119
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpResolver.cs
  9. 50
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCompilationUnit.cs
  10. 29
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpLanguageBinding.cs
  11. 9
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionBinding.cs
  12. 24
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionContext.cs
  13. 44
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EventCreationCompletionData.cs
  14. 2
      src/AddIns/Debugger/Debugger.AddIn/Pads/AutoCompleteTextBox.cs
  15. 4
      src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.cs
  16. 2
      src/AddIns/Debugger/Debugger.AddIn/Pads/ConsolePad.cs
  17. 8
      src/AddIns/Debugger/Debugger.AddIn/Pads/DebuggerDotCompletion.cs
  18. 2
      src/AddIns/Debugger/Debugger.Core/Breakpoint.cs
  19. 39
      src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs
  20. 4
      src/AddIns/Debugger/Debugger.Core/TypeSystemExtensions.cs
  21. 59
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/TextMarkerToolTipProvider.cs
  22. 18
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs
  23. 9
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/ToolboxProvider.cs
  24. 4
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.cs
  25. 23
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditView.cs
  26. 2
      src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs
  27. 19
      src/AddIns/VersionControl/GitAddIn/Src/Git.cs
  28. 1
      src/Main/Base/Project/Editor/DocumentationUIBuilder.cs
  29. 86
      src/Main/Base/Project/Editor/ToolTipUtils.cs
  30. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  31. 2
      src/Main/Base/Project/Src/Services/LanguageBinding/DefaultLanguageBinding.cs
  32. 2
      src/Main/Base/Project/Src/Services/LanguageBinding/ILanguageBinding.cs
  33. 1
      src/Main/Base/Project/Templates/ProjectTemplate.cs
  34. 11
      src/Main/Base/Project/Util/SharpDevelopExtensions.cs
  35. 11
      src/Main/Core/Project/Src/Util/CommandWrapper.cs
  36. 5
      src/Main/ICSharpCode.Core.Presentation/Menu/MenuCommand.cs
  37. 3
      src/Main/ICSharpCode.Core.Presentation/Menu/MenuService.cs
  38. 5
      src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarButton.cs
  39. 4
      src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarService.cs
  40. 10
      src/Main/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs
  41. 2
      src/Main/ICSharpCode.Core.WinForms/Menu/MenuService.cs
  42. 1
      src/Main/SharpDevelop/Project/Build/MSBuildEngine/MSBuildEngine.cs
  43. 2
      src/Main/SharpDevelop/Templates/Project/ProjectDescriptor.cs

2
src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.addin

@ -130,7 +130,7 @@
</ComplexCondition> </ComplexCondition>
</Path> </Path>
<Path name = "/AddIns/DefaultTextEditor/CodeCompletion"> <Path name = "/SharpDevelop/ViewContent/TextEditor/CodeCompletion">
<CodeCompletionBinding id = "RazorCSharp" extensions = ".cshtml" class = "ICSharpCode.AspNet.Mvc.Completion.RazorCSharpCompletionBinding"/> <CodeCompletionBinding id = "RazorCSharp" extensions = ".cshtml" class = "ICSharpCode.AspNet.Mvc.Completion.RazorCSharpCompletionBinding"/>
</Path> </Path>

10
src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj

@ -134,14 +134,9 @@
<Compile Include="Src\AddMvcViewToProjectViewModel.cs" /> <Compile Include="Src\AddMvcViewToProjectViewModel.cs" />
<Compile Include="Src\BooleanToVisibilityConverter.cs" /> <Compile Include="Src\BooleanToVisibilityConverter.cs" />
<Compile Include="Src\CloseDialogBehaviour.cs" /> <Compile Include="Src\CloseDialogBehaviour.cs" />
<Compile Include="Src\Completion\RazorCompilationUnit.cs" />
<Compile Include="Src\Completion\RazorCSharpCompletionBinding.cs" /> <Compile Include="Src\Completion\RazorCSharpCompletionBinding.cs" />
<Compile Include="Src\Completion\RazorCSharpDotCompletionDataProvider.cs" />
<Compile Include="Src\Completion\RazorCSharpExpressionFinder.cs" />
<Compile Include="Src\Completion\RazorCSharpModelTypeLocater.cs" /> <Compile Include="Src\Completion\RazorCSharpModelTypeLocater.cs" />
<Compile Include="Src\Completion\RazorCSharpParser.cs" />
<Compile Include="Src\Completion\RazorCSharpParserModelTypeVisitor.cs" /> <Compile Include="Src\Completion\RazorCSharpParserModelTypeVisitor.cs" />
<Compile Include="Src\Completion\RazorCSharpResolver.cs" />
<Compile Include="Src\CurrentAppDomain.cs" /> <Compile Include="Src\CurrentAppDomain.cs" />
<Compile Include="Src\CurrentAppDomainFactory.cs" /> <Compile Include="Src\CurrentAppDomainFactory.cs" />
<Compile Include="Src\Folding\CharacterReader.cs" /> <Compile Include="Src\Folding\CharacterReader.cs" />
@ -285,6 +280,11 @@
<Name>ICSharpCode.AvalonEdit</Name> <Name>ICSharpCode.AvalonEdit</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
<Name>ICSharpCode.NRefactory.CSharp</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> <ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name> <Name>ICSharpCode.NRefactory</Name>

170
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpCompletionBinding.cs

@ -16,27 +16,149 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
//using System; using System;
//using ICSharpCode.SharpDevelop.Editor; using System.IO;
//using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using System.Web.Razor;
// using ICSharpCode.NRefactory;
//namespace ICSharpCode.AspNet.Mvc.Completion using ICSharpCode.NRefactory.CSharp;
//{ using ICSharpCode.NRefactory.CSharp.Resolver;
// public class RazorCSharpCompletionBinding : DefaultCodeCompletionBinding using ICSharpCode.NRefactory.CSharp.TypeSystem;
// { using ICSharpCode.NRefactory.Editor;
// public RazorCSharpCompletionBinding() using ICSharpCode.NRefactory.TypeSystem;
// { using ICSharpCode.NRefactory.TypeSystem.Implementation;
// } using ICSharpCode.SharpDevelop;
// using ICSharpCode.SharpDevelop.Editor;
// public override CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch) using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
// {
// if (ch == '.') { namespace ICSharpCode.AspNet.Mvc.Completion
// new RazorCSharpDotCompletionDataProvider().ShowCompletion(editor); {
// return CodeCompletionKeyPressResult.Completed; public class RazorCSharpCompletionBinding : ICodeCompletionBinding
// } else if (ch == '(') { {
// return base.HandleKeyPress(editor, ch); public bool HandleKeyPressed(ITextEditor editor, char ch)
// } {
// return CodeCompletionKeyPressResult.None; if (ch == '.') {
// } var binding = CreateBinding(editor);
// } return binding.HandleKeyPressed(editor, ch);
//} }
return false;
}
public bool CtrlSpace(ITextEditor editor)
{
return false;
}
public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
{
// We use HandleKeyPressed instead.
return CodeCompletionKeyPressResult.None;
}
ICodeCompletionBinding CreateBinding(ITextEditor editor)
{
return SD.LanguageService.GetLanguageByExtension(".cs")
.CreateCompletionBinding(FindExpressionToComplete(editor), CreateContext(editor));
}
string FindExpressionToComplete(ITextEditor editor)
{
int endOffset = editor.Caret.Offset;
int startOffset = endOffset;
while (startOffset > 0 && IsValidCharacter(editor.Document.GetCharAt(startOffset - 1)))
startOffset--;
return editor.Document.GetText(startOffset, endOffset - startOffset);
}
bool IsValidCharacter(char ch)
{
return Char.IsLetterOrDigit(ch) ||
(ch == '.') ||
(ch == '_');
}
ICodeContext CreateContext(ITextEditor editor)
{
var compilation = SD.ParserService.GetCompilationForFile(editor.FileName);
var project = SD.ProjectService.FindProjectContainingFile(editor.FileName);
var resolveContext = new SimpleTypeResolveContext(compilation.MainAssembly);
var currentTypeDefinition = new DefaultUnresolvedTypeDefinition(project.RootNamespace, Path.GetFileNameWithoutExtension(editor.FileName));
ITypeReference baseTypeReference = new GetClassTypeReference("System.Web.Mvc", "WebViewPage", 1);
baseTypeReference = new ParameterizedTypeReference(baseTypeReference, new[] { FindModelType(editor) });
currentTypeDefinition.BaseTypes.Add(baseTypeReference);
var currentMethod = new DefaultUnresolvedMethod(currentTypeDefinition, "__ContextStub__");
currentMethod.ReturnType = KnownTypeReference.Void;
currentTypeDefinition.Members.Add(currentMethod);
var currentResolvedTypeDef = new DefaultResolvedTypeDefinition(resolveContext, currentTypeDefinition);
var projectContent = compilation.MainAssembly.UnresolvedAssembly as IProjectContent;
var currentFile = new CSharpUnresolvedFile();
currentFile.RootUsingScope.AddSimpleUsing("System.Web.Mvc");
currentFile.RootUsingScope.AddSimpleUsing("System.Web.Mvc.Ajax");
currentFile.RootUsingScope.AddSimpleUsing("System.Web.Mvc.Html");
currentFile.RootUsingScope.AddSimpleUsing("System.Web.Routing");
currentFile.TopLevelTypeDefinitions.Add(currentTypeDefinition);
if (projectContent != null) {
compilation = projectContent.AddOrUpdateFiles(currentFile).CreateCompilation(SD.ParserService.GetCurrentSolutionSnapshot());
}
var context = new CSharpTypeResolveContext(compilation.MainAssembly,
currentFile.RootUsingScope.Resolve(compilation),
currentResolvedTypeDef,
currentMethod.CreateResolved(resolveContext.WithCurrentTypeDefinition(currentResolvedTypeDef)));
return new CSharpResolver(context);
}
ITypeReference FindModelType(ITextEditor editor)
{
ParserResults results = ParseTemplate(editor.Document);
string typeName = GetModelTypeName(results);
if (string.IsNullOrWhiteSpace(typeName))
return KnownTypeReference.Object;
return new CSharpParser().ParseTypeReference(typeName)
.ToTypeReference(NameLookupMode.BaseTypeReference);
}
ParserResults ParseTemplate(ITextSource textBuffer)
{
var host = new RazorEngineHost(new CSharpRazorCodeLanguage());
var engine = new RazorTemplateEngine(host);
return engine.ParseTemplate(textBuffer.CreateReader());
}
string GetModelTypeName(ParserResults results)
{
var visitor = new RazorCSharpParserModelTypeVisitor();
results.Document.Accept(visitor);
return visitor.ModelTypeName;
}
}
static class NRUtils
{
/// <remarks>Does not support type arguments!</remarks>
public static void AddSimpleUsing(this UsingScope scope, string fullName)
{
if (scope == null)
throw new ArgumentNullException("scope");
string[] parts = fullName.Trim().Split('.');
TypeOrNamespaceReference reference = null;
foreach (var part in parts) {
if (reference != null) {
reference = new MemberTypeOrNamespaceReference(reference, part, EmptyList<ITypeReference>.Instance);
} else {
reference = new SimpleTypeOrNamespaceReference(part, EmptyList<ITypeReference>.Instance);
}
}
scope.Usings.AddIfNotNull(reference);
}
}
}

26
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpDotCompletionDataProvider.cs

@ -1,26 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// 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.AspNet.Mvc.Completion
//{
// public class RazorCSharpDotCompletionDataProvider : DotCodeCompletionItemProvider
// {
// }
//}

58
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpExpressionFinder.cs

@ -1,58 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// 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.SharpDevelop.Dom;
//
//namespace ICSharpCode.AspNet.Mvc.Completion
//{
// public class RazorCSharpExpressionFinder : IExpressionFinder
// {
// public RazorCSharpExpressionFinder()
// {
// }
//
// public ExpressionResult FindExpression(string text, int offset)
// {
// int position = offset - 1;
// while (position > 0 && IsValidCharacter(text[position])) {
// position--;
// }
// position++;
// string expression = text.Substring(position, offset - position);
// return new ExpressionResult(expression);
// }
//
// bool IsValidCharacter(char ch)
// {
// return Char.IsLetterOrDigit(ch) ||
// (ch == '.') ||
// (ch == '_');
// }
//
// public ExpressionResult FindFullExpression(string text, int offset)
// {
// return ExpressionResult.Empty;
// }
//
// public string RemoveLastPart(string expression)
// {
// return expression;
// }
// }
//}

62
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpModelTypeLocater.cs

@ -16,34 +16,34 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
//using System; using System;
//using System.Web.Razor; using System.Web.Razor;
//using ICSharpCode.SharpDevelop; using ICSharpCode.NRefactory.Editor;
//
//namespace ICSharpCode.AspNet.Mvc.Completion namespace ICSharpCode.AspNet.Mvc.Completion
//{ {
// public class RazorCSharpModelTypeLocater public class RazorCSharpModelTypeLocater
// { {
// public RazorCSharpModelTypeLocater(ITextBuffer textBuffer) public RazorCSharpModelTypeLocater(ITextSource textBuffer)
// { {
// ParserResults results = ParseTemplate(textBuffer); ParserResults results = ParseTemplate(textBuffer);
// ModelTypeName = GetModelTypeName(results); ModelTypeName = GetModelTypeName(results);
// } }
//
// ParserResults ParseTemplate(ITextBuffer textBuffer) ParserResults ParseTemplate(ITextSource textBuffer)
// { {
// var host = new RazorEngineHost(new CSharpRazorCodeLanguage()); var host = new RazorEngineHost(new CSharpRazorCodeLanguage());
// var engine = new RazorTemplateEngine(host); var engine = new RazorTemplateEngine(host);
// return engine.ParseTemplate(textBuffer.CreateReader()); return engine.ParseTemplate(textBuffer.CreateReader());
// } }
//
// string GetModelTypeName(ParserResults results) string GetModelTypeName(ParserResults results)
// { {
// var visitor = new RazorCSharpParserModelTypeVisitor(); var visitor = new RazorCSharpParserModelTypeVisitor();
// results.Document.Accept(visitor); results.Document.Accept(visitor);
// return visitor.ModelTypeName; return visitor.ModelTypeName;
// } }
//
// public string ModelTypeName { get; private set; } public string ModelTypeName { get; private set; }
// } }
//} }

68
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpParser.cs

@ -1,68 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// 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 ICSharpCode.SharpDevelop;
//using ICSharpCode.SharpDevelop.Dom;
//using ICSharpCode.SharpDevelop.Dom.CSharp;
//using ICSharpCode.SharpDevelop.Project;
//
//namespace ICSharpCode.AspNet.Mvc.Completion
//{
// public class RazorCSharpParser : IParser
// {
// public RazorCSharpParser()
// {
// }
//
// public string[] LexerTags { get; set; }
//
// public LanguageProperties Language {
// get { return LanguageProperties.CSharp; }
// }
//
// public IExpressionFinder CreateExpressionFinder(string fileName)
// {
// return new RazorCSharpExpressionFinder();
// }
//
// public bool CanParse(string fileName)
// {
// return Path.GetExtension(fileName).Equals(".cshtml", StringComparison.OrdinalIgnoreCase);
// }
//
// public bool CanParse(IProject project)
// {
// return project.Language == "C#";
// }
//
// public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ITextBuffer fileContent)
// {
// var modelTypeLocater = new RazorCSharpModelTypeLocater(fileContent);
// return new RazorCompilationUnit(projectContent) {
// ModelTypeName = modelTypeLocater.ModelTypeName
// };
// }
//
// public IResolver CreateResolver()
// {
// return new RazorCSharpResolver();
// }
// }
//}

119
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpResolver.cs

@ -1,119 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// 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 ICSharpCode.NRefactory.TypeSystem;
//
//namespace ICSharpCode.AspNet.Mvc.Completion
//{
// public class RazorCSharpResolver : IResolver
// {
// NRefactoryResolver resolver = new NRefactoryResolver(LanguageProperties.CSharp);
//
// public ResolveResult Resolve(ExpressionResult expressionResult, ParseInformation parseInfo, string fileContent)
// {
// ParseInformation parseInfoWithWebViewPageClass = CreateParseInformationWithWebViewPageClass(parseInfo);
// expressionResult.Region = GetRegionInMiddleOfWebViewPageClass();
// return resolver.Resolve(expressionResult, parseInfoWithWebViewPageClass, fileContent);
// }
//
// ParseInformation CreateParseInformationWithWebViewPageClass(ParseInformation parseInfo)
// {
// RazorCompilationUnit compilationUnit = RazorCompilationUnit.CreateFromParseInfo(parseInfo);
// AddDefaultUsings(compilationUnit);
// AddWebViewPageClass(compilationUnit);
// return new ParseInformation(compilationUnit);
// }
//
// void AddDefaultUsings(ICompilationUnit compilationUnit)
// {
// AddUsing("System.Web.Mvc", compilationUnit);
// AddUsing("System.Web.Mvc.Ajax", compilationUnit);
// AddUsing("System.Web.Mvc.Html", compilationUnit);
// AddUsing("System.Web.Routing", compilationUnit);
// }
//
// void AddUsing(string name, ICompilationUnit compilationUnit)
// {
// DefaultUsing defaultUsing = CreateUsing(name, compilationUnit.ProjectContent);
// compilationUnit.UsingScope.Usings.Add(defaultUsing);
// }
//
// DefaultUsing CreateUsing(string namespaceName, IProjectContent projectContent)
// {
// var defaultUsing = new DefaultUsing(projectContent);
// defaultUsing.Usings.Add(namespaceName);
// return defaultUsing;
// }
//
// void AddWebViewPageClass(RazorCompilationUnit compilationUnit)
// {
// DefaultClass webViewPageClass = CreateWebViewPageClass(compilationUnit);
// compilationUnit.Classes.Add(webViewPageClass);
// }
//
// DefaultClass CreateWebViewPageClass(RazorCompilationUnit compilationUnit)
// {
// var webViewPageClass = new DefaultClass(compilationUnit, "RazorWebViewPage") {
// Region = new DomRegion(1, 0, 3, 0)
// };
// IReturnType modelType = GetModelReturnType(compilationUnit);
// AddWebViewPageBaseClass(webViewPageClass, modelType);
// return webViewPageClass;
// }
//
// IReturnType GetModelReturnType(RazorCompilationUnit compilationUnit)
// {
// IClass modelType = GetClassIfTypeNameIsNotEmpty(compilationUnit.ProjectContent, compilationUnit.ModelTypeName);
// if (modelType != null) {
// return modelType.DefaultReturnType;
// }
// return new DynamicReturnType(compilationUnit.ProjectContent);
// }
//
// IClass GetClassIfTypeNameIsNotEmpty(IProjectContent projectContent, string modelTypeName)
// {
// if (!String.IsNullOrEmpty(modelTypeName)) {
// return projectContent.GetClass(modelTypeName, 0);
// }
// return null;
// }
//
// void AddWebViewPageBaseClass(DefaultClass webViewPageClass, IReturnType modelType)
// {
// IClass webViewPageBaseClass = webViewPageClass.ProjectContent.GetClass("System.Web.Mvc.WebViewPage", 1);
// if (webViewPageBaseClass != null) {
// IReturnType returnType = GetWebViewPageBaseClassReturnType(webViewPageBaseClass, modelType);
// webViewPageClass.BaseTypes.Add(returnType);
// }
// }
//
// IReturnType GetWebViewPageBaseClassReturnType(IClass webViewPageBaseClass, IReturnType modelType)
// {
// var typeArguments = new List<IReturnType>();
// typeArguments.Add(modelType);
// return new ConstructedReturnType(webViewPageBaseClass.DefaultReturnType, typeArguments);
// }
//
// DomRegion GetRegionInMiddleOfWebViewPageClass()
// {
// return new DomRegion(2, 0, 2, 0);
// }
// }
//}

50
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCompilationUnit.cs

@ -1,50 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// 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 ICSharpCode.SharpDevelop.Parser;
//
//namespace ICSharpCode.AspNet.Mvc.Completion
//{
// public class RazorCompilationUnit : DefaultCompilationUnit
// {
// public RazorCompilationUnit(IProjectContent projectContent)
// : base(projectContent)
// {
// }
//
// public static RazorCompilationUnit CreateFromParseInfo(ParseInformation parseInformation)
// {
// return new RazorCompilationUnit(parseInformation.CompilationUnit.ProjectContent) {
// ModelTypeName = GetModelTypeName(parseInformation.CompilationUnit)
// };
// }
//
// static string GetModelTypeName(ICompilationUnit compilationUnit)
// {
// var originalRazorCompilationUnit = compilationUnit as RazorCompilationUnit;
// if (originalRazorCompilationUnit != null) {
// return originalRazorCompilationUnit.ModelTypeName;
// }
// return String.Empty;
// }
//
// public string ModelTypeName { get; set; }
// }
//}

29
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpLanguageBinding.cs

@ -55,35 +55,26 @@ namespace CSharpBinding
this.container.AddService(typeof(System.CodeDom.Compiler.CodeDomProvider), new Microsoft.CSharp.CSharpCodeProvider()); this.container.AddService(typeof(System.CodeDom.Compiler.CodeDomProvider), new Microsoft.CSharp.CSharpCodeProvider());
} }
public override ICodeCompletionBinding CreateCompletionBinding(string expressionToComplete, FileName fileName, TextLocation location, ICodeContext context) public override ICodeCompletionBinding CreateCompletionBinding(string expressionToComplete, ICodeContext context)
{ {
if (fileName == null)
throw new ArgumentNullException("fileName");
if (context == null) if (context == null)
throw new ArgumentNullException("context"); throw new ArgumentNullException("context");
string content = GeneratePartialClassContextStub(fileName, location, context); string content = GeneratePartialClassContextStub(context);
const string caretPoint = "$__Caret_Point__$;"; const string caretPoint = "$__Caret_Point__$;";
int caretOffset = content.IndexOf(caretPoint, StringComparison.Ordinal) + expressionToComplete.Length; int caretOffset = content.IndexOf(caretPoint, StringComparison.Ordinal) + expressionToComplete.Length;
SD.Log.DebugFormatted("context used for dot completion: {0}", content.Replace(caretPoint, "$" + expressionToComplete + "|$")); SD.Log.DebugFormatted("context used for dot completion: {0}", content.Replace(caretPoint, "$" + expressionToComplete + "|$"));
var doc = new ReadOnlyDocument(content.Replace(caretPoint, expressionToComplete)); var doc = new ReadOnlyDocument(content.Replace(caretPoint, expressionToComplete));
return new CSharpCompletionBinding(fileName, doc.GetLocation(caretOffset), doc.CreateSnapshot()); return new CSharpCompletionBinding(context, doc.GetLocation(caretOffset), doc.CreateSnapshot());
} }
static string GeneratePartialClassContextStub(FileName fileName, TextLocation location, ICodeContext context) static string GeneratePartialClassContextStub(ICodeContext context)
{ {
var compilation = SD.ParserService.GetCompilationForFile(fileName); var member = context.CurrentMember;
var file = SD.ParserService.GetExistingUnresolvedFile(fileName);
if (compilation == null || file == null)
return "";
var unresolvedMember = file.GetMember(location);
if (unresolvedMember == null)
return "";
var member = unresolvedMember.Resolve(new SimpleTypeResolveContext(compilation.MainAssembly));
if (member == null) if (member == null)
return ""; return "";
var builder = new TypeSystemAstBuilder(); var builder = new TypeSystemAstBuilder();
MethodDeclaration decl; MethodDeclaration decl;
if (unresolvedMember is IMethod) { if (member is IMethod) {
// If it's a method, convert it directly (including parameters + type parameters) // If it's a method, convert it directly (including parameters + type parameters)
decl = (MethodDeclaration)builder.ConvertEntity(member); decl = (MethodDeclaration)builder.ConvertEntity(member);
} else { } else {
@ -97,11 +88,11 @@ namespace CSharpBinding
} }
decl.Name = "__DebuggerStub__"; decl.Name = "__DebuggerStub__";
decl.ReturnType = builder.ConvertType(member.ReturnType); decl.ReturnType = builder.ConvertType(member.ReturnType);
decl.Modifiers = unresolvedMember.IsStatic ? Modifiers.Static : Modifiers.None; decl.Modifiers = member.IsStatic ? Modifiers.Static : Modifiers.None;
// Make the method look like an explicit interface implementation so that it doesn't appear in CC // Make the method look like an explicit interface implementation so that it doesn't appear in CC
decl.PrivateImplementationType = new SimpleType("__DummyType__"); decl.PrivateImplementationType = new SimpleType("__DummyType__");
decl.Body = GenerateBodyFromContext(builder, context.LocalVariables.ToArray()); decl.Body = GenerateBodyFromContext(builder, context.LocalVariables.ToArray());
return WrapInType(unresolvedMember.DeclaringTypeDefinition, decl).ToString(); return WrapInType(context.CurrentTypeDefinition, decl).ToString();
} }
static BlockStatement GenerateBodyFromContext(TypeSystemAstBuilder builder, IVariable[] variables) static BlockStatement GenerateBodyFromContext(TypeSystemAstBuilder builder, IVariable[] variables)
@ -113,7 +104,7 @@ namespace CSharpBinding
return body; return body;
} }
static AstNode WrapInType(IUnresolvedTypeDefinition entity, EntityDeclaration decl) static AstNode WrapInType(ITypeDefinition entity, EntityDeclaration decl)
{ {
if (entity == null) if (entity == null)
return decl; return decl;
@ -137,7 +128,7 @@ namespace CSharpBinding
}; };
} }
static ClassType GetClassType(IUnresolvedTypeDefinition entity) static ClassType GetClassType(ITypeDefinition entity)
{ {
switch (entity.Kind) { switch (entity.Kind) {
case TypeKind.Interface: case TypeKind.Interface:

9
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionBinding.cs

@ -26,6 +26,7 @@ using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.Completion; using ICSharpCode.NRefactory.Completion;
using ICSharpCode.NRefactory.CSharp.Completion; using ICSharpCode.NRefactory.CSharp.Completion;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
@ -35,7 +36,7 @@ namespace CSharpBinding.Completion
{ {
public class CSharpCompletionBinding : ICodeCompletionBinding public class CSharpCompletionBinding : ICodeCompletionBinding
{ {
FileName contextFileName; ICodeContext context;
TextLocation currentLocation; TextLocation currentLocation;
ITextSource fileContent; ITextSource fileContent;
@ -44,9 +45,9 @@ namespace CSharpBinding.Completion
{ {
} }
public CSharpCompletionBinding(FileName contextFileName, TextLocation currentLocation, ITextSource fileContent) public CSharpCompletionBinding(ICodeContext context, TextLocation currentLocation, ITextSource fileContent)
{ {
this.contextFileName = contextFileName; this.context = context;
this.currentLocation = currentLocation; this.currentLocation = currentLocation;
this.fileContent = fileContent; this.fileContent = fileContent;
} }
@ -75,7 +76,7 @@ namespace CSharpBinding.Completion
if (fileContent == null) { if (fileContent == null) {
completionContext = CSharpCompletionContext.Get(editor); completionContext = CSharpCompletionContext.Get(editor);
} else { } else {
completionContext = CSharpCompletionContext.Get(editor, fileContent, currentLocation, contextFileName); completionContext = CSharpCompletionContext.Get(editor, context, currentLocation, fileContent);
} }
if (completionContext == null) if (completionContext == null)
return false; return false;

24
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionContext.cs

@ -61,38 +61,24 @@ namespace CSharpBinding.Completion
return new CSharpCompletionContext(editor, parseInfo.SyntaxTree.ConditionalSymbols, compilation, projectContent, editor.Document, parseInfo.UnresolvedFile, editor.Caret.Location); return new CSharpCompletionContext(editor, parseInfo.SyntaxTree.ConditionalSymbols, compilation, projectContent, editor.Document, parseInfo.UnresolvedFile, editor.Caret.Location);
} }
public static CSharpCompletionContext Get(ITextEditor editor, ITextSource fileContent, TextLocation currentLocation, FileName fileName) public static CSharpCompletionContext Get(ITextEditor editor, ICodeContext context, TextLocation currentLocation, ITextSource fileContent)
{ {
IDocument document = new ReadOnlyDocument(fileContent); IDocument document = new ReadOnlyDocument(fileContent);
// Don't require the very latest parse information, an older cached version is OK. var projectContent = context.Compilation.MainAssembly.UnresolvedAssembly as IProjectContent;
var parseInfo = SD.ParserService.GetCachedParseInformation(fileName) as CSharpFullParseInformation;
if (parseInfo == null) {
parseInfo = SD.ParserService.Parse(fileName) as CSharpFullParseInformation;
}
if (parseInfo == null)
return null;
var project = SD.ProjectService.FindProjectContainingFile(fileName)as CSharpProject;
if (project == null)
return null;
var solutionSnapshot = SD.ParserService.GetCurrentSolutionSnapshot();
var projectContent = solutionSnapshot.GetProjectContent(project);
if (projectContent == null) if (projectContent == null)
return null; return null;
CSharpParser parser = new CSharpParser(project.CompilerSettings); CSharpParser parser = new CSharpParser();
parser.GenerateTypeSystemMode = false; parser.GenerateTypeSystemMode = false;
SyntaxTree cu = parser.Parse(fileContent, Path.GetRandomFileName() + ".cs"); SyntaxTree cu = parser.Parse(fileContent, Path.GetRandomFileName() + ".cs");
cu.Freeze(); cu.Freeze();
CSharpUnresolvedFile unresolvedFile = cu.ToTypeSystem(); CSharpUnresolvedFile unresolvedFile = cu.ToTypeSystem();
ICompilation compilation = projectContent.AddOrUpdateFiles(unresolvedFile).CreateCompilation(solutionSnapshot); ICompilation compilation = projectContent.AddOrUpdateFiles(unresolvedFile).CreateCompilation(SD.ParserService.GetCurrentSolutionSnapshot());
return new CSharpCompletionContext(editor, parseInfo.SyntaxTree.ConditionalSymbols, compilation, projectContent, document, unresolvedFile, currentLocation); return new CSharpCompletionContext(editor, EmptyList<string>.Instance, compilation, projectContent, document, unresolvedFile, currentLocation);
} }
private CSharpCompletionContext(ITextEditor editor, IList<string> conditionalSymbols, ICompilation compilation, IProjectContent projectContent, IDocument document, CSharpUnresolvedFile unresolvedFile, TextLocation caretLocation) private CSharpCompletionContext(ITextEditor editor, IList<string> conditionalSymbols, ICompilation compilation, IProjectContent projectContent, IDocument document, CSharpUnresolvedFile unresolvedFile, TextLocation caretLocation)

44
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/EventCreationCompletionData.cs

@ -19,6 +19,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Windows.Controls;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using CSharpBinding.Parser; using CSharpBinding.Parser;
using CSharpBinding.Refactoring; using CSharpBinding.Refactoring;
@ -35,46 +36,27 @@ namespace CSharpBinding.Completion
/// </summary> /// </summary>
class EventCreationCompletionData : CompletionData class EventCreationCompletionData : CompletionData
{ {
IEvent eventDefinition; readonly string handlerName;
string varName; readonly ITypeReference delegateTypeReference;
IType delegateType; readonly bool isStatic;
string parameterList;
IUnresolvedMember callingMember;
IUnresolvedTypeDefinition declaringType;
CSharpResolver contextAtCaret;
public EventCreationCompletionData(string varName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType, CSharpResolver contextAtCaret) public EventCreationCompletionData(string handlerName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType, CSharpResolver contextAtCaret)
{ {
if (string.IsNullOrEmpty(varName)) { if (string.IsNullOrEmpty(handlerName)) {
this.DisplayText = "<Create handler for " + (evt != null ? evt.Name : "") + ">"; handlerName = (evt != null ? evt.Name : "Handle");
} }
else { this.handlerName = handlerName;
this.DisplayText = "Handle" + char.ToUpper(varName[0]) + varName.Substring(1) + (evt != null ? evt.Name : ""); this.DisplayText = "<Create " + handlerName + ">";
} this.delegateTypeReference = delegateType.ToTypeReference();
this.isStatic = callingMember != null && callingMember.IsStatic;
this.varName = varName;
this.eventDefinition = evt;
this.delegateType = delegateType;
this.parameterList = parameterList;
this.callingMember = callingMember;
this.declaringType = declaringType;
this.contextAtCaret = contextAtCaret;
} }
public override void Complete(CompletionContext context) public override void Complete(CompletionContext context)
{ {
var invokeSignature = delegateType.GetMethods(m => m.Name == "Invoke").Single();
var refactoringContext = SDRefactoringContext.Create(context.Editor, CancellationToken.None); var refactoringContext = SDRefactoringContext.Create(context.Editor, CancellationToken.None);
var delegateType = delegateTypeReference.Resolve(refactoringContext.Compilation);
var invokeSignature = delegateType.GetMethods(m => m.Name == "Invoke").Single();
var builder = refactoringContext.CreateTypeSystemAstBuilder(); var builder = refactoringContext.CreateTypeSystemAstBuilder();
string handlerName;
bool isStatic;
if (eventDefinition != null) {
handlerName = eventDefinition.Name;
isStatic = eventDefinition.IsStatic;
} else {
handlerName = varName;
isStatic = callingMember.IsStatic;
}
var throwStatement = new ThrowStatement(); var throwStatement = new ThrowStatement();
var decl = new MethodDeclaration { var decl = new MethodDeclaration {

2
src/AddIns/Debugger/Debugger.AddIn/Pads/AutoCompleteTextBox.cs

@ -134,7 +134,7 @@ namespace Debugger.AddIn.Pads.Controls
ContextTextLocation = new TextLocation(frame.NextStatement.StartLine, frame.NextStatement.StartColumn); ContextTextLocation = new TextLocation(frame.NextStatement.StartLine, frame.NextStatement.StartColumn);
} }
if (ContextFileName == null) return; if (ContextFileName == null) return;
var binding = DebuggerDotCompletion.PrepareDotCompletion(editor.Text.Substring(0, editor.CaretOffset), ContextFileName, ContextTextLocation, SD.ParserService.ResolveContext(ContextFileName, ContextTextLocation)); var binding = DebuggerDotCompletion.PrepareDotCompletion(editor.Text.Substring(0, editor.CaretOffset), SD.ParserService.ResolveContext(ContextFileName, ContextTextLocation));
if (binding == null) return; if (binding == null) return;
binding.HandleKeyPressed(editorAdapter, '.'); binding.HandleKeyPressed(editorAdapter, '.');
} else { } else {

4
src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.cs

@ -150,7 +150,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
bool showExternalMethods = DebuggingOptions.Instance.ShowExternalMethods; bool showExternalMethods = DebuggingOptions.Instance.ShowExternalMethods;
var symSource = WindowsDebugger.PdbSymbolSource; var symSource = WindowsDebugger.PdbSymbolSource;
bool hasSymbols = symSource.Handles(frame.MethodInfo) && !symSource.IsCompilerGenerated(frame.MethodInfo); bool hasSymbols = symSource.Handles(frame.MethodInfo)
&& !symSource.IsCompilerGenerated(frame.MethodInfo)
&& frame.NextStatement != null && !string.IsNullOrWhiteSpace(frame.NextStatement.Filename);
if (showExternalMethods || hasSymbols) { if (showExternalMethods || hasSymbols) {
// Show the method in the list // Show the method in the list
previousItemIsExternalMethod = false; previousItemIsExternalMethod = false;

2
src/AddIns/Debugger/Debugger.AddIn/Pads/ConsolePad.cs

@ -88,7 +88,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
var fileName = new ICSharpCode.Core.FileName(frame.NextStatement.Filename); var fileName = new ICSharpCode.Core.FileName(frame.NextStatement.Filename);
var textLocation = new TextLocation(frame.NextStatement.StartLine, frame.NextStatement.StartColumn); var textLocation = new TextLocation(frame.NextStatement.StartLine, frame.NextStatement.StartColumn);
var binding = DebuggerDotCompletion.PrepareDotCompletion(currentText, fileName, textLocation, SD.ParserService.ResolveContext(fileName, textLocation)); var binding = DebuggerDotCompletion.PrepareDotCompletion(currentText, SD.ParserService.ResolveContext(fileName, textLocation));
if (binding == null) return; if (binding == null) return;
binding.HandleKeyPressed(console.TextEditor, '.'); binding.HandleKeyPressed(console.TextEditor, '.');
} }

8
src/AddIns/Debugger/Debugger.AddIn/Pads/DebuggerDotCompletion.cs

@ -41,12 +41,10 @@ namespace Debugger.AddIn.Pads.Controls
return !errors.Any(); return !errors.Any();
} }
public static ICodeCompletionBinding PrepareDotCompletion(string expressionToComplete, FileName fileName, TextLocation location, ICodeContext context) public static ICodeCompletionBinding PrepareDotCompletion(string expressionToComplete, ICodeContext context)
{ {
var lang = SD.LanguageService.GetLanguageByFileName(fileName); return SD.LanguageService.GetLanguageByExtension(".cs")
if (lang == null) .CreateCompletionBinding(expressionToComplete, context);
return null;
return lang.CreateCompletionBinding(expressionToComplete, fileName, location, context);
} }
} }
} }

2
src/AddIns/Debugger/Debugger.Core/Breakpoint.cs

@ -84,7 +84,7 @@ namespace Debugger
public void SetBreakpoint(Module module) public void SetBreakpoint(Module module)
{ {
foreach(var symbolSource in module.Process.Debugger.SymbolSources) { foreach (var symbolSource in module.Process.Debugger.SymbolSources) {
foreach (var seq in symbolSource.GetSequencePoints(module, this.FileName, this.Line, this.Column)) { foreach (var seq in symbolSource.GetSequencePoints(module, this.FileName, this.Line, this.Column)) {
ICorDebugFunction corFunction = module.CorModule.GetFunctionFromToken(seq.MethodDefToken); ICorDebugFunction corFunction = module.CorModule.GetFunctionFromToken(seq.MethodDefToken);
ICorDebugFunctionBreakpoint corBreakpoint = corFunction.GetILCode().CreateBreakpoint((uint)seq.ILOffset); ICorDebugFunctionBreakpoint corBreakpoint = corFunction.GetILCode().CreateBreakpoint((uint)seq.ILOffset);

39
src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs

@ -48,6 +48,14 @@ namespace Debugger
this.StartLine, this.StartColumn, this.StartLine, this.StartColumn,
this.EndLine, this.EndColumn); this.EndLine, this.EndColumn);
} }
public bool ContainsLocation(int line, int column = 0)
{
if (column == 0)
return line >= StartLine && line <= EndLine;
return (StartLine < line || (StartLine == line && StartColumn <= column))
&& (line < EndLine || (line == EndLine && column <= EndColumn));
}
} }
public struct ILRange public struct ILRange
@ -185,14 +193,14 @@ namespace Debugger
var realSeqPoints = sequencePoints.Where(p => p.StartLine != 0xFEEFEE); var realSeqPoints = sequencePoints.Where(p => p.StartLine != 0xFEEFEE);
// Find point for which (ilstart <= iloffset < ilend) or fallback to the next valid sequence point // Find point for which (ilstart <= iloffset < ilend) or fallback to the next valid sequence point
var sequencePoint = realSeqPoints.FirstOrDefault(p => p.ILRanges.Any(r => r.From <= iloffset && iloffset < r.To)) ?? var sequencePoint = realSeqPoints.FirstOrDefault(p => p.ILRanges.Any(r => r.From <= iloffset && iloffset < r.To))
realSeqPoints.FirstOrDefault(p => iloffset <= p.ILOffset); ?? realSeqPoints.FirstOrDefault(p => iloffset <= p.ILOffset);
if (sequencePoint != null) { if (sequencePoint != null) {
// VB.NET sometimes produces temporary files which it then deletes // VB.NET sometimes produces temporary files which it then deletes
// (eg 17d14f5c-a337-4978-8281-53493378c1071.vb) // (eg 17d14f5c-a337-4978-8281-53493378c1071.vb)
string name = Path.GetFileName(sequencePoint.Filename); string name = Path.GetFileName(sequencePoint.Filename);
if (name.Length == 40 && name.EndsWith(".vb")) { if (name.Length == 40 && name.EndsWith(".vb", StringComparison.OrdinalIgnoreCase)) {
if (name.Substring(0, name.Length - 3).All(c => ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || (c == '-'))) { if (name.Substring(0, name.Length - 3).All(c => ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || (c == '-'))) {
return null; return null;
} }
@ -226,25 +234,34 @@ namespace Debugger
try { try {
uint validLine = symDoc.FindClosestLine((uint)line); uint validLine = symDoc.FindClosestLine((uint)line);
symMethods = symReader.GetMethodsFromDocumentPosition(symDoc, validLine, (uint)column); symMethods = symReader.GetMethodsFromDocumentPosition(symDoc, validLine, (uint)column);
if (validLine > 0)
line = (int)validLine;
} catch { } catch {
yield break; //Not found yield break; //Not found
} }
foreach (ISymUnmanagedMethod symMethod in symMethods) { foreach (ISymUnmanagedMethod symMethod in symMethods) {
var corFunction = module.CorModule.GetFunctionFromToken(symMethod.GetToken()); var corFunction = module.CorModule.GetFunctionFromToken(symMethod.GetToken());
int codesize = (int)corFunction.GetILCode().GetSize(); int codeSize = (int)corFunction.GetILCode().GetSize();
var seqPoints = symMethod.GetSequencePoints(codesize).Where(s => s.StartLine != 0xFEEFEE); var seqPoints = symMethod.GetSequencePoints(codeSize).Where(s => s.StartLine != 0xFEEFEE).OrderBy(s => s.StartLine).ToArray();
SequencePoint seqPoint = null; SequencePoint seqPoint = FindNearestMatchingSequencePoint(seqPoints, line, column);
if (column != 0) {
seqPoint = seqPoints.FirstOrDefault(s => (s.StartLine < line || (s.StartLine == line && s.StartColumn <= column)) &&
(line < s.EndLine || (line == s.EndLine && column <= s.EndColumn)));
}
seqPoint = seqPoint ?? seqPoints.FirstOrDefault(s => line <= s.StartLine);
if (seqPoint != null) if (seqPoint != null)
yield return seqPoint; yield return seqPoint;
} }
} }
SequencePoint FindNearestMatchingSequencePoint(SequencePoint[] seqPoints, int line, int column)
{
for (int i = 0; i < seqPoints.Length; i++) {
var s = seqPoints[i];
if (s.ContainsLocation(line, column))
return s;
if (s.StartLine > line)
return s;
}
return null;
}
public IEnumerable<ILRange> GetIgnoredILRanges(IMethod method) public IEnumerable<ILRange> GetIgnoredILRanges(IMethod method)
{ {
var symMethod = method.GetSymMethod(); var symMethod = method.GetSymMethod();

4
src/AddIns/Debugger/Debugger.Core/TypeSystemExtensions.cs

@ -232,7 +232,9 @@ namespace Debugger
{ {
var info = GetInfo(method.ParentAssembly); var info = GetInfo(method.ParentAssembly);
var variableTypes = info.GetLocalVariableTypes(method.UnresolvedMember); var variableTypes = info.GetLocalVariableTypes(method.UnresolvedMember);
return variableTypes[index].Resolve(new SimpleTypeResolveContext(method)); return variableTypes[index]
.Resolve(new SimpleTypeResolveContext(method))
.AcceptVisitor(method.Substitution);
} }
#endregion #endregion

59
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/TextMarkerToolTipProvider.cs

@ -67,64 +67,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
string GetTooltipTextForCollapsedSection(ToolTipRequestEventArgs args, FoldingSection foldingSection) string GetTooltipTextForCollapsedSection(ToolTipRequestEventArgs args, FoldingSection foldingSection)
{ {
// This fixes SD-1394: return ToolTipUtils.GetAlignedText(args.Editor.Document, foldingSection.StartOffset, foldingSection.EndOffset);
// Each line is checked for leading indentation whitespaces. If
// a line has the same or more indentation than the first line,
// it is reduced. If a line is less indented than the first line
// the indentation is removed completely.
//
// See the following example:
// line 1
// line 2
// line 3
// line 4
//
// is reduced to:
// line 1
// line 2
// line 3
// line 4
const int maxLineCount = 15;
TextDocument document = (TextDocument)args.Editor.Document;
int startOffset = foldingSection.StartOffset;
int endOffset = foldingSection.EndOffset;
DocumentLine startLine = document.GetLineByOffset(startOffset);
DocumentLine endLine = document.GetLineByOffset(endOffset);
StringBuilder builder = new StringBuilder();
DocumentLine current = startLine;
ISegment startIndent = TextUtilities.GetLeadingWhitespace(document, startLine);
int lineCount = 0;
while (current != endLine.NextLine && lineCount < maxLineCount) {
ISegment currentIndent = TextUtilities.GetLeadingWhitespace(document, current);
if (current == startLine && current == endLine)
builder.Append(document.GetText(startOffset, endOffset - startOffset));
else if (current == startLine) {
if (current.EndOffset - startOffset > 0)
builder.AppendLine(document.GetText(startOffset, current.EndOffset - startOffset).TrimStart());
} else if (current == endLine) {
if (startIndent.Length <= currentIndent.Length)
builder.Append(document.GetText(current.Offset + startIndent.Length, endOffset - current.Offset - startIndent.Length));
else
builder.Append(document.GetText(current.Offset + currentIndent.Length, endOffset - current.Offset - currentIndent.Length));
} else {
if (startIndent.Length <= currentIndent.Length)
builder.AppendLine(document.GetText(current.Offset + startIndent.Length, current.Length - startIndent.Length));
else
builder.AppendLine(document.GetText(current.Offset + currentIndent.Length, current.Length - currentIndent.Length));
}
current = current.NextLine;
lineCount++;
}
if (current != endLine.NextLine)
builder.Append("...");
return builder.ToString();
} }
} }
} }

18
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs

@ -50,6 +50,7 @@ namespace ICSharpCode.FormsDesigner
readonly Control pleaseWaitLabel = new Label() { Text = StringParser.Parse("${res:Global.PleaseWait}"), TextAlign=ContentAlignment.MiddleCenter }; readonly Control pleaseWaitLabel = new Label() { Text = StringParser.Parse("${res:Global.PleaseWait}"), TextAlign=ContentAlignment.MiddleCenter };
DesignSurface designSurface; DesignSurface designSurface;
bool disposing; bool disposing;
Timer timer = new Timer { Interval = 200 };
readonly IViewContent primaryViewContent; readonly IViewContent primaryViewContent;
readonly IDesignerLoaderProvider loaderProvider; readonly IDesignerLoaderProvider loaderProvider;
@ -142,6 +143,7 @@ namespace ICSharpCode.FormsDesigner
this.IsActiveViewContentChanged += this.IsActiveViewContentChangedHandler; this.IsActiveViewContentChanged += this.IsActiveViewContentChangedHandler;
timer.Tick += Timer_Tick;
FileService.FileRemoving += this.FileServiceFileRemoving; FileService.FileRemoving += this.FileServiceFileRemoving;
SD.Debugger.DebugStarting += this.DebugStarting; SD.Debugger.DebugStarting += this.DebugStarting;
} }
@ -168,6 +170,20 @@ namespace ICSharpCode.FormsDesigner
this.Files.Add(primaryViewContent.PrimaryFile); this.Files.Add(primaryViewContent.PrimaryFile);
} }
void Timer_Tick(object sender, System.EventArgs e)
{
// The WinForms designer internally relies on Application.Idle for some actions, e.g. 'Show Code'
// This event does not get raised in a WPF application.
// While we do forward WPF's equivalent idle event to WinForms (see WorkbenchStartup.cs),
// it doesn't happen often enough -- in particular, it doesn't get raised while the mouse
// is over the WinForms design surface.
// This caused the bug: https://github.com/icsharpcode/SharpDevelop/issues/525
// As a workaround, we use a timer to raise the event while the designer is open.
// Note: this timer is implemented in the WinForms designer and not globally in SharpDevelop
// so that we don't wake up the CPU unnecessarily when the designer is not in use.
Application.RaiseIdle(e);
}
bool inMasterLoadOperation; bool inMasterLoadOperation;
protected override void LoadInternal(OpenedFile file, System.IO.Stream stream) protected override void LoadInternal(OpenedFile file, System.IO.Stream stream)
@ -344,6 +360,7 @@ namespace ICSharpCode.FormsDesigner
UpdatePropertyPad(); UpdatePropertyPad();
hasUnmergedChanges = false; hasUnmergedChanges = false;
timer.Start();
LoggingService.Info("Form Designer: END INITIALIZE"); LoggingService.Info("Form Designer: END INITIALIZE");
} }
@ -404,6 +421,7 @@ namespace ICSharpCode.FormsDesigner
{ {
LoggingService.Debug("FormsDesigner unloading, setting ActiveDesignSurface to null"); LoggingService.Debug("FormsDesigner unloading, setting ActiveDesignSurface to null");
designSurfaceManager.ActiveDesignSurface = null; designSurfaceManager.ActiveDesignSurface = null;
timer.Stop();
bool savedIsDirty = (this.DesignerCodeFile == null) ? false : this.DesignerCodeFile.IsDirty; bool savedIsDirty = (this.DesignerCodeFile == null) ? false : this.DesignerCodeFile.IsDirty;
this.UserContent = this.pleaseWaitLabel; this.UserContent = this.pleaseWaitLabel;

9
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/ToolboxProvider.cs

@ -136,6 +136,13 @@ namespace ICSharpCode.FormsDesigner
toolboxService.SetSelectedToolboxItem(null); toolboxService.SetSelectedToolboxItem(null);
} }
static ICompilation GetCompilationForCurrentProject()
{
IProject project = SD.ProjectService.CurrentProject;
if (project == null) return null;
return SD.ParserService.GetCompilation(project);
}
static void SelectedToolUsedHandler(object sender, EventArgs e) static void SelectedToolUsedHandler(object sender, EventArgs e)
{ {
SD.Log.Debug("SelectedToolUsedHandler"); SD.Log.Debug("SelectedToolUsedHandler");
@ -148,7 +155,7 @@ namespace ICSharpCode.FormsDesigner
if (selectedItem != null && selectedItem.TypeName != null) { if (selectedItem != null && selectedItem.TypeName != null) {
SD.Log.Debug("Checking for reference to CustomComponent: " + selectedItem.TypeName); SD.Log.Debug("Checking for reference to CustomComponent: " + selectedItem.TypeName);
// Check current project has the custom component first. // Check current project has the custom component first.
ICompilation currentCompilation = SD.ParserService.GetCompilationForCurrentProject(); ICompilation currentCompilation = GetCompilationForCurrentProject();
var typeName = new FullTypeName(selectedItem.TypeName); var typeName = new FullTypeName(selectedItem.TypeName);
if (currentCompilation != null && currentCompilation.FindType(typeName).Kind == TypeKind.Unknown) { if (currentCompilation != null && currentCompilation.FindType(typeName).Kind == TypeKind.Unknown) {
// Check other projects in the solution. // Check other projects in the solution.

4
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.cs

@ -34,10 +34,6 @@ namespace HexEditor.View
get { return hexEditControl.HasSomethingSelected; } get { return hexEditControl.HasSomethingSelected; }
} }
public bool EditorFocused {
get { return hexEditControl.Focused; }
}
public bool CanUndo { public bool CanUndo {
get { return hexEditControl.CanUndo; } get { return hexEditControl.CanUndo; }
} }

23
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditView.cs

@ -18,10 +18,8 @@
using System; using System;
using System.IO; using System.IO;
using ICSharpCode.Core; using System.Windows.Input;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.WinForms; using ICSharpCode.SharpDevelop.WinForms;
using ICSharpCode.SharpDevelop.Workbench; using ICSharpCode.SharpDevelop.Workbench;
@ -34,7 +32,8 @@ namespace HexEditor.View
public HexEditView(OpenedFile file) public HexEditView(OpenedFile file)
{ {
hexEditContainer = new HexEditContainer(); hexEditContainer = new HexEditContainer();
hexEditContainer.hexEditControl.DocumentChanged += new EventHandler(DocumentChanged); hexEditContainer.hexEditControl.DocumentChanged += DocumentChanged;
hexEditContainer.hexEditControl.Selection.SelectionChanged += SelectionChanged;
this.Files.Add(file); this.Files.Add(file);
@ -67,23 +66,23 @@ namespace HexEditor.View
#region IClipboardHandler #region IClipboardHandler
public bool EnableCut { public bool EnableCut {
get { return hexEditContainer.HasSomethingSelected & hexEditContainer.EditorFocused; } get { return hexEditContainer.HasSomethingSelected; }
} }
public bool EnableCopy { public bool EnableCopy {
get { return hexEditContainer.HasSomethingSelected & hexEditContainer.EditorFocused; } get { return hexEditContainer.HasSomethingSelected; }
} }
public bool EnablePaste { public bool EnablePaste {
get { return hexEditContainer.EditorFocused; } get { return true; }
} }
public bool EnableDelete { public bool EnableDelete {
get { return hexEditContainer.HasSomethingSelected & hexEditContainer.EditorFocused; } get { return hexEditContainer.HasSomethingSelected; }
} }
public bool EnableSelectAll { public bool EnableSelectAll {
get { return hexEditContainer.EditorFocused; } get { return true; }
} }
public void Cut() public void Cut()
@ -137,10 +136,12 @@ namespace HexEditor.View
void DocumentChanged(object sender, EventArgs e) void DocumentChanged(object sender, EventArgs e)
{ {
if (PrimaryFile != null) PrimaryFile.MakeDirty(); if (PrimaryFile != null) PrimaryFile.MakeDirty();
CommandManager.InvalidateRequerySuggested();
} }
public override bool IsDirty { void SelectionChanged(object sender, System.EventArgs e)
get { return base.IsDirty; } {
CommandManager.InvalidateRequerySuggested();
} }
} }
} }

2
src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs

@ -106,7 +106,7 @@ namespace ICSharpCode.ILSpyAddIn
return symbols.LocalVariables.Where(v => v.OriginalVariable != null).Select( return symbols.LocalVariables.Where(v => v.OriginalVariable != null).Select(
v => new Debugger.ILLocalVariable() { v => new Debugger.ILLocalVariable() {
Index = v.OriginalVariable.Index, Index = v.OriginalVariable.Index,
Type = loader.ReadTypeReference(v.Type).Resolve(context), Type = loader.ReadTypeReference(v.Type).Resolve(context).AcceptVisitor(method.Substitution),
Name = v.Name, Name = v.Name,
IsCompilerGenerated = false, IsCompilerGenerated = false,
ILRanges = new [] { new ILRange(0, int.MaxValue) } ILRanges = new [] { new ILRange(0, int.MaxValue) }

19
src/AddIns/VersionControl/GitAddIn/Src/Git.cs

@ -18,6 +18,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
@ -59,7 +60,7 @@ namespace ICSharpCode.GitAddIn
string wcRoot = FindWorkingCopyRoot(fileName); string wcRoot = FindWorkingCopyRoot(fileName);
if (wcRoot == null) if (wcRoot == null)
return Task.FromResult(false); return Task.FromResult(false);
return RunGitAsync(wcRoot, "add", AdaptFileName(wcRoot, fileName)); return RunGitAsync(wcRoot, "add", "--intent-to-add", AdaptFileName(wcRoot, fileName));
} }
public static Task RemoveAsync(string fileName, bool indexOnly) public static Task RemoveAsync(string fileName, bool indexOnly)
@ -79,14 +80,24 @@ namespace ICSharpCode.GitAddIn
return relFileName.Replace('\\', '/'); return relFileName.Replace('\\', '/');
} }
public static Task<int> RunGitAsync(string workingDir, params string[] arguments) static SemaphoreSlim gitMutex = new SemaphoreSlim(1);
public static async Task<int> RunGitAsync(string workingDir, params string[] arguments)
{ {
string git = FindGit(); string git = FindGit();
if (git == null) if (git == null)
return Task.FromResult(9009); return 9009;
// Wait until other git calls have finished running
// This prevents git from failing due to a locked index when several files
// are added concurrently
await gitMutex.WaitAsync();
try {
ProcessRunner p = new ProcessRunner(); ProcessRunner p = new ProcessRunner();
p.WorkingDirectory = workingDir; p.WorkingDirectory = workingDir;
return p.RunInOutputPadAsync(GitMessageView.Category, git, arguments); return await p.RunInOutputPadAsync(GitMessageView.Category, git, arguments);
} finally {
gitMutex.Release();
}
} }
/// <summary> /// <summary>

1
src/Main/Base/Project/Editor/DocumentationUIBuilder.cs

@ -453,6 +453,7 @@ namespace ICSharpCode.SharpDevelop.Editor
AddBlock(para); AddBlock(para);
} }
inlineCollection.Add(inline); inlineCollection.Add(inline);
ignoreWhitespace = false;
} }
public void AddBlock(Block block) public void AddBlock(Block block)

86
src/Main/Base/Project/Editor/ToolTipUtils.cs

@ -0,0 +1,86 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// 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 ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.SharpDevelop.Editor
{
public static class ToolTipUtils
{
public static string GetAlignedText(IDocument document, int startOffset, int endOffset, int maxLineCount = 15)
{
// This fixes SD-1394:
// Each line is checked for leading indentation whitespaces. If
// a line has the same or more indentation than the first line,
// it is reduced. If a line is less indented than the first line
// the indentation is removed completely.
//
// See the following example:
// line 1
// line 2
// line 3
// line 4
//
// is reduced to:
// line 1
// line 2
// line 3
// line 4
if (maxLineCount < 1)
maxLineCount = int.MaxValue;
IDocumentLine startLine = document.GetLineByOffset(startOffset);
IDocumentLine endLine = document.GetLineByOffset(endOffset);
StringBuilder builder = new StringBuilder();
IDocumentLine current = startLine;
ISegment startIndent = TextUtilities.GetWhitespaceAfter(document, startLine.Offset);
int lineCount = 0;
while (current != endLine.NextLine && lineCount < maxLineCount) {
ISegment currentIndent = TextUtilities.GetWhitespaceAfter(document, current.Offset);
if (current == startLine && current == endLine)
builder.Append(document.GetText(startOffset, endOffset - startOffset));
else if (current == startLine) {
if (current.EndOffset - startOffset > 0)
builder.AppendLine(document.GetText(startOffset, current.EndOffset - startOffset).TrimStart());
} else if (current == endLine) {
if (startIndent.Length <= currentIndent.Length)
builder.Append(document.GetText(current.Offset + startIndent.Length, endOffset - current.Offset - startIndent.Length));
else
builder.Append(document.GetText(current.Offset + currentIndent.Length, endOffset - current.Offset - currentIndent.Length));
} else {
if (startIndent.Length <= currentIndent.Length)
builder.AppendLine(document.GetText(current.Offset + startIndent.Length, current.Length - startIndent.Length));
else
builder.AppendLine(document.GetText(current.Offset + currentIndent.Length, current.Length - currentIndent.Length));
}
current = current.NextLine;
lineCount++;
}
if (current != endLine.NextLine)
builder.Append("...");
return builder.ToString();
}
}
}

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -171,6 +171,7 @@
<DependentUpon>ToolTipService.cs</DependentUpon> <DependentUpon>ToolTipService.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Editor\ToolTipService.cs" /> <Compile Include="Editor\ToolTipService.cs" />
<Compile Include="Editor\ToolTipUtils.cs" />
<Compile Include="Editor\XmlDocFormatter.cs" /> <Compile Include="Editor\XmlDocFormatter.cs" />
<Compile Include="Parser\CombinedAssemblySearcher.cs" /> <Compile Include="Parser\CombinedAssemblySearcher.cs" />
<Compile Include="Parser\DefaultAssemblySearcher.cs" /> <Compile Include="Parser\DefaultAssemblySearcher.cs" />

2
src/Main/Base/Project/Src/Services/LanguageBinding/DefaultLanguageBinding.cs

@ -75,7 +75,7 @@ namespace ICSharpCode.SharpDevelop
} }
} }
public virtual ICodeCompletionBinding CreateCompletionBinding(string expressionToComplete, FileName fileName, TextLocation location, ICodeContext context) public virtual ICodeCompletionBinding CreateCompletionBinding(string expressionToComplete, ICodeContext context)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }

2
src/Main/Base/Project/Src/Services/LanguageBinding/ILanguageBinding.cs

@ -65,6 +65,6 @@ namespace ICSharpCode.SharpDevelop
/// <summary> /// <summary>
/// Creates a completion binding for a given expression and context. /// Creates a completion binding for a given expression and context.
/// </summary> /// </summary>
ICodeCompletionBinding CreateCompletionBinding(string expressionToComplete, FileName fileName, TextLocation location, ICodeContext context); ICodeCompletionBinding CreateCompletionBinding(string expressionToComplete, ICodeContext context);
} }
} }

1
src/Main/Base/Project/Templates/ProjectTemplate.cs

@ -70,6 +70,7 @@ namespace ICSharpCode.SharpDevelop.Templates
if (SD.ProjectService.OpenSolution(createdSolution)) { if (SD.ProjectService.OpenSolution(createdSolution)) {
solutionOpened = true; solutionOpened = true;
SD.GetRequiredService<IProjectServiceRaiseEvents>().RaiseSolutionCreated(new SolutionEventArgs(createdSolution)); SD.GetRequiredService<IProjectServiceRaiseEvents>().RaiseSolutionCreated(new SolutionEventArgs(createdSolution));
FileService.FireFileCreated(solutionFileName, false);
return result; return result;
} else { } else {
return null; return null;

11
src/Main/Base/Project/Util/SharpDevelopExtensions.cs

@ -902,17 +902,6 @@ namespace ICSharpCode.SharpDevelop
} }
#endregion #endregion
#region Service Extensions
public static ICompilation GetCompilationForCurrentProject(this IParserService svc)
{
if (svc == null)
throw new ArgumentNullException("svc");
IProject project = SD.ProjectService.CurrentProject;
if (project == null) return null;
return SD.ParserService.GetCompilation(project);
}
#endregion
#region Resource Service Extensions #region Resource Service Extensions
/// <summary> /// <summary>
/// Gets an <see cref="IImage"/> from a resource. /// Gets an <see cref="IImage"/> from a resource.

11
src/Main/Core/Project/Src/Util/CommandWrapper.cs

@ -44,6 +44,17 @@ namespace ICSharpCode.Core
/// </summary> /// </summary>
public static ICommand CreateLazyCommand(Codon codon, IReadOnlyCollection<ICondition> conditions) public static ICommand CreateLazyCommand(Codon codon, IReadOnlyCollection<ICondition> conditions)
{ {
if (codon.Properties["loadclasslazy"] == "false") {
// if lazy loading was explicitly disabled, create the actual command now
return CreateCommand(codon, conditions);
}
if (codon.Properties.Contains("command") && !codon.Properties.Contains("loadclasslazy")) {
// If we're using the 'command=' syntax, this is most likely a built-in command
// where lazy loading isn't useful (and hurts if CanExecute is used).
// Don't use lazy loading unless loadclasslazy is set explicitly.
return CreateCommand(codon, conditions);
}
// Create the wrapper that lazily loads the actual command.
return new CommandWrapper(codon, conditions); return new CommandWrapper(codon, conditions);
} }

5
src/Main/ICSharpCode.Core.Presentation/Menu/MenuCommand.cs

@ -32,12 +32,9 @@ namespace ICSharpCode.Core.Presentation
{ {
readonly string ActivationMethod; readonly string ActivationMethod;
public MenuCommand(UIElement inputBindingOwner, Codon codon, object caller, bool createCommand, string activationMethod, IReadOnlyCollection<ICondition> conditions) : base(codon, caller, conditions) public MenuCommand(UIElement inputBindingOwner, Codon codon, object caller, string activationMethod, IReadOnlyCollection<ICondition> conditions) : base(codon, caller, conditions)
{ {
this.ActivationMethod = activationMethod; this.ActivationMethod = activationMethod;
if (createCommand)
this.Command = CommandWrapper.CreateCommand(codon, conditions);
else
this.Command = CommandWrapper.CreateLazyCommand(codon, conditions); this.Command = CommandWrapper.CreateLazyCommand(codon, conditions);
this.CommandParameter = caller; this.CommandParameter = caller;

3
src/Main/ICSharpCode.Core.Presentation/Menu/MenuService.cs

@ -211,7 +211,6 @@ namespace ICSharpCode.Core.Presentation
{ {
Codon codon = descriptor.Codon; Codon codon = descriptor.Codon;
string type = codon.Properties.Contains("type") ? codon.Properties["type"] : "Command"; string type = codon.Properties.Contains("type") ? codon.Properties["type"] : "Command";
bool createCommand = codon.Properties["loadclasslazy"] == "false";
switch (type) { switch (type) {
case "Separator": case "Separator":
@ -220,7 +219,7 @@ namespace ICSharpCode.Core.Presentation
return new MenuCheckBox(context.InputBindingOwner, codon, descriptor.Parameter, descriptor.Conditions); return new MenuCheckBox(context.InputBindingOwner, codon, descriptor.Parameter, descriptor.Conditions);
case "Item": case "Item":
case "Command": case "Command":
return new MenuCommand(context.InputBindingOwner, codon, descriptor.Parameter, createCommand, context.ActivationMethod, descriptor.Conditions); return new MenuCommand(context.InputBindingOwner, codon, descriptor.Parameter, context.ActivationMethod, descriptor.Conditions);
case "Menu": case "Menu":
var item = new CoreMenuItem(codon, descriptor.Parameter, descriptor.Conditions) { var item = new CoreMenuItem(codon, descriptor.Parameter, descriptor.Conditions) {
ItemsSource = new object[1], ItemsSource = new object[1],

5
src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarButton.cs

@ -36,15 +36,12 @@ namespace ICSharpCode.Core.Presentation
readonly string inputGestureText; readonly string inputGestureText;
readonly IEnumerable<ICondition> conditions; readonly IEnumerable<ICondition> conditions;
public ToolBarButton(UIElement inputBindingOwner, Codon codon, object caller, bool createCommand, IReadOnlyCollection<ICondition> conditions) public ToolBarButton(UIElement inputBindingOwner, Codon codon, object caller, IReadOnlyCollection<ICondition> conditions)
{ {
ToolTipService.SetShowOnDisabled(this, true); ToolTipService.SetShowOnDisabled(this, true);
this.codon = codon; this.codon = codon;
this.caller = caller; this.caller = caller;
if (createCommand)
this.Command = CommandWrapper.CreateCommand(codon, conditions);
else
this.Command = CommandWrapper.CreateLazyCommand(codon, conditions); this.Command = CommandWrapper.CreateLazyCommand(codon, conditions);
this.CommandParameter = caller; this.CommandParameter = caller;
this.Content = ToolBarService.CreateToolBarItemContent(codon); this.Content = ToolBarService.CreateToolBarItemContent(codon);

4
src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarService.cs

@ -65,15 +65,13 @@ namespace ICSharpCode.Core.Presentation
object caller = descriptor.Parameter; object caller = descriptor.Parameter;
string type = codon.Properties.Contains("type") ? codon.Properties["type"] : "Item"; string type = codon.Properties.Contains("type") ? codon.Properties["type"] : "Item";
bool createCommand = codon.Properties["loadclasslazy"] == "false";
switch (type) { switch (type) {
case "Separator": case "Separator":
return new ConditionalSeparator(codon, caller, true, descriptor.Conditions); return new ConditionalSeparator(codon, caller, true, descriptor.Conditions);
case "CheckBox": case "CheckBox":
return new ToolBarCheckBox(codon, caller, descriptor.Conditions); return new ToolBarCheckBox(codon, caller, descriptor.Conditions);
case "Item": case "Item":
return new ToolBarButton(inputBindingOwner, codon, caller, createCommand, descriptor.Conditions); return new ToolBarButton(inputBindingOwner, codon, caller, descriptor.Conditions);
case "DropDownButton": case "DropDownButton":
return new ToolBarDropDownButton( return new ToolBarDropDownButton(
codon, caller, MenuService.CreateUnexpandedMenuItems( codon, caller, MenuService.CreateUnexpandedMenuItems(

10
src/Main/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs

@ -43,23 +43,13 @@ namespace ICSharpCode.Core.WinForms
} }
public MenuCommand(Codon codon, object caller, IReadOnlyCollection<ICondition> conditions) public MenuCommand(Codon codon, object caller, IReadOnlyCollection<ICondition> conditions)
: this(codon, caller, false, conditions)
{
}
public MenuCommand(Codon codon, object caller, bool createCommand, IReadOnlyCollection<ICondition> conditions)
{ {
this.RightToLeft = RightToLeft.Inherit; this.RightToLeft = RightToLeft.Inherit;
this.caller = caller; this.caller = caller;
this.codon = codon; this.codon = codon;
this.conditions = conditions; this.conditions = conditions;
if (createCommand) {
this.command = CommandWrapper.CreateCommand(codon, conditions);
} else {
this.command = CommandWrapper.CreateLazyCommand(codon, conditions); this.command = CommandWrapper.CreateLazyCommand(codon, conditions);
}
UpdateText(); UpdateText();
} }

2
src/Main/ICSharpCode.Core.WinForms/Menu/MenuService.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.Core.WinForms
return new MenuCheckBox(codon, descriptor.Parameter, descriptor.Conditions); return new MenuCheckBox(codon, descriptor.Parameter, descriptor.Conditions);
case "Item": case "Item":
case "Command": case "Command":
return new MenuCommand(codon, descriptor.Parameter, createCommand, descriptor.Conditions); return new MenuCommand(codon, descriptor.Parameter, descriptor.Conditions);
case "Menu": case "Menu":
return new Menu(codon, descriptor.Parameter, ConvertSubItems(descriptor.SubItems), descriptor.Conditions); return new Menu(codon, descriptor.Parameter, ConvertSubItems(descriptor.SubItems), descriptor.Conditions);
case "Builder": case "Builder":

1
src/Main/SharpDevelop/Project/Build/MSBuildEngine/MSBuildEngine.cs

@ -94,6 +94,7 @@ namespace ICSharpCode.SharpDevelop.Project
throw new ArgumentNullException("feedbackSink"); throw new ArgumentNullException("feedbackSink");
var additionalTargetFileList = additionalTargetFiles != null ? additionalTargetFiles.ToList() : new List<string>(); var additionalTargetFileList = additionalTargetFiles != null ? additionalTargetFiles.ToList() : new List<string>();
additionalTargetFileList.AddRange(AdditionalTargetFiles.Select(fileName => fileName.ToString()));
if (project.MinimumSolutionVersion >= SolutionFormatVersion.VS2010) { if (project.MinimumSolutionVersion >= SolutionFormatVersion.VS2010) {
additionalTargetFileList.Add(Path.Combine(Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location), "SharpDevelop.TargetingPack.targets")); additionalTargetFileList.Add(Path.Combine(Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location), "SharpDevelop.TargetingPack.targets"));
} }

2
src/Main/SharpDevelop/Templates/Project/ProjectDescriptor.cs

@ -514,6 +514,7 @@ namespace ICSharpCode.SharpDevelop.Templates
file.SetProjectItemProperties(projectFile); file.SetProjectItemProperties(projectFile);
project.Items.Add(projectFile); project.Items.Add(projectFile);
FileService.FireFileCreated(fileName, false);
} }
} }
@ -535,6 +536,7 @@ namespace ICSharpCode.SharpDevelop.Templates
project.ProjectLoaded(); project.ProjectLoaded();
SD.GetRequiredService<IProjectServiceRaiseEvents>().RaiseProjectCreated(new ProjectEventArgs(project)); SD.GetRequiredService<IProjectServiceRaiseEvents>().RaiseProjectCreated(new ProjectEventArgs(project));
FileService.FireFileCreated(project.FileName, false);
templateResults.NewProjects.Add(project); templateResults.NewProjects.Add(project);
success = true; success = true;
return true; return true;

Loading…
Cancel
Save