当前位置: 首页>>代码示例>>C#>>正文


C# VBEditor.QualifiedSelection类代码示例

本文整理汇总了C#中Rubberduck.VBEditor.QualifiedSelection的典型用法代码示例。如果您正苦于以下问题:C# QualifiedSelection类的具体用法?C# QualifiedSelection怎么用?C# QualifiedSelection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QualifiedSelection类属于Rubberduck.VBEditor命名空间,在下文中一共展示了QualifiedSelection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenameProjectQuickFix

 public RenameProjectQuickFix(ParserRuleContext context, QualifiedSelection selection, Declaration target, RubberduckParserState state, ICodePaneWrapperFactory wrapperFactory)
     : base(context, selection, string.Format(RubberduckUI.Rename_DeclarationType, RubberduckUI.ResourceManager.GetString("DeclarationType_" + DeclarationType.Project, RubberduckUI.Culture)))
 {
     _target = target;
     _state = state;
     _wrapperFactory = wrapperFactory;
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:7,代码来源:DefaultProjectNameInspectionResult.cs

示例2: FindSelectedDeclaration

        public Declaration FindSelectedDeclaration(QualifiedSelection selection, IEnumerable<DeclarationType> types, Func<Declaration,Selection> selector = null)
        {
            var userDeclarations = _declarations.Where(item => !item.IsBuiltIn);
            var declarations = userDeclarations.Where(item => types.Contains(item.DeclarationType)
                && item.QualifiedName.QualifiedModuleName == selection.QualifiedName).ToList();

            var declaration = declarations.SingleOrDefault(item => 
                selector == null
                    ? item.Selection.Contains(selection.Selection)
                    : selector(item).Contains(selection.Selection));

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

            // if we haven't returned yet, then we must be on an identifier reference.
            declaration = _declarations.SingleOrDefault(item => !item.IsBuiltIn
                && types.Contains(item.DeclarationType)
                && item.References.Any(reference =>
                reference.QualifiedModuleName == selection.QualifiedName
                && reference.Selection.Contains(selection.Selection)));

            return declaration;
        }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:25,代码来源:Declarations.cs

示例3: AcquireTarget

 private void AcquireTarget(QualifiedSelection selection)
 {
     TargetDeclaration = Declarations.FindTarget(selection, ValidDeclarationTypes);
     TargetDeclaration = PromptIfTargetImplementsInterface();
     TargetDeclaration = GetEvent();
     TargetDeclaration = GetGetter();
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:7,代码来源:ReorderParametersModel.cs

示例4: IgnoreOnceQuickFix

 public IgnoreOnceQuickFix(ParserRuleContext context, QualifiedSelection selection, string inspectionName) 
     : base(context, selection, InspectionsUI.IgnoreOnce)
 {
     _inspectionName = inspectionName;
     _annotationText = "'" + Parsing.Grammar.Annotations.AnnotationMarker +
                       Parsing.Grammar.Annotations.IgnoreInspection + ' ' + inspectionName;
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:7,代码来源:IgnoreOnceQuickFix.cs

示例5: RemoveUnusedParameterQuickFix

 public RemoveUnusedParameterQuickFix(ParserRuleContext context, QualifiedSelection selection, 
     RemoveParametersRefactoring quickFixRefactoring, RubberduckParserState parseResult)
     : base(context, selection, InspectionsUI.RemoveUnusedParameterQuickFix)
 {
     _quickFixRefactoring = quickFixRefactoring;
     _parseResult = parseResult;
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:7,代码来源:ParameterNotUsedInspectionResult.cs

示例6: MoveFieldCloserToUsageQuickFix

 public MoveFieldCloserToUsageQuickFix(ParserRuleContext context, QualifiedSelection selection, Declaration target, RubberduckParserState parseResult, ICodePaneWrapperFactory wrapperFactory, IMessageBox messageBox)
     : base(context, selection, string.Format(InspectionsUI.MoveFieldCloserToUsageInspectionResultFormat, target.IdentifierName))
 {
     _target = target;
     _parseResult = parseResult;
     _wrapperFactory = wrapperFactory;
     _messageBox = messageBox;
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:8,代码来源:MoveFieldCloserToUsageInspectionResult.cs

示例7: EncapsulateFieldModel

        public EncapsulateFieldModel(RubberduckParserState parseResult, QualifiedSelection selection)
        {
            IList<Declaration> declarations = parseResult.AllDeclarations
                                                        .Where(d => !d.IsBuiltIn && d.DeclarationType == DeclarationType.Variable)
                                                        .ToList();

            TargetDeclaration = declarations.FindVariable(selection);
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:8,代码来源:EncapsulateFieldModel.cs

示例8: ExtractMethodModel

        public ExtractMethodModel(IActiveCodePaneEditor editor, IEnumerable<Declaration> declarations, QualifiedSelection selection)
        {
            var items = declarations.ToList();

            _sourceMember = items.FindSelectedDeclaration(selection, DeclarationExtensions.ProcedureTypes, d => ((ParserRuleContext)d.Context.Parent).GetSelection());
            if (_sourceMember == null)
            {
                throw new InvalidOperationException("Invalid selection.");
            }

            _extractedMethod = new ExtractedMethod();

            _selection = selection;
            _selectedCode = editor.GetLines(selection.Selection);

            var inScopeDeclarations = items.Where(item => item.ParentScope == _sourceMember.Scope).ToList();

            var inSelection = inScopeDeclarations.SelectMany(item => item.References)
                .Where(item => selection.Selection.Contains(item.Selection))
                .ToList();

            var usedInSelection = new HashSet<Declaration>(inScopeDeclarations.Where(item =>
                selection.Selection.Contains(item.Selection) ||
                item.References.Any(reference => inSelection.Contains(reference))));

            var usedBeforeSelection = new HashSet<Declaration>(inScopeDeclarations.Where(item =>
                item.Selection.StartLine < selection.Selection.StartLine ||
                item.References.Any(reference => reference.Selection.StartLine < selection.Selection.StartLine)));

            var usedAfterSelection = new HashSet<Declaration>(inScopeDeclarations.Where(item =>
                item.Selection.StartLine > selection.Selection.StartLine ||
                item.References.Any(reference => reference.Selection.StartLine > selection.Selection.EndLine)));

            // identifiers used inside selection and before selection (or if it's a parameter) are candidates for parameters:
            var input = inScopeDeclarations.Where(item =>
                usedInSelection.Contains(item) && (usedBeforeSelection.Contains(item) || item.DeclarationType == DeclarationType.Parameter)).ToList();

            // identifiers used inside selection and after selection are candidates for return values:
            var output = inScopeDeclarations.Where(item =>
                usedInSelection.Contains(item) && usedAfterSelection.Contains(item))
                .ToList();

            // identifiers used only inside and/or after selection are candidates for locals:
            _locals = inScopeDeclarations.Where(item => item.DeclarationType != DeclarationType.Parameter && (
                item.References.All(reference => inSelection.Contains(reference))
                || (usedAfterSelection.Contains(item) && (!usedBeforeSelection.Contains(item)))))
                .ToList();

            // locals that are only used in selection are candidates for being moved into the new method:
            _declarationsToMove = _locals.Where(item => !usedAfterSelection.Contains(item)).ToList();

            _output = output.Select(declaration =>
                new ExtractedParameter(declaration.AsTypeName, ExtractedParameter.PassedBy.ByRef, declaration.IdentifierName));

            _input = input.Where(declaration => !output.Contains(declaration))
                .Select(declaration =>
                    new ExtractedParameter(declaration.AsTypeName, ExtractedParameter.PassedBy.ByVal, declaration.IdentifierName));
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:58,代码来源:ExtractMethodModel.cs

示例9: ToDoItem

 public ToDoItem(TodoPriority priority, string description, QualifiedSelection qualifiedSelection)
 {
     _priority = priority;
     _description = description;
     _selection = qualifiedSelection;
     _projectName = qualifiedSelection.QualifiedName.Project.Name;
     _moduleName = qualifiedSelection.QualifiedName.Component.Name;
     _lineNumber = qualifiedSelection.Selection.StartLine;
 }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:9,代码来源:ToDoItem.cs

示例10: QuickFix

        public void QuickFix(VBProjectParseResult parseResult, QualifiedSelection selection)
        {
            _model = new RemoveParametersModel(parseResult, selection);
            var target = _model.Declarations.FindSelection(selection, new[] { DeclarationType.Parameter });

            // ReSharper disable once PossibleUnintendedReferenceComparison
            _model.Parameters.Find(param => param.Declaration == target).IsRemoved = true;
            RemoveParameters();
        }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:9,代码来源:RemoveParametersRefactoring.cs

示例11: RenameModel

        public RenameModel(VBE vbe, VBProjectParseResult parseResult, QualifiedSelection selection)
        {
            _vbe = vbe;
            _parseResult = parseResult;
            _declarations = parseResult.Declarations;
            _selection = selection;

            AcquireTarget(out _target, Selection);
        }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:9,代码来源:RenameModel.cs

示例12: AcquireTarget

        private void AcquireTarget(out Declaration target, QualifiedSelection selection)
        {
            target = _declarations
                .Where(item => !item.IsBuiltIn && item.DeclarationType != DeclarationType.ModuleOption)
                .FirstOrDefault(item => item.IsSelected(selection)
                                      || item.References.Any(r => r.IsSelected(selection)));

            PromptIfTargetImplementsInterface(ref target);
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:9,代码来源:RenameModel.cs

示例13: RemoveParametersModel

        public RemoveParametersModel(VBProjectParseResult parseResult, QualifiedSelection selection)
        {
            _parseResult = parseResult;
            _declarations = parseResult.Declarations;

            AcquireTarget(selection);

            Parameters = new List<Parameter>();
            LoadParameters();
        }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:10,代码来源:RemoveParametersModel.cs

示例14: RenameModel

        public RenameModel(VBE vbe, RubberduckParserState parseResult, QualifiedSelection selection, IMessageBox messageBox)
        {
            _vbe = vbe;
            _parseResult = parseResult;
            _declarations = parseResult.AllDeclarations.ToList();
            _selection = selection;
            _messageBox = messageBox;

            AcquireTarget(out _target, Selection);
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:10,代码来源:RenameModel.cs

示例15: EncapsulatePublicField_WithLetter

        public void EncapsulatePublicField_WithLetter()
        {
            //Input
            const string inputCode =
@"Public fizz As Integer";
            var selection = new Selection(1, 1, 1, 1);

            //Expectation
            const string expectedCode =
@"Private fizz As Integer

Public Property Get Name() As Integer
    Name = fizz
End Property

Public Property Let Name(ByVal value As Integer)
    fizz = value
End Property
";

            //Arrange
            var builder = new MockVbeBuilder();
            VBComponent component;
            var vbe = builder.BuildFromSingleStandardModule(inputCode, out component);
            var project = vbe.Object.VBProjects.Item(0);
            var module = project.VBComponents.Item(0).CodeModule;
            var codePaneFactory = new CodePaneWrapperFactory();
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var qualifiedSelection = new QualifiedSelection(new QualifiedModuleName(component), selection);

            var model = new EncapsulateFieldModel(parser.State, qualifiedSelection)
            {
                ImplementLetSetterType = true,
                ImplementSetSetterType = false,
                ParameterName = "value",
                PropertyName = "Name"
            };

            //SetupFactory
            var factory = SetupFactory(model);

            //Act
            var refactoring = new EncapsulateFieldRefactoring(factory.Object, new ActiveCodePaneEditor(vbe.Object, codePaneFactory));
            refactoring.Refactor(qualifiedSelection);

            //Assert
            Assert.AreEqual(expectedCode, module.Lines());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:54,代码来源:EncapsulateFieldTests.cs


注:本文中的Rubberduck.VBEditor.QualifiedSelection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。