Browse Source
Code completion and folding currently disabled for Razor and Web Forms (.aspx) files.newNRvisualizers
49 changed files with 677 additions and 667 deletions
@ -1,27 +1,27 @@
@@ -1,27 +1,27 @@
|
||||
// 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 : DefaultCodeCompletionBinding |
||||
{ |
||||
public RazorCSharpCompletionBinding() |
||||
{ |
||||
} |
||||
|
||||
public override CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch) |
||||
{ |
||||
if (ch == '.') { |
||||
new RazorCSharpDotCompletionDataProvider().ShowCompletion(editor); |
||||
return CodeCompletionKeyPressResult.Completed; |
||||
} else if (ch == '(') { |
||||
return base.HandleKeyPress(editor, ch); |
||||
} |
||||
return CodeCompletionKeyPressResult.None; |
||||
} |
||||
} |
||||
} |
||||
//// 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 : DefaultCodeCompletionBinding
|
||||
// {
|
||||
// public RazorCSharpCompletionBinding()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public override CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
|
||||
// {
|
||||
// if (ch == '.') {
|
||||
// new RazorCSharpDotCompletionDataProvider().ShowCompletion(editor);
|
||||
// return CodeCompletionKeyPressResult.Completed;
|
||||
// } else if (ch == '(') {
|
||||
// return base.HandleKeyPress(editor, ch);
|
||||
// }
|
||||
// return CodeCompletionKeyPressResult.None;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,17 +1,11 @@
@@ -1,17 +1,11 @@
|
||||
// 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.Collections.Generic; |
||||
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 |
||||
{ |
||||
} |
||||
} |
||||
//// 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;
|
||||
//
|
||||
//namespace ICSharpCode.AspNet.Mvc.Completion
|
||||
//{
|
||||
// public class RazorCSharpDotCompletionDataProvider : DotCodeCompletionItemProvider
|
||||
// {
|
||||
// }
|
||||
//}
|
||||
|
@ -1,43 +1,43 @@
@@ -1,43 +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; |
||||
} |
||||
} |
||||
} |
||||
//// 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;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,34 +1,34 @@
@@ -1,34 +1,34 @@
|
||||
// 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.Web.Razor; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc.Completion |
||||
{ |
||||
public class RazorCSharpModelTypeLocater |
||||
{ |
||||
public RazorCSharpModelTypeLocater(ITextBuffer textBuffer) |
||||
{ |
||||
ParserResults results = ParseTemplate(textBuffer); |
||||
ModelTypeName = GetModelTypeName(results); |
||||
} |
||||
|
||||
ParserResults ParseTemplate(ITextBuffer 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; |
||||
} |
||||
|
||||
public string ModelTypeName { get; private set; } |
||||
} |
||||
} |
||||
//// 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.Web.Razor;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//
|
||||
//namespace ICSharpCode.AspNet.Mvc.Completion
|
||||
//{
|
||||
// public class RazorCSharpModelTypeLocater
|
||||
// {
|
||||
// public RazorCSharpModelTypeLocater(ITextBuffer textBuffer)
|
||||
// {
|
||||
// ParserResults results = ParseTemplate(textBuffer);
|
||||
// ModelTypeName = GetModelTypeName(results);
|
||||
// }
|
||||
//
|
||||
// ParserResults ParseTemplate(ITextBuffer 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;
|
||||
// }
|
||||
//
|
||||
// public string ModelTypeName { get; private set; }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,53 +1,53 @@
@@ -1,53 +1,53 @@
|
||||
// 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) |
||||
{ |
||||
var modelTypeLocater = new RazorCSharpModelTypeLocater(fileContent); |
||||
return new RazorCompilationUnit(projectContent) { |
||||
ModelTypeName = modelTypeLocater.ModelTypeName |
||||
}; |
||||
} |
||||
|
||||
public IResolver CreateResolver() |
||||
{ |
||||
return new RazorCSharpResolver(); |
||||
} |
||||
} |
||||
} |
||||
//// 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)
|
||||
// {
|
||||
// var modelTypeLocater = new RazorCSharpModelTypeLocater(fileContent);
|
||||
// return new RazorCompilationUnit(projectContent) {
|
||||
// ModelTypeName = modelTypeLocater.ModelTypeName
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public IResolver CreateResolver()
|
||||
// {
|
||||
// return new RazorCSharpResolver();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,105 +1,104 @@
@@ -1,105 +1,104 @@
|
||||
// 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.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
||||
|
||||
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); |
||||
} |
||||
} |
||||
} |
||||
//// 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.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,34 +1,35 @@
@@ -1,34 +1,35 @@
|
||||
// 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 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; } |
||||
} |
||||
} |
||||
//// 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.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; }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
// 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 AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public class FakeClass : DefaultClass |
||||
{ |
||||
public TestableProject TestableProject; |
||||
|
||||
public FakeClass(string name) |
||||
: this(name, new TestableProjectContent()) |
||||
{ |
||||
|
||||
} |
||||
|
||||
public FakeClass(string name, TestableProjectContent projectContent) |
||||
: base(new DefaultCompilationUnit(projectContent), name) |
||||
{ |
||||
this.TestableProject = projectContent.TestableProject; |
||||
} |
||||
|
||||
public FakeClass AddBaseClass(string name) |
||||
{ |
||||
var baseClass = new FakeClass(name); |
||||
var returnType = new DefaultReturnType(baseClass); |
||||
BaseTypes.Add(returnType); |
||||
return baseClass; |
||||
} |
||||
} |
||||
} |
@ -1,17 +0,0 @@
@@ -1,17 +0,0 @@
|
||||
// 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 AspNet.Mvc.Tests.Helpers |
||||
{ |
||||
public class TestableProjectContent : DefaultProjectContent |
||||
{ |
||||
public TestableProject TestableProject = TestableProject.CreateProject(); |
||||
|
||||
public override object Project { |
||||
get { return TestableProject; } |
||||
} |
||||
} |
||||
} |
@ -1,148 +1,148 @@
@@ -1,148 +1,148 @@
|
||||
// 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.AspNet.Mvc.Completion; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace AspNet.Mvc.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class RazorCSharpParserTests |
||||
{ |
||||
RazorCSharpParser parser; |
||||
|
||||
void CreateParser() |
||||
{ |
||||
parser = new RazorCSharpParser(); |
||||
} |
||||
|
||||
ICompilationUnit Parse(string code) |
||||
{ |
||||
var projectContent = new DefaultProjectContent(); |
||||
var textBuffer = new StringTextBuffer(code); |
||||
return parser.Parse(projectContent, @"d:\MyProject\Views\Index.cshtml", textBuffer); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_ModelDirectiveWithTypeName_ModelTypeNameFound() |
||||
{ |
||||
CreateParser(); |
||||
string code = "@model MvcApplication.MyModel\r\n"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual("MvcApplication.MyModel", compilationUnit.ModelTypeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_ModelDirectiveWithTypeNameFollowedByHtmlMarkup_ModelTypeNameFound() |
||||
{ |
||||
CreateParser(); |
||||
string code = |
||||
"@model MvcApplication.LogonModel\r\n" + |
||||
"<h2>Index</h2>\r\n"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual("MvcApplication.LogonModel", compilationUnit.ModelTypeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_SingleLineFileWithModelDirectiveAndTypeNameButNoNewLineAtEnd_ModelTypeNameFound() |
||||
{ |
||||
CreateParser(); |
||||
string code = "@model MvcApplication.MyModel"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual("MvcApplication.MyModel", compilationUnit.ModelTypeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_ModelTypeDirectiveWithTypeNameFollowedByRazorBlock_ModelTypeNameFound() |
||||
{ |
||||
CreateParser(); |
||||
|
||||
string code = |
||||
"@model IEnumerable<MvcApplication1.Models.MyClass>\r\n" + |
||||
"\r\n" + |
||||
"@{\r\n" + |
||||
" ViewBag.Title = \"Title1\";\r\n" + |
||||
"}\r\n" + |
||||
"\r\n"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual("IEnumerable<MvcApplication1.Models.MyClass>", compilationUnit.ModelTypeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_UsingDirective_ModelTypeNameIsEmptyString() |
||||
{ |
||||
CreateParser(); |
||||
string code = "@using System.Xml\r\n"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_HelperDirective_ModelTypeNameIsEmptyString() |
||||
{ |
||||
CreateParser(); |
||||
string code = "@helper MyHelper\r\n"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_HtmlMarkupOnly_ModelTypeNameIsEmptyString() |
||||
{ |
||||
CreateParser(); |
||||
string code = "<h1>heading</h1>\r\n"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_ModelDirectiveOnly_ModelTypeNameIsEmptyString() |
||||
{ |
||||
CreateParser(); |
||||
string code = "@model"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_ModelStringInsideParagraphTags_ModelTypeNameIsEmptyString() |
||||
{ |
||||
CreateParser(); |
||||
string code = "<p>model</p>"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Parse_ModelStringOnlyWithoutRazorTransition_ModelTypeNameIsEmptyString() |
||||
{ |
||||
CreateParser(); |
||||
string code = "model"; |
||||
|
||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
||||
|
||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
||||
} |
||||
} |
||||
} |
||||
//// 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.AspNet.Mvc.Completion;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//
|
||||
//namespace AspNet.Mvc.Tests.Completion
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class RazorCSharpParserTests
|
||||
// {
|
||||
// RazorCSharpParser parser;
|
||||
//
|
||||
// void CreateParser()
|
||||
// {
|
||||
// parser = new RazorCSharpParser();
|
||||
// }
|
||||
//
|
||||
// ICompilationUnit Parse(string code)
|
||||
// {
|
||||
// var projectContent = new DefaultProjectContent();
|
||||
// var textBuffer = new StringTextBuffer(code);
|
||||
// return parser.Parse(projectContent, @"d:\MyProject\Views\Index.cshtml", textBuffer);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_ModelDirectiveWithTypeName_ModelTypeNameFound()
|
||||
// {
|
||||
// CreateParser();
|
||||
// string code = "@model MvcApplication.MyModel\r\n";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual("MvcApplication.MyModel", compilationUnit.ModelTypeName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_ModelDirectiveWithTypeNameFollowedByHtmlMarkup_ModelTypeNameFound()
|
||||
// {
|
||||
// CreateParser();
|
||||
// string code =
|
||||
// "@model MvcApplication.LogonModel\r\n" +
|
||||
// "<h2>Index</h2>\r\n";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual("MvcApplication.LogonModel", compilationUnit.ModelTypeName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_SingleLineFileWithModelDirectiveAndTypeNameButNoNewLineAtEnd_ModelTypeNameFound()
|
||||
// {
|
||||
// CreateParser();
|
||||
// string code = "@model MvcApplication.MyModel";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual("MvcApplication.MyModel", compilationUnit.ModelTypeName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_ModelTypeDirectiveWithTypeNameFollowedByRazorBlock_ModelTypeNameFound()
|
||||
// {
|
||||
// CreateParser();
|
||||
//
|
||||
// string code =
|
||||
// "@model IEnumerable<MvcApplication1.Models.MyClass>\r\n" +
|
||||
// "\r\n" +
|
||||
// "@{\r\n" +
|
||||
// " ViewBag.Title = \"Title1\";\r\n" +
|
||||
// "}\r\n" +
|
||||
// "\r\n";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual("IEnumerable<MvcApplication1.Models.MyClass>", compilationUnit.ModelTypeName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_UsingDirective_ModelTypeNameIsEmptyString()
|
||||
// {
|
||||
// CreateParser();
|
||||
// string code = "@using System.Xml\r\n";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_HelperDirective_ModelTypeNameIsEmptyString()
|
||||
// {
|
||||
// CreateParser();
|
||||
// string code = "@helper MyHelper\r\n";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_HtmlMarkupOnly_ModelTypeNameIsEmptyString()
|
||||
// {
|
||||
// CreateParser();
|
||||
// string code = "<h1>heading</h1>\r\n";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_ModelDirectiveOnly_ModelTypeNameIsEmptyString()
|
||||
// {
|
||||
// CreateParser();
|
||||
// string code = "@model";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_ModelStringInsideParagraphTags_ModelTypeNameIsEmptyString()
|
||||
// {
|
||||
// CreateParser();
|
||||
// string code = "<p>model</p>";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Parse_ModelStringOnlyWithoutRazorTransition_ModelTypeNameIsEmptyString()
|
||||
// {
|
||||
// CreateParser();
|
||||
// string code = "model";
|
||||
//
|
||||
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||
//
|
||||
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// 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 NUnit.Framework; |
||||
using Rhino.Mocks; |
||||
|
||||
namespace AspNet.Mvc.Tests |
||||
{ |
||||
public abstract class MvcTestsBase |
||||
{ |
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
SD.InitializeForUnitTests(); |
||||
InitializeMessageLoop(); |
||||
} |
||||
|
||||
void InitializeMessageLoop() |
||||
{ |
||||
IMessageLoop messageLoop = MockRepository.GenerateStub<IMessageLoop>(); |
||||
SD.Services.RemoveService(typeof(IMessageLoop)); |
||||
SD.Services.AddService(typeof(IMessageLoop), messageLoop); |
||||
} |
||||
|
||||
[TearDown] |
||||
public void TearDown() |
||||
{ |
||||
SD.TearDownForUnitTests(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue