Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2010-05-29 10:11:41 +0000
committerStephan Herrmann2010-05-29 10:11:41 +0000
commit60b3e932d996fc068e852360525558dd103af894 (patch)
treef9459b66b9ed2da4b2c69c606b35a1948d4ef6c6 /org.eclipse.jdt.core.tests.model
parenta452036be8ceff6a03c2fa480275ae23230c8c8a (diff)
downloadorg.eclipse.objectteams-60b3e932d996fc068e852360525558dd103af894.tar.gz
org.eclipse.objectteams-60b3e932d996fc068e852360525558dd103af894.tar.xz
org.eclipse.objectteams-60b3e932d996fc068e852360525558dd103af894.zip
add new test resources from jdt tests (v_A54)
Diffstat (limited to 'org.eclipse.jdt.core.tests.model')
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test026b/A_in.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test026b/A_out.java17
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test167b/A_in.java14
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test167b/A_out.java11
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test169b/A_in.java7
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test169b/A_out.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test170b/A_in.java7
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test170b/A_out.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test337b/A_in.java339
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test337b/A_out.java346
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test455b/A_in.java49
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test455b/A_out.java49
12 files changed, 863 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test026b/A_in.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test026b/A_in.java
new file mode 100644
index 000000000..82463eedb
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test026b/A_in.java
@@ -0,0 +1,8 @@
+// test026
+public class A {
+ public void foo() {
+ this.longReceiver.someQuiteLongMessageSend("aaaaaaaaaaa","bbbbbbbbbbbbb","cccccccc");
+ this.extremlylongReceiverWillCauseTwoSplitActions.someQuiteLongMessageSend("aaaaaaaaaaa","bbbbbbbbbbbbb","cccccccc");
+ Alignment expressionsAlignment = this.scribe.createAlignment("expressions", Alignment.M_COMPACT_SPLIT + someMessageSend(Alignment.M_COMPACT_SPLIT, Alignment.M_COMPACT_SPLIT, Alignment.M_COMPACT_SPLIT, Alignment.M_COMPACT_SPLIT),expressionsLength - 1, this.scribe.scanner.currentPosition);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test026b/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test026b/A_out.java
new file mode 100644
index 000000000..fb27b0444
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test026b/A_out.java
@@ -0,0 +1,17 @@
+// test026
+public class A {
+ public void foo() {
+ this.longReceiver.someQuiteLongMessageSend("aaaaaaaaaaa",
+ "bbbbbbbbbbbbb", "cccccccc");
+ this.extremlylongReceiverWillCauseTwoSplitActions
+ .someQuiteLongMessageSend("aaaaaaaaaaa", "bbbbbbbbbbbbb",
+ "cccccccc");
+ Alignment expressionsAlignment = this.scribe.createAlignment(
+ "expressions", Alignment.M_COMPACT_SPLIT
+ + someMessageSend(Alignment.M_COMPACT_SPLIT,
+ Alignment.M_COMPACT_SPLIT,
+ Alignment.M_COMPACT_SPLIT,
+ Alignment.M_COMPACT_SPLIT),
+ expressionsLength - 1, this.scribe.scanner.currentPosition);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test167b/A_in.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test167b/A_in.java
new file mode 100644
index 000000000..d6362ce7b
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test167b/A_in.java
@@ -0,0 +1,14 @@
+public class X {
+ X(String s) {
+ }
+ protected void foo() {
+ X a = new X(new StringBuffer("this").append("is").append
+("a").append(
+ "long")
+ .append("argument")
+ .toString()) {
+ public void run() {
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test167b/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test167b/A_out.java
new file mode 100644
index 000000000..bfb3fb84a
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test167b/A_out.java
@@ -0,0 +1,11 @@
+public class X {
+ X(String s) {
+ }
+ protected void foo() {
+ X a = new X(new StringBuffer("this").append("is").append("a").append(
+ "long").append("argument").toString()) {
+ public void run() {
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169b/A_in.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169b/A_in.java
new file mode 100644
index 000000000..2a5f1fa03
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169b/A_in.java
@@ -0,0 +1,7 @@
+public class X {
+ X(String s) {
+ }
+ protected void foo() {
+ cmd.createArgument().foo().test().error().setFile(destDir.getAbsoluteFile());
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169b/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169b/A_out.java
new file mode 100644
index 000000000..684f8a4bb
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169b/A_out.java
@@ -0,0 +1,8 @@
+public class X {
+ X(String s) {
+ }
+ protected void foo() {
+ cmd.createArgument().foo().test().error().setFile(
+ destDir.getAbsoluteFile());
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test170b/A_in.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test170b/A_in.java
new file mode 100644
index 000000000..8a293eafa
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test170b/A_in.java
@@ -0,0 +1,7 @@
+public class X {
+ X(String s) {
+ }
+ protected void foo() {
+ cmd.createArgument().foo().test().error().setFile((Name) (destDir()).getAbsoluteFile());
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test170b/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test170b/A_out.java
new file mode 100644
index 000000000..c5572f035
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test170b/A_out.java
@@ -0,0 +1,8 @@
+public class X {
+ X(String s) {
+ }
+ protected void foo() {
+ cmd.createArgument().foo().test().error().setFile(
+ (Name) (destDir()).getAbsoluteFile());
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test337b/A_in.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test337b/A_in.java
new file mode 100644
index 000000000..55dbb3efd
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test337b/A_in.java
@@ -0,0 +1,339 @@
+package org.eclipse.update.configurator;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.osgi.service.environment.DebugOptions;
+import org.eclipse.osgi.service.environment.EnvironmentInfo;
+import org.osgi.framework.*;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.startlevel.StartLevel;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class ConfigurationActivator implements BundleActivator {
+ private final static String DEFAULT_CONVERTER = "org.eclipse.update.configurator.migration.PluginConverter"; //$NON-NLS-1$
+
+ public static String PI_CONFIGURATOR = "org.eclipse.update.configurator";
+ // debug options
+ public static String OPTION_DEBUG = PI_CONFIGURATOR + "/debug";
+ public static String OPTION_DEBUG_CONVERTER = PI_CONFIGURATOR + "/converter/debug";
+ // debug values
+ public static boolean DEBUG = false;
+ public static boolean DEBUG_CONVERTER = false;
+
+ private static BundleContext context;
+ private ServiceTracker platformTracker;
+ private ServiceRegistration configurationFactorySR;
+ private String[] allArgs;
+
+ // location used to put the generated manfests
+ private String cacheLocation = (String) System.getProperties().get("osgi.manifest.cache"); //PASCAL Need to set this value somewhere (probably from boot)
+ private IPluginConverter converter;
+ private Set ignore;
+ private BundleListener reconcilerListener;
+
+ public void start(BundleContext ctx) throws Exception {
+ context = ctx;loadOptions();if (DEBUG)
+ System.out.println("Starting update configurator...");
+ computeIgnoredBundles();
+ loadConverter();
+ obtainArgs();
+ installBundles();
+ }
+ private void computeIgnoredBundles() {
+ String ignoreList = System.getProperty("eclipse.ignore","org.eclipse.osgi,org.eclipse.core.boot,org.eclipse.core.runtime.adaptor");
+ ignore = new HashSet();
+ StringTokenizer tokenizer = new StringTokenizer(ignoreList,",");
+ while(tokenizer.hasMoreTokens())
+ ignore.add(tokenizer.nextToken().trim());
+ }
+ private boolean shouldIgnore(String bundleName) {
+ if (ignore == null)
+ return false;
+ StringTokenizer tokenizer = new StringTokenizer(bundleName,"._");
+ String partialName = "";
+ while(tokenizer.hasMoreTokens()) {
+ partialName += tokenizer.nextToken();
+ if (ignore.contains(partialName))
+ return true;
+ partialName += ".";
+ }
+ return false;
+ }
+ private void loadConverter() {
+ // TODO look at making this an extension
+ String converterClassName = System.getProperty("eclipse.manifestconverter", DEFAULT_CONVERTER);
+ if (converterClassName == null)
+ return;
+ Class converterClass;
+ try {
+ converterClass = Class.forName(converterClassName);
+ } catch (ClassNotFoundException e) {
+ return;
+ }
+ try {
+ converter = (IPluginConverter) converterClass.newInstance();
+ } catch (InstantiationException e1) {
+ return;
+ } catch (IllegalAccessException e1) {
+ return;
+ } catch (ClassCastException cce) {
+ return;
+ }
+ }
+ private void obtainArgs() {
+ // all this is only to get the application args
+ EnvironmentInfo envInfo = null;
+ ServiceReference envInfoSR = context.getServiceReference(EnvironmentInfo.class.getName());
+ if (envInfoSR != null)
+ envInfo = (EnvironmentInfo) context.getService(envInfoSR);
+ if (envInfo == null)
+ throw new IllegalStateException();
+ this.allArgs = envInfo.getAllArgs();
+ // we have what we want - release the service
+ context.ungetService(envInfoSR);
+ }
+
+ public void stop(BundleContext ctx) throws Exception {
+ releasePlatform();
+ configurationFactorySR.unregister();
+ }
+
+ private void releasePlatform() {
+ if (platformTracker == null)
+ return;
+ platformTracker.close();
+ platformTracker = null;
+ }
+ private IPlatform acquirePlatform() {
+ if (platformTracker == null) {
+ platformTracker = new ServiceTracker(context, IPlatform.class.getName(), null);
+ platformTracker.open();
+ }
+ IPlatform result = (IPlatform) platformTracker.getService();
+ while (result == null) {
+ try {
+ platformTracker.waitForService(1000);
+ result = (IPlatform) platformTracker.getService();
+ } catch (InterruptedException ie) {
+ }
+ }
+ return result;
+ }
+
+ private void installBundles() {
+ IPlatform platform = acquirePlatform();
+
+ String metaPath = platform.getLocation().append(".metadata").toOSString();
+ URL installURL = platform.getInstallURL();
+ ServiceReference reference = context.getServiceReference(StartLevel.class.getName());
+ StartLevel start = null;
+ if (reference != null)
+ start = (StartLevel) context.getService(reference);
+ try {
+ configurationFactorySR = context.registerService(IPlatformConfigurationFactory.class.getName(), new PlatformConfigurationFactory(), null);
+ PlatformConfiguration config = getPlatformConfiguration(allArgs, metaPath, installURL);
+ URL[] plugins = config.getPluginPath();
+ ArrayList installed = new ArrayList(plugins.length);
+ for (int i = 0; i < plugins.length; i++) {
+ try {
+ String location = plugins[i].toExternalForm();
+ checkOrGenerateManifest(location);
+ location = "reference:" + location.substring(0, location.lastIndexOf('/'));
+ if (!isInstalled(location)) {
+ try {
+ Bundle target = context.installBundle(location);
+ installed.add(target);
+ if (start != null)
+ start.setBundleStartLevel(target, 4);
+ } catch (Exception e) {
+ System.err.println("Ignoring bundle at: " + location);
+ System.err.println(e.getMessage());
+ }
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ context.ungetService(reference);
+ refreshPackages((Bundle[]) installed.toArray(new Bundle[installed.size()]));
+ if (System.getProperty("eclipse.application") == null || System.getProperty("eclipse.application").equals(PlatformConfiguration.RECONCILER_APP))
+ System.setProperty("eclipse.application", config.getApplicationIdentifier());
+// if (config.getApplicationIdentifier().equals(PlatformConfiguration.RECONCILER_APP) ) {
+// reconcilerListener = reconcilerListener();
+// context.addBundleListener(reconcilerListener);
+// }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ releasePlatform();
+ }
+ }
+
+ private BundleListener reconcilerListener() {
+ return new BundleListener() {
+ public void bundleChanged(BundleEvent event) {
+ String buid = event.getBundle().getUniqueId();
+ if (event.getType() == BundleEvent.STOPPED && buid!=null && buid.equals("org.eclipse.update.core"))
+ runPostReconciler();
+ }
+ };
+ }
+
+ private void runPostReconciler() {
+ Runnable postReconciler = new Runnable() {
+ public void run() {
+ try {
+ Bundle apprunner = context.getBundle("org.eclipse.core.applicationrunner");
+ apprunner.stop();
+ context.removeBundleListener(reconcilerListener);
+ try {
+ PlatformConfiguration.shutdown();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ installBundles();
+ apprunner.start();
+ } catch (BundleException be) {
+ be.printStackTrace();
+ }
+ }
+ };
+ new Thread(postReconciler, "Post reconciler").start();
+ }
+ /**
+ * @param location
+ */
+ private void checkOrGenerateManifest(String pluginManifestLocationURL) {
+ if (converter == null)
+ return;
+ String pluginManifestLocation = null;
+ try {
+ pluginManifestLocation = new URL(pluginManifestLocationURL).getPath();
+ } catch (MalformedURLException e) {
+ return;
+ }
+ File pluginDir = new File(pluginManifestLocation).getParentFile();
+ if (shouldIgnore(pluginDir.getName()))
+ return;
+ File manifest = new File(pluginDir, "META-INF/MANIFEST.MF");
+ if (manifest.exists())
+ return;
+ // bail if the install location is not writable and we don't know where else to write to
+ if (cacheLocation == null)
+ return;
+ File generationLocation = new File(cacheLocation, computeFileName(pluginDir.getPath()) + ".MF");
+ if (generationLocation.exists())
+ return;
+ if (!converter.convertManifest(pluginDir, generationLocation))
+ System.out.println(pluginDir + " manifest generation failed");
+ }
+ /*
+ * Derives a file name corresponding to a path:
+ * c:\autoexec.bat -> c__autoexec.bat
+ */
+ private String computeFileName(String filePath) {
+ StringBuffer newName = new StringBuffer(filePath);
+ for (int i = 0; i < filePath.length(); i++) {
+ char c = newName.charAt(i);
+ if (c == ':' || c == '/' || c == '\\')
+ newName.setCharAt(i,'_');
+ }
+ return newName.toString();
+ }
+ /**
+ * This is a major hack to try to get the reconciler application running. However we should find a way to not run it.
+ * @param args
+ * @param metaPath
+ * @return
+ */
+ private PlatformConfiguration getPlatformConfiguration(String[] args, String metaPath, URL installURL) {
+ try {
+ PlatformConfiguration.startup(args, null, null, metaPath, installURL);
+ } catch (Exception e) {
+ if (platformTracker != null) {
+ String message = e.getMessage();
+ if (message == null)
+ message = "";
+ IStatus status = new Status(IStatus.ERROR,IPlatform.PI_RUNTIME,IStatus.OK,message,e);
+ ((IPlatform)platformTracker.getService()).getLog(context.getBundle()).log(status);
+ }
+ }
+ return PlatformConfiguration.getCurrent();
+
+ }
+
+ /**
+ * Do PackageAdmin.refreshPackages() in a synchronous way. After installing
+ * all the requested bundles we need to do a refresh and want to ensure that
+ * everything is done before returning.
+ * @param bundles
+ */
+ private void refreshPackages(Bundle[] bundles) {
+ if (bundles.length == 0)
+ return;
+ ServiceReference packageAdminRef = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packageAdmin = null;
+ if (packageAdminRef != null) {
+ packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
+ if (packageAdmin == null)
+ return;
+ }
+ // TODO this is such a hack it is silly. There are still cases for race conditions etc
+ // but this should allow for some progress...
+ final Object semaphore = new Object();
+ FrameworkListener listener = new FrameworkListener() {
+ public void frameworkEvent(FrameworkEvent event) {
+ if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED)
+ synchronized (semaphore) {
+ semaphore.notifyAll();
+ }
+ }
+ };
+ context.addFrameworkListener(listener);
+ packageAdmin.refreshPackages(bundles);
+ synchronized (semaphore) {
+ try {
+ semaphore.wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ context.removeFrameworkListener(listener);
+ context.ungetService(packageAdminRef);
+ }
+
+ private boolean isInstalled(String location) {
+ Bundle[] installed = context.getBundles();
+ for (int i = 0; i < installed.length; i++) {
+ Bundle bundle = installed[i];
+ if (location.equalsIgnoreCase(bundle.getLocation()))
+ return true;
+ }
+ return false;
+ }
+
+ private void loadOptions() {
+ // all this is only to get the application args
+ DebugOptions service = null;ServiceReference reference = context.getServiceReference(DebugOptions.class.getName());
+ if (reference != null)
+ service = (DebugOptions) context.getService(reference);
+ if (service == null)
+ return;
+ try {
+ DEBUG = service.getBooleanOption(OPTION_DEBUG, false);
+ if (!DEBUG)
+ return;
+ DEBUG_CONVERTER = service.getBooleanOption(OPTION_DEBUG_CONVERTER, false);
+ } finally {
+ // we have what we want - release the service
+ context.ungetService(reference);
+ }
+ }
+ public static BundleContext getBundleContext() {return context;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test337b/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test337b/A_out.java
new file mode 100644
index 000000000..9b81e7714
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test337b/A_out.java
@@ -0,0 +1,346 @@
+package org.eclipse.update.configurator;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.osgi.service.environment.DebugOptions;
+import org.eclipse.osgi.service.environment.EnvironmentInfo;
+import org.osgi.framework.*;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.startlevel.StartLevel;
+import org.osgi.util.tracker.ServiceTracker;
+public class ConfigurationActivator implements BundleActivator {
+ private final static String DEFAULT_CONVERTER = "org.eclipse.update.configurator.migration.PluginConverter"; //$NON-NLS-1$
+ public static String PI_CONFIGURATOR = "org.eclipse.update.configurator";
+ // debug options
+ public static String OPTION_DEBUG = PI_CONFIGURATOR + "/debug";
+ public static String OPTION_DEBUG_CONVERTER = PI_CONFIGURATOR
+ + "/converter/debug";
+ // debug values
+ public static boolean DEBUG = false;
+ public static boolean DEBUG_CONVERTER = false;
+ private static BundleContext context;
+ private ServiceTracker platformTracker;
+ private ServiceRegistration configurationFactorySR;
+ private String[] allArgs;
+ // location used to put the generated manfests
+ private String cacheLocation = (String) System.getProperties().get(
+ "osgi.manifest.cache"); //PASCAL Need to set this value somewhere (probably from boot)
+ private IPluginConverter converter;
+ private Set ignore;
+ private BundleListener reconcilerListener;
+ public void start(BundleContext ctx) throws Exception {
+ context = ctx;
+ loadOptions();
+ if (DEBUG)
+ System.out.println("Starting update configurator...");
+ computeIgnoredBundles();
+ loadConverter();
+ obtainArgs();
+ installBundles();
+ }
+ private void computeIgnoredBundles() {
+ String ignoreList = System
+ .getProperty("eclipse.ignore",
+ "org.eclipse.osgi,org.eclipse.core.boot,org.eclipse.core.runtime.adaptor");
+ ignore = new HashSet();
+ StringTokenizer tokenizer = new StringTokenizer(ignoreList, ",");
+ while (tokenizer.hasMoreTokens())
+ ignore.add(tokenizer.nextToken().trim());
+ }
+ private boolean shouldIgnore(String bundleName) {
+ if (ignore == null)
+ return false;
+ StringTokenizer tokenizer = new StringTokenizer(bundleName, "._");
+ String partialName = "";
+ while (tokenizer.hasMoreTokens()) {
+ partialName += tokenizer.nextToken();
+ if (ignore.contains(partialName))
+ return true;
+ partialName += ".";
+ }
+ return false;
+ }
+ private void loadConverter() {
+ // TODO look at making this an extension
+ String converterClassName = System.getProperty(
+ "eclipse.manifestconverter", DEFAULT_CONVERTER);
+ if (converterClassName == null)
+ return;
+ Class converterClass;
+ try {
+ converterClass = Class.forName(converterClassName);
+ } catch (ClassNotFoundException e) {
+ return;
+ }
+ try {
+ converter = (IPluginConverter) converterClass.newInstance();
+ } catch (InstantiationException e1) {
+ return;
+ } catch (IllegalAccessException e1) {
+ return;
+ } catch (ClassCastException cce) {
+ return;
+ }
+ }
+ private void obtainArgs() {
+ // all this is only to get the application args
+ EnvironmentInfo envInfo = null;
+ ServiceReference envInfoSR = context
+ .getServiceReference(EnvironmentInfo.class.getName());
+ if (envInfoSR != null)
+ envInfo = (EnvironmentInfo) context.getService(envInfoSR);
+ if (envInfo == null)
+ throw new IllegalStateException();
+ this.allArgs = envInfo.getAllArgs();
+ // we have what we want - release the service
+ context.ungetService(envInfoSR);
+ }
+ public void stop(BundleContext ctx) throws Exception {
+ releasePlatform();
+ configurationFactorySR.unregister();
+ }
+ private void releasePlatform() {
+ if (platformTracker == null)
+ return;
+ platformTracker.close();
+ platformTracker = null;
+ }
+ private IPlatform acquirePlatform() {
+ if (platformTracker == null) {
+ platformTracker = new ServiceTracker(context, IPlatform.class
+ .getName(), null);
+ platformTracker.open();
+ }
+ IPlatform result = (IPlatform) platformTracker.getService();
+ while (result == null) {
+ try {
+ platformTracker.waitForService(1000);
+ result = (IPlatform) platformTracker.getService();
+ } catch (InterruptedException ie) {
+ }
+ }
+ return result;
+ }
+ private void installBundles() {
+ IPlatform platform = acquirePlatform();
+
+ String metaPath = platform.getLocation().append(".metadata").toOSString();
+ URL installURL = platform.getInstallURL();
+ ServiceReference reference = context.getServiceReference(StartLevel.class.getName());
+ StartLevel start = null;
+ if (reference != null)
+ start = (StartLevel) context.getService(reference);
+ try {
+ configurationFactorySR = context.registerService(IPlatformConfigurationFactory.class.getName(), new PlatformConfigurationFactory(), null);
+ PlatformConfiguration config = getPlatformConfiguration(allArgs, metaPath, installURL);
+ URL[] plugins = config.getPluginPath();
+ ArrayList installed = new ArrayList(plugins.length);
+ for (int i = 0; i < plugins.length; i++) {
+ try {
+ String location = plugins[i].toExternalForm();
+ checkOrGenerateManifest(location);
+ location = "reference:" + location.substring(0, location.lastIndexOf('/'));
+ if (!isInstalled(location)) {
+ try {
+ Bundle target = context.installBundle(location);
+ installed.add(target);
+ if (start != null)
+ start.setBundleStartLevel(target, 4);
+ } catch (Exception e) {
+ System.err.println("Ignoring bundle at: " + location);
+ System.err.println(e.getMessage());
+ }
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ context.ungetService(reference);
+ refreshPackages((Bundle[]) installed.toArray(new Bundle[installed.size()]));
+ if (System.getProperty("eclipse.application") == null || System.getProperty("eclipse.application").equals(PlatformConfiguration.RECONCILER_APP))
+ System.setProperty("eclipse.application", config.getApplicationIdentifier());
+// if (config.getApplicationIdentifier().equals(PlatformConfiguration.RECONCILER_APP) ) {
+// reconcilerListener = reconcilerListener();
+// context.addBundleListener(reconcilerListener);
+// }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ releasePlatform();
+ }
+ }
+ private BundleListener reconcilerListener() {
+ return new BundleListener() {
+ public void bundleChanged(BundleEvent event) {
+ String buid = event.getBundle().getUniqueId();
+ if (event.getType() == BundleEvent.STOPPED && buid != null
+ && buid.equals("org.eclipse.update.core"))
+ runPostReconciler();
+ }
+ };
+ }
+ private void runPostReconciler() {
+ Runnable postReconciler = new Runnable() {
+ public void run() {
+ try {
+ Bundle apprunner = context
+ .getBundle("org.eclipse.core.applicationrunner");
+ apprunner.stop();
+ context.removeBundleListener(reconcilerListener);
+ try {
+ PlatformConfiguration.shutdown();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ installBundles();
+ apprunner.start();
+ } catch (BundleException be) {
+ be.printStackTrace();
+ }
+ }
+ };
+ new Thread(postReconciler, "Post reconciler").start();
+ }
+ /**
+ * @param location
+ */
+ private void checkOrGenerateManifest(String pluginManifestLocationURL) {
+ if (converter == null)
+ return;
+ String pluginManifestLocation = null;
+ try {
+ pluginManifestLocation = new URL(pluginManifestLocationURL)
+ .getPath();
+ } catch (MalformedURLException e) {
+ return;
+ }
+ File pluginDir = new File(pluginManifestLocation).getParentFile();
+ if (shouldIgnore(pluginDir.getName()))
+ return;
+ File manifest = new File(pluginDir, "META-INF/MANIFEST.MF");
+ if (manifest.exists())
+ return;
+ // bail if the install location is not writable and we don't know where else to write to
+ if (cacheLocation == null)
+ return;
+ File generationLocation = new File(cacheLocation,
+ computeFileName(pluginDir.getPath()) + ".MF");
+ if (generationLocation.exists())
+ return;
+ if (!converter.convertManifest(pluginDir, generationLocation))
+ System.out.println(pluginDir + " manifest generation failed");
+ }
+ /*
+ * Derives a file name corresponding to a path:
+ * c:\autoexec.bat -> c__autoexec.bat
+ */
+ private String computeFileName(String filePath) {
+ StringBuffer newName = new StringBuffer(filePath);
+ for (int i = 0; i < filePath.length(); i++) {
+ char c = newName.charAt(i);
+ if (c == ':' || c == '/' || c == '\\')
+ newName.setCharAt(i, '_');
+ }
+ return newName.toString();
+ }
+ /**
+ * This is a major hack to try to get the reconciler application running. However we should find a way to not run it.
+ * @param args
+ * @param metaPath
+ * @return
+ */
+ private PlatformConfiguration getPlatformConfiguration(String[] args,
+ String metaPath, URL installURL) {
+ try {
+ PlatformConfiguration.startup(args, null, null, metaPath,
+ installURL);
+ } catch (Exception e) {
+ if (platformTracker != null) {
+ String message = e.getMessage();
+ if (message == null)
+ message = "";
+ IStatus status = new Status(IStatus.ERROR,
+ IPlatform.PI_RUNTIME, IStatus.OK, message, e);
+ ((IPlatform) platformTracker.getService()).getLog(
+ context.getBundle()).log(status);
+ }
+ }
+ return PlatformConfiguration.getCurrent();
+ }
+ /**
+ * Do PackageAdmin.refreshPackages() in a synchronous way. After installing
+ * all the requested bundles we need to do a refresh and want to ensure that
+ * everything is done before returning.
+ * @param bundles
+ */
+ private void refreshPackages(Bundle[] bundles) {
+ if (bundles.length == 0)
+ return;
+ ServiceReference packageAdminRef = context
+ .getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packageAdmin = null;
+ if (packageAdminRef != null) {
+ packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
+ if (packageAdmin == null)
+ return;
+ }
+ // TODO this is such a hack it is silly. There are still cases for race conditions etc
+ // but this should allow for some progress...
+ final Object semaphore = new Object();
+ FrameworkListener listener = new FrameworkListener() {
+ public void frameworkEvent(FrameworkEvent event) {
+ if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED)
+ synchronized (semaphore) {
+ semaphore.notifyAll();
+ }
+ }
+ };
+ context.addFrameworkListener(listener);
+ packageAdmin.refreshPackages(bundles);
+ synchronized (semaphore) {
+ try {
+ semaphore.wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ context.removeFrameworkListener(listener);
+ context.ungetService(packageAdminRef);
+ }
+ private boolean isInstalled(String location) {
+ Bundle[] installed = context.getBundles();
+ for (int i = 0; i < installed.length; i++) {
+ Bundle bundle = installed[i];
+ if (location.equalsIgnoreCase(bundle.getLocation()))
+ return true;
+ }
+ return false;
+ }
+ private void loadOptions() {
+ // all this is only to get the application args
+ DebugOptions service = null;
+ ServiceReference reference = context
+ .getServiceReference(DebugOptions.class.getName());
+ if (reference != null)
+ service = (DebugOptions) context.getService(reference);
+ if (service == null)
+ return;
+ try {
+ DEBUG = service.getBooleanOption(OPTION_DEBUG, false);
+ if (!DEBUG)
+ return;
+ DEBUG_CONVERTER = service.getBooleanOption(OPTION_DEBUG_CONVERTER,
+ false);
+ } finally {
+ // we have what we want - release the service
+ context.ungetService(reference);
+ }
+ }
+ public static BundleContext getBundleContext() {
+ return context;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test455b/A_in.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test455b/A_in.java
new file mode 100644
index 000000000..8f663adf2
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test455b/A_in.java
@@ -0,0 +1,49 @@
+public class A {
+ public void launch(
+ ILaunchConfiguration configuration,
+ String mode,
+ ILaunch launch,
+ IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ IJavaProject javaProject = getJavaProject(configuration);
+ if ((javaProject == null) || !javaProject.exists()) {
+ abort(PDEPlugin.getResourceString("JUnitLaunchConfiguration.error.invalidproject"), null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT); //$NON-NLS-1$
+ }
+ IType[] testTypes = getTestTypes(configuration, javaProject, new SubProgressMonitor(monitor, 1));
+ if (testTypes.length == 0) {
+ abort(PDEPlugin.getResourceString("JUnitLaunchConfiguration.error.notests"), null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE); //$NON-NLS-1$
+ }
+ monitor.worked(1);
+
+ IVMInstall launcher = LauncherUtils.createLauncher(configuration);
+ monitor.worked(1);
+
+ int port = SocketUtil.findFreePort();
+ VMRunnerConfiguration runnerConfig =
+ createVMRunner(configuration, testTypes, port, mode);
+ if (runnerConfig == null) {
+ monitor.setCanceled(true);
+ return;
+ }
+ monitor.worked(1);
+
+ launch.setAttribute(
+ ILauncherSettings.CONFIG_LOCATION,
+ (configFile == null) ? null : configFile.getParent());
+
+ String workspace = configuration.getAttribute(LOCATION + "0", getDefaultWorkspace(configuration));
+ LauncherUtils.clearWorkspace(configuration,workspace);
+
+ setDefaultSourceLocator(launch, configuration);
+ launch.setAttribute(PORT_ATTR, Integer.toString(port));
+ launch.setAttribute(TESTTYPE_ATTR, testTypes[0].getHandleIdentifier());
+ PDEPlugin.getDefault().getLaunchesListener().manage(launch);
+ launcher.getVMRunner(mode).run(runnerConfig, launch, monitor);
+ monitor.worked(1);
+ } catch (CoreException e) {
+ monitor.setCanceled(true);
+ throw e;
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test455b/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test455b/A_out.java
new file mode 100644
index 000000000..d28eb6c3b
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test455b/A_out.java
@@ -0,0 +1,49 @@
+public class A {
+ public void launch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ try {
+ IJavaProject javaProject = getJavaProject(configuration);
+ if ((javaProject == null) || !javaProject.exists()) {
+ abort(PDEPlugin
+ .getResourceString("JUnitLaunchConfiguration.error.invalidproject"), null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT); //$NON-NLS-1$
+ }
+ IType[] testTypes = getTestTypes(configuration, javaProject,
+ new SubProgressMonitor(monitor, 1));
+ if (testTypes.length == 0) {
+ abort(PDEPlugin
+ .getResourceString("JUnitLaunchConfiguration.error.notests"), null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE); //$NON-NLS-1$
+ }
+ monitor.worked(1);
+
+ IVMInstall launcher = LauncherUtils.createLauncher(configuration);
+ monitor.worked(1);
+
+ int port = SocketUtil.findFreePort();
+ VMRunnerConfiguration runnerConfig = createVMRunner(configuration,
+ testTypes, port, mode);
+ if (runnerConfig == null) {
+ monitor.setCanceled(true);
+ return;
+ }
+ monitor.worked(1);
+
+ launch.setAttribute(ILauncherSettings.CONFIG_LOCATION,
+ (configFile == null) ? null : configFile.getParent());
+
+ String workspace = configuration.getAttribute(LOCATION + "0",
+ getDefaultWorkspace(configuration));
+ LauncherUtils.clearWorkspace(configuration, workspace);
+
+ setDefaultSourceLocator(launch, configuration);
+ launch.setAttribute(PORT_ATTR, Integer.toString(port));
+ launch.setAttribute(TESTTYPE_ATTR, testTypes[0]
+ .getHandleIdentifier());
+ PDEPlugin.getDefault().getLaunchesListener().manage(launch);
+ launcher.getVMRunner(mode).run(runnerConfig, launch, monitor);
+ monitor.worked(1);
+ } catch (CoreException e) {
+ monitor.setCanceled(true);
+ throw e;
+ }
+ }
+} \ No newline at end of file

Back to the top