public override TypeUpdateInformation UpdateFromParseInfo(ICompilationUnit cu)
        {
            //List<IType> types = new List<IType> (cu.Types);
            //ProjectDomService.ResolveTypes (this, cu, ResolveTypeParameters (cu.Types), out types);
            List <IType> types = ResolveTypeParameters(cu.Types);

            //	totalUnresolvedCount += unresolvedCount;
            units.Add(cu);
            TypeUpdateInformation res = UpdateTypeInformation(types, cu.FileName);
            int fileParseErrorRetries = 0;

            files.TryGetValue(cu.FileName, out fileParseErrorRetries);

            /*	if (unresolvedCount > 0) {
             *              if (fileParseErrorRetries != 1) {
             *                      files[cu.FileName] = 1;
             *
             *                      ProjectDomService.ResolveTypes (this, cu, cu.Types, out resolved);
             *                      res = UpdateTypeInformation (resolved, cu.FileName);
             *              }
             *      } else {
             *              files[cu.FileName] = 0;
             *      }*/

            return(res);
        }
        public TypeUpdateInformation UpdateTypeInformation(IList <IType> newClasses, string fileName)
        {
            TypeUpdateInformation res = new TypeUpdateInformation();

            //Console.WriteLine ("UPDATE TYPE INFO: " + newClasses.Count);
            for (int n = 0; n < newClasses.Count; n++)
            {
                IType c = newClasses[n];
                c.SourceProjectDom = this;

                // Remove file from compound types.
                NamespaceEntry entry = rootNamespace.FindNamespace(c.Namespace, true);
                IType          t;
                if (entry.ContainingTypes.TryGetValue(NamespaceEntry.GetDecoratedName(c), out t))
                {
                    CompoundType.RemoveFile(t, c.CompilationUnit.FileName);
                }
            }

            for (int n = 0; n < newClasses.Count; n++)
            {
                IType          c     = newClasses[n];
                NamespaceEntry entry = rootNamespace.FindNamespace(c.Namespace, true);
                entry.Add(c);
                ResetInstantiatedTypes(c);
            }
            //Console.WriteLine ("root:" + rootNamespace);
            return(res);
        }
예제 #3
0
 public static void NotifyTypeUpdate(Project project, string fileName, TypeUpdateInformation info)
 {
     if (TypesUpdated != null)
     {
         TypesUpdated(null, new TypeUpdateInformationEventArgs(project, info));
     }
 }
 protected override void OnFileRemoved(string fileName, TypeUpdateInformation classInfo)
 {
     if (classInfo.Removed.Count > 0)
     {
         ProjectDomService.NotifyTypeUpdate(project, fileName, classInfo);
     }
 }
예제 #5
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 cu)
        {
            if (cu == null)
            {
                return(new TypeUpdateInformation());
            }
            // TODO dom Get tag comments
//			UpdateTagComments (cu.TagComments, file);
            List <IType> resolved;

            ProjectDomService.ResolveTypes(SourceProjectDom, cu, cu.Types, out resolved);
            TypeUpdateInformation res = UpdateTypeInformation(resolved, file);

            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);
            }
        }
예제 #8
0
		public static void NotifyTypeUpdate (Project project, string fileName, TypeUpdateInformation info)
		{
			if (TypesUpdated != null)
				TypesUpdated (null, new TypeUpdateInformationEventArgs (project, info));
		}
		protected override void OnFileRemoved (string fileName, TypeUpdateInformation classInfo)
		{
			if (classInfo.Removed.Count > 0)
				ProjectDomService.NotifyTypeUpdate (project, fileName, classInfo);
		}
 public ClassInformationEventArgs(string fileName, TypeUpdateInformation classInformation, Project project)
 {
     this.project          = project;
     this.fileName         = fileName;
     this.classInformation = classInformation;
 }
		public ClassInformationEventArgs(string fileName, TypeUpdateInformation classInformation, Project project)
		{
			this.project = project;
			this.fileName = fileName;
			this.classInformation = classInformation;
		}
예제 #12
0
        static ParsedDocument UpdateFile(Project[] projects, string fileName, Func <string> getContent)
        {
            try {
                if (GetParser(fileName) == null)
                {
                    return(null);
                }

                ParsedDocument parseInformation = null;
                string         fileContent;
                if (getContent == null)
                {
                    if (!System.IO.File.Exists(fileName))
                    {
                        fileContent = "";
                    }
                    else
                    {
                        try {
                            fileContent = System.IO.File.ReadAllText(fileName);
                        } catch (Exception e) {
                            LoggingService.LogError("Error reading file {0} for ProjectDomService: {1}", fileName, e);
                            fileContent = "";
                        }
                    }
                }
                else
                {
                    fileContent = getContent();
                }

                // Remove any pending jobs for this file
                RemoveParseJob(fileName);
                ProjectDom dom = projects != null && projects.Length > 0 ? GetProjectDom(projects [0]) : null;
                parseInformation = DoParseFile(dom, fileName, fileContent);
                if (parseInformation == null)
                {
                    return(null);
                }
                // don't update project dom with incorrect parse informations, they may not contain all
                // information.
                if (projects != null && projects.Length > 0 && parseInformation.CompilationUnit != null)
                {
                    SetSourceProject(parseInformation.CompilationUnit, dom);
                }

//				if (parseInformation.Errors.Any ()) {
//					Console.WriteLine (fileName + "-- Errors:");
//					foreach (var e in parseInformation.Errors) {
//						Console.WriteLine (e);
//					}
//				}

                if (parseInformation.CompilationUnit != null &&
                    (parseInformation.Flags & ParsedDocumentFlags.NonSerializable) == 0)
                {
                    if (projects != null && projects.Length > 0)
                    {
                        foreach (Project project in projects)
                        {
                            ProjectDom db = GetProjectDom(project);
                            if (db != null)
                            {
                                try {
                                    if (parseInformation.HasErrors)
                                    {
                                        db.UpdateTemporaryCompilationUnit(parseInformation.CompilationUnit);
                                    }
                                    else
                                    {
                                        db.UpdateTagComments(fileName, parseInformation.TagComments);
                                        db.RemoveTemporaryCompilationUnit(parseInformation.CompilationUnit);
                                        TypeUpdateInformation res = db.UpdateFromParseInfo(parseInformation.CompilationUnit, getContent == null);
                                        if (res != null)
                                        {
                                            NotifyTypeUpdate(project, fileName, res);
                                        }
                                        UpdatedCommentTasks(fileName, parseInformation.TagComments, project);
                                    }
                                } catch (Exception e) {
                                    LoggingService.LogError(e.ToString());
                                }
                            }
                        }
                    }
                    else
                    {
                        ProjectDom db = GetFileDom(fileName);
                        db.UpdateFromParseInfo(parseInformation.CompilationUnit, getContent == null);
                    }
                }

                return(parseInformation);
            } catch (Exception e) {
                LoggingService.LogError(e.ToString());
                return(null);
            }
        }
        static ParsedDocument UpdateFile(Project[] projects, string fileName, string mimeType, ContentDelegate getContent)
        {
            try {
                if (GetParser(fileName, mimeType) == null)
                {
                    return(null);
                }

                ParsedDocument parseInformation = null;
                string         fileContent;
                if (getContent == null)
                {
                    StreamReader sr = new StreamReader(fileName);
                    fileContent = sr.ReadToEnd();
                    sr.Close();
                }
                else
                {
                    fileContent = getContent();
                }

                // Remove any pending jobs for this file
                RemoveParseJob(fileName);
                ProjectDom dom = projects != null && projects.Length > 0 ? GetProjectDom(projects [0]) : null;
                parseInformation = DoParseFile(dom, fileName, fileContent);
                if (parseInformation == null)
                {
                    return(null);
                }
                // don't update project dom with incorrect parse informations, they may not contain all
                // information.
                if (projects != null && projects.Length > 0 && parseInformation.CompilationUnit != null)
                {
                    SetSourceProject(parseInformation.CompilationUnit, dom);
                }
                if (parseInformation.CompilationUnit != null &&
                    (parseInformation.Flags & ParsedDocumentFlags.NonSerializable) == 0)
                {
                    if (projects != null && projects.Length > 0)
                    {
                        foreach (Project project in projects)
                        {
                            ProjectDom db = GetProjectDom(project);
                            if (db != null)
                            {
                                try {
                                    if (parseInformation.HasErrors)
                                    {
                                        db.UpdateTemporaryCompilationUnit(parseInformation.CompilationUnit);
                                    }
                                    else
                                    {
                                        db.UpdateTagComments(fileName, parseInformation.TagComments);
                                        db.RemoveTemporaryCompilationUnit(parseInformation.CompilationUnit);
                                        TypeUpdateInformation res = db.UpdateFromParseInfo(parseInformation.CompilationUnit);
                                        if (res != null)
                                        {
                                            NotifyTypeUpdate(project, fileName, res);
                                        }
                                        UpdatedCommentTasks(fileName, parseInformation.TagComments, project);
                                    }
                                } catch (Exception e) {
                                    LoggingService.LogError(e.ToString());
                                }
                            }
                        }
                    }
                    else
                    {
                        ProjectDom db = GetFileDom(fileName);
                        db.UpdateFromParseInfo(parseInformation.CompilationUnit);
                    }
                }

                return(parseInformation);
            } catch (Exception e) {
                LoggingService.LogError(e.ToString());
                return(null);
            }
        }