示例#1
0
        protected virtual TaggedContentSpan TagComments(SnapshotSpan snapshotSpan, IMappingTagSpan <IClassificationTag> tagSpan)
        {
            // find spans that the language service has already classified as comments ...
            if (IsComment(tagSpan.Tag.ClassificationType) == false)
            {
                return(null);
            }
            var text = snapshotSpan.GetText();
            //NOTE: markup comment span does not include comment start token
            var endOfCommentStartToken = GetCommentStartIndex(text);

            if (endOfCommentStartToken < 0)
            {
                return(null);
            }
            var tl           = text.Length;
            var commentStart = endOfCommentStartToken;

            while (commentStart < tl)
            {
                if (Char.IsWhiteSpace(text[commentStart]))
                {
                    ++commentStart;
                }
                else
                {
                    break;
                }
            }

            var contentEnd = GetCommentEndIndex(text);

            ClassificationTag ctag  = null;
            CommentLabel      label = null;
            var contentStart        = 0;

            foreach (var item in Config.Instance.Labels)
            {
                var c = commentStart + item.LabelLength;
                if (c >= tl ||
                    text.IndexOf(item.Label, commentStart, item.Comparison) != commentStart)
                {
                    continue;
                }

                var followingChar = text[c];
                if (item.AllowPunctuationDelimiter && Char.IsPunctuation(followingChar))
                {
                    c++;
                }
                else if (!Char.IsWhiteSpace(followingChar))
                {
                    continue;
                }

                if (label == null || label.LabelLength < item.LabelLength)
                {
                    ctag         = __CommentClassifications[(int)item.StyleID];
                    label        = item;
                    contentStart = c;
                }
            }

            if (contentStart == 0 || ctag == null)
            {
                return(null);
            }

            // ignore whitespaces in content
            while (contentStart < tl)
            {
                if (Char.IsWhiteSpace(text[contentStart]))
                {
                    ++contentStart;
                }
                else
                {
                    break;
                }
            }
            while (contentEnd > contentStart)
            {
                if (Char.IsWhiteSpace(text[contentEnd - 1]))
                {
                    --contentEnd;
                }
                else
                {
                    break;
                }
            }

            return(label.StyleApplication == CommentStyleApplication.Tag
                                ? new TaggedContentSpan(snapshotSpan.Snapshot, ctag, snapshotSpan.Start + commentStart, label.LabelLength, contentStart - commentStart, contentEnd - contentStart)
                                : label.StyleApplication == CommentStyleApplication.Content
                                ? new TaggedContentSpan(snapshotSpan.Snapshot, ctag, snapshotSpan.Start + contentStart, contentEnd - contentStart, 0, contentEnd - contentStart)
                                : new TaggedContentSpan(snapshotSpan.Snapshot, ctag, snapshotSpan.Start + commentStart, contentEnd - commentStart, contentStart - commentStart, contentEnd - contentStart));
        }
示例#2
0
 protected override TaggedContentSpan TagComments(SnapshotSpan snapshotSpan, IMappingTagSpan <IClassificationTag> tagSpan)
 {
     if (Config.Instance.MarkerOptions.MatchFlags(MarkerOptions.CompilerDirective) &&
         tagSpan.Tag.ClassificationType == _PreprocessorKeyword)
     {
         return(Matches(snapshotSpan, "pragma") || Matches(snapshotSpan, "if") || Matches(snapshotSpan, "else")                     /*|| Matches(snapshotSpan, "region")*/
                                     ? new TaggedContentSpan(snapshotSpan.Snapshot, tagSpan.Tag, snapshotSpan.Start, snapshotSpan.Length, 0, 0)
                                     : null);
     }
     return(base.TagComments(snapshotSpan, tagSpan));
 }
        /// <summary>
        /// Determine which pieces of Quickinfo content should be displayed
        /// </summary>
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;
            try {
                DateTime time1 = DateTime.Now;

                ITextSnapshot snapshot     = _sourceBuffer.CurrentSnapshot;
                var           triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);
                if (triggerPoint == null)
                {
                    return;
                }
                string keyword = "";

                IEnumerable <IMappingTagSpan <AsmTokenTag> > enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint));

                if (enumerator.Count() > 0)
                {
                    if (false)
                    {
                        // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless...
                        if (enumerator.Count() > 1)
                        {
                            foreach (IMappingTagSpan <AsmTokenTag> v in enumerator)
                            {
                                AsmDudeToolsStatic.Output(string.Format("WARNING: {0}:AugmentQuickInfoSession. more than one tag! \"{1}\"", this.ToString(), v.Span.GetSpans(_sourceBuffer).First().GetText()));
                            }
                        }
                    }

                    IMappingTagSpan <AsmTokenTag> asmTokenTag = enumerator.First();
                    SnapshotSpan tagSpan = asmTokenTag.Span.GetSpans(_sourceBuffer).First();
                    keyword = tagSpan.GetText();

                    //AsmDudeToolsStatic.Output(string.Format("INFO: {0}:AugmentQuickInfoSession. keyword=\"{1}\"; type={2}", this.ToString(), keyword, asmTokenTag.Tag.type));
                    string keywordUpper = keyword.ToUpper();
                    applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive);

                    TextBlock description = null;

                    switch (asmTokenTag.Tag.type)
                    {
                    case AsmTokenType.Misc: {
                        description = new TextBlock();
                        description.Inlines.Add(makeRun1("Keyword "));
                        description.Inlines.Add(makeRun2(keyword, Settings.Default.SyntaxHighlighting_Misc));

                        string descr = this._asmDudeTools.getDescription(keywordUpper);
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)));
                        }
                        break;
                    }

                    case AsmTokenType.Directive: {
                        description = new TextBlock();
                        description.Inlines.Add(makeRun1("Directive "));
                        description.Inlines.Add(makeRun2(keyword, Settings.Default.SyntaxHighlighting_Directive));

                        string descr = this._asmDudeTools.getDescription(keywordUpper);
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)));
                        }
                        break;
                    }

                    case AsmTokenType.Register: {
                        description = new TextBlock();
                        description.Inlines.Add(makeRun1("Register "));
                        description.Inlines.Add(makeRun2(keyword, Settings.Default.SyntaxHighlighting_Register));

                        string descr = this._asmDudeTools.getDescription(keywordUpper);
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)));
                        }
                        break;
                    }

                    case AsmTokenType.Mnemonic:
                    case AsmTokenType.Jump:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(makeRun1("Mnemonic "));
                        description.Inlines.Add(makeRun2(keyword, Settings.Default.SyntaxHighlighting_Opcode));

                        string descr = this._asmDudeTools.mnemonicStore.getDescription(AsmSourceTools.parseMnemonic(keywordUpper));
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)));
                        }
                        break;
                    }

                    case AsmTokenType.Label: {
                        description = new TextBlock();
                        description.Inlines.Add(makeRun1("Label "));
                        description.Inlines.Add(makeRun2(keyword, Settings.Default.SyntaxHighlighting_Label));

                        string descr = this.getLabelDescription(keyword);
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)));
                        }
                        break;
                    }

                    case AsmTokenType.LabelDef: {
                        description = new TextBlock();
                        description.Inlines.Add(makeRun1("Label "));
                        description.Inlines.Add(makeRun2(keyword, Settings.Default.SyntaxHighlighting_Label));

                        string descr = this.getLabelDefDescription(keyword);
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)));
                        }
                        break;
                    }

                    case AsmTokenType.Constant: {
                        description = new TextBlock();
                        description.Inlines.Add(makeRun1("Constant "));
                        description.Inlines.Add(makeRun2(keyword, Settings.Default.SyntaxHighlighting_Constant));
                        break;
                    }

                    default:
                        //description = new TextBlock();
                        //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type));
                        break;
                    }
                    if (description != null)
                    {
                        description.FontSize   = AsmDudeToolsStatic.getFontSize() + 2;
                        description.FontFamily = AsmDudeToolsStatic.getFontType();
                        //AsmDudeToolsStatic.Output(string.Format("INFO: {0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily));
                        quickInfoContent.Add(description);
                    }
                }
                AsmDudeToolsStatic.printSpeedWarning(time1, "QuickInfo");
            } catch (Exception e) {
                AsmDudeToolsStatic.Output(string.Format("ERROR: {0}:AugmentQuickInfoSession; e={1}", this.ToString(), e.ToString()));
            }
        }
示例#4
0
        public static ITagSpan <IClassificationTag> ToTagSpan(this IMappingTagSpan <IClassificationTag> tagSpan, ITextSnapshot snapshot)
        {
            var span = tagSpan.GetSpan(snapshot);

            return(new TagSpan <IClassificationTag>(span, tagSpan.Tag));
        }
示例#5
0
 private Mark(IMappingTagSpan <IVsVisibleTextMarkerTag> tag)
 {
     _tag      = tag.Tag;
     _position = tag.Span.Start;
 }
        public static ITagSpan <T> MapToSingleSnapshotSpan <T>(this IWpfTextView textView, IMappingTagSpan <T> mappingTagSpan) where T : ITag
        {
            if (mappingTagSpan == null || textView.TextSnapshot == null)
            {
                return(null);
            }

            var tagSpans = mappingTagSpan.Span.GetSpans(textView.TextSnapshot);

            if (!tagSpans.Any())
            {
                return(null);
            }

            return(new TagSpan <T>(tagSpans[0], mappingTagSpan.Tag));
        }
示例#7
0
        private void CreateBlockAdornments(IMappingTagSpan <IBlockTag> tag, NormalizedSnapshotSpanCollection newOrReformattedSpans, double left, double right)
        {
            NormalizedSnapshotSpanCollection spans = tag.Span.GetSpans(_view.TextSnapshot);

            if (spans.Count > 0)
            {
                //Get the start of the tag's span (which could be out of the view or not even mappable to
                //the view's text snapshot).
                var statementStart = _view.BufferGraph.MapUpToSnapshot(tag.Tag.StatementStart, PointTrackingMode.Positive, PositionAffinity.Predecessor, _view.TextSnapshot);
                if (statementStart.HasValue)
                {
                    var end = _view.BufferGraph.MapUpToSnapshot(tag.Tag.Span.End, PointTrackingMode.Positive, PositionAffinity.Predecessor, _view.TextSnapshot);
                    if (end.HasValue)
                    {
                        //Get the full extent of the block tag so that its adornments will be destroyed if anything in the block changes.
                        SnapshotSpan extent = new SnapshotSpan(statementStart.Value, end.Value);

                        bool intersecting = newOrReformattedSpans.IntersectsWith(new NormalizedSnapshotSpanCollection(extent));
                        if (intersecting)
                        {
                            var start = _view.BufferGraph.MapUpToSnapshot(tag.Tag.Span.Start, PointTrackingMode.Positive, PositionAffinity.Predecessor, _view.TextSnapshot);
                            if (start.HasValue)
                            {
                                ITextSnapshotLine startLine = start.Value.GetContainingLine();

                                if (_showAdornments)
                                {
                                    double x = -1.0;
                                    foreach (var span in spans)
                                    {
                                        if (span.OverlapsWith(_view.TextViewLines.FormattedSpan))
                                        {
                                            ITextViewLine spanTop = _view.TextViewLines.GetTextViewLineContainingBufferPosition(span.Start);
                                            double        yTop    = (spanTop == null) ? _view.TextViewLines.FirstVisibleLine.Top : spanTop.Bottom;

                                            ITextViewLine spanBottom = _view.TextViewLines.GetTextViewLineContainingBufferPosition(span.End);
                                            double        yBottom    = (spanBottom == null) ? _view.TextViewLines.LastVisibleLine.Bottom : spanBottom.Top;

                                            if (yBottom > yTop)
                                            {
                                                if (x < 0.0)
                                                {
                                                    //We have a starting point ... but it may be the wrong one. We have three cases to consider:
                                                    //1)        if (foo) {
                                                    //          |                               //Line goes here
                                                    //
                                                    //2)        if (foo)
                                                    //              {
                                                    //              |                           //Line goes here
                                                    //
                                                    //3)        if (bar &&
                                                    //              foo) {
                                                    //          |                               //Line goes here
                                                    //
                                                    //
                                                    //In each of these cases, we need to find the position of the first non-whitespace character on the line
                                                    SnapshotPoint blockStart = FindFirstNonwhitespace(startLine);

                                                    //If the span start's on the first non-whitespace character of the line, then we have case 2
                                                    //(& we're done).
                                                    if (blockStart != start.Value)
                                                    {
                                                        //Case 1 or 3 ... see if the start & statement start are on the same line.
                                                        //Is the span start on the same line as the statement start (if so, we have case 1 & are done).
                                                        if (!startLine.Extent.Contains(statementStart.Value))
                                                        {
                                                            //Case 3.
                                                            blockStart = statementStart.Value;
                                                        }
                                                    }

                                                    //Get the x-coordinate of the adornment == middle of the character that starts the block.
                                                    ITextViewLine tagTop = _view.GetTextViewLineContainingBufferPosition(blockStart);
                                                    TextBounds    bounds = tagTop.GetCharacterBounds(blockStart);
                                                    x = Math.Floor((bounds.Left + bounds.Right) * 0.5);   //Make sure this is only a pixel wide.
                                                }

                                                this.CreateBlockAdornment(tag.Tag, extent, x, yTop, yBottom);
                                            }
                                        }
                                    }
                                }

                                if (_showMethodSeparator && (tag.Tag.Type == BlockType.Method) && (startLine.End < end.Value))
                                {
                                    var point = _view.BufferGraph.MapUpToBuffer(end.Value, PointTrackingMode.Negative, PositionAffinity.Predecessor, _view.VisualSnapshot.TextBuffer);
                                    if (point.HasValue)
                                    {
                                        ITextViewLine spanBottom = _view.TextViewLines.GetTextViewLineContainingBufferPosition(end.Value);
                                        if (spanBottom != null)
                                        {
                                            GeometryAdornment adornment = new GeometryAdornment(_coloring.MethodSeparatorAndHighlightColoring.LineBrush,
                                                                                                new RectangleGeometry(new Rect(0.0, 0.0, right - left, 1.0)));

                                            Canvas.SetLeft(adornment, left);
                                            Canvas.SetTop(adornment, spanBottom.Bottom - 1.0);

                                            _methodSeparators.Add(adornment);
                                            _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, extent, adornment, adornment, OnMethodSeparatorRemoved);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#8
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            WriteOutputMessage("-->> AugmentCompletionSessions");
            try
            {
                if (XSettings.DisableCodeCompletion)
                {
                    return;
                }
                XSharpModel.ModelWalker.Suspend();
                if (_disposed)
                {
                    throw new ObjectDisposedException("XSharpCompletionSource");
                }
                _showTabs      = XSettings.EditorCompletionListTabs;
                _keywordsInAll = XSettings.EditorKeywordsInAll;

                // Where does the StartSession has been triggered ?
                ITextSnapshot snapshot     = _buffer.CurrentSnapshot;
                var           triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);
                if (triggerPoint == null)
                {
                    return;
                }
                // What is the character were it starts ?
                var line = triggerPoint.GetContainingLine();
                //var triggerposinline = triggerPoint.Position - 2 - line.Start;
                //var afterChar = line.GetText()[triggerposinline];
                //if (afterChar == ' ' || afterChar == '\t')
                //    return;

                // The "parameters" coming from CommandFilter
                uint cmd       = 0;
                char typedChar = '\0';
                bool autoType  = false;
                session.Properties.TryGetProperty(XsCompletionProperties.Command, out cmd);
                VSConstants.VSStd2KCmdID nCmdId = (VSConstants.VSStd2KCmdID)cmd;
                session.Properties.TryGetProperty(XsCompletionProperties.Char, out typedChar);
                session.Properties.TryGetProperty(XsCompletionProperties.AutoType, out autoType);
                bool showInstanceMembers = (typedChar == ':') || ((typedChar == '.') && _file.Project.ParseOptions.AllowDotForInstanceMembers);

                ////////////////////////////////////////////
                //
                SnapshotSpan  lineSpan      = new SnapshotSpan(line.Start, line.Length);
                SnapshotPoint caret         = triggerPoint;
                var           tagAggregator = aggregator.CreateTagAggregator <IClassificationTag>(_buffer);
                var           tags          = tagAggregator.GetTags(lineSpan);
                IMappingTagSpan <IClassificationTag> lastTag = null;
                foreach (var tag in tags)
                {
                    //tagList.Add(tag);
                    SnapshotPoint ptStart = tag.Span.Start.GetPoint(_buffer, PositionAffinity.Successor).Value;
                    SnapshotPoint ptEnd   = tag.Span.End.GetPoint(_buffer, PositionAffinity.Successor).Value;
                    if ((ptStart != null) && (ptEnd != null))
                    {
                        if (caret.Position >= ptEnd)
                        {
                            lastTag = tag;
                        }
                    }
                }
                if (lastTag != null)
                {
                    var name = lastTag.Tag.ClassificationType.Classification.ToLower();
                    // No Intellisense in Comment
                    if (name == "comment" || name == "xsharp.text")
                    {
                        return;
                    }
                }
                ////////////////////////////////////////////
                SnapshotPoint start        = triggerPoint;
                var           applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);
                //
                if (_file == null)
                {
                    // Uhh !??, Something went wrong
                    return;
                }
                // The Completion list we are building
                XCompletionList compList = new XCompletionList(_file);
                XCompletionList kwdList  = new XCompletionList(_file);
                IXTypeSymbol    type     = null;
                if (session.Properties.ContainsProperty(XsCompletionProperties.Type))
                {
                    type = (IXTypeSymbol)session.Properties[XsCompletionProperties.Type];
                }
                // Start of Process
                string filterText = "";
                // Check if we can get the member where we are
                // Standard TokenList Creation (based on colon Selector )
                bool includeKeywords;
                session.Properties.TryGetProperty(XsCompletionProperties.IncludeKeywords, out includeKeywords);
                CompletionState state;
                var             member   = session.TextView.FindMember(triggerPoint);
                var             location = session.TextView.TextBuffer.FindLocation(triggerPoint);
                if (location == null)
                {
                    return;
                }
                var tokenList = XSharpTokenTools.GetTokenList(location, out state, includeKeywords);


                // We might be here due to a COMPLETEWORD command, so we have no typedChar
                // but we "may" have a incomplete word like System.String.To
                // Try to Guess what TypedChar could be
                if (typedChar == '\0' && autoType)
                {
                    if (tokenList.Count > 0)
                    {
                        string extract = tokenList[tokenList.Count - 1].Text;
                        typedChar = extract[extract.Length - 1];
                        if ((typedChar != '.') && (typedChar != ':'))
                        {
                            if (tokenList.Count == 1)
                            {
                                //
                                filterText = tokenList[0].Text;
                                int dotPos = extract.LastIndexOf(".");
                                if (dotPos > -1)
                                {
                                    string startToken = extract.Substring(0, dotPos);
                                    filterText        = extract.Substring(dotPos + 1);
                                    typedChar         = '.';
                                    tokenList[0].Text = startToken + ".";
                                }
                            }
                            else
                            {
                                // So, we get the last Token as a Filter
                                filterText = tokenList[tokenList.Count - 1].Text;
                            }
                            // Include the filter as the text to replace
                            start       -= filterText.Length;
                            applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);
                        }
                    }
                }
                bool dotSelector = (typedChar == '.');

                // TODO: Based on the Project.Settings, we should add the Vulcan.VO namespace
                int tokenType = XSharpLexer.UNRECOGNIZED;

                var symbol     = XSharpLookup.RetrieveElement(location, tokenList, CompletionState.General, out var notProcessed).FirstOrDefault();
                var memberName = "";
                // Check for members, locals etc and convert the type of these to IXTypeSymbol
                if (symbol != null)
                {
                    if (symbol is IXTypeSymbol xtype)
                    {
                        type = xtype;
                    }
                    else if (symbol is IXMemberSymbol xmember)
                    {
                        var typeName = xmember.TypeName;
                        if (xmember is XSourceMemberSymbol sourcemem)
                        {
                            type = sourcemem.File.FindType(typeName);
                        }
                        else
                        {
                            type = location.FindType(typeName);
                        }
                        memberName = xmember.Name;
                    }
                    else if (symbol is IXVariableSymbol xvar)
                    {
                        var typeName = "";
                        if (xvar is XSourceUndeclaredVariableSymbol)
                        {
                            type       = null;
                            state      = CompletionState.General;
                            filterText = xvar.Name;
                        }
                        else if (xvar is XSourceVariableSymbol sourcevar)
                        {
                            typeName = sourcevar.TypeName;
                            if (sourcevar.ResolvedType != null)
                            {
                                type     = sourcevar.ResolvedType;
                                typeName = type.FullName;
                            }
                            else
                            {
                                type = sourcevar.File.FindType(typeName);
                            }
                        }
                        else if (xvar is XPEParameterSymbol par)
                        {
                            typeName = par.TypeName;
                            type     = location.FindType(typeName);
                        }
                        memberName = xvar.Name;
                    }
                    else if (symbol.Kind == Kind.Keyword)
                    {
                        filterText = symbol.Name;
                    }
                    else if (symbol.Kind == Kind.Namespace)
                    {
                        filterText = symbol.Name + ".";
                    }
                    if (type != null)
                    {
                        switch (type.FullName)
                        {
                        case XSharpTypeNames.XSharpUsual:
                        case XSharpTypeNames.VulcanUsual:
                            type = null;
                            break;
                        }
                    }
                    session.Properties[XsCompletionProperties.Type] = type;
                }
                if (type == null)
                {
                    showInstanceMembers = false;
                }
                if ((dotSelector || state != CompletionState.None))
                {
                    if (string.IsNullOrEmpty(filterText) && type == null)
                    {
                        filterText = helpers.TokenListAsString(tokenList);
                        if (filterText.Length > 0 && !filterText.EndsWith(".") && state != CompletionState.General)
                        {
                            filterText += ".";
                        }
                    }
                    if (type == null && state.HasFlag(CompletionState.Namespaces))
                    {
                        helpers.AddNamespaces(compList, location, filterText);
                    }
                    if (type == null && state.HasFlag(CompletionState.Interfaces))
                    {
                        helpers.AddTypeNames(compList, location, filterText, afterDot: true, onlyInterfaces: true);
                        helpers.AddXSharpKeywordTypeNames(kwdList, filterText);
                    }
                    if (type == null && state.HasFlag(CompletionState.Types))
                    {
                        helpers.AddTypeNames(compList, location, filterText, afterDot: true, onlyInterfaces: false);
                        helpers.AddXSharpKeywordTypeNames(kwdList, filterText);
                    }
                    if (state.HasFlag(CompletionState.StaticMembers))
                    {
                        if (type != null && symbol is IXTypeSymbol)
                        {
                            // First we need to keep only the text AFTER the last dot
                            int dotPos = filterText.LastIndexOf('.');
                            filterText = filterText.Substring(dotPos + 1, filterText.Length - dotPos - 1);
                            helpers.BuildCompletionListMembers(location, compList, type, Modifiers.Public, true, filterText);
                        }
                    }
                    if (type.IsVoStruct() && typedChar == '.')
                    {
                        // vostruct or union in other assembly
                        showInstanceMembers = true;
                        filterText          = "";
                    }
                    if (state.HasFlag(CompletionState.InstanceMembers))
                    {
                        showInstanceMembers = true;
                        filterText          = "";
                    }
                }
                if (showInstanceMembers)
                {
                    // Member call
                    if (type != null)
                    {
                        Modifiers visibleAs = Modifiers.Public;
                        if (type is XSourceTypeSymbol sourceType && sourceType.File.Project == member.File.Project)
                        {
                            visibleAs = Modifiers.Internal;
                            switch (memberName.ToLower())
                            {
                            case "self":
                            case "this":
                                visibleAs = Modifiers.Private;
                                break;

                            case "super":
                                visibleAs = Modifiers.Protected;
                                break;

                            default:
                                if (member.ParentName == type.FullName)
                                {
                                    visibleAs = Modifiers.Private;
                                }
                                break;
                            }
                        }
                        // Now, Fill the CompletionList with the available members, from there
                        helpers.BuildCompletionListMembers(location, compList, type, visibleAs, false, filterText);
                    }
                }
                //
                if (!dotSelector && !showInstanceMembers)
                {
                    switch (tokenType)
                    {
                    case XSharpLexer.USING:
                        // It can be a namespace
                        helpers.AddNamespaces(compList, location, filterText);
                        break;

                    case XSharpLexer.AS:
                    case XSharpLexer.IS:
                    case XSharpLexer.REF:
                    case XSharpLexer.INHERIT:
                        // It can be a namespace
                        helpers.AddNamespaces(compList, location, filterText);
                        // It can be Type, FullyQualified
                        // we should also walk all the USINGs, and the current Namespace if any, to search Types
                        helpers.AddTypeNames(compList, location, filterText, onlyInterfaces: false, afterDot: false);
                        //
                        helpers.AddXSharpKeywordTypeNames(kwdList, filterText);
                        break;

                    case XSharpLexer.IMPLEMENTS:
                        // It can be a namespace
                        helpers.AddNamespaces(compList, location, filterText);
                        helpers.AddTypeNames(compList, location, filterText, onlyInterfaces: true, afterDot: false);
                        break;

                    default:
                        //if (state.HasFlag(CompletionState.General))
                        //{
                        //    filterText = notProcessed;
                        //    helpers.AddGenericCompletion(compList, location, filterText);
                        //}
                        break;
                    }
                }

                if ((kwdList.Count > 0) && _keywordsInAll /*&& XSettings.CompleteKeywords*/)
                {
                    foreach (var item in kwdList.Values)
                    {
                        compList.Add(item);
                    }
                }
                // Sort in alphabetical order
                // and put in the SelectionList
                var values = compList.Values;
                // Create the All Tab
                completionSets.Add(new CompletionSet("All", "All", applicableTo, values, Enumerable.Empty <Completion>()));
                if (_showTabs)
                {
                    helpers.BuildTabs(compList, completionSets, applicableTo);
                }
                // Keywords are ALWAYS in a separate Tab anyway
                if (kwdList.Count > 0)
                {
                    completionSets.Add(new CompletionSet("Keywords", "Keywords", applicableTo, kwdList.Values, Enumerable.Empty <Completion>()));
                }
            }
            catch (Exception ex)
            {
                XSettings.LogException(ex, "AugmentCompletionSessions failed");
            }
            finally
            {
                XSharpModel.ModelWalker.Resume();
            }
            WriteOutputMessage("<<-- AugmentCompletionSessions");
        }
示例#9
0
        private ITagSpan <ClassificationTag> CreateTagSpanForTag(ITextSnapshot snapShot, IMappingTagSpan <GherkinTokenTag> tagSpan)
        {
            NormalizedSnapshotSpanCollection tagSpans = tagSpan.Span.GetSpans(snapShot);
            GherkinTokenType classificationType       = tagSpan.Tag.Type;

            return(new TagSpan <ClassificationTag>(tagSpans[0], new ClassificationTag(gherkinTypes[classificationType])));
        }
示例#10
0
        private void Handle(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;
            DateTime time1 = DateTime.Now;

            ITextSnapshot snapshot     = this._sourceBuffer.CurrentSnapshot;
            SnapshotPoint triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                AsmDudeToolsStatic.Output_WARNING("AsmQuickInfoSource:AugmentQuickInfoSession: trigger point is null");
                return;
            }

            Brush foreground = AsmDudeToolsStatic.GetFontColor();

            IEnumerator <IMappingTagSpan <AsmTokenTag> > enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)).GetEnumerator();

            if (enumerator.MoveNext())
            {
                IMappingTagSpan <AsmTokenTag> asmTokenTag = enumerator.Current;

                IEnumerator <SnapshotSpan> enumerator2 = asmTokenTag.Span.GetSpans(this._sourceBuffer).GetEnumerator();
                if (enumerator2.MoveNext())
                {
                    SnapshotSpan tagSpan      = enumerator2.Current;
                    string       keyword      = tagSpan.GetText();
                    string       keywordUpper = keyword.ToUpper();

                    #region Tests
                    // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless...
                    if (false)
                    {
                        if (enumerator.MoveNext())
                        {
                            IMappingTagSpan <AsmTokenTag> asmTokenTagX = enumerator.Current;
                            IEnumerator <SnapshotSpan>    enumeratorX  = asmTokenTagX.Span.GetSpans(this._sourceBuffer).GetEnumerator();
                            enumeratorX.MoveNext();
                            AsmDudeToolsStatic.Output_WARNING(string.Format("{0}:AugmentQuickInfoSession. current keyword " + keyword + ": but span has more than one tag! next tag=\"{1}\"", this.ToString(), enumeratorX.Current.GetText()));
                        }
                    }
                    #endregion

                    //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: keyword=\""+ keyword + "\"; type=" + asmTokenTag.Tag.type +"; file="+AsmDudeToolsStatic.GetFileName(session.TextView.TextBuffer));
                    applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeInclusive);

                    TextBlock    description = null;
                    AsmTokenType type        = asmTokenTag.Tag.Type;
                    switch (type)
                    {
                    case AsmTokenType.Misc:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Keyword ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }

                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Directive:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Directive ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }

                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Register:
                    {
                        int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan);
                        if (keywordUpper.StartsWith("%"))
                        {
                            keywordUpper = keywordUpper.Substring(1);         // remove the preceding % in AT&T syntax
                        }

                        Rn reg = RegisterTools.ParseRn(keywordUpper, true);
                        if (this._asmDudeTools.RegisterSwitchedOn(reg))
                        {
                            RegisterTooltipWindow registerTooltipWindow = new RegisterTooltipWindow(foreground);
                            registerTooltipWindow.SetDescription(reg, this._asmDudeTools);
                            registerTooltipWindow.SetAsmSim(this._asmSimulator, reg, lineNumber, true);
                            quickInfoContent.Add(registerTooltipWindow);
                        }
                        break;
                    }

                    case AsmTokenType.Mnemonic:
                    case AsmTokenType.Jump:
                    {
                        int      lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan);
                        Mnemonic mnemonic   = AsmSourceTools.ParseMnemonic_Att(keywordUpper, true);
                        if (this._asmDudeTools.MnemonicSwitchedOn(mnemonic))
                        {
                            InstructionTooltipWindow instructionTooltipWindow = new InstructionTooltipWindow(foreground)
                            {
                                Session = session         // set the owner of this windows such that we can manually close this window
                            };
                            instructionTooltipWindow.SetDescription(mnemonic, this._asmDudeTools);
                            instructionTooltipWindow.SetPerformanceInfo(mnemonic, this._asmDudeTools);
                            instructionTooltipWindow.SetAsmSim(this._asmSimulator, lineNumber, true);
                            quickInfoContent.Add(instructionTooltipWindow);
                        }
                        break;
                    }

                    case AsmTokenType.Label:
                    {
                        string label                = keyword;
                        string labelPrefix          = asmTokenTag.Tag.Misc;
                        string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler);

                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Label ", foreground));
                        description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label))));

                        string descr = this.Get_Label_Description(full_Qualified_Label);
                        if (descr.Length == 0)
                        {
                            descr = this.Get_Label_Description(label);
                        }
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }

                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.LabelDef:
                    {
                        string label          = keyword;
                        string extra_Tag_Info = asmTokenTag.Tag.Misc;
                        string full_Qualified_Label;
                        if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO))
                        {
                            full_Qualified_Label = label;
                        }
                        else
                        {
                            full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler);
                        }

                        AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label);

                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Label ", foreground));
                        description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label))));

                        string descr = this.Get_Label_Def_Description(full_Qualified_Label, label);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }

                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Constant:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Constant ", foreground));

                        (bool Valid, ulong Value, int NBits) = AsmSourceTools.Evaluate_Constant(keyword);
                        string constantStr = Valid
                                    ? Value + "d = " + Value.ToString("X") + "h = " + AsmSourceTools.ToStringBin(Value, NBits) + "b"
                                    : keyword;

                        description.Inlines.Add(Make_Run2(constantStr, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant))));
                        break;
                    }

                    case AsmTokenType.UserDefined1:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("User defined 1: ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined1))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }

                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.UserDefined2:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("User defined 2: ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined2))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }

                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.UserDefined3:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("User defined 3: ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined3))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }

                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    default:
                        //description = new TextBlock();
                        //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type));
                        break;
                    }
                    if (description != null)
                    {
                        description.FontSize   = AsmDudeToolsStatic.GetFontSize() + 2;
                        description.FontFamily = AsmDudeToolsStatic.GetFontType();
                        //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily));
                        quickInfoContent.Add(description);
                    }
                }
            }
            //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count);
            AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo");
        }
示例#11
0
        private TagSpan <TextMarkerTag> Mark(IMappingTagSpan <LexTag> tagSpan, SnapshotSpan snapshotSpan)
        {
            var tagSpans = tagSpan.Span.GetSpans(snapshotSpan.Snapshot);

            return(new TagSpan <TextMarkerTag>(tagSpans[0], new TextMarkerTag("blue")));
        }
示例#12
0
        /// <summary>
        /// Determine which pieces of Quickinfo content should be displayed
        /// </summary>
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession");
            applicableToSpan = null;
            try
            {
                DateTime time1 = DateTime.Now;

                ITextSnapshot snapshot     = this._sourceBuffer.CurrentSnapshot;
                var           triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);
                if (triggerPoint == null)
                {
                    AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: trigger point is null");
                    return;
                }
                string keyword = "";

                IEnumerable <IMappingTagSpan <AsmTokenTag> > enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint));
                //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: enumerator.Count="+ enumerator.Count());

                if (enumerator.Count() > 0)
                {
                    if (false)
                    {
                        // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless...
                        if (enumerator.Count() > 1)
                        {
                            foreach (IMappingTagSpan <AsmTokenTag> v in enumerator)
                            {
                                AsmDudeToolsStatic.Output(string.Format("WARNING: {0}:AugmentQuickInfoSession. more than one tag! \"{1}\"", ToString(), v.Span.GetSpans(this._sourceBuffer).First().GetText()));
                            }
                        }
                    }

                    IMappingTagSpan <AsmTokenTag> asmTokenTag = enumerator.First();
                    SnapshotSpan tagSpan = asmTokenTag.Span.GetSpans(this._sourceBuffer).First();
                    keyword = tagSpan.GetText();
                    int lineNumber = tagSpan.Snapshot.GetLineNumberFromPosition(tagSpan.Start);

                    //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: keyword=\""+ keyword + "\"; type=" + asmTokenTag.Tag.type +"; file="+AsmDudeToolsStatic.GetFileName(session.TextView.TextBuffer));
                    string keywordUpper = keyword.ToUpper();
                    applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive);

                    TextBlock description = null;

                    switch (asmTokenTag.Tag.Type)
                    {
                    case AsmTokenType.Misc:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Keyword ", this._foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = this._foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Directive:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Directive ", this._foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = this._foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Register:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Register ", this._foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Register))));

                        string register_Descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (register_Descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + register_Descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = this._foreground
                                });
                        }

                        if (this._asmSimulator.Is_Enabled)
                        {
                            IState_R state = this._asmSimulator.GetState(lineNumber, true);
                            string   msg   = this._asmSimulator.GetRegisterValue(RegisterTools.ParseRn(keyword), state);
                            if (msg.Length == 0)
                            {
                                msg = "Calculating register content";
                            }

                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap("\n" + msg, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = this._foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Mnemonic:
                    case AsmTokenType.Jump:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Mnemonic ", this._foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Opcode))));

                        Mnemonic mmemonic = AsmSourceTools.ParseMnemonic(keywordUpper);
                        {
                            string archStr = ":" + ArchTools.ToString(this._asmDudeTools.Mnemonic_Store.GetArch(mmemonic)) + " ";
                            string descr   = this._asmDudeTools.Mnemonic_Store.GetDescription(mmemonic);

                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(archStr + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = this._foreground
                                });
                        }
                        {           // show performance information
                            MicroArch selectedMicroarchitures = AsmDudeToolsStatic.Get_MicroArch_Switched_On();
                            IReadOnlyList <PerformanceItem> performanceData = this._asmDudeTools.Performance_Store.GetPerformance(mmemonic, selectedMicroarchitures);
                            if (performanceData.Count > 0)
                            {
                                FontFamily  family = new FontFamily("Consolas");
                                IList <Run> list   = new List <Run>();

                                description.Inlines.Add(new Run(string.Format("\n\n{0,-15}{1,-24}{2,-10}{3,-10}\n", "Architecture", "Instruction", "Latency", "Throughput"))
                                    {
                                        FontFamily = family,
                                        FontStyle  = FontStyles.Italic,
                                        FontWeight = FontWeights.Bold,
                                        Foreground = this._foreground
                                    });
                                foreach (PerformanceItem item in performanceData)
                                {
                                    description.Inlines.Add(new Run(string.Format("{0,-15}{1,-24}{2,-10}{3,-10}{4,-10}\n", item._microArch, item._instr + " " + item._args, item._latency, item._throughput, item._remark))
                                        {
                                            FontFamily = family,
                                            Foreground = this._foreground
                                        });
                                }
                            }
                        }
                        break;
                    }

                    case AsmTokenType.Label:
                    {
                        string label                = keyword;
                        string labelPrefix          = asmTokenTag.Tag.Misc;
                        string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler);

                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Label ", this._foreground));
                        description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label))));

                        string descr = Get_Label_Description(full_Qualified_Label);
                        if (descr.Length == 0)
                        {
                            descr = Get_Label_Description(label);
                        }
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = this._foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.LabelDef:
                    {
                        string label          = keyword;
                        string extra_Tag_Info = asmTokenTag.Tag.Misc;
                        string full_Qualified_Label;
                        if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO))
                        {
                            full_Qualified_Label = label;
                        }
                        else
                        {
                            full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler);
                        }

                        AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label);

                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Label ", this._foreground));
                        description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label))));

                        string descr = Get_Label_Def_Description(full_Qualified_Label, label);
                        if (descr.Length > 0)
                        {
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = this._foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Constant:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Constant ", this._foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant))));
                        break;
                    }

                    default:
                        //description = new TextBlock();
                        //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type));
                        break;
                    }
                    if (description != null)
                    {
                        description.FontSize   = AsmDudeToolsStatic.Get_Font_Size() + 2;
                        description.FontFamily = AsmDudeToolsStatic.Get_Font_Type();
                        //AsmDudeToolsStatic.Output(string.Format("INFO: {0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily));
                        quickInfoContent.Add(description);
                    }
                }
                //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count);
                AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo");
            }
            catch (Exception e)
            {
                AsmDudeToolsStatic.Output(string.Format("ERROR: {0}:AugmentQuickInfoSession; e={1}", ToString(), e.ToString()));
            }
        }
        private void HandleContentTypeTagsChanged()
        {
            ITextSnapshot snapshot     = DiskBuffer.CurrentSnapshot;
            ITextSnapshot htmlSnapshot = _htmlBuffer.CurrentSnapshot;
            ITextSnapshot phpSnapshot  = TemplateBuffer.CurrentSnapshot;

            SnapshotSpan completeSnapshot = new SnapshotSpan(snapshot, 0, snapshot.Length);

            IMappingTagSpan <ContentTypeTag>[] tags = _contentTypeTagger.GetTags(completeSnapshot).ToArray();

            IMappingPoint[] trackingPoints = new IMappingPoint[tags.Length];
            for (int i = 0; i < tags.Length; i++)
            {
                IMappingTagSpan <ContentTypeTag> tag = tags[i];
                switch (tag.Tag.RegionType)
                {
                case RegionType.Begin:
                    trackingPoints[i] = tag.Span.Start;
                    break;

                case RegionType.End:
                    trackingPoints[i] = tag.Span.End;
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            List <ITrackingSpan> projectionSpans = new List <ITrackingSpan>();
            List <SpanInfo>      spans           = new List <SpanInfo>();

            for (int i = 0; i < tags.Length; i++)
            {
                IMappingTagSpan <ContentTypeTag> tag = tags[i];

                Span sourceSpan;
                if (i == 0)
                {
                    sourceSpan = new Span(0, trackingPoints[0].GetPoint(snapshot, PositionAffinity.Successor) ?? 0);
                }
                else
                {
                    SnapshotPoint?startPoint = trackingPoints[i - 1].GetPoint(snapshot, PositionAffinity.Successor);
                    SnapshotPoint?endPoint   = trackingPoints[i].GetPoint(snapshot, PositionAffinity.Successor);
                    if (!startPoint.HasValue || !endPoint.HasValue)
                    {
                        throw new InvalidOperationException();
                    }

                    sourceSpan = Span.FromBounds(startPoint.Value.Position, endPoint.Value.Position);
                }

                switch (tag.Tag.RegionType)
                {
                case RegionType.Begin:
                {
                    // handle the Text region that ended where this tag started
                    ITrackingSpan projectionSpan = htmlSnapshot.Version.CreateCustomTrackingSpan(
                        sourceSpan,
                        TrackingFidelityMode.Forward,
                        new LanguageSpanCustomState(sourceSpan),
                        TrackToVersion);
                    ITrackingSpan diskBufferSpan = snapshot.Version.CreateCustomTrackingSpan(
                        sourceSpan,
                        TrackingFidelityMode.Forward,
                        new LanguageSpanCustomState(sourceSpan),
                        TrackToVersion);

                    projectionSpans.Add(projectionSpan);
                    spans.Add(new SpanInfo(diskBufferSpan, TemplateTokenKind.Text));
                    break;
                }

                case RegionType.End:
                {
                    // handle the code region that ended where this tag ended
                    ITrackingSpan projectionSpan = new CustomTrackingSpan(phpSnapshot.CreateTrackingSpan(sourceSpan, SpanTrackingMode.EdgeExclusive));
                    ITrackingSpan diskBufferSpan = new CustomTrackingSpan(snapshot.CreateTrackingSpan(sourceSpan, SpanTrackingMode.EdgeExclusive));

                    projectionSpans.Add(projectionSpan);
                    spans.Add(new SpanInfo(diskBufferSpan, TemplateTokenKind.Block));
                    break;
                }

                default:
                    throw new NotSupportedException();
                }
            }

            if (true)
            {
                int startPosition = 0;
                if (tags.Length > 0)
                {
                    SnapshotPoint?startPoint = trackingPoints.Last().GetPoint(snapshot, PositionAffinity.Successor);
                    if (!startPoint.HasValue)
                    {
                        throw new InvalidOperationException();
                    }

                    startPosition = startPoint.Value.Position;
                }

                Span sourceSpan = Span.FromBounds(startPosition, snapshot.Length);

                RegionType finalRegionType = tags.Length > 0 ? tags.Last().Tag.RegionType : RegionType.End;
                switch (finalRegionType)
                {
                case RegionType.Begin:
                {
                    // handle the code region that ended at the end of the document
                    ITrackingSpan projectionSpan = new CustomTrackingSpan(phpSnapshot.CreateTrackingSpan(sourceSpan, SpanTrackingMode.EdgePositive));
                    ITrackingSpan diskBufferSpan = new CustomTrackingSpan(snapshot.CreateTrackingSpan(sourceSpan, SpanTrackingMode.EdgePositive));

                    projectionSpans.Add(projectionSpan);
                    spans.Add(new SpanInfo(diskBufferSpan, TemplateTokenKind.Block));
                    break;
                }

                case RegionType.End:
                {
                    // handle the Text region that ended at the end of the document
                    ITrackingSpan projectionSpan = htmlSnapshot.Version.CreateCustomTrackingSpan(
                        sourceSpan,
                        TrackingFidelityMode.Forward,
                        new LanguageSpanCustomState(sourceSpan),
                        TrackToVersion);
                    ITrackingSpan diskBufferSpan = snapshot.Version.CreateCustomTrackingSpan(
                        sourceSpan,
                        TrackingFidelityMode.Forward,
                        new LanguageSpanCustomState(sourceSpan),
                        TrackToVersion);

                    projectionSpans.Add(projectionSpan);
                    spans.Add(new SpanInfo(diskBufferSpan, TemplateTokenKind.Text));
                    break;
                }

                default:
                    throw new NotSupportedException();
                }
            }

            int startSpan    = 0;
            int oldSpanCount = _spans.Count;

            _spans.RemoveRange(startSpan, oldSpanCount - startSpan);
            _spans.AddRange(spans);

            _projBuffer.ReplaceSpans(startSpan, oldSpanCount - startSpan, projectionSpans.ToArray(), _editOptions, null);

            ProjectionClassifier classifier;

            if (spans.Count > 0 &&
                _projBuffer.Properties.TryGetProperty <ProjectionClassifier>(typeof(ProjectionClassifier), out classifier))
            {
                classifier.RaiseClassificationChanged(
                    spans[0].DiskBufferSpan.GetStartPoint(_diskBuffer.CurrentSnapshot),
                    spans[spans.Count - 1].DiskBufferSpan.GetEndPoint(_diskBuffer.CurrentSnapshot)
                    );
            }
        }
示例#14
0
 private static int getLineNumber(IMappingTagSpan <AsmTokenTag> tag)
 {
     return(getLineNumber(tag.Span.GetSpans(tag.Span.AnchorBuffer)[0]));
 }
 public AdornmentTagInfo(SnapshotSpan span, UIElement element, IMappingTagSpan <IntraTextAdornmentTag> tagSpan)
 {
     Span          = span;
     UserUIElement = element;
     TagSpan       = tagSpan;
 }
示例#16
0
 private string getText(ITextBuffer buffer, IMappingTagSpan <AsmTokenTag> asmTokenSpan)
 {
     return(asmTokenSpan.Span.GetSpans(buffer)[0].GetText());
 }
示例#17
0
 protected override TagSpan <ClassificationTag> TagComments(string className, SnapshotSpan snapshotSpan, IMappingTagSpan <IClassificationTag> tagSpan)
 {
     if (Config.Instance.MarkerOptions.MatchFlags(MarkerOptions.CompilerDirective))
     {
         if (Matches(snapshotSpan, "region") || Matches(snapshotSpan, "pragma") || Matches(snapshotSpan, "if") || Matches(snapshotSpan, "else"))
         {
             return(new TagSpan <ClassificationTag>(snapshotSpan, (ClassificationTag)tagSpan.Tag));
         }
     }
     return(base.TagComments(className, snapshotSpan, tagSpan));
 }
示例#18
0
 public AdornmentElement(IMappingTagSpan <SpaceNegotiatingAdornmentTag> tagSpan) => this.tagSpan = tagSpan ?? throw new ArgumentNullException(nameof(tagSpan));
示例#19
0
        public static TextMark Create(IMappingTagSpan<IVsVisibleTextMarkerTag> tag)
        {
            uint flags;
            int hr = tag.Tag.StreamMarker.GetVisualStyle(out flags);
            if (ErrorHandler.Succeeded(hr) &&
                    ((flags & (uint)MARKERVISUAL.MV_GLYPH) != 0) &&
                    ((flags & ((uint)MARKERVISUAL.MV_COLOR_ALWAYS | (uint)MARKERVISUAL.MV_COLOR_LINE_IF_NO_MARGIN)) != 0))
            {
                COLORINDEX[] foreground = new COLORINDEX[1];
                COLORINDEX[] background = new COLORINDEX[1];
                hr = tag.Tag.MarkerType.GetDefaultColors(foreground, background);
                if (ErrorHandler.Succeeded(hr))
                {
                    ITextBuffer buffer = tag.Span.BufferGraph.TopBuffer;
                    SnapshotPoint? pos = tag.Span.Start.GetPoint(buffer, PositionAffinity.Successor);
                    if (pos.HasValue)
                    {
                        var text_mark = new TextMark();
                        text_mark.line = buffer.CurrentSnapshot.GetLineNumberFromPosition(pos.Value.Position);
                        text_mark.brush = ColorExtractor.GetBrushFromIndex(background[0]);
                        return text_mark;
                    }
                }
            }

            return null;
        }