C# 代码编辑器实现篇-智能提示和代码折叠

本文介绍了如何在C#代码编辑器中实现智能提示和代码折叠功能。通过引用链接到的GitHub项目,展示了关键代码片段,帮助开发者理解实现过程。对于editor.Text赋值无法使用智能提示的问题,文章也进行了说明。
摘要由CSDN通过智能技术生成

实现参见:https://github.com/lukebuehler/NRefactory-Completion-Sample

智能提示:关键代码片段

		//editor初始化
		editor.Completion=new ICSharpCode.CodeCompletion.CSharpCompletion(GetRelativeAssemblies());

		//需要支持提示的DLL在此处加载
        private Assembly[] GetRelativeAssemblies()
        {
   
            return new Assembly[] {
   
                    typeof(object).Assembly, //mscorlib
                    typeof(Uri).Assembly, //System.dll
                    typeof(Enumerable).Assembly,//System.Core.dll

                };
        }
			//注意:此处若直接采用 editor.Text 赋值,则智能提示无法使用
            editor.OpenFile("../../Program.cs");
            editor.Text = "using System;";
            //editor.NewFile("Program.cs", "using System;");

关于 editor.Text 赋值无法使用智能提示原因见 CodeTextEditor.cs

            //only process csharp files and if there is a code completion engine available
            if (String.IsNullOrEmpty(Document.FileName))
            {
   
                Debug.WriteLine("No document file name, cannot run code completion");
                return;
            }

代码折叠:关键代码片段


		//editor初始化
  • 0
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值