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

Bug 527134

Summary: codeEdit: Reusing the codeEdit.create() API on the same DOM introduces the javascript validation issue.
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: EditorAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: Michael_Rennie
Version: 16.0   
Target Milestone: 17.0   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description libing wang CLA 2017-11-10 11:44:26 EST
IF you use codeEdit.create() API to create an editorViewer, the javascript validator uses the fileClient.getProject(fileURL) API to see which project it belongs to.
The file URL in the codeEdit widget is an "in-memory" URL (e.g. /in_memory_fs/0/foo.js), but the codeEdit file system impl always return the same project Location.
When you create another editorViewer in the widget, the file URL will be "/in_memory_fs/1/foo.js", this URL pattern confused the js validator because the project URL "/in_memory_fs/project/" will return mismatch metadata against the file location.
Comment 1 Michael Rennie CLA 2017-11-10 11:56:00 EST
There are a few bugs at play here:

1. the code edit widget does not return the correct project for a file - regardless of the path of the file, the call to getProject for the embedded file impl always returns /in_memory_fs/project. So when the tools gets a new file and see it is not part of the  same project path, it asks for the project again (via the getProject call). But then detects that it is indeed in the same project context, and does not resolve a project change promise it uses (which cause the tools to 'wait')

2. all files in the widget should simply be created in the same virtual project: in_memory_fs/project since there is no support for more than one project in the widget

3. I can add a check in to the tools to catch this edge case:

if(file.location.indexOf(project.Location) === -1) {
  this.projectPromise.resolve(project);
}

which basically will ask "is the file not actually part of the project we resolved? Ok, then resolve the project promise".