Exemple #1
0
        /// <summary>
        /// Process clean-up on file.
        /// </summary>
        /// <param name="projectFile">
        /// The project file to process.
        /// </param>
        /// <param name="rangeMarker">
        /// The range marker to process.
        /// </param>
        /// <param name="profile">
        /// The code cleanup settings to use.
        /// </param>
        /// <param name="progressIndicator">
        /// The progress indicator.
        /// </param>
        public void Process(
            IPsiSourceFile projectFile, IRangeMarker rangeMarker, CodeCleanupProfile profile, JB::JetBrains.Application.Progress.IProgressIndicator progressIndicator)
        {
            if (projectFile == null)
            {
                return;
            }

            if (!this.IsAvailable(projectFile))
            {
                return;
            }

            ISolution solution = projectFile.GetSolution();

            ICSharpFile file = projectFile.GetNonInjectedPsiFile <CSharpLanguage>() as ICSharpFile;

            if (file == null)
            {
                return;
            }

            PsiManager.GetInstance(solution).DoTransaction(() => this.InternalProcess(profile, file), "Code cleanup");

            StyleCopTrace.Out();
        }
    public void Process(IPsiSourceFile sourceFile, IRangeMarker rangeMarker, CodeCleanupProfile profile, IProgressIndicator progressIndicator)
    {
      var file = sourceFile.GetNonInjectedPsiFile<CSharpLanguage>();
      if (file == null)
        return;

      if (!profile.GetSetting(DescriptorInstance))
        return;

      CSharpElementFactory elementFactory = CSharpElementFactory.GetInstance(sourceFile.PsiModule);
      
      file.GetPsiServices().PsiManager.DoTransaction(
        () =>
          {
            using (_shellLocks.UsingWriteLock())
              file.ProcessChildren<IExpression>(
                expression =>
                  {
                    ConstantValue value = expression.ConstantValue;
                    if (value.IsInteger() && Convert.ToInt32(value.Value) == int.MaxValue)
                      ModificationUtil.ReplaceChild(expression, elementFactory.CreateExpression("int.MaxValue"));
                  }
                );
          },
        "Code cleanup");
    }
        public void Process(IPsiSourceFile sourceFile, IRangeMarker rangeMarker, CodeCleanupProfile profile, IProgressIndicator progressIndicator)
        {
            var file = sourceFile.GetNonInjectedPsiFile <CSharpLanguage>();

            if (file == null)
            {
                return;
            }

            if (!profile.GetSetting(DescriptorInstance))
            {
                return;
            }

            CSharpElementFactory elementFactory = CSharpElementFactory.GetInstance(sourceFile.PsiModule);

            file.GetPsiServices().PsiManager.DoTransaction(
                () =>
            {
                using (_shellLocks.UsingWriteLock())
                    file.ProcessChildren <IExpression>(
                        expression =>
                    {
                        ConstantValue value = expression.ConstantValue;
                        if (value.IsInteger() && Convert.ToInt32(value.Value) == int.MaxValue)
                        {
                            ModificationUtil.ReplaceChild(expression, elementFactory.CreateExpression("int.MaxValue"));
                        }
                    }
                        );
            },
                "Code cleanup");
        }
        /// <summary>
        /// Process clean-up on file.
        /// </summary>
        /// <param name="projectFile">
        /// The project file to process.
        /// </param>
        /// <param name="rangeMarker">
        /// The range marker to process.
        /// </param>
        /// <param name="profile">
        /// The code cleanup settings to use.
        /// </param>
        /// <param name="progressIndicator">
        /// The progress indicator.
        /// </param>
        public void Process(
            IPsiSourceFile projectFile, IRangeMarker rangeMarker, CodeCleanupProfile profile, JB::JetBrains.Application.Progress.IProgressIndicator progressIndicator)
        {
            if (projectFile == null)
            {
                return;
            }

            if (!this.IsAvailable(projectFile))
            {
                return;
            }

            ISolution solution = projectFile.GetSolution();

            ICSharpFile file = projectFile.GetNonInjectedPsiFile<CSharpLanguage>() as ICSharpFile;

            if (file == null)
            {
                return;
            }

            PsiManager.GetInstance(solution).DoTransaction(() => this.InternalProcess(profile, file), "Code cleanup");

            StyleCopTrace.Out();
        }
 /// <summary>
 /// Check if this module can handle given project file.
 /// </summary>
 /// <param name="projectFile">
 /// The project file to check.
 /// </param>
 /// <returns>
 /// <c>True.</c>if the project file is available; otherwise 
 /// <c>False.</c>.
 /// </returns>
 public bool IsAvailable(IPsiSourceFile projectFile)
 {
     return projectFile.GetNonInjectedPsiFile<CSharpLanguage>() != null;
 }
Exemple #6
0
 /// <summary>
 /// Check if this module can handle given project file.
 /// </summary>
 /// <param name="projectFile">
 /// The project file to check.
 /// </param>
 /// <returns>
 /// <c>True.</c>if the project file is available; otherwise
 /// <c>False.</c>.
 /// </returns>
 public bool IsAvailable(IPsiSourceFile projectFile)
 {
     return(projectFile.GetNonInjectedPsiFile <CSharpLanguage>() != null);
 }