登录

  • 登录
  • 忘记密码?点击找回

注册

  • 获取手机验证码 60
  • 注册

找回密码

  • 获取手机验证码60
  • 找回
毕业论文网 > 毕业论文 > 计算机类 > 计算机科学与技术 > 正文

基于Electron的热更新代码编辑器的设计与实现毕业论文

 2021-03-15 08:03  

摘 要

实现热更新编辑器的过程需要进行词法分析、语法分析、抽象语法树构建等工作,涵盖编译原理、计算机算法、计算机前端和后台等多个方面的知识。本文通过对编辑器实现过程中重难以及对可拓展性架构的研究,实现了一个功能齐全的代码编辑器,支持编辑器的拓展和自定义样式。此外,编辑器还提供了热更新服务器,可以实时监听静态资源改刷新浏览器,帮助前端人员更好的开发。本文从打造一个代码编辑器,同时为前端开发者提供静态资源服务器和热更新服务器的角度出发,主要工作如下:

1)通过对编辑器内的原始编码进行词法分析和语法分析,结合原始编码的行列等信息,生成抽象语法树。本文主要选取javascript为分析对象语言,建立了抽象语法树后,通过对抽象语法树的遍历等操作,实现了代码的高亮,智能提示和补全等功能。

2)实现编辑器主体之外的交互功能,包括与系统的文件交互模块,标签页模块等。通过对该部分的特殊架构设计,做到了与编辑器主体尽量低耦合的特性,具有很好的拓展性和可维护性。

3) 在编辑器的基础上实现了代码热更新功能,编辑器提供了静态及热更新两种服务器,当编辑器用户使用热更新服务器后,在用户更改了服务器静态资源后,如果用户在浏览器中打开了引用该静态资源的页面,该页面会自动进行刷新,显示更改后的网页内容。通过热更新服务器可以大幅提高前端开发者的开发效率。

本论文对代码编辑器每一个模块进行了深入的挖掘和实现,介绍了每一个模块的重点的实现方式以及相互间的设计原则,提供了热更新服务器的解决方案,提高前端开发者的编程效率。

关键词:代码编辑器,Electron,热更新,Node.js

Abstract

The process of implementing the hot update editor requires lexical analysis, parsing, abstract syntax tree construction, and so on, covering the principles of compiling principles, computer algorithms, computer front end and background. In this paper, through the editor to achieve the process of difficult and scalable architecture of the study, to achieve a full-featured code editor to support the expansion of the editor and custom style. In addition, the editor also provides a hot update server, you can monitor real-time static resources to refresh the new browser to help front-end staff better development. This article from the build a code editor, while the front-end developers to provide static resource server and hot update server point of view, the main work is as follows:

1) through the editor of the original code for lexical analysis and syntax analysis, combined with the original coding of the ranks of information, generate abstract syntax tree. This paper mainly chooses javascript as the object of analysis, establishes the abstract syntax tree, and realizes the function of highlighting, intelligent prompting and completion through the operation of abstract syntax tree.

2) To achieve the editor outside the main body of the interactive functions, including the system with the file interaction module, tab page module. Through the special structure of the design, the editor with the main body as low as possible coupling characteristics, with good scalability and maintainability.

3) In the editor based on the code to achieve the hot update function, the editor provides a static and hot update two servers, when the editor user to use the hot update server, the user changes the server static resources, if the user in the browser Open the page that references the static resource, which will automatically refresh to display the changed page content. Through the heat update server can greatly improve the development efficiency of front-end developers.

In this paper, each module of the code editor in-depth mining and implementation, describes the focus of each module to achieve the way and the design principles between each other to provide a hot update server solutions to improve the front-end developers programming efficiency.

Key Words: code editor, Electron, Hot Update, Node.js

目 录

摘 要 II

Abstract III

第1章 绪论 1

1.1 研究目的与意义 1

1.2 研究背景与现状 2

1.3 功能需求 3

1.4 研究的主要内容 4

1.4.1 词法分析与代码着色 4

1.4.2 智能提示及其他辅助功能 4

1.4.3 编辑器主体交互 4

1.4.4 服务器热更新 5

1.5 研究的技术路线与方法 5

1.5.1 平台环境 5

1.5.2 技术方法 5

1.6 本章小结 6

第2章 词法分析与代码着色 7

2.1 原始编码 7

2.2 词法分析 7

2.2.1 词法分析方法——状态机 7

2.2.2 状态机绘制 8

2.2.3 状态机编码生成 9

2.3 着色器的实现 9

2.4 着色器语言扩展支持 9

2.5 本章小结 10

第3章 智能提示及其他辅助功能 11

3.1 代码智能提示简介 11

3.2 功能基础——语法分析 12

3.3 智能提示实现 13

3.3.1 两个关键问题 13

3.3.2 语法分析及AST构建 13

3.3.3 SCOPE表的建立 14

3.3.4 块语法分析 14

3.4 定义及引用查询 15

3.5 本章小结 15

第4章 编辑器主体功能实现 16

4.1 Electron原生应用编写 16

4.2 文件系统交互实现 16

4.3 标签页实现 17

4.4 MVVM组件设计 18

图4.3 MVVM数据交互图 18

4.5 状态流管理 19

4.5 本章小结 19

第5章 服务器拓展及热更新实现 20

5.1 Node.js服务器编程简介 20

5.2 服务器拓展实现 20

5.3 热更新功能拓展 20

5.3.1 websocket协议通信 20

5.3.2 自动刷新及热更新实现 21

5.3 本章小结 22

第6章 总结与展望 23

6.1 总结 23

6.2 展望 23

参考文献 25

致 谢 26

第1章 绪论

1.1 研究目的与意义

随着计算机的性能不断提升,脚本语言发展迅速。脚本语言相关的通用库不断完善,执行环境(解释器)在一步步的发展之下,执行的速度也越来越快,脚本语言能够胜任越来越多高级语言的工作。与传统的高级语言相比,脚本语言摒弃了强类型的语言设计,使用弱类型或无类型定义来简化组件之间的联系,为程序员的开发工作带来了更多的便利,使用脚本语言辅助开发工作可以大幅提高程序员的工作效率。

根据IEEE Spectrum出品的“2016年最受欢迎编程语言排行榜”(图1.1),最受欢迎的程序设计语言的前十中,脚本语言占了半数之多。在脚本语言风靡的时代,了解和优化脚本语言的开发环境势在必行。区别于高级语言的复杂特性,脚本语言的开发往往不需要重量级的IDE来支持,而只需要轻量级的代码编辑器即可。

图1.1 2016编程语言受欢迎排行榜

您需要先支付 80元 才能查看全部内容!立即支付

企业微信

Copyright © 2010-2022 毕业论文网 站点地图