Exemple #1
0
        /// <summary>
        /// This does the actual node construction
        /// </summary>
        private Node(NodeProvider provider, ITextSnapshot snapshot, SourceLocation location, int length)
        {
            this.Provider = provider;

            snapshotSpan = new SnapshotSpan(snapshot, location.Position, length);
            int offset = 0;

            ITextSnapshotLine line = snapshot.GetLineFromPosition(location.Position);

            // if the Value list is not empty, expand the snapshotSpan
            // to include leading whitespaces, so that when a user
            // types smth in this space he will get the dropdown
            for (; location.Position - offset > line.Extent.Start.Position; offset++)
            {
                switch (snapshot[location.Position - offset - 1])
                {
                case ' ':
                case '\t':
                    continue;

                default:
                    break;
                }
                break;
            }

            extensionSpan = new SnapshotSpan(snapshot, location.Position - offset, offset);
        }
Exemple #2
0
        /// <summary>
        /// Creates the designer (proxy) node over the real syntax node passed in as a parameter
        /// Also recursively creates child nodes for all 'real' node children
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="snapshot"></param>
        /// <param name="node"></param>
        public Node(NodeProvider provider, Node parent, ITextSnapshot snapshot, AstNode node) : this(provider, snapshot, node.Location, node.Span.Length)
        {
            Parent       = parent;
            this.astnode = node;

            foreach (AstNode child in node.ChildNodes)
            {
                if (child != null)
                {
                    children.Add(new Node(provider, this, snapshot, child));
                }
            }
        }
Exemple #3
0
        public HighlightWordTagger(ITextView view, ITextBuffer sourceBuffer, ITextSearchService textSearchService, ITextStructureNavigator textStructureNavigator)
        {
            nodeProvider = (new NodeProviderBroker()).GetNodeProvider(sourceBuffer);

            this.View                        = view;
            this.SourceBuffer                = sourceBuffer;
            this.TextSearchService           = textSearchService;
            this.TextStructureNavigator      = textStructureNavigator;
            this.WordSpans                   = new NormalizedSnapshotSpanCollection();
            this.CurrentWord                 = null;
            this.View.Caret.PositionChanged += CaretPositionChanged;
            this.View.LayoutChanged         += ViewLayoutChanged;
        }
Exemple #4
0
        public TripleClickMouseProcessor(IWpfTextView view, NodeProvider nodeprovider = null)
        {
            _view = view;

            _view.LayoutChanged += (sender, args) =>
            {
                if (_dragging && args.OldSnapshot != args.NewSnapshot)
                {
                    StopDrag();
                }
            };

            nodeProvider = nodeprovider;
        }
Exemple #5
0
        public NodeProvider GetNodeProvider(ITextBuffer buffer)
        {
            NodeProvider provider;

            if (!buffer.Properties.TryGetProperty(typeof(NodeProvider), out provider))
            {
                LanguageOption options;
                if (!buffer.Properties.TryGetProperty(typeof(LanguageOption), out options))
                {
                    if (buffer.CurrentSnapshot.LineCount > 0)
                    { // Determine language
                        // try to determine from comments
                        if (!Utils.TryGetLanguageDeclaration(buffer.CurrentSnapshot.GetLineFromLineNumber(0).GetText(), out options))
                        {// try to determine from file extension
                            ITextDocument doc;
                            if (buffer.Properties.TryGetProperty(typeof(ITextDocument), out doc))
                            {
                                if (doc.FilePath.EndsWith(".uosl"))
                                {
                                    options = LanguageOption.Extended;
                                }
                                else
                                {
                                    options = LanguageOption.Enhanced;
                                }
                            }
                        }
                    }

                    buffer.Properties.AddProperty(typeof(LanguageOption), options);
                }
                parser = new Parser(UOSL.Service.UOSLBase.GetGrammar(options));
                buffer.Properties.AddProperty(typeof(NodeProvider), provider = new NodeProvider(parser, buffer));
            }
            return(provider);
        }
Exemple #6
0
 /// <summary>
 /// Adds a "nodeless" node, primarily intended to denote comments.
 /// </summary>
 public Node(NodeProvider provider, Node parent, ITextSnapshot snapshot, Token token) : this(provider, snapshot, token.Location, token.Length)
 {
 }
Exemple #7
0
 public SignatureHelpSource(ITextBuffer textBuffer)
 {
     nodeprovider = nbroker.GetNodeProvider(textBuffer);
     m_textBuffer = textBuffer;
 }