Ejemplo n.º 1
0
		Variable ResolveVariable(Variable variable)
		{
			Dom.ParseInformation info = ParserService.GetParseInformation(this.textEditor.FileName);
			Dom.ExpressionResult res = new Dom.ExpressionResult(variable.Name,
			                                                    Dom.DomRegion.FromLocation(variable.StartPos, variable.EndPos),
			                                                    Dom.ExpressionContext.Default, null);
			Dom.ResolveResult result = this.GetResolver().Resolve(res, info, this.textEditor.Document.Text);
			
			Dom.IReturnType type = currentProjectContent.SystemTypes.Object;
			Dom.ClassFinder finder = new Dom.ClassFinder(currentClass, textEditor.Caret.Line, textEditor.Caret.Column);
			
			if (result != null && result.ResolvedType != null)
				type = result.ResolvedType;
			
			if (variable.Type.Type == "var")
				variable.Type = Dom.Refactoring.CodeGenerator.ConvertType(type, finder);
			
			variable.IsReferenceType = type.IsReferenceType == true;
			
			return variable;
		}
Ejemplo n.º 2
0
		bool HasReferencesInSelection(MethodDeclaration newMethod, Variable variable)
		{
			FindReferenceVisitor frv = new FindReferenceVisitor(CSharpNameComparer, variable.Name,
			                                                    newMethod.Body.StartLocation, newMethod.Body.EndLocation);
			
			newMethod.AcceptVisitor(frv, null);
			return frv.Identifiers.Count > 0;
		}
Ejemplo n.º 3
0
		protected static bool HasAssignment(MethodDeclaration method, Variable variable)
		{
			HasAssignmentsVisitor hav = new HasAssignmentsVisitor(variable.Name, variable.Type, variable.StartPos, variable.EndPos);
			
			method.AcceptVisitor(hav, null);
			
			return hav.HasAssignment;
		}
		Variable ResolveVariable(Variable variable)
		{
			Dom.ParseInformation info = ParserService.GetParseInformation(this.textEditor.FileName);
			Dom.ExpressionResult res = new Dom.ExpressionResult(variable.Name,
			                                                    Dom.DomRegion.FromLocation(variable.StartPos, variable.EndPos),
			                                                    Dom.ExpressionContext.Default, null);
			Dom.ResolveResult result = this.GetResolver().Resolve(res, info, this.textEditor.Document.TextContent);

			if (variable.Type.Type == "var")
				variable.Type = Dom.Refactoring.CodeGenerator.ConvertType(result.ResolvedType, new Dom.ClassFinder(result.CallingMember));

			variable.IsReferenceType = result.ResolvedType.IsReferenceType == true;
			
			return variable;
		}
 private bool HasReferencesInSelection(ISelection selection, Variable variable)
 {
     FindReferenceVisitor frv = new FindReferenceVisitor(CSharpNameComparer, variable.Name, selection.StartPosition, selection.EndPosition);
     var statement = new BlockStatement();
     statement.Children = selection.Nodes;
     statement.AcceptVisitor(frv, null);
     return frv.Identifiers.Count > 0;
 }