43 changed files with 428 additions and 599 deletions
@ -1,26 +0,0 @@
@@ -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
|
||||
// {
|
||||
// }
|
||||
//}
|
@ -1,58 +0,0 @@
@@ -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;
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,68 +0,0 @@
@@ -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();
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,119 +0,0 @@
@@ -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);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,50 +0,0 @@
@@ -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; }
|
||||
// }
|
||||
//}
|
@ -0,0 +1,86 @@
@@ -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(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue