コード例 #1
0
ファイル: AstNodeExtensions.cs プロジェクト: dykim07/vim-ide
        public static string Preview(this AstNode node, CSharpFile file, int maxWidth)
        {
            var startLocation = node.StartLocation;
            var startOffset = file.Document.GetOffset(startLocation.Line, startLocation.Column);
            

            var line = file.Document.GetLineByNumber(startLocation.Line);

            var lineText = file.Document.GetText(line.Offset, line.Length);
            
            if (line.Length < maxWidth)
            {
                // Don't truncate
                return lineText;
            }

            var endLocation = node.EndLocation;
            var endOffset = file.Document.GetOffset(endLocation.Line, endLocation.Column);

            const string ellipsis = "...";

            var charactersEitherSide = (maxWidth - (ellipsis.Length * 2));

            // Place the node text as close as possible to the centre of the returned text
            var start = Math.Max(line.Offset, startOffset - charactersEitherSide); 
            var end = Math.Min(line.EndOffset, endOffset + charactersEitherSide); 

            return ellipsis + file.Document.GetText(start, end - start).Trim() + ellipsis;
        }
コード例 #2
0
ファイル: OrphanProject.cs プロジェクト: charlesfuture/vim
        public void AddFile(string fileName)
        {
            var csharpFile = new CSharpFile(this, fileName);

            Files.Add(csharpFile);
            ProjectContent.AddOrUpdateFiles(new[] { csharpFile.ParsedFile });
        }
コード例 #3
0
ファイル: OrphanProject.cs プロジェクト: CSRedRat/Omnisharp
        public OrphanProject(ISolution solution)
        {
            Title = "Orphan Project";
            _file = new CSharpFile(this, "dummy_file", "");
            Files = new List<CSharpFile>();
            Files.Add(_file);

            string mscorlib = CSharpProject.FindAssembly(CSharpProject.AssemblySearchPaths, "mscorlib");
            ProjectContent = new CSharpProjectContent()
                .SetAssemblyName("OrphanProject")
                .AddAssemblyReferences(CSharpProject.LoadAssembly(mscorlib));
        }
コード例 #4
0
ファイル: OrphanProject.cs プロジェクト: gamwang/vimrc
        private CSharpFile GetFile(string fileName, string source)
        {
            var file = Files.FirstOrDefault(f => f.FileName.Equals(fileName, StringComparison.InvariantCultureIgnoreCase));
            if (file == null)
            {
                file = new CSharpFile(this, fileName, source);
                Files.Add (file);

                this.ProjectContent = this.ProjectContent
                    .AddOrUpdateFiles(file.ParsedFile);
            }
            return file;
        }
コード例 #5
0
        private CSharpFile GetFile(string fileName, string source)
        {
            var file = Files.FirstOrDefault(f => f.FileName.Equals(fileName, StringComparison.InvariantCultureIgnoreCase));

            if (file == null)
            {
                file = new CSharpFile(this, fileName, source);
                Files.Add(file);

                this.ProjectContent
                .AddOrUpdateFiles(file.ParsedFile);
            }
            return(file);
        }
コード例 #6
0
        public OrphanProject(ISolution solution)
        {
            Title = "Orphan Project";
            _file = new CSharpFile(this, "dummy_file", "");
            Files = new List <CSharpFile>();
            Files.Add(_file);

            ProjectId = Guid.NewGuid();

            string mscorlib = CSharpProject.FindAssembly(CSharpProject.AssemblySearchPaths, "mscorlib");

            ProjectContent = new CSharpProjectContent()
                             .SetAssemblyName("OrphanProject")
                             .AddAssemblyReferences(CSharpProject.LoadAssembly(mscorlib));
        }
コード例 #7
0
        public static string Preview(this AstNode node, CSharpFile file)
        {
            var location = node.StartLocation;
            var offset = file.Document.GetOffset(location.Line, location.Column);
            var line = file.Document.GetLineByNumber(location.Line);
            if (line.Length < 50)
            {
                return file.Document.GetText(line.Offset, line.Length);
            }

            var start = Math.Max(line.Offset, offset - 60);
            var end = Math.Min(line.EndOffset, offset + 60);

            return "..." + file.Document.GetText(start, end - start).Trim() + "...";
        }
コード例 #8
0
ファイル: QuickFix.cs プロジェクト: jtprog/subvim
        /// <summary>
        ///   Initialize a QuickFix pointing to the first line of the
        ///   given region in the given file.
        /// </summary>
        public static QuickFix ForFirstLineInRegion(DomRegion region, CSharpFile file)
        {
            return new QuickFix
                { FileName = region.FileName
                , Line     = region.BeginLine
                , Column   = region.BeginColumn

                // Note that we could display an arbitrary amount of
                // context to the user: ranging from one line to tens,
                // hundreds..
                , Text = file.Document.GetText
                    ( offset: file.Document.GetOffset(region.Begin)
                    , length: file.Document.GetLineByNumber
                                (region.BeginLine).Length)};
        }
コード例 #9
0
ファイル: QuickFix.cs プロジェクト: sphynx79/dotfiles
        /// <summary>
        ///   Initialize a QuickFix pointing to the first line of the
        ///   given region in the given file.
        /// </summary>
        public static QuickFix ForFirstLineInRegion
            (DomRegion region, CSharpFile file) {

            return QuickFix.ForFirstLineInRegion
                (region, file.Document);
        }
コード例 #10
0
 public void AddFile(string fileName)
 {
     var csharpFile = new CSharpFile (this, fileName);
     Files.Add (csharpFile);
     ProjectContent.AddOrUpdateFiles (new[] { csharpFile.ParsedFile });
 }