Skip to content

Commit

Permalink
Editor refactor - Part 1: Feature project (onivim#1279)
Browse files Browse the repository at this point in the history
* move FontAwesome and FontIcon to Components

* move HighlightText to Components

* initial move of EditorSurface to feature project - not compiling

* initial move of Minimap - not compiling

* move Filter to Core

* factor out LanguageSupport feature project

* move BufferHighlights to Oni_Syntax

* factor out Editor feature project

* remove leftover duplicate modules from Model

* create Feature_Editor_Test project

* create FeatureLanguageSupport_Test project
  • Loading branch information
glennsl authored Jan 31, 2020
1 parent d038760 commit 174af59
Show file tree
Hide file tree
Showing 108 changed files with 720 additions and 475 deletions.
2 changes: 1 addition & 1 deletion bench/lib/BufferViewTokenizerBench.re
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open Oni_Core;
open Oni_Model;
open BenchFramework;
open Revery;
open Feature_Editor;

let giantString =
String.make(1000, 'a')
Expand Down
2 changes: 1 addition & 1 deletion bench/lib/EditorDiffMarkersBench.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open Oni_Core;
open Oni_UI;
open BenchFramework;
open Feature_Editor;

// DATA

Expand Down
93 changes: 82 additions & 11 deletions bench/lib/EditorSurfaceBench.re
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
open Oni_UI;
open Oni_Model;
open BenchFramework;
open Feature_Editor;

open Helpers;

Expand All @@ -21,10 +22,24 @@ let editorSurfaceMinimalState = () => {
rootNode,
<EditorSurface
isActiveSplit=true
editorGroup
editor=simpleEditor
state=simpleState
activeBuffer={Selectors.getBufferForEditor(
thousandLineState,
simpleEditor,
)}
metrics
onScroll={_ => ()}
onDimensionsChanged={_ => ()}
onCursorChange={_ => ()}
bufferHighlights={thousandLineState.bufferHighlights}
bufferSyntaxHighlights={thousandLineState.bufferSyntaxHighlights}
diagnostics={thousandLineState.diagnostics}
completions={thousandLineState.completions}
tokenTheme={thousandLineState.tokenTheme}
definition={thousandLineState.definition}
mode={thousandLineState.mode}
theme={thousandLineState.theme}
editorFont={thousandLineState.editorFont}
/>,
);
();
Expand All @@ -36,10 +51,24 @@ let editorSurfaceThousandLineState = () => {
rootNode,
<EditorSurface
isActiveSplit=true
editorGroup
editor=simpleEditor
state=thousandLineState
activeBuffer={Selectors.getBufferForEditor(
thousandLineState,
simpleEditor,
)}
metrics
onScroll={_ => ()}
onDimensionsChanged={_ => ()}
onCursorChange={_ => ()}
bufferHighlights={thousandLineState.bufferHighlights}
bufferSyntaxHighlights={thousandLineState.bufferSyntaxHighlights}
diagnostics={thousandLineState.diagnostics}
completions={thousandLineState.completions}
tokenTheme={thousandLineState.tokenTheme}
definition={thousandLineState.definition}
mode={thousandLineState.mode}
theme={thousandLineState.theme}
editorFont={thousandLineState.editorFont}
/>,
);
();
Expand All @@ -51,10 +80,24 @@ let editorSurfaceThousandLineStateWithIndents = () => {
rootNode,
<EditorSurface
isActiveSplit=true
editorGroup
editor=simpleEditor
state=thousandLineStateWithIndents
activeBuffer={Selectors.getBufferForEditor(
thousandLineState,
simpleEditor,
)}
metrics
onScroll={_ => ()}
onDimensionsChanged={_ => ()}
onCursorChange={_ => ()}
bufferHighlights={thousandLineState.bufferHighlights}
bufferSyntaxHighlights={thousandLineState.bufferSyntaxHighlights}
diagnostics={thousandLineState.diagnostics}
completions={thousandLineState.completions}
tokenTheme={thousandLineState.tokenTheme}
definition={thousandLineState.definition}
mode={thousandLineState.mode}
theme={thousandLineState.theme}
editorFont={thousandLineState.editorFont}
/>,
);
();
Expand All @@ -66,10 +109,24 @@ let editorSurfaceHundredThousandLineState = () => {
rootNode,
<EditorSurface
isActiveSplit=true
editorGroup
editor=simpleEditor
state=hundredThousandLineState
activeBuffer={Selectors.getBufferForEditor(
thousandLineState,
simpleEditor,
)}
metrics
onScroll={_ => ()}
onDimensionsChanged={_ => ()}
onCursorChange={_ => ()}
bufferHighlights={thousandLineState.bufferHighlights}
bufferSyntaxHighlights={thousandLineState.bufferSyntaxHighlights}
diagnostics={thousandLineState.diagnostics}
completions={thousandLineState.completions}
tokenTheme={thousandLineState.tokenTheme}
definition={thousandLineState.definition}
mode={thousandLineState.mode}
theme={thousandLineState.theme}
editorFont={thousandLineState.editorFont}
/>,
);
();
Expand All @@ -87,10 +144,24 @@ let setupSurfaceThousandLineLayout = () => {
container,
<EditorSurface
isActiveSplit=true
editorGroup
editor=simpleEditor
state=thousandLineState
activeBuffer={Selectors.getBufferForEditor(
thousandLineState,
simpleEditor,
)}
metrics
onScroll={_ => ()}
onDimensionsChanged={_ => ()}
onCursorChange={_ => ()}
bufferHighlights={thousandLineState.bufferHighlights}
bufferSyntaxHighlights={thousandLineState.bufferSyntaxHighlights}
diagnostics={thousandLineState.diagnostics}
completions={thousandLineState.completions}
tokenTheme={thousandLineState.tokenTheme}
definition={thousandLineState.definition}
mode={thousandLineState.mode}
theme={thousandLineState.theme}
editorFont={thousandLineState.editorFont}
/>,
)
|> ignore;
Expand Down
1 change: 1 addition & 0 deletions bench/lib/Helpers.re
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ open Oni_Core;
open Utility;
open Oni_Model;
open Oni_Store;
open Feature_Editor;

let metrics = EditorMetrics.create();

Expand Down
2 changes: 2 additions & 0 deletions integration_test/ExtHostDefinitionTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ open Oni_Core;
open Oni_Core.Utility;
open Oni_Model;
open Oni_IntegrationTestLib;
open Feature_LanguageSupport;
open Feature_Editor;

// This test validates:
// - The 'oni-dev' extension gets activated
Expand Down
7 changes: 3 additions & 4 deletions integration_test/LanguageCssTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ open Oni_Core;
open Oni_Core.Utility;
open Oni_Model;
open Oni_IntegrationTestLib;
open Feature_LanguageSupport;

// This test validates:
// - The 'oni-dev' extension gets activated
Expand Down Expand Up @@ -62,8 +63,7 @@ runTestWithInput(

switch (bufferOpt) {
| Some(buffer) =>
let diags =
Model.Diagnostics.getDiagnostics(state.diagnostics, buffer);
let diags = Diagnostics.getDiagnostics(state.diagnostics, buffer);
List.length(diags) > 0;
| _ => false
};
Expand Down Expand Up @@ -92,8 +92,7 @@ runTestWithInput(

switch (bufferOpt) {
| Some(buffer) =>
let diags =
Model.Diagnostics.getDiagnostics(state.diagnostics, buffer);
let diags = Diagnostics.getDiagnostics(state.diagnostics, buffer);
List.length(diags) == 0;
| _ => false
};
Expand Down
7 changes: 3 additions & 4 deletions integration_test/LanguageTypeScriptTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ open Oni_Core;
open Oni_Core.Utility;
open Oni_Model;
open Oni_IntegrationTestLib;
open Feature_LanguageSupport;

runTestWithInput(
~name="LanguageTypeScriptTest", (input, dispatch, wait, _runEffects) => {
Expand Down Expand Up @@ -70,8 +71,7 @@ runTestWithInput(

switch (bufferOpt) {
| Some(buffer) =>
let diags =
Model.Diagnostics.getDiagnostics(state.diagnostics, buffer);
let diags = Diagnostics.getDiagnostics(state.diagnostics, buffer);
List.length(diags) > 0;
| _ => false
};
Expand All @@ -97,8 +97,7 @@ runTestWithInput(

switch (bufferOpt) {
| Some(buffer) =>
let diags =
Model.Diagnostics.getDiagnostics(state.diagnostics, buffer);
let diags = Diagnostics.getDiagnostics(state.diagnostics, buffer);
List.length(diags) == 0;
| _ => false
};
Expand Down
2 changes: 2 additions & 0 deletions integration_test/Regression1097Test.re
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ open Oni_Core.Utility;
open Oni_Model;
open Oni_IntegrationTestLib;

module BufferSyntaxHighlights = Feature_Editor.BufferSyntaxHighlights;

let gotSyntaxServerClose = ref(false);

let onAfterDispatch =
Expand Down
1 change: 1 addition & 0 deletions integration_test/SearchShowClearHighlightsTest.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
open Oni_Core;
open Oni_Model;
open Oni_IntegrationTestLib;
open Oni_Syntax;

runTest(
~name="InsertMode test - effects batched to runEffects",
Expand Down
2 changes: 2 additions & 0 deletions integration_test/SyntaxHighlightTextMateTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ open Oni_Core.Utility;
open Oni_Model;
open Oni_IntegrationTestLib;

module BufferSyntaxHighlights = Feature_Editor.BufferSyntaxHighlights;

// Validate that textmate highlight runs
runTest(~name="SyntaxHighlightTextMateTest", (dispatch, wait, _runEffects) => {
wait(~name="Capture initial state", (state: State.t) =>
Expand Down
2 changes: 2 additions & 0 deletions integration_test/SyntaxHighlightTreesitterTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ open Oni_Core.Utility;
open Oni_Model;
open Oni_IntegrationTestLib;

module BufferSyntaxHighlights = Feature_Editor.BufferSyntaxHighlights;

let configuration = Some({|
{ "experimental.treeSitter": true }
|});
Expand Down
2 changes: 1 addition & 1 deletion integration_test/lib/ExtensionHelpers.re
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Option = Core.Utility.Option;
module Model = Oni_Model;

module State = Model.State;
module LanguageFeatures = Model.LanguageFeatures;
module LanguageFeatures = Feature_LanguageSupport.LanguageFeatures;

let waitForExtensionToActivate =
(~extensionId, waitForState: Types.waitForState) => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/Model/Filter.re → src/Core/Filter.re
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
open ReasonFuzz;

open Oni_Core.CamomileBundled.Camomile;
open CamomileBundled.Camomile;

module IndexEx = Oni_Core.Utility.IndexEx;
module Zed_utf8 = Oni_Core.ZedBundled;
module IndexEx = Utility.IndexEx;
module Zed_utf8 = ZedBundled;

module Option = {
let map = f =>
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Filter.rei → src/Core/Filter.rei
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Module to filter & rank items using various strategies.
*/

open Oni_Core.CamomileBundled.Camomile;
open CamomileBundled.Camomile;

type result('a) = {
item: 'a,
Expand Down
1 change: 1 addition & 0 deletions src/Core/Oni_Core.re
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module EditorFont = EditorFont;
module EditorSize = EditorSize;
module EnvironmentVariables = Kernel.EnvironmentVariables;
module Filesystem = Filesystem;
module Filter = Filter;
module Indentation = Indentation;
module IndentationGuesser = IndentationGuesser;
module IndentationSettings = IndentationSettings;
Expand Down
1 change: 1 addition & 0 deletions src/Core/dune
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
textmate
editor-core-types
timber
ReasonFuzz
)
(preprocess (pps ppx_deriving_yojson ppx_deriving.show)))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ open Revery.UI;

open Oni_Core;
open Oni_Syntax;
open Oni_Model;
open Oni_Components;
open Utility;

open Completions;
open Feature_LanguageSupport.Completions;

module Zed_utf8 = Oni_Core.ZedBundled;
module Ext = Oni_Extensions;
module CompletionItem = Feature_LanguageSupport.CompletionItem;

open Ext.CompletionItemKind;

Expand Down Expand Up @@ -189,10 +189,19 @@ let detailView =
<Text style={Styles.detailText(~editorFont, ~theme, ~tokenTheme)} text />
</View>;

let make = (~x: int, ~y: int, ~lineHeight: float, ~state: State.t, ()) => {
let make =
(
~x: int,
~y: int,
~lineHeight: float,
~theme,
~tokenTheme,
~editorFont,
~completions,
(),
) => {
/*let hoverEnabled =
Configuration.getValue(c => c.editorHoverEnabled, state.configuration);*/
let {theme, tokenTheme, editorFont, completions, _}: State.t = state;
let items = completions.filtered;

let maxWidth =
Expand Down
Loading

0 comments on commit 174af59

Please sign in to comment.