protected override void AddCodeMarkers(FileModel fileModel)
        {
            foreach (IForEachStatement item in fileModel.All<IForEachStatement>().Where(v => v.ExistsTextuallyInFile))
            {
                var lineCheck = item.Text.Trim();

                if (lineCheck.IndexOf("(") != -1)
                {
                    var result = whiteSpaceHelper.CheckNoWhiteSpaceAroundCharacter(lineCheck, "(");

                    if (result == true)
                    {
                        item.AddCodeMarker(WarningId, this, FixSpacingForEach, item);
                    }
                }
            }

            foreach (IForStatement item in fileModel.All<IForStatement>().Where(v => v.ExistsTextuallyInFile))
            {
                var lineCheck = item.Text.Trim();

                if (lineCheck.IndexOf("(") != -1)
                {
                    var result = whiteSpaceHelper.CheckNoWhiteSpaceAroundCharacter(lineCheck, "(");

                    if (result == true)
                    {
                        item.AddCodeMarker(WarningId, this, FixSpacingFor, item);
                    }
                }
            }
        }
Пример #2
0
        protected override void AddCodeMarkers(FileModel fileModel)
        {
            foreach (IForEachStatement item in fileModel.All <IForEachStatement>().Where(v => v.ExistsTextuallyInFile))
            {
                var lineCheck = item.Text.Trim();

                if (lineCheck.IndexOf("(") != -1)
                {
                    var result = whiteSpaceHelper.CheckNoWhiteSpaceAroundCharacter(lineCheck, "(");

                    if (result == true)
                    {
                        item.AddCodeMarker(WarningId, this, FixSpacingForEach, item);
                    }
                }
            }

            foreach (IForStatement item in fileModel.All <IForStatement>().Where(v => v.ExistsTextuallyInFile))
            {
                var lineCheck = item.Text.Trim();

                if (lineCheck.IndexOf("(") != -1)
                {
                    var result = whiteSpaceHelper.CheckNoWhiteSpaceAroundCharacter(lineCheck, "(");

                    if (result == true)
                    {
                        item.AddCodeMarker(WarningId, this, FixSpacingFor, item);
                    }
                }
            }
        }
        private void MoveUsingStatements(FileModel fileModel)
        {
            List <IUsingDirectiveSection> innerSections = new List <IUsingDirectiveSection>();
            IUsingDirectiveSection        mainSection   = null;

            foreach (IUsingDirectiveSection section in fileModel.All <IUsingDirectiveSection>())
            {
                if (section.Enclosing <INamespaceDeclaration>().Exists)
                {
                    innerSections.Add(section);
                }
                else if (mainSection == null)
                {
                    mainSection = section;
                }
            }

            if (mainSection != null)
            {
                foreach (IUsingDirectiveSection section in innerSections)
                {
                    section.Insert(mainSection.Directives, section.FileModel);
                }

                foreach (IUsingDirective directive in mainSection.Directives)
                {
                    directive.Remove();
                }
            }
        }
        protected override void AddCodeMarkers(FileModel fileModel)
        {
            Dictionary<IMemberDeclaration, List<IVariableDeclaration>> variableDeclarations = new Dictionary<IMemberDeclaration, List<IVariableDeclaration>>();

            foreach (IVariableDeclaration variable in fileModel.All<IVariableDeclaration>().Where(v => v.ExistsTextuallyInFile))
            {
                IMemberDeclaration member = variable.EnclosingMember();
                if (member.ExistsTextuallyInFile)
                {
                    if (!variableDeclarations.ContainsKey(member))
                    {
                        variableDeclarations[member] = new List<IVariableDeclaration>();
                    }
                    variableDeclarations[member].Add(variable);
                }
            }

            foreach (KeyValuePair<IMemberDeclaration, List<IVariableDeclaration>> pair in variableDeclarations)
            {
                if (pair.Value.Count > 64)
                {
                    pair.Key.AddCodeMarker(CodeMarkerId, this);
                }
            }
        }
Пример #5
0
        protected override void AddCodeMarkers(FileModel fileModel)
        {
            Dictionary <IMemberDeclaration, List <IVariableDeclaration> > variableDeclarations = new Dictionary <IMemberDeclaration, List <IVariableDeclaration> >();

            foreach (IVariableDeclaration variable in fileModel.All <IVariableDeclaration>().Where(v => v.ExistsTextuallyInFile))
            {
                IMemberDeclaration member = variable.EnclosingMember();
                if (member.ExistsTextuallyInFile)
                {
                    if (!variableDeclarations.ContainsKey(member))
                    {
                        variableDeclarations[member] = new List <IVariableDeclaration>();
                    }
                    variableDeclarations[member].Add(variable);
                }
            }

            foreach (KeyValuePair <IMemberDeclaration, List <IVariableDeclaration> > pair in variableDeclarations)
            {
                if (pair.Value.Count > 64)
                {
                    pair.Key.AddCodeMarker(CodeMarkerId, this);
                }
            }
        }
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     foreach (IAddEventHandlerStatement addEventHandler in fileModel.All <IAddEventHandlerStatement>().Where(x => x.HandlerExpression.Is <IObjectCreation>()))
     {
         IObjectCreation objectCreation = addEventHandler.HandlerExpression.As <IObjectCreation>();
         objectCreation.TypeName.AddCodeMarker(RemoveNewDelegateCreationMarkerID, this, RemoveUnnecessaryObjectCreation, objectCreation);
     }
 }
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     foreach (IAddEventHandlerStatement addEventHandler in fileModel.All<IAddEventHandlerStatement>().Where(x => x.HandlerExpression.Is<IObjectCreation>()))
     {
         IObjectCreation objectCreation = addEventHandler.HandlerExpression.As<IObjectCreation>();
         objectCreation.TypeName.AddCodeMarker(RemoveNewDelegateCreationMarkerID, this, RemoveUnnecessaryObjectCreation, objectCreation);
     }
 }
 /// <summary>
 /// This method is responsible for analyzing a single file and producing warning code markers.
 /// It gets called whenever the file or its dependencies changes so that reanalysis of the code
 /// markers is required
 /// </summary>
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     // you can use fileModel.All<T> to iterate over the construct you are in terested in
     // you might also use LINQ queries
     foreach (IComment comment in fileModel.All <IComment>().Where(v => v.ExistsTextuallyInFile))
     {
         var lineCheck = comment.Text.Trim();
         CheckForSingleComments(lineCheck, comment);
     }
 }
 /// <summary>
 /// This method is responsible for analyzing a single file and producing warning code markers.
 /// It gets called whenever the file or its dependencies changes so that reanalysis of the code 
 /// markers is required
 /// </summary>
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     // you can use fileModel.All<T> to iterate over the construct you are in terested in
     // you might also use LINQ queries
     foreach (IComment comment in fileModel.All<IComment>().Where(v => v.ExistsTextuallyInFile))
     {
         var lineCheck = comment.Text.Trim();
         CheckForSingleComments(lineCheck, comment);
     }
 }
Пример #10
0
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     foreach (var memberDeclaration in fileModel.All <IMemberDeclaration>().Where(m => m.ExistsTextuallyInFile && m.IsPublic() && AreAllEnclosingClassesPublic(m)))
     {
         if (!memberDeclaration.DocComment.Exists)
         {
             memberDeclaration.Identifier.AddCodeMarker(WarningID, this, GenerateDocumentation, memberDeclaration);
         }
     }
 }
        protected override void AddCodeMarkers(FileModel fileModel)
        {
            var needWarning = false;

            foreach (IForEachStatement item in fileModel.All <IForEachStatement>().Where(v => v.ExistsTextuallyInFile))
            {
                List <string> keywordSearch = new List <string> {
                    "in"
                };
                foreach (var key in keywordSearch)
                {
                    if (item.Text.WholeWordIndexOf(key) != -1)
                    {
                        needWarning = this.CheckSpacingAroundKeyword(key, item.Text);
                        if (needWarning == true)
                        {
                            item.AddCodeMarker(WarningId, this, FixSpacingAroundKeywordForeach, item);
                            break;
                        }
                    }
                }
            }

            foreach (IForStatement item in fileModel.All <IForStatement>().Where(v => v.ExistsTextuallyInFile))
            {
                List <string> keywordSearch = new List <string> {
                    "in"
                };

                foreach (var key in keywordSearch)
                {
                    if (item.Text.WholeWordIndexOf(key) != -1)
                    {
                        needWarning = this.CheckSpacingAroundKeyword(key, item.Text);
                        if (needWarning == true)
                        {
                            item.AddCodeMarker(WarningId, this, FixSpacingAroundKeywordFor, item);
                            break;
                        }
                    }
                }
            }
        }
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     foreach (var memberDeclaration in fileModel.All<IMemberDeclaration>().Where(m => m.ExistsTextuallyInFile && m.IsPublic() && AreAllEnclosingClassesPublic(m)))
     {
         if (!memberDeclaration.DocComment.Exists)
         {
             memberDeclaration.Identifier.AddCodeMarker(WarningID, this, GenerateDocumentation, memberDeclaration);
         }
     }
 }
Пример #13
0
        protected override void AddCodeMarkers(FileModel fileModel)
        {
            var needWarning = false;

            // Grabs the first two rows of a list
            foreach (IVariableDeclaration item in fileModel.All <IVariableDeclaration>().Where(v => v.ExistsTextuallyInFile))
            {
                List <string> keywordSearch = new List <string> {
                    "new"
                };
                foreach (var key in keywordSearch)
                {
                    if (item.Text.Contains(key))
                    {
                        needWarning = this.CheckSpacingAroundKeyword(key, item.Text.ToString());
                        if (needWarning == true)
                        {
                            item.AddCodeMarker(WarningId, this, FixSpacingAroundKeywordVarDec, item);
                        }
                    }
                }
            }

            // Grabs everything else
            foreach (IAssignmentExpression item in fileModel.All <IAssignmentExpression>().Where(v => v.ExistsTextuallyInFile))
            {
                List <string> keywordSearch = new List <string> {
                    "new"
                };
                foreach (var key in keywordSearch)
                {
                    if (item.Text.Contains(key))
                    {
                        needWarning = this.CheckSpacingAroundKeyword(key, item.Text.ToString());
                        if (needWarning == true)
                        {
                            item.AddCodeMarker(WarningId, this, FixSpacingAroundKeywordAsExp, item);
                        }
                    }
                }
            }
        }
        protected override void AddCodeMarkers(FileModel fileModel)
        {
            var needWarning = false;

            foreach (IForEachStatement item in fileModel.All<IForEachStatement>().Where(v => v.ExistsTextuallyInFile))
            {
                List<string> keywordSearch = new List<string> { "in" };
                foreach (var key in keywordSearch)
                {
                    if (item.Text.WholeWordIndexOf(key) != -1)
                    {
                        needWarning = this.CheckSpacingAroundKeyword(key, item.Text);
                        if (needWarning == true)
                        {
                            item.AddCodeMarker(WarningId, this, FixSpacingAroundKeywordForeach, item);
                            break;
                        }
                    }
                }
            }

            foreach (IForStatement item in fileModel.All<IForStatement>().Where(v => v.ExistsTextuallyInFile))
            {
                List<string> keywordSearch = new List<string> { "in" };

                foreach (var key in keywordSearch)
                {
                    if (item.Text.WholeWordIndexOf(key) != -1)
                    {
                        needWarning = this.CheckSpacingAroundKeyword(key, item.Text);
                        if (needWarning == true)
                        {
                            item.AddCodeMarker(WarningId, this, FixSpacingAroundKeywordFor, item);
                            break;
                        }
                    }
                }
            }
        }
 public void CheckUsing(FileModel fileModel)
 {
     if (fileModel.FileName != "AssemblyInfo")
     {
         foreach (IUsingDirectiveSection section in fileModel.All<IUsingDirectiveSection>())
         {
             if (!section.Enclosing<INamespaceDeclaration>().Exists && section.Directives.Count() > 0)
             {
                 section.AddCodeMarker(WarningId, this, MoveUsingStatements, fileModel);
                 break;
             }
         }
     }
 }
 public void CheckUsing(FileModel fileModel)
 {
     if (fileModel.FileName != "AssemblyInfo")
     {
         foreach (IUsingDirectiveSection section in fileModel.All <IUsingDirectiveSection>())
         {
             if (!section.Enclosing <INamespaceDeclaration>().Exists&& section.Directives.Count() > 0)
             {
                 section.AddCodeMarker(WarningId, this, MoveUsingStatements, fileModel);
                 break;
             }
         }
     }
 }
        protected override void AddCodeMarkers(FileModel fileModel)
        {
            var needWarning = false;
            // Grabs the first two rows of a list
            foreach (IVariableDeclaration item in fileModel.All<IVariableDeclaration>().Where(v => v.ExistsTextuallyInFile))
            {
                List<string> keywordSearch = new List<string> { "new" };
                foreach (var key in keywordSearch)
                {
                    if (item.Text.Contains(key))
                    {
                        needWarning = this.CheckSpacingAroundKeyword(key, item.Text.ToString());
                        if (needWarning == true)
                        {
                            item.AddCodeMarker(WarningId, this, FixSpacingAroundKeywordVarDec, item);
                        }
                    }
                }
            }

            // Grabs everything else
            foreach (IAssignmentExpression item in fileModel.All<IAssignmentExpression>().Where(v => v.ExistsTextuallyInFile))
            {
                List<string> keywordSearch = new List<string> { "new" };
                foreach (var key in keywordSearch)
                {
                    if (item.Text.Contains(key))
                    {
                        needWarning = this.CheckSpacingAroundKeyword(key, item.Text.ToString());
                        if (needWarning == true)
                        {
                            item.AddCodeMarker(WarningId, this, FixSpacingAroundKeywordAsExp, item);
                        }
                    }
                }
            }
        }
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     fileModel.All<IQualifiedTypeName>()
              .Where(q => q.IsNamespaceInScope(q.NamespaceName.Namespace))
              .ForEach(q => q.NamespaceName.AddCodeMarker(RemoveFullyQuallifiedTypesMarkerID, this, ConvertToSimpleTypeName, q, q.Type.Name));
 }
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     fileModel.All <IStringLiteral>()
     .Where(x => x.Content.Length == 0 && CanBeConvertToStringEmpty(x))
     .ForEach(literal => literal.AddCodeMarker(UseStringEmptyMarkerID, this, ReplaceWithStringEmpty, literal));
 }
 public override void ExecuteCodeCleaningStep(CodeCleaningStep step, FileModel fileModel, CodeSpan span)
 {
     fileModel.All<IPreProcessorDirectiveLine>()
              .Where(line => line.IsRegion())
              .ForEach(region => region.Delete());
 }
Пример #21
0
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     fileModel.All <IQualifiedTypeName>()
     .Where(q => q.IsNamespaceInScope(q.NamespaceName.Namespace))
     .ForEach(q => q.NamespaceName.AddCodeMarker(RemoveFullyQuallifiedTypesMarkerID, this, ConvertToSimpleTypeName, q, q.Type.Name));
 }
        private void MoveUsingStatements(FileModel fileModel)
        {
            List<IUsingDirectiveSection> innerSections = new List<IUsingDirectiveSection>();
            IUsingDirectiveSection mainSection = null;

            foreach (IUsingDirectiveSection section in fileModel.All<IUsingDirectiveSection>())
            {
                if (section.Enclosing<INamespaceDeclaration>().Exists)
                {
                    innerSections.Add(section);
                }
                else if (mainSection == null)
                {
                    mainSection = section;
                }
            }

            if (mainSection != null)
            {
                foreach (IUsingDirectiveSection section in innerSections)
                {
                    section.Insert(mainSection.Directives, section.FileModel);
                }

                foreach (IUsingDirective directive in mainSection.Directives)
                {
                    directive.Remove();
                }
            }
        }
 public override void ExecuteCodeCleaningStep(CodeCleaningStep step, FileModel fileModel, CodeSpan span)
 {
     fileModel.All <IPreProcessorDirectiveLine>()
     .Where(line => line.IsRegion())
     .ForEach(region => region.Delete());
 }
 protected override void AddCodeMarkers(FileModel fileModel)
 {
     fileModel.All<IStringLiteral>()
              .Where(x => x.Content.Length == 0 && CanBeConvertToStringEmpty(x))
              .ForEach(literal => literal.AddCodeMarker(UseStringEmptyMarkerID, this, ReplaceWithStringEmpty, literal));
 }