diff options
Diffstat (limited to 'rfc.md')
-rw-r--r-- | rfc.md | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -80,7 +80,10 @@ simpler ones. | |||
80 | 80 | ||
81 | In contrast, for IDEs it is crucial to have a lossless view of the | 81 | In contrast, for IDEs it is crucial to have a lossless view of the |
82 | source code because, for example, it's important to preserve comments | 82 | source code because, for example, it's important to preserve comments |
83 | during refactorings. | 83 | during refactorings. Ideally, IDEs should be able to incrementally |
84 | relex and reparse the file as the user types, because syntax tree is | ||
85 | necessary to correctly handle certain code-editing actions like | ||
86 | autoindentation or joining lines. | ||
84 | 87 | ||
85 | Currently rustc uses the AST approach, which preserves the source code | 88 | Currently rustc uses the AST approach, which preserves the source code |
86 | information to some extent by storing spans in the AST. | 89 | information to some extent by storing spans in the AST. |
@@ -98,7 +101,7 @@ Not applicable. | |||
98 | 101 | ||
99 | This section proposes a new syntax tree data structure, which should | 102 | This section proposes a new syntax tree data structure, which should |
100 | be suitable for both compiler and IDE. It is heavily inspired by [PSI] | 103 | be suitable for both compiler and IDE. It is heavily inspired by [PSI] |
101 | data structure which used in [IntelliJ] based IDEs and in the Kotlin | 104 | data structure which used in [IntelliJ] based IDEs and in the [Kotlin] |
102 | compiler. | 105 | compiler. |
103 | 106 | ||
104 | 107 | ||
@@ -107,6 +110,21 @@ compiler. | |||
107 | [Kotlin]: https://kotlinlang.org/ | 110 | [Kotlin]: https://kotlinlang.org/ |
108 | 111 | ||
109 | 112 | ||
113 | The main idea is to store the minimal amount of information in the | ||
114 | tree itself, and instead lean heavily on the source code string for | ||
115 | the actual data about identifier names, constant values etc. | ||
116 | |||
117 | All nodes in the tree are of the same type and store a constant for | ||
118 | the syntactic category of the element and a range in the source code. | ||
119 | |||
120 | Here is a minimal implementation of this data structure: | ||
121 | |||
122 | |||
123 | ```Rust | ||
124 | ``` | ||
125 | |||
126 | |||
127 | |||
110 | # Drawbacks | 128 | # Drawbacks |
111 | [drawbacks]: #drawbacks | 129 | [drawbacks]: #drawbacks |
112 | 130 | ||