public UnityEventFunctionQuickDocProvider(ISolution solution, UnityApi unityApi,
                                           DocumentManager documentManager, QuickDocTypeMemberProvider quickDocTypeMemberProvider,
                                           HelpSystem helpSystem, ITheming theming)
 {
     mySolution = solution;
     myUnityApi = unityApi;
     myDocumentManager = documentManager;
     myQuickDocTypeMemberProvider = quickDocTypeMemberProvider;
     myHelpSystem = helpSystem;
     myTheming = theming;
 }
 public RiderTypeDetector(ISolution solution,
                          IApplicationWideContextBoundSettingStore settingsStore,
                          UnityApi unityApi,
                          AssetIndexingSupport assetIndexingSupport,
                          UnityUsagesCodeVisionProvider usagesCodeVisionProvider,
                          UnityCodeInsightProvider codeInsightProvider,
                          AssetScriptUsagesElementContainer assetScriptUsagesElementContainer,
                          DeferredCacheController deferredCacheController, UnitySolutionTracker solutionTracker,
                          BackendUnityHost backendUnityHost,
                          IconHost iconHost, AssetSerializationMode assetSerializationMode,
                          PerformanceCriticalContextProvider contextProvider)
     : base(solution, settingsStore, unityApi, contextProvider)
 {
     myAssetIndexingSupport              = assetIndexingSupport;
     myUsagesCodeVisionProvider          = usagesCodeVisionProvider;
     myCodeInsightProvider               = codeInsightProvider;
     myAssetScriptUsagesElementContainer = assetScriptUsagesElementContainer;
     myDeferredCacheController           = deferredCacheController;
     mySolutionTracker        = solutionTracker;
     myBackendUnityHost       = backendUnityHost;
     myIconHost               = iconHost;
     myAssetSerializationMode = assetSerializationMode;
 }
Ejemplo n.º 3
0
        private bool CheckPosition(CSharpCodeCompletionContext context, UnityApi unityApi,
                                   out IClassDeclaration classDeclaration,
                                   out AccessRights accessRights, out bool hasReturnType)
        {
            classDeclaration = GetClassDeclaration(context.NodeInFile);
            accessRights     = AccessRights.NONE;
            hasReturnType    = false;

            if (classDeclaration == null)
            {
                return(false);
            }

            // Make sure we're completing an identifier
            if (!(context.UnterminatedContext.TreeNode is ICSharpIdentifier identifier))
            {
                return(false);
            }

            if (!unityApi.IsUnityType(classDeclaration.DeclaredElement))
            {
                return(false);
            }

            // Make sure we're in the correct place for showing Unity event functions.
            if (!ShouldComplete(context.NodeInFile, identifier))
            {
                return(false);
            }

            // We know we're in a place where we can complete, so now configure what we
            // complete and what we display
            hasReturnType = HasExistingReturnType(identifier, out var typeUsage);
            accessRights  = GetAccessRights(typeUsage);

            return(true);
        }
Ejemplo n.º 4
0
        public static bool IsPerformanceCriticalRootMethod(ITreeNode node)
        {
            if (!(node is ICSharpDeclaration declaration))
            {
                return(false);
            }

            // TODO: 20.1, support lambda
            if (declaration.DeclaredElement is IAttributesOwner attributesOwner && HasFrequentlyCalledMethodAttribute(attributesOwner))
            {
                return(true);
            }

            if (!(declaration is ITypeMemberDeclaration typeMemberDeclaration))
            {
                return(false);
            }

            var typeElement = typeMemberDeclaration.DeclaredElement?.GetContainingType();

            if (typeElement == null)
            {
                return(false);
            }

            if (!UnityApi.IsDescendantOfMonoBehaviour(typeElement))
            {
                return(false);
            }

            if (declaration.DeclaredElement is IClrDeclaredElement clrDeclaredElement)
            {
                return(ourKnownHotMonoBehaviourMethods.Contains(clrDeclaredElement.ShortName));
            }

            return(false);
        }
        private UnityPresentationType GetUnityPresentationType(IType type)
        {
            if (UnityApi.IsDescendantOfScriptableObject(type.GetTypeElement()))
            {
                return(UnityPresentationType.ScriptableObject);
            }
            if (type.IsBool())
            {
                return(UnityPresentationType.Bool);
            }
            if (type.IsEnumType())
            {
                return(UnityPresentationType.Enum);
            }
            if (type.IsString())
            {
                return(UnityPresentationType.String);
            }

            if (type.IsSimplePredefined())
            {
                return(UnityPresentationType.OtherSimple);
            }

            if (type.IsValueType())
            {
                return(UnityPresentationType.ValueType);
            }

            if (IsSerializedViaFileId(type))
            {
                return(UnityPresentationType.FileId);
            }

            return(UnityPresentationType.Other);
        }
 public FormerlySerializedAsAttributeProblemAnalyzer(UnityApi unityApi)
     : base(unityApi)
 {
 }
Ejemplo n.º 7
0
 public CustomCodeAnnotationProvider(ExternalAnnotationsModuleFactory externalAnnotationsModuleFactory, IPredefinedTypeCache predefinedTypeCache, UnityApi unityApi)
 {
     myPredefinedTypeCache  = predefinedTypeCache;
     myUnityApi             = unityApi;
     myAnnotationsPsiModule = externalAnnotationsModuleFactory
                              .GetPsiModule(TargetFrameworkId.Default);
 }
 public RedundantEventFunctionProblemAnalyzer(UnityApi unityApi)
     : base(unityApi)
 {
 }
 public RedundantSerializeFieldAttributeProblemAnalyzer(UnityApi unityApi)
     : base(unityApi)
 {
 }
Ejemplo n.º 10
0
 public PreferNonAllocApiAnalyzer([NotNull] UnityApi unityApi) : base(unityApi)
 {
 }
        public override IEnumerable <BulbMenuItem> CreateAdditionalMenuItem(IDeclaration declaration, UnityApi api, ITextControl textControl)
        {
            var declaredElement = declaration.DeclaredElement;

            if (declaredElement != null && (declaredElement is IMethod method && !api.IsEventFunction(method) ||
                                            declaration is IClassDeclaration))
            {
                var action = new UnityFindUsagesNavigationAction(declaredElement,
                                                                 declaration.GetSolution().GetComponent <UnityEditorFindUsageResultCreator>(), myConnectionTracker);
                return(new[]
                {
                    new BulbMenuItem(
                        new IntentionAction.MyExecutableProxi(action, Solution, textControl),
                        action.Text, BulbThemedIcons.ContextAction.Id,
                        BulbMenuAnchors.FirstClassContextItems)
                });
            }


            return(EmptyList <BulbMenuItem> .Instance);
        }
 public UnityHighlightingStage(IEnumerable <IUnityDeclarationHiglightingProvider> higlightingProviders,
                               UnityApi api, UnityHighlightingContributor unityHighlightingContributor)
     : base(higlightingProviders, api, unityHighlightingContributor)
 {
 }
Ejemplo n.º 13
0
 public MultiplicationOrderAnalyzer(UnityApi unityApi)
     : base(unityApi)
 {
 }
Ejemplo n.º 14
0
 public UnityInitialiseOnLoadCctorDetector(UnityApi unityApi)
     : base(unityApi)
 {
 }
Ejemplo n.º 15
0
 public CompareTagProblemAnalyzer(UnityApi unityApi)
     : base(unityApi)
 {
 }
 public InitializeOnLoadSignatureProblemAnalyzer(UnityApi unityApi, IPredefinedTypeCache predefinedTypeCache)
     : base(unityApi)
 {
     myPredefinedTypeCache = predefinedTypeCache;
 }
Ejemplo n.º 17
0
 public UnityTypeDetector(UnityApi unityApi)
     : base(unityApi)
 {
 }
Ejemplo n.º 18
0
 public UnityObjectNullCoalescingProblemAnalyzer([NotNull] UnityApi unityApi)
     : base(unityApi)
 {
 }
 public CustomCodeAnnotationProvider(ExternalAnnotationsModuleFactory externalAnnotationsModuleFactory, IPredefinedTypeCache predefinedTypeCache, UnityApi unityApi)
 {
     myPredefinedTypeCache  = predefinedTypeCache;
     myUnityApi             = unityApi;
     myAnnotationsPsiModule =
         externalAnnotationsModuleFactory.Modules.OfType <IExternalAnnotationPsiModule>().Single();
 }
 public DrawGizmoAttributeProblemAnalyzer([NotNull] UnityApi unityApi, IPredefinedTypeCache predefinedTypeCache)
     : base(unityApi)
 {
     myPredefinedTypeCache = predefinedTypeCache;
 }
Ejemplo n.º 21
0
 public TypeDetector(ISolution solution, CallGraphSwaExtensionProvider callGraphSwaExtensionProvider, SettingsStore settingsStore, UnityApi unityApi,
                     PerformanceCriticalCodeCallGraphMarksProvider marksProvider, IElementIdProvider provider)
     : base(solution, callGraphSwaExtensionProvider, settingsStore, marksProvider, provider)
 {
     myUnityApi = unityApi;
 }
Ejemplo n.º 22
0
        private static string GetUnityName(IPsiDocumentRangeView psiDocumentRangeView, UnityApi unityApi)
        {
            var psiView = psiDocumentRangeView.View <CSharpLanguage>();

            if (psiView.ContainingNodes.All(n => !n.IsFromUnityProject()))
            {
                return(string.Empty);
            }

            if (!(FindDeclaredElement(psiView) is IClrDeclaredElement element))
            {
                return(string.Empty);
            }

            var unityName = GetUnityEventFunctionName(element, unityApi);

            if (unityName != null)
            {
                return(unityName);
            }

            return(GetFullyQualifiedUnityName(element));
        }
 public VsUnityVersionPropertiesExtenderProvider(Lifetime lifetime, IShellLocks locks, UnityVersion unityVersion, UnityApi unityApi)
 {
     myLifetime     = lifetime;
     myLocks        = locks;
     myUnityVersion = unityVersion;
     myUnityApi     = unityApi;
 }
Ejemplo n.º 24
0
 public ChangeNamingRuleWindowProvider(ILogger logger, UnityApi unityApi)
     : base(logger)
 {
     myUnityApi = unityApi;
 }
Ejemplo n.º 25
0
 public UnityFieldDetector(UnityApi unityApi)
 {
     myUnityApi = unityApi;
 }
 public UnityEventFunctionAnalyzer(UnityApi unityApi)
     : base(unityApi)
 {
 }
Ejemplo n.º 27
0
        private static string GetUnityEventFunctionName([NotNull] IDeclaredElement element, UnityApi unityApi)
        {
            var method = element as IMethod;

            if (method == null && element is IParameter parameter)
            {
                method = parameter.ContainingParametersOwner as IMethod;
            }

            if (method == null)
            {
                return(null);
            }

            var unityEventFunction = unityApi.GetUnityEventFunction(method);

            if (unityEventFunction == null)
            {
                return(null);
            }

            return(unityEventFunction.TypeName + "." + element.ShortName);
        }
Ejemplo n.º 28
0
 protected MethodSignatureProblemAnalyzerBase([NotNull] UnityApi unityApi)
     : base(unityApi)
 {
 }
 public SyncVarUsageProblemAnalyzer(UnityApi unityApi)
     : base(unityApi)
 {
 }
 public RedundantAttributeOnTargetProblemAnalyzer([NotNull] UnityApi unityApi)
     : base(unityApi)
 {
 }
 public UnityEventFunctionDescriptionProvider(UnityApi unityApi)
 {
     myUnityApi = unityApi;
 }
 protected UnityElementProblemAnalyzer(UnityApi unityApi)
 {
     Api = unityApi;
 }