Changeset 3466 for devel-tools
- Timestamp:
- Mar 7, 2008, 1:49:44 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.plus.rfpdt.launch/src/org/refal/plus/rfpdt/launch/RfpClasspathProvider.java
r3449 r3466 2 2 3 3 import java.io.IOException; 4 import java.net.URL;5 4 import java.util.ArrayList; 6 5 import java.util.Arrays; … … 10 9 import org.eclipse.core.runtime.CoreException; 11 10 import org.eclipse.core.runtime.FileLocator; 12 import org.eclipse.core.runtime.IPath;13 11 import org.eclipse.core.runtime.Path; 14 12 import org.eclipse.core.runtime.Platform; 15 13 import org.eclipse.debug.core.ILaunchConfiguration; 16 import org.eclipse.jdt.core.IClasspathContainer;17 import org.eclipse.jdt.core.IClasspathEntry;18 import org.eclipse.jdt.core.JavaCore;19 14 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 20 15 import org.eclipse.jdt.launching.IRuntimeClasspathEntry; … … 25 20 26 21 public class RfpClasspathProvider extends StandardClasspathProvider { 27 private List<IRuntimeClasspathEntry> defaultUserClassPath (ILaunchConfiguration configuration) throws CoreException { 28 List<IPath> paths = new ArrayList<IPath>(); 29 String projectName = configuration.getAttribute(IRfpLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); 30 if (projectName.length() > 0) { 31 paths.add(ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getFullPath()); 32 } 33 Bundle b = Platform.getBundle("org.refal.plus"); 34 // TODO: 35 // if (b instanceof BundleHost) { 36 // BundleFile file = ((BaseData) ((BundleHost) b).getBundleData()).getBundleFile(); 37 // String x = file.getBaseFile().getAbsolutePath(); 38 // x.charAt(0); 39 // } 22 private static IRuntimeClasspathEntry newStandartEntry (String path) { 23 IRuntimeClasspathEntry entry = JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path)); 24 entry.setClasspathProperty(IRuntimeClasspathEntry.BOOTSTRAP_CLASSES); 25 return entry; 26 } 27 28 private static void addDefaultUserPath (List<IRuntimeClasspathEntry> entries, ILaunchConfiguration configuration) 29 throws CoreException { 40 30 try { 41 URL url = b.getEntry("/bin");42 if (url == null) {43 String file = FileLocator.resolve(b.getEntry("")).getPath();44 paths.add(new Path(file.substring(5, file.length() - 2)));45 }else {46 paths.add(new Path(FileLocator.resolve(url).getPath()));47 paths.add(new Path(FileLocator.resolve(b.getEntry("/asm")).getPath()));48 paths.add(new Path(FileLocator.resolve(b.getEntry("/wrappers")).getPath()));31 Bundle b = Platform.getBundle("org.refal.plus"); 32 String file = FileLocator.resolve(b.getEntry("")).getPath(); 33 if (file.startsWith("file:") && file.endsWith("jar!/")) 34 entries.add(newStandartEntry(file.substring(5, file.length() - 2))); 35 else { 36 entries.add(newStandartEntry(FileLocator.resolve(b.getEntry("/bin")).getPath())); 37 entries.add(newStandartEntry(FileLocator.resolve(b.getEntry("/asm")).getPath())); 38 entries.add(newStandartEntry(FileLocator.resolve(b.getEntry("/wrappers")).getPath())); 49 39 } 50 40 } catch (IOException e) { 51 41 RfpCorePlugin.log(e); 52 42 } 53 List<IRuntimeClasspathEntry> classpathEntries = new ArrayList<IRuntimeClasspathEntry>(); 54 for (IPath path : paths) { 55 IClasspathEntry entry = JavaCore.newLibraryEntry((IPath) path, null, null); 56 IRuntimeClasspathEntry runtimeClasspathEntry = runtimeClasspathEntryFor(entry); 57 if (runtimeClasspathEntry != null) 58 classpathEntries.add(runtimeClasspathEntry); 59 } 60 return classpathEntries; 61 } 62 63 public IRuntimeClasspathEntry runtimeClasspathEntryFor (IClasspathEntry entry) throws CoreException { 64 switch (entry.getEntryKind()) { 65 case IClasspathEntry.CPE_LIBRARY: 66 return JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()); 67 case IClasspathEntry.CPE_CONTAINER: 68 IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), null); 69 if (container != null) { 70 switch (container.getKind()) { 71 case IClasspathContainer.K_APPLICATION: 72 // don't look at application entries 73 return null; 74 case IClasspathContainer.K_DEFAULT_SYSTEM: 75 return JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(), 76 IRuntimeClasspathEntry.STANDARD_CLASSES); 77 case IClasspathContainer.K_SYSTEM: 78 return JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(), 79 IRuntimeClasspathEntry.BOOTSTRAP_CLASSES); 80 } 81 } 82 break; 83 case IClasspathEntry.CPE_VARIABLE: 84 if (JavaRuntime.JRELIB_VARIABLE.equals(entry.getPath().segment(0))) { 85 IRuntimeClasspathEntry jre = JavaRuntime.newVariableRuntimeClasspathEntry(entry.getPath()); 86 jre.setClasspathProperty(IRuntimeClasspathEntry.STANDARD_CLASSES); 87 return jre; 88 } 89 break; 90 default: 91 break; 92 } 93 return JavaRuntime.newDefaultProjectClasspathEntry(null); 43 // FIXME: Project must be JavaProject 44 String projectName = configuration.getAttribute(IRfpLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); 45 if (projectName.length() > 0) 46 entries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(ResourcesPlugin.getWorkspace().getRoot() 47 .getProject(projectName).getFullPath())); 94 48 } 95 49 … … 100 54 if (useDefault) { 101 55 List<IRuntimeClasspathEntry> list = new ArrayList<IRuntimeClasspathEntry>(Arrays.asList(entries)); 102 list.addAll(defaultUserClassPath(configuration));56 addDefaultUserPath(list, configuration); 103 57 return list.toArray(new IRuntimeClasspathEntry[list.size()]); 104 58 }
Note: See TracChangeset
for help on using the changeset viewer.