|
14 | 14 | import java.io.File;
|
15 | 15 | import java.io.IOException;
|
16 | 16 |
|
| 17 | +import org.eclipse.core.internal.runtime.InternalPlatform; |
17 | 18 | import org.eclipse.core.runtime.CoreException;
|
18 | 19 | import org.eclipse.core.runtime.FileLocator;
|
19 | 20 | import org.eclipse.core.runtime.IConfigurationElement;
|
| 21 | +import org.eclipse.core.runtime.IPath; |
20 | 22 | import org.eclipse.core.runtime.Platform;
|
21 | 23 |
|
22 | 24 | import tern.eclipse.ide.server.nodejs.core.INodejsInstall;
|
23 | 25 | import tern.eclipse.ide.server.nodejs.core.INodejsInstallProvider;
|
24 | 26 | import tern.utils.ZipUtils;
|
25 | 27 |
|
| 28 | +@SuppressWarnings("restriction") |
26 | 29 | public class NodejsInstall implements INodejsInstall {
|
27 | 30 |
|
28 | 31 | private String id;
|
@@ -56,23 +59,31 @@ private void createClass(IConfigurationElement element) throws IOException {
|
56 | 59 | String pluginId = element.getNamespaceIdentifier();
|
57 | 60 | String path = element.getAttribute("path");
|
58 | 61 | if (path != null && path.length() > 0) {
|
59 |
| - File baseDir = FileLocator.getBundleFile(Platform |
| 62 | + File bundleDir = FileLocator.getBundleFile(Platform |
60 | 63 | .getBundle(pluginId));
|
61 |
| - this.path = new File(baseDir, path); |
62 |
| - |
63 |
| - // check if path exists, if it doesn't look for zip |
64 |
| - if (!this.path.exists()) { |
65 |
| - String zip = element.getAttribute("zip"); |
66 |
| - |
67 |
| - File zipFile = new File(baseDir, zip); |
68 |
| - |
69 |
| - if (zipFile.exists()) { |
70 |
| - if (zipFile.getName().toLowerCase().endsWith(".zip")) { |
71 |
| - ZipUtils.extract(zipFile, baseDir); |
72 |
| - } |
| 64 | + |
| 65 | + IPath stateLocationPath = InternalPlatform.getDefault().getStateLocation(Platform |
| 66 | + .getBundle(pluginId)); |
| 67 | + |
| 68 | + if (stateLocationPath != null) { |
| 69 | + File baseDir = stateLocationPath.toFile(); |
73 | 70 |
|
74 |
| - if(this.path.exists()) { |
75 |
| - this.path.setExecutable(true); |
| 71 | + this.path = new File(baseDir, path); |
| 72 | + |
| 73 | + // check if path exists, if it doesn't look for zip |
| 74 | + if (!this.path.exists()) { |
| 75 | + String zip = element.getAttribute("zip"); |
| 76 | + |
| 77 | + File zipFile = new File(bundleDir, zip); |
| 78 | + |
| 79 | + if (zipFile.exists()) { |
| 80 | + if (zipFile.getName().toLowerCase().endsWith(".zip")) { |
| 81 | + ZipUtils.extract(zipFile, baseDir); |
| 82 | + } |
| 83 | + |
| 84 | + if(this.path.exists()) { |
| 85 | + this.path.setExecutable(true); |
| 86 | + } |
76 | 87 | }
|
77 | 88 | }
|
78 | 89 | }
|
|
0 commit comments