Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5469 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
122 changed files with 6593 additions and 766 deletions
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public interface IPythonResolver |
||||
{ |
||||
ResolveResult Resolve(PythonResolverContext resolverContext, ExpressionResult expressionResult); |
||||
} |
||||
} |
@ -0,0 +1,79 @@
@@ -0,0 +1,79 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Split up an expression into a member name and a type name.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// "myObject.Field" => "myObject" + "Field"
|
||||
/// "System.Console.WriteLine" => "System.Console" + "Console.WriteLine"
|
||||
/// </example>
|
||||
public class MemberName |
||||
{ |
||||
string name = String.Empty; |
||||
string type = String.Empty; |
||||
|
||||
public MemberName(string expression) |
||||
{ |
||||
Parse(expression); |
||||
} |
||||
|
||||
public MemberName(string typeName, string memberName) |
||||
{ |
||||
this.type = typeName; |
||||
this.name = memberName; |
||||
} |
||||
|
||||
void Parse(string expression) |
||||
{ |
||||
if (!String.IsNullOrEmpty(expression)) { |
||||
int index = expression.LastIndexOf('.'); |
||||
if (index > 0) { |
||||
type = expression.Substring(0, index); |
||||
name = expression.Substring(index + 1); |
||||
} else { |
||||
type = expression; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public string Name { |
||||
get { return name; } |
||||
} |
||||
|
||||
public bool HasName { |
||||
get { return !String.IsNullOrEmpty(name); } |
||||
} |
||||
|
||||
public string Type { |
||||
get { return type; } |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return String.Format("Type: {0}, Member: {1}", type, name); |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
MemberName rhs = obj as MemberName; |
||||
if (rhs != null) { |
||||
return (name == rhs.name) && (type == rhs.type); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return name.GetHashCode() ^ type.GetHashCode(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonBuiltInModuleMemberName : MemberName |
||||
{ |
||||
public const string PythonBuiltInModuleName = "__builtin__"; |
||||
|
||||
public PythonBuiltInModuleMemberName(string memberName) |
||||
: base(PythonBuiltInModuleName, memberName) |
||||
{ |
||||
} |
||||
|
||||
public static bool IsBuiltInModule(string name) |
||||
{ |
||||
return name == PythonBuiltInModuleName; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonClassResolver : IPythonResolver |
||||
{ |
||||
public PythonClassResolver() |
||||
{ |
||||
} |
||||
|
||||
public ResolveResult Resolve(PythonResolverContext context, ExpressionResult expressionResult) |
||||
{ |
||||
IClass matchingClass = GetClass(context, expressionResult.Expression); |
||||
if (matchingClass != null) { |
||||
return CreateTypeResolveResult(matchingClass); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public IClass GetClass(PythonResolverContext context, string name) |
||||
{ |
||||
if (String.IsNullOrEmpty(name)) { |
||||
return null; |
||||
} |
||||
|
||||
IClass matchedClass = context.GetClass(name); |
||||
if (matchedClass != null) { |
||||
return matchedClass; |
||||
} |
||||
|
||||
return context.GetImportedClass(name); |
||||
} |
||||
|
||||
TypeResolveResult CreateTypeResolveResult(IClass c) |
||||
{ |
||||
return new TypeResolveResult(null, null, c); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonDotNetMethodResolver |
||||
{ |
||||
PythonClassResolver classResolver; |
||||
|
||||
public PythonDotNetMethodResolver(PythonClassResolver classResolver) |
||||
{ |
||||
this.classResolver = classResolver; |
||||
} |
||||
|
||||
public ResolveResult Resolve(PythonResolverContext resolverContext, ExpressionResult expressionResult) |
||||
{ |
||||
MemberName memberName = new MemberName(expressionResult.Expression); |
||||
IClass matchingClass = classResolver.GetClass(resolverContext, memberName.Type); |
||||
if (matchingClass != null) { |
||||
return new PythonMethodGroupResolveResult(matchingClass, memberName.Name); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using Microsoft.Scripting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Hosting.Providers; |
||||
using Microsoft.Scripting.Runtime; |
||||
using IronPython.Compiler; |
||||
using IronPython.Runtime; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonExpression |
||||
{ |
||||
Tokenizer tokenizer; |
||||
Token currentToken; |
||||
|
||||
public PythonExpression(ScriptEngine engine, string expression) |
||||
{ |
||||
Init(engine, expression); |
||||
} |
||||
|
||||
void Init(ScriptEngine engine, string expression) |
||||
{ |
||||
PythonContext context = HostingHelpers.GetLanguageContext(engine) as PythonContext; |
||||
SourceUnit source = CreateSourceUnit(context, expression); |
||||
CreateTokenizer(source); |
||||
} |
||||
|
||||
SourceUnit CreateSourceUnit(PythonContext context, string expression) |
||||
{ |
||||
StringTextContentProvider textProvider = new StringTextContentProvider(expression); |
||||
return context.CreateSourceUnit(textProvider, String.Empty, SourceCodeKind.SingleStatement); |
||||
} |
||||
|
||||
void CreateTokenizer(SourceUnit source) |
||||
{ |
||||
PythonCompilerSink sink = new PythonCompilerSink(); |
||||
PythonCompilerOptions options = new PythonCompilerOptions(); |
||||
|
||||
tokenizer = new Tokenizer(sink, options); |
||||
tokenizer.Initialize(source); |
||||
} |
||||
|
||||
public Token GetNextToken() |
||||
{ |
||||
currentToken = tokenizer.GetNextToken(); |
||||
return currentToken; |
||||
} |
||||
|
||||
public Token CurrentToken { |
||||
get { return currentToken; } |
||||
} |
||||
|
||||
public bool IsImportToken(Token token) |
||||
{ |
||||
return token.Kind == IronPython.Compiler.TokenKind.KeywordImport; |
||||
} |
||||
|
||||
public bool IsFromToken(Token token) |
||||
{ |
||||
return token.Kind == IronPython.Compiler.TokenKind.KeywordFrom; |
||||
} |
||||
|
||||
public bool IsDotToken(Token token) |
||||
{ |
||||
return token.Kind == IronPython.Compiler.TokenKind.Dot; |
||||
} |
||||
|
||||
public bool IsNameToken(Token token) |
||||
{ |
||||
return token.Kind == IronPython.Compiler.TokenKind.Name; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using IronPython.Compiler.Ast; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonFromImport : DefaultUsing |
||||
{ |
||||
FromImportStatement fromImport; |
||||
|
||||
public PythonFromImport(IProjectContent projectContent, FromImportStatement fromImport) |
||||
: base(projectContent) |
||||
{ |
||||
this.fromImport = fromImport; |
||||
} |
||||
|
||||
public bool IsImportedName(string name) |
||||
{ |
||||
if (String.IsNullOrEmpty(name)) { |
||||
return false; |
||||
} |
||||
|
||||
for (int i = 0; i < fromImport.Names.Count; ++i) { |
||||
string importedName = GetImportedAsNameIfExists(i); |
||||
if (importedName == name) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
string GetImportedAsNameIfExists(int index) |
||||
{ |
||||
if (fromImport.AsNames != null) { |
||||
string importedAsName = fromImport.AsNames[index]; |
||||
if (importedAsName != null) { |
||||
return importedAsName; |
||||
} |
||||
} |
||||
return fromImport.Names[index]; |
||||
} |
||||
|
||||
public string Module { |
||||
get { return fromImport.Root.MakeString(); } |
||||
} |
||||
|
||||
public string GetOriginalNameForAlias(string alias) |
||||
{ |
||||
if (fromImport.AsNames == null) { |
||||
return null; |
||||
} |
||||
|
||||
int index = fromImport.AsNames.IndexOf(alias); |
||||
if (index >= 0) { |
||||
return fromImport.Names[index]; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public bool ImportsEverything { |
||||
get { |
||||
return fromImport.Names[0] == "*"; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using IronPython.Compiler.Ast; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonImport : DefaultUsing |
||||
{ |
||||
ImportStatement importStatement; |
||||
|
||||
public PythonImport(IProjectContent projectContent, ImportStatement importStatement) |
||||
: base(projectContent) |
||||
{ |
||||
this.importStatement = importStatement; |
||||
AddUsings(); |
||||
} |
||||
|
||||
void AddUsings() |
||||
{ |
||||
for (int i = 0; i < importStatement.Names.Count; ++i) { |
||||
string name = GetImportedAsNameIfExists(i); |
||||
Usings.Add(name); |
||||
} |
||||
} |
||||
|
||||
string GetImportedAsNameIfExists(int index) |
||||
{ |
||||
string name = importStatement.AsNames[index]; |
||||
if (name != null) { |
||||
return name; |
||||
} |
||||
return importStatement.Names[index].MakeString(); |
||||
} |
||||
|
||||
public string Module { |
||||
get { return importStatement.Names[0].MakeString(); } |
||||
} |
||||
|
||||
public string GetOriginalNameForAlias(string alias) |
||||
{ |
||||
int index = importStatement.AsNames.IndexOf(alias); |
||||
if (index >= 0) { |
||||
return importStatement.Names[index].MakeString(); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using IronPython.Modules; |
||||
using IronPython.Runtime; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonImportCompletion |
||||
{ |
||||
IProjectContent projectContent; |
||||
static readonly PythonStandardModules standardPythonModules = new PythonStandardModules(); |
||||
|
||||
public PythonImportCompletion(IProjectContent projectContent) |
||||
{ |
||||
this.projectContent = projectContent; |
||||
} |
||||
|
||||
public List<ICompletionEntry> GetCompletionItems() |
||||
{ |
||||
return GetCompletionItems(String.Empty); |
||||
} |
||||
|
||||
public List<ICompletionEntry> GetCompletionItems(string subNamespace) |
||||
{ |
||||
List<ICompletionEntry> items = projectContent.GetNamespaceContents(subNamespace); |
||||
|
||||
if (String.IsNullOrEmpty(subNamespace)) { |
||||
AddStandardPythonModules(items); |
||||
} |
||||
return items; |
||||
} |
||||
|
||||
void AddStandardPythonModules(List<ICompletionEntry> items) |
||||
{ |
||||
items.AddRange(standardPythonModules); |
||||
} |
||||
|
||||
public List<ICompletionEntry> GetCompletionItemsFromModule(string module) |
||||
{ |
||||
PythonStandardModuleType type = standardPythonModules.GetModuleType(module); |
||||
if (type != null) { |
||||
return GetCompletionItemsFromModule(type); |
||||
} |
||||
return projectContent.GetNamespaceContents(module); |
||||
} |
||||
|
||||
List<ICompletionEntry> GetCompletionItemsFromModule(PythonStandardModuleType type) |
||||
{ |
||||
PythonModuleCompletionItems moduleItems = PythonModuleCompletionItemsFactory.Create(type); |
||||
List<ICompletionEntry> items = new List<ICompletionEntry>(moduleItems); |
||||
return items; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,179 @@
@@ -0,0 +1,179 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Text; |
||||
using IronPython.Compiler; |
||||
using IronPython.Hosting; |
||||
using Microsoft.Scripting.Hosting; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonImportExpression : PythonExpression |
||||
{ |
||||
string module = String.Empty; |
||||
string identifier = String.Empty; |
||||
bool hasFromAndImport; |
||||
|
||||
public PythonImportExpression(string expression) |
||||
: this(Python.CreateEngine(), expression) |
||||
{ |
||||
} |
||||
|
||||
public PythonImportExpression(ScriptEngine engine, string expression) |
||||
: base(engine, expression) |
||||
{ |
||||
Parse(engine, expression); |
||||
} |
||||
|
||||
void Parse(ScriptEngine engine, string expression) |
||||
{ |
||||
Token token = GetNextToken(); |
||||
if (IsImportToken(token)) { |
||||
ParseImportExpression(); |
||||
} else if (IsFromToken(token)) { |
||||
ParseFromExpression(); |
||||
} |
||||
} |
||||
|
||||
void ParseImportExpression() |
||||
{ |
||||
GetModuleName(); |
||||
} |
||||
|
||||
void ParseFromExpression() |
||||
{ |
||||
GetModuleName(); |
||||
|
||||
if (IsImportToken(CurrentToken)) { |
||||
hasFromAndImport = true; |
||||
GetIdentifierName(); |
||||
} |
||||
} |
||||
|
||||
void GetModuleName() |
||||
{ |
||||
module = GetName(); |
||||
} |
||||
|
||||
string GetName() |
||||
{ |
||||
StringBuilder name = new StringBuilder(); |
||||
Token token = GetNextToken(); |
||||
while (IsNameToken(token)) { |
||||
name.Append((string)token.Value); |
||||
token = GetNextToken(); |
||||
if (IsDotToken(token)) { |
||||
name.Append('.'); |
||||
token = GetNextToken(); |
||||
} |
||||
} |
||||
return name.ToString(); |
||||
} |
||||
|
||||
void GetIdentifierName() |
||||
{ |
||||
identifier = GetName(); |
||||
} |
||||
|
||||
public bool HasFromAndImport { |
||||
get { return hasFromAndImport; } |
||||
} |
||||
|
||||
public string Module { |
||||
get { return module; } |
||||
} |
||||
|
||||
public string Identifier { |
||||
get { return identifier; } |
||||
} |
||||
|
||||
public bool HasIdentifier { |
||||
get { return !String.IsNullOrEmpty(identifier); } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns true if the expression is of the form:
|
||||
///
|
||||
/// "import "
|
||||
/// "from "
|
||||
/// "import System"
|
||||
/// "from System"
|
||||
/// "from System import Console"
|
||||
/// </summary>
|
||||
public static bool IsImportExpression(string text, int offset) |
||||
{ |
||||
if (!ValidIsImportExpressionParameters(text, offset)) { |
||||
return false; |
||||
} |
||||
|
||||
string previousWord = FindPreviousWord(text, offset); |
||||
if (IsImportOrFromString(previousWord)) { |
||||
return true; |
||||
} |
||||
|
||||
int previousWordOffset = offset - previousWord.Length + 1; |
||||
previousWord = FindPreviousWord(text, previousWordOffset); |
||||
return IsImportOrFromString(previousWord); |
||||
} |
||||
|
||||
static bool ValidIsImportExpressionParameters(string text, int offset) |
||||
{ |
||||
if (String.IsNullOrEmpty(text) || (offset <= 0) || (offset >= text.Length)) { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
static string FindPreviousWord(string text, int offset) |
||||
{ |
||||
int previousWordOffset = FindPreviousWordOffset(text, offset); |
||||
int length = offset - previousWordOffset + 1; |
||||
return text.Substring(previousWordOffset, length); |
||||
} |
||||
|
||||
static int FindPreviousWordOffset(string text, int offset) |
||||
{ |
||||
bool ignoreWhitespace = true; |
||||
while (offset > 0) { |
||||
char ch = text[offset]; |
||||
if (Char.IsWhiteSpace(ch)) { |
||||
if (IsNewLineOrCarriageReturn(ch)) { |
||||
return offset; |
||||
} |
||||
if (!ignoreWhitespace) { |
||||
return offset; |
||||
} |
||||
} else { |
||||
ignoreWhitespace = false; |
||||
} |
||||
--offset; |
||||
} |
||||
return offset; |
||||
} |
||||
|
||||
static bool IsNewLineOrCarriageReturn(char ch) |
||||
{ |
||||
return (ch == '\r') || (ch == '\n'); |
||||
} |
||||
|
||||
static bool IsImportOrFromString(string text) |
||||
{ |
||||
return IsImportString(text) || IsFromString(text); |
||||
} |
||||
|
||||
static bool IsImportString(string text) |
||||
{ |
||||
return text.Trim() == "import"; |
||||
} |
||||
|
||||
static bool IsFromString(string text) |
||||
{ |
||||
return text.Trim() == "from"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonImportExpressionContext : ExpressionContext |
||||
{ |
||||
public bool HasFromAndImport { get; set; } |
||||
|
||||
public override bool ShowEntry(ICompletionEntry entry) |
||||
{ |
||||
if (HasFromAndImport) { |
||||
return ShowEntryForImportIdentifier(entry); |
||||
} |
||||
return ShowEntryForImportModule(entry); |
||||
} |
||||
|
||||
bool ShowEntryForImportModule(ICompletionEntry entry) |
||||
{ |
||||
return entry is NamespaceEntry; |
||||
} |
||||
|
||||
bool ShowEntryForImportIdentifier(ICompletionEntry entry) |
||||
{ |
||||
if (entry is IMethod) { |
||||
return true; |
||||
} else if (entry is IField) { |
||||
return true; |
||||
} else if (entry is IClass) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonImportModuleResolveResult : ResolveResult |
||||
{ |
||||
PythonImportExpression expression; |
||||
|
||||
public PythonImportModuleResolveResult(PythonImportExpression expression) |
||||
: base(null, null, null) |
||||
{ |
||||
this.expression = expression; |
||||
} |
||||
|
||||
public string Name { |
||||
get { return expression.Module; } |
||||
} |
||||
|
||||
public override List<ICompletionEntry> GetCompletionData(IProjectContent projectContent) |
||||
{ |
||||
PythonImportCompletion completion = new PythonImportCompletion(projectContent); |
||||
if (expression.HasFromAndImport) { |
||||
if (expression.HasIdentifier) { |
||||
return new List<ICompletionEntry>(); |
||||
} else { |
||||
return completion.GetCompletionItemsFromModule(expression.Module); |
||||
} |
||||
} |
||||
return completion.GetCompletionItems(expression.Module); |
||||
} |
||||
|
||||
public override ResolveResult Clone() |
||||
{ |
||||
return new PythonImportModuleResolveResult(expression); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonImportResolver : IPythonResolver |
||||
{ |
||||
public PythonImportResolver() |
||||
{ |
||||
} |
||||
|
||||
public ResolveResult Resolve(PythonResolverContext resolverContext, ExpressionResult expressionResult) |
||||
{ |
||||
if (IsNamespace(expressionResult)) { |
||||
PythonImportExpression importExpression = new PythonImportExpression(expressionResult.Expression); |
||||
PythonImportExpressionContext context = expressionResult.Context as PythonImportExpressionContext; |
||||
context.HasFromAndImport = importExpression.HasFromAndImport; |
||||
|
||||
return new PythonImportModuleResolveResult(importExpression); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
bool IsNamespace(ExpressionResult expressionResult) |
||||
{ |
||||
return expressionResult.Context is PythonImportExpressionContext; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonMethodGroupResolveResult : MethodGroupResolveResult |
||||
{ |
||||
public PythonMethodGroupResolveResult(IClass containingClass, string methodName) |
||||
: base(null, null, containingClass.DefaultReturnType, methodName) |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonMethodResolver : IPythonResolver |
||||
{ |
||||
PythonDotNetMethodResolver dotNetMethodResolver; |
||||
PythonStandardModuleMethodResolver standardModuleMethodResolver; |
||||
|
||||
public PythonMethodResolver(PythonClassResolver classResolver, PythonStandardModuleResolver standardModuleResolver) |
||||
{ |
||||
dotNetMethodResolver = new PythonDotNetMethodResolver(classResolver); |
||||
standardModuleMethodResolver = new PythonStandardModuleMethodResolver(standardModuleResolver); |
||||
} |
||||
|
||||
public ResolveResult Resolve(PythonResolverContext resolverContext, ExpressionResult expressionResult) |
||||
{ |
||||
ResolveResult resolveResult = dotNetMethodResolver.Resolve(resolverContext, expressionResult); |
||||
if (resolveResult != null) { |
||||
return resolveResult; |
||||
} |
||||
return standardModuleMethodResolver.Resolve(resolverContext, expressionResult); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,160 @@
@@ -0,0 +1,160 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.ReflectionLayer; |
||||
using IronPython.Modules; |
||||
using IronPython.Runtime; |
||||
using Microsoft.Scripting.Runtime; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonModuleCompletionItems : List<ICompletionEntry> |
||||
{ |
||||
DefaultCompilationUnit compilationUnit; |
||||
DefaultClass moduleClass; |
||||
DefaultProjectContent projectContent; |
||||
|
||||
static readonly BindingFlags PublicAndStaticBindingFlags = BindingFlags.Public | BindingFlags.Static; |
||||
|
||||
public PythonModuleCompletionItems(PythonStandardModuleType moduleType) |
||||
{ |
||||
projectContent = new DefaultProjectContent(); |
||||
compilationUnit = new DefaultCompilationUnit(projectContent); |
||||
moduleClass = new DefaultClass(compilationUnit, moduleType.Name); |
||||
|
||||
AddCompletionItemsForType(moduleType.Type); |
||||
AddStandardCompletionItems(); |
||||
} |
||||
|
||||
void AddCompletionItemsForType(Type type) |
||||
{ |
||||
foreach (MemberInfo member in type.GetMembers(PublicAndStaticBindingFlags)) { |
||||
if (!HasPythonHiddenAttribute(member)) { |
||||
ICompletionEntry item = CreateCompletionItem(member, moduleClass); |
||||
if (item != null) { |
||||
Add(item); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void AddStandardCompletionItems() |
||||
{ |
||||
AddField("__name__"); |
||||
AddField("__package__"); |
||||
} |
||||
|
||||
protected void AddField(string name) |
||||
{ |
||||
DefaultField field = new DefaultField(moduleClass, name); |
||||
Add(field); |
||||
} |
||||
|
||||
bool HasPythonHiddenAttribute(MemberInfo memberInfo) |
||||
{ |
||||
foreach (Attribute attribute in memberInfo.GetCustomAttributes(false)) { |
||||
Type type = attribute.GetType(); |
||||
if (type.Name == "PythonHiddenAttribute") { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
ICompletionEntry CreateCompletionItem(MemberInfo memberInfo, IClass c) |
||||
{ |
||||
if (memberInfo is MethodInfo) { |
||||
return CreateMethodFromMethodInfo((MethodInfo)memberInfo, c); |
||||
} else if (memberInfo is FieldInfo) { |
||||
return CreateFieldFromFieldInfo((FieldInfo)memberInfo, c); |
||||
} else if (memberInfo is Type) { |
||||
return CreateClassFromType((Type)memberInfo); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
IMethod CreateMethodFromMethodInfo(MethodInfo methodInfo, IClass c) |
||||
{ |
||||
DefaultMethod method = new DefaultMethod(c, methodInfo.Name); |
||||
method.Documentation = GetDocumentation(methodInfo); |
||||
method.ReturnType = CreateMethodReturnType(methodInfo); |
||||
method.Modifiers = ModifierEnum.Public; |
||||
|
||||
foreach (ParameterInfo paramInfo in methodInfo.GetParameters()) { |
||||
if (!IsCodeContextParameter(paramInfo)) { |
||||
IParameter parameter = ConvertParameter(paramInfo, method); |
||||
method.Parameters.Add(parameter); |
||||
} |
||||
} |
||||
|
||||
c.Methods.Add(method); |
||||
|
||||
return method; |
||||
} |
||||
|
||||
string GetDocumentation(MemberInfo memberInfo) |
||||
{ |
||||
foreach (DocumentationAttribute documentation in GetDocumentationAttributes(memberInfo)) { |
||||
return documentation.Documentation; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
object[] GetDocumentationAttributes(MemberInfo memberInfo) |
||||
{ |
||||
return memberInfo.GetCustomAttributes(typeof(DocumentationAttribute), false); |
||||
} |
||||
|
||||
IReturnType CreateMethodReturnType(MethodInfo methodInfo) |
||||
{ |
||||
DefaultClass declaringType = new DefaultClass(compilationUnit, methodInfo.ReturnType.FullName); |
||||
return new DefaultReturnType(declaringType); |
||||
} |
||||
|
||||
bool IsCodeContextParameter(ParameterInfo paramInfo) |
||||
{ |
||||
return paramInfo.ParameterType == typeof(CodeContext); |
||||
} |
||||
|
||||
IParameter ConvertParameter(ParameterInfo paramInfo, IMethod method) |
||||
{ |
||||
DefaultClass c = new DefaultClass(compilationUnit, paramInfo.ParameterType.FullName); |
||||
DefaultReturnType returnType = new DefaultReturnType(c); |
||||
return new DefaultParameter(paramInfo.Name, returnType, DomRegion.Empty); |
||||
} |
||||
|
||||
IField CreateFieldFromFieldInfo(FieldInfo fieldInfo, IClass c) |
||||
{ |
||||
return new DefaultField(c, fieldInfo.Name); |
||||
} |
||||
|
||||
IClass CreateClassFromType(Type type) |
||||
{ |
||||
DefaultCompilationUnit unit = new DefaultCompilationUnit(projectContent); |
||||
return new DefaultClass(unit, type.Name); |
||||
} |
||||
|
||||
public MethodGroup GetMethods(string name) |
||||
{ |
||||
List<IMethod> methods = new List<IMethod>(); |
||||
foreach (object member in this) { |
||||
IMethod method = member as IMethod; |
||||
if (method != null) { |
||||
if (method.Name == name) { |
||||
methods.Add(method); |
||||
} |
||||
} |
||||
} |
||||
return new MethodGroup(methods); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using IronPython.Modules; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public static class PythonModuleCompletionItemsFactory |
||||
{ |
||||
public static PythonModuleCompletionItems Create(PythonStandardModuleType moduleType) |
||||
{ |
||||
if (IsSysModule(moduleType.Type)) { |
||||
return new SysModuleCompletionItems(moduleType); |
||||
} |
||||
return new PythonModuleCompletionItems(moduleType); |
||||
} |
||||
|
||||
static bool IsSysModule(Type type) |
||||
{ |
||||
return type == typeof(SysModule); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonNamespaceResolver : IPythonResolver |
||||
{ |
||||
public PythonNamespaceResolver() |
||||
{ |
||||
} |
||||
|
||||
public ResolveResult Resolve(PythonResolverContext resolverContext, ExpressionResult expressionResult) |
||||
{ |
||||
string actualNamespace = resolverContext.UnaliasImportedModuleName(expressionResult.Expression); |
||||
if (resolverContext.NamespaceExists(actualNamespace)) { |
||||
return new NamespaceResolveResult(null, null, actualNamespace); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,242 @@
@@ -0,0 +1,242 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonResolverContext |
||||
{ |
||||
ICompilationUnit mostRecentCompilationUnit; |
||||
ICompilationUnit bestCompilationUnit; |
||||
IProjectContent projectContent; |
||||
IClass callingClass; |
||||
|
||||
public PythonResolverContext(ParseInformation parseInfo) |
||||
{ |
||||
GetCompilationUnits(parseInfo); |
||||
GetProjectContent(); |
||||
} |
||||
|
||||
void GetCompilationUnits(ParseInformation parseInfo) |
||||
{ |
||||
mostRecentCompilationUnit = GetCompilationUnit(parseInfo, true); |
||||
bestCompilationUnit = GetCompilationUnit(parseInfo, false); |
||||
} |
||||
|
||||
void GetProjectContent() |
||||
{ |
||||
if (mostRecentCompilationUnit != null) { |
||||
projectContent = mostRecentCompilationUnit.ProjectContent; |
||||
} |
||||
} |
||||
|
||||
public ICompilationUnit MostRecentCompilationUnit { |
||||
get { return mostRecentCompilationUnit; } |
||||
} |
||||
|
||||
public IProjectContent ProjectContent { |
||||
get { return projectContent; } |
||||
} |
||||
|
||||
public bool HasProjectContent { |
||||
get { return projectContent != null; } |
||||
} |
||||
|
||||
public IClass CallingClass { |
||||
get { return callingClass; } |
||||
} |
||||
|
||||
public bool NamespaceExists(string name) |
||||
{ |
||||
return projectContent.NamespaceExists(name); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Determines the class and member at the specified
|
||||
/// line and column in the specified file.
|
||||
/// </summary>
|
||||
public bool GetCallingMember(DomRegion region) |
||||
{ |
||||
if (mostRecentCompilationUnit == null) { |
||||
return false; |
||||
} |
||||
|
||||
if (projectContent != null) { |
||||
callingClass = GetCallingClass(mostRecentCompilationUnit, bestCompilationUnit, region); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the compilation unit for the specified parse information.
|
||||
/// </summary>
|
||||
public ICompilationUnit GetCompilationUnit(ParseInformation parseInfo, bool mostRecent) |
||||
{ |
||||
if (parseInfo != null) { |
||||
if (mostRecent) { |
||||
return parseInfo.MostRecentCompilationUnit; |
||||
} |
||||
return parseInfo.BestCompilationUnit; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the calling class at the specified.
|
||||
/// </summary>
|
||||
IClass GetCallingClass(ICompilationUnit mostRecentCompilationUnit, ICompilationUnit bestCompilationUnit, DomRegion region) |
||||
{ |
||||
// Try the most recent compilation unit first
|
||||
IClass c = GetCallingClass(mostRecentCompilationUnit, region); |
||||
if (c != null) { |
||||
return c; |
||||
} |
||||
|
||||
// Try the best compilation unit.
|
||||
if (bestCompilationUnit != null && bestCompilationUnit.ProjectContent != null) { |
||||
IClass oldClass = GetCallingClass(bestCompilationUnit, region); |
||||
if (oldClass != null) { |
||||
return oldClass; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the calling class at the specified line and column.
|
||||
/// </summary>
|
||||
IClass GetCallingClass(ICompilationUnit compilationUnit, DomRegion region) |
||||
{ |
||||
if (compilationUnit.Classes.Count > 0) { |
||||
return compilationUnit.Classes[0]; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public IClass GetClass(string fullyQualifiedName) |
||||
{ |
||||
return projectContent.GetClass(fullyQualifiedName, 0); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns an array of the types that are imported by the
|
||||
/// current compilation unit.
|
||||
/// </summary>
|
||||
public List<ICompletionEntry> GetImportedTypes() |
||||
{ |
||||
List<ICompletionEntry> types = new List<ICompletionEntry>(); |
||||
CtrlSpaceResolveHelper.AddImportedNamespaceContents(types, mostRecentCompilationUnit, callingClass); |
||||
return types; |
||||
} |
||||
|
||||
public bool HasImport(string name) |
||||
{ |
||||
foreach (IUsing u in mostRecentCompilationUnit.UsingScope.Usings) { |
||||
foreach (string ns in u.Usings) { |
||||
if (name == ns) { |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Looks in the imported namespaces for a class that
|
||||
/// matches the class name. The class name searched for is not fully
|
||||
/// qualified.
|
||||
/// </summary>
|
||||
/// <param name="name">The unqualified class name.</param>
|
||||
public IClass GetImportedClass(string name) |
||||
{ |
||||
foreach (Object obj in GetImportedTypes()) { |
||||
IClass c = obj as IClass; |
||||
if ((c != null) && IsSameClassName(name, c.Name)) { |
||||
return c; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Determines whether the two type names are the same.
|
||||
/// </summary>
|
||||
static bool IsSameClassName(string name1, string name2) |
||||
{ |
||||
return name1 == name2; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Looks for the module name where the specified identifier is imported from.
|
||||
/// </summary>
|
||||
public string GetModuleForImportedName(string name) |
||||
{ |
||||
foreach (IUsing u in mostRecentCompilationUnit.UsingScope.Usings) { |
||||
PythonFromImport pythonFromImport = u as PythonFromImport; |
||||
if (pythonFromImport != null) { |
||||
if (pythonFromImport.IsImportedName(name)) { |
||||
return pythonFromImport.Module; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Converts a name into the correct identifier name based on any from import as statements.
|
||||
/// </summary>
|
||||
public string UnaliasImportedName(string name) |
||||
{ |
||||
foreach (IUsing u in mostRecentCompilationUnit.UsingScope.Usings) { |
||||
PythonFromImport pythonFromImport = u as PythonFromImport; |
||||
if (pythonFromImport != null) { |
||||
string actualName = pythonFromImport.GetOriginalNameForAlias(name); |
||||
if (actualName != null) { |
||||
return actualName; |
||||
} |
||||
} |
||||
} |
||||
return name; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Converts the module name to its original unaliased value if it exists.
|
||||
/// </summary>
|
||||
public string UnaliasImportedModuleName(string name) |
||||
{ |
||||
foreach (IUsing u in mostRecentCompilationUnit.UsingScope.Usings) { |
||||
PythonImport pythonImport = u as PythonImport; |
||||
if (pythonImport != null) { |
||||
string actualName = pythonImport.GetOriginalNameForAlias(name); |
||||
if (actualName != null) { |
||||
return actualName; |
||||
} |
||||
} |
||||
} |
||||
return name; |
||||
} |
||||
|
||||
public string[] GetModulesThatImportEverything() |
||||
{ |
||||
List<string> modules = new List<string>(); |
||||
foreach (IUsing u in mostRecentCompilationUnit.UsingScope.Usings) { |
||||
PythonFromImport pythonFromImport = u as PythonFromImport; |
||||
if (pythonFromImport != null) { |
||||
if (pythonFromImport.ImportsEverything) { |
||||
modules.Add(pythonFromImport.Module); |
||||
} |
||||
} |
||||
} |
||||
return modules.ToArray(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonStandardModuleMethodGroupResolveResult : MethodGroupResolveResult |
||||
{ |
||||
public PythonStandardModuleMethodGroupResolveResult(IReturnType containingType, string methodName, MethodGroup[] methodGroups) |
||||
: base(null, null, containingType, methodName, methodGroups) |
||||
{ |
||||
} |
||||
|
||||
public static PythonStandardModuleMethodGroupResolveResult Create(PythonStandardModuleType type, string methodName) |
||||
{ |
||||
PythonModuleCompletionItems completionItems = PythonModuleCompletionItemsFactory.Create(type); |
||||
MethodGroup methods = completionItems.GetMethods(methodName); |
||||
if (methods.Count > 0) { |
||||
return Create(methods); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
static PythonStandardModuleMethodGroupResolveResult Create(MethodGroup methods) |
||||
{ |
||||
MethodGroup[] methodGroups = new MethodGroup[] { methods }; |
||||
IMethod method = methods[0]; |
||||
IReturnType returnType = new DefaultReturnType(method.DeclaringType); |
||||
return new PythonStandardModuleMethodGroupResolveResult(returnType, method.Name, methodGroups); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonStandardModuleMethodResolver |
||||
{ |
||||
PythonStandardModuleResolver standardModuleResolver; |
||||
|
||||
public PythonStandardModuleMethodResolver(PythonStandardModuleResolver standardModuleResolver) |
||||
{ |
||||
this.standardModuleResolver = standardModuleResolver; |
||||
} |
||||
|
||||
public ResolveResult Resolve(PythonResolverContext resolverContext, ExpressionResult expressionResult) |
||||
{ |
||||
MemberName memberName = new MemberName(expressionResult.Expression); |
||||
MethodGroupResolveResult result = ResolveMethodFromImportedNames(resolverContext, memberName); |
||||
if (result != null) { |
||||
return result; |
||||
} |
||||
result = ResolveIfMethodIsImported(resolverContext, memberName); |
||||
if (result != null) { |
||||
return result; |
||||
} |
||||
return ResolveMethodFromModulesThatImportEverything(resolverContext, memberName); |
||||
} |
||||
|
||||
MethodGroupResolveResult ResolveMethodFromImportedNames(PythonResolverContext resolverContext, MemberName memberName) |
||||
{ |
||||
if (!memberName.HasName) { |
||||
string name = memberName.Type; |
||||
string moduleName = resolverContext.GetModuleForImportedName(name); |
||||
if (moduleName != null) { |
||||
PythonStandardModuleType type = standardModuleResolver.GetStandardModuleType(moduleName); |
||||
if (type != null) { |
||||
name = resolverContext.UnaliasImportedName(name); |
||||
return PythonStandardModuleMethodGroupResolveResult.Create(type, name); |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
MethodGroupResolveResult ResolveIfMethodIsImported(PythonResolverContext resolverContext, MemberName memberName) |
||||
{ |
||||
if (!memberName.HasName) { |
||||
memberName = new PythonBuiltInModuleMemberName(memberName.Type); |
||||
} |
||||
|
||||
PythonStandardModuleType type = standardModuleResolver.GetStandardModuleTypeIfImported(resolverContext, memberName.Type); |
||||
if (type != null) { |
||||
return CreateResolveResult(type, memberName.Name); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
MethodGroupResolveResult ResolveMethodFromModulesThatImportEverything(PythonResolverContext resolverContext, MemberName memberName) |
||||
{ |
||||
foreach (string module in resolverContext.GetModulesThatImportEverything()) { |
||||
PythonStandardModuleType type = standardModuleResolver.GetStandardModuleType(module); |
||||
if (type != null) { |
||||
MethodGroupResolveResult resolveResult = CreateResolveResult(type, memberName.Type); |
||||
if (resolveResult != null) { |
||||
return resolveResult; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
MethodGroupResolveResult CreateResolveResult(PythonStandardModuleType type, string name) |
||||
{ |
||||
return PythonStandardModuleMethodGroupResolveResult.Create(type, name); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonStandardModuleResolveResult : ResolveResult |
||||
{ |
||||
PythonStandardModuleType standardModuleType; |
||||
|
||||
public PythonStandardModuleResolveResult(PythonStandardModuleType standardModuleType) |
||||
: base(null, null, null) |
||||
{ |
||||
this.standardModuleType = standardModuleType; |
||||
} |
||||
|
||||
public override List<ICompletionEntry> GetCompletionData(IProjectContent projectContent) |
||||
{ |
||||
PythonModuleCompletionItems completionItems = PythonModuleCompletionItemsFactory.Create(standardModuleType); |
||||
List<ICompletionEntry> items = new List<ICompletionEntry>(completionItems); |
||||
return items; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonStandardModuleResolver : IPythonResolver |
||||
{ |
||||
PythonStandardModules standardPythonModules = new PythonStandardModules(); |
||||
|
||||
public PythonStandardModuleResolver() |
||||
{ |
||||
} |
||||
|
||||
public ResolveResult Resolve(PythonResolverContext resolverContext, ExpressionResult expressionResult) |
||||
{ |
||||
PythonStandardModuleType type = GetStandardModuleTypeIfImported(resolverContext, expressionResult.Expression); |
||||
if (type != null) { |
||||
return new PythonStandardModuleResolveResult(type); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public PythonStandardModuleType GetStandardModuleTypeIfImported(PythonResolverContext resolverContext, string moduleName) |
||||
{ |
||||
if (resolverContext.HasImport(moduleName) || PythonBuiltInModuleMemberName.IsBuiltInModule(moduleName)) { |
||||
string actualModuleName = resolverContext.UnaliasImportedModuleName(moduleName); |
||||
return standardPythonModules.GetModuleType(actualModuleName); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public PythonStandardModuleType GetStandardModuleType(string moduleName) |
||||
{ |
||||
return standardPythonModules.GetModuleType(moduleName); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonStandardModuleType |
||||
{ |
||||
Type type; |
||||
string name; |
||||
|
||||
public PythonStandardModuleType(Type type, string name) |
||||
{ |
||||
this.type = type; |
||||
this.name = name; |
||||
} |
||||
|
||||
public Type Type { |
||||
get { return type; } |
||||
} |
||||
|
||||
public string Name { |
||||
get { return name; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using IronPython.Modules; |
||||
using IronPython.Runtime; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Represents the standard library modules that are implemented in
|
||||
/// IronPython.
|
||||
/// </summary>
|
||||
public class PythonStandardModules : List<ICompletionEntry> |
||||
{ |
||||
Dictionary<string, Type> moduleTypes = new Dictionary<string, Type>(); |
||||
|
||||
public PythonStandardModules() |
||||
{ |
||||
GetPythonStandardModuleNames(); |
||||
} |
||||
|
||||
void GetPythonStandardModuleNames() |
||||
{ |
||||
GetPythonModuleNamesFromAssembly(typeof(Builtin).Assembly); |
||||
GetPythonModuleNamesFromAssembly(typeof(ModuleOps).Assembly); |
||||
} |
||||
|
||||
void GetPythonModuleNamesFromAssembly(Assembly assembly) |
||||
{ |
||||
foreach (Attribute attribute in Attribute.GetCustomAttributes(assembly, typeof(PythonModuleAttribute))) { |
||||
PythonModuleAttribute pythonModuleAttribute = attribute as PythonModuleAttribute; |
||||
Add(new NamespaceEntry(pythonModuleAttribute.Name)); |
||||
moduleTypes.Add(pythonModuleAttribute.Name, pythonModuleAttribute.Type); |
||||
} |
||||
} |
||||
|
||||
public PythonStandardModuleType GetModuleType(string moduleName) |
||||
{ |
||||
Type type = GetTypeForModule(moduleName); |
||||
if (type != null) { |
||||
return new PythonStandardModuleType(type, moduleName); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
Type GetTypeForModule(string moduleName) |
||||
{ |
||||
Type type; |
||||
if (moduleTypes.TryGetValue(moduleName, out type)) { |
||||
return type; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -1,41 +0,0 @@
@@ -1,41 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
using IronPython.Modules; |
||||
using IronPython.Runtime; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Represents the standard library modules that are implemented in
|
||||
/// IronPython.
|
||||
/// </summary>
|
||||
public class StandardPythonModules |
||||
{ |
||||
public StandardPythonModules() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the names of the standard Python library modules.
|
||||
/// </summary>
|
||||
public string[] GetNames() |
||||
{ |
||||
List<string> names = new List<string>(); |
||||
names.Add("sys"); |
||||
Assembly assembly = typeof(Builtin).Assembly; |
||||
foreach (Attribute customAttribute in Attribute.GetCustomAttributes(assembly, typeof(PythonModuleAttribute))) { |
||||
PythonModuleAttribute pythonModuleAttribute = customAttribute as PythonModuleAttribute; |
||||
names.Add(pythonModuleAttribute.Name); |
||||
} |
||||
return names.ToArray(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
using Microsoft.Scripting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Hosting.Providers; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class StringTextContentProvider : TextContentProvider |
||||
{ |
||||
string code; |
||||
|
||||
public StringTextContentProvider(string code) |
||||
{ |
||||
this.code = code; |
||||
} |
||||
|
||||
public override SourceCodeReader GetReader() |
||||
{ |
||||
StringReader stringReader = new StringReader(code); |
||||
return new SourceCodeReader(stringReader, Encoding.UTF8); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class SysModuleCompletionItems : PythonModuleCompletionItems |
||||
{ |
||||
public SysModuleCompletionItems(PythonStandardModuleType moduleType) |
||||
: base(moduleType) |
||||
{ |
||||
AddCompletionItems(); |
||||
} |
||||
|
||||
void AddCompletionItems() |
||||
{ |
||||
AddField("__stderr__"); |
||||
AddField("__stdin__"); |
||||
AddField("__stdout__"); |
||||
AddField("argv"); |
||||
AddField("builtin_module_names"); |
||||
AddField("dont_write_byte_code"); |
||||
AddField("executable"); |
||||
AddField("exec_prefix"); |
||||
AddField("flags"); |
||||
AddField("hexversion"); |
||||
AddField("last_type"); |
||||
AddField("last_value"); |
||||
AddField("last_traceback"); |
||||
AddField("meta_path"); |
||||
AddField("modules"); |
||||
AddField("path"); |
||||
AddField("path_hooks"); |
||||
AddField("path_importer_cache"); |
||||
AddField("ps1"); |
||||
AddField("ps2"); |
||||
AddField("py3kwarning"); |
||||
AddField("stderr"); |
||||
AddField("stdin"); |
||||
AddField("stdout"); |
||||
AddField("version"); |
||||
AddField("version_info"); |
||||
AddField("warnoptions"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the From keyword is correctly identified as a
|
||||
/// importable code completion keyword.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class FromImportCompletionTestFixture |
||||
{ |
||||
DerivedPythonCodeCompletionBinding codeCompletionBinding; |
||||
bool handlesImportKeyword; |
||||
AvalonEditTextEditorAdapter textEditor; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
if (!PropertyService.Initialized) { |
||||
PropertyService.InitializeService(String.Empty, String.Empty, String.Empty); |
||||
} |
||||
textEditor = new AvalonEditTextEditorAdapter(new ICSharpCode.AvalonEdit.TextEditor()); |
||||
codeCompletionBinding = new DerivedPythonCodeCompletionBinding(); |
||||
handlesImportKeyword = codeCompletionBinding.HandleKeyword(textEditor, "from"); |
||||
} |
||||
|
||||
[Test] |
||||
public void HandlesImportKeyWord() |
||||
{ |
||||
Assert.IsTrue(handlesImportKeyword); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class FromDateTimeLibraryImportCompletionTestFixture |
||||
{ |
||||
PythonImportExpression importExpression; |
||||
PythonImportModuleResolveResult resolveResult; |
||||
MockProjectContent projectContent; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string code = "from datetime import"; |
||||
importExpression = new PythonImportExpression(code); |
||||
resolveResult = new PythonImportModuleResolveResult(importExpression); |
||||
|
||||
projectContent = new MockProjectContent(); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompletionItemsContainsDateClass() |
||||
{ |
||||
List<ICompletionEntry> items = resolveResult.GetCompletionData(projectContent); |
||||
IClass c = PythonCompletionItemsHelper.FindClassFromCollection("datetime", items); |
||||
Assert.IsNotNull(c); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class FromImportDotNetNamespaceCompletionTestFixture |
||||
{ |
||||
PythonImportCompletion completion; |
||||
MockProjectContent projectContent; |
||||
DefaultClass c; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
projectContent = new MockProjectContent(); |
||||
completion = new PythonImportCompletion(projectContent); |
||||
|
||||
DefaultCompilationUnit unit = new DefaultCompilationUnit(projectContent); |
||||
ParseInformation parseInfo = new ParseInformation(unit); |
||||
c = new DefaultClass(unit, "Class"); |
||||
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>(); |
||||
namespaceItems.Add(c); |
||||
projectContent.AddExistingNamespaceContents("System", namespaceItems); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromDotNetSystemLibraryGetCompletionItemsReturnsAllClassesFromSystemNamespace() |
||||
{ |
||||
List<ICompletionEntry> items = completion.GetCompletionItemsFromModule("System"); |
||||
List<ICompletionEntry> expectedItems = new List<ICompletionEntry>(); |
||||
expectedItems.Add(c); |
||||
|
||||
Assert.AreEqual(expectedItems, items); |
||||
} |
||||
|
||||
[Test] |
||||
public void SystemNamespaceSearchedForWhenGetCompletionItemsMethodCalled() |
||||
{ |
||||
completion.GetCompletionItemsFromModule("System"); |
||||
Assert.AreEqual("System", projectContent.NamespacePassedToGetNamespaceContentsMethod); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class FromImportPythonModuleCompletionTestFixture |
||||
{ |
||||
PythonImportCompletion completion; |
||||
MockProjectContent projectContent; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
projectContent = new MockProjectContent(); |
||||
ParseInformation parseInfo = new ParseInformation(new DefaultCompilationUnit(projectContent)); |
||||
completion = new PythonImportCompletion(projectContent); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromUnknownLibraryNoCompletionItemsReturned() |
||||
{ |
||||
List<ICompletionEntry> items = completion.GetCompletionItemsFromModule("unknown"); |
||||
Assert.AreEqual(0, items.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromMathLibraryGetCompletionItemsReturnsPiField() |
||||
{ |
||||
List<ICompletionEntry> items = completion.GetCompletionItemsFromModule("math"); |
||||
IField field = PythonCompletionItemsHelper.FindFieldFromCollection("pi", items); |
||||
Assert.IsNotNull(field); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class FromMathLibraryImportCompletionTestFixture |
||||
{ |
||||
PythonImportExpression importExpression; |
||||
PythonImportModuleResolveResult resolveResult; |
||||
MockProjectContent projectContent; |
||||
List<ICompletionEntry> completionItems; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string code = "from math import"; |
||||
importExpression = new PythonImportExpression(code); |
||||
resolveResult = new PythonImportModuleResolveResult(importExpression); |
||||
|
||||
projectContent = new MockProjectContent(); |
||||
completionItems = resolveResult.GetCompletionData(projectContent); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompletionItemsContainsCosMethodFromMathLibrary() |
||||
{ |
||||
IMethod method = PythonCompletionItemsHelper.FindMethodFromCollection("cos", completionItems); |
||||
Assert.IsNotNull(method); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompletionItemsContainsPiPropertyFromMathLibrary() |
||||
{ |
||||
IField field = PythonCompletionItemsHelper.FindFieldFromCollection("pi", completionItems); |
||||
Assert.IsNotNull(field); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompletionItemsDoesNotContainNonStaticToStringMethod() |
||||
{ |
||||
IMethod method = PythonCompletionItemsHelper.FindMethodFromCollection("ToString", completionItems); |
||||
Assert.IsNull(method); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompletionItemsContain__name__() |
||||
{ |
||||
IField field = PythonCompletionItemsHelper.FindFieldFromCollection("__name__", completionItems); |
||||
Assert.IsNotNull(field); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompletionItemsContain__package__() |
||||
{ |
||||
IField field = PythonCompletionItemsHelper.FindFieldFromCollection("__package__", completionItems); |
||||
Assert.IsNotNull(field); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
/// <summary>
|
||||
/// With dot completion if the from import statement has an a identifier then no
|
||||
/// completion items should be returned.
|
||||
///
|
||||
/// For example pressing '.' after the following should not show any completion items:
|
||||
///
|
||||
/// "from math import cos"
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class FromMathLibraryImportCosMethodCompletionTestFixture |
||||
{ |
||||
PythonImportExpression importExpression; |
||||
PythonImportModuleResolveResult resolveResult; |
||||
MockProjectContent projectContent; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string code = "from math import cos"; |
||||
importExpression = new PythonImportExpression(code); |
||||
resolveResult = new PythonImportModuleResolveResult(importExpression); |
||||
|
||||
projectContent = new MockProjectContent(); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoCompletionItemsReturned() |
||||
{ |
||||
List<ICompletionEntry> items = resolveResult.GetCompletionData(projectContent); |
||||
Assert.AreEqual(0, items.Count); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,232 @@
@@ -0,0 +1,232 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class FromSysLibraryImportCompletionItemsTestFixture |
||||
{ |
||||
PythonImportCompletion completion; |
||||
MockProjectContent projectContent; |
||||
List<ICompletionEntry> completionItems; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
projectContent = new MockProjectContent(); |
||||
ParseInformation parseInfo = new ParseInformation(new DefaultCompilationUnit(projectContent)); |
||||
completion = new PythonImportCompletion(projectContent); |
||||
completionItems = completion.GetCompletionItemsFromModule("sys"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsDoesNotReturnPythonHiddenMethods() |
||||
{ |
||||
IMethod method = PythonCompletionItemsHelper.FindMethodFromCollection("_getframeImpl", completionItems); |
||||
Assert.IsNull(method); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturns__name__() |
||||
{ |
||||
AssertFieldExists("__name__"); |
||||
} |
||||
|
||||
void AssertFieldExists(string name) |
||||
{ |
||||
IField field = GetFieldFromCompletionItems(name); |
||||
Assert.IsNotNull(field, String.Format("Field '{0}' not found in completion items.", name)); |
||||
} |
||||
|
||||
IField GetFieldFromCompletionItems(string name) |
||||
{ |
||||
return PythonCompletionItemsHelper.FindFieldFromCollection(name, completionItems); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturns__package__() |
||||
{ |
||||
AssertFieldExists("__package__"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturns__stderr__() |
||||
{ |
||||
AssertFieldExists("__stderr__"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturns__stdin__() |
||||
{ |
||||
AssertFieldExists("__stdin__"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturns__stdout__() |
||||
{ |
||||
AssertFieldExists("__stdout__"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsArgv() |
||||
{ |
||||
AssertFieldExists("argv"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsBuiltInModuleNames() |
||||
{ |
||||
AssertFieldExists("builtin_module_names"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsExecutable() |
||||
{ |
||||
AssertFieldExists("executable"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsExecPrefix() |
||||
{ |
||||
AssertFieldExists("exec_prefix"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsExitMethod() |
||||
{ |
||||
IMethod method = PythonCompletionItemsHelper.FindMethodFromCollection("exit", completionItems); |
||||
Assert.IsNotNull(method); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsFlags() |
||||
{ |
||||
AssertFieldExists("flags"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsHexVersion() |
||||
{ |
||||
AssertFieldExists("hexversion"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsLastType() |
||||
{ |
||||
AssertFieldExists("last_type"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsLastValue() |
||||
{ |
||||
AssertFieldExists("last_value"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsLastTraceback() |
||||
{ |
||||
AssertFieldExists("last_traceback"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsMetaPath() |
||||
{ |
||||
AssertFieldExists("meta_path"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsModules() |
||||
{ |
||||
AssertFieldExists("modules"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsPath() |
||||
{ |
||||
AssertFieldExists("path"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsPathHooks() |
||||
{ |
||||
AssertFieldExists("path_hooks"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsPathImporterCache() |
||||
{ |
||||
AssertFieldExists("path_importer_cache"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsPs1() |
||||
{ |
||||
AssertFieldExists("ps1"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsPs2() |
||||
{ |
||||
AssertFieldExists("ps2"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsPy3kWarning() |
||||
{ |
||||
AssertFieldExists("py3kwarning"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsDontWriteByteCode() |
||||
{ |
||||
AssertFieldExists("dont_write_byte_code"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsStdErr() |
||||
{ |
||||
AssertFieldExists("stderr"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsStdIn() |
||||
{ |
||||
AssertFieldExists("stdin"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsStdOut() |
||||
{ |
||||
AssertFieldExists("stdout"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsVersion() |
||||
{ |
||||
AssertFieldExists("version"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsVersionInfo() |
||||
{ |
||||
AssertFieldExists("version_info"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionItemsReturnsWarnOptions() |
||||
{ |
||||
AssertFieldExists("warnoptions"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,94 @@
@@ -0,0 +1,94 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using IronPython.Modules; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class GetMethodsFromSysLibraryTestFixture |
||||
{ |
||||
SysModuleCompletionItems completionItems; |
||||
MethodGroup exitMethodGroup; |
||||
MethodGroup displayHookMethodGroup; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
PythonStandardModuleType moduleType = new PythonStandardModuleType(typeof(SysModule), "sys"); |
||||
completionItems = new SysModuleCompletionItems(moduleType); |
||||
exitMethodGroup = completionItems.GetMethods("exit"); |
||||
displayHookMethodGroup = completionItems.GetMethods("displayhook"); |
||||
} |
||||
|
||||
[Test] |
||||
public void TwoExitMethodsReturnedFromGetMethods() |
||||
{ |
||||
Assert.AreEqual(2, exitMethodGroup.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstMethodNameIsExit() |
||||
{ |
||||
Assert.AreEqual("exit", exitMethodGroup[0].Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void SecondMethodNameIsExit() |
||||
{ |
||||
Assert.AreEqual("exit", exitMethodGroup[1].Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstMethodHasReturnType() |
||||
{ |
||||
Assert.IsNotNull(exitMethodGroup[0].ReturnType); |
||||
} |
||||
|
||||
[Test] |
||||
public void SecondMethodHasReturnType() |
||||
{ |
||||
Assert.IsNotNull(exitMethodGroup[1].ReturnType); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExitMethodReturnsVoid() |
||||
{ |
||||
IMethod method = displayHookMethodGroup[0]; |
||||
Assert.AreEqual("Void", method.ReturnType.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void DisplayHookMethodDoesNotHaveCodeContextParameter() |
||||
{ |
||||
IMethod method = displayHookMethodGroup[0]; |
||||
IParameter parameter = method.Parameters[0]; |
||||
Assert.AreEqual("value", parameter.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void DisplayHookMethodReturnsVoid() |
||||
{ |
||||
IMethod method = displayHookMethodGroup[0]; |
||||
Assert.AreEqual("Void", method.ReturnType.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetDefaultEncodingMethodReturnsString() |
||||
{ |
||||
MethodGroup methodGroup = completionItems.GetMethods("getdefaultencoding"); |
||||
IMethod method = methodGroup[0]; |
||||
Assert.AreEqual("String", method.ReturnType.Name); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using NUnit.Framework; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the standard Python module names can be determined
|
||||
/// for IronPython.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GetPythonModulesTestFixture |
||||
{ |
||||
List<ICompletionEntry> moduleNames; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
moduleNames = new PythonStandardModules(); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContainsSysModuleName() |
||||
{ |
||||
Assert.Contains(new NamespaceEntry("sys"), moduleNames); |
||||
} |
||||
|
||||
[Test] |
||||
public void SysModuleInListOfModulesOnlyOnce() |
||||
{ |
||||
int countOccurrencesOfSysModuleName = 0; |
||||
foreach (ICompletionEntry entry in moduleNames) { |
||||
if (entry.Name == "sys") { |
||||
countOccurrencesOfSysModuleName++; |
||||
} |
||||
} |
||||
Assert.AreEqual(1, countOccurrencesOfSysModuleName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContainsBuiltInModule() |
||||
{ |
||||
Assert.Contains(new NamespaceEntry("__builtin__"), moduleNames, "Module names: " + WriteList(moduleNames)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContainsMathModule() |
||||
{ |
||||
Assert.Contains(new NamespaceEntry("math"), moduleNames); |
||||
} |
||||
|
||||
static string WriteList(List<ICompletionEntry> items) |
||||
{ |
||||
StringBuilder text = new StringBuilder(); |
||||
foreach (ICompletionEntry item in items) { |
||||
text.AppendLine(item.Name); |
||||
} |
||||
return text.ToString(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Modules; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class GetTypeForPythonModuleTestFixture |
||||
{ |
||||
PythonStandardModules modules; |
||||
PythonStandardModuleType sysModuleType; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
modules = new PythonStandardModules(); |
||||
sysModuleType = modules.GetModuleType("sys"); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetTypeReturnsNullForUnknownModuleName() |
||||
{ |
||||
Assert.IsNull(modules.GetModuleType("unknown")); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetTypeReturnsSysModuleTypeForSysModuleName() |
||||
{ |
||||
Assert.AreEqual(typeof(SysModule), modules.GetModuleType("sys").Type); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetModuleTypeReturnsSysModuleTypeForSysModuleName() |
||||
{ |
||||
Assert.AreEqual(typeof(SysModule), sysModuleType.Type); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetModuleTypeReturnsSysModuleNameForSysModuleName() |
||||
{ |
||||
Assert.AreEqual("sys", sysModuleType.Name); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class ImportCompletionTestFixture |
||||
{ |
||||
List<ICompletionEntry> completionItems; |
||||
MockProjectContent projectContent; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
projectContent = new MockProjectContent(); |
||||
ParseInformation parseInfo = new ParseInformation(new DefaultCompilationUnit(projectContent)); |
||||
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>(); |
||||
namespaceItems.Add(new NamespaceEntry("Test")); |
||||
projectContent.AddExistingNamespaceContents(String.Empty, namespaceItems); |
||||
|
||||
PythonImportCompletion completion = new PythonImportCompletion(projectContent); |
||||
completionItems = completion.GetCompletionItems(); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestNamespaceIsAddedToCompletionItems() |
||||
{ |
||||
Assert.Contains(new NamespaceEntry("Test"), completionItems); |
||||
} |
||||
|
||||
[Test] |
||||
public void MathStandardPythonModuleIsAddedToCompletionItems() |
||||
{ |
||||
Assert.Contains(new NamespaceEntry("math"), completionItems); |
||||
} |
||||
|
||||
[Test] |
||||
public void NamespacePassedToProjectContentGetNamespaceContentsIsEmptyString() |
||||
{ |
||||
Assert.AreEqual(String.Empty, projectContent.NamespacePassedToGetNamespaceContentsMethod); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class ImportEmptyNamespaceCompletionTestFixture |
||||
{ |
||||
List<ICompletionEntry> completionItems; |
||||
MockProjectContent projectContent; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
projectContent = new MockProjectContent(); |
||||
ParseInformation parseInfo = new ParseInformation(new DefaultCompilationUnit(projectContent)); |
||||
|
||||
PythonImportCompletion completion = new PythonImportCompletion(projectContent); |
||||
completionItems = completion.GetCompletionItems(String.Empty); |
||||
} |
||||
|
||||
[Test] |
||||
public void StandardMathPythonModuleIsAddedToCompletionItems() |
||||
{ |
||||
Assert.Contains(new NamespaceEntry("math"), completionItems); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class ImportResolveResultReturnsNoCompletionItemsIfExpressionHasIdentifierTestFixture |
||||
{ |
||||
PythonImportExpression importExpression; |
||||
PythonImportModuleResolveResult resolveResult; |
||||
MockProjectContent projectContent; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string code = "from System import Console"; |
||||
importExpression = new PythonImportExpression(code); |
||||
resolveResult = new PythonImportModuleResolveResult(importExpression); |
||||
|
||||
projectContent = new MockProjectContent(); |
||||
DefaultCompilationUnit unit = new DefaultCompilationUnit(projectContent); |
||||
DefaultClass c = new DefaultClass(unit, "Test"); |
||||
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>(); |
||||
namespaceItems.Add(c); |
||||
projectContent.AddExistingNamespaceContents("System", namespaceItems); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProjectContentGetNamespaceReturnsOneItem() |
||||
{ |
||||
Assert.AreEqual(1, projectContent.GetNamespaceContents("System").Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoCompletionItemsReturned() |
||||
{ |
||||
List<ICompletionEntry> items = resolveResult.GetCompletionData(projectContent); |
||||
Assert.AreEqual(0, items.Count); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class ImportSubNamespaceCompletionTestFixture |
||||
{ |
||||
List<ICompletionEntry> completionItems; |
||||
MockProjectContent projectContent; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
projectContent = new MockProjectContent(); |
||||
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>(); |
||||
namespaceItems.Add(new NamespaceEntry("ICSharpCode.PythonBinding.Test")); |
||||
projectContent.AddExistingNamespaceContents("ICSharpCode", namespaceItems); |
||||
|
||||
PythonImportCompletion completion = new PythonImportCompletion(projectContent); |
||||
completionItems = completion.GetCompletionItems("ICSharpCode"); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestNamespaceIsAddedToCompletionItems() |
||||
{ |
||||
List<ICompletionEntry> expectedItems = new List<ICompletionEntry>(); |
||||
expectedItems.Add(new NamespaceEntry("ICSharpCode.PythonBinding.Test")); |
||||
Assert.AreEqual(expectedItems, completionItems); |
||||
} |
||||
|
||||
[Test] |
||||
public void NamespacePassedToProjectContentGetNamespaceContentsIsSubNamespaceName() |
||||
{ |
||||
Assert.AreEqual("ICSharpCode", projectContent.NamespacePassedToGetNamespaceContentsMethod); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using IronPython.Hosting; |
||||
using IronPython.Modules; |
||||
using IronPython.Runtime; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Hosting.Providers; |
||||
using Microsoft.Scripting.Runtime; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class MathModuleMembersInPythonContextTestFixture |
||||
{ |
||||
[Test] |
||||
public void UnableToGetMathModuleFromBuiltinModuleDictionary() |
||||
{ |
||||
ScriptEngine engine = Python.CreateEngine(); |
||||
PythonContext context = HostingHelpers.GetLanguageContext(engine) as PythonContext; |
||||
|
||||
object mathModuleFromBuiltinModuleDictionaryObject = null; |
||||
context.BuiltinModuleDict.TryGetValue("math", out mathModuleFromBuiltinModuleDictionaryObject); |
||||
Assert.IsNull(mathModuleFromBuiltinModuleDictionaryObject); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class PythonImportExpressionContextTestFixture |
||||
{ |
||||
[Test] |
||||
public void ShowEntryReturnsTrueForIMethod() |
||||
{ |
||||
PythonImportExpressionContext context = new PythonImportExpressionContext(); |
||||
context.HasFromAndImport = true; |
||||
|
||||
IMethod method = CreateMethod(); |
||||
|
||||
Assert.IsTrue(context.ShowEntry(method)); |
||||
} |
||||
|
||||
IMethod CreateMethod() |
||||
{ |
||||
IClass c = CreateClass(); |
||||
return new DefaultMethod(c, "Test"); |
||||
} |
||||
|
||||
IClass CreateClass() |
||||
{ |
||||
DefaultCompilationUnit unit = new DefaultCompilationUnit(new MockProjectContent()); |
||||
return new DefaultClass(unit, "ICSharpCode.MyClass"); |
||||
} |
||||
|
||||
[Test] |
||||
public void ShowEntryReturnsFalseForNull() |
||||
{ |
||||
PythonImportExpressionContext context = new PythonImportExpressionContext(); |
||||
context.HasFromAndImport = true; |
||||
Assert.IsFalse(context.ShowEntry(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ShowEntryReturnsFalseForIMethodWhenHasFromAndImportIsFalse() |
||||
{ |
||||
PythonImportExpressionContext context = new PythonImportExpressionContext(); |
||||
IMethod method = CreateMethod(); |
||||
Assert.IsFalse(context.ShowEntry(method)); |
||||
} |
||||
|
||||
[Test] |
||||
public void PythonImportExpressionContextHasFromAndImportIsFalseByDefault() |
||||
{ |
||||
PythonImportExpressionContext context = new PythonImportExpressionContext(); |
||||
Assert.IsFalse(context.HasFromAndImport); |
||||
} |
||||
|
||||
[Test] |
||||
public void ShowEntryReturnsTrueForIField() |
||||
{ |
||||
PythonImportExpressionContext context = new PythonImportExpressionContext(); |
||||
context.HasFromAndImport = true; |
||||
IField field = CreateField(); |
||||
|
||||
Assert.IsTrue(context.ShowEntry(field)); |
||||
} |
||||
|
||||
IField CreateField() |
||||
{ |
||||
IClass c = CreateClass(); |
||||
return new DefaultField(c, "field"); |
||||
} |
||||
|
||||
[Test] |
||||
public void ShowEntryReturnsFalseForIFieldWhenHasFromAndImportIsFalse() |
||||
{ |
||||
PythonImportExpressionContext context = new PythonImportExpressionContext(); |
||||
IField field = CreateField(); |
||||
|
||||
Assert.IsFalse(context.ShowEntry(field)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ShowEntryReturnsTrueForIClass() |
||||
{ |
||||
PythonImportExpressionContext context = new PythonImportExpressionContext(); |
||||
context.HasFromAndImport = true; |
||||
IClass c = CreateClass(); |
||||
|
||||
Assert.IsTrue(context.ShowEntry(c)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ShowEntryReturnsFalseForIClassWhenHasFromAndImportIsFalse() |
||||
{ |
||||
PythonImportExpressionContext context = new PythonImportExpressionContext(); |
||||
IClass c = CreateClass(); |
||||
|
||||
Assert.IsFalse(context.ShowEntry(c)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using IronPython.Modules; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the documentation is taken from the Documentation attribute for the method/field in the
|
||||
/// python module classes.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class PythonSocketLibraryDocumentationTestFixture |
||||
{ |
||||
PythonModuleCompletionItems completionItems; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
PythonStandardModuleType moduleType = new PythonStandardModuleType(typeof(PythonSocket), "socket"); |
||||
completionItems = PythonModuleCompletionItemsFactory.Create(moduleType); |
||||
} |
||||
|
||||
[Test] |
||||
public void DocumentationForCreateConnectionMethodTakenFromDocumentationAttribute() |
||||
{ |
||||
string doc = |
||||
"Connect to *address* and return the socket object.\n" + |
||||
"\n" + |
||||
"Convenience function. Connect to *address* (a 2-tuple ``(host,\nport)``) and return the socket object. Passing the optional\n" + |
||||
"*timeout* parameter will set the timeout on the socket instance\nbefore attempting to connect. If no *timeout* is supplied, the\n" + |
||||
"global default timeout setting returned by :func:`getdefaulttimeout`\n" + |
||||
"is used.\n"; |
||||
|
||||
IMethod method = PythonCompletionItemsHelper.FindMethodFromCollection("create_connection", completionItems); |
||||
Assert.AreEqual(doc, method.Documentation); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using IronPython.Hosting; |
||||
using IronPython.Modules; |
||||
using IronPython.Runtime; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Hosting.Providers; |
||||
using Microsoft.Scripting.Runtime; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Completion |
||||
{ |
||||
[TestFixture] |
||||
public class SysModuleMembersInPythonContextTestFixture |
||||
{ |
||||
IList<string> membersFromSystemState; |
||||
object sysModuleFromBuiltinModuleDictionaryObject; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
ScriptEngine engine = Python.CreateEngine(); |
||||
PythonContext context = HostingHelpers.GetLanguageContext(engine) as PythonContext; |
||||
|
||||
membersFromSystemState = context.GetMemberNames(context.SystemState); |
||||
|
||||
sysModuleFromBuiltinModuleDictionaryObject = null; |
||||
context.BuiltinModuleDict.TryGetValue("sys", out sysModuleFromBuiltinModuleDictionaryObject); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExitMethodIsMemberOfSystemState() |
||||
{ |
||||
Assert.IsTrue(membersFromSystemState.Contains("exit")); |
||||
} |
||||
|
||||
[Test] |
||||
public void SysModuleFromBuiltinModuleDictionary() |
||||
{ |
||||
Assert.IsNull(sysModuleFromBuiltinModuleDictionaryObject); |
||||
} |
||||
|
||||
[Test] |
||||
public void PathIsMemberOfSystemState() |
||||
{ |
||||
Assert.IsTrue(membersFromSystemState.Contains("path")); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Drawing; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
[TestFixture] |
||||
public class LoadFileSystemWatcherTestFixture : LoadFormTestFixtureBase |
||||
{ |
||||
public override string PythonCode { |
||||
get { |
||||
return |
||||
"class MainForm(System.Windows.Forms.Form):\r\n" + |
||||
" def InitializeComponent(self):\r\n" + |
||||
" self._fileSystemWatcher1 = System.IO.FileSystemWatcher()\r\n" + |
||||
" self._fileSystemWatcher1.BeginInit()\r\n" + |
||||
" self.SuspendLayout()\r\n" + |
||||
" # \r\n" + |
||||
" # fileSystemWatcher1\r\n" + |
||||
" # \r\n" + |
||||
" self._fileSystemWatcher1.EnableRaisingEvents = True\r\n" + |
||||
" self._fileSystemWatcher1.SynchronizingObject = self\r\n" + |
||||
" # \r\n" + |
||||
" # MainForm\r\n" + |
||||
" # \r\n" + |
||||
" self.ClientSize = System.Drawing.Size(300, 400)\r\n" + |
||||
" self.Name = \"MainForm\"\r\n" + |
||||
" self._fileSystemWatcher1.EndInit()\r\n" + |
||||
" self.ResumeLayout(False)\r\n"; |
||||
} |
||||
} |
||||
|
||||
public CreatedInstance FileSystemWatcherInstance { |
||||
get { return ComponentCreator.CreatedInstances[0]; } |
||||
} |
||||
|
||||
public FileSystemWatcher FileSystemWatcher { |
||||
get { return FileSystemWatcherInstance.Object as FileSystemWatcher; } |
||||
} |
||||
|
||||
[Test] |
||||
public void ComponentName() |
||||
{ |
||||
Assert.AreEqual("fileSystemWatcher1", FileSystemWatcherInstance.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void ComponentType() |
||||
{ |
||||
Assert.AreEqual("System.IO.FileSystemWatcher", FileSystemWatcherInstance.InstanceType.FullName); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileSystemWatcherEnableRaisingEventsIsTrue() |
||||
{ |
||||
Assert.IsTrue(FileSystemWatcher.EnableRaisingEvents); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileSystemWatcherSynchronisingObjectIsForm() |
||||
{ |
||||
Assert.AreSame(Form, FileSystemWatcher.SynchronizingObject); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class FindExpressionOnLineWithSingleSpaceTestFixture |
||||
{ |
||||
ExpressionResult result; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string text = " "; |
||||
PythonExpressionFinder expressionFinder = new PythonExpressionFinder(); |
||||
result = expressionFinder.FindExpression(text, 1); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExpressionResultExpressionIsEmptyString() |
||||
{ |
||||
Assert.AreEqual(String.Empty, result.Expression); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class FindExpressionWithImportOnPreviousLineTestFixture |
||||
{ |
||||
ExpressionResult result; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string text = "import\r\n"; |
||||
PythonExpressionFinder expressionFinder = new PythonExpressionFinder(); |
||||
int offset = 8; // Cursor is just after \r\n on second line.
|
||||
result = expressionFinder.FindExpression(text, offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExpressionResultExpressionIsEmptyString() |
||||
{ |
||||
Assert.AreEqual(String.Empty, result.Expression); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Hosting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class FromImportNamespaceExpressionTests |
||||
{ |
||||
ScriptEngine engine; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
engine = Python.CreateEngine(); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromModuleNameIsSystemForFromSystemExpression() |
||||
{ |
||||
PythonImportExpression expression = new PythonImportExpression(engine, "from System"); |
||||
Assert.AreEqual("System", expression.Module); |
||||
Assert.IsFalse(expression.HasFromAndImport); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromModuleNameIsEmptyWhenOnlyFromIsInExpression() |
||||
{ |
||||
PythonImportExpression expression = new PythonImportExpression(engine, "from"); |
||||
Assert.AreEqual(String.Empty, expression.Module); |
||||
Assert.IsFalse(expression.HasFromAndImport); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromModuleNameIsSystemForFromSystemExpressionWithWhitespaceBetweenImportAndSystem() |
||||
{ |
||||
PythonImportExpression expression = new PythonImportExpression(engine, "from \t System"); |
||||
Assert.AreEqual("System", expression.Module); |
||||
Assert.IsFalse(expression.HasFromAndImport); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasIdentifierReturnsFalseForFromMathImportWithoutIdentfier() |
||||
{ |
||||
PythonImportExpression expression = new PythonImportExpression(engine, "from math import"); |
||||
Assert.IsFalse(expression.HasIdentifier); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Hosting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class FromSystemImportTestFixture |
||||
{ |
||||
PythonImportExpression expression; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string text = "from System import "; |
||||
expression = new PythonImportExpression(Python.CreateEngine(), text); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasFromImportAndImportReturnsTrue() |
||||
{ |
||||
Assert.IsTrue(expression.HasFromAndImport); |
||||
} |
||||
|
||||
[Test] |
||||
public void ModuleNameIsSystem() |
||||
{ |
||||
Assert.AreEqual("System", expression.Module); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Hosting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class ImportNamespaceExpressionTests |
||||
{ |
||||
ScriptEngine engine; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
engine = Python.CreateEngine(); |
||||
} |
||||
|
||||
[Test] |
||||
public void ModuleNameReturnedIsSystemForImportSystemExpression() |
||||
{ |
||||
PythonImportExpression expression = new PythonImportExpression(engine, "import System"); |
||||
Assert.AreEqual("System", expression.Module); |
||||
} |
||||
|
||||
[Test] |
||||
public void ModuleNameReturnedIsSystemForImportSystemExpressionWithWhitespaceBetweenImportAndSystem() |
||||
{ |
||||
string code = "import \t System"; |
||||
PythonImportExpression expression = new PythonImportExpression(engine, code); |
||||
Assert.AreEqual("System", expression.Module); |
||||
} |
||||
|
||||
[Test] |
||||
public void ModuleNameIsEmptyStringWhenExpressionIsEmptyString() |
||||
{ |
||||
PythonImportExpression expression = new PythonImportExpression(engine, String.Empty); |
||||
Assert.AreEqual(String.Empty, expression.Module); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class IsImportExpressionTestFixture |
||||
{ |
||||
[Test] |
||||
public void EmptyStringIsNotImportExpression() |
||||
{ |
||||
string text = String.Empty; |
||||
int offset = 0; |
||||
Assert.IsFalse(PythonImportExpression.IsImportExpression(text, offset)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ImportStringFollowedByWhitespaceIsImportExpression() |
||||
{ |
||||
string text = "import "; |
||||
int offset = text.Length - 1; |
||||
Assert.IsTrue(PythonImportExpression.IsImportExpression(text, offset)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ImportStringSurroundedByExtraWhitespaceIsImportExpression() |
||||
{ |
||||
string text = " import "; |
||||
int offset = text.Length - 1; |
||||
Assert.IsTrue(PythonImportExpression.IsImportExpression(text, offset)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ImportInsideAnotherStringIsNotImportExpression() |
||||
{ |
||||
string text = "Start-import-End"; |
||||
int offset = text.Length - 1; |
||||
Assert.IsFalse(PythonImportExpression.IsImportExpression(text, offset)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ImportSystemIsImportExpression() |
||||
{ |
||||
string text = "import System"; |
||||
int offset = text.Length - 1; |
||||
Assert.IsTrue(PythonImportExpression.IsImportExpression(text, offset)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsImportExpressionReturnsFalseWhenOffsetIsMinusOne() |
||||
{ |
||||
string text = "import a"; |
||||
int offset = -1; |
||||
Assert.IsFalse(PythonImportExpression.IsImportExpression(text, offset)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsImportExpressionReturnsTrueWhenExpressionContainsOnlyFromPart() |
||||
{ |
||||
string text = "from a"; |
||||
int offset = text.Length - 1; |
||||
Assert.IsTrue(PythonImportExpression.IsImportExpression(text, offset)); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromExpressionFollowedByWhitespaceIsImportExpression() |
||||
{ |
||||
string text = "from "; |
||||
int offset = text.Length - 1; |
||||
Assert.IsTrue(PythonImportExpression.IsImportExpression(text, offset)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class ParseFromImportWithIdentifierTestFixture |
||||
{ |
||||
PythonImportExpression importExpression; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string code = "from System import Console"; |
||||
importExpression = new PythonImportExpression(code); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasImportAndFromReturnsTrue() |
||||
{ |
||||
Assert.IsTrue(importExpression.HasFromAndImport); |
||||
} |
||||
|
||||
[Test] |
||||
public void ImportIdentifierIsConsole() |
||||
{ |
||||
Assert.AreEqual("Console", importExpression.Identifier); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasIdentifierReturnsTrue() |
||||
{ |
||||
Assert.IsTrue(importExpression.HasIdentifier); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class FindExpressionFromImportWithoutImportedNameTestFixture |
||||
{ |
||||
ExpressionResult expressionResult; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string code = "from System import "; |
||||
int offset = 19; |
||||
PythonExpressionFinder expressionFinder = new PythonExpressionFinder(); |
||||
expressionResult = expressionFinder.FindExpression(code, offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExpressionResultContextIsImportExpression() |
||||
{ |
||||
Assert.IsNotNull(expressionResult.Context as PythonImportExpressionContext); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExpressionIsFullFromImportStatement() |
||||
{ |
||||
Assert.AreSame("from System import ", expressionResult.Expression); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Hosting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class ParseImportExpressionOnlyTestFixture |
||||
{ |
||||
PythonImportExpression importExpression; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string text = "import"; |
||||
importExpression = new PythonImportExpression(Python.CreateEngine(), text); |
||||
} |
||||
|
||||
[Test] |
||||
public void ModuleNameIsEmptyString() |
||||
{ |
||||
Assert.AreEqual(String.Empty, importExpression.Module); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasFromAndImportIsFalse() |
||||
{ |
||||
Assert.IsFalse(importExpression.HasFromAndImport); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Hosting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class ParseImportSystemConsoleExpressionTestFixture |
||||
{ |
||||
PythonImportExpression importExpression; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string text = "import System.Console"; |
||||
importExpression = new PythonImportExpression(Python.CreateEngine(), text); |
||||
} |
||||
|
||||
[Test] |
||||
public void ModuleNameIsSystem() |
||||
{ |
||||
Assert.AreEqual("System.Console", importExpression.Module); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasFromAndImportIsFalse() |
||||
{ |
||||
Assert.IsFalse(importExpression.HasFromAndImport); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Hosting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class ParseImportSystemExpressionTestFixture |
||||
{ |
||||
PythonImportExpression importExpression; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string text = "import System"; |
||||
importExpression = new PythonImportExpression(Python.CreateEngine(), text); |
||||
} |
||||
|
||||
[Test] |
||||
public void ModuleNameIsSystem() |
||||
{ |
||||
Assert.AreEqual("System", importExpression.Module); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasFromAndImportIsFalse() |
||||
{ |
||||
Assert.IsFalse(importExpression.HasFromAndImport); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,123 @@
@@ -0,0 +1,123 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
using Microsoft.Scripting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Hosting.Providers; |
||||
using Microsoft.Scripting.Runtime; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython; |
||||
using IronPython.Compiler; |
||||
using IronPython.Compiler.Ast; |
||||
using IronPython.Hosting; |
||||
using IronPython.Runtime; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class ParsePartialFromImportStatementTestFixture |
||||
{ |
||||
FromImportStatement fromStatement; |
||||
|
||||
public FromImportStatement ParseStatement(string text) |
||||
{ |
||||
ScriptEngine engine = Python.CreateEngine(); |
||||
PythonContext context = HostingHelpers.GetLanguageContext(engine) as PythonContext; |
||||
|
||||
StringTextContentProvider textProvider = new StringTextContentProvider(text); |
||||
SourceUnit source = context.CreateSourceUnit(textProvider, String.Empty, SourceCodeKind.SingleStatement); |
||||
|
||||
PythonCompilerSink sink = new PythonCompilerSink(); |
||||
CompilerContext compilerContext = new CompilerContext(source, new PythonCompilerOptions(), sink); |
||||
|
||||
PythonOptions options = new PythonOptions(); |
||||
using (Parser parser = Parser.CreateParser(compilerContext, options)) { |
||||
return parser.ParseSingleStatement().Body as FromImportStatement; |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemImportStatementFollowedByIdentifierHasModuleNameOfSystem() |
||||
{ |
||||
string text = "from System import abc"; |
||||
fromStatement = ParseStatement(text); |
||||
Assert.AreEqual("System", fromStatement.Root.MakeString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemImportStatementFollowedByIdentifierHasIdentifierInNamesCollection() |
||||
{ |
||||
FromSystemImportStatementFollowedByIdentifierHasModuleNameOfSystem(); |
||||
Assert.IsTrue(fromStatement.Names.Contains("abc")); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemImportStatementFollowedByEmptySpaceHasModuleNameOfSystem() |
||||
{ |
||||
string text = "from System import "; |
||||
fromStatement = ParseStatement(text); |
||||
Assert.AreEqual("System", fromStatement.Root.MakeString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemStatementWithNoImportHasModuleNameOfSystem() |
||||
{ |
||||
string text = "from System"; |
||||
fromStatement = ParseStatement(text); |
||||
Assert.AreEqual("System", fromStatement.Root.MakeString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromStatementFollowedBySpaceCharButNoModuleNameHasModuleNameOfEmptyString() |
||||
{ |
||||
string text = "from "; |
||||
fromStatement = ParseStatement(text); |
||||
Assert.AreEqual(String.Empty, fromStatement.Root.MakeString()); |
||||
} |
||||
|
||||
[Test] |
||||
[Ignore("Does not work")] |
||||
public void FromSystemImportStatementFollowedByIdentifierAsNameHasIdentifierAsNameInAsNamesCollection() |
||||
{ |
||||
string text = "from System import abc as def"; |
||||
fromStatement = ParseStatement(text); |
||||
Assert.AreEqual("def", fromStatement.AsNames[0]); |
||||
} |
||||
|
||||
[Test] |
||||
[Ignore("Does not work")] |
||||
public void FromSystemImportStatementFollowedByIdentifierAsNameFollowedBySpaceHasIdentifierAsNameInAsNamesCollection() |
||||
{ |
||||
string text = "from System import abc as def "; |
||||
fromStatement = ParseStatement(text); |
||||
Assert.AreEqual("def", fromStatement.AsNames[0]); |
||||
} |
||||
|
||||
[Test] |
||||
[Ignore("Does not work")] |
||||
public void FromSystemImportStatementFollowedByIdentifierAsNameFollowedByNewLineHasIdentifierAsNameInAsNamesCollection() |
||||
{ |
||||
string text = "from System import abc as def\r\n"; |
||||
fromStatement = ParseStatement(text); |
||||
Assert.AreEqual("def", fromStatement.AsNames[0]); |
||||
} |
||||
|
||||
[Test] |
||||
[Ignore("Does not work")] |
||||
public void FromSystemImportStatementFollowedByMultipleIdentifierAsNameFollowedBySpaceHasIdentifierAsNameInAsNamesCollection() |
||||
{ |
||||
string text = "from System import abc as def, ghi as jkl"; |
||||
fromStatement = ParseStatement(text); |
||||
Assert.AreEqual("def", fromStatement.AsNames[0]); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,145 @@
@@ -0,0 +1,145 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
using Microsoft.Scripting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Hosting.Providers; |
||||
using Microsoft.Scripting.Runtime; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython; |
||||
using IPyCompiler = IronPython.Compiler; |
||||
using IronPython.Compiler.Ast; |
||||
using IronPython.Hosting; |
||||
using IronPython.Runtime; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class ParsePartialFromImportStatementWithTokenizerTestFixture |
||||
{ |
||||
IPyCompiler.Tokenizer tokenizer; |
||||
|
||||
public IPyCompiler.Tokenizer CreateTokenizer(string text) |
||||
{ |
||||
ScriptEngine engine = Python.CreateEngine(); |
||||
PythonContext context = HostingHelpers.GetLanguageContext(engine) as PythonContext; |
||||
|
||||
StringTextContentProvider textProvider = new StringTextContentProvider(text); |
||||
SourceUnit source = context.CreateSourceUnit(textProvider, String.Empty, SourceCodeKind.SingleStatement); |
||||
|
||||
PythonCompilerSink sink = new PythonCompilerSink(); |
||||
IPyCompiler.PythonCompilerOptions options = new IPyCompiler.PythonCompilerOptions(); |
||||
|
||||
tokenizer = new IPyCompiler.Tokenizer(sink, options); |
||||
tokenizer.Initialize(source); |
||||
return tokenizer; |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstTokenIsFrom() |
||||
{ |
||||
string text = "from"; |
||||
tokenizer = CreateTokenizer(text); |
||||
IPyCompiler.Token token = tokenizer.GetNextToken(); |
||||
Assert.AreEqual(IPyCompiler.TokenKind.KeywordFrom, token.Kind); |
||||
} |
||||
|
||||
[Test] |
||||
public void TokenAfterFromIsEof() |
||||
{ |
||||
FirstTokenIsFrom(); |
||||
IPyCompiler.Token token = tokenizer.GetNextToken(); |
||||
|
||||
Assert.AreEqual(IPyCompiler.TokenKind.EndOfFile, token.Kind); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemImportSecondTokenIsModule() |
||||
{ |
||||
string text = "from System"; |
||||
IPyCompiler.Token token = GetSecondToken(text); |
||||
|
||||
Assert.AreEqual(IPyCompiler.TokenKind.Name, token.Kind); |
||||
} |
||||
|
||||
IPyCompiler.Token GetSecondToken(string text) |
||||
{ |
||||
return GetToken(text, 2); |
||||
} |
||||
|
||||
IPyCompiler.Token GetToken(string text, int tokenNumber) |
||||
{ |
||||
tokenizer = CreateTokenizer(text); |
||||
|
||||
IPyCompiler.Token token = null; |
||||
for (int i = 0; i < tokenNumber; ++i) { |
||||
token = tokenizer.GetNextToken(); |
||||
} |
||||
return token; |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemImportSecondTokenValueIsSystem() |
||||
{ |
||||
string text = "from System"; |
||||
IPyCompiler.Token token = GetSecondToken(text); |
||||
|
||||
Assert.AreEqual("System", token.Value as String); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemConsoleImportSecondTokenValueIsSystem() |
||||
{ |
||||
string text = "from System.Console"; |
||||
IPyCompiler.Token token = GetSecondToken(text); |
||||
|
||||
Assert.AreEqual("System", token.Value as String); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemConsoleImportThirdTokenValueIsDotCharacter() |
||||
{ |
||||
FromSystemConsoleImportSecondTokenValueIsSystem(); |
||||
IPyCompiler.Token token = tokenizer.GetNextToken(); |
||||
|
||||
Assert.AreEqual(IPyCompiler.TokenKind.Dot, token.Kind); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemImportThirdTokenIsImportToken() |
||||
{ |
||||
string text = "from System import"; |
||||
IPyCompiler.Token token = GetThirdToken(text); |
||||
|
||||
Assert.AreEqual(IPyCompiler.TokenKind.KeywordImport, token.Kind); |
||||
} |
||||
|
||||
IPyCompiler.Token GetThirdToken(string text) |
||||
{ |
||||
return GetToken(text, 3); |
||||
} |
||||
|
||||
[Test] |
||||
public void FromSystemImportIdentifierFourthTokenIsIndentifierToken() |
||||
{ |
||||
string text = "from System import abc"; |
||||
IPyCompiler.Token token = GetFourthToken(text); |
||||
|
||||
Assert.AreEqual("abc", token.Value as String); |
||||
} |
||||
|
||||
IPyCompiler.Token GetFourthToken(string text) |
||||
{ |
||||
return GetToken(text, 4); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Compiler; |
||||
using IronPython.Hosting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class ParseSimpleImportExpressionTestFixture |
||||
{ |
||||
PythonExpression expression; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string code = "import"; |
||||
ScriptEngine engine = Python.CreateEngine(); |
||||
expression = new PythonExpression(engine, code); |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstTokenIsImportKeyword() |
||||
{ |
||||
Token token = expression.GetNextToken(); |
||||
Assert.AreEqual(TokenKind.KeywordImport, token.Kind); |
||||
} |
||||
|
||||
[Test] |
||||
public void SecondTokenIsEndOfFile() |
||||
{ |
||||
expression.GetNextToken(); |
||||
Token token = expression.GetNextToken(); |
||||
Assert.AreEqual(TokenKind.EndOfFile, token.Kind); |
||||
} |
||||
|
||||
[Test] |
||||
public void CurrentTokenIsNull() |
||||
{ |
||||
Assert.IsNull(expression.CurrentToken); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetNextTokenSetsCurrentTokenToKeywordImport() |
||||
{ |
||||
expression.GetNextToken(); |
||||
Assert.AreEqual(TokenKind.KeywordImport, expression.CurrentToken.Kind); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Hosting; |
||||
using IronPython.Runtime; |
||||
using Microsoft.Scripting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Hosting.Providers; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Expressions |
||||
{ |
||||
[TestFixture] |
||||
public class StringTextContentProviderTests |
||||
{ |
||||
[Test] |
||||
public void ReadToEndFromStringTextContentProvider() |
||||
{ |
||||
string text = "abc"; |
||||
StringTextContentProvider provider = new StringTextContentProvider(text); |
||||
using (SourceCodeReader reader = provider.GetReader()) { |
||||
Assert.AreEqual("abc", reader.ReadToEnd()); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void StringTextContentProviderIsMicrosoftScriptingTextContentProvider() |
||||
{ |
||||
StringTextContentProvider provider = new StringTextContentProvider(String.Empty); |
||||
Assert.IsNotNull(provider as TextContentProvider); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Parsing |
||||
{ |
||||
[TestFixture] |
||||
public class ParseFromMathImportAllTestFixture |
||||
{ |
||||
ICompilationUnit compilationUnit; |
||||
PythonFromImport import; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string python = "from math import *"; |
||||
|
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
PythonParser parser = new PythonParser(); |
||||
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); |
||||
import = compilationUnit.UsingScope.Usings[0] as PythonFromImport; |
||||
} |
||||
|
||||
[Test] |
||||
public void PythonImportContainsMathModuleName() |
||||
{ |
||||
Assert.AreEqual("math", import.Module); |
||||
} |
||||
|
||||
[Test] |
||||
public void PythonImportImportsEverythingReturnsTrue() |
||||
{ |
||||
Assert.IsTrue(import.ImportsEverything); |
||||
} |
||||
|
||||
[Test] |
||||
public void PythonImportGetIdentifierForAliasDoesNotThrowNullReferenceException() |
||||
{ |
||||
string identifier = String.Empty; |
||||
Assert.DoesNotThrow(delegate { identifier = import.GetOriginalNameForAlias("unknown"); }); |
||||
Assert.IsNull(identifier); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Parsing |
||||
{ |
||||
[TestFixture] |
||||
public class ParseFromMathImportCosAndTanTestFixture |
||||
{ |
||||
ICompilationUnit compilationUnit; |
||||
PythonFromImport import; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string python = "from math import cos, tan"; |
||||
|
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
PythonParser parser = new PythonParser(); |
||||
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); |
||||
import = compilationUnit.UsingScope.Usings[0] as PythonFromImport; |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportHasCosIdentifier() |
||||
{ |
||||
Assert.IsTrue(import.IsImportedName("cos")); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportContainsMathModuleName() |
||||
{ |
||||
Assert.AreEqual("math", import.Module); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportHasTanIdentifier() |
||||
{ |
||||
Assert.IsTrue(import.IsImportedName("tan")); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportDoesNotHaveACosIdentifier() |
||||
{ |
||||
Assert.IsFalse(import.IsImportedName("acos")); |
||||
} |
||||
|
||||
[Test] |
||||
public void PythonImportImportsEverythingReturnsFalse() |
||||
{ |
||||
Assert.IsFalse(import.ImportsEverything); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Parsing |
||||
{ |
||||
[TestFixture] |
||||
public class ParseFromSysImportExitAsMyExitTestFixture |
||||
{ |
||||
ICompilationUnit compilationUnit; |
||||
PythonFromImport import; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string python = "from sys import exit as myexit"; |
||||
|
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
PythonParser parser = new PythonParser(); |
||||
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); |
||||
import = compilationUnit.UsingScope.Usings[0] as PythonFromImport; |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportHasMyExitIdentifier() |
||||
{ |
||||
Assert.IsTrue(import.IsImportedName("myexit")); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportDoesNotHaveExitIdentifier() |
||||
{ |
||||
Assert.IsFalse(import.IsImportedName("exit")); |
||||
} |
||||
|
||||
[Test] |
||||
public void PythonImportGetIdentifierFromAliasReturnsExitForMyExit() |
||||
{ |
||||
Assert.AreEqual("exit", import.GetOriginalNameForAlias("myexit")); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Parsing |
||||
{ |
||||
[TestFixture] |
||||
public class ParseFromSysImportExitTestFixture |
||||
{ |
||||
ICompilationUnit compilationUnit; |
||||
PythonFromImport import; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string python = "from sys import exit"; |
||||
|
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
PythonParser parser = new PythonParser(); |
||||
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); |
||||
import = compilationUnit.UsingScope.Usings[0] as PythonFromImport; |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportHasExitIdentifier() |
||||
{ |
||||
Assert.IsTrue(import.IsImportedName("exit")); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportDoesNotHaveUnknownIdentifier() |
||||
{ |
||||
Assert.IsFalse(import.IsImportedName("unknown")); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportContainsSysModuleName() |
||||
{ |
||||
Assert.AreEqual("sys", import.Module); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Parsing |
||||
{ |
||||
[TestFixture] |
||||
public class ParseFromSysImportMissingImportTestFixture |
||||
{ |
||||
ICompilationUnit compilationUnit; |
||||
PythonFromImport import; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string python = "from sys"; |
||||
|
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
PythonParser parser = new PythonParser(); |
||||
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); |
||||
import = compilationUnit.UsingScope.Usings[0] as PythonFromImport; |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportDoesNotHaveEmptyStringIdentifier() |
||||
{ |
||||
Assert.IsFalse(import.IsImportedName(String.Empty)); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportDoesNotHaveNullIdentifier() |
||||
{ |
||||
Assert.IsFalse(import.IsImportedName(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportContainsSysModuleName() |
||||
{ |
||||
Assert.AreEqual("sys", import.Module); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Parsing |
||||
{ |
||||
[TestFixture] |
||||
public class ParseFromSysImportWithoutImportedNameTestFixture |
||||
{ |
||||
ICompilationUnit compilationUnit; |
||||
PythonFromImport import; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string python = "from sys import"; |
||||
|
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
PythonParser parser = new PythonParser(); |
||||
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); |
||||
import = compilationUnit.UsingScope.Usings[0] as PythonFromImport; |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportDoesNotHaveEmptyStringIdentifier() |
||||
{ |
||||
Assert.IsFalse(import.IsImportedName(String.Empty)); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportDoesNotHaveNullIdentifier() |
||||
{ |
||||
Assert.IsFalse(import.IsImportedName(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void UsingAsPythonImportContainsSysModuleName() |
||||
{ |
||||
Assert.AreEqual("sys", import.Module); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests; |
||||
|
||||
namespace PythonBinding.Tests.Parsing |
||||
{ |
||||
[TestFixture] |
||||
public class ParseImportMultipleModulesTestFixture |
||||
{ |
||||
ICompilationUnit compilationUnit; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
string python = "import System, System.Console"; |
||||
|
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
PythonParser parser = new PythonParser(); |
||||
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); |
||||
} |
||||
|
||||
[Test] |
||||
public void OneUsingStatementCreatedByParser() |
||||
{ |
||||
Assert.AreEqual(1, compilationUnit.UsingScope.Usings.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstNamespaceImportedIsSystem() |
||||
{ |
||||
Assert.AreEqual("System", compilationUnit.UsingScope.Usings[0].Usings[0]); |
||||
} |
||||
|
||||
[Test] |
||||
public void SecondNamespaceImportedIsSystemConsole() |
||||
{ |
||||
Assert.AreEqual("System.Console", compilationUnit.UsingScope.Usings[0].Usings[1]); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Parsing |
||||
{ |
||||
[TestFixture] |
||||
public class ParseImportSysTestFixture |
||||
{ |
||||
ICompilationUnit compilationUnit; |
||||
PythonImport import; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string python = "import sys"; |
||||
|
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
PythonParser parser = new PythonParser(); |
||||
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); |
||||
import = compilationUnit.UsingScope.Usings[0] as PythonImport; |
||||
} |
||||
|
||||
[Test] |
||||
public void PythonImportHasExitIdentifier() |
||||
{ |
||||
Assert.AreEqual("sys", import.Module); |
||||
} |
||||
} |
||||
} |
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Text; |
||||
using NUnit.Framework; |
||||
using ICSharpCode.PythonBinding; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the standard Python module names can be determined
|
||||
/// from the IronPython assembly.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GetPythonModulesTestFixture |
||||
{ |
||||
string[] moduleNames; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
StandardPythonModules modules = new StandardPythonModules(); |
||||
moduleNames = modules.GetNames(); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContainsSysModuleName() |
||||
{ |
||||
Assert.Contains("sys", moduleNames); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContainsBuiltInModule() |
||||
{ |
||||
Assert.Contains("__builtin__", moduleNames, "Module names: " + WriteArray(moduleNames)); |
||||
} |
||||
|
||||
static string WriteArray(string[] items) |
||||
{ |
||||
StringBuilder text = new StringBuilder(); |
||||
foreach (string item in items) { |
||||
text.AppendLine(item); |
||||
} |
||||
return text.ToString(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ImportModuleResolveResultTests |
||||
{ |
||||
[Test] |
||||
public void NamePropertyMatchesTextPassedToConstructor() |
||||
{ |
||||
PythonImportExpression expression = new PythonImportExpression("import abc"); |
||||
PythonImportModuleResolveResult result = new PythonImportModuleResolveResult(expression); |
||||
Assert.AreEqual("abc", result.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetCompletionDataReturnsStandardMathPythonModuleWhenImportNameIsEmptyString() |
||||
{ |
||||
PythonImportExpression expression = new PythonImportExpression(String.Empty); |
||||
PythonImportModuleResolveResult result = new PythonImportModuleResolveResult(expression); |
||||
MockProjectContent projectContent = new MockProjectContent(); |
||||
Assert.Contains(new NamespaceEntry("math"), result.GetCompletionData(projectContent)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ClonedPythonModuleResultReturnsSameCompletionItems() |
||||
{ |
||||
PythonImportExpression expression = new PythonImportExpression(String.Empty); |
||||
PythonImportModuleResolveResult result = new PythonImportModuleResolveResult(expression); |
||||
ResolveResult clonedResult = result.Clone(); |
||||
MockProjectContent projectContent = new MockProjectContent(); |
||||
Assert.Contains(new NamespaceEntry("math"), clonedResult.GetCompletionData(projectContent)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class MemberNameTests |
||||
{ |
||||
[Test] |
||||
public void MemberNameIsEqualReturnsTrueWhenNameAndTypeAreSame() |
||||
{ |
||||
MemberName lhs = new MemberName("type", "member"); |
||||
MemberName rhs = new MemberName("type", "member"); |
||||
|
||||
Assert.IsTrue(lhs.Equals(rhs)); |
||||
} |
||||
|
||||
[Test] |
||||
public void MemberNameIsEqualsReturnsFalseWhenMemberNameIsNull() |
||||
{ |
||||
MemberName lhs = new MemberName("type", "Member"); |
||||
Assert.IsFalse(lhs.Equals(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void MemberNamePropertyReturnsMemberName() |
||||
{ |
||||
MemberName methodName = new MemberName("type", "method"); |
||||
Assert.AreEqual("method", methodName.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void MemberNameTypePropertyReturnsType() |
||||
{ |
||||
MemberName methodName = new MemberName("type", "method"); |
||||
Assert.AreEqual("type", methodName.Type); |
||||
} |
||||
|
||||
[Test] |
||||
public void MemberNameIsEqualReturnsFalseWhenMemberNameIsDifferent() |
||||
{ |
||||
MemberName lhs = new MemberName("type", "method1"); |
||||
MemberName rhs = new MemberName("type", "method2"); |
||||
|
||||
Assert.IsFalse(lhs.Equals(rhs)); |
||||
} |
||||
|
||||
[Test] |
||||
public void MemberNameIsEqualReturnsFalseWhenTypeNameIsDifferent() |
||||
{ |
||||
MemberName lhs = new MemberName("type1", "method"); |
||||
MemberName rhs = new MemberName("type2", "method"); |
||||
|
||||
Assert.IsFalse(lhs.Equals(rhs)); |
||||
} |
||||
|
||||
[Test] |
||||
public void MemberNameToStringShowsTypeNameAndMemberName() |
||||
{ |
||||
MemberName methodName = new MemberName("type", "method"); |
||||
string expectedText = "Type: type, Member: method"; |
||||
Assert.AreEqual(expectedText, methodName.ToString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateMemberNameWithNullStringReturnsMemberNameWithEmptyTypeAndMemberName() |
||||
{ |
||||
MemberName methodName = new MemberName(null); |
||||
MemberName expectedMemberName = new MemberName(String.Empty, String.Empty); |
||||
Assert.AreEqual(expectedMemberName, methodName); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateMemberNameWithEmptyStringReturnsMemberNameWithEmptyTypeAndMemberName() |
||||
{ |
||||
MemberName methodName = new MemberName(String.Empty); |
||||
MemberName expectedMemberName = new MemberName(String.Empty, String.Empty); |
||||
Assert.AreEqual(expectedMemberName, methodName); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateMemberNameWithSystemDotConsoleDotWriteLineReturnsMemberNameWriteLineAndTypeNameSystemDotConsole() |
||||
{ |
||||
MemberName methodName = new MemberName("System.Console.WriteLine"); |
||||
MemberName expectedMemberName = new MemberName("System.Console", "WriteLine"); |
||||
|
||||
Assert.AreEqual(expectedMemberName, methodName); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateMemberNameWithExpressionWithoutDotCharReturnsMemberNameOfEmptyStringAndExpressionAsTypeName() |
||||
{ |
||||
MemberName methodName = new MemberName("test"); |
||||
MemberName expectedMemberName = new MemberName("test", String.Empty); |
||||
Assert.AreEqual(expectedMemberName, methodName); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasNameReturnsFalseForMemberNameWithEmptyStringForMemberName() |
||||
{ |
||||
MemberName memberName = new MemberName("System", String.Empty); |
||||
Assert.IsFalse(memberName.HasName); |
||||
} |
||||
|
||||
[Test] |
||||
public void HasNameReturnsTrueForMemberNameWithNonEmptyStringForMemberName() |
||||
{ |
||||
MemberName memberName = new MemberName("System", "Console"); |
||||
Assert.IsTrue(memberName.HasName); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,121 @@
@@ -0,0 +1,121 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveBuiltInRoundMethodTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
return new ExpressionResult("round", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"round\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsMethodGroupResolveResult() |
||||
{ |
||||
Assert.IsTrue(resolveResult is MethodGroupResolveResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultMethodNameIsRound() |
||||
{ |
||||
Assert.AreEqual("round", MethodResolveResult.Name); |
||||
} |
||||
|
||||
MethodGroupResolveResult MethodResolveResult { |
||||
get { return (MethodGroupResolveResult)resolveResult; } |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultContainingTypeHasTwoRoundMethods() |
||||
{ |
||||
List<IMethod> exitMethods = GetRoundMethods(); |
||||
Assert.AreEqual(2, exitMethods.Count); |
||||
} |
||||
|
||||
List<IMethod> GetRoundMethods() |
||||
{ |
||||
return GetRoundMethods(-1); |
||||
} |
||||
|
||||
List<IMethod> GetRoundMethods(int parameterCount) |
||||
{ |
||||
List<IMethod> methods = MethodResolveResult.ContainingType.GetMethods(); |
||||
return PythonCompletionItemsHelper.FindAllMethodsFromCollection("round", parameterCount, methods.ToArray()); |
||||
} |
||||
|
||||
[Test] |
||||
public void BothRoundMethodsArePublic() |
||||
{ |
||||
foreach (IMethod method in GetRoundMethods()) { |
||||
Assert.IsTrue(method.IsPublic); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void BothRoundMethodsHaveClassWithNameOfSys() |
||||
{ |
||||
foreach (IMethod method in GetRoundMethods()) { |
||||
Assert.AreEqual("__builtin__", method.DeclaringType.Name); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void OneRoundMethodHasTwoParameters() |
||||
{ |
||||
int parameterCount = 2; |
||||
Assert.AreEqual(1, GetRoundMethods(parameterCount).Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void RoundMethodParameterNameIsNumber() |
||||
{ |
||||
IParameter parameter = GetFirstRoundMethodParameter(); |
||||
Assert.AreEqual("number", parameter.Name); |
||||
} |
||||
|
||||
IParameter GetFirstRoundMethodParameter() |
||||
{ |
||||
int parameterCount = 1; |
||||
List<IMethod> methods = GetRoundMethods(parameterCount); |
||||
IMethod method = methods[0]; |
||||
return method.Parameters[0]; |
||||
} |
||||
|
||||
[Test] |
||||
public void RoundMethodParameterReturnTypeIsDouble() |
||||
{ |
||||
IParameter parameter = GetFirstRoundMethodParameter(); |
||||
Assert.AreEqual("Double", parameter.ReturnType.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void RoundMethodParameterConvertedToStringUsingAmbienceReturnsDoubleNumberString() |
||||
{ |
||||
IAmbience ambience = new CSharpAmbience(); |
||||
string text = ambience.Convert(GetFirstRoundMethodParameter()); |
||||
Assert.AreEqual("double number", text); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveExitMethodFromSysImportExitAsMyExitTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
return new ExpressionResult("myexit", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"from sys import exit as myexit\r\n" + |
||||
"myexit\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsMethodGroupResolveResult() |
||||
{ |
||||
Assert.IsTrue(resolveResult is MethodGroupResolveResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultMethodNameIsExit() |
||||
{ |
||||
Assert.AreEqual("exit", MethodResolveResult.Name); |
||||
} |
||||
|
||||
MethodGroupResolveResult MethodResolveResult { |
||||
get { return (MethodGroupResolveResult)resolveResult; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveExitMethodFromSysImportExitTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
return new ExpressionResult("exit", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"from sys import exit\r\n" + |
||||
"exit\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsMethodGroupResolveResult() |
||||
{ |
||||
Assert.IsTrue(resolveResult is MethodGroupResolveResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultMethodNameIsExit() |
||||
{ |
||||
Assert.AreEqual("exit", MethodResolveResult.Name); |
||||
} |
||||
|
||||
MethodGroupResolveResult MethodResolveResult { |
||||
get { return (MethodGroupResolveResult)resolveResult; } |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultContainingTypeHasTwoExitMethods() |
||||
{ |
||||
List<IMethod> exitMethods = GetExitMethods(); |
||||
Assert.AreEqual(2, exitMethods.Count); |
||||
} |
||||
|
||||
List<IMethod> GetExitMethods() |
||||
{ |
||||
List<IMethod> methods = MethodResolveResult.ContainingType.GetMethods(); |
||||
return PythonCompletionItemsHelper.FindAllMethodsFromCollection("exit", -1, methods.ToArray()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveFromMathImportedMathModuleCompletionItemsTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
List<ICompletionEntry> GetCompletionResults() |
||||
{ |
||||
return resolveResult.GetCompletionData(projectContent); |
||||
} |
||||
|
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
string code = GetPythonScript(); |
||||
PythonExpressionFinder finder = new PythonExpressionFinder(); |
||||
return finder.FindExpression(code, code.Length); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return "from math import"; |
||||
} |
||||
|
||||
[Test] |
||||
public void CompletionResultsContainCosMethodFromMathModule() |
||||
{ |
||||
IMethod method = PythonCompletionItemsHelper.FindMethodFromCollection("cos", GetCompletionResults()); |
||||
Assert.IsNotNull(method); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExpressionResultContextShowItemReturnsTrueForIMethod() |
||||
{ |
||||
MockProjectContent projectContent = new MockProjectContent(); |
||||
DefaultCompilationUnit unit = new DefaultCompilationUnit(projectContent); |
||||
DefaultClass c = new DefaultClass(unit, "MyClass"); |
||||
DefaultMethod method = new DefaultMethod(c, "Test"); |
||||
|
||||
Assert.IsTrue(expressionResult.Context.ShowEntry(method)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveMethodFromUnknownImportAllTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
return new ExpressionResult("methodcall", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"from unknown import *\r\n" + |
||||
"methodcall\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsNull() |
||||
{ |
||||
Assert.IsNull(resolveResult); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveMethodWhenFromImportIsUnknownTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
return new ExpressionResult("methodcall", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"from unknown import methodcall\r\n" + |
||||
"methodcall\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsNull() |
||||
{ |
||||
Assert.IsNull(resolveResult); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveMethodWhenImportIsUnknownTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
return new ExpressionResult("unknown.methodcall", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"from unknown import methodcall\r\n" + |
||||
"unknown.methodcall\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsNull() |
||||
{ |
||||
Assert.IsNull(resolveResult); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveNullCtrlSpaceParseInfoTestFixture |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the resolver handles the parse info being null
|
||||
/// </summary>
|
||||
[Test] |
||||
public void ResolveCtrlSpaceDoesNotThrowExceptionWhenNullParseInfoIsNull() |
||||
{ |
||||
PythonResolver resolver = new PythonResolver(); |
||||
List<ICompletionEntry> results = resolver.CtrlSpace(0, 0, null, "abc", ExpressionContext.Namespace); |
||||
Assert.AreEqual(0, results.Count); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,140 @@
@@ -0,0 +1,140 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveSysModuleExitMethodTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
return new ExpressionResult("sys.exit", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"import sys\r\n" + |
||||
"sys.exit\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsMethodGroupResolveResult() |
||||
{ |
||||
Assert.IsTrue(resolveResult is MethodGroupResolveResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultMethodNameIsExit() |
||||
{ |
||||
Assert.AreEqual("exit", MethodResolveResult.Name); |
||||
} |
||||
|
||||
MethodGroupResolveResult MethodResolveResult { |
||||
get { return (MethodGroupResolveResult)resolveResult; } |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultContainingTypeHasTwoExitMethods() |
||||
{ |
||||
List<IMethod> exitMethods = GetExitMethods(); |
||||
Assert.AreEqual(2, exitMethods.Count); |
||||
} |
||||
|
||||
List<IMethod> GetExitMethods() |
||||
{ |
||||
return GetExitMethods(-1); |
||||
} |
||||
|
||||
List<IMethod> GetExitMethods(int parameterCount) |
||||
{ |
||||
List<IMethod> methods = MethodResolveResult.ContainingType.GetMethods(); |
||||
return PythonCompletionItemsHelper.FindAllMethodsFromCollection("exit", parameterCount, methods.ToArray()); |
||||
} |
||||
|
||||
[Test] |
||||
public void BothExitMethodsArePublic() |
||||
{ |
||||
foreach (IMethod method in GetExitMethods()) { |
||||
Assert.IsTrue(method.IsPublic); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void BothExitMethodsHaveClassWithNameOfSys() |
||||
{ |
||||
foreach (IMethod method in GetExitMethods()) { |
||||
Assert.AreEqual("sys", method.DeclaringType.Name); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void OneExitMethodHasOneParameter() |
||||
{ |
||||
int parameterCount = 1; |
||||
Assert.AreEqual(1, GetExitMethods(parameterCount).Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExitMethodParameterNameIsCode() |
||||
{ |
||||
IParameter parameter = GetFirstExitMethodParameter(); |
||||
Assert.AreEqual("code", parameter.Name); |
||||
} |
||||
|
||||
IParameter GetFirstExitMethodParameter() |
||||
{ |
||||
int parameterCount = 1; |
||||
List<IMethod> methods = GetExitMethods(parameterCount); |
||||
IMethod method = methods[0]; |
||||
return method.Parameters[0]; |
||||
} |
||||
|
||||
[Test] |
||||
public void ExitMethodParameterReturnTypeIsObject() |
||||
{ |
||||
IParameter parameter = GetFirstExitMethodParameter(); |
||||
Assert.AreEqual("Object", parameter.ReturnType.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExitMethodParameterConvertedToStringUsingAmbienceReturnsObjectCodeString() |
||||
{ |
||||
IAmbience ambience = new CSharpAmbience(); |
||||
string text = ambience.Convert(GetFirstExitMethodParameter()); |
||||
Assert.AreEqual("object code", text); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExitMethodReturnTypeConvertedToStringUsingAmbienceReturnsVoid() |
||||
{ |
||||
IAmbience ambience = new CSharpAmbience(); |
||||
List<IMethod> methods = GetExitMethods(); |
||||
IReturnType returnType = methods[0].ReturnType; |
||||
string text = ambience.Convert(returnType); |
||||
Assert.AreEqual("void", text); |
||||
} |
||||
|
||||
[Test] |
||||
public void MethodGroupContainingTypeHasTwoExitMethods() |
||||
{ |
||||
IReturnType returnType = MethodResolveResult.ContainingType; |
||||
List<IMethod> methods = PythonCompletionItemsHelper.FindAllMethodsFromCollection("exit", returnType.GetMethods()); |
||||
Assert.AreEqual(2, methods.Count); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveSysModuleImportedAsMySysTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
return new ExpressionResult("mysys", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"import sys as mysys\r\n" + |
||||
"mysys\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultContainsExitMethod() |
||||
{ |
||||
List<ICompletionEntry> items = GetCompletionItems(); |
||||
IMethod method = PythonCompletionItemsHelper.FindMethodFromCollection("exit", items); |
||||
Assert.IsNotNull(method); |
||||
} |
||||
|
||||
List<ICompletionEntry> GetCompletionItems() |
||||
{ |
||||
return resolveResult.GetCompletionData(projectContent); |
||||
} |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue