diff options
author | Paul Pazderski | 2020-01-07 20:18:37 +0000 |
---|---|---|
committer | Paul Pazderski | 2020-01-11 21:58:14 +0000 |
commit | 492af0407faf9dc981b28d99abff4642d126534c (patch) | |
tree | f68db19076a7663b20c096a10e11ff67f1298e33 /org.eclipse.ui.console | |
parent | e0f10fa9497237de090d33902fea61c5f05336c2 (diff) | |
download | eclipse.platform.debug-492af0407faf9dc981b28d99abff4642d126534c.tar.gz eclipse.platform.debug-492af0407faf9dc981b28d99abff4642d126534c.tar.xz eclipse.platform.debug-492af0407faf9dc981b28d99abff4642d126534c.zip |
Bug 559070 - Fix resource related compiler warnings in platform.debug
Change-Id: If9102e5fcd24e7888596fd33a14ed5529419acc2
Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r-- | org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java | 20 | ||||
-rw-r--r-- | org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java | 7 |
2 files changed, 24 insertions, 3 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java index 34ffa88c3..48af576ff 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java @@ -236,6 +236,26 @@ public class IOConsolePartition implements ITypedRegion { return inputStream; } + /** + * Test if this partition belongs to the given input stream. + * + * @param in the input stream to test or <code>null</code> + * @return <code>true</code> if this partition belongs to input stream + */ + boolean belongsTo(IOConsoleInputStream in) { + return inputStream == in; + } + + /** + * Test if this partition belongs to the given output stream. + * + * @param out the output stream to test or <code>null</code> + * @return <code>true</code> if this partition belongs to output stream + */ + boolean belongsTo(IOConsoleOutputStream out) { + return outputStream == out; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(40); diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java index 3102a3ab0..f6df185ee 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java @@ -643,6 +643,7 @@ public class IOConsolePartitioner * and a new partition will start * @return the newly created partition (i.e. the right side of the split) */ + @SuppressWarnings("resource") // suppress wrong 'not closed' warnings private IOConsolePartition splitPartition(int offset) { final int partitionIndex = findPartitionCandidate(offset); final IOConsolePartition existingPartition = partitions.get(partitionIndex); @@ -861,7 +862,7 @@ public class IOConsolePartitioner Assert.isTrue(atOutputPartitionIndex == findPartitionCandidate(outputOffset - 1)); } } - if (atOutputPartition == null || atOutputPartition.getOutputStream() != pending.stream) { + if (atOutputPartition == null || !atOutputPartition.belongsTo(pending.stream)) { // no partitions yet or last partition is incompatible to reuse -> add new one atOutputPartition = new IOConsolePartition(outputOffset, pending.stream); partitions.add(atOutputPartition); @@ -904,7 +905,7 @@ public class IOConsolePartitioner atOutputPartition.getLength() - (outputOffset - atOutputPartition.getOffset())); Assert.isTrue(chunkLength > 0); // do not remove since it can prevent an infinity loop - if (atOutputPartition.getOutputStream() != pending.stream) { + if (!atOutputPartition.belongsTo(pending.stream)) { // new output is from other stream then overwritten output // Note: this implementation ignores the possibility to reuse the partition @@ -925,7 +926,7 @@ public class IOConsolePartitioner atOutputPartition = splitPartition(outputOffset); atOutputPartitionIndex++; } - if (outputPartition == null || outputPartition.getOutputStream() != pending.stream) { + if (outputPartition == null || !outputPartition.belongsTo(pending.stream)) { outputPartition = new IOConsolePartition(outputOffset, pending.stream); partitions.add(atOutputPartitionIndex, outputPartition); atOutputPartitionIndex++; |