Browse Source

Comment more

Sebastien Lebreton 5 năm trước cách đây
mục cha
commit
a3274dcb2c
1 tập tin đã thay đổi với 19 bổ sung10 xóa
  1. 19 10
      Playground/js/monacoCreator.js

+ 19 - 10
Playground/js/monacoCreator.js

@@ -7,6 +7,8 @@
  * - compilation and proper error reporting for both JS and TS.
  * - private/internal member filtering (we should not see members starting with an underscore).
  * - dedicated adornments, like the one used for previewing colors for BABYLON.ColorX types.
+ * - diff support.
+ * - minimap support.
  */
 class MonacoCreator {
     constructor(parent) {
@@ -97,16 +99,15 @@ class MonacoCreator {
         });
     };
 
+    // > This worker will analyze the syntaxtree and return an array of deprecated functions (but the goal is to do more in the future!)
+    // We need to do this because:
+    // - checking extended properties during completion is time consuming, so we need to prefilter potential candidates
+    // - we don't want to maintain a static list of deprecated members or to instrument this work on the CI
+    // - we have more plans involving syntaxtree analysis
+    // > This worker was carefully crafted to work even if the processing is super fast or super long. 
+    // In both cases the deprecation filter will start working after the worker is done.
+    // We will also need this worker in the future to compute Intellicode scores for completion using dedicated attributes.
     setupDefinitionWorker(libContent) {
-
-        // > This worker will analyze the syntaxtree and return an array of deprecated functions (but the goal is to do more in the future!)
-        // We need to do this because:
-        // - checking extended properties during completion is time consuming, so we need to prefilter potential candidates
-        // - we don't want to maintain a static list of deprecated members or to instrument this work on the CI
-        // - we have more plans involving syntaxtree analysis
-        // > This worker was carefully crafted to work even if the processing is super fast or super long. 
-        // In both cases the deprecation filter will start working after the worker is done.
-        // We will also need this worker in the future to compute Intellicode scores for completion using dedicated attributes.
         this.definitionWorker = new Worker('/js/definitionWorker.js');
         this.definitionWorker.addEventListener('message', ({ data }) => {
             this.deprecatedCandidates = data.result;
@@ -126,6 +127,9 @@ class MonacoCreator {
             && tag.name == "deprecated";
     }
 
+    // This will make sure that all members marked with a deprecated jsdoc attribute will be marked as such in Monaco UI
+    // We use a prefiltered list of deprecated candidates, because the effective call to getCompletionEntryDetails is slow.
+    // @see setupDefinitionWorker
     async analyzeCode() {
         // if the definition worker is very fast, this can be called out of context. @see setupDefinitionWorker
         if (!this.jsEditor)
@@ -180,7 +184,10 @@ class MonacoCreator {
 
         monaco.editor.setModelMarkers(model, source, markers);
     }
-
+    
+    // This is our hook in the Monaco suggest adapter, we are called everytime a completion UI is displayed
+    // So we need to be super fast.
+    // We need the 'dev' version of Monaco, as we use monkey-patching to hook into this suggestion adapter
     hookMonacoCompletionProvider(provider) {
         const provideCompletionItems = provider.prototype.provideCompletionItems;
         const owner = this;
@@ -220,6 +227,7 @@ class MonacoCreator {
         }
     }
 
+    // Setup both JS and TS compilation pipelines to work with our scripts. 
     setupMonacoCompilationPipeline(libContent) {
         const typescript = monaco.languages.typescript;
 
@@ -249,6 +257,7 @@ class MonacoCreator {
         }
     }
 
+    // Provide an adornment for BABYLON.ColorX types: color preview
     setupMonacoColorProvider() {
         monaco.languages.registerColorProvider(this.monacoMode, {
             provideColorPresentations: (model, colorInfo) => {