コード例 #1
0
        private static void ProcessT4FeatureBlock(
            [NotNull] IT4FeatureBlock featureBlock,
            [NotNull] CodeStructureElement parentElement,
            [NotNull] ICSharpFile cSharpFile,
            [NotNull] ISecondaryRangeTranslator secondaryRangeTranslator,
            [NotNull] CSharpCodeStructureProcessingState state
            )
        {
            TreeTextRange t4Range     = featureBlock.Code.GetTreeTextRange();
            TreeTextRange cSharpRange = secondaryRangeTranslator.OriginalToGenerated(t4Range);

            if (!cSharpRange.IsValid())
            {
                return;
            }

            TreeOffset cSharpStart = cSharpRange.StartOffset;
            TreeOffset cSharpEnd   = cSharpRange.EndOffset;

            ITreeNode containingNode = cSharpFile.FindNodeAt(cSharpRange);

            if (containingNode == null)
            {
                return;
            }

            for (ITreeNode node = containingNode.FirstChild; node != null; node = node.NextSibling)
            {
                TreeOffset nodeStart = node.GetTreeStartOffset();
                if (nodeStart >= cSharpStart && nodeStart < cSharpEnd)
                {
                    ProcessCSharpNode(node, parentElement, state);
                }
            }
        }
コード例 #2
0
        public void ExecuteEx(ISolution solution, IDataContext context)
        {
            ITextControl editor = context.GetData(JetBrains.TextControl.DataContext.DataConstants.TEXT_CONTROL);

            Logger.Assert(editor != null, "Condition (editor != null) is false");

            IDocument document = context.GetData(JetBrains.DocumentModel.DataConstants.DOCUMENT);

            if (editor == null || document == null)
            {
                throw new ArgumentException("context");
            }
            ICSharpFile file = solution.GetPsiServices().GetPsiFile <CSharpLanguage>(new DocumentRange(editor.Document, editor.Caret.Offset())) as ICSharpFile;

            if (file == null)
            {
                return;
            }

            ITreeNode element = file.FindNodeAt(new TreeTextRange(new TreeOffset(editor.Caret.Offset())));

            HandleElement(editor, element, editor.Caret.Offset());
        }