Skip to content

Commit 6cd6874

Browse files
committed
Issue #200: Add more comments to the code
1 parent d5b27f7 commit 6cd6874

36 files changed

+150
-11
lines changed

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/MicroclimateCorePlugin.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public class MicroclimateCorePlugin extends AbstractUIPlugin {
3131
public static final String DEFAULT_ICON_PATH = "icons/microclimate.ico"; //$NON-NLS-1$
3232

3333
public static final String
34-
// Boolean option for hiding the on-finish dialog for the Link Project wizard
35-
HIDE_ONFINISH_MSG_PREFSKEY = "showLinkWizardOnFinishDialog", //$NON-NLS-1$
3634
// Int option for debug timeout in seconds
3735
DEBUG_CONNECT_TIMEOUT_PREFSKEY = "serverDebugTimeout"; //$NON-NLS-1$
3836

@@ -60,7 +58,6 @@ public void start(BundleContext context) throws Exception {
6058
context.registerService(DebugOptionsListener.class, MCLogger.instance(), null);
6159

6260
// Set default preferences once, here
63-
getPreferenceStore().setDefault(HIDE_ONFINISH_MSG_PREFSKEY, false);
6461
getPreferenceStore().setDefault(DEBUG_CONNECT_TIMEOUT_PREFSKEY,
6562
MCEclipseApplication.DEFAULT_DEBUG_CONNECT_TIMEOUT);
6663
}

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/MCEclipseApplication.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
import com.ibm.microclimate.core.internal.launch.MicroclimateLaunchConfigDelegate;
4646
import com.ibm.microclimate.core.internal.messages.Messages;
4747

48+
/**
49+
* Eclipse specific code for a Microclimate application. Anything related to Eclipse
50+
* (launches, consoles, connecting the debugger, etc.) should go here and not in the
51+
* MicroclimateApplication class.
52+
*/
4853
public class MCEclipseApplication extends MicroclimateApplication {
4954

5055
// Validation marker
@@ -150,10 +155,13 @@ public void reconnectDebugger() {
150155

151156
@Override
152157
public void dispose() {
158+
// Clean up the launch
153159
if (launch != null) {
154160
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
155161
launchManager.removeLaunch(launch);
156162
}
163+
164+
// Clean up the consoles
157165
List<IConsole> consoles = new ArrayList<IConsole>();
158166
if (appConsole != null) {
159167
consoles.add(appConsole);
@@ -170,6 +178,7 @@ public void dispose() {
170178

171179
@Override
172180
public void resetValidation() {
181+
// Delete all Microclimate markers for a project
173182
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
174183
if (project != null && project.isAccessible()) {
175184
try {
@@ -191,7 +200,8 @@ public void validationWarning(String filePath, String message, String quickFixId
191200
}
192201

193202
private void validationEvent(int severity, String filePath, String message, String quickFixId, String quickFixDescription) {
194-
try {
203+
// Create a marker and quick fix (if available) on the specific file if there is one or the project if not.
204+
try {
195205
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
196206
if (project != null && project.isAccessible()) {
197207
IResource resource = project;

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/MCUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,29 @@ public static int parsePort(String portStr) {
131131
}
132132
}
133133

134+
/**
135+
* Update everything in the Microclimate explorer view
136+
*/
134137
public static void updateAll() {
135138
IUpdateHandler handler = MicroclimateCorePlugin.getUpdateHandler();
136139
if (handler != null) {
137140
handler.updateAll();
138141
}
139142
}
140143

144+
/**
145+
* Update the connection and its children in the Microclimate explorer view
146+
*/
141147
public static void updateConnection(MicroclimateConnection connection) {
142148
IUpdateHandler handler = MicroclimateCorePlugin.getUpdateHandler();
143149
if (handler != null) {
144150
handler.updateConnection(connection);
145151
}
146152
}
147153

154+
/**
155+
* Update the application in the Microclimate explorer view
156+
*/
148157
public static void updateApplication(MicroclimateApplication app) {
149158
IUpdateHandler handler = MicroclimateCorePlugin.getUpdateHandler();
150159
if (handler != null) {

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/MicroclimateApplication.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ public synchronized void invalidatePorts() {
203203
debugPort = -1;
204204
}
205205

206+
/**
207+
* Get the capabilities of a project. Cache them because they should not change
208+
* and since they are used to decide which menu items are shown/enabled this method
209+
* needs to be fast.
210+
*/
206211
public ProjectCapabilities getProjectCapabilities() {
207212
if (projectCapabilities == null) {
208213
try {
@@ -243,6 +248,7 @@ public void validationWarning(String filePath, String message, String quickFixId
243248
}
244249

245250
public boolean supportsDebug() {
251+
// Override as needed
246252
return false;
247253
}
248254

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/MicroclimateObjectFactory.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
import com.ibm.microclimate.core.internal.connection.MicroclimateConnection;
1515
import com.ibm.microclimate.core.internal.constants.ProjectType;
1616

17+
/**
18+
* Factory for creating the correct Microclimate objects. This is used to keep the Eclipse
19+
* code and the Microclimate code separate.
20+
*
21+
* Currently only MicroclimateApplication has an Eclipse version. Rather than let Eclipse
22+
* code leak into MicroclimateConnection an Eclipse version of it should be created if necessary.
23+
*/
1724
public class MicroclimateObjectFactory {
1825

1926
public static MicroclimateConnection createMicroclimateConnection(URI uri) throws Exception {

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/connection/MicroclimateConnectionManager.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
import java.util.Iterator;
1616
import java.util.List;
1717

18-
import org.eclipse.jface.util.IPropertyChangeListener;
19-
import org.eclipse.jface.util.PropertyChangeEvent;
20-
2118
import com.ibm.microclimate.core.MicroclimateCorePlugin;
2219
import com.ibm.microclimate.core.internal.MCLogger;
2320
import com.ibm.microclimate.core.internal.MCUtil;

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/connection/MicroclimateSocket.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,18 @@ private void onValidationEvent(JSONObject event) throws JSONException {
419419
MCLogger.logError("No application found for project: " + projectID);
420420
return;
421421
}
422+
423+
// Clear out any old validation objects
422424
app.resetValidation();
423425

426+
// If the validation is successful then just return
424427
String status = event.getString(MCConstants.KEY_VALIDATION_STATUS);
425428
if (MCConstants.VALUE_STATUS_SUCCESS.equals(status)) {
426429
// Nothing to do
427430
return;
428431
}
429432

433+
// If the validation is not successful, create validation objects for each problem
430434
if (event.has(MCConstants.KEY_VALIDATION_RESULTS)) {
431435
JSONArray results = event.getJSONArray(MCConstants.KEY_VALIDATION_RESULTS);
432436
for (int i = 0; i < results.length(); i++) {
@@ -458,6 +462,7 @@ private void onValidationEvent(JSONObject event) throws JSONException {
458462
}
459463

460464
private boolean supportsQuickFix(MicroclimateApplication app, String type, String filename) {
465+
// The regenerate job only works in certain cases so only show the quickfix in the working cases
461466
if (!MCConstants.VALUE_TYPE_MISSING.equals(type) || app.projectType.isType(ProjectType.TYPE_DOCKER)) {
462467
return false;
463468
}

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/constants/ProjectCapabilities.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import com.ibm.microclimate.core.internal.MCLogger;
2020

21+
/**
22+
* Represents the capabilities of a project.
23+
*/
2124
public class ProjectCapabilities {
2225

2326
public static final ProjectCapabilities emptyCapabilities = new ProjectCapabilities();

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/constants/ProjectType.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
package com.ibm.microclimate.core.internal.constants;
1111

12+
/**
13+
* Type and language of a project.
14+
*/
1215
public class ProjectType {
1316

1417
public static final String UNKNOWN = "unknown";

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/constants/StartMode.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
import com.ibm.microclimate.core.internal.MCLogger;
1717

18+
/**
19+
* Project start modes.
20+
*/
1821
public enum StartMode {
1922

2023
RUN("run"),

0 commit comments

Comments
 (0)