public static AnalysisEntry Initialize(IServiceProvider serviceProvider, ITextBuffer textBuffer) { AnalysisEntry analysisEntry; IVsSolution sln = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution; IVsProject proj = sln.GetLoadedProject(); // if not a NPL project if (proj == null) { analysisEntry = textBuffer.GetAnalysisAtCaretSingletonMode(); // if not register yet, register it if (analysisEntry == null) { analysisEntry = new AnalysisEntry(textBuffer.GetFilePath()); analysisEntry.RegisterSingletonMode(textBuffer); } } else { var project = sln.GetLoadedProject().GetNPLProject(); if (!project.Analyzer.HasMonitoredTextBuffer(textBuffer)) { project.Analyzer.MonitorTextBuffer(textBuffer); } analysisEntry = textBuffer.GetAnalysisAtCaretProjectMode(serviceProvider); } return(analysisEntry); }
internal void CanceledMonitorTextBuffer(AnalysisEntry entry, ITextBuffer textBuffer) { string path = entry.FilePath; if (_projectFiles.ContainsKey(path)) { _projectFiles.Remove(path); } textBuffer.Changed -= TextBufferChanged; }
public LuaModel(ParseTree parseTree, string filePath) { _parseTree = parseTree; _entry = null; _filePath = filePath; if (_parseTree.Root != null) { _root = _parseTree.Root.AstNode as LuaChunkNode; WalkASTForDeclarations(); } }
public LuaModel(ParseTree parseTree, AnalysisEntry entry) { _parseTree = parseTree; _entry = entry; _filePath = entry.FilePath; if (_parseTree.Root != null) { _root = _parseTree.Root.AstNode as LuaChunkNode; WalkASTForDeclarations(); } }
internal AnalysisEntry CreateAnalysisEntry(string path) { Random random = new Random(); int id; do { id = random.Next(1000); // TODO: use a more proper number } while (_projectFilesById.ContainsKey(id)); AnalysisEntry entry = new AnalysisEntry(this, path, id); _projectFiles[path] = entry; _projectFilesById[id] = entry; return(entry); }
internal AnalysisEntry CreateAnalysisEntry(ITextBuffer textBuffer) { string path = textBuffer.GetFilePath(); Random random = new Random(); int id; do { id = random.Next(1000); // TODO: use a more proper number } while (_projectFilesById.ContainsKey(id)); _projectBufferById[id] = textBuffer; // TODO: move to a better place AnalysisEntry entry = new AnalysisEntry(this, path, id); _projectFiles[path] = entry; _projectFilesById[id] = entry; return(entry); }
public bool TryGetAnalysisEntry(ITextView textView, ITextBuffer textBuffer, out AnalysisEntry entry) { ProjectAnalyzer analyzer; string filename; if ((textView == null || !TryGetAnalyzer(textView, out analyzer, out filename)) && !TryGetAnalyzer(textBuffer, out analyzer, out filename)) { entry = null; return(false); } if (analyzer != null) { entry = analyzer.GetAnalysisEntryFromPath(filename); return(entry != null); } entry = null; return(true); }
private async void TextBufferChanged(object sender, TextContentChangedEventArgs e) { AnalysisEntry entry = _projectFiles[e.After.TextBuffer.GetFilePath()]; await entry.UpdateModel(e.After.GetText()); }
public bool TryGetAnalysisEntry(ITextBuffer textBuffer, out AnalysisEntry entry) { return(TryGetAnalysisEntry(null, textBuffer, out entry)); }