コード例 #1
0
            public Session(
                RenameLocations renameLocationSet,
                Location renameSymbolDeclarationLocation,
                string originalText,
                string replacementText,
                OptionSet optionSet,
                Func<IEnumerable<ISymbol>, bool?> newSymbolsAreValid,
                CancellationToken cancellationToken)
            {
                _renameLocationSet = renameLocationSet;
                _renameSymbolDeclarationLocation = renameSymbolDeclarationLocation;
                _originalText = originalText;
                _replacementText = replacementText;
                _optionSet = optionSet;
                _hasConflictCallback = newSymbolsAreValid;
                _cancellationToken = cancellationToken;

                _renamedSymbolDeclarationAnnotation = new RenameAnnotation();

                _conflictLocations = SpecializedCollections.EmptySet<ConflictLocationInfo>();
                _replacementTextValid = true;
                _possibleNameConflicts = new List<string>();

                // only process documents which possibly contain the identifiers.
                _documentsIdsToBeCheckedForConflict = new HashSet<DocumentId>();
                _documentIdOfRenameSymbolDeclaration = renameLocationSet.Solution.GetDocument(renameSymbolDeclarationLocation.SourceTree).Id;

                _renameAnnotations = new AnnotationTable<RenameAnnotation>(RenameAnnotation.Kind);
            }
コード例 #2
0
            public Session(
                RenameLocations renameLocationSet,
                Location renameSymbolDeclarationLocation,
                string originalText,
                string replacementText,
                OptionSet optionSet,
                Func <IEnumerable <ISymbol>, bool?> newSymbolsAreValid,
                CancellationToken cancellationToken)
            {
                _renameLocationSet = renameLocationSet;
                _renameSymbolDeclarationLocation = renameSymbolDeclarationLocation;
                _originalText        = originalText;
                _replacementText     = replacementText;
                _optionSet           = optionSet;
                _hasConflictCallback = newSymbolsAreValid;
                _cancellationToken   = cancellationToken;

                _renamedSymbolDeclarationAnnotation = new RenameAnnotation();

                _conflictLocations     = SpecializedCollections.EmptySet <ConflictLocationInfo>();
                _replacementTextValid  = true;
                _possibleNameConflicts = new List <string>();

                // only process documents which possibly contain the identifiers.
                _documentsIdsToBeCheckedForConflict  = new HashSet <DocumentId>();
                _documentIdOfRenameSymbolDeclaration = renameLocationSet.Solution.GetDocument(renameSymbolDeclarationLocation.SourceTree).Id;

                _renameAnnotations = new AnnotationTable <RenameAnnotation>(RenameAnnotation.Kind);
            }
コード例 #3
0
            public Session(RenameLocationSet renameLocationSet, Location renameSymbolDeclarationLocation, string originalText, string replacementText, OptionSet optionSet, CancellationToken cancellationToken)
            {
                this.renameLocationSet = renameLocationSet;
                this.renameSymbolDeclarationLocation = renameSymbolDeclarationLocation;
                this.originalText = originalText;
                this.replacementText = replacementText;
                this.optionSet = optionSet;
                this.cancellationToken = cancellationToken;

                this.renamedSymbolDeclarationAnnotation = new RenameAnnotation();

                this.conflictLocations = SpecializedCollections.EmptySet<ConflictLocationInfo>();
                this.replacementTextValid = true;
                this.possibleNameConflicts = new List<string>();

                // only process documents which possibly contain the identifiers.
                this.documentsIdsToBeCheckedForConflict = new HashSet<DocumentId>();
                this.documentIdOfRenameSymbolDeclaration = renameLocationSet.Solution.GetDocument(renameSymbolDeclarationLocation.SourceTree).Id;

                this.renameAnnotations = new AnnotationTable<RenameAnnotation>(RenameAnnotation.Kind);
            }
コード例 #4
0
            public Session(RenameLocationSet renameLocationSet, Location renameSymbolDeclarationLocation, string originalText, string replacementText, OptionSet optionSet, CancellationToken cancellationToken)
            {
                this.renameLocationSet = renameLocationSet;
                this.renameSymbolDeclarationLocation = renameSymbolDeclarationLocation;
                this.originalText      = originalText;
                this.replacementText   = replacementText;
                this.optionSet         = optionSet;
                this.cancellationToken = cancellationToken;

                this.renamedSymbolDeclarationAnnotation = new RenameAnnotation();

                this.conflictLocations     = SpecializedCollections.EmptySet <ConflictLocationInfo>();
                this.replacementTextValid  = true;
                this.possibleNameConflicts = new List <string>();

                // only process documents which possibly contain the identifiers.
                this.documentsIdsToBeCheckedForConflict  = new HashSet <DocumentId>();
                this.documentIdOfRenameSymbolDeclaration = renameLocationSet.Solution.GetDocument(renameSymbolDeclarationLocation.SourceTree).Id;

                this.renameAnnotations = new AnnotationTable <RenameAnnotation>(RenameAnnotation.Kind);
            }
コード例 #5
0
 public RenameRewriterParameters(
     RenameAnnotation renamedSymbolDeclarationAnnotation,
     Document document,
     SemanticModel semanticModel,
     SyntaxNode syntaxRoot,
     string replacementText,
     string originalText,
     ICollection<string> possibleNameConflicts,
     Dictionary<TextSpan, RenameLocation> renameLocations,
     ISet<TextSpan> stringAndCommentTextSpans,
     ISet<TextSpan> conflictLocationSpans,
     Solution originalSolution,
     ISymbol renameSymbol,
     bool replacementTextValid,
     CancellationToken cancellationToken,
     RenamedSpansTracker renameSpansTracker,
     OptionSet optionSet,
     AnnotationTable<RenameAnnotation> renameAnnotations)
 {
     this.RenamedSymbolDeclarationAnnotation = renamedSymbolDeclarationAnnotation;
     this.Document = document;
     this.SemanticModel = semanticModel;
     this.SyntaxRoot = syntaxRoot;
     this.OriginalSyntaxTree = semanticModel.SyntaxTree;
     this.ReplacementText = replacementText;
     this.OriginalText = originalText;
     this.PossibleNameConflicts = possibleNameConflicts;
     this.RenameLocations = renameLocations;
     this.StringAndCommentTextSpans = stringAndCommentTextSpans;
     this.ConflictLocationSpans = conflictLocationSpans;
     this.OriginalSolution = originalSolution;
     this.RenameSymbol = renameSymbol;
     this.ReplacementTextValid = replacementTextValid;
     this.CancellationToken = cancellationToken;
     this.RenameSpansTracker = renameSpansTracker;
     this.OptionSet = optionSet;
     this.RenameAnnotations = renameAnnotations;
 }
コード例 #6
0
            public RenameRewriter(RenameRewriterParameters parameters)
                : base(visitIntoStructuredTrivia: true)
            {
                _documentId = parameters.Document.Id;
                _renameRenamableSymbolDeclaration = parameters.RenamedSymbolDeclarationAnnotation;
                _solution = parameters.OriginalSolution;
                _replacementText = parameters.ReplacementText;
                _originalText = parameters.OriginalText;
                _possibleNameConflicts = parameters.PossibleNameConflicts;
                _renameLocations = parameters.RenameLocations;
                _conflictLocations = parameters.ConflictLocationSpans;
                _cancellationToken = parameters.CancellationToken;
                _semanticModel = parameters.SemanticModel;
                _renamedSymbol = parameters.RenameSymbol;
                _replacementTextValid = parameters.ReplacementTextValid;
                _renameSpansTracker = parameters.RenameSpansTracker;
                _isRenamingInStrings = parameters.OptionSet.GetOption(RenameOptions.RenameInStrings);
                _isRenamingInComments = parameters.OptionSet.GetOption(RenameOptions.RenameInComments);
                _stringAndCommentTextSpans = parameters.StringAndCommentTextSpans;
                _renameAnnotations = parameters.RenameAnnotations;

                _aliasSymbol = _renamedSymbol as IAliasSymbol;
                _renamableDeclarationLocation = _renamedSymbol.Locations.FirstOrDefault(loc => loc.IsInSource && loc.SourceTree == _semanticModel.SyntaxTree);
                _isVerbatim = _replacementText.StartsWith("@", StringComparison.Ordinal);

                _simplificationService = parameters.Document.Project.LanguageServices.GetService<ISimplificationService>();
                _semanticFactsService = parameters.Document.Project.LanguageServices.GetService<ISemanticFactsService>();
            }
コード例 #7
0
            public RenameRewriter(RenameRewriterParameters parameters)
                : base(visitIntoStructuredTrivia: true)
            {
                this.documentId = parameters.Document.Id;
                this.renameRenamableSymbolDeclaration = parameters.RenamedSymbolDeclarationAnnotation;
                this.solution = parameters.OriginalSolution;
                this.replacementText = parameters.ReplacementText;
                this.originalText = parameters.OriginalText;
                this.possibleNameConflicts = parameters.PossibleNameConflicts;
                this.renameLocations = parameters.RenameLocations;
                this.conflictLocations = parameters.ConflictLocationSpans;
                this.cancellationToken = parameters.CancellationToken;
                this.semanticModel = (SemanticModel)parameters.SemanticModel;
                this.renamedSymbol = parameters.RenameSymbol;
                this.replacementTextValid = parameters.ReplacementTextValid;
                this.renameSpansTracker = parameters.RenameSpansTracker;
                this.isRenamingInStrings = parameters.OptionSet.GetOption(RenameOptions.RenameInStrings);
                this.isRenamingInComments = parameters.OptionSet.GetOption(RenameOptions.RenameInComments);
                this.stringAndCommentTextSpans = parameters.StringAndCommentTextSpans;
                this.renameAnnotations = parameters.RenameAnnotations;

                this.aliasSymbol = this.renamedSymbol as IAliasSymbol;
                this.renamableDeclarationLocation = this.renamedSymbol.Locations.Where(loc => loc.IsInSource && loc.SourceTree == semanticModel.SyntaxTree).FirstOrDefault();
                this.isVerbatim = this.replacementText.StartsWith("@");

                this.simplificationService = LanguageService.GetService<ISimplificationService>(parameters.Document);
            }