/// <summary>
        /// This method provides a <see cref="IDaemonStageProcess"/> instance which is assigned to highlighting a single document.
        /// </summary>
        protected override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind, ICSharpFile file)
        {
            if (process == null)
                throw new ArgumentNullException("process");

            return new CloneDetectionDaemonStageProcess(process);
        }
        /// <summary>
        /// This method provides a <see cref="IDaemonStageProcess"/> instance which is assigned to highlighting a single document
        /// </summary>
        public IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind kind)
        {
            if (process == null)
            throw new ArgumentNullException("process");

              return new InjectionHappyDetectorDaemonStageProcess(process, settings.GetValue((InjectionHappyDetectorSettings s) => s.MaximumParameters));
        }
        public IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            if (process == null)
                throw new ArgumentNullException("process");

            return new MakeEnumComparisonTypeSafeDaemonStageProcess(process);
        }
        /// <summary>
        /// This method provides a <see cref="IDaemonStageProcess"/> instance which is assigned to highlighting a single document
        /// </summary>
        public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind kind)
        {
            if (process == null)
                throw new ArgumentNullException("process");

            return new List<IDaemonStageProcess> { new ComplexityAnalysisDaemonStageProcess(process, 0) };
        }
예제 #5
0
	    /// <summary>
	    /// Creates a code analysis process corresponding to this stage for analysing a file.
	    /// </summary>
	    /// <returns>Code analysis process to be executed or <c>null</c> if this stage is not available for this file.</returns>
	    public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind) {
		    var t4File = process.SourceFile.GetTheOnlyPsiFile(T4Language.Instance) as IT4File;
			if (t4File == null)
				return EmptyList<IDaemonStageProcess>.InstanceList;

		    return new[] { CreateProcess(process, t4File) };
	    }
예제 #6
0
        public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            IFile psiFile = process.SourceFile.GetNonInjectedPsiFile(JavaScriptLanguage.Instance);
            if (psiFile == null)
                yield return null;

            yield return new DaemonStageProcess(process);
        }
    public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
    {
      IFile psiFile = process.SourceFile.GetNonInjectedPsiFile<CSharpLanguage>();
      if (psiFile == null)
        return Enumerable.Empty<IDaemonStageProcess>();

      return new [] { new UseInt16MaxValueLiteralDaemonProcess(process) };
    }
 public override IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
 {
   if (!IsSupported(process.SourceFile))
   {
     return EmptyList<IDaemonStageProcess>.InstanceList;
   }
   return new List<IDaemonStageProcess> { new IdentifierHighlighterProcess(process, settings) };
 }
        public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            IFile psiFile = process.SourceFile.GetTheOnlyPsiFile(RazorCSharpLanguage.Instance);
            if (psiFile == null)
                return Enumerable.Empty<IDaemonStageProcess>();

            return new[] { new UseOfSemicolonLiteralInRazorSyntaxDaemonProcess(process) };
        }
        public IDaemonStageProcess CreateProcess(IDaemonProcess process, DaemonProcessKind processKind)
#endif
        {
#if RESHARPER_70
            return new[] { new AnnotationDaemonStageProcess(process) };
#else
            return new AnnotationDaemonStageProcess(process);
#endif
        }
 protected override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
     DaemonProcessKind processKind, ICSharpFile file)
 {
     if (processKind == DaemonProcessKind.VISIBLE_DOCUMENT &&
         settings.GetValue(HighlightingSettingsAccessor.ColorUsageHighlightingEnabled))
     {
         return new UnityColorHighlighterProcess(process, settings, file);
     }
     return null;
 }
        public override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            if (!IsSupported(process.SourceFile))
                return null;

            var collectUsagesStageProcess = process.GetStageProcess<CollectUsagesStageProcess>();
            var typeUsageManager = new TypeUsageManager(collectUsagesStageProcess);

            return new ContainerRegistrationAnalysisStageProcess(process, settings, typeUsageManager, solutionAnalyzer);
        }
        public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            if (!IsSupported(process.SourceFile))
                return Enumerable.Empty<IDaemonStageProcess>();

            process.SourceFile.GetPsiServices().Files.AssertAllDocumentAreCommitted();

            return process.SourceFile.GetPsiFiles<AngularJsLanguage>()
                .SelectNotNull(file => CreateProcess(process, settings, processKind, (IJavaScriptFile)file));
        }
        public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            if (process == null)
                throw new ArgumentNullException("process");

            return new[]
               {
                 new MockMetricsDaemonStageProcess(process, settings.GetValue((MockMetricsSettings s) => s.ArrangeAmount))
               };
        }
        public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            if (process == null)
                throw new ArgumentNullException("process");

            return new[]
               {
                 new FakeDaemonStageProcess(process)
               };
        }
예제 #16
0
    public override IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
    {
      if (!IsSupported(process.SourceFile))
        return EmptyList<IDaemonStageProcess>.InstanceList;

      var factory = myServices.TryGetService<IPsiInspectionsProcessFactory>(process.SourceFile.LanguageType);
      if (factory == null)
        return EmptyList<IDaemonStageProcess>.InstanceList;

      return new List<IDaemonStageProcess> { factory.CreateInspectionsProcess(process, settings) };
    }
 public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process,
     IContextBoundSettingsStore settings, DaemonProcessKind processKind)
 {
     if (process == null)
         throw new ArgumentNullException("process");
     return new[]
     {
         new DisposableFunctionDaemonStageProcess(process,
             settings.GetValue((DisposePluginSettings s) => s.MaxLevel))
     };
 }
    /// <summary>
    /// This method provides a <see cref="IDaemonStageProcess"/> instance which is assigned to highlighting a single document
    /// </summary>
    public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind kind)
    {
      if (process == null)
        throw new ArgumentNullException("process");

      return new[]
               {
                 new ComplexityAnalysisDaemonStageProcess(
                   process, settings.GetValue((ComplexityAnalysisSettings s) => s.Threshold))
               };
    }
예제 #19
0
        protected override IDaemonStageProcess CreateProcess(
        IDaemonProcess process,
        IContextBoundSettingsStore settings,
        DaemonProcessKind processKind,
        ICSharpFile file)
        {
            var testFile = file.ToTestFile();
              if (testFile == null)
            return null;

              return new TestFileDaemonStageProcess(process, testFile, _testFileAnalyzers);
        }
        /// <summary>
        /// Invoked by ReSharper each time it wants us to perform some background processing
        /// of a file.
        /// </summary>
        /// <param name="process">Provides information about and services relating to the
        /// work we are being asked to do.</param>
        /// <param name="settings">Settings information.</param>
        /// <param name="processKind">The kind of processing we're being asked to do.</param>
        /// <param name="file">The file to be processed.</param>
        /// <returns>A process object representing the work, or null if no work will be done.</returns>
        protected override IDaemonStageProcess CreateProcess(
            IDaemonProcess process,
            IContextBoundSettingsStore settings,
            DaemonProcessKind processKind,
            ICSharpFile file)
        {
            if (process == null)
            {
                throw new ArgumentNullException("process");
            }

            // StyleCop's daemon stage looks for a processKind of DaemonProcessKind.OTHER
            // and does nothing (returns null) if it sees it. This turns out to prevent
            // highlights from showing up when you ask ReSharper to inspect code issues
            // across the whole solution. I'm not sure why StyleCop deliberately opts out
            // of it. Perhaps something goes horribly wrong, but I've not seen any sign
            // of that yet, and we really do want solution-wide inspection to work.

            try
            {
                // I guess the base class checks that this is actually a C# file?
                if (!IsSupported(process.SourceFile))
                {
                    return null;
                }

                // StyleCop checks to see if there are already any errors in the file, and if
                // there are, it decides to do nothing.
                // TODO: Do we need to do that?

                // TODO: We should probably check for exemptions, e.g. generated source files.
            }
            catch (ProcessCancelledException)
            {
                return null;
            }

            // TODO: should we get an injected ISettingsOptimization?
            var orderUsingSettings =
                settings.GetKey<OrderUsingsSettings>(SettingsOptimization.DoMeSlowly);

            OrderUsingsConfiguration config = null;
            if (!string.IsNullOrWhiteSpace(orderUsingSettings.OrderSpecificationXml))
            {
                config = ConfigurationSerializer.FromXml(new StringReader(orderUsingSettings.OrderSpecificationXml));
            }

            return new OrderUsingsDaemonStageProcess(process, file, config);
        }
        private IDaemonStageProcess DoCreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            if (!IsSupported(process.SourceFile))
            {
                return null;
            }

            if (processKind != DaemonProcessKind.VISIBLE_DOCUMENT)
            {
                return null;
            }

            var collectUsagesStageProcess = process.GetStageProcess<CollectUsagesStageProcess>();
            var typeUsageManager = new TypeUsageManager(collectUsagesStageProcess);

            return new ContainerRegistrationAnalysisStageProcess(process, settings, typeUsageManager, patternManager);
        }
        protected override IDaemonStageProcess CreateProcess(
            IDaemonProcess process, IContextBoundSettingsStore settings,
            DaemonProcessKind processKind, ICSharpFile file)
        {
            if (IsSupported(process.SourceFile) == false)
            {
                return(null);
            }

            var exceptionalSettings = settings.GetKey <ExceptionalSettings>(SettingsOptimization.OptimizeDefault);

            exceptionalSettings.InvalidateCaches();

            ServiceLocator.Process      = process;
            ServiceLocator.Settings     = exceptionalSettings;
            ServiceLocator.StageProcess = new ExceptionalDaemonStageProcess(file, settings);

            return(ServiceLocator.StageProcess);
        }
예제 #23
0
        protected override void AddHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element, string text, string tooltip,
                                                DaemonProcessKind kind)
        {
            var iconId = element.HasHotIcon(CallGraphSwaExtensionProvider, Settings, MarksProvider, kind, myProvider)
                ? InsightUnityIcons.InsightHot.Id
                : InsightUnityIcons.InsightUnity.Id;

            if (RiderIconProviderUtil.IsCodeVisionEnabled(Settings, myCodeInsightProvider.ProviderId,
                                                          () => { base.AddHighlighting(consumer, element, text, tooltip, kind); }, out var useFallback))
            {
                if (!useFallback)
                {
                    consumer.AddImplicitConfigurableHighlighting(element);
                }

                IconModel iconModel = myIconHost.Transform(iconId);
                if (myAssetIndexingSupport.IsEnabled.Value && myAssetSerializationMode.IsForceText)
                {
                    if (myDeferredCacheController.IsProcessingFiles())
                    {
                        iconModel = myIconHost.Transform(CodeInsightsThemedIcons.InsightWait.Id);
                    }

                    if (!myDeferredCacheController.CompletedOnce.Value)
                    {
                        tooltip = "Usages in assets are not available during asset indexing";
                    }
                }

                if (!myAssetIndexingSupport.IsEnabled.Value || !myDeferredCacheController.CompletedOnce.Value || !myAssetSerializationMode.IsForceText)
                {
                    myCodeInsightProvider.AddHighlighting(consumer, element, element.DeclaredElement, text,
                                                          tooltip, text, iconModel, GetActions(element),
                                                          RiderIconProviderUtil.GetExtraActions(mySolutionTracker, myConnectionTracker));
                }
                else
                {
                    var count = myAssetMethodsElementContainer.GetAssetUsagesCount(element.DeclaredElement, out var estimate);
                    myUsagesCodeVisionProvider.AddHighlighting(consumer, element, element.DeclaredElement, count,
                                                               "Click to view usages in assets", "Assets usages", estimate, iconModel);
                }
            }
        }
예제 #24
0
        protected override void AddHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element, string text, string tooltip,
                                                DaemonProcessKind kind)
        {
            var iconId = element.HasHotIcon(Swa, CallGraphSwaExtensionProvider, Settings, Analyzer, kind)
                ? InsightUnityIcons.InsightHot.Id
                : InsightUnityIcons.InsightUnity.Id;

            if (RiderIconProviderUtil.IsCodeVisionEnabled(Settings, myFieldUsageProvider.ProviderId,
                                                          () => { base.AddHighlighting(consumer, element, text, tooltip, kind); }, out var useFallback))
            {
                if (!useFallback)
                {
                    consumer.AddImplicitConfigurableHighlighting(element);
                }
                myFieldUsageProvider.AddHighlighting(consumer, element, element.DeclaredElement, text,
                                                     tooltip, text, myIconHost.Transform(iconId), GetActions(element),
                                                     RiderIconProviderUtil.GetExtraActions(mySolutionTracker, myConnectionTracker));
            }
        }
        public IEnumerable <IDaemonStageProcess> CreateProcess(
            IDaemonProcess process,
            IContextBoundSettingsStore settings,
            DaemonProcessKind processKind
            )
        {
            if (processKind != DaemonProcessKind.SOLUTION_ANALYSIS && processKind != DaemonProcessKind.VISIBLE_DOCUMENT)
            {
                return(Enumerable.Empty <IDaemonStageProcess>());
            }

            if (!_specflowStepsDefinitionsCache.AllStepsPerFiles.ContainsKey(process.SourceFile))
            {
                return(Enumerable.Empty <IDaemonStageProcess>());
            }

            return(process.SourceFile.GetPsiFiles <CSharpLanguage>()
                   .SelectNotNull(file => new MethodNameMismatchPatternHighlightingDaemonStageProcess(process, (ICSharpFile)file, _stepDefinitionBuilder)));
        }
        protected override IDaemonStageProcess CreateProcess(IDaemonProcess process,
                                                             IContextBoundSettingsStore settings,
                                                             DaemonProcessKind processKind, ICSharpFile file)
        {
            if (!file.GetProject().IsUnityProject())
            {
                return(null);
            }

            var isPerformanceAnalysisEnabled =
                settings.GetValue((UnitySettings s) => s.EnablePerformanceCriticalCodeHighlighting);
            var isBurstAnalysisEnabled = settings.GetValue((UnitySettings s) => s.EnableBurstCodeHighlighting);


            return(new UnityHighlightingProcess(process, file, myCallGraphSwaExtensionProvider,
                                                myPerformanceCriticalCodeCallGraphMarksProvider, isPerformanceAnalysisEnabled,
                                                myCallGraphBurstMarksProvider, isBurstAnalysisEnabled,
                                                HiglightingProviders, PerformanceProblemAnalyzers,
                                                API, myCommonIconProvider, processKind, myProvider, Logger));
        }
        public IEnumerable <IDaemonStageProcess> CreateProcess(
            IDaemonProcess process,
            IContextBoundSettingsStore settings,
            DaemonProcessKind processKind
            )
        {
            if (processKind != DaemonProcessKind.SOLUTION_ANALYSIS && processKind != DaemonProcessKind.VISIBLE_DOCUMENT)
            {
                return(Enumerable.Empty <IDaemonStageProcess>());
            }

            var gherkinFile = process.SourceFile.GetPsiFile <GherkinLanguage>(process.Document.GetDocumentRange());

            if (gherkinFile == null)
            {
                return(Enumerable.Empty <IDaemonStageProcess>());
            }

            return(new[] { new ParameterHighlightingDaemonStageProcess(process, (GherkinFile)gherkinFile) });
        }
        public static void AddHotHighlighting(this IHighlightingConsumer consumer,
                                              PerformanceCriticalContextProvider contextProvider,
                                              ICSharpDeclaration element,
                                              IContextBoundSettingsStore settings, string text,
                                              string tooltip, DaemonProcessKind kind, IEnumerable <BulbMenuItem> items,
                                              bool onlyHot = false)
        {
            var isIconHot = element.HasHotIcon(contextProvider, settings, kind);

            if (onlyHot && !isIconHot)
            {
                return;
            }

            var highlighting = isIconHot
                ? new UnityHotGutterMarkInfo(items, element, tooltip)
                : (IHighlighting) new UnityGutterMarkInfo(items, element, tooltip);

            consumer.AddHighlighting(highlighting);
        }
예제 #29
0
        public IEnumerable <IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
                                                               DaemonProcessKind processKind)
        {
            var services = process.SourceFile.GetPsiServices();

            services.Files.AssertAllDocumentAreCommitted();
            var languageManager = services.LanguageManager;
            var files           = process.SourceFile.GetPsiFiles <ShaderLabLanguage>();
            var processes       = new List <IDaemonStageProcess>();

            foreach (var file in files)
            {
                var manager = languageManager.TryGetService <ShaderLabSyntaxHighlightingManager>(file.Language);
                if (manager != null)
                {
                    processes.Add(manager.CreateProcess(process, settings, file));
                }
            }
            return(processes);
        }
        public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            Handler.Init();
            if (processKind != DaemonProcessKind.VISIBLE_DOCUMENT ||
                !IsSupported(process.SourceFile))
            {
                return EmptyList<IDaemonStageProcess>.InstanceList;
            }

            var document = process.Document;
            if (!documentToProcess.ContainsKey(document))
            {
                var highlightingProcess = new HighlightingProcess(process, settings);
                documentToProcess.Add(process.Document, highlightingProcess);
            }
            else
            {
                documentToProcess[document].Update(process, settings);
            }

            return new List<IDaemonStageProcess> { documentToProcess[document] };
        }
        public static bool IsNodeMarked(
            [CanBeNull] this ICallGraphContextProvider provider, 
            [CanBeNull] ITreeNode treeNode,
            DaemonProcessKind processKind)
        {
            if (provider == null)
                return false;

            var mark = false;
            
            switch (treeNode)
            {
                case ICSharpExpression expression:
                    mark = provider.IsCalleeMarked(expression, processKind);
                    break;
                case IDeclaration declaration:
                    mark = provider.HasContext(declaration, processKind);
                    break;
            }

            return mark;
        }
        public override bool HasContext(IDeclaration declaration, DaemonProcessKind processKind)
        {
            if (IsContextAvailable == false)
            {
                return(false);
            }

            if (declaration == null || IsBurstProhibitedNode(declaration))
            {
                return(false);
            }

            var functionDeclaration = declaration as IFunctionDeclaration;

            if (UnityCallGraphUtil.HasAnalysisComment(functionDeclaration,
                                                      BurstMarksProvider.MarkId, ReSharperControlConstruct.Kind.Restore))
            {
                return(true);
            }

            return(base.HasContext(declaration, processKind));
        }
예제 #33
0
        protected override void AddMonoBehaviourHighlighting(IHighlightingConsumer consumer, IClassLikeDeclaration declaration, string text,
                                                             string tooltip, DaemonProcessKind kind)
        {
            if (RiderIconProviderUtil.IsCodeVisionEnabled(SettingsStore.BoundSettingsStore, myCodeInsightProvider.ProviderId,
                                                          () => { base.AddHighlighting(consumer, declaration, text, tooltip, kind); }, out var useFallback))
            {
                if (!useFallback)
                {
                    consumer.AddImplicitConfigurableHighlighting(declaration);
                }

                IconModel iconModel = myIconHost.Transform(InsightUnityIcons.InsightUnity.Id);
                if (myAssetIndexingSupport.IsEnabled.Value && myAssetSerializationMode.IsForceText)
                {
                    if (myDeferredCacheController.IsProcessingFiles())
                    {
                        iconModel = myIconHost.Transform(CodeInsightsThemedIcons.InsightWait.Id);
                    }

                    if (!myDeferredCacheController.CompletedOnce.Value)
                    {
                        tooltip = "Usages in assets are not available during asset indexing";
                    }
                }

                if (!myAssetIndexingSupport.IsEnabled.Value || !myDeferredCacheController.CompletedOnce.Value || !myAssetSerializationMode.IsForceText)
                {
                    myCodeInsightProvider.AddHighlighting(consumer, declaration, declaration.DeclaredElement, text,
                                                          tooltip, text, iconModel, GetActions(declaration),
                                                          RiderIconProviderUtil.GetExtraActions(mySolutionTracker, myBackendUnityHost));
                }
                else
                {
                    var count = myAssetScriptUsagesElementContainer.GetUsagesCount(declaration, out var estimatedResult);
                    myUsagesCodeVisionProvider.AddHighlighting(consumer, declaration, declaration.DeclaredElement, count,
                                                               "Click to view usages in assets", "Assets usages", estimatedResult, iconModel);
                }
            }
        }
        protected override void AddMonoBehaviourHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element,
                                                             string text,
                                                             string tooltip, DaemonProcessKind kind)
        {
            if (!myAssetSerializationMode.IsForceText ||
                !Settings.GetValue((UnitySettings key) => key.EnableInspectorPropertiesEditor))
            {
                AddHighlighting(consumer, element, text, tooltip, kind);
                return;
            }

            if (RiderIconProviderUtil.IsCodeVisionEnabled(Settings, myFieldUsageProvider.ProviderId,
                                                          () => { base.AddHighlighting(consumer, element, text, tooltip, kind); }, out var useFallback))
            {
                if (!useFallback)
                {
                    consumer.AddImplicitConfigurableHighlighting(element);
                }
                myFieldUsageProvider.AddInspectorHighlighting(consumer, element, element.DeclaredElement, text,
                                                              tooltip, text, myIconHost.Transform(InsightUnityIcons.InsightUnity.Id), GetActions(element),
                                                              RiderIconProviderUtil.GetExtraActions(mySolutionTracker, myConnectionTracker));
            }
        }
예제 #35
0
        public IEnumerable<IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            process.Solution.GetPsiServices().DependencyStore.AddDependency(MvcSpecificFileImageContributor.Dependency);

            IProjectFile projectFile = process.SourceFile.ToProjectFile();
            if (projectFile == null)
            {
                return Enumerable.Empty<IDaemonStageProcess>();
            }

            if (!projectFile.IsProjectReferencingNancy())
            {
                return Enumerable.Empty<IDaemonStageProcess>();
            }

            return new[]
            {
                new NancyDaemonStageProcess(searchDomainFactory,
                                            process,
                                            process.GetStageProcess<CollectUsagesStageProcess>(),
                                            settings)
            };
        }
예제 #36
0
        public virtual void AddHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element, string tooltip,
                                            string displayName, DaemonProcessKind kind, bool addOnlyHotIcon = false)
        {
            var mode = SettingsStore.GetValue((UnitySettings key) => key.GutterIconMode);

            if (mode == GutterIconMode.None)
            {
                return;
            }

            var isIconHot = IsHotIcon(element, kind);

            if (addOnlyHotIcon && !isIconHot)
            {
                return;
            }

            var highlighting = isIconHot
                ? new UnityHotGutterMarkInfo(element, tooltip)
                : (IHighlighting) new UnityGutterMarkInfo(element, tooltip);

            consumer.AddHighlighting(highlighting);
        }
예제 #37
0
        public override bool AddDeclarationHighlighting(IDeclaration treeNode, IHighlightingConsumer consumer,
                                                        DaemonProcessKind kind)
        {
            var declaredElement = treeNode.DeclaredElement;
            var method          = declaredElement as IMethod;

            if (method is IAccessor)
            {
                return(false);
            }

            if (declaredElement is IProperty property)
            {
                method = property.Setter;
            }

            if (method != null && myAssetMethodsElementContainer.GetAssetUsagesCount(method, out _) > 0)
            {
                AddHighlighting(consumer, treeNode as ICSharpDeclaration, "Event handler", "Unity event handler", kind);
                return(true);
            }

            return(false);
        }
예제 #38
0
        public void AdvanceContext([NotNull] ITreeNode node, DaemonProcessKind processKind, [NotNull] IEnumerable <ICallGraphContextProvider> providers)
        {
            var newContext   = CallGraphContextElement.NONE;
            var context      = myStack.Peek().Context;
            var shouldChange = false;

            foreach (var provider in providers)
            {
                if (provider.IsContextChangingNode(node))
                {
                    newContext  |= provider.GetNodeContext(node, processKind);
                    shouldChange = true;
                }
                else if (context.HasFlag(provider.Context))
                {
                    newContext |= provider.Context;
                }
            }

            if (shouldChange)
            {
                myStack.Push(new BoundContextElement(newContext, node));
            }
        }
예제 #39
0
        public override IDeclaredElement Analyze(IDeclaration treeNode, IHighlightingConsumer consumer,
                                                 DaemonProcessKind kind)
        {
            var declaredElement = treeNode.DeclaredElement;
            var method          = declaredElement as IMethod;

            if (method is IAccessor)
            {
                return(null);
            }

            if (declaredElement is IProperty property)
            {
                method = property.Setter;
            }

            if (method != null && mySceneDataCache.IsEventHandler(method))
            {
                AddHighlighting(consumer, treeNode as ICSharpDeclaration, "Event handler", "Unity event handler", kind);
                return(declaredElement);
            }

            return(null);
        }
        public virtual bool IsMarked(IDeclaredElement declaredElement, DaemonProcessKind processKind)
        {
            if (IsContextAvailable == false)
            {
                return(false);
            }

            var isGlobalStage = processKind == DaemonProcessKind.GLOBAL_WARNINGS;

            if (!isGlobalStage)
            {
                return(false);
            }

            var id = myElementIdProvider.GetElementId(declaredElement);

            if (!id.HasValue)
            {
                return(false);
            }

            return(myCallGraphSwaExtensionProvider.IsMarkedByCallGraphRootMarksProvider(
                       myMarksProviderBase.Id, isGlobalStage: true, id.Value));
        }
        public IEnumerable <IDaemonStageProcess> CreateProcess(IDaemonProcess daemonProcess,
                                                               IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            if (!IsSupported(daemonProcess.SourceFile, processKind))
            {
                return(EmptyList <IDaemonStageProcess> .InstanceList);
            }

            if (!(daemonProcess.SourceFile.GetPrimaryPsiFile() is IFSharpFile fsFile))
            {
                return(EmptyList <IDaemonStageProcess> .Instance);
            }

            var process = CreateStageProcess(fsFile, settings, daemonProcess);

            return(process != null
        ? new[] { process }
        : EmptyList <IDaemonStageProcess> .InstanceList);
        }
예제 #42
0
 protected override IDaemonStageProcess CreateDaemonProcess(IDaemonProcess process, DaemonProcessKind processKind, SpringFile file,
                                                            IContextBoundSettingsStore settingsStore)
 {
     return(new SpringDaemonProcess(process, file));
 }
 public override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind, IVBFile file)
 {
     return new UseIsNotOperatorDaemonStageProcess(process, settings, file);
 }
예제 #44
0
 public IEnumerable <IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
 {
     if (process.SourceFile.Name.ToLower().EndsWith(".resx"))
     {
         yield return(new ResXProcess(process, settings, process.SourceFile));
     }
 }
예제 #45
0
 protected abstract IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
                                                      DaemonProcessKind processKind, IJavaScriptFile file);
 protected abstract IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
     DaemonProcessKind processKind, IJavaScriptFile file);
예제 #47
0
 protected override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind, ICSharpFile file)
 {
     return(new T4CSharpErrorProcess(process, settings, file));
 }
예제 #48
0
        public override IEnumerable <IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            if (!IsSupported(process.SourceFile))
            {
                return(EmptyList <IDaemonStageProcess> .InstanceList);
            }

            var factory = myServices.TryGetService <IPsiInspectionsProcessFactory>(process.SourceFile.LanguageType);

            if (factory == null)
            {
                return(EmptyList <IDaemonStageProcess> .InstanceList);
            }

            return(new List <IDaemonStageProcess> {
                factory.CreateInspectionsProcess(process, settings)
            });
        }
 protected virtual IDaemonStageProcess GetProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
                                                  DaemonProcessKind processKind, ICSharpFile file)
 {
     return(new PerformanceCriticalCodeAnalysisProcess(process, file, CallGraphSwaExtension, Swa, Tracker, PerformanceAnalyzer, ExpensiveAnalyzer));
 }
예제 #50
0
        public override bool AddDeclarationHighlighting(IDeclaration node, IHighlightingConsumer consumer, DaemonProcessKind kind)
        {
            if (!(node is IClassLikeDeclaration element))
            {
                return(false);
            }

            var typeElement = element.DeclaredElement;

            if (typeElement != null)
            {
                if (typeElement.DerivesFromMonoBehaviour())
                {
                    AddMonoBehaviourHiglighting(consumer, element, "Script", "Unity script", kind);
                }
                else if (typeElement.DerivesFrom(KnownTypes.Editor) || typeElement.DerivesFrom(KnownTypes.EditorWindow))
                {
                    AddEditorHiglighting(consumer, element, "Editor", "Custom Unity Editor", kind);
                }
                else if (typeElement.DerivesFromScriptableObject())
                {
                    AddMonoBehaviourHiglighting(consumer, element, "Scriptable object", "Scriptable Object", kind);
                }
                else if (myUnityApi.IsUnityType(typeElement))
                {
                    AddUnityTypeHighlighting(consumer, element, "Unity type", "Custom Unity type", kind);
                }
                else if (myUnityApi.IsUnityECSType(typeElement))
                {
                    AddUnityECSHighlighting(consumer, element, "Unity ECS", "Unity entity component system object",
                                            kind);
                }

                return(true);
            }

            return(false);
        }
 public AngularJsIdentifierHighlighterProcess(ResolveHighlighterRegistrar resolveHighlighterRegistrar, IDaemonProcess daemonProcess,
     IContextBoundSettingsStore settingsStore, IJavaScriptFile file, DaemonProcessKind processKind)
     : base(resolveHighlighterRegistrar, daemonProcess, settingsStore, file, processKind)
 {
 }
예제 #52
0
        /// <summary>
        /// This method provides a <see cref="IDaemonStageProcess"/> instance which is assigned to highlighting a single document.
        /// </summary>
        /// <param name="process">
        /// Current Daemon Process.
        /// </param>
        /// <param name="settingsStore">
        /// The settingsStore store to use.
        /// </param>
        /// <param name="processKind">
        /// The process kind.
        /// </param>
        /// <param name="file">
        /// The file to analyze.
        /// </param>
        /// /// 
        /// <returns>
        /// The current <see cref="IDaemonStageProcess"/>.
        /// </returns>
        protected override IDaemonStageProcess CreateProcess(
            IDaemonProcess process, IContextBoundSettingsStore settingsStore, DaemonProcessKind processKind, ICSharpFile file)
        {
            StyleCopTrace.In(process, settingsStore, processKind, file);

            if (process == null)
            {
                throw new ArgumentNullException("process");
            }

            try
            {
                if (processKind == DaemonProcessKind.OTHER)
                {
                    StyleCopTrace.Info("ProcessKind Other.");
                    StyleCopTrace.Out();
                    return null;
                }

                if (!settingsStore.GetValue<StyleCopOptionsSettingsKey, bool>(key => key.AnalysisEnabled))
                {
                    StyleCopTrace.Info("Analysis disabled.");
                    StyleCopTrace.Out();
                    return null;
                }

                if (!this.IsSupported(process.SourceFile))
                {
                    StyleCopTrace.Info("File type not supported.");
                    StyleCopTrace.Out();
                    return null;
                }

                if (!this.FileIsValid(file))
                {
                    StyleCopTrace.Info("Source file not valid.");
                    StyleCopTrace.Out();
                    return null;
                }

                if (!settingsStore.GetValue<StyleCopOptionsSettingsKey, bool>(key => key.AnalyzeReadOnlyFiles))
                {
                    if (process.SourceFile.Properties.IsNonUserFile)
                    {
                        StyleCopTrace.Info("Not analysing non user files.");
                        StyleCopTrace.Out();
                        return null;
                    }
                }

                return StyleCopTrace.Out(new StyleCopStageProcess(process, settingsStore, file));
            }
            catch (JetBrains.Application.Progress.ProcessCancelledException)
            {
                return null;
            }
        }
 public override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
 {
     return DoCreateProcess(process, settings, processKind);
 }
예제 #54
0
        protected override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind, ICSharpFile file)
        {
            // TODO: Load configuration
            var configuration = new SyntaxRuleConfiguration(new SyntaxRule[0]);

            return(new SourcePathDaemonProcess(process, file, configuration, _queryExecutor));
        }
 protected override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
                                                      DaemonProcessKind processKind, ICgFile file)
 {
     return(new CgPreprocessorHighligthingProcess(process, settings, file));
 }
 protected override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
     DaemonProcessKind processKind, IJavaScriptFile file)
 {
     return new AngularJsIdentifierHighlighterProcess(resolveHighlighterRegistrar, process, settings, file, processKind);
 }
예제 #57
0
 protected virtual void AddUnityECSHighlighting(IHighlightingConsumer consumer, IClassLikeDeclaration declaration, string text, string tooltip, DaemonProcessKind kind)
 {
     AddHighlighting(consumer, declaration, text, tooltip, kind);
 }
예제 #58
0
        public IEnumerable <IDaemonStageProcess> CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind)
        {
            if (!IsSupported(process.SourceFile))
            {
                return(Enumerable.Empty <IDaemonStageProcess>());
            }

            process.SourceFile.GetPsiServices().Files.AssertAllDocumentAreCommitted();

            return(process.SourceFile.GetPsiFiles <AngularJsLanguage>()
                   .SelectNotNull(file => CreateProcess(process, settings, processKind, (IJavaScriptFile)file)));
        }
예제 #59
0
 protected override void AddHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration declaration, string text, string tooltip, DaemonProcessKind kind)
 {
     consumer.AddImplicitConfigurableHighlighting(declaration);
     consumer.AddHighlighting(new UnityGutterMarkInfo(GetActions(declaration), declaration, tooltip));
 }
 public abstract IEnumerable<IDaemonStageProcess> CreateProcess(
     IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind);