mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 540373: Post code-cleanup for DSF examples
The DSF Examples contains some commented out source that is enabled via a script so this commit cleans that up for new formatting rules. Change-Id: I82c5e195cc3746415c659b2c0fc72b8118cdc56c
This commit is contained in:
parent
37ed2c406d
commit
f869a3f247
10 changed files with 65 additions and 65 deletions
|
@ -87,7 +87,7 @@ org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
|||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
|
|
|
@ -87,7 +87,7 @@ org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
|||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
|
|
|
@ -87,7 +87,7 @@ org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
|||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
|
|
|
@ -87,7 +87,7 @@ org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
|||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
|
|
|
@ -157,9 +157,9 @@ public class PreProcessor extends Task {
|
|||
}
|
||||
String contents = null;
|
||||
if (fileName.endsWith(".java")) {
|
||||
contents = preProcessFile(srcFile, "//#");
|
||||
contents = preProcessFile(srcFile);
|
||||
} else if (fileName.equals("plugin.xml")) {
|
||||
contents = preProcessFile(srcFile, null);
|
||||
contents = preProcessFile(srcFile);
|
||||
}
|
||||
if (contents == null) {
|
||||
// no change, just copy file
|
||||
|
@ -186,10 +186,9 @@ public class PreProcessor extends Task {
|
|||
* Preprocesses a file
|
||||
*
|
||||
* @param srcFile the file to process
|
||||
* @param strip chars to stip off lines in a true condition, or <code>null</code>
|
||||
* @return
|
||||
*/
|
||||
public String preProcessFile(File srcFile, String strip) {
|
||||
public String preProcessFile(File srcFile) {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(srcFile))) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String line = reader.readLine();
|
||||
|
@ -262,10 +261,8 @@ public class PreProcessor extends Task {
|
|||
}
|
||||
if (!commandLine) {
|
||||
if (state == STATE_OUTSIDE_CONDITION || state == STATE_TRUE_CONDITION) {
|
||||
if (state == STATE_TRUE_CONDITION && strip != null) {
|
||||
if (line.startsWith(strip)) {
|
||||
line = line.substring(strip.length());
|
||||
}
|
||||
if (state == STATE_TRUE_CONDITION) {
|
||||
line = line.replaceFirst("^(\t*)//#", "$1");
|
||||
}
|
||||
buffer.append(line);
|
||||
buffer.append("\n");
|
||||
|
@ -288,8 +285,7 @@ public class PreProcessor extends Task {
|
|||
PreProcessor processor = new PreProcessor();
|
||||
processor.setSymbols("ex2");
|
||||
String string = processor.preProcessFile(new File(
|
||||
"c:\\eclipse3.1\\dev\\example.debug.core\\src\\example\\debug\\core\\launcher\\PDALaunchDelegate.java"),
|
||||
"//#");
|
||||
"c:\\eclipse3.1\\dev\\example.debug.core\\src\\example\\debug\\core\\launcher\\PDALaunchDelegate.java"));
|
||||
//String string = processor.preProcessFile(new File("c:\\eclipse3.1\\dev\\example.debug.core\\plugin.xml"), null);
|
||||
System.out.println(string);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotationindicating allowed concurrency access
|
||||
// Hint: Request and its subclasses have all their fields declared as final.
|
||||
//#else
|
||||
//# @Immutable
|
||||
//#@Immutable
|
||||
//#endif
|
||||
abstract class Request {
|
||||
final RequestMonitor fRequestMonitor;
|
||||
|
@ -93,7 +93,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @Immutable
|
||||
//#@Immutable
|
||||
//#endif
|
||||
class CountRequest extends Request {
|
||||
CountRequest(DataRequestMonitor<Integer> rm) {
|
||||
|
@ -105,7 +105,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @Immutable
|
||||
//#@Immutable
|
||||
//#endif
|
||||
class ItemRequest extends Request {
|
||||
final int fIndex;
|
||||
|
@ -134,7 +134,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private List<Request> fQueue = new LinkedList<Request>();
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private List<Listener> fListeners = new LinkedList<Listener>();
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private int fCount = MIN_COUNT;
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private int fCountResetTrigger = 0;
|
||||
|
||||
|
@ -171,7 +171,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private Map<Integer, Integer> fChangedValues = new HashMap<Integer, Integer>();
|
||||
|
||||
|
@ -306,7 +306,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private void serviceQueue() {
|
||||
fExecutor.schedule(new DsfRunnable() {
|
||||
|
@ -321,7 +321,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private void doServiceQueue() {
|
||||
//#ifdef exercises
|
||||
|
@ -331,15 +331,15 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// thread. This method can safely iterate and modify fQueue without
|
||||
// risk of race conditions or concurrent modification exceptions.
|
||||
//#else
|
||||
//# for (Iterator<Request> requestItr = fQueue.iterator(); requestItr.hasNext();) {
|
||||
//# Request request = requestItr.next();
|
||||
//# if (request.fRequestMonitor.isCanceled()) {
|
||||
//# request.fRequestMonitor.setStatus(
|
||||
//# new Status(IStatus.CANCEL, DsfExamplesPlugin.PLUGIN_ID, "Request canceled"));
|
||||
//# request.fRequestMonitor.done();
|
||||
//# requestItr.remove();
|
||||
//# }
|
||||
//# }
|
||||
//#for (Iterator<Request> requestItr = fQueue.iterator(); requestItr.hasNext();) {
|
||||
//# Request request = requestItr.next();
|
||||
//# if (request.fRequestMonitor.isCanceled()) {
|
||||
//# request.fRequestMonitor.setStatus(
|
||||
//# new Status(IStatus.CANCEL, DsfExamplesPlugin.PLUGIN_ID, "Request canceled"));
|
||||
//# request.fRequestMonitor.done();
|
||||
//# requestItr.remove();
|
||||
//# }
|
||||
//#}
|
||||
//#endif
|
||||
|
||||
while (fQueue.size() != 0) {
|
||||
|
@ -359,7 +359,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private void processCountRequest(CountRequest request) {
|
||||
@SuppressWarnings("unchecked") // Suppress warning about lost type info.
|
||||
|
@ -373,7 +373,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private void processItemRequest(ItemRequest request) {
|
||||
@SuppressWarnings("unchecked") // Suppress warning about lost type info.
|
||||
|
@ -394,7 +394,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private void randomChanges() {
|
||||
// Once every number of changes, reset the count, the rest of the
|
||||
|
@ -413,7 +413,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private void randomCountReset() {
|
||||
// Calculate the new count.
|
||||
|
@ -436,7 +436,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
|
|||
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
|
||||
// indicating allowed thread access to this class/method/member
|
||||
//#else
|
||||
//# @ConfinedToDsfExecutor("fExecutor")
|
||||
//#@ConfinedToDsfExecutor("fExecutor")
|
||||
//#endif
|
||||
private void randomDataChange() {
|
||||
// Calculate the indexes to change.
|
||||
|
|
|
@ -144,7 +144,7 @@ public class SyncDataViewer implements IStructuredContentProvider, IDataGenerato
|
|||
//#ifdef exercises
|
||||
// TODO Exercise 5 - Add a call to getElements() to force a deadlock.
|
||||
//#else
|
||||
//# getElements(null);
|
||||
//#getElements(null);
|
||||
//#endif
|
||||
|
||||
// This method may be called on any thread, switch to the display
|
||||
|
@ -182,7 +182,7 @@ public class SyncDataViewer implements IStructuredContentProvider, IDataGenerato
|
|||
// TODO Exercise 5 - Use the DataGeneratorWithExecutor() instead.
|
||||
final IDataGenerator generator = new DataGeneratorWithThread();
|
||||
//#else
|
||||
//# final IDataGenerator generator = new DataGeneratorWithExecutor();
|
||||
//#final IDataGenerator generator = new DataGeneratorWithExecutor();
|
||||
//#endif
|
||||
|
||||
// Create the content provider which will populate the viewer.
|
||||
|
|
|
@ -50,17 +50,17 @@ public class AsyncHelloWorld {
|
|||
// completed.
|
||||
rm.done();
|
||||
//#else
|
||||
//# RequestMonitor rm2 = new RequestMonitor(ImmediateExecutor.getInstance(), rm);
|
||||
//# asyncHelloWorld2(rm2);
|
||||
//#RequestMonitor rm2 = new RequestMonitor(ImmediateExecutor.getInstance(), rm);
|
||||
//#asyncHelloWorld2(rm2);
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#ifdef exercises
|
||||
// TODO: Exercise 1 - Add a second async. "Hello world 2" method.
|
||||
//#else
|
||||
//# static void asyncHelloWorld2(RequestMonitor rm) {
|
||||
//# System.out.println("Hello world 2");
|
||||
//# rm.done();
|
||||
//# }
|
||||
//#static void asyncHelloWorld2(RequestMonitor rm) {
|
||||
//# System.out.println("Hello world 2");
|
||||
//# rm.done();
|
||||
//#}
|
||||
//#endif
|
||||
}
|
||||
|
|
|
@ -64,20 +64,20 @@ public class AsyncQuicksort {
|
|||
asyncQuicksort(array, newPivot + 1, right, countingRm);
|
||||
countingRm.setDoneCount(2);
|
||||
//#else
|
||||
//# asyncPartition(
|
||||
//# array, left, right, pivot,
|
||||
//# new DataRequestMonitor<Integer>(fgExecutor, rm) {
|
||||
//# @Override
|
||||
//# protected void handleCompleted() {
|
||||
//# int newPivot = getData();
|
||||
//# printArray(array, left, right, newPivot);
|
||||
//#asyncPartition(
|
||||
//# array, left, right, pivot,
|
||||
//# new DataRequestMonitor<Integer>(fgExecutor, rm) {
|
||||
//# @Override
|
||||
//# protected void handleCompleted() {
|
||||
//# int newPivot = getData();
|
||||
//# printArray(array, left, right, newPivot);
|
||||
//#
|
||||
//# CountingRequestMonitor countingRm = new CountingRequestMonitor(fgExecutor, rm);
|
||||
//# asyncQuicksort(array, left, newPivot - 1, countingRm);
|
||||
//# asyncQuicksort(array, newPivot + 1, right, countingRm);
|
||||
//# countingRm.setDoneCount(2);
|
||||
//# }
|
||||
//# });
|
||||
//# CountingRequestMonitor countingRm = new CountingRequestMonitor(fgExecutor, rm);
|
||||
//# asyncQuicksort(array, left, newPivot - 1, countingRm);
|
||||
//# asyncQuicksort(array, newPivot + 1, right, countingRm);
|
||||
//# countingRm.setDoneCount(2);
|
||||
//# }
|
||||
//#});
|
||||
//#endif
|
||||
} else {
|
||||
rm.done();
|
||||
|
@ -90,7 +90,7 @@ public class AsyncQuicksort {
|
|||
// return value to the caller.
|
||||
static int partition(int[] array, int left, int right, int pivot)
|
||||
//#else
|
||||
//# static void asyncPartition(int[] array, int left, int right, int pivot, DataRequestMonitor<Integer> rm)
|
||||
//#static void asyncPartition(int[] array, int left, int right, int pivot, DataRequestMonitor<Integer> rm)
|
||||
//#endif
|
||||
{
|
||||
int pivotValue = array[pivot];
|
||||
|
@ -113,10 +113,10 @@ public class AsyncQuicksort {
|
|||
// a request monitor.
|
||||
return store;
|
||||
//#else
|
||||
//# // Java 5 automatically converts the int type of the store variable
|
||||
//# // to an Integer object.
|
||||
//# rm.setData(store);
|
||||
//# rm.done();
|
||||
//#// Java 5 automatically converts the int type of the store variable
|
||||
//#// to an Integer object.
|
||||
//#rm.setData(store);
|
||||
//#rm.done();
|
||||
//#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,11 @@ git ls-files -- \*\*/.project ':!core/org.eclipse.cdt.core/.project' | while re
|
|||
sed -i \
|
||||
'-es@compilers.p.not-externalized-att=1@compilers.p.not-externalized-att=2@' \
|
||||
$d/.settings/org.eclipse.pde.prefs
|
||||
|
||||
fi
|
||||
if echo $i | grep 'org.eclipse.cdt.examples.dsf' > /dev/null; then
|
||||
sed -i \
|
||||
'-es@org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning@org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore@' \
|
||||
$d/.settings/org.eclipse.jdt.core.prefs
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Add table
Reference in a new issue