Skip to content

Package: Activator

Activator

nameinstructionbranchcomplexitylinemethod
Activator()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getStatus(Throwable)
M: 29 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
log(IStatus)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
log(String)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
log(Throwable)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
start(BundleContext)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
stop(BundleContext)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2017 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * johannes - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ide.internal.migration;
15:
16: import org.eclipse.core.runtime.CoreException;
17: import org.eclipse.core.runtime.IStatus;
18: import org.eclipse.core.runtime.Plugin;
19: import org.eclipse.core.runtime.Status;
20: import org.osgi.framework.BundleContext;
21:
22: /**
23: * @author johannes
24: *
25: */
26: public class Activator extends Plugin {
27:
28:         /**
29:          * The PlugIn ID.
30:          */
31:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.ide.migration"; //$NON-NLS-1$
32:
33:         private static Activator instance;
34:
35:         // BEGIN SUPRESS CATCH EXCEPTION
36:         @Override
37:         public void start(BundleContext bundleContext) throws Exception {
38:                 super.start(bundleContext);
39:                 instance = this;
40:         }
41:
42:         @Override
43:         public void stop(BundleContext bundleContext) throws Exception {
44:                 instance = null;
45:                 super.stop(bundleContext);
46:         }
47:
48:         /**
49:          * Logs messages.
50:          *
51:          * @param message the message
52:          */
53:         public static void log(String message) {
54:                 instance.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
55:         }
56:
57:         /**
58:          * Logs {@link IStatus}.
59:          *
60:          * @param status the {@link IStatus}
61:          */
62:         public static void log(IStatus status) {
63:                 instance.getLog().log(status);
64:         }
65:
66:         /**
67:          * Logs {@link Throwable}.
68:          *
69:          * @param t the {@link Throwable}
70:          * @return the message of the created status
71:          */
72:         public static String log(Throwable t) {
73:                 final IStatus status = getStatus(t);
74:                 log(status);
75:                 return status.getMessage();
76:         }
77:
78:         /**
79:          * Gets a {@link IStatus} for a throwable.
80:          *
81:          * @param t the {@link Throwable}
82:          * @return the created {@link IStatus}
83:          */
84:         public static IStatus getStatus(Throwable t) {
85:•                if (t instanceof CoreException) {
86:                         final CoreException coreException = (CoreException) t;
87:                         return coreException.getStatus();
88:                 }
89:
90:                 String msg = t.getLocalizedMessage();
91:•                if (msg == null || msg.length() == 0) {
92:                         msg = t.getClass().getName();
93:                 }
94:
95:                 return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
96:         }
97:
98: }