Beispiel #1
0
        IEnumerable <DocumentInfo> CreateDocuments(ProjectData projectData, MonoDevelop.Projects.Project p, CancellationToken token, MonoDevelop.Projects.ProjectFile [] sourceFiles)
        {
            var duplicates = new HashSet <DocumentId> ();

            // use given source files instead of project.Files because there may be additional files added by msbuild targets
            foreach (var f in sourceFiles)
            {
                if (token.IsCancellationRequested)
                {
                    yield break;
                }
                if (f.Subtype == MonoDevelop.Projects.Subtype.Directory)
                {
                    continue;
                }
                if (TypeSystemParserNode.IsCompileBuildAction(f.BuildAction))
                {
                    if (!duplicates.Add(projectData.GetOrCreateDocumentId(f.Name)))
                    {
                        continue;
                    }
                    yield return(CreateDocumentInfo(solutionData, p.Name, projectData, f));
                }
                else
                {
                    foreach (var projectedDocument in GenerateProjections(f, projectData, p))
                    {
                        yield return(projectedDocument);
                    }
                }
            }
        }
Beispiel #2
0
        void OnFileAdded(object sender, MonoDevelop.Projects.ProjectFileEventArgs args)
        {
            if (internalChanges)
            {
                return;
            }
            var project = (MonoDevelop.Projects.Project)sender;

            foreach (MonoDevelop.Projects.ProjectFileEventInfo fargs in args)
            {
                var projectFile = fargs.ProjectFile;
                if (projectFile.Subtype == MonoDevelop.Projects.Subtype.Directory)
                {
                    continue;
                }
                var projectData = GetProjectData(GetProjectId(project));
                if (TypeSystemParserNode.IsCompileBuildAction(projectFile.BuildAction))
                {
                    var newDocument = CreateDocumentInfo(solutionData, project.Name, projectData, projectFile);
                    OnDocumentAdded(newDocument);
                }
                else
                {
                    foreach (var projectedDocument in GenerateProjections(projectFile, projectData, project))
                    {
                        OnDocumentAdded(projectedDocument);
                    }
                }
            }
        }
Beispiel #3
0
        void OnFileRenamed(object sender, MonoDevelop.Projects.ProjectFileRenamedEventArgs args)
        {
            if (internalChanges)
            {
                return;
            }
            var project = (MonoDevelop.Projects.Project)sender;

            foreach (MonoDevelop.Projects.ProjectFileRenamedEventInfo fargs in args)
            {
                var projectFile = fargs.ProjectFile;
                if (projectFile.Subtype == MonoDevelop.Projects.Subtype.Directory)
                {
                    continue;
                }
                if (!TypeSystemParserNode.IsCompileBuildAction(projectFile.BuildAction))
                {
                    continue;
                }

                var projectId = GetProjectId(project);
                var data      = GetProjectData(projectId);

                var id = data.GetDocumentId(fargs.OldName);
                if (id != null)
                {
                    if (this.IsDocumentOpen(id))
                    {
                        this.InformDocumentClose(id, fargs.OldName);
                    }
                    OnDocumentRemoved(id);
                    data.RemoveDocument(fargs.OldName);
                }

                var newDocument = CreateDocumentInfo(solutionData, project.Name, GetProjectData(projectId), projectFile);
                OnDocumentAdded(newDocument);
            }
        }
Beispiel #4
0
        IEnumerable <DocumentInfo> CreateDocuments(ProjectData projectData, MonoDevelop.Projects.Project p, CancellationToken token, MonoDevelop.Projects.ProjectFile[] sourceFiles)
        {
            var duplicates = new HashSet <DocumentId> ();

            // use given source files instead of project.Files because there may be additional files added by msbuild targets
            foreach (var f in sourceFiles)
            {
                if (token.IsCancellationRequested)
                {
                    yield break;
                }
                if (f.Subtype == MonoDevelop.Projects.Subtype.Directory)
                {
                    continue;
                }
                if (TypeSystemParserNode.IsCompileBuildAction(f.BuildAction))
                {
                    if (!duplicates.Add(projectData.GetOrCreateDocumentId(f.Name)))
                    {
                        continue;
                    }
                    yield return(CreateDocumentInfo(solutionData, p.Name, projectData, f));

                    continue;
                }
                var mimeType = DesktopService.GetMimeTypeForUri(f.FilePath);
                var node     = TypeSystemService.GetTypeSystemParserNode(mimeType, f.BuildAction);
                if (node == null || !node.Parser.CanGenerateProjection(mimeType, f.BuildAction, p.SupportedLanguages))
                {
                    continue;
                }
                var options = new ParseOptions {
                    FileName = f.FilePath,
                    Project  = p,
                    Content  = StringTextSource.ReadFrom(f.FilePath),
                };
                var projections = node.Parser.GenerateProjections(options);
                var entry       = new ProjectionEntry();
                entry.File = f;
                var list = new List <Projection> ();
                entry.Projections = list;
                foreach (var projection in projections.Result)
                {
                    list.Add(projection);
                    if (!duplicates.Add(projectData.GetOrCreateDocumentId(projection.Document.FileName)))
                    {
                        continue;
                    }
                    var plainName = projection.Document.FileName.FileName;
                    yield return(DocumentInfo.Create(
                                     projectData.GetOrCreateDocumentId(projection.Document.FileName),
                                     plainName,
                                     new [] { p.Name }.Concat(f.ProjectVirtualPath.ParentDirectory.ToString().Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)),
                                     SourceCodeKind.Regular,
                                     TextLoader.From(TextAndVersion.Create(new MonoDevelopSourceText(projection.Document), VersionStamp.Create(), projection.Document.FileName)),
                                     projection.Document.FileName,
                                     false
                                     ));
                }
                projectionList.Add(entry);
            }
        }