コード例 #1
0
            protected override IEnumerable <string> GenerateCode(List <object> includedMembers)
            {
                var generator = Options.CreateCodeGenerator();

                generator.AutoIndent = false;
                var ctx = MDRefactoringContext.Create(Options.Document, Options.Document.Editor.Caret.Location).Result;

                if (ctx == null)
                {
                    yield break;
                }
                var builder = ctx.CreateTypeSystemAstBuilder();

                foreach (IMember member in includedMembers)
                {
                    yield return(GenerateMemberCode(ctx, builder, member));
                }
            }
コード例 #2
0
        public override ParsedDocument Parse(bool storeAst, string fileName, System.IO.TextReader content, MonoDevelop.Projects.Project project = null)
        {
            var parser = new ICSharpCode.NRefactory.CSharp.CSharpParser(GetCompilerArguments(project));

            parser.GenerateTypeSystemMode = !storeAst;
            var result = new ParsedDocumentDecorator();

            if (project != null)
            {
                var projectFile = project.Files.GetFile(fileName);
                if (projectFile != null && !TypeSystemParserNode.IsCompileBuildAction(projectFile.BuildAction))
                {
                    result.Flags |= ParsedDocumentFlags.NonSerializable;
                }
            }

            var tagComments = CommentTag.SpecialCommentTags.Select(t => t.Tag).ToArray();

            parser.CompilationUnitCallback = delegate(CompilerCompilationUnit top) {
                foreach (var special in top.SpecialsBag.Specials)
                {
                    var comment = special as SpecialsBag.Comment;
                    if (comment != null)
                    {
                        VisitComment(result, comment, tagComments);
                    }
                    else
                    {
                        if (storeAst)
                        {
                            var ppd = special as SpecialsBag.PreProcessorDirective;
                            if (ppd != null)
                            {
                                VisitPreprocessorDirective(result, ppd);
                            }
                        }
                    }
                }
            };

            var unit = parser.Parse(content, fileName);

            unit.Freeze();
            var pf = unit.ToTypeSystem();

            try {
                pf.LastWriteTime = System.IO.File.GetLastWriteTimeUtc(fileName);
            } catch (Exception) {
                pf.LastWriteTime = DateTime.UtcNow;
            }

            result.LastWriteTimeUtc = pf.LastWriteTime.Value;
            result.ParsedFile       = pf;
            result.Add(GetSemanticTags(unit));

            result.CreateRefactoringContext = delegate(MonoDevelop.Ide.Gui.Document doc, System.Threading.CancellationToken token) {
                var task = MDRefactoringContext.Create(doc, doc.Editor.Caret.Location, token);
                task.Wait(5000, token);
                if (!task.IsCompleted)
                {
                    return(null);
                }
                return(task.Result);
            };
            result.CreateRefactoringContextWithEditor = (data, resolver, token) => new MDRefactoringContext((DotNetProject)project, data, result, (CSharpAstResolver)resolver, TextLocation.Empty, token);

            if (storeAst)
            {
                result.Ast = unit;
                result.Add(GenerateFoldings(unit, result));
            }
            return(result);
        }
コード例 #3
0
 public MonoCSharpCompletionEngine(CSharpCompletionTextEditorExtension ext, ICSharpCode.NRefactory.Editor.IDocument document, ICompletionContextProvider completionContextProvider, ICompletionDataFactory factory, ICSharpCode.NRefactory.TypeSystem.IProjectContent content, ICSharpCode.NRefactory.CSharp.TypeSystem.CSharpTypeResolveContext ctx) : base(document, completionContextProvider, factory, content, ctx)
 {
     this.ext = ext;
     this.mdRefactoringCtx = MDRefactoringContext.Create(ext.Document, ext.Document.Editor.Caret.Location);
 }