コード例 #1
0
		IEnumerable<Variable> FromParameters(MethodDeclaration newMethod)
		{
			if (parentNode is ParametrizedNode) {
				foreach (ParameterDeclarationExpression pde in (parentNode as ParametrizedNode).Parameters) {
					FindReferenceVisitor frv = new FindReferenceVisitor(CSharpNameComparer, pde.ParameterName, newMethod.Body.StartLocation, newMethod.Body.EndLocation);
					
					newMethod.AcceptVisitor(frv, null);
					if (frv.Identifiers.Count > 0) {
						pde.ParamModifier &= ~(ParameterModifiers.Params);
						
						if (parentNode is MethodDeclaration) {
							yield return new Variable((parentNode as MethodDeclaration).Body, pde);
						} else if (parentNode is ConstructorDeclaration) {
							yield return new Variable((parentNode as ConstructorDeclaration).Body, pde);
						} else if (parentNode is PropertyDeclaration) {
							var p = parentNode as PropertyDeclaration;
							yield return new Variable(p.BodyStart, p.BodyEnd, pde);
						} else {
							throw new NotSupportedException("not supported!");
						}
					}
				}
			}
			
			if (parentNode is PropertyDeclaration && IsInSetter(parentNode as PropertyDeclaration)) {
				PropertyDeclaration pd = parentNode as PropertyDeclaration;
				yield return new Variable(
					new LocalLookupVariable(
						"value", pd.TypeReference,
						pd.SetRegion.StartLocation, pd.SetRegion.EndLocation,
						false, false, null, null, false
					)
				);
			}
		}
コード例 #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;
		}
コード例 #3
0
		protected static bool HasOccurrencesAfter(StringComparer nameComparer, AttributedNode member, Location location, string name, Location start, Location end)
		{
			FindReferenceVisitor frv = new FindReferenceVisitor(nameComparer, name, start, end);
			
			member.AcceptVisitor(frv, null);
			
			foreach (IdentifierExpression identifier in frv.Identifiers) {
				if (identifier.StartLocation > location)
					return true;
			}
			
			return false;
		}
コード例 #4
0
		IEnumerable<Variable> FromParameters(MethodDeclaration newMethod)
		{
			foreach (ParameterDeclarationExpression pde in parentNode.Parameters) {
				FindReferenceVisitor frv = new FindReferenceVisitor(CSharpNameComparer, pde.ParameterName, newMethod.Body.StartLocation, newMethod.Body.EndLocation);
				
				newMethod.AcceptVisitor(frv, null);
				if (frv.Identifiers.Count > 0) {
					pde.ParamModifier &= ~(ParameterModifiers.Params);
					
					if (parentNode is MethodDeclaration) {
						yield return new Variable((parentNode as MethodDeclaration).Body, pde);
					} else {
						throw new NotSupportedException("not supported!");
					}
				}
			}
		}
コード例 #5
0
 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;
 }