7 changed files with 164 additions and 1 deletions
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc.Completion |
||||
{ |
||||
public class RazorCSharpCompletionBinding : ICodeCompletionBinding |
||||
{ |
||||
public RazorCSharpCompletionBinding() |
||||
{ |
||||
} |
||||
|
||||
public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch) |
||||
{ |
||||
if (ch == '.') { |
||||
new RazorCSharpDotCompletionDataProvider().ShowCompletion(editor); |
||||
return CodeCompletionKeyPressResult.Completed; |
||||
} |
||||
return CodeCompletionKeyPressResult.None; |
||||
} |
||||
|
||||
public bool CtrlSpace(ITextEditor editor) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc.Completion |
||||
{ |
||||
public class RazorCSharpDotCompletionDataProvider : DotCodeCompletionItemProvider |
||||
{ |
||||
public override ResolveResult Resolve(ITextEditor editor, ExpressionResult expressionResult) |
||||
{ |
||||
ParseInformation parseInfo = ParserService.GetParseInformation(editor.FileName); |
||||
NRefactoryResolver resolver = new NRefactoryResolver(LanguageProperties.CSharp); |
||||
resolver.LimitMethodExtractionUntilLine = editor.Caret.Line; |
||||
return resolver.Resolve(expressionResult, parseInfo, editor.Document.Text); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
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; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
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) |
||||
{ |
||||
return new DefaultCompilationUnit(projectContent); |
||||
} |
||||
|
||||
public IResolver CreateResolver() |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue