public int GetUsagesCount(IClassLikeDeclaration classLikeDeclaration, out bool estimatedResult)
        {
            myShellLocks.AssertReadAccessAllowed();

            // TODO : prefabs
            estimatedResult = false;

            var sourceFile = classLikeDeclaration.GetSourceFile();

            if (sourceFile == null)
            {
                return(0);
            }

            var declaredElement = classLikeDeclaration.DeclaredElement;

            if (declaredElement == null)
            {
                return(0);
            }

            var guid = GetGuidFor(declaredElement);

            return(myAssetUsages.GetOrEmpty(guid).Count);
        }
示例#2
0
        public int GetScriptUsagesCount(IClassLikeDeclaration classLikeDeclaration, out bool estimatedResult)
        {
            myShellLocks.AssertReadAccessAllowed();

            // TODO : prefabs
            estimatedResult = false;

            var sourceFile = classLikeDeclaration.GetSourceFile();

            if (sourceFile == null)
            {
                return(0);
            }

            var declaredElement = classLikeDeclaration.DeclaredElement;

            if (declaredElement == null)
            {
                return(0);
            }

            var guid = AssetUtils.GetGuidFor(myMetaFileGuidCache, declaredElement);

            if (guid == null)
            {
                return(0);
            }

            return(myUsagesCount.GetCount(guid.Value));
        }
示例#3
0
 public bool UpToDate(IPsiSourceFile sourceFile)
 {
     myShellLocks.AssertReadAccessAllowed();
     if (!Accepts(sourceFile))
     {
         return(true);
     }
     return(!myDirtyFiles.Contains(sourceFile) && (myFilesWithoutAnnotations.Contains(sourceFile) || mySourceFileToNodes.ContainsKey(sourceFile)));
 }
        public IHierarchyElement GetHierarchyElement(IHierarchyReference reference, bool prefabImport)
        {
            myShellLocks.AssertReadAccessAllowed();

            var sourceFile = GetSourceFile(reference, out var guid);

            if (sourceFile == null || guid == null)
            {
                return(null);
            }

            return(myAssetDocumentsHierarchy[sourceFile].GetHierarchyElement(guid, reference.LocalDocumentAnchor, prefabImport ? myPrefabImportCache : null));
        }
        public void ProcessSceneHierarchyFromComponentToRoot(IHierarchyElement hierarchyElement, IGameObjectConsumer consumer, bool forcePrefabImport)
        {
            myLocks.AssertReadAccessAllowed();

            if (hierarchyElement == null)
            {
                return;
            }

            Assertion.Assert(!hierarchyElement.IsStripped, "!hierarchyElement.IsStripped"); // stripped elements should be never returned,
            Assertion.Assert(!(hierarchyElement is IPrefabInstanceHierarchy), "Process should not be started from prefab instance, use corresponding GO");

            var owner = myAssetDocumentHierarchyElementContainer.GetAssetHierarchyFor(hierarchyElement.Location, out _);

            ProcessHierarchy(owner, hierarchyElement, consumer, forcePrefabImport, new HashSet <ulong>());
        }
示例#6
0
        public void UpdateOccurrences(
            [NotNull] IList <LocalOccurrence> occurrences,
            [NotNull] IEnumerable <LocalOccurrence> tailOccurrences = null)
        {
            lock (mySyncRoot)
            {
                myOccurrences        = occurrences;
                mySelectedOccurrence = (occurrences.Count == 0) ? null : occurrences[0];

                if (!myShouldDropHighlightings && occurrences.Count == 0)
                {
                    return;
                }

                mySequentialOccurrences.Next(lifetime =>
                {
                    myShellLocks.ExecuteOrQueueReadLock(
                        lifetime, Prefix + "UpdateOccurrence", () =>
                        UpdateOccurrencesHighlighting(lifetime, occurrences));

                    myUpdateSelectedScheduled = true;
                });

                mySequentialFocused.Next(lifetime =>
                {
                    myShellLocks.AssertReadAccessAllowed();

                    myShellLocks.ExecuteOrQueueReadLock(
                        lifetime, Prefix + "UpdateOccurrence", UpdateFocusedOccurrence);
                });
            }
        }
        public bool IsPossibleEventHandler(IDeclaredElement declaredElement)
        {
            myShellLocks.AssertReadAccessAllowed();

            if (declaredElement is IProperty property)
            {
                var setter = property.Setter;
                if (setter != null && myShortNameToScriptTarget.GetValues(setter.ShortName).Length > 0)
                {
                    return(true);
                }

                var getter = property.Getter;
                if (getter != null && myShortNameToScriptTarget.GetValues(getter.ShortName).Length > 0)
                {
                    return(true);
                }

                return(false);
            }

            return(myShortNameToScriptTarget.GetValues(declaredElement.ShortName).Length > 0);
        }
        [NotNull] public IEnumerable <MatchingInfo> FindMatchingInfos(
            [NotNull] IdentifierMatcher matcher, [NotNull] INavigationScope scope,
            [NotNull] GotoContext gotoContext, [NotNull] CheckForInterrupt checkCanceled)
        {
            var solution = scope.GetSolution();

            if (solution == null)
            {
                return(EmptyList <MatchingInfo> .InstanceList);
            }

            var navigationScope = scope as FileMemberNavigationScope;

            if (navigationScope != null)
            {
                var sourceFile = navigationScope.GetPrimarySourceFile();
                var consumer   = new List <IOccurence>();
                SearchInFile(matcher.Filter, sourceFile, consumer, checkCanceled);

                foreach (var occurence in consumer)
                {
                    //return new MatchingInfo(matcher.Filter, EmptyList<IdentifierMatch>.InstanceList);
                }
            }


            var filterText  = matcher.Filter;
            var occurrences = new List <IOccurence>();

            myShellLocks.AssertReadAccessAllowed();

            //if (scope.ExtendedSearchFlag == LibrariesFlag.SolutionOnly)
            //{
            //  FindByWords(filterText, solution, occurrences, gotoContext, checkCanceled);
            //}
            //else
            //{
            //  FindTextual(filterText, solution, occurrences, checkCanceled);
            //}

            if (occurrences.Count > 0)
            {
                gotoContext.PutData(GoToWordOccurrences, occurrences);
                return(new[] { new MatchingInfo(filterText, EmptyList <IdentifierMatch> .InstanceList) });
            }

            return(EmptyList <MatchingInfo> .InstanceList);
        }
        public int GetValueCount(Guid guid, IEnumerable <string> possibleNames, IAssetValue assetValue)
        {
            myShellLocks.AssertReadAccessAllowed();

            var count = 0;

            foreach (var name in possibleNames)
            {
                var mbField = new MonoBehaviourField(guid, name.GetPlatformIndependentHashCode());
                count += myUniqueValuesCount.GetCount(mbField, assetValue.GetHashCode());
            }

            return(count);
        }
示例#10
0
        public IDictionary <long, IHierarchyElement> GetImportedElementsFor(Guid ownerGuid,
                                                                            AssetDocumentHierarchyElement assetDocumentHierarchyElement)
        {
            myShellLocks.AssertReadAccessAllowed();
            if (!myCache.TryGetFromCache(ownerGuid, out var result))
            {
                lock (myLockObject)
                {
                    if (myCache.TryGetFromCache(ownerGuid, out result))
                    {
                        return(result);
                    }

                    result = DoImport(ownerGuid, assetDocumentHierarchyElement, new HashSet <Guid>());
                    StoreResult(ownerGuid, result);
                }
            }

            return(result);
        }
示例#11
0
        /// <summary>
        /// Gets all modules referenced by this module.
        /// </summary>
        /// <returns>All referenced modules.</returns>
        public IEnumerable <IPsiModuleReference> GetReferences(IModuleReferenceResolveContext moduleReferenceResolveContext)
        {
            _shellLocks.AssertReadAccessAllowed();

            var references = new PsiModuleReferenceAccumulator(TargetFrameworkId);

            foreach (IAssemblyCookie cookie in _assemblyReferences.Values)
            {
                if (cookie.Assembly == null)
                {
                    continue;
                }

                IPsiModule psiModule = _psiModules.GetPrimaryPsiModule(cookie.Assembly, TargetFrameworkId);

                // Normal assembly.
                if (psiModule != null)
                {
                    references.Add(new PsiModuleReference(psiModule));
                }

                // Assembly that is the output of a current project: reference the project instead.
                else
                {
                    IProject project = _outputAssemblies.GetProjectByOutputAssembly(cookie.Assembly);
                    if (project != null)
                    {
                        psiModule = _psiModules.GetPrimaryPsiModule(project, TargetFrameworkId);
                        if (psiModule != null)
                        {
                            references.Add(new PsiModuleReference(psiModule));
                        }
                    }
                }
            }

            return(references.GetReferences());
        }
示例#12
0
        /// <summary>
        /// Gets all modules referenced by this module.
        /// </summary>
        /// <returns>All referenced modules.</returns>
        public IEnumerable <IPsiModuleReference> GetReferences()
        {
            _shellLocks.AssertReadAccessAllowed();

            var references = new PsiModuleReferenceAccumulator();

            foreach (IAssemblyCookie cookie in _assemblyReferences.Values)
            {
                if (cookie.Assembly == null)
                {
                    continue;
                }

                IPsiModule psiModule = _psiModuleManager.GetPrimaryPsiModule(cookie.Assembly);

                // Normal assembly.
                if (psiModule != null)
                {
                    references.Add(new PsiModuleReference(psiModule));
                }

                // Assembly that is the output of a current project: reference the project instead.
                else
                {
                    foreach (IProject project in _outputAssembliesCache.GetProjectsByAssembly(cookie.Assembly))
                    {
                        psiModule = _psiModuleManager.GetPrimaryPsiModule(project);
                        if (psiModule != null)
                        {
                            references.Add(new PsiModuleReference(psiModule));
                        }
                    }
                }
            }

            return(references.GetReferences());
        }
示例#13
0
        /// <summary>
        /// Gets all <see cref="T4PsiModule"/>s for opened files.
        /// </summary>
        /// <returns>A collection of <see cref="T4PsiModule"/>.</returns>
        internal IEnumerable <IPsiModule> GetModules()
        {
            _shellLocks.AssertReadAccessAllowed();

            return(_modules.Values.Select(wrapper => (IPsiModule)wrapper.Module));
        }
示例#14
0
 public IReferenceFactory CreateFactory(IPsiSourceFile sourceFile, IFile file)
 {
     myShellLocks.AssertReadAccessAllowed();
     return(new NitraReferenceFactory());
 }
示例#15
0
 private void AssertShellLocks()
 {
     myShellLocks.AssertReadAccessAllowed();
 }
示例#16
0
 public FileSystemPath GetPathFor(string name)
 {
     myShellLocks.AssertReadAccessAllowed();
     return(myNames.GetValuesSafe(name).FirstOrDefault(null)?.GetLocation());
 }
 public override bool ProjectCanHaveAlternateOutput(IProject project)
 {
     myShellLocks.AssertReadAccessAllowed();
     return(project.IsUnityProject());
 }