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 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
//// 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)
|
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
//
|
||||||
using System; |
//using System;
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
//using ICSharpCode.SharpDevelop.Editor;
|
||||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
//using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
|
||||||
|
//
|
||||||
namespace ICSharpCode.AspNet.Mvc.Completion |
//namespace ICSharpCode.AspNet.Mvc.Completion
|
||||||
{ |
//{
|
||||||
public class RazorCSharpCompletionBinding : DefaultCodeCompletionBinding |
// public class RazorCSharpCompletionBinding : DefaultCodeCompletionBinding
|
||||||
{ |
// {
|
||||||
public RazorCSharpCompletionBinding() |
// public RazorCSharpCompletionBinding()
|
||||||
{ |
// {
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public override CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch) |
// public override CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
|
||||||
{ |
// {
|
||||||
if (ch == '.') { |
// if (ch == '.') {
|
||||||
new RazorCSharpDotCompletionDataProvider().ShowCompletion(editor); |
// new RazorCSharpDotCompletionDataProvider().ShowCompletion(editor);
|
||||||
return CodeCompletionKeyPressResult.Completed; |
// return CodeCompletionKeyPressResult.Completed;
|
||||||
} else if (ch == '(') { |
// } else if (ch == '(') {
|
||||||
return base.HandleKeyPress(editor, ch); |
// return base.HandleKeyPress(editor, ch);
|
||||||
} |
// }
|
||||||
return CodeCompletionKeyPressResult.None; |
// return CodeCompletionKeyPressResult.None;
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
|||||||
@ -1,17 +1,11 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
//// 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)
|
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
//
|
||||||
using System; |
//using System;
|
||||||
using System.Collections.Generic; |
//
|
||||||
using ICSharpCode.SharpDevelop; |
//namespace ICSharpCode.AspNet.Mvc.Completion
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
//{
|
||||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
// public class RazorCSharpDotCompletionDataProvider : DotCodeCompletionItemProvider
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
// {
|
||||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
// }
|
||||||
|
//}
|
||||||
namespace ICSharpCode.AspNet.Mvc.Completion |
|
||||||
{ |
|
||||||
public class RazorCSharpDotCompletionDataProvider : DotCodeCompletionItemProvider |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
|
|||||||
@ -1,43 +1,43 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
//// 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)
|
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
//
|
||||||
using System; |
//using System;
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
//using ICSharpCode.SharpDevelop.Dom;
|
||||||
|
//
|
||||||
namespace ICSharpCode.AspNet.Mvc.Completion |
//namespace ICSharpCode.AspNet.Mvc.Completion
|
||||||
{ |
//{
|
||||||
public class RazorCSharpExpressionFinder : IExpressionFinder |
// public class RazorCSharpExpressionFinder : IExpressionFinder
|
||||||
{ |
// {
|
||||||
public RazorCSharpExpressionFinder() |
// public RazorCSharpExpressionFinder()
|
||||||
{ |
// {
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public ExpressionResult FindExpression(string text, int offset) |
// public ExpressionResult FindExpression(string text, int offset)
|
||||||
{ |
// {
|
||||||
int position = offset - 1; |
// int position = offset - 1;
|
||||||
while (position > 0 && IsValidCharacter(text[position])) { |
// while (position > 0 && IsValidCharacter(text[position])) {
|
||||||
position--; |
// position--;
|
||||||
} |
// }
|
||||||
position++; |
// position++;
|
||||||
string expression = text.Substring(position, offset - position); |
// string expression = text.Substring(position, offset - position);
|
||||||
return new ExpressionResult(expression); |
// return new ExpressionResult(expression);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
bool IsValidCharacter(char ch) |
// bool IsValidCharacter(char ch)
|
||||||
{ |
// {
|
||||||
return Char.IsLetterOrDigit(ch) || |
// return Char.IsLetterOrDigit(ch) ||
|
||||||
(ch == '.') || |
// (ch == '.') ||
|
||||||
(ch == '_'); |
// (ch == '_');
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public ExpressionResult FindFullExpression(string text, int offset) |
// public ExpressionResult FindFullExpression(string text, int offset)
|
||||||
{ |
// {
|
||||||
return ExpressionResult.Empty; |
// return ExpressionResult.Empty;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public string RemoveLastPart(string expression) |
// public string RemoveLastPart(string expression)
|
||||||
{ |
// {
|
||||||
return expression; |
// return expression;
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
|||||||
@ -1,34 +1,34 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
//// 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)
|
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
//
|
||||||
using System; |
//using System;
|
||||||
using System.Web.Razor; |
//using System.Web.Razor;
|
||||||
using ICSharpCode.SharpDevelop; |
//using ICSharpCode.SharpDevelop;
|
||||||
|
//
|
||||||
namespace ICSharpCode.AspNet.Mvc.Completion |
//namespace ICSharpCode.AspNet.Mvc.Completion
|
||||||
{ |
//{
|
||||||
public class RazorCSharpModelTypeLocater |
// public class RazorCSharpModelTypeLocater
|
||||||
{ |
// {
|
||||||
public RazorCSharpModelTypeLocater(ITextBuffer textBuffer) |
// public RazorCSharpModelTypeLocater(ITextBuffer textBuffer)
|
||||||
{ |
// {
|
||||||
ParserResults results = ParseTemplate(textBuffer); |
// ParserResults results = ParseTemplate(textBuffer);
|
||||||
ModelTypeName = GetModelTypeName(results); |
// ModelTypeName = GetModelTypeName(results);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
ParserResults ParseTemplate(ITextBuffer textBuffer) |
// ParserResults ParseTemplate(ITextBuffer 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; }
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
|||||||
@ -1,53 +1,53 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
//// 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)
|
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
//
|
||||||
using System; |
//using System;
|
||||||
using System.IO; |
//using System.IO;
|
||||||
using ICSharpCode.SharpDevelop; |
//using ICSharpCode.SharpDevelop;
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
//using ICSharpCode.SharpDevelop.Dom;
|
||||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
//using ICSharpCode.SharpDevelop.Dom.CSharp;
|
||||||
using ICSharpCode.SharpDevelop.Project; |
//using ICSharpCode.SharpDevelop.Project;
|
||||||
|
//
|
||||||
namespace ICSharpCode.AspNet.Mvc.Completion |
//namespace ICSharpCode.AspNet.Mvc.Completion
|
||||||
{ |
//{
|
||||||
public class RazorCSharpParser : IParser |
// public class RazorCSharpParser : IParser
|
||||||
{ |
// {
|
||||||
public RazorCSharpParser() |
// public RazorCSharpParser()
|
||||||
{ |
// {
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public string[] LexerTags { get; set; } |
// public string[] LexerTags { get; set; }
|
||||||
|
//
|
||||||
public LanguageProperties Language { |
// public LanguageProperties Language {
|
||||||
get { return LanguageProperties.CSharp; } |
// get { return LanguageProperties.CSharp; }
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public IExpressionFinder CreateExpressionFinder(string fileName) |
// public IExpressionFinder CreateExpressionFinder(string fileName)
|
||||||
{ |
// {
|
||||||
return new RazorCSharpExpressionFinder(); |
// return new RazorCSharpExpressionFinder();
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public bool CanParse(string fileName) |
// public bool CanParse(string fileName)
|
||||||
{ |
// {
|
||||||
return Path.GetExtension(fileName).Equals(".cshtml", StringComparison.OrdinalIgnoreCase); |
// return Path.GetExtension(fileName).Equals(".cshtml", StringComparison.OrdinalIgnoreCase);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public bool CanParse(IProject project) |
// public bool CanParse(IProject project)
|
||||||
{ |
// {
|
||||||
return project.Language == "C#"; |
// return project.Language == "C#";
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ITextBuffer fileContent) |
// public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ITextBuffer fileContent)
|
||||||
{ |
// {
|
||||||
var modelTypeLocater = new RazorCSharpModelTypeLocater(fileContent); |
// var modelTypeLocater = new RazorCSharpModelTypeLocater(fileContent);
|
||||||
return new RazorCompilationUnit(projectContent) { |
// return new RazorCompilationUnit(projectContent) {
|
||||||
ModelTypeName = modelTypeLocater.ModelTypeName |
// ModelTypeName = modelTypeLocater.ModelTypeName
|
||||||
}; |
// };
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public IResolver CreateResolver() |
// public IResolver CreateResolver()
|
||||||
{ |
// {
|
||||||
return new RazorCSharpResolver(); |
// return new RazorCSharpResolver();
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
|||||||
@ -1,105 +1,104 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
//// 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)
|
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
//
|
||||||
using System; |
//using System;
|
||||||
using System.Collections.Generic; |
//using System.Collections.Generic;
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
//using ICSharpCode.NRefactory.TypeSystem;
|
||||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
//
|
||||||
|
//namespace ICSharpCode.AspNet.Mvc.Completion
|
||||||
namespace ICSharpCode.AspNet.Mvc.Completion |
//{
|
||||||
{ |
// public class RazorCSharpResolver : IResolver
|
||||||
public class RazorCSharpResolver : IResolver |
// {
|
||||||
{ |
// NRefactoryResolver resolver = new NRefactoryResolver(LanguageProperties.CSharp);
|
||||||
NRefactoryResolver resolver = new NRefactoryResolver(LanguageProperties.CSharp); |
//
|
||||||
|
// public ResolveResult Resolve(ExpressionResult expressionResult, ParseInformation parseInfo, string fileContent)
|
||||||
public ResolveResult Resolve(ExpressionResult expressionResult, ParseInformation parseInfo, string fileContent) |
// {
|
||||||
{ |
// ParseInformation parseInfoWithWebViewPageClass = CreateParseInformationWithWebViewPageClass(parseInfo);
|
||||||
ParseInformation parseInfoWithWebViewPageClass = CreateParseInformationWithWebViewPageClass(parseInfo); |
// expressionResult.Region = GetRegionInMiddleOfWebViewPageClass();
|
||||||
expressionResult.Region = GetRegionInMiddleOfWebViewPageClass(); |
// return resolver.Resolve(expressionResult, parseInfoWithWebViewPageClass, fileContent);
|
||||||
return resolver.Resolve(expressionResult, parseInfoWithWebViewPageClass, fileContent); |
// }
|
||||||
} |
//
|
||||||
|
// ParseInformation CreateParseInformationWithWebViewPageClass(ParseInformation parseInfo)
|
||||||
ParseInformation CreateParseInformationWithWebViewPageClass(ParseInformation parseInfo) |
// {
|
||||||
{ |
// RazorCompilationUnit compilationUnit = RazorCompilationUnit.CreateFromParseInfo(parseInfo);
|
||||||
RazorCompilationUnit compilationUnit = RazorCompilationUnit.CreateFromParseInfo(parseInfo); |
// AddDefaultUsings(compilationUnit);
|
||||||
AddDefaultUsings(compilationUnit); |
// AddWebViewPageClass(compilationUnit);
|
||||||
AddWebViewPageClass(compilationUnit); |
// return new ParseInformation(compilationUnit);
|
||||||
return new ParseInformation(compilationUnit); |
// }
|
||||||
} |
//
|
||||||
|
// void AddDefaultUsings(ICompilationUnit compilationUnit)
|
||||||
void AddDefaultUsings(ICompilationUnit compilationUnit) |
// {
|
||||||
{ |
// AddUsing("System.Web.Mvc", compilationUnit);
|
||||||
AddUsing("System.Web.Mvc", compilationUnit); |
// AddUsing("System.Web.Mvc.Ajax", compilationUnit);
|
||||||
AddUsing("System.Web.Mvc.Ajax", compilationUnit); |
// AddUsing("System.Web.Mvc.Html", compilationUnit);
|
||||||
AddUsing("System.Web.Mvc.Html", compilationUnit); |
// AddUsing("System.Web.Routing", compilationUnit);
|
||||||
AddUsing("System.Web.Routing", compilationUnit); |
// }
|
||||||
} |
//
|
||||||
|
// void AddUsing(string name, ICompilationUnit compilationUnit)
|
||||||
void AddUsing(string name, ICompilationUnit compilationUnit) |
// {
|
||||||
{ |
// DefaultUsing defaultUsing = CreateUsing(name, compilationUnit.ProjectContent);
|
||||||
DefaultUsing defaultUsing = CreateUsing(name, compilationUnit.ProjectContent); |
// compilationUnit.UsingScope.Usings.Add(defaultUsing);
|
||||||
compilationUnit.UsingScope.Usings.Add(defaultUsing); |
// }
|
||||||
} |
//
|
||||||
|
// DefaultUsing CreateUsing(string namespaceName, IProjectContent projectContent)
|
||||||
DefaultUsing CreateUsing(string namespaceName, IProjectContent projectContent) |
// {
|
||||||
{ |
// var defaultUsing = new DefaultUsing(projectContent);
|
||||||
var defaultUsing = new DefaultUsing(projectContent); |
// defaultUsing.Usings.Add(namespaceName);
|
||||||
defaultUsing.Usings.Add(namespaceName); |
// return defaultUsing;
|
||||||
return defaultUsing; |
// }
|
||||||
} |
//
|
||||||
|
// void AddWebViewPageClass(RazorCompilationUnit compilationUnit)
|
||||||
void AddWebViewPageClass(RazorCompilationUnit compilationUnit) |
// {
|
||||||
{ |
// DefaultClass webViewPageClass = CreateWebViewPageClass(compilationUnit);
|
||||||
DefaultClass webViewPageClass = CreateWebViewPageClass(compilationUnit); |
// compilationUnit.Classes.Add(webViewPageClass);
|
||||||
compilationUnit.Classes.Add(webViewPageClass); |
// }
|
||||||
} |
//
|
||||||
|
// DefaultClass CreateWebViewPageClass(RazorCompilationUnit compilationUnit)
|
||||||
DefaultClass CreateWebViewPageClass(RazorCompilationUnit compilationUnit) |
// {
|
||||||
{ |
// var webViewPageClass = new DefaultClass(compilationUnit, "RazorWebViewPage") {
|
||||||
var webViewPageClass = new DefaultClass(compilationUnit, "RazorWebViewPage") { |
// Region = new DomRegion(1, 0, 3, 0)
|
||||||
Region = new DomRegion(1, 0, 3, 0) |
// };
|
||||||
}; |
// IReturnType modelType = GetModelReturnType(compilationUnit);
|
||||||
IReturnType modelType = GetModelReturnType(compilationUnit); |
// AddWebViewPageBaseClass(webViewPageClass, modelType);
|
||||||
AddWebViewPageBaseClass(webViewPageClass, modelType); |
// return webViewPageClass;
|
||||||
return webViewPageClass; |
// }
|
||||||
} |
//
|
||||||
|
// IReturnType GetModelReturnType(RazorCompilationUnit compilationUnit)
|
||||||
IReturnType GetModelReturnType(RazorCompilationUnit compilationUnit) |
// {
|
||||||
{ |
// IClass modelType = GetClassIfTypeNameIsNotEmpty(compilationUnit.ProjectContent, compilationUnit.ModelTypeName);
|
||||||
IClass modelType = GetClassIfTypeNameIsNotEmpty(compilationUnit.ProjectContent, compilationUnit.ModelTypeName); |
// if (modelType != null) {
|
||||||
if (modelType != null) { |
// return modelType.DefaultReturnType;
|
||||||
return modelType.DefaultReturnType; |
// }
|
||||||
} |
// return new DynamicReturnType(compilationUnit.ProjectContent);
|
||||||
return new DynamicReturnType(compilationUnit.ProjectContent); |
// }
|
||||||
} |
//
|
||||||
|
// IClass GetClassIfTypeNameIsNotEmpty(IProjectContent projectContent, string modelTypeName)
|
||||||
IClass GetClassIfTypeNameIsNotEmpty(IProjectContent projectContent, string modelTypeName) |
// {
|
||||||
{ |
// if (!String.IsNullOrEmpty(modelTypeName)) {
|
||||||
if (!String.IsNullOrEmpty(modelTypeName)) { |
// return projectContent.GetClass(modelTypeName, 0);
|
||||||
return projectContent.GetClass(modelTypeName, 0); |
// }
|
||||||
} |
// return null;
|
||||||
return null; |
// }
|
||||||
} |
//
|
||||||
|
// void AddWebViewPageBaseClass(DefaultClass webViewPageClass, IReturnType modelType)
|
||||||
void AddWebViewPageBaseClass(DefaultClass webViewPageClass, IReturnType modelType) |
// {
|
||||||
{ |
// IClass webViewPageBaseClass = webViewPageClass.ProjectContent.GetClass("System.Web.Mvc.WebViewPage", 1);
|
||||||
IClass webViewPageBaseClass = webViewPageClass.ProjectContent.GetClass("System.Web.Mvc.WebViewPage", 1); |
// if (webViewPageBaseClass != null) {
|
||||||
if (webViewPageBaseClass != null) { |
// IReturnType returnType = GetWebViewPageBaseClassReturnType(webViewPageBaseClass, modelType);
|
||||||
IReturnType returnType = GetWebViewPageBaseClassReturnType(webViewPageBaseClass, modelType); |
// webViewPageClass.BaseTypes.Add(returnType);
|
||||||
webViewPageClass.BaseTypes.Add(returnType); |
// }
|
||||||
} |
// }
|
||||||
} |
//
|
||||||
|
// IReturnType GetWebViewPageBaseClassReturnType(IClass webViewPageBaseClass, IReturnType modelType)
|
||||||
IReturnType GetWebViewPageBaseClassReturnType(IClass webViewPageBaseClass, IReturnType modelType) |
// {
|
||||||
{ |
// var typeArguments = new List<IReturnType>();
|
||||||
var typeArguments = new List<IReturnType>(); |
// typeArguments.Add(modelType);
|
||||||
typeArguments.Add(modelType); |
// return new ConstructedReturnType(webViewPageBaseClass.DefaultReturnType, typeArguments);
|
||||||
return new ConstructedReturnType(webViewPageBaseClass.DefaultReturnType, typeArguments); |
// }
|
||||||
} |
//
|
||||||
|
// DomRegion GetRegionInMiddleOfWebViewPageClass()
|
||||||
DomRegion GetRegionInMiddleOfWebViewPageClass() |
// {
|
||||||
{ |
// return new DomRegion(2, 0, 2, 0);
|
||||||
return new DomRegion(2, 0, 2, 0); |
// }
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
} |
|
||||||
|
|||||||
@ -1,34 +1,35 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
//// 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)
|
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
//
|
||||||
using System; |
//using System;
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
//using ICSharpCode.NRefactory.TypeSystem;
|
||||||
|
//using ICSharpCode.SharpDevelop.Parser;
|
||||||
namespace ICSharpCode.AspNet.Mvc.Completion |
//
|
||||||
{ |
//namespace ICSharpCode.AspNet.Mvc.Completion
|
||||||
public class RazorCompilationUnit : DefaultCompilationUnit |
//{
|
||||||
{ |
// public class RazorCompilationUnit : DefaultCompilationUnit
|
||||||
public RazorCompilationUnit(IProjectContent projectContent) |
// {
|
||||||
: base(projectContent) |
// public RazorCompilationUnit(IProjectContent projectContent)
|
||||||
{ |
// : base(projectContent)
|
||||||
} |
// {
|
||||||
|
// }
|
||||||
public static RazorCompilationUnit CreateFromParseInfo(ParseInformation parseInformation) |
//
|
||||||
{ |
// public static RazorCompilationUnit CreateFromParseInfo(ParseInformation parseInformation)
|
||||||
return new RazorCompilationUnit(parseInformation.CompilationUnit.ProjectContent) { |
// {
|
||||||
ModelTypeName = GetModelTypeName(parseInformation.CompilationUnit) |
// return new RazorCompilationUnit(parseInformation.CompilationUnit.ProjectContent) {
|
||||||
}; |
// ModelTypeName = GetModelTypeName(parseInformation.CompilationUnit)
|
||||||
} |
// };
|
||||||
|
// }
|
||||||
static string GetModelTypeName(ICompilationUnit compilationUnit) |
//
|
||||||
{ |
// static string GetModelTypeName(ICompilationUnit compilationUnit)
|
||||||
var originalRazorCompilationUnit = compilationUnit as RazorCompilationUnit; |
// {
|
||||||
if (originalRazorCompilationUnit != null) { |
// var originalRazorCompilationUnit = compilationUnit as RazorCompilationUnit;
|
||||||
return originalRazorCompilationUnit.ModelTypeName; |
// if (originalRazorCompilationUnit != null) {
|
||||||
} |
// return originalRazorCompilationUnit.ModelTypeName;
|
||||||
return String.Empty; |
// }
|
||||||
} |
// return String.Empty;
|
||||||
|
// }
|
||||||
public string ModelTypeName { get; set; } |
//
|
||||||
} |
// public string ModelTypeName { get; set; }
|
||||||
} |
// }
|
||||||
|
//}
|
||||||
|
|||||||
@ -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 @@ |
|||||||
// 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 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
//// 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)
|
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
//
|
||||||
using System; |
//using System;
|
||||||
using ICSharpCode.AspNet.Mvc.Completion; |
//using ICSharpCode.AspNet.Mvc.Completion;
|
||||||
using ICSharpCode.SharpDevelop; |
//using ICSharpCode.SharpDevelop;
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
//using ICSharpCode.SharpDevelop.Dom;
|
||||||
using NUnit.Framework; |
//using NUnit.Framework;
|
||||||
|
//
|
||||||
namespace AspNet.Mvc.Tests.Completion |
//namespace AspNet.Mvc.Tests.Completion
|
||||||
{ |
//{
|
||||||
[TestFixture] |
// [TestFixture]
|
||||||
public class RazorCSharpParserTests |
// public class RazorCSharpParserTests
|
||||||
{ |
// {
|
||||||
RazorCSharpParser parser; |
// RazorCSharpParser parser;
|
||||||
|
//
|
||||||
void CreateParser() |
// void CreateParser()
|
||||||
{ |
// {
|
||||||
parser = new RazorCSharpParser(); |
// parser = new RazorCSharpParser();
|
||||||
} |
// }
|
||||||
|
//
|
||||||
ICompilationUnit Parse(string code) |
// ICompilationUnit Parse(string code)
|
||||||
{ |
// {
|
||||||
var projectContent = new DefaultProjectContent(); |
// var projectContent = new DefaultProjectContent();
|
||||||
var textBuffer = new StringTextBuffer(code); |
// var textBuffer = new StringTextBuffer(code);
|
||||||
return parser.Parse(projectContent, @"d:\MyProject\Views\Index.cshtml", textBuffer); |
// return parser.Parse(projectContent, @"d:\MyProject\Views\Index.cshtml", textBuffer);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_ModelDirectiveWithTypeName_ModelTypeNameFound() |
// public void Parse_ModelDirectiveWithTypeName_ModelTypeNameFound()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
string code = "@model MvcApplication.MyModel\r\n"; |
// string code = "@model MvcApplication.MyModel\r\n";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual("MvcApplication.MyModel", compilationUnit.ModelTypeName); |
// Assert.AreEqual("MvcApplication.MyModel", compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_ModelDirectiveWithTypeNameFollowedByHtmlMarkup_ModelTypeNameFound() |
// public void Parse_ModelDirectiveWithTypeNameFollowedByHtmlMarkup_ModelTypeNameFound()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
string code = |
// string code =
|
||||||
"@model MvcApplication.LogonModel\r\n" + |
// "@model MvcApplication.LogonModel\r\n" +
|
||||||
"<h2>Index</h2>\r\n"; |
// "<h2>Index</h2>\r\n";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual("MvcApplication.LogonModel", compilationUnit.ModelTypeName); |
// Assert.AreEqual("MvcApplication.LogonModel", compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_SingleLineFileWithModelDirectiveAndTypeNameButNoNewLineAtEnd_ModelTypeNameFound() |
// public void Parse_SingleLineFileWithModelDirectiveAndTypeNameButNoNewLineAtEnd_ModelTypeNameFound()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
string code = "@model MvcApplication.MyModel"; |
// string code = "@model MvcApplication.MyModel";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual("MvcApplication.MyModel", compilationUnit.ModelTypeName); |
// Assert.AreEqual("MvcApplication.MyModel", compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_ModelTypeDirectiveWithTypeNameFollowedByRazorBlock_ModelTypeNameFound() |
// public void Parse_ModelTypeDirectiveWithTypeNameFollowedByRazorBlock_ModelTypeNameFound()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
|
//
|
||||||
string code = |
// string code =
|
||||||
"@model IEnumerable<MvcApplication1.Models.MyClass>\r\n" + |
// "@model IEnumerable<MvcApplication1.Models.MyClass>\r\n" +
|
||||||
"\r\n" + |
// "\r\n" +
|
||||||
"@{\r\n" + |
// "@{\r\n" +
|
||||||
" ViewBag.Title = \"Title1\";\r\n" + |
// " ViewBag.Title = \"Title1\";\r\n" +
|
||||||
"}\r\n" + |
// "}\r\n" +
|
||||||
"\r\n"; |
// "\r\n";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual("IEnumerable<MvcApplication1.Models.MyClass>", compilationUnit.ModelTypeName); |
// Assert.AreEqual("IEnumerable<MvcApplication1.Models.MyClass>", compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_UsingDirective_ModelTypeNameIsEmptyString() |
// public void Parse_UsingDirective_ModelTypeNameIsEmptyString()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
string code = "@using System.Xml\r\n"; |
// string code = "@using System.Xml\r\n";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_HelperDirective_ModelTypeNameIsEmptyString() |
// public void Parse_HelperDirective_ModelTypeNameIsEmptyString()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
string code = "@helper MyHelper\r\n"; |
// string code = "@helper MyHelper\r\n";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_HtmlMarkupOnly_ModelTypeNameIsEmptyString() |
// public void Parse_HtmlMarkupOnly_ModelTypeNameIsEmptyString()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
string code = "<h1>heading</h1>\r\n"; |
// string code = "<h1>heading</h1>\r\n";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_ModelDirectiveOnly_ModelTypeNameIsEmptyString() |
// public void Parse_ModelDirectiveOnly_ModelTypeNameIsEmptyString()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
string code = "@model"; |
// string code = "@model";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_ModelStringInsideParagraphTags_ModelTypeNameIsEmptyString() |
// public void Parse_ModelStringInsideParagraphTags_ModelTypeNameIsEmptyString()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
string code = "<p>model</p>"; |
// string code = "<p>model</p>";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
[Test] |
// [Test]
|
||||||
public void Parse_ModelStringOnlyWithoutRazorTransition_ModelTypeNameIsEmptyString() |
// public void Parse_ModelStringOnlyWithoutRazorTransition_ModelTypeNameIsEmptyString()
|
||||||
{ |
// {
|
||||||
CreateParser(); |
// CreateParser();
|
||||||
string code = "model"; |
// string code = "model";
|
||||||
|
//
|
||||||
var compilationUnit = Parse(code) as RazorCompilationUnit; |
// var compilationUnit = Parse(code) as RazorCompilationUnit;
|
||||||
|
//
|
||||||
Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName); |
// Assert.AreEqual(String.Empty, compilationUnit.ModelTypeName);
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
|||||||
@ -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