void UpdateFromProject()
        {
            files.Clear();
            foreach (string fileName in from pf in Project.Files where pf.BuildAction == BuildAction.Compile select pf.Name)
            {
                if (!files.Contains(fileName))
                {
                    files.Add(fileName);
                    ProjectDomService.QueueParseJob(this, new JobCallback(ParseCallback), fileName);
                }
            }

            if (Project is DotNetProject)
            {
                DotNetProject netProject = (DotNetProject)Project;
                referenceUris.Clear();
                foreach (ProjectReference pr in netProject.References)
                {
                    foreach (string refId in GetReferenceKeys(pr))
                    {
                        referenceUris.Add(refId);
                    }
                }
                UpdateReferences();
            }
            UpdateCorlibReference();
        }
Example #2
0
        void StartReparseThread()
        {
            // Don't directly parse the document because doing it at every key press is
            // very inefficient. Do it after a small delay instead, so several changes can
            // be parsed at the same time.
            string currentParseFile = FileName;

            if (parseTimeout != 0)
            {
                GLib.Source.Remove(parseTimeout);
            }
            parseTimeout = GLib.Timeout.Add(ParseDelay, delegate {
                string currentParseText    = Editor.Text;
                Project curentParseProject = Project;
                // parser revice queue takes care of the locking
                ProjectDomService.QueueParseJob(dom, delegate(string name, IProgressMonitor monitor) {
                    var currentParsedDocument = ProjectDomService.Parse(curentParseProject, currentParseFile, currentParseText);
                    Application.Invoke(delegate {
                        this.parsedDocument = currentParsedDocument;
                        if (this.parsedDocument != null && !this.parsedDocument.HasErrors)
                        {
                            this.lastErrorFreeParsedDocument = parsedDocument;
                        }
                        OnDocumentParsed(EventArgs.Empty);
                    });
                }, FileName);
                parseTimeout = 0;
                return(false);
            });
        }
Example #3
0
        void OnClosed(object s, EventArgs a)
        {
            ProjectDomService.DomRegistered -= UpdateRegisteredDom;
            if (parseTimeout != 0)
            {
                GLib.Source.Remove(parseTimeout);
                parseTimeout = 0;
            }
            ClearTasks();

            string  currentParseFile   = FileName;
            Project curentParseProject = Project;

            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).DetachFromPathedDocument();
            }
            window.Closed -= OnClosed;
            window.ActiveViewContentChanged -= OnActiveViewContentChanged;
            if (IdeApp.Workspace != null)
            {
                IdeApp.Workspace.ItemRemovedFromSolution -= OnEntryRemoved;
            }

            try {
                OnClosed(a);
            } catch (Exception ex) {
                LoggingService.LogError("Exception while calling OnClosed.", ex);
            }

            while (editorExtension != null)
            {
                try {
                    editorExtension.Dispose();
                } catch (Exception ex) {
                    LoggingService.LogError("Exception while disposing extension:" + editorExtension, ex);
                }
                editorExtension = editorExtension.Next as TextEditorExtension;
            }

            // Parse the file when the document is closed. In this way if the document
            // is closed without saving the changes, the saved compilation unit
            // information will be restored
            if (currentParseFile != null)
            {
                ProjectDomService.QueueParseJob(dom, delegate(string name, IProgressMonitor monitor) {
                    ProjectDomService.Parse(curentParseProject, currentParseFile);
                }, FileName);
            }
            if (isFileDom)
            {
                ProjectDomService.RemoveFileDom(FileName);
                dom = null;
            }

            Counters.OpenDocuments--;
        }
Example #4
0
        public TypeUpdateInformation UpdateFromParseInfo(ICompilationUnit parserInfo, string fileName, bool isFromFile)
        {
            lock (rwlock) {
                ICompilationUnit cu = parserInfo;

                List <IType>      resolved;
                List <IAttribute> resolvedAtts;

                int unresolvedCount = ResolveTypes(cu, cu.Types, cu.Attributes, out resolved, out resolvedAtts);
                totalUnresolvedCount += unresolvedCount;

                TypeUpdateInformation res = UpdateTypeInformation(resolved, resolvedAtts, parserInfo.FileName);

                FileEntry file;
                if (files.TryGetValue(fileName, out file))
                {
                    if (unresolvedCount > 0)
                    {
                        if (file.ParseErrorRetries != 1)
                        {
                            file.ParseErrorRetries = 1;

                            // Enqueue the file for quickly reparse. Types can't be resolved most probably because
                            // the file that implements them is not yet parsed.

                            if (isFromFile)
                            {
                                // To reduce memory usage, we don't keep the compilation unit in memory if the
                                // content comes from a saved file. We'll just reparse the file.
                                file.InParseQueue = false;
                                QueueParseJob(file);
                            }
                            else
                            {
                                ProjectDomService.QueueParseJob(SourceProjectDom,
                                                                delegate { UpdateFromParseInfo(parserInfo, fileName, false); },
                                                                file.FileName);
                            }
                        }
                    }
                    else
                    {
                        file.ParseErrorRetries = 0;
                    }
                }

                if ((++parseCount % MAX_ACTIVE_COUNT) == 0)
                {
                    Flush();
                }
                return(res);
            }
        }
        public TypeUpdateInformation UpdateFromParseInfo(ICompilationUnit parserInfo, string fileName)
        {
            lock (rwlock) {
                ICompilationUnit cu = parserInfo;

                List <IType>      resolved;
                List <IAttribute> resolvedAtts;

                int unresolvedCount = ResolveTypes(cu, cu.Types, cu.Attributes, out resolved, out resolvedAtts);
                totalUnresolvedCount += unresolvedCount;

                TypeUpdateInformation res = UpdateTypeInformation(resolved, resolvedAtts, parserInfo.FileName);

                FileEntry file;
                if (files.TryGetValue(fileName, out file))
                {
                    if (unresolvedCount > 0)
                    {
                        if (file.ParseErrorRetries != 1)
                        {
                            file.ParseErrorRetries = 1;

                            // Enqueue the file for quickly reparse. Types can't be resolved most probably because
                            // the file that implements them is not yet parsed.
                            ProjectDomService.QueueParseJob(SourceProjectDom,
                                                            delegate { UpdateFromParseInfo(parserInfo, fileName); },
                                                            file.FileName);
                        }
                    }
                    else
                    {
                        file.ParseErrorRetries = 0;
                    }
                }

                if ((++parseCount % MAX_ACTIVE_COUNT) == 0)
                {
                    Flush();
                }
                return(res);
            }
        }