Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 482880

Summary: Decouple built-codeEdit from javascriptPlugin
Product: [ECD] Orion Reporter: Miro Spönemann <miro.spoenemann>
Component: EditorAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: libingw
Version: 11.0   
Target Milestone: 11.0   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Miro Spönemann CLA 2015-11-24 03:02:19 EST
Currently the javascriptPlugin is loaded whenever built-codeEdit or built-codeEdit-amd is used. This should be optional in order to reduce loading times for custom languages.
Comment 1 Miro Spönemann CLA 2015-11-24 03:03:10 EST
By the way, with build I20151123-2224 I get

TypeError: e.toUrl is not a function. (In 'e.toUrl(n)', 'e.toUrl' is undefined)
cjavascriptPlugin.js:1:26935
(anonymous function)javascriptPlugin.js:10:20281
fjavascriptPlugin.js:1:2221
ljavascriptPlugin.js:1:1113
djavascriptPlugin.js:1:2387
(anonymous function)javascriptPlugin.js:11:329
(anonymous function)javascriptPlugin.js:1:155
(anonymous function)javascriptPlugin.js:1:159
Comment 2 libing wang CLA 2015-11-24 08:47:32 EST
(In reply to Miro Spoenemann from comment #1)
> By the way, with build I20151123-2224 I get
> 
> TypeError: e.toUrl is not a function. (In 'e.toUrl(n)', 'e.toUrl' is
> undefined)
> cjavascriptPlugin.js:1:26935
> (anonymous function)javascriptPlugin.js:10:20281
> fjavascriptPlugin.js:1:2221
> ljavascriptPlugin.js:1:1113
> djavascriptPlugin.js:1:2387
> (anonymous function)javascriptPlugin.js:11:329
> (anonymous function)javascriptPlugin.js:1:155
> (anonymous function)javascriptPlugin.js:1:159

Verified the build is broken due to recent js plugin changes, opened bug 482900.
Comment 3 libing wang CLA 2015-11-24 08:49:55 EST
(In reply to Miro Spoenemann from comment #0)
> Currently the javascriptPlugin is loaded whenever built-codeEdit or
> built-codeEdit-amd is used. This should be optional in order to reduce
> loading times for custom languages.

The widget is loading 3 plugins by default. I will add another option to exclude plugins you want. Should be fixed soon...
Comment 4 libing wang CLA 2015-11-24 16:22:03 EST
Fixed with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=5e81bf671b27f624e283278ee092ba3ef1fdd57a.

Here is what happened behind the scene:
The widget is using the following plugin URLs to load all the default plugins.
[
    "../javascript/plugins/javascriptPlugin.html",
    "../webtools/plugins/webToolsPlugin.html",
    "../plugins/embeddedToolingPlugin.html"
];

With the fix I just pushed, when you construct the widget you can use the defaultPlugins options to specify what you want. Please note that the strings you used in the options do not have to use "/path1/path2" in front of hte plugin names because the widget code will be smart enough to use them just by the name.

var embeddedEditor = new mEmbeddedEditor({defaultPlugins: ["webToolsPlugin.html", "embeddedToolingPlugin.html"]});

Note that the snippet above just use "webToolsPlugin.html" and "embeddedToolingPlugin.html" to skip the javascript plugins. You can also use [] to skip all the plugins but I am not sure if you really want that.
Comment 5 libing wang CLA 2015-11-24 16:22:48 EST
The fix should be in the 20151124 nightly build.
Comment 6 libing wang CLA 2015-11-24 16:24:35 EST
For the toUrl() issue of the build, I've opened bug 482900 and it is fixed now. Should be in 20151124 nightly build as well.
Comment 7 Miro Spönemann CLA 2015-11-25 03:01:09 EST
(In reply to libing wang from comment #4)
> var embeddedEditor = new mEmbeddedEditor({defaultPlugins:
> ["webToolsPlugin.html", "embeddedToolingPlugin.html"]});

What do these two plugins contribute? I have no idea whether I need them.
Comment 8 libing wang CLA 2015-11-25 08:10:01 EST
(In reply to Miro Spoenemann from comment #7)
> (In reply to libing wang from comment #4)
> > var embeddedEditor = new mEmbeddedEditor({defaultPlugins:
> > ["webToolsPlugin.html", "embeddedToolingPlugin.html"]});
> 
> What do these two plugins contribute? I have no idea whether I need them.

Theses are validation, syntax highlighting for other contents types like html and css, etc. IF you only need the bare-bone editor you can just use [].
Comment 9 Miro Spönemann CLA 2015-11-25 08:27:14 EST
(In reply to libing wang from comment #8)
> Theses are validation, syntax highlighting for other contents types like
> html and css, etc. IF you only need the bare-bone editor you can just use [].

If I do that the editor remains empty after calling editorViewer.setContents(). Is this a bug?
Comment 10 libing wang CLA 2015-11-25 09:27:47 EST
(In reply to Miro Spoenemann from comment #9)
> (In reply to libing wang from comment #8)
> > Theses are validation, syntax highlighting for other contents types like
> > html and css, etc. IF you only need the bare-bone editor you can just use [].
> 
> If I do that the editor remains empty after calling
> editorViewer.setContents(). Is this a bug?

OK, here is why:
When we load contents to the editor, we check if the content type is an "text/plain".
Below is the code we are using to check that:

var textPlain = this.contentTypeRegistry.getContentType("text/plain");
return this.contentTypeRegistry.isExtensionOf(yourContentType, textPlain);

You already registered yourContentType, but "text/plain" type is defined in the "embeddedToolingPlugin.html" plugin.

SO you can either:
1. Use ["embeddedToolingPlugin.html"] 
or
2. register the "text/plain" type by your self:
{id: "text/plain", name: "Text", extension: ["txt"]};

I think you may want to use option 1 for now. Because there may be other dependencies on this plugin in some other cases. But it's up to you.
Comment 11 libing wang CLA 2015-11-25 11:17:36 EST
OK, I think you are safe to use defaultPlugins: [].
And you DO NOT have to register the "text/plain" type by yourself.
The widget code will register that type for you if it finds the "text/plain" type is not yet registered when it starts up.
The fix will be pushed soon and you can use tonight's build to just use the bare-bone editor.
Comment 12 libing wang CLA 2015-11-25 11:26:37 EST
Pushed the fix with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=bd4ea2250d7801211d4f6230a274cafcd36151cd.

You can now use bare-bone editor safely from tonight's build.