private void UpdateHighlightingStyles(AsyncServerMessage.LanguageLoaded languageInfo) { _highlightingStyles[CurrentAstSpanClassId] = new HighlightingColor { Background = new SimpleHighlightingBrush(Brushes.LightCyan) }; foreach (var spanClassInfo in languageInfo.spanClassInfos) _highlightingStyles[spanClassInfo.Id] = new HighlightingColor { Foreground = new SimpleHighlightingBrush(ColorFromArgb(spanClassInfo.ForegroundColor)) }; }
void Response(AsyncServerMessage msg) { Debug.Assert(msg.FileId >= 0); ITextBuffer textBuffer = _textBuffer; OutliningCreated outlining; KeywordsHighlightingCreated keywordHighlighting; SymbolsHighlightingCreated symbolsHighlighting; MatchedBrackets matchedBrackets; MappingMessages mappingMessages; ParsingMessages parsingMessages; SemanticAnalysisMessages semanticAnalysisMessages; Hint hint; if ((outlining = msg as OutliningCreated) != null) { var tegget = (OutliningTagger)textBuffer.Properties.GetProperty(Constants.OutliningTaggerKey); tegget.Update(outlining); } else if ((keywordHighlighting = msg as KeywordsHighlightingCreated) != null) { UpdateSpanInfos(HighlightingType.Keyword, keywordHighlighting.spanInfos, keywordHighlighting.Version); } else if ((symbolsHighlighting = msg as SymbolsHighlightingCreated) != null) { UpdateSpanInfos(HighlightingType.Symbol, symbolsHighlighting.spanInfos, symbolsHighlighting.Version); } else if ((matchedBrackets = msg as MatchedBrackets) != null) { if (_activeTextViewModelOpt == null) { return; } _activeTextViewModelOpt.Update(matchedBrackets); } else if ((parsingMessages = msg as ParsingMessages) != null) { UpdateCompilerMessages(0, parsingMessages.messages, parsingMessages.Version); } else if ((mappingMessages = msg as MappingMessages) != null) { UpdateCompilerMessages(1, mappingMessages.messages, mappingMessages.Version); } else if ((semanticAnalysisMessages = msg as SemanticAnalysisMessages) != null) { UpdateCompilerMessages(2, semanticAnalysisMessages.messages, semanticAnalysisMessages.Version); } else if ((hint = msg as Hint) != null) { _mouseHoverTextViewModelOpt?.ShowHint(hint); } }
void Response(AsyncServerMessage msg) { switch (msg) { case AsyncServerMessage.LanguageLoaded languageInfo: var spanClassInfos = languageInfo.spanClassInfos; if (_spanClassInfos.IsDefaultOrEmpty) { _spanClassInfos = spanClassInfos; } else if (!spanClassInfos.IsDefaultOrEmpty) { var bilder = ImmutableArray.CreateBuilder <SpanClassInfo>(_spanClassInfos.Length + spanClassInfos.Length); bilder.AddRange(_spanClassInfos); bilder.AddRange(spanClassInfos); _spanClassInfos = bilder.MoveToImmutable(); } break; case AsyncServerMessage.FindSymbolReferences findSymbolReferences: // передать всем вьюхам отображаемым на экране foreach (var fileModel in _fileModels) { foreach (var textViewModel in fileModel.TextViewModels) { textViewModel.Update(findSymbolReferences); } } break; case AsyncServerMessage.FoundDeclarations found: if (_callback == null) { break; } MatchKind calcKibd(DeclarationInfo decl) { var spans = decl.NameMatchRuns; switch (spans.Length) { case 0: return(MatchKind.None); case 1: var name = decl.Name; var span = decl.NameMatchRuns[0]; if (span.StartPos == 0) { return(span.Length == name.Length ? MatchKind.Exact : MatchKind.Prefix); } return(MatchKind.Substring); default: return(MatchKind.Regular); } } foreach (var decl in found.declarations) { // So far we can use the following kinds "OtherSymbol", "NitraSymbol" // TODO: Allows add user spetified kinds var loc = decl.Location; var fileId = loc.File.FileId; var path = fileId == FileId.Invalid ? "<no file>" : Client.StringManager.GetPath(fileId); var ext = fileId == FileId.Invalid ? "" : Path.GetExtension(path); var lang = _config.Languages.Where(x => x.Extensions.Contains(ext)).Select(x => x.Name).SingleOrDefault() ?? "<Unknown Nitra language>"; _callback.AddItem(new NavigateToItem(decl.Name, "NitraSymbol", lang, decl.FullName, decl, calcKibd(decl), false, _nitraNavigateToItemProvider.GetFactory(this))); } break; } }
void Response(AsyncServerMessage msg) { AsyncServerMessage.LanguageLoaded languageInfo; if ((languageInfo = msg as AsyncServerMessage.LanguageLoaded) != null) { var spanClassInfos = languageInfo.spanClassInfos; if (_spanClassInfos.IsDefaultOrEmpty) _spanClassInfos = spanClassInfos; else if (!spanClassInfos.IsDefaultOrEmpty) { var bilder = ImmutableArray.CreateBuilder<SpanClassInfo>(_spanClassInfos.Length + spanClassInfos.Length); bilder.AddRange(_spanClassInfos); bilder.AddRange(spanClassInfos); _spanClassInfos = bilder.MoveToImmutable(); } } }
void Response(AsyncServerMessage msg) { Debug.Assert(msg.FileId >= 0); ITextBuffer textBuffer = _textBuffer; switch (msg) { case OutliningCreated outlining: var tegget = (OutliningTagger)textBuffer.Properties.GetProperty(Constants.OutliningTaggerKey); tegget.Update(outlining); break; case KeywordsHighlightingCreated keywordHighlighting: UpdateSpanInfos(HighlightingType.Keyword, keywordHighlighting.spanInfos, keywordHighlighting.Version); break; case SymbolsHighlightingCreated symbolsHighlighting: UpdateSpanInfos(HighlightingType.Symbol, symbolsHighlighting.spanInfos, symbolsHighlighting.Version); break; case MatchedBrackets matchedBrackets: if (_activeTextViewModelOpt == null) { return; } _activeTextViewModelOpt.Update(matchedBrackets); break; case ParsingMessages parsingMessages: UpdateCompilerMessages(0, parsingMessages.messages, parsingMessages.Version); break; case MappingMessages mappingMessages: UpdateCompilerMessages(1, mappingMessages.messages, mappingMessages.Version); break; case SemanticAnalysisMessages semanticAnalysisMessages: UpdateCompilerMessages(2, semanticAnalysisMessages.messages, semanticAnalysisMessages.Version); break; case Hint hint: _mouseHoverTextViewModelOpt?.ShowHint(hint); break; case CompleteWord completeWord: if (_completionSession != null) { _completionSession.Properties[Constants.NitraCompleteWord] = completeWord; if (_completionSession.IsStarted) { _completionSession.Recalculate(); } else { _completionSession.Start(); } } break; } }
private void UpdateSymbolsSpanInfos(AsyncServerMessage.SymbolsHighlightingCreated symbolsHighlighting) { _symbolsSpanInfos = symbolsHighlighting.spanInfos; _textEditor.TextArea.TextView.Redraw(); }
private void UpdateKeywordSpanInfos(AsyncServerMessage.KeywordsHighlightingCreated keywordHighlighting) { _keywordsSpanInfos = keywordHighlighting.spanInfos; _textEditor.TextArea.TextView.Redraw(); }
void Response(AsyncServerMessage msg) { Debug.Assert(msg.FileId >= 0); ITextBuffer textBuffer = _textBuffer; OutliningCreated outlining; KeywordsHighlightingCreated keywordHighlighting; SymbolsHighlightingCreated symbolsHighlighting; MatchedBrackets matchedBrackets; MappingMessages mappingMessages; ParsingMessages parsingMessages; SemanticAnalysisMessages semanticAnalysisMessages; FindSymbolReferences findSymbolReferences; Hint hint; if ((outlining = msg as OutliningCreated) != null) { var tegget = (OutliningTagger)textBuffer.Properties.GetProperty(Constants.OutliningTaggerKey); tegget.Update(outlining); } else if ((keywordHighlighting = msg as KeywordsHighlightingCreated) != null) UpdateSpanInfos(HighlightingType.Keyword, keywordHighlighting.spanInfos, keywordHighlighting.Version); else if ((symbolsHighlighting = msg as SymbolsHighlightingCreated) != null) UpdateSpanInfos(HighlightingType.Symbol, symbolsHighlighting.spanInfos, symbolsHighlighting.Version); else if ((matchedBrackets = msg as MatchedBrackets) != null) { if (_activeTextViewModelOpt == null) return; _activeTextViewModelOpt.Update(matchedBrackets); } else if ((findSymbolReferences = msg as FindSymbolReferences) != null) { if (_activeTextViewModelOpt == null) return; _activeTextViewModelOpt.Update(findSymbolReferences); } else if ((parsingMessages = msg as ParsingMessages) != null) UpdateCompilerMessages(0, parsingMessages.messages, parsingMessages.Version); else if ((mappingMessages = msg as MappingMessages) != null) UpdateCompilerMessages(1, mappingMessages.messages, mappingMessages.Version); else if ((semanticAnalysisMessages = msg as SemanticAnalysisMessages) != null) UpdateCompilerMessages(2, semanticAnalysisMessages.messages, semanticAnalysisMessages.Version); else if ((hint = msg as Hint) != null) _mouseHoverTextViewModelOpt?.ShowHint(hint); }
void Response(AsyncServerMessage msg) { ThreadHelper.ThrowIfNotOnUIThread(); if (_disposed) { ReportDisposed(); return; } Debug.Assert(msg.FileId >= 0); ITextBuffer textBuffer = _textBuffer; switch (msg) { case OutliningCreated outlining: if (textBuffer.Properties.TryGetProperty(Constants.OutliningTaggerKey, out OutliningTagger tegget)) { tegget.Update(outlining); } break; case KeywordsHighlightingCreated keywordHighlighting: UpdateSpanInfos(HighlightingType.Keyword, keywordHighlighting.spanInfos, keywordHighlighting.Version); break; case SymbolsHighlightingCreated symbolsHighlighting: UpdateSpanInfos(HighlightingType.Symbol, symbolsHighlighting.spanInfos, symbolsHighlighting.Version); break; case MatchedBrackets matchedBrackets: if (_activeTextViewModelOpt == null) { return; } _activeTextViewModelOpt.Update(matchedBrackets); break; case ParsingMessages parsingMessages: UpdateCompilerMessages(0, parsingMessages.messages, parsingMessages.Version); break; case MappingMessages mappingMessages: UpdateCompilerMessages(1, mappingMessages.messages, mappingMessages.Version); break; case SemanticAnalysisMessages semanticAnalysisMessages: UpdateCompilerMessages(2, semanticAnalysisMessages.messages, semanticAnalysisMessages.Version); break; case Hint hint: if (_hintCompletion == null) { break; } _hintCompletion.SetResult(hint); _hintCancellationTokenRegistration.Dispose(); _hintCompletion = null; break; case CompleteWord completeWord: if (_completionSession != null) { _completionSession.Properties[Constants.NitraCompleteWord] = completeWord; if (_completionSession.IsStarted) { _completionSession.Recalculate(); } else { _completionSession.Start(); } } break; } }