|
|
|
@ -21,12 +21,12 @@ using System.CodeDom; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.IO; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
using ICSharpCode.NRefactory.CSharp.Refactoring; |
|
|
|
using ICSharpCode.NRefactory.CSharp.Resolver; |
|
|
|
using ICSharpCode.NRefactory.CSharp.Resolver; |
|
|
|
using ICSharpCode.NRefactory.CSharp.TypeSystem; |
|
|
|
using ICSharpCode.NRefactory.CSharp.TypeSystem; |
|
|
|
using ICSharpCode.NRefactory.PatternMatching; |
|
|
|
using ICSharpCode.NRefactory.PatternMatching; |
|
|
|
using ICSharpCode.NRefactory.Semantics; |
|
|
|
using ICSharpCode.NRefactory.Semantics; |
|
|
|
using ICSharpCode.NRefactory.TypeSystem; |
|
|
|
using ICSharpCode.NRefactory.TypeSystem; |
|
|
|
using ICSharpCode.NRefactory.TypeSystem.Implementation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.NRefactory.CSharp |
|
|
|
namespace ICSharpCode.NRefactory.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -40,14 +40,23 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
//ICompilation compilation = MinimalResolveContext.Instance;
|
|
|
|
//ICompilation compilation = MinimalResolveContext.Instance;
|
|
|
|
CSharpAstResolver resolver; |
|
|
|
CSharpAstResolver resolver; |
|
|
|
bool useFullyQualifiedTypeNames; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets/Sets whether the visitor should use fully-qualified type references.
|
|
|
|
/// Gets/Sets whether the visitor should use fully-qualified type references.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public bool UseFullyQualifiedTypeNames { |
|
|
|
public bool UseFullyQualifiedTypeNames { get; set; } |
|
|
|
get { return useFullyQualifiedTypeNames; } |
|
|
|
|
|
|
|
set { useFullyQualifiedTypeNames = value; } |
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Gets whether the visitor is allowed to produce snippet nodes for
|
|
|
|
|
|
|
|
/// code that cannot be converted.
|
|
|
|
|
|
|
|
/// The default is true. If this property is set to false,
|
|
|
|
|
|
|
|
/// unconvertible code will throw a NotSupportedException.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public bool AllowSnippetNodes { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CodeDomConvertVisitor() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this.AllowSnippetNodes = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
@ -136,7 +145,15 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
|
|
|
|
|
|
|
|
CodeTypeReference Convert(IType type) |
|
|
|
CodeTypeReference Convert(IType type) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new CodeTypeReference(type.ReflectionName); |
|
|
|
if (type.Kind == TypeKind.Array) { |
|
|
|
|
|
|
|
ArrayType a = (ArrayType)type; |
|
|
|
|
|
|
|
return new CodeTypeReference(Convert(a.ElementType), a.Dimensions); |
|
|
|
|
|
|
|
} else if (type is ParameterizedType) { |
|
|
|
|
|
|
|
var pt = (ParameterizedType)type; |
|
|
|
|
|
|
|
return new CodeTypeReference(pt.GetDefinition().ReflectionName, pt.TypeArguments.Select(Convert).ToArray()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return new CodeTypeReference(type.ReflectionName); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CodeStatement Convert(Statement stmt) |
|
|
|
CodeStatement Convert(Statement stmt) |
|
|
|
@ -148,6 +165,8 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
List<CodeStatement> result = new List<CodeStatement>(); |
|
|
|
List<CodeStatement> result = new List<CodeStatement>(); |
|
|
|
foreach (Statement stmt in block.Statements) { |
|
|
|
foreach (Statement stmt in block.Statements) { |
|
|
|
|
|
|
|
if (stmt is EmptyStatement) |
|
|
|
|
|
|
|
continue; |
|
|
|
CodeStatement s = Convert(stmt); |
|
|
|
CodeStatement s = Convert(stmt); |
|
|
|
if (s != null) |
|
|
|
if (s != null) |
|
|
|
result.Add(s); |
|
|
|
result.Add(s); |
|
|
|
@ -160,6 +179,8 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
BlockStatement block = embeddedStatement as BlockStatement; |
|
|
|
BlockStatement block = embeddedStatement as BlockStatement; |
|
|
|
if (block != null) { |
|
|
|
if (block != null) { |
|
|
|
return ConvertBlock(block); |
|
|
|
return ConvertBlock(block); |
|
|
|
|
|
|
|
} else if (embeddedStatement is EmptyStatement) { |
|
|
|
|
|
|
|
return new CodeStatement[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
CodeStatement s = Convert(embeddedStatement); |
|
|
|
CodeStatement s = Convert(embeddedStatement); |
|
|
|
if (s != null) |
|
|
|
if (s != null) |
|
|
|
@ -170,6 +191,8 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
|
|
|
|
|
|
|
|
string MakeSnippet(AstNode node) |
|
|
|
string MakeSnippet(AstNode node) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!AllowSnippetNodes) |
|
|
|
|
|
|
|
throw new NotSupportedException(); |
|
|
|
StringWriter w = new StringWriter(); |
|
|
|
StringWriter w = new StringWriter(); |
|
|
|
CSharpOutputVisitor v = new CSharpOutputVisitor(w, FormattingOptionsFactory.CreateMono ()); |
|
|
|
CSharpOutputVisitor v = new CSharpOutputVisitor(w, FormattingOptionsFactory.CreateMono ()); |
|
|
|
node.AcceptVisitor(v); |
|
|
|
node.AcceptVisitor(v); |
|
|
|
@ -371,7 +394,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
TypeResolveResult trr = rr as TypeResolveResult; |
|
|
|
TypeResolveResult trr = rr as TypeResolveResult; |
|
|
|
if (trr != null) { |
|
|
|
if (trr != null) { |
|
|
|
CodeTypeReference typeRef; |
|
|
|
CodeTypeReference typeRef; |
|
|
|
if (useFullyQualifiedTypeNames) { |
|
|
|
if (UseFullyQualifiedTypeNames) { |
|
|
|
typeRef = Convert(trr.Type); |
|
|
|
typeRef = Convert(trr.Type); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
typeRef = new CodeTypeReference(identifierExpression.Identifier); |
|
|
|
typeRef = new CodeTypeReference(identifierExpression.Identifier); |
|
|
|
@ -380,7 +403,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
return new CodeTypeReferenceExpression(typeRef); |
|
|
|
return new CodeTypeReferenceExpression(typeRef); |
|
|
|
} |
|
|
|
} |
|
|
|
MethodGroupResolveResult mgrr = rr as MethodGroupResolveResult; |
|
|
|
MethodGroupResolveResult mgrr = rr as MethodGroupResolveResult; |
|
|
|
if (mgrr != null) { |
|
|
|
if (mgrr != null || identifierExpression.TypeArguments.Any()) { |
|
|
|
return new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), identifierExpression.Identifier, Convert(identifierExpression.TypeArguments)); |
|
|
|
return new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), identifierExpression.Identifier, Convert(identifierExpression.TypeArguments)); |
|
|
|
} |
|
|
|
} |
|
|
|
return new CodeVariableReferenceExpression(identifierExpression.Identifier); |
|
|
|
return new CodeVariableReferenceExpression(identifierExpression.Identifier); |
|
|
|
@ -658,7 +681,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CodeTypeDelegate d = new CodeTypeDelegate(delegateDeclaration.Name); |
|
|
|
CodeTypeDelegate d = new CodeTypeDelegate(delegateDeclaration.Name); |
|
|
|
d.Attributes = ConvertMemberAttributes(delegateDeclaration.Modifiers); |
|
|
|
d.Attributes = ConvertMemberAttributes(delegateDeclaration.Modifiers, EntityType.TypeDefinition); |
|
|
|
d.CustomAttributes.AddRange(Convert(delegateDeclaration.Attributes)); |
|
|
|
d.CustomAttributes.AddRange(Convert(delegateDeclaration.Attributes)); |
|
|
|
d.ReturnType = Convert(delegateDeclaration.ReturnType); |
|
|
|
d.ReturnType = Convert(delegateDeclaration.ReturnType); |
|
|
|
d.Parameters.AddRange(Convert(delegateDeclaration.Parameters)); |
|
|
|
d.Parameters.AddRange(Convert(delegateDeclaration.Parameters)); |
|
|
|
@ -666,13 +689,15 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
return d; |
|
|
|
return d; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static MemberAttributes ConvertMemberAttributes(Modifiers modifiers) |
|
|
|
MemberAttributes ConvertMemberAttributes(Modifiers modifiers, EntityType entityType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MemberAttributes a = 0; |
|
|
|
MemberAttributes a = 0; |
|
|
|
if ((modifiers & Modifiers.Abstract) != 0) |
|
|
|
if ((modifiers & Modifiers.Abstract) != 0) |
|
|
|
a |= MemberAttributes.Abstract; |
|
|
|
a |= MemberAttributes.Abstract; |
|
|
|
if ((modifiers & Modifiers.Sealed) != 0) |
|
|
|
if ((modifiers & Modifiers.Sealed) != 0) |
|
|
|
a |= MemberAttributes.Final; |
|
|
|
a |= MemberAttributes.Final; |
|
|
|
|
|
|
|
if (entityType != EntityType.TypeDefinition && (modifiers & (Modifiers.Abstract | Modifiers.Override | Modifiers.Virtual)) == 0) |
|
|
|
|
|
|
|
a |= MemberAttributes.Final; |
|
|
|
if ((modifiers & Modifiers.Static) != 0) |
|
|
|
if ((modifiers & Modifiers.Static) != 0) |
|
|
|
a |= MemberAttributes.Static; |
|
|
|
a |= MemberAttributes.Static; |
|
|
|
if ((modifiers & Modifiers.Override) != 0) |
|
|
|
if ((modifiers & Modifiers.Override) != 0) |
|
|
|
@ -719,7 +744,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
//bool isNestedType = typeStack.Count > 0;
|
|
|
|
//bool isNestedType = typeStack.Count > 0;
|
|
|
|
CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(typeDeclaration.Name); |
|
|
|
CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(typeDeclaration.Name); |
|
|
|
typeDecl.Attributes = ConvertMemberAttributes(typeDeclaration.Modifiers); |
|
|
|
typeDecl.Attributes = ConvertMemberAttributes(typeDeclaration.Modifiers, EntityType.TypeDefinition); |
|
|
|
typeDecl.CustomAttributes.AddRange(Convert(typeDeclaration.Attributes)); |
|
|
|
typeDecl.CustomAttributes.AddRange(Convert(typeDeclaration.Attributes)); |
|
|
|
|
|
|
|
|
|
|
|
switch (typeDeclaration.ClassType) { |
|
|
|
switch (typeDeclaration.ClassType) { |
|
|
|
@ -809,7 +834,12 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
|
|
|
|
|
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitEmptyStatement(EmptyStatement emptyStatement) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitEmptyStatement(EmptyStatement emptyStatement) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return null; |
|
|
|
return EmptyStatement(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CodeStatement EmptyStatement() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return new CodeExpressionStatement(new CodeObjectCreateExpression(new CodeTypeReference(typeof(object)))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitExpressionStatement(ExpressionStatement expressionStatement) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitExpressionStatement(ExpressionStatement expressionStatement) |
|
|
|
@ -817,10 +847,55 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
AssignmentExpression assignment = expressionStatement.Expression as AssignmentExpression; |
|
|
|
AssignmentExpression assignment = expressionStatement.Expression as AssignmentExpression; |
|
|
|
if (assignment != null && assignment.Operator == AssignmentOperatorType.Assign) { |
|
|
|
if (assignment != null && assignment.Operator == AssignmentOperatorType.Assign) { |
|
|
|
return new CodeAssignStatement(Convert(assignment.Left), Convert(assignment.Right)); |
|
|
|
return new CodeAssignStatement(Convert(assignment.Left), Convert(assignment.Right)); |
|
|
|
|
|
|
|
} else if (assignment != null && CanBeDuplicatedForCompoundAssignment(assignment.Left)) { |
|
|
|
|
|
|
|
CodeBinaryOperatorType op; |
|
|
|
|
|
|
|
switch (assignment.Operator) { |
|
|
|
|
|
|
|
case AssignmentOperatorType.Add: |
|
|
|
|
|
|
|
op = CodeBinaryOperatorType.Add; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case AssignmentOperatorType.Subtract: |
|
|
|
|
|
|
|
op = CodeBinaryOperatorType.Subtract; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case AssignmentOperatorType.Multiply: |
|
|
|
|
|
|
|
op = CodeBinaryOperatorType.Multiply; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case AssignmentOperatorType.Divide: |
|
|
|
|
|
|
|
op = CodeBinaryOperatorType.Divide; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case AssignmentOperatorType.Modulus: |
|
|
|
|
|
|
|
op = CodeBinaryOperatorType.Modulus; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case AssignmentOperatorType.BitwiseAnd: |
|
|
|
|
|
|
|
op = CodeBinaryOperatorType.BitwiseAnd; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case AssignmentOperatorType.BitwiseOr: |
|
|
|
|
|
|
|
op = CodeBinaryOperatorType.BitwiseOr; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return MakeSnippetStatement(expressionStatement); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var cboe = new CodeBinaryOperatorExpression(Convert(assignment.Left), op, Convert(assignment.Right)); |
|
|
|
|
|
|
|
return new CodeAssignStatement(Convert(assignment.Left), cboe); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
UnaryOperatorExpression unary = expressionStatement.Expression as UnaryOperatorExpression; |
|
|
|
|
|
|
|
if (unary != null && CanBeDuplicatedForCompoundAssignment(unary.Expression)) { |
|
|
|
|
|
|
|
var op = unary.Operator; |
|
|
|
|
|
|
|
if (op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement) { |
|
|
|
|
|
|
|
var cboe = new CodeBinaryOperatorExpression(Convert(unary.Expression), CodeBinaryOperatorType.Add, new CodePrimitiveExpression(1)); |
|
|
|
|
|
|
|
return new CodeAssignStatement(Convert(unary.Expression), cboe); |
|
|
|
|
|
|
|
} else if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement) { |
|
|
|
|
|
|
|
var cboe = new CodeBinaryOperatorExpression(Convert(unary.Expression), CodeBinaryOperatorType.Subtract, new CodePrimitiveExpression(1)); |
|
|
|
|
|
|
|
return new CodeAssignStatement(Convert(unary.Expression), cboe); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return new CodeExpressionStatement(Convert(expressionStatement.Expression)); |
|
|
|
return new CodeExpressionStatement(Convert(expressionStatement.Expression)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CanBeDuplicatedForCompoundAssignment(Expression expr) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return expr is IdentifierExpression; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitFixedStatement(FixedStatement fixedStatement) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitFixedStatement(FixedStatement fixedStatement) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return MakeSnippetStatement(fixedStatement); |
|
|
|
return MakeSnippetStatement(fixedStatement); |
|
|
|
@ -956,7 +1031,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
|
|
|
|
|
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitWhileStatement(WhileStatement whileStatement) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitWhileStatement(WhileStatement whileStatement) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new CodeIterationStatement(null, Convert(whileStatement.Condition), null, ConvertEmbeddedStatement(whileStatement.EmbeddedStatement)); |
|
|
|
return new CodeIterationStatement(EmptyStatement(), Convert(whileStatement.Condition), EmptyStatement(), ConvertEmbeddedStatement(whileStatement.EmbeddedStatement)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement) |
|
|
|
@ -977,7 +1052,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CodeConstructor ctor = new CodeConstructor(); |
|
|
|
CodeConstructor ctor = new CodeConstructor(); |
|
|
|
ctor.Attributes = ConvertMemberAttributes(constructorDeclaration.Modifiers); |
|
|
|
ctor.Attributes = ConvertMemberAttributes(constructorDeclaration.Modifiers, EntityType.Constructor); |
|
|
|
ctor.CustomAttributes.AddRange(Convert(constructorDeclaration.Attributes)); |
|
|
|
ctor.CustomAttributes.AddRange(Convert(constructorDeclaration.Attributes)); |
|
|
|
if (constructorDeclaration.Initializer.ConstructorInitializerType == ConstructorInitializerType.This) { |
|
|
|
if (constructorDeclaration.Initializer.ConstructorInitializerType == ConstructorInitializerType.This) { |
|
|
|
ctor.ChainedConstructorArgs.AddRange(Convert(constructorDeclaration.Initializer.Arguments)); |
|
|
|
ctor.ChainedConstructorArgs.AddRange(Convert(constructorDeclaration.Initializer.Arguments)); |
|
|
|
@ -1019,7 +1094,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CodeMemberEvent e = new CodeMemberEvent(); |
|
|
|
CodeMemberEvent e = new CodeMemberEvent(); |
|
|
|
e.Attributes = ConvertMemberAttributes(eventDeclaration.Modifiers); |
|
|
|
e.Attributes = ConvertMemberAttributes(eventDeclaration.Modifiers, EntityType.Event); |
|
|
|
e.CustomAttributes.AddRange(Convert(eventDeclaration.Attributes)); |
|
|
|
e.CustomAttributes.AddRange(Convert(eventDeclaration.Attributes)); |
|
|
|
e.Name = vi.Name; |
|
|
|
e.Name = vi.Name; |
|
|
|
e.Type = Convert(eventDeclaration.ReturnType); |
|
|
|
e.Type = Convert(eventDeclaration.ReturnType); |
|
|
|
@ -1037,7 +1112,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (VariableInitializer vi in fieldDeclaration.Variables) { |
|
|
|
foreach (VariableInitializer vi in fieldDeclaration.Variables) { |
|
|
|
CodeMemberField f = new CodeMemberField(Convert(fieldDeclaration.ReturnType), vi.Name); |
|
|
|
CodeMemberField f = new CodeMemberField(Convert(fieldDeclaration.ReturnType), vi.Name); |
|
|
|
f.Attributes = ConvertMemberAttributes(fieldDeclaration.Modifiers); |
|
|
|
f.Attributes = ConvertMemberAttributes(fieldDeclaration.Modifiers, EntityType.Field); |
|
|
|
f.CustomAttributes.AddRange(Convert(fieldDeclaration.Attributes)); |
|
|
|
f.CustomAttributes.AddRange(Convert(fieldDeclaration.Attributes)); |
|
|
|
f.InitExpression = ConvertVariableInitializer(vi.Initializer, fieldDeclaration.ReturnType); |
|
|
|
f.InitExpression = ConvertVariableInitializer(vi.Initializer, fieldDeclaration.ReturnType); |
|
|
|
AddTypeMember(f); |
|
|
|
AddTypeMember(f); |
|
|
|
@ -1048,7 +1123,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CodeMemberProperty p = new CodeMemberProperty(); |
|
|
|
CodeMemberProperty p = new CodeMemberProperty(); |
|
|
|
p.Attributes = ConvertMemberAttributes(indexerDeclaration.Modifiers); |
|
|
|
p.Attributes = ConvertMemberAttributes(indexerDeclaration.Modifiers, EntityType.Indexer); |
|
|
|
p.CustomAttributes.AddRange(Convert(indexerDeclaration.Attributes)); |
|
|
|
p.CustomAttributes.AddRange(Convert(indexerDeclaration.Attributes)); |
|
|
|
p.Name = "Items"; |
|
|
|
p.Name = "Items"; |
|
|
|
p.PrivateImplementationType = Convert(indexerDeclaration.PrivateImplementationType); |
|
|
|
p.PrivateImplementationType = Convert(indexerDeclaration.PrivateImplementationType); |
|
|
|
@ -1069,7 +1144,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitMethodDeclaration(MethodDeclaration methodDeclaration) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitMethodDeclaration(MethodDeclaration methodDeclaration) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CodeMemberMethod m = new CodeMemberMethod(); |
|
|
|
CodeMemberMethod m = new CodeMemberMethod(); |
|
|
|
m.Attributes = ConvertMemberAttributes(methodDeclaration.Modifiers); |
|
|
|
m.Attributes = ConvertMemberAttributes(methodDeclaration.Modifiers, EntityType.Method); |
|
|
|
|
|
|
|
|
|
|
|
m.CustomAttributes.AddRange(Convert(methodDeclaration.Attributes.Where(a => a.AttributeTarget != "return"))); |
|
|
|
m.CustomAttributes.AddRange(Convert(methodDeclaration.Attributes.Where(a => a.AttributeTarget != "return"))); |
|
|
|
m.ReturnTypeCustomAttributes.AddRange(Convert(methodDeclaration.Attributes.Where(a => a.AttributeTarget == "return"))); |
|
|
|
m.ReturnTypeCustomAttributes.AddRange(Convert(methodDeclaration.Attributes.Where(a => a.AttributeTarget == "return"))); |
|
|
|
@ -1087,7 +1162,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CodeMemberMethod m = new CodeMemberMethod(); |
|
|
|
CodeMemberMethod m = new CodeMemberMethod(); |
|
|
|
m.Attributes = ConvertMemberAttributes(operatorDeclaration.Modifiers); |
|
|
|
m.Attributes = ConvertMemberAttributes(operatorDeclaration.Modifiers, EntityType.Method); |
|
|
|
|
|
|
|
|
|
|
|
m.CustomAttributes.AddRange(Convert(operatorDeclaration.Attributes.Where(a => a.AttributeTarget != "return"))); |
|
|
|
m.CustomAttributes.AddRange(Convert(operatorDeclaration.Attributes.Where(a => a.AttributeTarget != "return"))); |
|
|
|
m.ReturnTypeCustomAttributes.AddRange(Convert(operatorDeclaration.Attributes.Where(a => a.AttributeTarget == "return"))); |
|
|
|
m.ReturnTypeCustomAttributes.AddRange(Convert(operatorDeclaration.Attributes.Where(a => a.AttributeTarget == "return"))); |
|
|
|
@ -1129,7 +1204,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CodeMemberProperty p = new CodeMemberProperty(); |
|
|
|
CodeMemberProperty p = new CodeMemberProperty(); |
|
|
|
p.Attributes = ConvertMemberAttributes(propertyDeclaration.Modifiers); |
|
|
|
p.Attributes = ConvertMemberAttributes(propertyDeclaration.Modifiers, EntityType.Property); |
|
|
|
p.CustomAttributes.AddRange(Convert(propertyDeclaration.Attributes)); |
|
|
|
p.CustomAttributes.AddRange(Convert(propertyDeclaration.Attributes)); |
|
|
|
p.Name = propertyDeclaration.Name; |
|
|
|
p.Name = propertyDeclaration.Name; |
|
|
|
p.PrivateImplementationType = Convert(propertyDeclaration.PrivateImplementationType); |
|
|
|
p.PrivateImplementationType = Convert(propertyDeclaration.PrivateImplementationType); |
|
|
|
@ -1181,7 +1256,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
|
|
|
|
|
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitSimpleType(SimpleType simpleType) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitSimpleType(SimpleType simpleType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (useFullyQualifiedTypeNames) { |
|
|
|
if (UseFullyQualifiedTypeNames) { |
|
|
|
IType type = Resolve(simpleType).Type; |
|
|
|
IType type = Resolve(simpleType).Type; |
|
|
|
if (type.Kind != TypeKind.Unknown) |
|
|
|
if (type.Kind != TypeKind.Unknown) |
|
|
|
return Convert(type); |
|
|
|
return Convert(type); |
|
|
|
@ -1198,7 +1273,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
tr.TypeArguments.AddRange(Convert(memberType.TypeArguments)); |
|
|
|
tr.TypeArguments.AddRange(Convert(memberType.TypeArguments)); |
|
|
|
return tr; |
|
|
|
return tr; |
|
|
|
} |
|
|
|
} |
|
|
|
if (useFullyQualifiedTypeNames || memberType.IsDoubleColon) { |
|
|
|
if (UseFullyQualifiedTypeNames || memberType.IsDoubleColon) { |
|
|
|
IType type = Resolve(memberType).Type; |
|
|
|
IType type = Resolve(memberType).Type; |
|
|
|
if (type.Kind != TypeKind.Unknown) |
|
|
|
if (type.Kind != TypeKind.Unknown) |
|
|
|
return Convert(type); |
|
|
|
return Convert(type); |
|
|
|
@ -1309,7 +1384,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitPatternPlaceholder(AstNode placeholder, ICSharpCode.NRefactory.PatternMatching.Pattern pattern) |
|
|
|
CodeObject IAstVisitor<CodeObject>.VisitPatternPlaceholder(AstNode placeholder, Pattern pattern) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|