Exemple #1
0
            async Task <List <DocumentInfo> > GenerateProjections(MonoDevelop.Projects.ProjectFile f, DocumentMap documentMap, MonoDevelop.Projects.Project p, CancellationToken token, ProjectData oldProjectData, HashSet <DocumentId> duplicates)
            {
                var mimeType = IdeServices.DesktopService.GetMimeTypeForUri(f.FilePath);
                var node     = IdeApp.TypeSystemService.GetTypeSystemParserNode(mimeType, f.BuildAction);

                if (node == null || !node.Parser.CanGenerateProjection(mimeType, f.BuildAction, p.SupportedLanguages))
                {
                    return(new List <DocumentInfo> ());
                }

                var content = TextFileProvider.Instance.GetReadOnlyTextEditorData(f.FilePath, throwOnFileNotFound: false);

                if (content == null)
                {
                    return(new List <DocumentInfo> ());
                }

                var options = new ParseOptions {
                    FileName = f.FilePath,
                    Project  = p,
                    Content  = content,
                };
                var generatedProjections = await node.Parser.GenerateProjections(options, token);

                var list  = new List <Projection> ();
                var entry = new ProjectionEntry {
                    File        = f,
                    Projections = list,
                };

                var result = new List <DocumentInfo> (generatedProjections.Count);

                foreach (var projection in generatedProjections)
                {
                    list.Add(projection);
                    if (duplicates != null && !duplicates.Add(documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData)))
                    {
                        continue;
                    }
                    var plainName = projection.Document.FileName.FileName;
                    var folders   = GetFolders(p.Name, f.ProjectVirtualPath);
                    result.Add(DocumentInfo.Create(
                                   documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData),
                                   plainName,
                                   folders,
                                   SourceCodeKind.Regular,
                                   TextLoader.From(TextAndVersion.Create(new MonoDevelopSourceText(projection.Document), VersionStamp.Create(), projection.Document.FileName)),
                                   projection.Document.FileName,
                                   false)
                               );
                }
                projections.AddProjectionEntry(entry);
                return(result);
            }
        private OracleQueryParser Format(ProjectionEntry a)
        {
            Format(a.Term);
            var b = a.GetColumnInfo();

            if (!string.IsNullOrEmpty(a.Alias))
            {
                Append(" AS ").AppendQuoteExpression(FormatProjectionAlias(a.Alias));
            }
            else if (b != null)
            {
                Append(" AS ").AppendQuoteExpression(FormatProjectionAlias(b.Name));
            }
            return(this);
        }
Exemple #3
0
        /// <summary>
        /// Formata o texto de uma <see cref="ProjectionEntry"/>
        /// </summary>
        /// <param name="entry">Recebe a projeção de coluna</param>
        /// <returns>Retorna o próprio objeto</returns>
        private DefaultSqlQueryParser Format(ProjectionEntry entry)
        {
            Format(entry.Term);
            var columnInfo = entry.GetColumnInfo();

            if (!string.IsNullOrEmpty(entry.Alias))
            {
                Append(" AS ").AppendQuoteExpression(FormatProjectionAlias(entry.Alias));
            }
            else if (columnInfo != null)
            {
                Append(" AS ").AppendQuoteExpression(FormatProjectionAlias(columnInfo.Name));
            }
            return(this);
        }
Exemple #4
0
            IEnumerable <DocumentInfo> GenerateProjections(MonoDevelop.Projects.ProjectFile f, DocumentMap documentMap, MonoDevelop.Projects.Project p, ProjectData oldProjectData, HashSet <DocumentId> duplicates)
            {
                var mimeType = DesktopService.GetMimeTypeForUri(f.FilePath);
                var node     = TypeSystemService.GetTypeSystemParserNode(mimeType, f.BuildAction);

                if (node == null || !node.Parser.CanGenerateProjection(mimeType, f.BuildAction, p.SupportedLanguages))
                {
                    yield break;
                }
                var options = new ParseOptions {
                    FileName = f.FilePath,
                    Project  = p,
                    Content  = TextFileProvider.Instance.GetReadOnlyTextEditorData(f.FilePath),
                };
                var generatedProjections = node.Parser.GenerateProjections(options);
                var list  = new List <Projection> ();
                var entry = new ProjectionEntry {
                    File        = f,
                    Projections = list,
                };

                foreach (var projection in generatedProjections.Result)
                {
                    list.Add(projection);
                    if (duplicates != null && !duplicates.Add(documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData)))
                    {
                        continue;
                    }
                    var plainName = projection.Document.FileName.FileName;
                    var folders   = GetFolders(p.Name, f);
                    yield return(DocumentInfo.Create(
                                     documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData),
                                     plainName,
                                     folders,
                                     SourceCodeKind.Regular,
                                     TextLoader.From(TextAndVersion.Create(new MonoDevelopSourceText(projection.Document), VersionStamp.Create(), projection.Document.FileName)),
                                     projection.Document.FileName,
                                     false
                                     ));
                }
                projections.AddProjectionEntry(entry);
            }
Exemple #5
0
        IEnumerable <DocumentInfo> GenerateProjections(MonoDevelop.Projects.ProjectFile f, ProjectData projectData, MonoDevelop.Projects.Project p, HashSet <DocumentId> duplicates = null)
        {
            var mimeType = DesktopService.GetMimeTypeForUri(f.FilePath);
            var node     = TypeSystemService.GetTypeSystemParserNode(mimeType, f.BuildAction);

            if (node == null || !node.Parser.CanGenerateProjection(mimeType, f.BuildAction, p.SupportedLanguages))
            {
                yield break;
            }
            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 != null && !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);
        }
		IEnumerable<DocumentInfo> GenerateProjections (MonoDevelop.Projects.ProjectFile f, ProjectData projectData, MonoDevelop.Projects.Project p, HashSet<DocumentId> duplicates = null)
		{
			var mimeType = DesktopService.GetMimeTypeForUri (f.FilePath);
			var node = TypeSystemService.GetTypeSystemParserNode (mimeType, f.BuildAction);
			if (node == null || !node.Parser.CanGenerateProjection (mimeType, f.BuildAction, p.SupportedLanguages))
				yield break;
			var options = new ParseOptions {
				FileName = f.FilePath,
				Project = p,
				Content = TextFileProvider.Instance.GetReadOnlyTextEditorData (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 != null && !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);
		}
Exemple #7
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);
            }
        }
 internal void AddProjectionEntry(ProjectionEntry entry)
 {
     lock (projectionListUpdateLock)
         projectionList = projectionList.Add(entry);
 }
		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);
			}
		}
 /// <summary>
 /// Verifica se a entrada é uma função COUNT.
 /// </summary>
 /// <param name="entry"></param>
 /// <returns></returns>
 private static bool IsCountFunction(ProjectionEntry entry)
 {
     return(entry.Term is FunctionCall && StringComparer.InvariantCultureIgnoreCase.Equals(((FunctionCall)entry.Term).Call.ToString(), "COUNT"));
 }