public void AddProblem(ProblemMetadata problemMetadata) { ArgumentUtility.CheckNotNull ("problemMetadata", problemMetadata); var resolution = GetResolution (problemMetadata.ExpectedFragment, problemMetadata.GivenFragment); var problem = new Problem (resolution, problemMetadata.SourceContext, CheckId); Problems.Add (problem); }
public void AddProblem(ProblemMetadata problemMetadata) { if (!_filteredIds.Contains (problemMetadata.SourceExpressionId)) { _filteredIds.Add (problemMetadata.SourceExpressionId); _problemDestination.AddProblem (problemMetadata); } }
public void AddProblem(ProblemMetadata problemMetadata) { if (!_filteredIds.Contains(problemMetadata.SourceExpressionId)) { _filteredIds.Add(problemMetadata.SourceExpressionId); _problemDestination.AddProblem(problemMetadata); } }
protected PreConditionBase(string symbol, Fragment fragment) { ArgumentUtility.CheckNotNullOrEmpty ("symbol", symbol); ArgumentUtility.CheckNotNull ("fragment", fragment); _symbol = symbol; _fragment = fragment; _problemMetadata = null; }
private void CheckParameter(Expression operand, Fragment expectedFragment) { Fragment operandFragmentType = _symbolTable.InferFragmentType (operand); if (!FragmentUtility.FragmentTypesAssignable (operandFragmentType, expectedFragment)) { ProblemMetadata problemMetadata = new ProblemMetadata (operand.UniqueKey, operand.SourceContext, expectedFragment, operandFragmentType); PassProblem (operand, problemMetadata); } }
public void IsViolated_ViolatingContext_ChangesProblemMetadatasGivenType() { var expectedFragment = Fragment.CreateNamed( "expectedFragment"); var unexpectedFragment = Fragment.CreateNamed( "unexpectedFragment"); ProblemMetadata problemMetaData = new ProblemMetadata(0, new SourceContext(), expectedFragment, Fragment.CreateNamed( "dummy")); IBlacklistManager blackListManager = _mocks.Stub<IBlacklistManager>(); EqualityPreCondition preCondition = new EqualityPreCondition("testSymbol", expectedFragment, problemMetaData); SymbolTable context = new SymbolTable(blackListManager); context.MakeSafe("testSymbol", unexpectedFragment); preCondition.IsViolated(context); Assert.That(problemMetaData.GivenFragment, Is.EqualTo(unexpectedFragment)); }
public void AddProblem_MultipleProblemMetadataObjectsWithDifferentSourceExpressionIds_PassesObjects_() { ProblemMetadata problem1 = new ProblemMetadata(c_sourceExpressionId1, new SourceContext(), Fragment.CreateNamed("dummy"), Fragment.CreateNamed("dummy")); ProblemMetadata problem2 = new ProblemMetadata(c_sourceExpressionId2, new SourceContext(), Fragment.CreateNamed("dummy"), Fragment.CreateNamed("dummy")); using (_mocks.Record()) { _problemDestination.AddProblem (problem1); _problemDestination.AddProblem (problem2); } var problemDuplicateFilter = new ProblemDuplicateFilter (_problemDestination); problemDuplicateFilter.AddProblem (problem1); problemDuplicateFilter.AddProblem (problem2); _mocks.Verify (_problemDestination); }
public void PassProblem( MethodCall methodCall, List<IPreCondition> preConditions, ProblemMetadata problemMetadata, ISymbolTable symbolTable, IProblemPipe problemPipe) { Method calleeMethod = IntrospectionUtility.ExtractMethod (methodCall); if(_coveredMethods.Contains(calleeMethod.FullName)) { foreach (var operand in methodCall.Operands) { string nestedVariableName; if (OperandIsVariableFromPrecedingBlock (operand, symbolTable, out nestedVariableName)) { preConditions.Add (new AssignabilityPreCondition (nestedVariableName, problemMetadata.ExpectedFragment, problemMetadata)); } else { problemPipe.AddProblem (problemMetadata); } } } }
public CustomInferencePreCondition(string symbol, Fragment fragment, ProblemMetadata problemMetadata) : base(symbol, fragment, problemMetadata) { }
private void SetPreConditionForIndexerObject( AssignmentStatement assignmentStatement, string targetName, Fragment sourceFragmentType, HandleContext context) { if (targetName != null) { ProblemMetadata problemMetadata = new ProblemMetadata ( assignmentStatement.UniqueKey, assignmentStatement.SourceContext, sourceFragmentType, Fragment.CreateNamed ("??")); var preCondition = new EqualityPreCondition (targetName, sourceFragmentType, problemMetadata); context.PreConditions.Add (preCondition); } }
public void PassProblem( MethodCall methodCall, List<IPreCondition> preConditions, ProblemMetadata problemMetadata, ISymbolTable symbolTable, IProblemPipe problemPipe) { Method calleeMethod = IntrospectionUtility.ExtractMethod (methodCall); ICustomInference matchingRule = MatchingAnalyzeRule (calleeMethod); if (matchingRule != null) { matchingRule.PassProblem (methodCall, preConditions, problemMetadata, symbolTable, problemPipe); } }
public void Analyze(MethodCall methodCall, ISymbolTable context, List<IPreCondition> preConditions) { Method method = IntrospectionUtility.ExtractMethod (methodCall); if (Analyzes(method) && methodCall.Callee is MemberBinding) { MemberBinding memberBinding = (MemberBinding) methodCall.Callee; if (IsFragmentParameterInferenceMethod (method)) { string variableName; if (IntrospectionUtility.IsVariable (memberBinding.TargetObject, out variableName)) { Fragment parameterFragment = ParameterFragmentUtility.ParameterFragmentIntersection (methodCall, context); Fragment targetObjectFragment = context.GetFragmentType (variableName); if (targetObjectFragment == Fragment.CreateLiteral() || targetObjectFragment.Undefined) { context.MakeSafe (variableName, parameterFragment); } else { if (targetObjectFragment == Fragment.CreateEmpty() && parameterFragment != Fragment.CreateLiteral()) // && parameterFragment != Fragment.CreateEmpty() { ProblemMetadata problemMetadata = new ProblemMetadata(methodCall.UniqueKey, methodCall.SourceContext, parameterFragment, targetObjectFragment); IPreCondition precondition = new CustomInferencePreCondition(variableName, parameterFragment, problemMetadata); preConditions.Add(precondition); } else if (!FragmentUtility.FragmentTypesAssignable(parameterFragment, targetObjectFragment)) { context.MakeUnsafe(variableName); } } } } else if (!IsSafeMethod(method)) { string variableName; if (IntrospectionUtility.IsVariable(memberBinding.TargetObject, out variableName)) { context.MakeUnsafe(variableName); } } } }
public void PassProblem(MethodCall methodCall, List<IPreCondition> preConditions, ProblemMetadata problemMetadata, ISymbolTable symbolTable, IProblemPipe problemPipe) { throw new NotImplementedException(); }
public void SetUp() { _problemMetadata = new ProblemMetadata (0, new SourceContext(), Fragment.CreateEmpty(), Fragment.CreateEmpty()); MockRepository mocks = new MockRepository(); _blacklistManager = mocks.Stub<IBlacklistManager>(); }
public void AddProblem(ProblemMetadata problemMetadata) { _problems.Add (problemMetadata); }
protected PreConditionBase(string symbol, Fragment fragment, ProblemMetadata problemMetadata) : this(symbol, fragment) { _problemMetadata = ArgumentUtility.CheckNotNull ("sourceContext", problemMetadata); }
public EqualityPreCondition(string symbol, Fragment fragment, ProblemMetadata problemMetadata) : base(symbol, fragment, problemMetadata) { }
private void PassProblem(Expression problemSource, ProblemMetadata problemMetadata) { string variableName; Fragment expectedFragment = problemMetadata.ExpectedFragment; if (ExpressionIsVariableFromPrecedingBlock (problemSource, out variableName)) { _preConditions.Add (new AssignabilityPreCondition (variableName, expectedFragment, problemMetadata)); } else if (problemSource is MethodCall) { MethodCall methodCall = (MethodCall) problemSource; Method calleeMethod = IntrospectionUtility.ExtractMethod (methodCall); if (_customInferenceController.Analyzes(calleeMethod)) { _customInferenceController.PassProblem (methodCall, _preConditions, problemMetadata, _symbolTable, _problemPipe); } else { _problemPipe.AddProblem (problemMetadata); } } else { _problemPipe.AddProblem (problemMetadata); } }