public override Task <IEnumerable <SearchResult> > FindAllReferences(string documentationCommentId, MonoDevelop.Projects.Project hintProject, CancellationToken token) { var workspace = TypeSystemService.Workspace as MonoDevelopWorkspace; if (workspace == null) { return(Task.FromResult(Enumerable.Empty <SearchResult> ())); } return(Task.Run(async delegate { var antiDuplicatesSet = new HashSet <SearchResult> (new SearchResultComparer()); var result = new List <SearchResult> (); var lookup = await TryLookupSymbol(documentationCommentId, hintProject, token); if (!lookup.Success) { return result; } foreach (var simSym in SymbolFinder.FindSimilarSymbols(lookup.Symbol, lookup.Compilation)) { foreach (var loc in simSym.Locations) { if (!loc.IsInSource) { continue; } var sr = new SearchResult(new FileProvider(loc.SourceTree.FilePath), loc.SourceSpan.Start, loc.SourceSpan.Length); if (antiDuplicatesSet.Add(sr)) { result.Add(sr); } } foreach (var mref in await SymbolFinder.FindReferencesAsync(simSym, lookup.Solution).ConfigureAwait(false)) { foreach (var loc in mref.Locations) { var fileName = loc.Document.FilePath; var offset = loc.Location.SourceSpan.Start; string projectedName; int projectedOffset; if (workspace.TryGetOriginalFileFromProjection(fileName, offset, out projectedName, out projectedOffset)) { fileName = projectedName; offset = projectedOffset; } var sr = new SearchResult(new FileProvider(fileName), offset, loc.Location.SourceSpan.Length); if (antiDuplicatesSet.Add(sr)) { result.Add(sr); } } } } return (IEnumerable <SearchResult>)result; })); }
async Task <Tuple <List <DocumentInfo>, List <DocumentInfo> > > CreateDocuments(ProjectData projectData, MonoDevelop.Projects.Project p, CancellationToken token, MonoDevelop.Projects.ProjectFile[] sourceFiles, ProjectData oldProjectData) { var documents = new List <DocumentInfo> (); // We don' add additionalDocuments anymore because they were causing slowdown of compilation generation // and no upside to setting additionalDocuments, keeping this around in case this changes in future. var additionalDocuments = new List <DocumentInfo> (); 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) { return(null); } if (f.Subtype == MonoDevelop.Projects.Subtype.Directory) { continue; } if (p.IsCompileable(f.FilePath) || CanGenerateAnalysisContextForNonCompileable(p, f)) { var filePath = (FilePath)f.Name; var id = projectData.DocumentData.GetOrCreate(filePath.ResolveLinks(), oldProjectData?.DocumentData); if (!duplicates.Add(id)) { continue; } documents.Add(CreateDocumentInfo(solutionData, p.Name, projectData, f)); } else { foreach (var projectedDocument in await GenerateProjections(f, projectData.DocumentData, p, token, oldProjectData, null)) { var projectedId = projectData.DocumentData.GetOrCreate(projectedDocument.FilePath, oldProjectData?.DocumentData); if (!duplicates.Add(projectedId)) { continue; } documents.Add(projectedDocument); } } } var projectId = projectMap.GetId(p); lock (workspace.generatedFiles) { foreach (var generatedFile in workspace.generatedFiles) { if (generatedFile.Key.Id.ProjectId == projectId) { documents.Add(generatedFile.Key); } } } return(Tuple.Create(documents, additionalDocuments)); }
public override void AttachToProject(MonoDevelop.Projects.Project project) { }
internal static async Task <LookupResult> TryLookupSymbol(string documentationCommentId, MonoDevelop.Projects.Project hintProject, CancellationToken token) { Microsoft.CodeAnalysis.Project codeAnalysisHintProject = null; LookupResult result = LookupResult.Failure; if (hintProject != null) { codeAnalysisHintProject = TypeSystemService.GetCodeAnalysisProject(hintProject); if (codeAnalysisHintProject != null) { var curResult = await TryLookupSymbolInProject(codeAnalysisHintProject, documentationCommentId, token); if (curResult.Success) { curResult.MonoDevelopProject = hintProject; result = curResult; } } } if (result.Success && result.Symbol.IsDefinedInSource()) { return(result); } foreach (var ws in TypeSystemService.AllWorkspaces) { foreach (var prj in ws.CurrentSolution.Projects) { if (prj == codeAnalysisHintProject) { continue; } var curResult = await TryLookupSymbolInProject(prj, documentationCommentId, token); if (curResult.Success) { curResult.MonoDevelopProject = TypeSystemService.GetMonoProject(prj); if (curResult.Symbol.IsDefinedInSource()) { return(curResult); } result = curResult; } } } return(result); }
public override ParsedDocument Parse(bool storeAst, string fileName, TextReader content, MonoDevelop.Projects.Project project = null) { var doc = new XmlParsedDocument(fileName); doc.Flags |= ParsedDocumentFlags.NonSerializable; try { var xmlParser = new XmlParser(new XmlRootState(), true); xmlParser.Parse(content); doc.XDocument = xmlParser.Nodes.GetRoot(); doc.Add(xmlParser.Errors); if (doc.XDocument != null && doc.XDocument.RootElement != null) { if (!doc.XDocument.RootElement.IsEnded) { doc.XDocument.RootElement.End(xmlParser.Location); } } } catch (Exception ex) { MonoDevelop.Core.LoggingService.LogError("Unhandled error parsing xml document", ex); } return(doc); }
public async Task <(ImmutableArray <MonoDevelopMetadataReference>, ImmutableArray <ProjectReference>)> CreateReferences(MonoDevelop.Projects.Project proj, CancellationToken token) { var metadataReferences = await CreateMetadataReferences(proj, token).ConfigureAwait(false); if (token.IsCancellationRequested) { return(ImmutableArray <MonoDevelopMetadataReference> .Empty, ImmutableArray <ProjectReference> .Empty); } var projectReferences = await CreateProjectReferences(proj, token).ConfigureAwait(false); return(metadataReferences, projectReferences); }
public PipelineDesktopApplication(string filename, MonoDevelop.Projects.Project ownerProject) : base("MonoGamePipelineTool", "MonoGame Pipeline Tool", true) { this.project = ownerProject; this.filename = filename; }
public override Task <IEnumerable <SearchResult> > FindAllReferences(string documentationCommentId, MonoDevelop.Projects.Project hintProject, CancellationToken token) { return(Task.Run(async delegate { var antiDuplicatesSet = new HashSet <SearchResult> (new SearchResultComparer()); var result = new List <SearchResult> (); var lookup = await TryLookupSymbol(documentationCommentId, hintProject, token); if (!lookup.Success) { return result; } var workspace = TypeSystemService.AllWorkspaces.FirstOrDefault(w => w.CurrentSolution == lookup.Solution) as MonoDevelopWorkspace; if (workspace == null) { return Enumerable.Empty <SearchResult> (); } if (lookup.Symbol.Kind == SymbolKind.Method) { foreach (var curSymbol in lookup.Symbol.ContainingType.GetMembers().Where(m => m.Kind == lookup.Symbol.Kind && m.Name == lookup.Symbol.Name)) { foreach (var sym in SymbolFinder.FindSimilarSymbols(curSymbol, lookup.Compilation)) { foreach (var simSym in await GatherSymbols(sym, lookup.Solution, token)) { await FindSymbolReferencesAsync(antiDuplicatesSet, result, lookup, workspace, simSym); } } } } else { await FindSymbolReferencesAsync(antiDuplicatesSet, result, lookup, workspace, lookup.Symbol); } return (IEnumerable <SearchResult>)result; })); }
public IViewContent CreateContent(MonoDevelop.Core.FilePath fileName, string mimeType, MonoDevelop.Projects.Project ownerProject) { return(new MonoGameContentEditorViewContent(fileName, ownerProject)); }
public bool CanHandle(MonoDevelop.Core.FilePath fileName, string mimeType, MonoDevelop.Projects.Project ownerProject) { return(mimeType == "text/x-mgcb"); }
/// <summary> /// Gets a CodeAnalysis project from a MonoDevelop project /// </summary> public static Microsoft.CodeAnalysis.Project GetCodeAnalysisProject(this MonoDevelop.Projects.Project monoDevelopProject) { return(TypeSystemService.GetCodeAnalysisProject(monoDevelopProject)); }
public override ParsedDocument Parse(bool storeAst, string fileName, System.IO.TextReader content, MonoDevelop.Projects.Project project = null) { throw new NotImplementedException(); }
protected override void OnSetProject(MonoDevelop.Projects.Project project) { base.OnSetProject(project); content.Project = project; }
public async Task <List <ClassDefinition> > ProcessAsync(MonoDevelop.Projects.Project project, IProgress <TreeBuilderProgress> progress = null) { var classes = new Dictionary <ITypeSymbol, ClassDefinition>(); var compilation = await TypeSystemService.GetCompilationAsync(project); var types = compilation.GetAllTypesInMainAssembly(); progress?.Report(new TreeBuilderProgress { totalClasses = types.Count() }); for (int i = 0; i < types.Count(); i++) { var type = types.ElementAt(i); var definition = GetValueOrCreate(type, classes); if (type.IsAbstract && definition.ClassType == ClassType.Class) { definition.ClassType = ClassType.Abstract; } foreach (var iface in type.Interfaces) { var interfaceDefinition = GetValueOrCreate(iface, classes); interfaceDefinition.ClassType = ClassType.Interface; definition.Interfaces.Add(interfaceDefinition); } foreach (var baseClass in type.GetAllBaseClasses()) { if (!baseClass.IsDefinedInSource()) { continue; } var baseDefinition = GetValueOrCreate(baseClass, classes); definition.BaseClasses.Add(baseDefinition); } HashSet <ClassDefinition> dependencies = new HashSet <ClassDefinition>(); var syntaxDeclarations = type.GetDeclarations(); foreach (var declaration in syntaxDeclarations) { var semanticModel = compilation.GetSemanticModel(declaration.SyntaxTree); var descendants = declaration.GetSyntax().DescendantNodes(); foreach (var descendant in descendants) { ITypeSymbol usedType = semanticModel.GetTypeInfo(descendant).Type; usedType = usedType as INamedTypeSymbol; if (usedType != null && usedType.IsDefinedInSource()) { var def = GetValueOrCreate(usedType, classes); if (def != definition && !definition.Interfaces.Contains(def) && !definition.BaseClasses.Contains(def)) { dependencies.Add(def); } } } } definition.Dependencies.AddRange(dependencies); progress?.Report(new TreeBuilderProgress { totalClasses = types.Count(), doneClasses = i + 1 }); } return(classes.Values.ToList()); }
static bool SupportsRoslyn(MonoDevelop.Projects.Project proj) { return(string.Equals(proj.TypeGuid, "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", StringComparison.OrdinalIgnoreCase) || string.Equals(proj.TypeGuid, "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", StringComparison.OrdinalIgnoreCase)); }
public override Task <IEnumerable <SearchResult> > FindReferences(string documentationCommentId, MonoDevelop.Projects.Project hintProject, CancellationToken token) { return(Task.Run(async delegate { var result = new List <SearchResult> (); var antiDuplicatesSet = new HashSet <SearchResult> (new SearchResultComparer()); var lookup = await TryLookupSymbol(documentationCommentId, hintProject, token); if (lookup == null || !lookup.Success) { return Enumerable.Empty <SearchResult> (); } var workspace = TypeSystemService.AllWorkspaces.FirstOrDefault(w => w.CurrentSolution == lookup.Solution) as MonoDevelopWorkspace; if (workspace == null) { return Enumerable.Empty <SearchResult> (); } foreach (var sym in await GatherSymbols(lookup.Symbol, lookup.Solution, token)) { foreach (var loc in sym.Locations) { if (token.IsCancellationRequested) { break; } if (!loc.IsInSource) { continue; } var fileName = loc.SourceTree.FilePath; var offset = loc.SourceSpan.Start; string projectedName; int projectedOffset; if (workspace.TryGetOriginalFileFromProjection(fileName, offset, out projectedName, out projectedOffset)) { fileName = projectedName; offset = projectedOffset; } var sr = new MemberReference(sym, fileName, offset, loc.SourceSpan.Length); sr.ReferenceUsageType = ReferenceUsageType.Declaration; antiDuplicatesSet.Add(sr); result.Add(sr); } foreach (var mref in await SymbolFinder.FindReferencesAsync(sym, lookup.Solution, token).ConfigureAwait(false)) { foreach (var loc in mref.Locations) { if (token.IsCancellationRequested) { break; } var fileName = loc.Document.FilePath; var offset = loc.Location.SourceSpan.Start; string projectedName; int projectedOffset; if (workspace.TryGetOriginalFileFromProjection(fileName, offset, out projectedName, out projectedOffset)) { fileName = projectedName; offset = projectedOffset; } var sr = new MemberReference(sym, fileName, offset, loc.Location.SourceSpan.Length); if (antiDuplicatesSet.Add(sr)) { var root = loc.Location.SourceTree.GetRoot(); var node = root.FindNode(loc.Location.SourceSpan); var trivia = root.FindTrivia(loc.Location.SourceSpan.Start); sr.ReferenceUsageType = HighlightUsagesExtension.GetUsage(node); result.Add(sr); } } } } return (IEnumerable <SearchResult>)result; })); }
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); } }
protected override string RunExCommand(string command) { if (':' != command[0] || 2 > command.Length) { return(base.RunExCommand(command)); } switch (command[1]) { case 'w': if (2 < command.Length) { switch (command[2]) { case 'q': // :wq editor.View.WorkbenchWindow.Document.Save(); Gtk.Application.Invoke(delegate { editor.View.WorkbenchWindow.CloseWindow(false, true, -1); }); return("Saved and closed file."); case '!': // :w! editor.View.Save(); break; default: return(base.RunExCommand(command)); } } else { editor.View.WorkbenchWindow.Document.Save(); } return("Saved file."); case 'q': bool force = false; if (2 < command.Length) { switch (command[2]) { case '!': // :q! force = true; break; default: return(base.RunExCommand(command)); } } if (!force && editor.View.IsDirty) { return("Document has not been saved!"); } Gtk.Application.Invoke(delegate { editor.View.WorkbenchWindow.CloseWindow(force, true, -1); }); return(force? "Closed file without saving.": "Closed file."); case 'm': if (!Regex.IsMatch(command, "^:mak[e!]", RegexOptions.Compiled)) { break; } MonoDevelop.Projects.Project proj = editor.View.Project; if (proj != null) { IdeApp.ProjectOperations.Build(proj); return(string.Format("Building project {0}", proj.Name)); } return("File is not part of a project"); case 'c': // Error manipulation if (3 == command.Length) { switch (command[2]) { case 'n': // :cn - jump to next error IdeApp.CommandService.DispatchCommand(MonoDevelop.Ide.Commands.ViewCommands.ShowNext); return(string.Empty); case 'N': case 'p': // :c[pN] - jump to previous error IdeApp.CommandService.DispatchCommand(MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious); return(string.Empty); } } break; } return(base.RunExCommand(command)); }
static async Task <List <MetadataReference> > CreateMetadataReferences(MonoDevelop.Projects.Project p, ProjectId projectId, CancellationToken token) { List <MetadataReference> result = new List <MetadataReference> (); var netProject = p as MonoDevelop.Projects.DotNetProject; if (netProject == null) { return(result); } var configurationSelector = IdeApp.Workspace?.ActiveConfiguration ?? MonoDevelop.Projects.ConfigurationSelector.Default; var hashSet = new HashSet <string> (FilePath.PathComparer); bool addFacadeAssemblies = false; try { foreach (string file in await netProject.GetReferencedAssemblies(configurationSelector, false).ConfigureAwait(false)) { if (token.IsCancellationRequested) { return(result); } string fileName; if (!Path.IsPathRooted(file)) { fileName = Path.Combine(Path.GetDirectoryName(netProject.FileName), file); } else { fileName = Path.GetFullPath(file); } if (hashSet.Contains(fileName)) { continue; } hashSet.Add(fileName); if (!File.Exists(fileName)) { continue; } result.Add(MetadataReferenceCache.LoadReference(projectId, fileName)); addFacadeAssemblies |= MonoDevelop.Core.Assemblies.SystemAssemblyService.ContainsReferenceToSystemRuntime(fileName); } } catch (Exception e) { LoggingService.LogError("Error while getting referenced assemblies", e); } // HACK: Facade assemblies should be added by the project system. Remove that when the project system can do that. if (addFacadeAssemblies) { if (netProject != null) { var runtime = netProject.TargetRuntime ?? MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime; var facades = runtime.FindFacadeAssembliesForPCL(netProject.TargetFramework); foreach (var facade in facades) { if (!File.Exists(facade)) { continue; } result.Add(MetadataReferenceCache.LoadReference(projectId, facade)); } } } foreach (var pr in p.GetReferencedItems(configurationSelector)) { if (token.IsCancellationRequested) { return(result); } var referencedProject = pr as MonoDevelop.Projects.DotNetProject; if (referencedProject == null) { continue; } if (TypeSystemService.IsOutputTrackedProject(referencedProject)) { var fileName = referencedProject.GetOutputFileName(configurationSelector); if (!File.Exists(fileName)) { continue; } result.Add(MetadataReferenceCache.LoadReference(projectId, fileName)); } } return(result); }
internal ProjectId GetId(MonoDevelop.Projects.Project p) { lock (gate) { return(projectIdMap.TryGetValue(p, out ProjectId result) ? result : null); } }
internal ProjectId GetProjectId(MonoDevelop.Projects.Project project) => ProjectMap.GetId(project);
async Task <ImmutableArray <MonoDevelopMetadataReference> > CreateMetadataReferences(MonoDevelop.Projects.Project proj, CancellationToken token) { // create some default references for unsupported project types. if (!(proj is MonoDevelop.Projects.DotNetProject netProject)) { return(CreateDefaultMetadataReferences()); } var data = new AddMetadataReferencesData { Result = new List <MonoDevelopMetadataReference> (), Project = netProject, Visited = new HashSet <string> (FilePath.PathComparer), ConfigurationSelector = IdeApp.IsInitialized ? IdeApp.Workspace.ActiveConfiguration : MonoDevelop.Projects.ConfigurationSelector.Default, Token = token, }; if (!await AddMetadataAssemblyReferences(data)) { return(ImmutableArray <MonoDevelopMetadataReference> .Empty); } return(data.Result.ToImmutableArray()); }
internal ProjectId[] GetProjectIds(MonoDevelop.Projects.Project project) => ProjectMap.GetIds(project);
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); }
internal Task <ProjectInfo> LoadProject(MonoDevelop.Projects.Project p, CancellationToken token, MonoDevelop.Projects.Project oldProject, string framework) => ProjectHandler.LoadProject(p, token, oldProject, null, framework);
public override Task <IEnumerable <SearchResult> > FindReferences(string documentationCommentId, MonoDevelop.Projects.Project hintProject, CancellationToken token) { return(Task.Run(async delegate { var result = new List <SearchResult> (); var antiDuplicatesSet = new HashSet <SearchResult> (new SearchResultComparer()); foreach (var workspace in TypeSystemService.AllWorkspaces.OfType <MonoDevelopWorkspace> ()) { LookupResult lookup = null; foreach (var project in workspace.CurrentSolution.Projects) { lookup = await TryLookupSymbolInProject(project, documentationCommentId, token); if (lookup.Success) { break; } } if (lookup == null || !lookup.Success) { continue; } foreach (var loc in lookup.Symbol.Locations) { if (token.IsCancellationRequested) { break; } if (!loc.IsInSource) { continue; } var fileName = loc.SourceTree.FilePath; var offset = loc.SourceSpan.Start; string projectedName; int projectedOffset; if (workspace.TryGetOriginalFileFromProjection(fileName, offset, out projectedName, out projectedOffset)) { fileName = projectedName; offset = projectedOffset; } var sr = new SearchResult(new FileProvider(fileName), offset, loc.SourceSpan.Length); antiDuplicatesSet.Add(sr); result.Add(sr); } foreach (var mref in await SymbolFinder.FindReferencesAsync(lookup.Symbol, lookup.Solution).ConfigureAwait(false)) { foreach (var loc in mref.Locations) { if (token.IsCancellationRequested) { break; } var fileName = loc.Document.FilePath; var offset = loc.Location.SourceSpan.Start; string projectedName; int projectedOffset; if (workspace.TryGetOriginalFileFromProjection(fileName, offset, out projectedName, out projectedOffset)) { fileName = projectedName; offset = projectedOffset; } var sr = new SearchResult(new FileProvider(fileName), offset, loc.Location.SourceSpan.Length); if (antiDuplicatesSet.Add(sr)) { result.Add(sr); } } } } return (IEnumerable <SearchResult>)result; })); }
internal static IEnumerable <string> GetFrameworks(MonoDevelop.Projects.Project p) => MonoDevelopWorkspace.ProjectSystemHandler.GetFrameworks(p);
internal async Task <ProjectInfo> LoadProject(MonoDevelop.Projects.Project p, CancellationToken token, MonoDevelop.Projects.Project oldProject) { var projectId = projectMap.GetOrCreateId(p, oldProject); var config = IdeApp.Workspace != null?p.GetConfiguration(IdeApp.Workspace.ActiveConfiguration) as MonoDevelop.Projects.DotNetProjectConfiguration : null; MonoDevelop.Projects.DotNetCompilerParameters cp = config?.CompilationParameters; FilePath fileName = IdeApp.Workspace != null?p.GetOutputFileName(IdeApp.Workspace.ActiveConfiguration) : (FilePath)""; if (fileName.IsNullOrEmpty) { fileName = new FilePath(p.Name + ".dll"); } var(references, projectReferences) = await metadataHandler.Value.CreateReferences(p, token).ConfigureAwait(false); if (token.IsCancellationRequested) { return(null); } var sourceFiles = await p.GetSourceFilesAsync(config?.Selector).ConfigureAwait(false); if (token.IsCancellationRequested) { return(null); } var analyzerFiles = await p.GetAnalyzerFilesAsync(config?.Selector).ConfigureAwait(false); if (token.IsCancellationRequested) { return(null); } var loader = workspace.Services.GetService <IAnalyzerService> ().GetLoader(); ProjectData projectData, oldProjectData; List <DocumentInfo> mainDocuments, additionalDocuments; try { await workspace.LoadLock.WaitAsync().ConfigureAwait(false); //when reloading e.g. after a save, preserve document IDs oldProjectData = projectMap.RemoveData(projectId); projectData = projectMap.CreateData(projectId, references); var documents = await CreateDocuments(projectData, p, token, sourceFiles, oldProjectData).ConfigureAwait(false); if (documents == null) { return(null); } mainDocuments = documents.Item1; additionalDocuments = documents.Item2; } finally { workspace.LoadLock.Release(); } // TODO: Pass in the WorkspaceMetadataFileReferenceResolver var info = ProjectInfo.Create( projectId, VersionStamp.Create(), p.Name, fileName.FileNameWithoutExtension, (p as MonoDevelop.Projects.DotNetProject)?.RoslynLanguageName ?? LanguageNames.CSharp, p.FileName, fileName, cp?.CreateCompilationOptions(), cp?.CreateParseOptions(config), mainDocuments, projectReferences, references.Select(x => x.CurrentSnapshot), analyzerReferences: analyzerFiles.SelectAsArray(x => { var analyzer = new MonoDevelopAnalyzer(x, hostDiagnosticUpdateSource.Value, projectId, workspace, loader, LanguageNames.CSharp); return(analyzer.GetReference()); }), additionalDocuments: additionalDocuments ); return(info); }
public override async Task <bool> TryJumpToDeclarationAsync(string documentIdString, MonoDevelop.Projects.Project hintProject, System.Threading.CancellationToken token) { var lookup = await CSharpFindReferencesProvider.TryLookupSymbol(documentIdString, hintProject, token); if (!lookup.Success || lookup.Symbol.Locations.First().IsInMetadata) { return(false); } IdeApp.ProjectOperations.JumpToDeclaration(lookup.Symbol, lookup.MonoDevelopProject); return(true); }
public PipelineDesktopApplication (string filename, MonoDevelop.Projects.Project ownerProject) : base ("MonoGamePipelineTool", "MonoGame Pipeline Tool", true) { this.project = ownerProject; this.filename = filename; }
public IViewContent CreateContent(MonoDevelop.Core.FilePath fileName, string mimeType, MonoDevelop.Projects.Project ownerProject) { exclude = true; var defaultViewBinding = DisplayBindingService.GetDefaultViewBinding(fileName, mimeType, ownerProject); var content = defaultViewBinding.CreateContent(fileName, mimeType, ownerProject); var result = new EditorView(content); exclude = false; return(result); }