Bug 319453 - [project setup] JSDT uses wrong default include path when deleting and recreating projects
Summary: [project setup] JSDT uses wrong default include path when deleting and recrea...
Status: NEW
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows Vista
: P3 normal with 1 vote (vote)
Target Milestone: Future   Edit
Assignee: Project Inbox CLA
QA Contact: Chris Jaun CLA
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2010-07-09 20:43 EDT by Eugene Ostroukhov CLA
Modified: 2013-12-10 14:43 EST (History)
3 users (show)

See Also:


Attachments
JUnit Test is added for the issue (8.34 KB, patch)
2013-12-10 14:05 EST, Victor Rubezhny CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Ostroukhov CLA 2010-07-09 20:43:34 EDT
Our project is built on top of Eclipse Helios. Our project has JSDT nature (org.eclipse.wst.jsdt.core.jsNature) and is not a WTP web project (it is not a faceted project).

We create our projects using following APIs:
BuildPathsBlock.createProject(project, uri, new SubProgressMonitor(monitor, 10));
BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(monitor, 10));


IJavaScriptProject jsProject = JavaScriptCore.create(project);
final IIncludePathEntry[] includepath = jsProject.getRawIncludepath();
---- Setup classpath ----

The problem we encountered is that if you create a new project then includepath will have 3 entries (source + browser + default). But if you delete project and then create a new one without restarting the workbench its include path will not be reseted to default but will have 0 entries instead.

It is because project description is cached by JSDT and is reused for the new project.
Comment 1 Eugene Ostroukhov CLA 2010-07-09 20:47:58 EDT
As a workaround we now explicitly reset include path on a new project:
jsProject.setRawIncludepath(null, new SubProgressMonitor(monitor, 5));
Comment 2 Nitin Dahyabhai CLA 2011-01-26 22:59:42 EST
Eugene, do you have more exact details about where this going wrong in the source?
Comment 3 Chris Jaun CLA 2013-11-07 13:46:09 EST
We have no plans to work on this, especially if there is a work around. If anyone in the community would like to submit a patch for this, we will take it. If not, I plan to close by the end of WTP 3.6 development.
Comment 4 Victor Rubezhny CLA 2013-11-27 10:04:32 EST
I cannot reproduce it using Kepler + WTP 3.5.1.

Initially I have a project with various natures (including the JavaScript one). So, due to reproduce the issue:
- I've deleted that project (but didn't remove its contents on the disk)
- I've used New->Project->General Project wizard due to re-create the deleted project, typed the name of the project that I've removed on the previous step and pressed "Finish" button

The project was successfully recreated and "Project->Properties->JavaScript->Include Path" had all the three mentioned items.

When using "New->Project->JavaScript->JavaScript Project" wizard, I have the same result. The difference is only I have to select "Create project from existing source" option and select the folder that contains the deleted project.

So, either I'm doing something wrong while trying to reproduce, or the issue is fixed somehow in Kepler, or there is a very special project setup.
Comment 5 Chris Jaun CLA 2013-12-10 10:07:19 EST
So many things have changed since this was originally opened, so would not be surprised if this got fixed along the way.

Victor, were you re-creating this using the wizards? The original bug was using API calls to create the project, I believe. Perhaps the problem is on a different code path than the wizard uses.
Comment 6 Victor Rubezhny CLA 2013-12-10 11:02:00 EST
Yes, I did tested the issue by using the wizards only.

But you're correct, we need to test it by the calls to the API. I'll create a test for this case.
Comment 7 Victor Rubezhny CLA 2013-12-10 14:05:47 EST
Created attachment 238219 [details]
JUnit Test is added for the issue

The patch adds JUnit Test due to verify the issue.

Due to test the issue, the test case performs the following steps:
- Creates a JavaScript Project using BuildPathsBlock.createProject(...) and BuildPathsBlock.addJavaNature(...) API
- Tests the Include Path of the created project (Should contain at least one Source, one Script Support and one Browser support containers)
- Deletes the created project
- On the same workspace the test creates a new JavaScript Project with the same name using BuildPathsBlock.createProject(...) and BuildPathsBlock.addJavaNature(...) API
- Tests the Include Path of the created project (Should contain at least one Source, one Script Support and one Browser support containers)
Comment 8 Victor Rubezhny CLA 2013-12-10 14:43:17 EST
I've attached the JUnit Test that should probably reproduce the issue (See the comment to the patch).

In my environment the Test completes with success.

Chris, WDYT? Probably, some other operations should be invoked between the deletion and the re-creation of the project due to reproduce the issue?