Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Johnson2018-11-30 06:43:16 -0500
committerAndrew Johnson2018-11-30 06:43:16 -0500
commita09fad3a581c4717f533efb246fbe5b76532f58f (patch)
tree6e33c4178b0343760ce62c0f8b4ee61127160a5f
parent675412f3e160be7bb14a5e206c191fee56ec87a7 (diff)
downloadorg.eclipse.mat-a09fad3a581c4717f533efb246fbe5b76532f58f.tar.gz
org.eclipse.mat-a09fad3a581c4717f533efb246fbe5b76532f58f.tar.xz
org.eclipse.mat-a09fad3a581c4717f533efb246fbe5b76532f58f.zip
[541539] Simple batch mode comparison of two snapshots
Bug fix - error message for bad retained size filter Change-Id: I297e4ec8f06efbf5264bdb9518e075b8d8b5bcf5
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/query/RetainedSizeDerivedData.java39
-rw-r--r--plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/BytesFormat.java6
-rw-r--r--plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/internal/annotations.properties2
3 files changed, 43 insertions, 4 deletions
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/query/RetainedSizeDerivedData.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/query/RetainedSizeDerivedData.java
index 61a32019..d515168a 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/query/RetainedSizeDerivedData.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/query/RetainedSizeDerivedData.java
@@ -369,7 +369,11 @@ public class RetainedSizeDerivedData extends ContextDerivedData
@Override
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
{
- Long v = (Long) obj;
+ Number v;
+ if (obj instanceof Bytes)
+ v = ((Bytes)obj).getValue();
+ else
+ v = (Number) obj;
if (v.longValue() < 0)
{
@@ -379,14 +383,43 @@ public class RetainedSizeDerivedData extends ContextDerivedData
}
else
{
- return super.format(new Bytes(v), toAppendTo, pos);
+ return super.format(new Bytes(v.longValue()), toAppendTo, pos);
}
}
@Override
public Object parseObject(String source, ParsePosition pos)
{
- return null;
+ Object ret;
+ if (source.regionMatches(pos.getIndex(), Messages.RetainedSizeDerivedData_Approximate, 0, Messages.RetainedSizeDerivedData_Approximate.length()))
+ {
+ int pi = pos.getIndex();
+ pos.setIndex(pi + Messages.RetainedSizeDerivedData_Approximate.length());
+ ret = super.parseObject(source, pos);
+ if (ret != null)
+ {
+ long v;
+ if (ret instanceof Bytes)
+ {
+ v = ((Bytes)ret).getValue();
+ return new Bytes(-Math.abs(v));
+ }
+ else if (ret instanceof Number)
+ {
+ v = ((Number)ret).longValue();
+ return new Bytes(-Math.abs(v));
+ }
+ }
+ // >= in front of something else
+ pos.setErrorIndex(pi + Messages.RetainedSizeDerivedData_Approximate.length());
+ pos.setIndex(pi);
+ ret = null;
+ }
+ else
+ {
+ ret = super.parseObject(source, pos);
+ }
+ return ret;
}
}
diff --git a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/BytesFormat.java b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/BytesFormat.java
index 6722ce18..2caefbae 100644
--- a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/BytesFormat.java
+++ b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/BytesFormat.java
@@ -256,6 +256,7 @@ public class BytesFormat extends Format
if (currentDisplay != BytesDisplay.Bytes)
{
// Output formatting has units, so input should
+ int pi = pos.getIndex();
Object o1 = this.getDetailedFormat().parseObject(source, pos);
if (o1 instanceof Number)
{
@@ -285,9 +286,14 @@ public class BytesFormat extends Format
pos.setIndex(pos.getIndex() + 3);
return new Bytes((long)(n1.longValue() * GB));
}
+ pos.setErrorIndex(pos.getIndex());
+ pos.setIndex(pi);
// Given a format, but no suffix given
return null;
}
+ // Not parsed as a Number, so can't check the suffix
+ pos.setErrorIndex(pi);
+ pos.setIndex(pi);
return null;
}
else
diff --git a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/internal/annotations.properties b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/internal/annotations.properties
index a227dba9..7f577064 100644
--- a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/internal/annotations.properties
+++ b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/internal/annotations.properties
@@ -15,7 +15,7 @@ RunExternalTest.help = Hidden query to run a report defined in an external file.
RunExternalTest.testSuite.help = The file path of the report to be run.
RunExternalTest.params.help = Additional parameters for the report, as 'key=value'.
RunRegisterdReport.name = Run Registered Report
-RunRegisterdReport.help = Hidden query to run a report already register in a plugin.
+RunRegisterdReport.help = Hidden query to run a report already registered in a plugin.
RunRegisterdReport.extensionIdentifier.help = The bundle name and report extension identifier to find the report.\n\
The format is like: my.bundle.name:reportid
RunRegisterdReport.params.help = Additional parameters for the report, as 'key=value'.

Back to the top