Beispiel #1
0
        /// <summary>
        /// Loads the content from an auto save file and removes the auto save file.
        /// </summary>
        public static ITextSource LoadAndRemoveAutoSave(string fileName)
        {
            string autoSaveFileName = GetAutoSaveFileName(fileName);
            var    result           = StringTextSource.ReadFrom(autoSaveFileName);

            AutoSave.RemoveAutoSaveFile(fileName);
            return(result);
        }
Beispiel #2
0
        public void Load(string fileName)
        {
            MainEditor.Document.MimeType = IdeServices.DesktopService.GetMimeTypeForUri(fileName);
            MainEditor.Document.Text     = StringTextSource.ReadFrom(fileName).Text;

            this.CreateDiff();
            Show();
        }
Beispiel #3
0
 public static ITextDocument LoadDocument(string fileName, string mimeType = null)
 {
     if (fileName == null)
     {
         throw new System.ArgumentNullException("fileName");
     }
     return(currentFactory.CreateNewDocument(StringTextSource.ReadFrom(fileName), fileName, mimeType));
 }
        internal static bool HandleSourceCodeEntity(ITreeNavigator navigator, TextEditor data)
        {
            if (IsFromAssembly(navigator))
            {
                return(false);
            }

            var method = (IUnresolvedEntity)navigator.DataItem;
            var source = StringTextSource.ReadFrom(method.Region.FileName);

            data.Text          = source.Text;
            data.CaretLocation = new MonoDevelop.Ide.Editor.DocumentLocation(method.Region.BeginLine, method.Region.BeginColumn);
            return(true);
        }
        public static Task <ParsedDocument> ParseFile(Project project, string fileName, CancellationToken cancellationToken = default(CancellationToken))
        {
            StringTextSource text;

            try {
                if (!File.Exists(fileName))
                {
                    return(TaskUtil.Default <ParsedDocument>());
                }
                text = StringTextSource.ReadFrom(fileName);
            } catch (Exception) {
                return(TaskUtil.Default <ParsedDocument>());
            }

            return(ParseFile(project, fileName, DesktopService.GetMimeTypeForUri(fileName), text, cancellationToken));
        }
        string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup(ITreeNavigator navigator)
        {
            var method   = (IUnresolvedMethod)navigator.DataItem;
            var resolved = Resolve(navigator, method);

            if (GetMainAssembly(navigator) == null)
            {
                return(StringTextSource.ReadFrom(method.Region.FileName).Text);
            }
            StringBuilder result = new StringBuilder();

            result.Append("<big>");
            result.Append(MonoDevelop.Ide.TypeSystem.Ambience.EscapeText(Ambience.ConvertSymbol(resolved)));
            result.Append("</big>");
            result.AppendLine();

            //result.Append (AmbienceService.GetDocumentationMarkup (resolved, AmbienceService.GetDocumentation (resolved), options));

            return(result.ToString());
        }
Beispiel #7
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);
        }
Beispiel #8
0
        /// <summary>
        /// Loads the content from an auto save file.
        /// </summary>
        public static ITextSource LoadAutoSave(string fileName)
        {
            string autoSaveFileName = GetAutoSaveFileName(fileName);

            return(StringTextSource.ReadFrom(autoSaveFileName));
        }
Beispiel #9
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);
            }
        }
 protected override string GenerateInfo(string filename)
 {
     try {
         var doc = IdeApp.TypeSystemService.ParseFile(null, filename, IdeServices.DesktopService.GetMimeTypeForUri(filename), StringTextSource.ReadFrom(filename)).Result as WebFormsParsedDocument;
         if (doc != null && !string.IsNullOrEmpty(doc.Info.InheritedClass))
         {
             return(doc.Info.InheritedClass);
         }
     } catch (Exception ex) {
         LoggingService.LogError("Error reading codebehind name for file '" + filename + "'", ex);
     }
     return(null);
 }