@ -290,7 +290,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// <summary>
/// <summary>
/// Gets the file names that possibly contain references to the element being searched for.
/// Gets the file names that possibly contain references to the element being searched for.
/// </summary>
/// </summary>
public IEnumerable < CSharpPars edFile > GetInterestingFiles ( IFindReferenceSearchScope searchScope , ICompilation compilation )
public IEnumerable < CSharpUnresolv edFile > GetInterestingFiles ( IFindReferenceSearchScope searchScope , ICompilation compilation )
{
{
if ( searchScope = = null )
if ( searchScope = = null )
throw new ArgumentNullException ( "searchScope" ) ;
throw new ArgumentNullException ( "searchScope" ) ;
@ -303,47 +303,47 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
ITypeDefinition topLevelTypeDef = compilation . Import ( searchScope . TopLevelTypeDefinition ) ;
ITypeDefinition topLevelTypeDef = compilation . Import ( searchScope . TopLevelTypeDefinition ) ;
if ( topLevelTypeDef = = null ) {
if ( topLevelTypeDef = = null ) {
// This compilation cannot have references to the target entity.
// This compilation cannot have references to the target entity.
return EmptyList < CSharpPars edFile > . Instance ;
return EmptyList < CSharpUnresolv edFile > . Instance ;
}
}
switch ( searchScope . Accessibility ) {
switch ( searchScope . Accessibility ) {
case Accessibility . None :
case Accessibility . None :
case Accessibility . Private :
case Accessibility . Private :
if ( topLevelTypeDef . ParentAssembly = = compilation . MainAssembly )
if ( topLevelTypeDef . ParentAssembly = = compilation . MainAssembly )
return topLevelTypeDef . Parts . Select ( p = > p . Pars edFile) . OfType < CSharpPars edFile > ( ) . Distinct ( ) ;
return topLevelTypeDef . Parts . Select ( p = > p . Unresolv edFile) . OfType < CSharpUnresolv edFile > ( ) . Distinct ( ) ;
else
else
return EmptyList < CSharpPars edFile > . Instance ;
return EmptyList < CSharpUnresolv edFile > . Instance ;
case Accessibility . Protected :
case Accessibility . Protected :
return GetInterestingFilesProtected ( topLevelTypeDef ) ;
return GetInterestingFilesProtected ( topLevelTypeDef ) ;
case Accessibility . Internal :
case Accessibility . Internal :
if ( topLevelTypeDef . ParentAssembly . InternalsVisibleTo ( compilation . MainAssembly ) )
if ( topLevelTypeDef . ParentAssembly . InternalsVisibleTo ( compilation . MainAssembly ) )
return pc . Files . OfType < CSharpPars edFile > ( ) ;
return pc . Files . OfType < CSharpUnresolv edFile > ( ) ;
else
else
return EmptyList < CSharpPars edFile > . Instance ;
return EmptyList < CSharpUnresolv edFile > . Instance ;
case Accessibility . ProtectedAndInternal :
case Accessibility . ProtectedAndInternal :
if ( topLevelTypeDef . ParentAssembly . InternalsVisibleTo ( compilation . MainAssembly ) )
if ( topLevelTypeDef . ParentAssembly . InternalsVisibleTo ( compilation . MainAssembly ) )
return GetInterestingFilesProtected ( topLevelTypeDef ) ;
return GetInterestingFilesProtected ( topLevelTypeDef ) ;
else
else
return EmptyList < CSharpPars edFile > . Instance ;
return EmptyList < CSharpUnresolv edFile > . Instance ;
case Accessibility . ProtectedOrInternal :
case Accessibility . ProtectedOrInternal :
if ( topLevelTypeDef . ParentAssembly . InternalsVisibleTo ( compilation . MainAssembly ) )
if ( topLevelTypeDef . ParentAssembly . InternalsVisibleTo ( compilation . MainAssembly ) )
return pc . Files . OfType < CSharpPars edFile > ( ) ;
return pc . Files . OfType < CSharpUnresolv edFile > ( ) ;
else
else
return GetInterestingFilesProtected ( topLevelTypeDef ) ;
return GetInterestingFilesProtected ( topLevelTypeDef ) ;
default :
default :
return pc . Files . OfType < CSharpPars edFile > ( ) ;
return pc . Files . OfType < CSharpUnresolv edFile > ( ) ;
}
}
} else {
} else {
return pc . Files . OfType < CSharpPars edFile > ( ) ;
return pc . Files . OfType < CSharpUnresolv edFile > ( ) ;
}
}
}
}
IEnumerable < CSharpPars edFile > GetInterestingFilesProtected ( ITypeDefinition referencedTypeDefinition )
IEnumerable < CSharpUnresolv edFile > GetInterestingFilesProtected ( ITypeDefinition referencedTypeDefinition )
{
{
return ( from typeDef in referencedTypeDefinition . Compilation . MainAssembly . GetAllTypeDefinitions ( )
return ( from typeDef in referencedTypeDefinition . Compilation . MainAssembly . GetAllTypeDefinitions ( )
where typeDef . IsDerivedFrom ( referencedTypeDefinition )
where typeDef . IsDerivedFrom ( referencedTypeDefinition )
from part in typeDef . Parts
from part in typeDef . Parts
select part . Pars edFile
select part . Unresolv edFile
) . OfType < CSharpPars edFile > ( ) . Distinct ( ) ;
) . OfType < CSharpUnresolv edFile > ( ) . Distinct ( ) ;
}
}
#endregion
#endregion
@ -352,35 +352,35 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// Finds all references in the given file.
/// Finds all references in the given file.
/// </summary>
/// </summary>
/// <param name="searchScope">The search scope for which to look.</param>
/// <param name="searchScope">The search scope for which to look.</param>
/// <param name="pars edFile">The type system representation of the file being searched.</param>
/// <param name="unresolv edFile">The type system representation of the file being searched.</param>
/// <param name="syntaxTree">The syntax tree 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="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="callback">Callback used to report the references that were found.</param>
/// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
/// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
public void FindReferencesInFile ( IFindReferenceSearchScope searchScope , CSharpParsedFile pars edFile , SyntaxTree syntaxTree ,
public void FindReferencesInFile ( IFindReferenceSearchScope searchScope , CSharpUnresolvedFile unresolv edFile , SyntaxTree syntaxTree ,
ICompilation compilation , FoundReferenceCallback callback , CancellationToken cancellationToken )
ICompilation compilation , FoundReferenceCallback callback , CancellationToken cancellationToken )
{
{
if ( searchScope = = null )
if ( searchScope = = null )
throw new ArgumentNullException ( "searchScope" ) ;
throw new ArgumentNullException ( "searchScope" ) ;
FindReferencesInFile ( new [ ] { searchScope } , pars edFile, syntaxTree , compilation , callback , cancellationToken ) ;
FindReferencesInFile ( new [ ] { searchScope } , unresolv edFile, syntaxTree , compilation , callback , cancellationToken ) ;
}
}
/// <summary>
/// <summary>
/// Finds all references in the given file.
/// Finds all references in the given file.
/// </summary>
/// </summary>
/// <param name="searchScopes">The search scopes for which to look.</param>
/// <param name="searchScopes">The search scopes for which to look.</param>
/// <param name="pars edFile">The type system representation of the file being searched.</param>
/// <param name="unresolv edFile">The type system representation of the file being searched.</param>
/// <param name="syntaxTree">The syntax tree 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="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="callback">Callback used to report the references that were found.</param>
/// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
/// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
public void FindReferencesInFile ( IList < IFindReferenceSearchScope > searchScopes , CSharpParsedFile pars edFile , SyntaxTree syntaxTree ,
public void FindReferencesInFile ( IList < IFindReferenceSearchScope > searchScopes , CSharpUnresolvedFile unresolv edFile , SyntaxTree syntaxTree ,
ICompilation compilation , FoundReferenceCallback callback , CancellationToken cancellationToken )
ICompilation compilation , FoundReferenceCallback callback , CancellationToken cancellationToken )
{
{
if ( searchScopes = = null )
if ( searchScopes = = null )
throw new ArgumentNullException ( "searchScopes" ) ;
throw new ArgumentNullException ( "searchScopes" ) ;
if ( pars edFile = = null )
if ( unresolv edFile = = null )
throw new ArgumentNullException ( "pars edFile" ) ;
throw new ArgumentNullException ( "unresolv edFile" ) ;
if ( syntaxTree = = null )
if ( syntaxTree = = null )
throw new ArgumentNullException ( "syntaxTree" ) ;
throw new ArgumentNullException ( "syntaxTree" ) ;
if ( compilation = = null )
if ( compilation = = null )
@ -404,7 +404,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
cancellationToken . ThrowIfCancellationRequested ( ) ;
cancellationToken . ThrowIfCancellationRequested ( ) ;
combinedNavigator = new DetectSkippableNodesNavigator ( combinedNavigator , syntaxTree ) ;
combinedNavigator = new DetectSkippableNodesNavigator ( combinedNavigator , syntaxTree ) ;
cancellationToken . ThrowIfCancellationRequested ( ) ;
cancellationToken . ThrowIfCancellationRequested ( ) ;
CSharpAstResolver resolver = new CSharpAstResolver ( compilation , syntaxTree , pars edFile) ;
CSharpAstResolver resolver = new CSharpAstResolver ( compilation , syntaxTree , unresolv edFile) ;
resolver . ApplyNavigator ( combinedNavigator , cancellationToken ) ;
resolver . ApplyNavigator ( combinedNavigator , cancellationToken ) ;
foreach ( var n in navigators ) {
foreach ( var n in navigators ) {
var frn = n as FindReferenceNavigator ;
var frn = n as FindReferenceNavigator ;
@ -1171,19 +1171,19 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// Finds all references of a given variable.
/// Finds all references of a given variable.
/// </summary>
/// </summary>
/// <param name="variable">The variable for which to look.</param>
/// <param name="variable">The variable for which to look.</param>
/// <param name="pars edFile">The type system representation of the file being searched.</param>
/// <param name="unresolv edFile">The type system representation of the file being searched.</param>
/// <param name="syntaxTree">The syntax tree 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="compilation">The compilation.</param>
/// <param name="callback">Callback used to report the references that were found.</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>
/// <param name="cancellationToken">Cancellation token that may be used to cancel the operation.</param>
public void FindLocalReferences ( IVariable variable , CSharpParsedFile pars edFile , SyntaxTree syntaxTree ,
public void FindLocalReferences ( IVariable variable , CSharpUnresolvedFile unresolv edFile , SyntaxTree syntaxTree ,
ICompilation compilation , FoundReferenceCallback callback , CancellationToken cancellationToken )
ICompilation compilation , FoundReferenceCallback callback , CancellationToken cancellationToken )
{
{
if ( variable = = null )
if ( variable = = null )
throw new ArgumentNullException ( "variable" ) ;
throw new ArgumentNullException ( "variable" ) ;
var searchScope = new SearchScope ( c = > new FindLocalReferencesNavigator ( variable ) ) ;
var searchScope = new SearchScope ( c = > new FindLocalReferencesNavigator ( variable ) ) ;
searchScope . declarationCompilation = compilation ;
searchScope . declarationCompilation = compilation ;
FindReferencesInFile ( searchScope , pars edFile, syntaxTree , compilation , callback , cancellationToken ) ;
FindReferencesInFile ( searchScope , unresolv edFile, syntaxTree , compilation , callback , cancellationToken ) ;
}
}
class FindLocalReferencesNavigator : FindReferenceNavigator
class FindLocalReferencesNavigator : FindReferenceNavigator
@ -1225,12 +1225,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
/// Finds all references of a given type parameter.
/// Finds all references of a given type parameter.
/// </summary>
/// </summary>
/// <param name="typeParameter">The type parameter for which to look.</param>
/// <param name="typeParameter">The type parameter for which to look.</param>
/// <param name="pars edFile">The type system representation of the file being searched.</param>
/// <param name="unresolv edFile">The type system representation of the file being searched.</param>
/// <param name="syntaxTree">The syntax tree 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="compilation">The compilation.</param>
/// <param name="callback">Callback used to report the references that were found.</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>
/// <param name="cancellationToken">Cancellation token that may be used to cancel the operation.</param>
public void FindTypeParameterReferences ( IType typeParameter , CSharpParsedFile pars edFile , SyntaxTree syntaxTree ,
public void FindTypeParameterReferences ( IType typeParameter , CSharpUnresolvedFile unresolv edFile , SyntaxTree syntaxTree ,
ICompilation compilation , FoundReferenceCallback callback , CancellationToken cancellationToken )
ICompilation compilation , FoundReferenceCallback callback , CancellationToken cancellationToken )
{
{
if ( typeParameter = = null )
if ( typeParameter = = null )
@ -1240,7 +1240,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
var searchScope = new SearchScope ( c = > new FindTypeParameterReferencesNavigator ( ( ITypeParameter ) typeParameter ) ) ;
var searchScope = new SearchScope ( c = > new FindTypeParameterReferencesNavigator ( ( ITypeParameter ) typeParameter ) ) ;
searchScope . declarationCompilation = compilation ;
searchScope . declarationCompilation = compilation ;
searchScope . accessibility = Accessibility . Private ;
searchScope . accessibility = Accessibility . Private ;
FindReferencesInFile ( searchScope , pars edFile, syntaxTree , compilation , callback , cancellationToken ) ;
FindReferencesInFile ( searchScope , unresolv edFile, syntaxTree , compilation , callback , cancellationToken ) ;
}
}
class FindTypeParameterReferencesNavigator : FindReferenceNavigator
class FindTypeParameterReferencesNavigator : FindReferenceNavigator