public NRefactory.CSharp.ParameterDeclaration[] GetParametersForProperty(NRefactory.CSharp.PropertyDeclaration property) { var propInfo = property.Annotation<PropertyReference>(); if (propInfo == null) return new NRefactory.CSharp.ParameterDeclaration[0]; return propInfo.Parameters.Select(p => new NRefactory.CSharp.ParameterDeclaration(AstBuilder.ConvertType(p.ParameterType), p.Name, GetModifiers(p))).ToArray(); }
private void BuildCatchClauses(NRefactory.AstNodeCollection<NRefactory.CatchClause> catchClauses) { Handlers = catchClauses.Select(@catch => { var catchClause = @catch.AcceptVisitor(Visitor, this) as CatchClause; Expression body = catchClause.Reduce(); Type type = @catch.Type.AcceptVisitor(Visitor, this).Type; if (catchClause.ExceptionVariable != null) { return Expression.Catch(catchClause.ExceptionVariable, body); } return Expression.Catch(type, body); }); }
public IType ResolveType(NRefactory.VB.Ast.AstType type, NRefactory.VB.Ast.TypeDeclaration entity = null) { var annotation = type.Annotation<TypeReference>(); if (annotation == null ) return null; IEntity current = null; if (entity != null) { var typeInfo = entity.Annotation<TypeReference>(); current = loader.ReadTypeReference(typeInfo).Resolve(context).GetDefinition(); } return loader.ReadTypeReference(annotation, entity: current).Resolve(context); }
public CSharpFile(NRefactory.CSharpProject project, string fileName, string sourceCode) { _project = project; FileName = fileName; var parser = new CSharpParser(project.CompilerSettings); // Keep the original text around; we might use it for a refactoring later OriginalText = sourceCode; SyntaxTree = parser.Parse(OriginalText, fileName); _errors = parser.HasErrors ? parser.ErrorsAndWarnings : new List<Error>(0); UnresolvedTypeSystemForFile = SyntaxTree.ToTypeSystem(); }
public TypeKind GetTypeKindForAstType(NRefactory.CSharp.AstType type) { var annotation = type.Annotation<TypeReference>(); if (annotation == null) return TypeKind.Unknown; var definition = annotation.ResolveOrThrow(); if (definition.IsClass) return TypeKind.Class; if (definition.IsInterface) return TypeKind.Interface; if (definition.IsEnum) return TypeKind.Enum; if (definition.IsFunctionPointer) return TypeKind.Delegate; if (definition.IsValueType) return TypeKind.Struct; return TypeKind.Unknown; }
public bool HasEvent(NRefactory.VB.Ast.Expression expression) { return expression.Annotation<EventDef>() != null; }
public SolutionExtender(NRefactory.Solution solution) { Ensure.ArgumentNotNull(solution, "solution"); Solution = solution; }
public void RemoveProject(NRefactory.CSharpProject project) { if (null == project) return; throw new NotImplementedException(); }
public void RemoveCSharpFileFromProject(NRefactory.CSharpProject project, string codeAbsoluteFilePath) { Ensure.ArgumentNotNull(project, "project"); for (var i = 0; i < project.Files.Count; i++) if (PathExt.PathsAreEqual(project.Files[i].FileName, codeAbsoluteFilePath)) project.Files.RemoveAt(i); }
//readonly CecilLoader loader = new CecilLoader(); public string GetTypeNameForAttribute(NRefactory.CSharp.Attribute attribute) { return attribute.Type.Annotations .OfType<Mono.Cecil.MemberReference>() .First() .FullName; }
public TypeCode ResolveExpression(NRefactory.CSharp.Expression expression) { var annotation = expression.Annotations.OfType<TypeInformation>().FirstOrDefault(); if (annotation == null || annotation.InferredType == null) return TypeCode.Object; var definition = annotation.InferredType.Resolve(); if (definition == null) return TypeCode.Object; switch (definition.FullName) { case "System.String": return TypeCode.String; default: break; } return TypeCode.Object; }
public bool? IsReferenceType(NRefactory.CSharp.Expression expression) { if (expression is NRefactory.CSharp.NullReferenceExpression) return true; var annotation = expression.Annotations.OfType<TypeInformation>().FirstOrDefault(); if (annotation == null || annotation.InferredType == null) return null; var definition = annotation.InferredType.Resolve(); if (definition == null) return null; return !definition.IsValueType; }
public bool IsMethodGroup(NRefactory.CSharp.Expression expression) { var methodInfo = expression.Annotation<MethodReference>()?.Resolve(); if (methodInfo != null) { return !methodInfo.IsGetter && !methodInfo.IsSetter && !methodInfo.IsAddOn && !methodInfo.IsRemoveOn; } return false; }
public SolutionManager(NRefactory.Solution solution, IVisualStudioEventProxy visualStudioEvents) : this(new SolutionExtender(solution), visualStudioEvents) { }