コード例 #1
0
 public RegistryCompletionSource(ITextBuffer buffer, IGlyphService glyphService)
 {
     _buffer = buffer;
     _versionGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.GlyphItemPublic);
     _keyGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphClosedFolder, StandardGlyphItem.GlyphItemPublic);
     _dataTypeGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupStruct, StandardGlyphItem.GlyphItemPublic);
 }
コード例 #2
0
        public IEnumerable <Completion> GetCompletions(ITextBuffer buffer, SnapshotSpan span, IGlyphService glyphService)
        {
            var semanticModel = GetSemanticModel(buffer);
            var identifiers   = semanticModel.GetIdentifiers(span.Start);
            var contextSpan   = semanticModel.GetContextSpan(span.Start);
            var prefix        = contextSpan.Type == ContextType.Template ? "$" : "";

            var completions = identifiers.Select(i =>
            {
                var imageSource = glyphService.GetGlyph(i.Glyph, StandardGlyphItem.GlyphItemPublic);
                var quickInfo   = i.IsParent ? i.QuickInfo.Replace("Item", contextSpan.ParentContext?.Name) : i.QuickInfo;

                return(new Completion(prefix + i.Name, prefix + i.Name, quickInfo, imageSource, null));
            });

            if (contextSpan.Type == ContextType.Template && contextSpan.Context.Name == nameof(File))
            {
                var imageSource = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic);
                var codeBlock   = new[]
                {
                    new Completion("#reference", "#reference", "Add a reference to an external assembly.", imageSource, null),
                    new Completion("${ }", "${\r\n}", "Insert a custom C# code block.", imageSource, null)
                };

                return(codeBlock.Concat(completions));
            }

            return(completions);
        }
コード例 #3
0
        public CompletionSource(ITextBuffer buffer, ITextStructureNavigatorSelectorService navigation, IGlyphService glyphService)
        {
            _buffer       = buffer;
            _navigation   = navigation;
            _glyphService = glyphService;

            var keywordImage = _glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupNamespace, StandardGlyphItem.GlyphItemPublic);

            foreach (var str in _poorMansKeywords)
            {
                _completions.Add(new Completion(str, str, str, keywordImage, null));
            }

            var extensionImage = _glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupClass, StandardGlyphItem.GlyphItemPublic);

            foreach (var str in _poorMansExtensionIntellisense)
            {
                _completions.Add(new Completion(str, str, str, extensionImage, null));
            }

            var localVariableImage = _glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);

            foreach (var localVar in new[] { "$localVar1", "$localVar2", "$anotherLocalVar" })
            {
                _completions.Add(new Completion(localVar, localVar, localVar, localVariableImage, null));
            }

            _completions = _completions.OrderBy(x => x.DisplayText).ToList();
        }
コード例 #4
0
        protected override void HandleFunction(CommonTree function, CommonTree name, bool isPrivate, IList <CommonTree> parameters, CommonTree returnSpec, CommonTree body)
        {
            var group = StandardGlyphGroup.GlyphGroupMethod;
            var item  = isPrivate ? StandardGlyphItem.GlyphItemPrivate : StandardGlyphItem.GlyphItemPublic;
            var glyph = _glyphService.GetGlyph(group, item);

            HandleFunctionOrPredicate(function, name, parameters, returnSpec, glyph);
        }
コード例 #5
0
 public CmdCompletionSource(ITextBuffer buffer, IClassifierAggregatorService classifier, IGlyphService glyphService, ITextStructureNavigator textStructureNavigator)
 {
     _buffer = buffer;
     _classifier = classifier.GetClassifier(buffer);
     _keywordGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);
     _environmentGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphAssembly, StandardGlyphItem.GlyphItemPublic);
     _labelGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphArrow, StandardGlyphItem.GlyphItemPublic);
     _textStructureNavigator = textStructureNavigator;
 }
コード例 #6
0
 public PkgdefCompletionSource(ITextBuffer buffer, IClassifierAggregatorService classifier, ITextStructureNavigatorSelectorService navigator, IGlyphService glyphService)
 {
     _buffer       = buffer;
     _classifier   = classifier.GetClassifier(buffer);
     _navigator    = navigator;
     _glyphService = glyphService;
     _defaultGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPublic);
     _snippetGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphCSharpExpansion, StandardGlyphItem.GlyphItemPublic);
 }
コード例 #7
0
 public CmdCompletionSource(ITextBuffer buffer, IClassifierAggregatorService classifier, IGlyphService glyphService, ITextStructureNavigator textStructureNavigator)
 {
     _buffer                 = buffer;
     _classifier             = classifier.GetClassifier(buffer);
     _keywordGlyph           = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);
     _environmentGlyph       = glyphService.GetGlyph(StandardGlyphGroup.GlyphAssembly, StandardGlyphItem.GlyphItemPublic);
     _labelGlyph             = glyphService.GetGlyph(StandardGlyphGroup.GlyphArrow, StandardGlyphItem.GlyphItemPublic);
     _textStructureNavigator = textStructureNavigator;
 }
コード例 #8
0
 public PkgdefCompletionSource(ITextBuffer buffer, IClassifierAggregatorService classifier, ITextStructureNavigatorSelectorService navigator, IGlyphService glyphService)
 {
     _buffer = buffer;
     _classifier = classifier.GetClassifier(buffer);
     _navigator = navigator;
     _glyphService = glyphService;
     _defaultGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPublic);
     _snippetGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphCSharpExpansion, StandardGlyphItem.GlyphItemPublic);
 }
コード例 #9
0
 public VsctCompletionSource(ITextBuffer buffer, IClassifierAggregatorService classifier, ITextStructureNavigatorSelectorService navigator, IGlyphService glyphService)
 {
     _buffer = buffer;
     _classifier = classifier.GetClassifier(buffer);
     _navigator = navigator;
     _glyphService = glyphService;
     _defaultGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPublic);
     _builtInGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.TotalGlyphItems);
     _imageService = ExtensibilityToolsPackage.GetGlobalService(typeof(SVsImageService)) as IVsImageService2;
 }
コード例 #10
0
 public VsctCompletionSource(ITextBuffer buffer, IClassifierAggregatorService classifier, ITextStructureNavigatorSelectorService navigator, IGlyphService glyphService)
 {
     _buffer       = buffer;
     _classifier   = classifier.GetClassifier(buffer);
     _navigator    = navigator;
     _glyphService = glyphService;
     _defaultGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPublic);
     _builtInGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.TotalGlyphItems);
     _imageService = ExtensibilityToolsPackage.GetGlobalService(typeof(SVsImageService)) as IVsImageService2;
 }
コード例 #11
0
        public CrmPathCompletionSource(CrmPathCompletionSourceProvider sourceProvider, ITextBuffer buffer, IClassifierAggregatorService classifier, ITextStructureNavigatorSelectorService navigator, IGlyphService glyphService)
        {
            _sourceProvider = sourceProvider;

            _buffer       = buffer;
            _classifier   = classifier.GetClassifier(buffer);
            _navigator    = navigator;
            _glyphService = glyphService;
            _defaultGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPublic);
            _builtInGlyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.TotalGlyphItems);
        }
コード例 #12
0
        private void AddAllGuids(ITextSnapshot snapshot, List <Intel.Completion> list)
        {
            var guidSpans = _classifier.GetClassificationSpans(new SnapshotSpan(snapshot, 0, snapshot.Length)).Where(g => g.ClassificationType.IsOfType(PkgdefClassificationTypes.Guid));
            Dictionary <string, Tuple <string, ImageSource> > dic = new Dictionary <string, Tuple <string, ImageSource> >();
            var unknown = _glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupModule, StandardGlyphItem.TotalGlyphItems);

            foreach (var cspan in guidSpans)
            {
                string            guid     = cspan.Span.GetText();
                ITextSnapshotLine line     = snapshot.GetLineFromPosition(cspan.Span.Start.Position);
                string            lineText = line.GetText();
                Guid check = Guid.Empty;

                if (!dic.ContainsKey(guid) && Guid.TryParse(guid, out check))
                {
                    dic[guid] = null;
                }

                if (check != Guid.Empty && (!dic.ContainsKey(guid) || dic[guid] == null || !dic[guid].Item1.Contains("\\")))
                {
                    string before = lineText.Substring(0, lineText.IndexOf(guid)).Trim();
                    string text   = before;
                    var    glyph  = unknown;

                    Match entryKey = Regex.Match(text, "\"(?<key>[^\"]+)\"");
                    if (entryKey.Success)
                    {
                        text = entryKey.Value + "=";
                    }

                    string name;
                    glyph = GetGlyph(lineText, glyph, out name);

                    if (glyph == null || text == "\"")
                    {
                        continue;
                    }

                    if (!string.IsNullOrEmpty(name))
                    {
                        name += Environment.NewLine;
                    }

                    dic[guid] = Tuple.Create(name + text + Environment.NewLine + "Line: " + line.LineNumber, glyph);
                }
            }

            List <Completion> entries = new List <Completion>();

            foreach (string guid in dic.Keys)
            {
                if (dic[guid] != null)
                {
                    entries.Add(CreateCompletion(guid, guid, dic[guid].Item2, dic[guid].Item1));
                }
            }

            list.AddRange(entries.OrderByDescending(e => e.Description));
        }
コード例 #13
0
        public object GetImage(ImageType imageType, ImageSubType subType = ImageSubType.Public)
        {
            StandardGlyphItem qualifier;

            switch (subType)
            {
            case ImageSubType.Internal:
                qualifier = StandardGlyphItem.GlyphItemInternal;
                break;

            default:
                qualifier = StandardGlyphItem.GlyphItemPublic;
                break;
            }

            switch (imageType)
            {
            case ImageType.Keyword:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphKeyword, qualifier));

            case ImageType.Variable:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, qualifier));

            case ImageType.Method:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, qualifier));

            case ImageType.Constant:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupConstant, qualifier));

            case ImageType.Library:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphLibrary, qualifier));

            case ImageType.ValueType:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupValueType, qualifier));

            case ImageType.Snippet:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphCSharpExpansion, qualifier));

            case ImageType.OpenFolder:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphOpenFolder, qualifier));

            case ImageType.ClosedFolder:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphClosedFolder, qualifier));

            case ImageType.Intrinsic:
                return(_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupIntrinsic, qualifier));

            case ImageType.File:
            case ImageType.Document:
                return(GetImage("Document"));
            }
            return(null);
        }
コード例 #14
0
ファイル: PyCompletion.cs プロジェクト: smartmobili/parsing
 /// <summary>
 /// Constructor used by IPy declarations retrieved from the IPy engine
 /// </summary>
 internal PyCompletion(Declaration declaration, IGlyphService glyphService)
     : base(declaration.Title)
 {
     this.InsertionText = declaration.Title;
     this.Description = declaration.Description;
     this.IconSource = glyphService.GetGlyph(GetGroupFromDeclaration(declaration), GetScopeFromDeclaration(declaration));
 }
コード例 #15
0
        public void GetMap(XML_TYPE xmltype, out List <Completion> list, IGlyphService gs, string key, string pro)
        {
            list = new List <Completion>();
            ImageSource ico = gs.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.GlyphItemPublic);

            AddProValue(ref list, key, pro, ref ico);
        }
コード例 #16
0
 /// <summary>
 /// Constructor used by IPy declarations retrieved from the IPy engine
 /// </summary>
 internal PyCompletion(Declaration declaration, IGlyphService glyphService)
     : base(declaration.Title)
 {
     this.InsertionText = declaration.Title;
     this.Description   = declaration.Description;
     this.IconSource    = glyphService.GetGlyph(GetGroupFromDeclaration(declaration), GetScopeFromDeclaration(declaration));
 }
コード例 #17
0
        public GlslCompletionSourceProvider(IClassifierAggregatorService classifierAggregatorService, IGlyphService glyphService)
        {
            if (glyphService is null)
            {
                throw new ArgumentNullException(nameof(glyphService));
            }

            this.classifierAggregatorService = classifierAggregatorService ?? throw new ArgumentNullException(nameof(classifierAggregatorService));
            identifier = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemFriend);

            var keyword  = glyphService.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.GlyphItemPublic);
            var function = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic);
            var variable = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);

            ImageSource ConvertReservedType(TokenType type)
            {
                switch (type)
                {
                case TokenType.Keyword: return(keyword);

                case TokenType.Function: return(function);

                case TokenType.Variable: return(variable);

                default: return(identifier);
                }
            }

            foreach (var var in GlslSpecification.ReservedWords)
            {
                staticCompletions.Add(GlslCompletionSource.NewCompletion(var.Key, ConvertReservedType(var.Value)));
            }
            //ImageSource ConvertUser(UserKeyWords.DefinedWordType type)
            //{
            //	switch (type)
            //	{
            //		case UserKeyWords.DefinedWordType.UserKeyword1:
            //		case UserKeyWords.DefinedWordType.UserKeyword2:
            //		default: return identifier;
            //	}
            //}
            //foreach (var var in UserKeyWords.DefinedWords)
            //{
            //	staticCompletions.Add(GlslCompletionSource.NewCompletion(var.Key, ConvertUser(var.Value)));
            //}
            staticCompletions.Sort((a, b) => a.DisplayText.CompareTo(b.DisplayText));
        }
コード例 #18
0
        private EpochQuickInfoContent ConstructHighlightableContent(string text, TypeOfContent typeOfContent)
        {
            var content = new EpochQuickInfoContent();

            content.Lines = new List <List <ClassificationSpan> >();

            if (typeOfContent == TypeOfContent.Variable)
            {
                content.Glyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);
            }
            else if (typeOfContent == TypeOfContent.Function)
            {
                content.Glyph = content.SubGlyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic);
            }
            else if (typeOfContent == TypeOfContent.Structure)
            {
                content.Glyph    = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupType, StandardGlyphItem.GlyphItemPublic);
                content.SubGlyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);
            }

            var contentType = m_contentTypes.GetContentType("EpochFile");
            var buffer      = m_bufferFactory.CreateTextBuffer(text, contentType);
            var snapshot    = buffer.CurrentSnapshot;

            var classifier = m_classifierProvider.GetClassifier(buffer) as EpochClassifier;

            classifier.ParsedProject = m_subjectBuffer.Properties.GetProperty <Parser.Project>(typeof(Parser.Project));
            var spans = classifier.GetAllSpans(new SnapshotSpan(snapshot, 0, text.Length), true);

            var lines = text.Count(x => x == '\n') + 1;

            for (int i = 0; i < lines; ++i)
            {
                var line = new List <ClassificationSpan>();
                foreach (var span in spans)
                {
                    if (span.Span.Start.GetContainingLine().LineNumber == i)
                    {
                        line.Add(span);
                    }
                }

                content.Lines.Add(line);
            }

            return(content);
        }
コード例 #19
0
ファイル: CompletionAnalysis.cs プロジェクト: KaushikCh/PTVS
 internal static DynamicallyVisibleCompletion PythonCompletion(IGlyphService service, MemberResult memberResult) {
     return new DynamicallyVisibleCompletion(memberResult.Name, 
         memberResult.Completion, 
         () => memberResult.Documentation, 
         () => service.GetGlyph(memberResult.MemberType.ToGlyphGroup(), StandardGlyphItem.GlyphItemPublic),
         Enum.GetName(typeof(PythonMemberType), memberResult.MemberType)
     );
 }
 internal static DynamicallyVisibleCompletion JsCompletion(IGlyphService service, MemberResult memberResult, bool quote) {
     return new DynamicallyVisibleCompletion(memberResult.Name,
         GetInsertionQuote(quote, memberResult.Completion),
         memberResult.Documentation,
         service.GetGlyph(GetGlyphGroup(memberResult), StandardGlyphItem.GlyphItemPublic),
         String.Empty
     );
 }
コード例 #21
0
        public override CompletionSet GetCompletions(IGlyphService glyphService)
        {
            var snapshot = TextBuffer.CurrentSnapshot;
            var span     = snapshot.GetApplicableSpan(Span.GetStartPoint(snapshot));
            var text     = span.GetText(snapshot);

            var  classifier     = snapshot.TextBuffer.GetPythonClassifier();
            var  token          = classifier.GetClassificationSpans(span.GetSpan(snapshot)).LastOrDefault();
            bool quoteBackslash = !token.Span.GetText().TakeWhile(c => !QuoteChars.Contains(c)).Any(c => c == 'r' || c == 'R');

            if (quoteBackslash)
            {
                text = text.Replace("\\\\", "\\");
            }

            string cwd;
            var    replEval = TextBuffer.GetInteractiveWindow()?.GetPythonEvaluator();

            if (replEval != null)
            {
                cwd = replEval.CurrentWorkingDirectory;
            }
            else if (!string.IsNullOrEmpty(cwd = TextBuffer.GetFilePath()))
            {
                cwd = PathUtils.GetParent(cwd);
            }
            else
            {
                cwd = Environment.CurrentDirectory;
            }

            var completions = GetEntryInfo(text, cwd, Environment.GetFolderPath(Environment.SpecialFolder.UserProfile))
                              .Select(e => new DynamicallyVisibleCompletion(
                                          e.Caption,
                                          quoteBackslash ? e.InsertionText.Replace("\\", "\\\\") : e.InsertionText,
                                          e.Tooltip,
                                          glyphService.GetGlyph(
                                              e.IsFile ? StandardGlyphGroup.GlyphLibrary : StandardGlyphGroup.GlyphClosedFolder,
                                              StandardGlyphItem.GlyphItemPublic
                                              ),
                                          e.IsFile ? "File" : "Directory"
                                          )).ToArray();

            if (completions.Length == 0)
            {
                return(null);
            }

            return(new FuzzyCompletionSet(
                       "PythonFilenames",
                       "Files",
                       Span,
                       completions,
                       _options,
                       CompletionComparer.UnderscoresLast,
                       matchInsertionText: true
                       ));
        }
        public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
        {
            if (_glyph == null)
            {
                _glyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic);
            }

            return(new EditorConfigCompletionSource(textBuffer, ClassifierAggregatorService, NavigatorService, _glyph));
        }
コード例 #23
0
        internal static Completion PythonCompletion(IGlyphService service, string name, string tooltip, StandardGlyphGroup group)
        {
            var icon = new IconDescription(group, StandardGlyphItem.GlyphItemPublic);

            var result = new LazyCompletion(name, () => name, () => tooltip, service.GetGlyph(group, StandardGlyphItem.GlyphItemPublic));

            result.Properties.AddProperty(typeof(IconDescription), icon);
            return(result);
        }
コード例 #24
0
        /// <summary>
        /// Constructor used by IPy snippets retrieved from the expansion manager
        /// </summary>
        internal PyCompletion(VsExpansion vsExpansion, IGlyphService glyphService)
            : base(vsExpansion.title)
        {
            this.InsertionText = vsExpansion.title;
            this.Description   = vsExpansion.description;
            this.IconSource    = glyphService.GetGlyph(StandardGlyphGroup.GlyphCSharpExpansion, StandardGlyphItem.GlyphItemPublic);

            this.VsExpansion = vsExpansion;
        }
コード例 #25
0
ファイル: PyCompletion.cs プロジェクト: smartmobili/parsing
        /// <summary>
        /// Constructor used by IPy snippets retrieved from the expansion manager
        /// </summary>
        internal PyCompletion(VsExpansion vsExpansion, IGlyphService glyphService)
            : base(vsExpansion.title)
        {
            this.InsertionText = vsExpansion.title;
            this.Description = vsExpansion.description;
            this.IconSource = glyphService.GetGlyph(StandardGlyphGroup.GlyphCSharpExpansion, StandardGlyphItem.GlyphItemPublic);

            this.VsExpansion = vsExpansion;
        }
コード例 #26
0
ファイル: CompletionAnalysis.cs プロジェクト: JoshVarty/PTVS
 internal static DynamicallyVisibleCompletion PythonCompletion(IGlyphService service, CompletionResult memberResult)
 {
     return(new DynamicallyVisibleCompletion(memberResult.Name,
                                             memberResult.Completion,
                                             () => memberResult.Documentation,
                                             () => service.GetGlyph(memberResult.MemberType.ToGlyphGroup(), StandardGlyphItem.GlyphItemPublic),
                                             Enum.GetName(typeof(PythonMemberType), memberResult.MemberType)
                                             ));
 }
コード例 #27
0
 internal static DynamicallyVisibleCompletion JsCompletion(IGlyphService service, MemberResult memberResult, bool quote)
 {
     return(new DynamicallyVisibleCompletion(memberResult.Name,
                                             GetInsertionQuote(quote, memberResult.Completion),
                                             memberResult.Documentation,
                                             service.GetGlyph(GetGlyphGroup(memberResult), StandardGlyphItem.GlyphItemPublic),
                                             String.Empty
                                             ));
 }
コード例 #28
0
ファイル: CompletionAnalysis.cs プロジェクト: KaushikCh/PTVS
        internal static DynamicallyVisibleCompletion PythonCompletion(IGlyphService service, string name, string tooltip, StandardGlyphGroup group) {
            var icon = new IconDescription(group, StandardGlyphItem.GlyphItemPublic);

            var result = new DynamicallyVisibleCompletion(name, 
                name, 
                tooltip, 
                service.GetGlyph(group, StandardGlyphItem.GlyphItemPublic),
                Enum.GetName(typeof(StandardGlyphGroup), group));
            result.Properties.AddProperty(typeof(IconDescription), icon);
            return result;
        }
コード例 #29
0
            public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
            {
                ITextSnapshot  snapshot     = _buffer.CurrentSnapshot;
                ITrackingPoint triggerPoint = session.GetTriggerPoint(_buffer);
                SnapshotPoint  point        = triggerPoint.GetPoint(snapshot);

                SyntaxTree syntax            = snapshot.GetSyntaxTree();
                RobotsTxtDocumentSyntax root = syntax.Root as RobotsTxtDocumentSyntax;

                applicableToSpan = null;

                // find section
                RobotsTxtLineSyntax line = root.Records
                                           .SelectMany(r => r.Lines)
                                           .FirstOrDefault(s => s.NameToken.Span.Span.Contains(point));

                if (line != null)
                {
                    IClassificationFormatMap formatMap = _classificationFormatMapService.GetClassificationFormatMap(session.TextView);

                    string fieldName = line.NameToken.Value;

                    // get glyph
                    var glyph = _glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic);
                    var classificationType = _classificationRegistry.GetClassificationType("RobotsTxt/RecordName");
                    var format             = formatMap.GetTextProperties(classificationType);

                    // construct content
                    ISemanticModel model = syntax.GetSemanticModel();
                    var            field = model.GetFieldSymbol(line);

                    var content = new QuickInfoContent
                    {
                        Glyph     = glyph,
                        Signature = new Run(field.Name)
                        {
                            Foreground = format.ForegroundBrush
                        },
                        Documentation = RobotsTxtDocumentation.GetDocumentation(field),
                    };

                    // add to session
                    quickInfoContent.Add(
                        new ContentPresenter
                    {
                        Content         = content,
                        ContentTemplate = Template,
                    }
                        );
                    applicableToSpan = snapshot.CreateTrackingSpan(line.NameToken.Span.Span, SpanTrackingMode.EdgeInclusive);
                    return;
                }
            }
コード例 #30
0
        private ImageSource GetIconSource(IGlyphService glyphService, SpringCompletionType type)
        {
            switch (type)
            {
            case SpringCompletionType.Namespace:
            case SpringCompletionType.Class:
            case SpringCompletionType.Interface:
            case SpringCompletionType.Property:
            case SpringCompletionType.ConstructorArg:
            case SpringCompletionType.EnumMember:
            case SpringCompletionType.Boolean:
                return(glyphService.GetGlyph(GetGroupFromDeclaration(type), GetScopeFromDeclaration(type)));

            case SpringCompletionType.Snippet:
            case SpringCompletionType.Alias:
                return(SpringLeafGlyph);

            default:
                return(glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupClass, StandardGlyphItem.GlyphItemPublic));
            }
        }
コード例 #31
0
ファイル: CompletionAnalysis.cs プロジェクト: JoshVarty/PTVS
        internal static DynamicallyVisibleCompletion PythonCompletion(IGlyphService service, string name, string completion, string tooltip, StandardGlyphGroup group)
        {
            var icon = new IconDescription(group, StandardGlyphItem.GlyphItemPublic);

            var result = new DynamicallyVisibleCompletion(name,
                                                          completion,
                                                          tooltip,
                                                          service.GetGlyph(group, StandardGlyphItem.GlyphItemPublic),
                                                          Enum.GetName(typeof(StandardGlyphGroup), group));

            result.Properties.AddProperty(typeof(IconDescription), icon);
            return(result);
        }
コード例 #32
0
ファイル: IconHelper.cs プロジェクト: belav/roslyn
        public static void Initialize(IGlyphService glyphService, IIconService iconService)
        {
            var supportedGlyphGroups = new Dictionary <StandardGlyphGroup, string>
            {
                { StandardGlyphGroup.GlyphGroupError, "Error" },
                { StandardGlyphGroup.GlyphGroupDelegate, "Delegate" },
                { StandardGlyphGroup.GlyphGroupEnum, "Enum" },
                { StandardGlyphGroup.GlyphGroupStruct, "Struct" },
                { StandardGlyphGroup.GlyphGroupClass, "Class" },
                { StandardGlyphGroup.GlyphGroupInterface, "Interface" },
                { StandardGlyphGroup.GlyphGroupModule, "Module" },
                { StandardGlyphGroup.GlyphGroupConstant, "Constant" },
                { StandardGlyphGroup.GlyphGroupEnumMember, "EnumMember" },
                { StandardGlyphGroup.GlyphGroupEvent, "Event" },
                { StandardGlyphGroup.GlyphExtensionMethodPrivate, "ExtensionMethodPrivate" },
                { StandardGlyphGroup.GlyphExtensionMethodProtected, "ExtensionMethodProtected" },
                { StandardGlyphGroup.GlyphExtensionMethodInternal, "ExtensionMethodInternal" },
                { StandardGlyphGroup.GlyphExtensionMethod, "ExtensionMethod" },
                { StandardGlyphGroup.GlyphGroupMethod, "Method" },
                { StandardGlyphGroup.GlyphGroupProperty, "Property" },
                { StandardGlyphGroup.GlyphGroupField, "Field" },
                { StandardGlyphGroup.GlyphGroupOperator, "Operator" },
                { StandardGlyphGroup.GlyphReference, "Reference" }
            };

            var supportedGlyphItems = new Dictionary <StandardGlyphItem, string>
            {
                { StandardGlyphItem.GlyphItemPrivate, "Private" },
                { StandardGlyphItem.GlyphItemProtected, "Protected" },
                { StandardGlyphItem.GlyphItemInternal, "Internal" },
                { StandardGlyphItem.GlyphItemPublic, "Public" },
                { StandardGlyphItem.GlyphItemFriend, "Friend" }
            };

            foreach (var groupKvp in supportedGlyphGroups)
            {
                foreach (var itemKvp in supportedGlyphItems)
                {
                    var iconName   = GetIconName(groupKvp.Value, itemKvp.Value);
                    var localGroup = groupKvp.Key;
                    var localItem  = itemKvp.Key;
                    iconService.AddIcon(
                        iconName,
                        iconName,
                        () => glyphService.GetGlyph(localGroup, localItem)
                        );
                }
            }
        }
コード例 #33
0
        public IEnumerable <Completion> GetCompletions(ITextBuffer buffer, SnapshotSpan span, IGlyphService glyphService)
        {
            var semanticModel = GetSemanticModel(buffer);
            var identifiers   = semanticModel.GetIdentifiers(span.Start);
            var contextSpan   = semanticModel.GetContextSpan(span.Start);
            var prefix        = contextSpan.Type == ContextType.Template ? "$" : "";

            return(identifiers.Select(i =>
            {
                var imageSource = glyphService.GetGlyph(i.Glyph, StandardGlyphItem.GlyphItemPublic);
                var quickInfo = i.IsParent ? i.QuickInfo.Replace("$parent", contextSpan.ParentContext?.Name.ToLowerInvariant()) : i.QuickInfo;

                return new Completion(prefix + i.Name, prefix + i.Name, quickInfo, imageSource, null);
            }));
        }
コード例 #34
0
        internal DynamicallyVisibleCompletion PythonCompletion(IGlyphService service, CompletionResult memberResult)
        {
            var insert = memberResult.Completion;

            if (insert.IndexOf('\t') >= 0 && _view.Options.IsConvertTabsToSpacesEnabled())
            {
                insert = insert.Replace("\t", new string(' ', _view.Options.GetIndentSize()));
            }

            return(new DynamicallyVisibleCompletion(memberResult.Name,
                                                    insert,
                                                    () => memberResult.Documentation,
                                                    () => service.GetGlyph(memberResult.MemberType.ToGlyphGroup(), StandardGlyphItem.GlyphItemPublic),
                                                    Enum.GetName(typeof(PythonMemberType), memberResult.MemberType)
                                                    ));
        }
コード例 #35
0
        public ImageSource getImage(TypeExpression type, IGlyphService glyphService)
        {
            //StandardGlyphGroup group;
            StandardGlyphItem item = StandardGlyphItem.GlyphItemPublic;

            if (type is IMemberType)
            {
                //group = this.getGroupVSValue(type);
                if (((IMemberType)type).MemberInfo != null)
                {
                    item = this.getItemVSValue(((IMemberType)type).MemberInfo);
                }
            }

            return(glyphService.GetGlyph(this.getGroupVSValue(type), item));
        }
コード例 #36
0
        public CompletionCompiler(IGlyphService glyphs)
        {
            Glyphs = glyphs;

            IconMappings = new Dictionary<SassCompletionValueType, ImageSource>
            {
                { SassCompletionValueType.Default, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupUnknown, StandardGlyphItem.TotalGlyphItems) },
                { SassCompletionValueType.Keyword, Glyphs.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.TotalGlyphItems) },
                { SassCompletionValueType.SystemFunction, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic) },
                { SassCompletionValueType.UserFunction, Glyphs.GetGlyph(StandardGlyphGroup.GlyphExtensionMethod, StandardGlyphItem.GlyphItemInternal) },
                { SassCompletionValueType.Mixin, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupInterface, StandardGlyphItem.GlyphItemInternal) },
                { SassCompletionValueType.Variable, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemInternal) },
                { SassCompletionValueType.Property, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.TotalGlyphItems) }
            };
        }
コード例 #37
0
        public CompletionCompiler(IGlyphService glyphs)
        {
            Glyphs = glyphs;

            IconMappings = new Dictionary <SassCompletionValueType, ImageSource>
            {
                { SassCompletionValueType.Default, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupUnknown, StandardGlyphItem.TotalGlyphItems) },
                { SassCompletionValueType.Keyword, Glyphs.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.TotalGlyphItems) },
                { SassCompletionValueType.SystemFunction, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic) },
                { SassCompletionValueType.UserFunction, Glyphs.GetGlyph(StandardGlyphGroup.GlyphExtensionMethod, StandardGlyphItem.GlyphItemInternal) },
                { SassCompletionValueType.Mixin, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupInterface, StandardGlyphItem.GlyphItemInternal) },
                { SassCompletionValueType.Variable, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemInternal) },
                { SassCompletionValueType.Property, Glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.TotalGlyphItems) }
            };
        }
コード例 #38
0
ファイル: IconHelper.cs プロジェクト: Rickinio/roslyn
        public static void Initialize(IGlyphService glyphService, IIconService iconService)
        {
            var supportedGlyphGroups = new Dictionary<StandardGlyphGroup, string>
            {
                { StandardGlyphGroup.GlyphGroupError, "Error" },
                { StandardGlyphGroup.GlyphGroupDelegate, "Delegate" },
                { StandardGlyphGroup.GlyphGroupEnum, "Enum" },
                { StandardGlyphGroup.GlyphGroupStruct, "Struct" },
                { StandardGlyphGroup.GlyphGroupClass, "Class" },
                { StandardGlyphGroup.GlyphGroupInterface, "Interface" },
                { StandardGlyphGroup.GlyphGroupModule, "Module" },
                { StandardGlyphGroup.GlyphGroupConstant, "Constant" },
                { StandardGlyphGroup.GlyphGroupEnumMember, "EnumMember" },
                { StandardGlyphGroup.GlyphGroupEvent, "Event" },
                { StandardGlyphGroup.GlyphExtensionMethodPrivate, "ExtensionMethodPrivate" },
                { StandardGlyphGroup.GlyphExtensionMethodProtected, "ExtensionMethodProtected" },
                { StandardGlyphGroup.GlyphExtensionMethodInternal, "ExtensionMethodInternal" },
                { StandardGlyphGroup.GlyphExtensionMethod, "ExtensionMethod" },
                { StandardGlyphGroup.GlyphGroupMethod, "Method" },
                { StandardGlyphGroup.GlyphGroupProperty, "Property" },
                { StandardGlyphGroup.GlyphGroupField, "Field" },
                { StandardGlyphGroup.GlyphGroupOperator, "Operator" },
                { StandardGlyphGroup.GlyphReference, "Reference" }
            };

            var supportedGlyphItems = new Dictionary<StandardGlyphItem, string>
            {
                { StandardGlyphItem.GlyphItemPrivate, "Private" },
                { StandardGlyphItem.GlyphItemProtected, "Protected" },
                { StandardGlyphItem.GlyphItemInternal, "Internal" },
                { StandardGlyphItem.GlyphItemPublic, "Public" },
                { StandardGlyphItem.GlyphItemFriend, "Friend" }
            };

            foreach (var groupKvp in supportedGlyphGroups)
            {
                foreach (var itemKvp in supportedGlyphItems)
                {
                    string iconName = GetIconName(groupKvp.Value, itemKvp.Value);
                    StandardGlyphGroup localGroup = groupKvp.Key;
                    StandardGlyphItem localItem = itemKvp.Key;
                    iconService.AddIcon(iconName, iconName, () => glyphService.GetGlyph(localGroup, localItem));
                }
            }
        }
コード例 #39
0
ファイル: CompletionAnalysis.cs プロジェクト: rkhjjs/VSGenero
        internal static DynamicallyVisibleCompletion GeneroCompletion(IGlyphService service, MemberResult memberResult)
        {
            var compl = new DynamicallyVisibleCompletion(memberResult.Name,
                                                         memberResult.Completion,
                                                         () => memberResult.Documentation,
                                                         () => service.GetGlyph(memberResult.MemberType.ToGlyphGroup(), StandardGlyphItem.GlyphItemPublic),
                                                         Enum.GetName(typeof(GeneroMemberType), memberResult.MemberType)
                                                         );

            // Handle case where we can provide pseudo-class completions for functions
            var resVar = memberResult.Var;

            if (resVar is IFunctionResult && !string.IsNullOrWhiteSpace((resVar as IFunctionResult).CompletionParentName))
            {
                compl.Properties.AddProperty(CompletionParentPropertyName, (resVar as IFunctionResult).CompletionParentName);
            }
            return(compl);
        }
コード例 #40
0
        public System.Windows.Media.ImageSource GetImageSource(Type type)
        {
            StandardGlyphGroup group;
            StandardGlyphItem  item = StandardGlyphItem.GlyphItemPublic;

            switch (type.Name)
            {
            case "LuaTable": group = StandardGlyphGroup.GlyphGroupClass; break;

            case "LuaFunction": group = StandardGlyphGroup.GlyphGroupMethod; break;

            case "LuaMember": group = StandardGlyphGroup.GlyphGroupField; break;

            default:
                group = StandardGlyphGroup.GlyphGroupVariable; break;
            }
            return(GlyphService.GetGlyph(group, item));
        }
コード例 #41
0
        private void SaveGlyphsToDisk(string folder)
        {
            Array groups = Enum.GetValues(typeof(StandardGlyphGroup));
            Array items  = Enum.GetValues(typeof(StandardGlyphItem));

            foreach (var groupName in groups)
            {
                int    count       = 0;
                string glyphFolder = Path.Combine(folder, groupName.ToString());
                var    sprite      = new WriteableBitmap(16, 16 * (items.Length), 96, 96, PixelFormats.Pbgra32, null);
                sprite.Lock();

                foreach (var itemName in items)
                {
                    StandardGlyphGroup group = (StandardGlyphGroup)groupName;
                    StandardGlyphItem  item  = (StandardGlyphItem)itemName;

                    BitmapSource glyph = _glyphService.GetGlyph(group, item) as BitmapSource;

                    if (glyph == null)
                    {
                        continue;
                    }

                    string fileName = Path.Combine(folder, group.ToString(), item.ToString() + ".png");

                    SaveBitmapToDisk(glyph, fileName);

                    int    stride = glyph.PixelWidth * (glyph.Format.BitsPerPixel / 8);
                    byte[] data   = new byte[stride * glyph.PixelHeight];
                    glyph.CopyPixels(data, stride, 0);

                    sprite.WritePixels(
                        new Int32Rect(0, count, glyph.PixelWidth, glyph.PixelHeight),
                        data, stride, 0);

                    count += 16;
                }

                sprite.Unlock();
                SaveBitmapToDisk(sprite, Path.Combine(folder, "_sprites", groupName + ".png"));
            }
        }
コード例 #42
0
 public PaketCompletionSource(IGlyphService glyphService, ITextBuffer textBuffer, ITextStructureNavigator navigator)
 {
     this.textBuffer = textBuffer;
     this.navigator = navigator;
     glyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);
 }
コード例 #43
0
ファイル: CompletionAnalysis.cs プロジェクト: TerabyteX/main
        internal static Completion PythonCompletion(IGlyphService service, string name, string tooltip, StandardGlyphGroup group)
        {
            var icon = new IconDescription(group, StandardGlyphItem.GlyphItemPublic);

            var result = new LazyCompletion(name, () => name, () => tooltip, service.GetGlyph(group, StandardGlyphItem.GlyphItemPublic));
            result.Properties.AddProperty(typeof(IconDescription), icon);
            return result;
        }
コード例 #44
0
        public override CompletionSet GetCompletions(IGlyphService glyphService)
        {
            var snapshot = TextBuffer.CurrentSnapshot;
            var span = snapshot.GetApplicableSpan(Span.GetStartPoint(snapshot));
            var text = span.GetText(snapshot);

            var classifier = snapshot.TextBuffer.GetPythonClassifier();
            var token = classifier.GetClassificationSpans(span.GetSpan(snapshot)).LastOrDefault();
            bool quoteBackslash = !token.Span.GetText().TakeWhile(c => !QuoteChars.Contains(c)).Any(c => c == 'r' || c == 'R');

            if (quoteBackslash) {
                text = text.Replace("\\\\", "\\");
            }

            string cwd;
            var replEval = TextBuffer.GetInteractiveWindow()?.GetPythonEvaluator();
            if (replEval != null) {
                cwd = replEval.CurrentWorkingDirectory;
            } else if (!string.IsNullOrEmpty(cwd = TextBuffer.GetFilePath())) {
                cwd = PathUtils.GetParent(cwd);
            } else {
                cwd = Environment.CurrentDirectory;
            }

            var completions = GetEntryInfo(text, cwd, Environment.GetFolderPath(Environment.SpecialFolder.UserProfile))
                .Select(e => new DynamicallyVisibleCompletion(
                    e.Caption,
                    quoteBackslash ? e.InsertionText.Replace("\\", "\\\\") : e.InsertionText,
                    e.Tooltip,
                    glyphService.GetGlyph(
                        e.IsFile ? StandardGlyphGroup.GlyphLibrary : StandardGlyphGroup.GlyphClosedFolder,
                        StandardGlyphItem.GlyphItemPublic
                    ),
                    e.IsFile ? "File" : "Directory"
                )).ToArray();

            if (completions.Length == 0) {
                return null;
            }

            return new FuzzyCompletionSet(
                "PythonFilenames",
                "Files",
                Span,
                completions,
                _options,
                CompletionComparer.UnderscoresLast,
                matchInsertionText: true
            );
        }
コード例 #45
0
 private ImageSource GetIconSource(IGlyphService glyphService, SpringCompletionType type)
 {
     switch (type)
     {
         case SpringCompletionType.Namespace:
         case SpringCompletionType.Class:
         case SpringCompletionType.Interface:
         case SpringCompletionType.Property:
         case SpringCompletionType.ConstructorArg:
         case SpringCompletionType.EnumMember:
         case SpringCompletionType.Boolean:
             return glyphService.GetGlyph(GetGroupFromDeclaration(type), GetScopeFromDeclaration(type));
         case SpringCompletionType.Snippet:
         case SpringCompletionType.Alias:
             return SpringLeafGlyph;
         default:
             return glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupClass, StandardGlyphItem.GlyphItemPublic);
     }
 }
コード例 #46
0
 public RobotsTxtCompletionSource(ITextBuffer buffer, IGlyphService glyphService)
 {
     _buffer = buffer;
     _glyph = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic);
 }
コード例 #47
0
ファイル: JNavigateToItemDisplay.cs プロジェクト: borota/JTVS
        private static Icon GetIcon(IGlyphService glyphService, StandardGlyphGroup glyphGroup)
        {
            Icon icon = null;
            if (_iconCache.TryGetValue(glyphGroup, out icon)) {
                return icon;
            }

            BitmapSource glyph = glyphService.GetGlyph(glyphGroup, StandardGlyphItem.GlyphItemPublic) as BitmapSource;
            if (glyph != null) {
                Bitmap bmp = new Bitmap(glyph.PixelWidth, glyph.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
                BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
                glyph.CopyPixels(Int32Rect.Empty, bmpData.Scan0, bmpData.Height * bmpData.Stride, bmpData.Stride);
                bmp.UnlockBits(bmpData);
                icon = Icon.FromHandle(bmp.GetHicon());
            }

            _iconCache[glyphGroup] = icon;
            return icon;
        }
コード例 #48
0
ファイル: Editor.cs プロジェクト: ChinaJason/Typewriter
        public IEnumerable<Completion> GetCompletions(ITextBuffer buffer, SnapshotSpan span, IGlyphService glyphService)
        {
            var semanticModel = GetSemanticModel(buffer);
            var identifiers = semanticModel.GetIdentifiers(span.Start);
            var contextSpan = semanticModel.GetContextSpan(span.Start);
            var prefix = contextSpan.Type == ContextType.Template ? "$" : "";

            var completions = identifiers.Select(i =>
            {
                var imageSource = glyphService.GetGlyph(i.Glyph, StandardGlyphItem.GlyphItemPublic);
                var quickInfo = i.IsParent ? i.QuickInfo.Replace("Item", contextSpan.ParentContext?.Name) : i.QuickInfo;

                return new Completion(prefix + i.Name, prefix + i.Name, quickInfo, imageSource, null);
            });

            if (contextSpan.Type == ContextType.Template && contextSpan.Context.Name == nameof(File))
            {
                var imageSource = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic);
                var codeBlock = new[]
                {
                    new Completion("${ }", "${\r\n}", "Insert a custom C# code block.", imageSource, null)
                };

                return codeBlock.Concat(completions);
            }

            return completions;
        }
コード例 #49
0
ファイル: CompletionAnalysis.cs プロジェクト: TerabyteX/main
        internal static Completion PythonCompletion(IGlyphService service, MemberResult memberResult)
        {
            StandardGlyphGroup group = memberResult.MemberType.ToGlyphGroup();
            var icon = new IconDescription(group, StandardGlyphItem.GlyphItemPublic);

            var result = new LazyCompletion(memberResult.Name, () => memberResult.Completion, () => memberResult.ToolTip, service.GetGlyph(group, StandardGlyphItem.GlyphItemPublic));
            result.Properties.AddProperty(typeof(IconDescription), icon);
            return result;
        }
コード例 #50
0
ファイル: GlyphExtensions.cs プロジェクト: CAPCHIK/roslyn
 public static ImageSource GetImageSource(this Glyph glyph, IGlyphService glyphService)
 {
     return glyphService.GetGlyph(glyph.GetStandardGlyphGroup(), glyph.GetStandardGlyphItem());
 }
コード例 #51
0
ファイル: Editor.cs プロジェクト: Kymeric/Typewriter
        public IEnumerable<Completion> GetCompletions(ITextBuffer buffer, SnapshotSpan span, IGlyphService glyphService)
        {
            var semanticModel = GetSemanticModel(buffer);
            var identifiers = semanticModel.GetIdentifiers(span.Start);
            var contextSpan = semanticModel.GetContextSpan(span.Start);
            var prefix = contextSpan.Type == ContextType.Template ? "$" : "";

            return identifiers.Select(i =>
            {
                var imageSource = glyphService.GetGlyph(i.Glyph, StandardGlyphItem.GlyphItemPublic);
                var quickInfo = i.IsParent ? i.QuickInfo.Replace("$parent", contextSpan.ParentContext?.Name.ToLowerInvariant()) : i.QuickInfo;

                return new Completion(prefix + i.Name, prefix + i.Name, quickInfo, imageSource, null);
            });
        }