Changeset 3466


Ignore:
Timestamp:
Mar 7, 2008, 1:49:44 PM (13 years ago)
Author:
yura
Message:
  • Simlification.
  • Refal plus runtime classes are added to bootstrap.
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  
    22
    33import java.io.IOException;
    4 import java.net.URL;
    54import java.util.ArrayList;
    65import java.util.Arrays;
     
    109import org.eclipse.core.runtime.CoreException;
    1110import org.eclipse.core.runtime.FileLocator;
    12 import org.eclipse.core.runtime.IPath;
    1311import org.eclipse.core.runtime.Path;
    1412import org.eclipse.core.runtime.Platform;
    1513import 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;
    1914import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
    2015import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
     
    2520
    2621public 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 {
    4030        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()));
    4939            }
    5040        } catch (IOException e) {
    5141            RfpCorePlugin.log(e);
    5242        }
    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()));
    9448    }
    9549
     
    10054        if (useDefault) {
    10155            List<IRuntimeClasspathEntry> list = new ArrayList<IRuntimeClasspathEntry>(Arrays.asList(entries));
    102             list.addAll(defaultUserClassPath(configuration));
     56            addDefaultUserPath(list, configuration);
    10357            return list.toArray(new IRuntimeClasspathEntry[list.size()]);
    10458        }
Note: See TracChangeset for help on using the changeset viewer.