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();
                }
            }
        }
コード例 #4
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);
                }
            }
        }
コード例 #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);
                }
            }
        }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
 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);
         }
     }
 }
コード例 #11
0
        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;
                        }
                    }
                }
            }
        }
コード例 #12
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);
         }
     }
 }
コード例 #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);
                        }
                    }
                }
            }
        }
コード例 #14
0
        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;
                        }
                    }
                }
            }
        }
コード例 #15
0
 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;
             }
         }
     }
 }
コード例 #17
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)
 {
     fileModel.All<IQualifiedTypeName>()
              .Where(q => q.IsNamespaceInScope(q.NamespaceName.Namespace))
              .ForEach(q => q.NamespaceName.AddCodeMarker(RemoveFullyQuallifiedTypesMarkerID, this, ConvertToSimpleTypeName, q, q.Type.Name));
 }
コード例 #19
0
 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));
 }
コード例 #20
0
 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));
 }
コード例 #22
0
        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();
                }
            }
        }
コード例 #23
0
 public override void ExecuteCodeCleaningStep(CodeCleaningStep step, FileModel fileModel, CodeSpan span)
 {
     fileModel.All <IPreProcessorDirectiveLine>()
     .Where(line => line.IsRegion())
     .ForEach(region => region.Delete());
 }
コード例 #24
0
 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));
 }