Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        internal void CanceledMonitorTextBuffer(AnalysisEntry entry, ITextBuffer textBuffer)
        {
            string path = entry.FilePath;

            if (_projectFiles.ContainsKey(path))
            {
                _projectFiles.Remove(path);
            }
            textBuffer.Changed -= TextBufferChanged;
        }
Ejemplo n.º 3
0
 public LuaModel(ParseTree parseTree, string filePath)
 {
     _parseTree = parseTree;
     _entry     = null;
     _filePath  = filePath;
     if (_parseTree.Root != null)
     {
         _root = _parseTree.Root.AstNode as LuaChunkNode;
         WalkASTForDeclarations();
     }
 }
Ejemplo n.º 4
0
 public LuaModel(ParseTree parseTree, AnalysisEntry entry)
 {
     _parseTree = parseTree;
     _entry     = entry;
     _filePath  = entry.FilePath;
     if (_parseTree.Root != null)
     {
         _root = _parseTree.Root.AstNode as LuaChunkNode;
         WalkASTForDeclarations();
     }
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 private async void TextBufferChanged(object sender, TextContentChangedEventArgs e)
 {
     AnalysisEntry entry = _projectFiles[e.After.TextBuffer.GetFilePath()];
     await entry.UpdateModel(e.After.GetText());
 }
Ejemplo n.º 9
0
 public bool TryGetAnalysisEntry(ITextBuffer textBuffer, out AnalysisEntry entry)
 {
     return(TryGetAnalysisEntry(null, textBuffer, out entry));
 }