예제 #1
0
        /// <summary>
        /// Finds all references in the given file.
        /// </summary>
        /// <param name="searchScopes">The search scopes for which to look.</param>
        /// <param name="parsedFile">The type system representation of the file being searched.</param>
        /// <param name="compilationUnit">The compilation unit of the file being searched.</param>
        /// <param name="compilation">The compilation for the project that contains the file.</param>
        /// <param name="callback">Callback used to report the references that were found.</param>
        /// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
        public void FindReferencesInFile(IList <IFindReferenceSearchScope> searchScopes, CppParsedFile parsedFile, CompilationUnit compilationUnit,
                                         ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
        {
            if (searchScopes == null)
            {
                throw new ArgumentNullException("searchScopes");
            }
            if (parsedFile == null)
            {
                throw new ArgumentNullException("parsedFile");
            }
            if (compilationUnit == null)
            {
                throw new ArgumentNullException("compilationUnit");
            }
            if (compilation == null)
            {
                throw new ArgumentNullException("compilation");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            if (searchScopes.Count == 0)
            {
                return;
            }
            var navigators = new IResolveVisitorNavigator[searchScopes.Count];

            for (int i = 0; i < navigators.Length; i++)
            {
                navigators[i] = searchScopes[i].GetNavigator(compilation, callback);
            }
            IResolveVisitorNavigator combinedNavigator;

            if (searchScopes.Count == 1)
            {
                combinedNavigator = navigators[0];
            }
            else
            {
                combinedNavigator = new CompositeResolveVisitorNavigator(navigators);
            }

            cancellationToken.ThrowIfCancellationRequested();
            combinedNavigator = new DetectSkippableNodesNavigator(combinedNavigator, compilationUnit);
            cancellationToken.ThrowIfCancellationRequested();
            CppAstResolver resolver = new CppAstResolver(compilation, compilationUnit, parsedFile);

            resolver.ApplyNavigator(combinedNavigator, cancellationToken);
            foreach (var n in navigators)
            {
                var frn = n as FindReferenceNavigator;
                if (frn != null)
                {
                    frn.NavigatorDone(resolver, cancellationToken);
                }
            }
        }
예제 #2
0
            IResolveVisitorNavigator IFindReferenceSearchScope.GetNavigator(FoundReferenceCallback callback)
            {
                SearchScope n = (SearchScope)MemberwiseClone();

                n.callback = callback;
                return(n);
            }
예제 #3
0
        void FindReferencesButtonClick(object sender, EventArgs e)
        {
            if (csharpTreeView.SelectedNode == null)
            {
                return;
            }

            SimpleProjectContent project = new SimpleProjectContent();
            var parsedFile = new TypeSystemConvertVisitor(project, "dummy.cs").Convert(compilationUnit);

            project.UpdateProjectContent(null, parsedFile);

            List <ITypeResolveContext> projects = new List <ITypeResolveContext>();

            projects.Add(project);
            projects.AddRange(builtInLibs.Value);

            using (var context = new CompositeTypeResolveContext(projects).Synchronize()) {
                CSharpResolver resolver = new CSharpResolver(context);

                AstNode node = (AstNode)csharpTreeView.SelectedNode.Tag;
                IResolveVisitorNavigator navigator = new NodeListResolveVisitorNavigator(new[] { node });
                ResolveVisitor           visitor   = new ResolveVisitor(resolver, parsedFile, navigator);
                visitor.Scan(compilationUnit);
                IEntity             entity;
                MemberResolveResult mrr = visitor.GetResolveResult(node) as MemberResolveResult;
                TypeResolveResult   trr = visitor.GetResolveResult(node) as TypeResolveResult;
                if (mrr != null)
                {
                    entity = mrr.Member;
                }
                else if (trr != null)
                {
                    entity = trr.Type.GetDefinition();
                }
                else
                {
                    return;
                }

                FindReferences         fr             = new FindReferences();
                int                    referenceCount = 0;
                FoundReferenceCallback callback       = delegate(AstNode matchNode, ResolveResult result) {
                    referenceCount++;
                };

                var searchScopes = fr.GetSearchScopes(entity);
                navigator = new CompositeResolveVisitorNavigator(searchScopes.Select(s => s.GetNavigator(callback)).ToArray());
                visitor   = new ResolveVisitor(resolver, parsedFile, navigator);
                visitor.Scan(compilationUnit);

                csharpTreeView.BeginUpdate();
                ShowResolveResultsInTree(csharpTreeView.Nodes, visitor);
                csharpTreeView.EndUpdate();

                MessageBox.Show("Found " + referenceCount + " references to " + entity.FullName);
            }
        }
예제 #4
0
 /// <summary>
 /// Finds all references in the given file.
 /// </summary>
 /// <param name="searchScope">The search scope for which to look.</param>
 /// <param name="parsedFile">The type system representation of the file being searched.</param>
 /// <param name="compilationUnit">The compilation unit of the file being searched.</param>
 /// <param name="compilation">The compilation for the project that contains the file.</param>
 /// <param name="callback">Callback used to report the references that were found.</param>
 /// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
 public void FindReferencesInFile(IFindReferenceSearchScope searchScope, CppParsedFile parsedFile, CompilationUnit compilationUnit,
                                  ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
 {
     if (searchScope == null)
     {
         throw new ArgumentNullException("searchScope");
     }
     FindReferencesInFile(new[] { searchScope }, parsedFile, compilationUnit, compilation, callback, cancellationToken);
 }
예제 #5
0
 /// <summary>
 /// Finds all references in the given file.
 /// </summary>
 /// <param name="searchScope">The search scope for which to look.</param>
 /// <param name="parsedFile">The type system representation of the file being searched.</param>
 /// <param name="compilationUnit">The compilation unit of the file being searched.</param>
 /// <param name="context">The type resolve context to use for resolving the file.</param>
 /// <param name="callback">Callback used to report the references that were found.</param>
 public void FindReferencesInFile(IFindReferenceSearchScope searchScope, CSharpParsedFile parsedFile, CompilationUnit compilationUnit,
                                  ITypeResolveContext context, FoundReferenceCallback callback)
 {
     if (searchScope == null)
     {
         throw new ArgumentNullException("searchScope");
     }
     FindReferencesInFile(new[] { searchScope }, parsedFile, compilationUnit, context, callback);
 }
예제 #6
0
        /// <summary>
        /// Finds all references of a given variable.
        /// </summary>
        /// <param name="variable">The variable for which to look.</param>
        /// <param name="parsedFile">The type system representation of the file being searched.</param>
        /// <param name="compilationUnit">The compilation unit of the file being searched.</param>
        /// <param name="compilation">The compilation.</param>
        /// <param name="callback">Callback used to report the references that were found.</param>
        /// <param name="cancellationToken">Cancellation token that may be used to cancel the operation.</param>
        public void FindLocalReferences(IVariable variable, CppParsedFile parsedFile, CompilationUnit compilationUnit,
                                        ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
        {
            if (variable == null)
            {
                throw new ArgumentNullException("variable");
            }
            var searchScope = new SearchScope(c => new FindLocalReferencesNavigator(variable));

            searchScope.declarationCompilation = compilation;
            FindReferencesInFile(searchScope, parsedFile, compilationUnit, compilation, callback, cancellationToken);
        }
예제 #7
0
파일: CSDemo.cs 프로젝트: VE-2016/VE-2016
        private void FindReferencesButtonClick(object sender, EventArgs e)
        {
            if (csharpTreeView.SelectedNode == null)
            {
                return;
            }

            IProjectContent project        = new CSharpProjectContent();
            var             unresolvedFile = _syntaxTree.ToTypeSystem();

            project = project.AddOrUpdateFiles(unresolvedFile);
            project = project.AddAssemblyReferences(_builtInLibs.Value);

            ICompilation      compilation = project.CreateCompilation();
            CSharpAstResolver resolver    = new CSharpAstResolver(compilation, _syntaxTree, unresolvedFile);

            AstNode             node = (AstNode)csharpTreeView.SelectedNode.Tag;
            IEntity             entity;
            MemberResolveResult mrr = resolver.Resolve(node) as MemberResolveResult;
            TypeResolveResult   trr = resolver.Resolve(node) as TypeResolveResult;

            if (mrr != null)
            {
                entity = mrr.Member;
            }
            else if (trr != null)
            {
                entity = trr.Type.GetDefinition();
            }
            else
            {
                return;
            }

            FindReferences         fr             = new FindReferences();
            int                    referenceCount = 0;
            FoundReferenceCallback callback       = delegate(AstNode matchNode, ResolveResult result)
            {
                Debug.WriteLine(matchNode.StartLocation + " - " + matchNode + " - " + result);
                referenceCount++;
            };

            var searchScopes = fr.GetSearchScopes(entity);

            Debug.WriteLine("Find references to " + entity.ReflectionName);
            fr.FindReferencesInFile(searchScopes, unresolvedFile, _syntaxTree, compilation, callback, CancellationToken.None);

            MessageBox.Show("Found " + referenceCount + " references to " + entity.FullName);
        }
예제 #8
0
        private List <AstNode> GetResolvedNodes(ResolveResultType type, AstNode node)
        {
            var           resolvedNodes = new List <AstNode>();
            ResolveResult resolveResult = _resolver.Resolve(node);

            if (resolveResult != null)
            {
                var findReferences = new FindReferences();
                FoundReferenceCallback callback = delegate(AstNode matchNode, ResolveResult result)
                {
                    resolvedNodes.Add(matchNode);
                };

                if (type == ResolveResultType.Local)
                {
                    var localResolveResult = resolveResult as LocalResolveResult;
                    if (localResolveResult != null)
                    {
                        findReferences.FindLocalReferences(localResolveResult.Variable, _unresolvedFile, SyntaxTree, _compilation, callback, CancellationToken.None);
                    }
                }
                else if (type == ResolveResultType.Member)
                {
                    var memberResolveResult = resolveResult as MemberResolveResult;
                    if (memberResolveResult != null)
                    {
                        var searchScopes = findReferences.GetSearchScopes(memberResolveResult.Member);
                        findReferences.FindReferencesInFile(searchScopes, _unresolvedFile, SyntaxTree, _compilation, callback, CancellationToken.None);
                    }
                }
                else if (type == ResolveResultType.Type)
                {
                    var typeResolveResult = resolveResult as TypeResolveResult;
                    if (typeResolveResult != null)
                    {
                        var searchScopes = findReferences.GetSearchScopes(typeResolveResult.Type.GetDefinition());
                        findReferences.FindReferencesInFile(searchScopes, _unresolvedFile, SyntaxTree, _compilation, callback, CancellationToken.None);
                    }
                }
            }
            else
            {
            }
            return(resolvedNodes);
        }
예제 #9
0
 /// <summary>
 /// Finds all references in the given file.
 /// </summary>
 /// <param name="searchScopes">The search scopes for which to look.</param>
 /// <param name="parsedFile">The type system representation of the file being searched.</param>
 /// <param name="compilationUnit">The compilation unit of the file being searched.</param>
 /// <param name="context">The type resolve context to use for resolving the file.</param>
 /// <param name="callback">Callback used to report the references that were found.</param>
 public void FindReferencesInFile(IList <IFindReferenceSearchScope> searchScopes, CSharpParsedFile parsedFile, CompilationUnit compilationUnit,
                                  ITypeResolveContext context, FoundReferenceCallback callback)
 {
     if (searchScopes == null)
     {
         throw new ArgumentNullException("searchScopes");
     }
     if (parsedFile == null)
     {
         throw new ArgumentNullException("parsedFile");
     }
     if (compilationUnit == null)
     {
         throw new ArgumentNullException("compilationUnit");
     }
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     this.CancellationToken.ThrowIfCancellationRequested();
     if (searchScopes.Count == 0)
     {
         return;
     }
     using (var ctx = context.Synchronize()) {
         IResolveVisitorNavigator navigator;
         if (searchScopes.Count == 1)
         {
             navigator = searchScopes[0].GetNavigator(callback);
         }
         else
         {
             navigator = new CompositeResolveVisitorNavigator(searchScopes.Select(s => s.GetNavigator(callback)).ToArray());
         }
         navigator = new DetectSkippableNodesNavigator(navigator, compilationUnit);
         CSharpResolver resolver = new CSharpResolver(ctx, this.CancellationToken);
         ResolveVisitor v        = new ResolveVisitor(resolver, parsedFile, navigator);
         v.Scan(compilationUnit);
     }
 }
        private static List <AstNode> ComputeMatchNodes(RefactoringContext context, VariableInitializer firstOrNullObject)
        {
            var referenceFinder = new FindReferences();
            var matchedNodes    = new List <AstNode>();

            var resolveResult = context.Resolver.Resolve(firstOrNullObject);
            var member        = resolveResult as MemberResolveResult;

            if (member == null)//not a member is unexpected case, so is better to return no match than to break the code
            {
                return(matchedNodes);
            }

            FoundReferenceCallback callback = (matchNode, result) => matchedNodes.Add(matchNode);

            var searchScopes = referenceFinder.GetSearchScopes(member.Member);

            referenceFinder.FindReferencesInFile(searchScopes,
                                                 context.UnresolvedFile,
                                                 context.RootNode as SyntaxTree,
                                                 context.Compilation, callback,
                                                 context.CancellationToken);
            return(matchedNodes);
        }
			void FindLocalReferences (IVariable variable, FoundReferenceCallback callback)
			{
				refFinder.FindLocalReferences (variable, ctx.ParsedFile, unit, ctx.Compilation, callback, 
											   ctx.CancellationToken);
			}
예제 #12
0
		/// <summary>
		/// Finds all references in the given file.
		/// </summary>
		/// <param name="searchScope">The search scope for which to look.</param>
		/// <param name="parsedFile">The type system representation of the file being searched.</param>
		/// <param name="compilationUnit">The compilation unit of the file being searched.</param>
		/// <param name="compilation">The compilation for the project that contains the file.</param>
		/// <param name="callback">Callback used to report the references that were found.</param>
		/// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
		public void FindReferencesInFile(IFindReferenceSearchScope searchScope, CSharpParsedFile parsedFile, CompilationUnit compilationUnit,
		                                 ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
		{
			if (searchScope == null)
				throw new ArgumentNullException("searchScope");
			FindReferencesInFile(new[] { searchScope }, parsedFile, compilationUnit, compilation, callback, cancellationToken);
		}
예제 #13
0
		/// <summary>
		/// Finds all references in the given file.
		/// </summary>
		/// <param name="searchScope">The search scope for which to look.</param>
		/// <param name="parsedFile">The type system representation of the file being searched.</param>
		/// <param name="compilationUnit">The compilation unit of the file being searched.</param>
		/// <param name="context">The type resolve context to use for resolving the file.</param>
		/// <param name="callback">Callback used to report the references that were found.</param>
		public void FindReferencesInFile(IFindReferenceSearchScope searchScope, CSharpParsedFile parsedFile, CompilationUnit compilationUnit,
		                                 ITypeResolveContext context, FoundReferenceCallback callback)
		{
			if (searchScope == null)
				throw new ArgumentNullException("searchScope");
			FindReferencesInFile(new[] { searchScope }, parsedFile, compilationUnit, context, callback);
		}
예제 #14
0
			IResolveVisitorNavigator IFindReferenceSearchScope.GetNavigator(FoundReferenceCallback callback)
			{
				SearchScope n = (SearchScope)MemberwiseClone();
				n.callback = callback;
				return n;
			}
예제 #15
0
        /// <summary>
        /// Finds all references in the given file.
        /// </summary>
        /// <param name="searchScopes">The search scopes for which to look.</param>
        /// <param name="unresolvedFile">The type system representation of the file being searched.</param>
        /// <param name="syntaxTree">The syntax tree of the file being searched.</param>
        /// <param name="compilation">The compilation for the project that contains the file.</param>
        /// <param name="callback">Callback used to report the references that were found.</param>
        /// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
        public void FindReferencesInFile(IList<IFindReferenceSearchScope> searchScopes, CSharpUnresolvedFile unresolvedFile, SyntaxTree syntaxTree,
		                                 ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
        {
            if (searchScopes == null)
                throw new ArgumentNullException("searchScopes");
            if (syntaxTree == null)
                throw new ArgumentNullException("syntaxTree");
            if (compilation == null)
                throw new ArgumentNullException("compilation");
            if (callback == null)
                throw new ArgumentNullException("callback");

            if (searchScopes.Count == 0)
                return;
            var navigators = new IResolveVisitorNavigator[searchScopes.Count];
            for (int i = 0; i < navigators.Length; i++) {
                navigators[i] = searchScopes[i].GetNavigator(compilation, callback);
            }
            IResolveVisitorNavigator combinedNavigator;
            if (searchScopes.Count == 1) {
                combinedNavigator = navigators[0];
            } else {
                combinedNavigator = new CompositeResolveVisitorNavigator(navigators);
            }

            cancellationToken.ThrowIfCancellationRequested();
            combinedNavigator = new DetectSkippableNodesNavigator(combinedNavigator, syntaxTree);
            cancellationToken.ThrowIfCancellationRequested();
            CSharpAstResolver resolver = new CSharpAstResolver(compilation, syntaxTree, unresolvedFile);
            resolver.ApplyNavigator(combinedNavigator, cancellationToken);
            foreach (var n in navigators) {
                var frn = n as FindReferenceNavigator;
                if (frn != null)
                    frn.NavigatorDone(resolver, cancellationToken);
            }
        }
예제 #16
0
 IResolveVisitorNavigator IFindReferenceSearchScope.GetNavigator(ICompilation compilation, FoundReferenceCallback callback)
 {
     FindReferenceNavigator n = factory(compilation);
     if (n != null) {
         n.callback = callback;
         n.findReferences = findReferences;
         return n;
     } else {
         return new ConstantModeResolveVisitorNavigator(ResolveVisitorNavigationMode.Skip, null);
     }
 }
예제 #17
0
 void FindLocalReferences(IVariable variable, FoundReferenceCallback callback)
 {
     refFinder.FindLocalReferences(variable, ctx.UnresolvedFile, unit, ctx.Compilation, callback,
                                   ctx.CancellationToken);
 }
예제 #18
0
		/// <summary>
		/// Finds all references in the given file.
		/// </summary>
		/// <param name="searchScopes">The search scopes for which to look.</param>
		/// <param name="parsedFile">The type system representation of the file being searched.</param>
		/// <param name="compilationUnit">The compilation unit of the file being searched.</param>
		/// <param name="compilation">The compilation for the project that contains the file.</param>
		/// <param name="callback">Callback used to report the references that were found.</param>
		/// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
		public void FindReferencesInFile(IList<IFindReferenceSearchScope> searchScopes, CSharpParsedFile parsedFile, CompilationUnit compilationUnit,
		                                 ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
		{
			if (searchScopes == null)
				throw new ArgumentNullException("searchScopes");
			if (parsedFile == null)
				throw new ArgumentNullException("parsedFile");
			if (compilationUnit == null)
				throw new ArgumentNullException("compilationUnit");
			if (compilation == null)
				throw new ArgumentNullException("compilation");
			if (callback == null)
				throw new ArgumentNullException("callback");
			
			if (searchScopes.Count == 0)
				return;
			IResolveVisitorNavigator navigator;
			if (searchScopes.Count == 1) {
				navigator = searchScopes[0].GetNavigator(compilation, callback);
			} else {
				IResolveVisitorNavigator[] navigators = new IResolveVisitorNavigator[searchScopes.Count];
				for (int i = 0; i < navigators.Length; i++) {
					navigators[i] = searchScopes[i].GetNavigator(compilation, callback);
				}
				navigator = new CompositeResolveVisitorNavigator(navigators);
			}
			
			cancellationToken.ThrowIfCancellationRequested();
			navigator = new DetectSkippableNodesNavigator(navigator, compilationUnit);
			cancellationToken.ThrowIfCancellationRequested();
			CSharpAstResolver resolver = new CSharpAstResolver(compilation, compilationUnit, parsedFile);
			resolver.ApplyNavigator(navigator, cancellationToken);
		}
예제 #19
0
		/// <summary>
		/// Finds all references in the given file.
		/// </summary>
		/// <param name="searchScopes">The search scopes for which to look.</param>
		/// <param name="parsedFile">The type system representation of the file being searched.</param>
		/// <param name="compilationUnit">The compilation unit of the file being searched.</param>
		/// <param name="context">The type resolve context to use for resolving the file.</param>
		/// <param name="callback">Callback used to report the references that were found.</param>
		public void FindReferencesInFile(IList<IFindReferenceSearchScope> searchScopes, CSharpParsedFile parsedFile, CompilationUnit compilationUnit,
		                                 ITypeResolveContext context, FoundReferenceCallback callback)
		{
			if (searchScopes == null)
				throw new ArgumentNullException("searchScopes");
			if (parsedFile == null)
				throw new ArgumentNullException("parsedFile");
			if (compilationUnit == null)
				throw new ArgumentNullException("compilationUnit");
			if (context == null)
				throw new ArgumentNullException("context");
			this.CancellationToken.ThrowIfCancellationRequested();
			if (searchScopes.Count == 0)
				return;
			using (var ctx = context.Synchronize()) {
				IResolveVisitorNavigator navigator;
				if (searchScopes.Count == 1)
					navigator = searchScopes[0].GetNavigator(callback);
				else
					navigator = new CompositeResolveVisitorNavigator(searchScopes.Select(s => s.GetNavigator(callback)).ToArray());
				navigator = new DetectSkippableNodesNavigator(navigator, compilationUnit);
				CSharpResolver resolver = new CSharpResolver(ctx, this.CancellationToken);
				ResolveVisitor v = new ResolveVisitor(resolver, parsedFile, navigator);
				v.Scan(compilationUnit);
			}
		}
예제 #20
0
        /// <summary>
        /// Finds all references of a given variable.
        /// </summary>
        /// <param name="variable">The variable for which to look.</param>
        /// <param name="unresolvedFile">The type system representation of the file being searched.</param>
        /// <param name="syntaxTree">The syntax tree of the file being searched.</param>
        /// <param name="compilation">The compilation.</param>
        /// <param name="callback">Callback used to report the references that were found.</param>
        /// <param name="cancellationToken">Cancellation token that may be used to cancel the operation.</param>
        public void FindLocalReferences(IVariable variable, CSharpUnresolvedFile unresolvedFile, SyntaxTree syntaxTree,
		                                ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
        {
            if (variable == null)
                throw new ArgumentNullException("variable");
            var searchScope = new SearchScope(c => new FindLocalReferencesNavigator(variable));
            searchScope.declarationCompilation = compilation;
            FindReferencesInFile(searchScope, unresolvedFile, syntaxTree, compilation, callback, cancellationToken);
        }
예제 #21
0
		/// <summary>
		/// Finds all references in the given file.
		/// </summary>
		/// <param name="searchScopes">The search scopes for which to look.</param>
		/// <param name="resolver">AST resolver for the file to search in.</param>
		/// <param name="callback">Callback used to report the references that were found.</param>
		/// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
		public void FindReferencesInFile(IList<IFindReferenceSearchScope> searchScopes, CSharpAstResolver resolver,
		                                 FoundReferenceCallback callback, CancellationToken cancellationToken)
		{
			if (resolver == null)
				throw new ArgumentNullException("resolver");
			FindReferencesInFile(searchScopes, resolver.UnresolvedFile, (SyntaxTree)resolver.RootNode, resolver.Compilation, callback, cancellationToken);
		}
예제 #22
0
        /// <summary>
        /// Finds all references in the given file.
        /// </summary>
        /// <param name="searchScope">The search scope for which to look.</param>
        /// <param name="unresolvedFile">The type system representation of the file being searched.</param>
        /// <param name="syntaxTree">The syntax tree of the file being searched.</param>
        /// <param name="compilation">The compilation for the project that contains the file.</param>
        /// <param name="callback">Callback used to report the references that were found.</param>
        /// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
        public void FindReferencesInFile(IFindReferenceSearchScope searchScope, CSharpUnresolvedFile unresolvedFile, SyntaxTree syntaxTree,
		                                 ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
        {
            if (searchScope == null)
                throw new ArgumentNullException("searchScope");
            FindReferencesInFile(new[] { searchScope }, unresolvedFile, syntaxTree, compilation, callback, cancellationToken);
        }
예제 #23
0
            IResolveVisitorNavigator IFindReferenceSearchScope.GetNavigator(ICompilation compilation, FoundReferenceCallback callback)
            {
                FindReferenceNavigator n = factory(compilation);

                if (n != null)
                {
                    n.callback = callback;
                    return(n);
                }
                else
                {
                    return(new ConstantModeResolveVisitorNavigator(ResolveVisitorNavigationMode.Skip, null));
                }
            }
예제 #24
0
        /// <summary>
        /// Finds all references of a given type parameter.
        /// </summary>
        /// <param name="typeParameter">The type parameter for which to look.</param>
        /// <param name="unresolvedFile">The type system representation of the file being searched.</param>
        /// <param name="syntaxTree">The syntax tree of the file being searched.</param>
        /// <param name="compilation">The compilation.</param>
        /// <param name="callback">Callback used to report the references that were found.</param>
        /// <param name="cancellationToken">Cancellation token that may be used to cancel the operation.</param>
        public void FindTypeParameterReferences(IType typeParameter, CSharpUnresolvedFile unresolvedFile, SyntaxTree syntaxTree,
		                                ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
        {
            if (typeParameter == null)
                throw new ArgumentNullException("typeParameter");
            if (typeParameter.Kind != TypeKind.TypeParameter)
                throw new ArgumentOutOfRangeException("typeParameter", "Only type parameters are allowed");
            var searchScope = new SearchScope(c => new FindTypeParameterReferencesNavigator((ITypeParameter)typeParameter));
            searchScope.declarationCompilation = compilation;
            searchScope.accessibility = Accessibility.Private;
            FindReferencesInFile(searchScope, unresolvedFile, syntaxTree, compilation, callback, cancellationToken);
        }
예제 #25
0
		/// <summary>
		/// Finds all references of a given variable.
		/// </summary>
		/// <param name="variable">The variable for which to look.</param>
		/// <param name="parsedFile">The type system representation of the file being searched.</param>
		/// <param name="compilationUnit">The compilation unit of the file being searched.</param>
		/// <param name="compilation">The compilation.</param>
		/// <param name="callback">Callback used to report the references that were found.</param>
		/// <param name="cancellationToken">Cancellation token that may be used to cancel the operation.</param>
		public void FindLocalReferences(IVariable variable, CppParsedFile parsedFile, CompilationUnit compilationUnit,
		                                ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
		{
			if (variable == null)
				throw new ArgumentNullException("variable");
			var searchScope = new SearchScope(c => new FindLocalReferencesNavigator(variable));
			searchScope.declarationCompilation = compilation;
			FindReferencesInFile(searchScope, parsedFile, compilationUnit, compilation, callback, cancellationToken);
		}